def main(parsed_args): if parsed_args.is_initialization_required(): # Init db db_composer = DBComposer() db_composer.compose_vuln_db() elif parsed_args.get_cve(): # Get product from CVE m = MongoDbDriver() print( json.dumps(m.get_products_from_CVE(parsed_args.get_cve()), sort_keys=True, indent=4)) elif parsed_args.get_bid(): # Get product from BID m = MongoDbDriver() print( json.dumps(m.get_products_from_BID(parsed_args.get_bid()), sort_keys=True, indent=4)) else: m = MongoDbDriver() if parsed_args.is_only_product_check(): # Checks if vulnerabilities exists print( m.has_vulnerabilities(parsed_args.get_product(), parsed_args.get_product_version())) else: # Gets cves print( json.dumps(m.get_vulnerabilities( parsed_args.get_product(), parsed_args.get_product_version()), sort_keys=True, indent=4))
def check_cves(product, version): m = MongoDbDriver() if m.has_vulnerabilities(product, version): return 'VULN' else: return 'OK'