PyVulnerabilityLookup/pyvulnerabilitylookup/__init__.py
2023-05-19 15:21:11 +02:00

25 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))