def vendor_frequency(): """ Get Vendor frequency from CPE :return: Vendor Frequency from CPE """ datapipeline = DataPipeline() datapipeline.query_vendor_frequency()
def product_frequency(): """ Get Product frequency from CPE :return: """ datapipeline = DataPipeline() datapipeline.query_product_frequency()
def populate_cpes(cpe_entries): """ Save CPEs to database :param cpe_entries: CPEs as list of dictionaries. :return: None """ print("[+]Writing to database") pipeline = DataPipeline() pipeline.process_cpe_many(cpe_entries)
def search_vulnerabilities(cveid, search_limit): """ Seach for Vulnerability information :param cveid: CVE Identifier :param search_limit: Numberical quantity to limit search results :return: JSON object with results """ datapileline = DataPipeline() # Add validation if not validate_cve(cveid): sys.exit(print("Invalid CVEID")) results = datapileline.query_cve(cveid, search_limit) return print_json(results)
def search_vulnerable_products(cpeid, search_limit): """ Search for vulnerability information with CPE URI :param cpeid: CPE 2.2 URI :param search_limit: Numerical quantity to limit search results :return: """ datapileline = DataPipeline() # Add validation if not validate_cpe(cpeid): sys.exit(print("Invalid CPEID")) results = datapileline.query_cpe(cpeid, search_limit) return print_json(results)
def search_by_year(year, search_limit): """ Search vulnerabilities by Year :param year: Numerical quantity to represent year :param search_limit: Numerical quantity to limit Search results. :return: JSON Object with results """ year_string = str(year) search_query = 'CVE-' + year_string + '-%' datapileline = DataPipeline() # Add validation if not validate_year(search_query): sys.exit(print("Invalid Year")) results = datapileline.query_year(search_query, search_limit) return print_json(results)
def start_cve_population(): """ Initiate CVE Population Dummy function to start CVE population - For export outside the module :return: None """ feeds = get_cve_feeds() feeds = list(set(feeds)) feeds.sort() pipeline = DataPipeline() cleanup() for feed in feeds: filename = download_xml_zip(feed) populate_cve(filename, pipeline) cleanup() print("[+]CVEs Populated")
def update_cve_dictionary(): """ Update CVEs in the database :return: None """ print("[+] Updating CVE Dictionary") feeds = list(set(get_cve_feeds())) feeds.sort() update_feeds = [] pipeline = DataPipeline() cleanup() for feed in feeds: if 'Modified' in feed: update_feeds.append(feed) elif 'Recent' in feed: update_feeds.append(feed) else: pass for update_feed in update_feeds: filename = download_xml_zip(update_feed) populate_cve(filename, pipeline) cleanup() print("[+]CVEs Updated")