mirror of
https://github.com/cve-search/PyVulnerabilityLookup.git
synced 2024-11-25 16:27:23 +00:00
26 lines
867 B
Python
26 lines
867 B
Python
|
import argparse
|
||
|
import json
|
||
|
import sys
|
||
|
|
||
|
from .api import PyVulnerabilityLookup
|
||
|
|
||
|
|
||
|
def main():
|
||
|
parser = argparse.ArgumentParser(description='Query a thing.')
|
||
|
parser.add_argument('--url', type=str, required=True, help='URL of the instance.')
|
||
|
group = parser.add_mutually_exclusive_group(required=True)
|
||
|
group.add_argument('--redis_up', action='store_true', help='Check if redis is up.')
|
||
|
group.add_argument('--vulnerability', type=str, help='Get a vulnerability.')
|
||
|
args = parser.parse_args()
|
||
|
|
||
|
client = PyVulnerabilityLookup(args.url)
|
||
|
|
||
|
if not client.is_up:
|
||
|
print(f'Unable to reach {client.root_url}. Is the server up?')
|
||
|
sys.exit(1)
|
||
|
if args.redis_up:
|
||
|
response = client.redis_up()
|
||
|
elif args.vulnerability:
|
||
|
response = client.get_vulnerability(args.vulnerability)
|
||
|
print(json.dumps(response, indent=2))
|