示例#1
0
def extract_data_from_cve(root: dict) -> Tuple[List[CveEntry], List[CveSummaryEntry]]:
    cve_list, summary_list = [], []
    for feed in root['CVE_Items']:
        cve_id = feed['cve']['CVE_data_meta']['ID']
        summary = feed['cve']['description']['description_data'][0]['value']
        impact = extract_cve_impact(feed['impact']) if 'impact' in feed else {}
        if feed['configurations']['nodes']:
            cpe_entries = list(set(extract_cpe_data_from_cve(feed['configurations']['nodes'])))
            cve_list.append(CveEntry(cve_id=cve_id, impact=impact, cpe_list=cpe_entries))
        elif not summary.startswith('** REJECT **'):
            summary_list.append(CveSummaryEntry(cve_id=cve_id, summary=summary, impact=impact))
    return cve_list, summary_list
    ('CVE-2018-8825', 2018,
     'Google TensorFlow 1.7 and below is affected by: Buffer Overflow. The impact is: execute arbitrary code (local).',
     'N/A', 'N/A')
]

EXPECTED_GET_CVE_FEEDS_UPDATE_CONTENT = [
    CveEntry(
        cve_id='CVE-2012-0001',
        impact={'cvssV2': 9.3},
        cpe_list=[
            ('cpe:2.3:o:microsoft:windows_xp:*:sp2:professional_x64:*:*:*:*:*', '', '', '', ''),
            ('cpe:2.3:o:microsoft:windows_server_2008:r2:*:itanium:*:*:*:*:*', '', '', '', ''),
            ('cpe:2.3:o:microsoft:windows_server_2008:r2:*:x64:*:*:*:*:*', '', '', '', ''),
            ('cpe:2.3:o:microsoft:windows_server_2003:*:sp2:*:*:*:*:*:*', '', '', '', ''),
            ('cpe:2.3:o:microsoft:windows_server_2008:-:sp2:itanium:*:*:*:*:*', '', '', '', ''),
            ('cpe:2.3:o:microsoft:windows_7:-:*:*:*:*:*:*:*', '', '', '', ''),
            ('cpe:2.3:o:microsoft:windows_7:-:sp1:x64:*:*:*:*:*', '', '', '', ''),
            ('cpe:2.3:o:microsoft:windows_server_2008:r2:sp1:itanium:*:*:*:*:*', '', '', '', ''),
            ('cpe:2.3:o:microsoft:windows_vista:*:sp2:x64:*:*:*:*:*', '', '', '', ''),
            ('cpe:2.3:o:microsoft:windows_7:-:sp1:x86:*:*:*:*:*', '', '', '', ''),
            ('cpe:2.3:o:microsoft:windows_server_2008:r2:sp1:x64:*:*:*:*:*', '', '', '', ''),
            ('cpe:2.3:o:microsoft:windows_vista:*:sp2:*:*:*:*:*:*', '', '', '', ''),
            ('cpe:2.3:o:microsoft:windows_server_2008:*:sp2:x64:*:*:*:*:*', '', '', '', ''),
            ('cpe:2.3:o:microsoft:windows_server_2008:*:sp2:x32:*:*:*:*:*', '', '', '', '')
        ]
    ),
    CveEntry(
        cve_id='CVE-2018-0010',
        impact={'cvssV2': 4.3},
        cpe_list=[
            ('cpe:2.3:a:microsoft:ie:6:*:*:*:*:*:*:*', '', '', '', ''),
            ('cpe:2.3:a:microsoft:ie:8:*:*:*:*:*:*:*', '', '', '', ''),