예제 #1
0
def test_extract_cve(monkeypatch):
    with monkeypatch.context() as monkey:
        monkey.setattr(data_parsing.Path, 'read_text',
                       lambda *_, **__: '{"foo": "bar"}')
        monkey.setattr(data_parsing, 'extract_data_from_cve',
                       lambda root: root)
        assert data_parsing.extract_cve('') == {'foo': 'bar'}
예제 #2
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
예제 #3
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])