mirror of
https://github.com/cve-search/PyVulnerabilityLookup.git
synced 2024-11-25 16:27:23 +00:00
33 lines
1,009 B
Python
33 lines
1,009 B
Python
from __future__ import annotations
|
|
|
|
import argparse
|
|
import json
|
|
import sys
|
|
|
|
from typing import Any
|
|
|
|
from .api import PyVulnerabilityLookup
|
|
|
|
__all__ = ['PyVulnerabilityLookup']
|
|
|
|
|
|
def main() -> None:
|
|
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)
|
|
|
|
response: bool | dict[str, Any]
|
|
|
|
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))
|