Esempio n. 1
0
def download_cpe(download_path: str):
    if not CPE_URL:
        raise CveLookupException('Error: No CPE URL provided. Check metadata.json if required URL is set.')
    process_url(CPE_URL, download_path)
def get_cpe_content(path: str) -> list:
    dp.download_cpe(download_path=path)
    if not glob(path + '*.xml'):
        raise CveLookupException('Glob has found none of the specified files!')
    return dp.extract_cpe(glob(path + '*.xml')[0])
Esempio n. 3
0
def import_cpe(cpe_extract_path: str):
    if table_exists(table_name='cpe_table'):
        raise CveLookupException('CPE table does already exist')
    create(query='create_cpe_table', table_name='cpe_table')
    insert_into(query='insert_cpe', table_name='cpe_table', input_data=setup_cpe_table(get_cpe_content(path=cpe_extract_path)))
def get_cve_update_content(cve_extraction_path: str) -> Tuple[list, list]:
    dp.download_cve(cve_extraction_path, update=True)
    cve_json_files = get_cve_json_files(cve_extraction_path)
    if not cve_json_files:
        raise CveLookupException('Glob has found none of the specified files!')
    return dp.extract_cve(cve_json_files[0])
Esempio n. 5
0
def update_cpe(cpe_extract_path: str):
    if not table_exists(table_name='cpe_table'):
        raise CveLookupException('CPE table does not exist! Did you mean import CPE?')
    drop_table(table_name='cpe_table')
    create(query='create_cpe_table', table_name='cpe_table')
    insert_into(query='insert_cpe', table_name='cpe_table', input_data=setup_cpe_table(get_cpe_content(path=cpe_extract_path)))