示例#1
0
def get_cve_import_content(cve_extraction_path: str, year_selection: list) -> Tuple[list, list]:
    cve_list, summary_list = list(), list()
    dp.download_cve(cve_extraction_path, years=year_selection)
    for file in get_cve_json_files(cve_extraction_path):
        cve_data, summary_data = dp.extract_cve(file)
        cve_list.extend(cve_data)
        summary_list.extend(summary_data)

    return cve_list, summary_list
示例#2
0
def test_download_cve():
    data_parsing.download_cve(download_path='.',
                              years=DOWNLOAD_DATA_YEAR_INPUT,
                              update=False)
    assert set(DOWNLOAD_CVE_EXPECTED) == set(glob('nvdcve-1.0-*.json'))
    data_parsing.download_cve(download_path='.',
                              years=DOWNLOAD_DATA_YEAR_INPUT,
                              update=True)
    assert DOWNLOAD_UPDATE_EXPECTED == glob('nvdcve-1.0-modified.json')
示例#3
0
def update_cve_repository(cve_extract_path: str):
    if not table_exists(table_name='cve_table'):
        raise CveLookupException('CVE tables do not exist! Did you mean import CVE?')
    dp.download_cve(cve_extract_path, update=True)
    cve_list, summary_list = get_cve_update_content(cve_extraction_path=cve_extract_path)

    init_cve_feeds_table(cve_list=cve_list, table_name='temp_feeds')
    update_cve_feeds()

    if summary_list:
        init_cve_summaries_table(summary_list=summary_list, table_name='temp_sum')
        update_cve_summaries()
        drop_table(table_name='temp_sum')

    drop_table(table_name='temp_feeds')
示例#4
0
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])