def test_get_cves_by_date_ecosystem_remove(mocker): """Test getting CVEs by date and ecosystem.""" mocker.return_value = mock_response = Mock() mock_response.json.return_value = mocker_input cve = CveByDateEcosystemUtils('20180911', 'npm') response = cve.get_cves_by_date_ecosystem() assert response assert 'remove' in response assert response['remove'][0]['cve_id'] == 'CVE-2018-0002' assert 'ecosystem' in response['remove'][0] assert response['remove'][0]['ecosystem'] == 'npm'
def test_get_epvs_by_cve(mocker): """Test getting CVEs by date and ecosystem.""" mocker.return_value = mock_response = Mock() mock_response.json.return_value = mocker_input_epv cve = CveByDateEcosystemUtils('CVE-2019-0542') response = cve.get_cves_epv_by_date() assert response assert 'add' in response assert 'name' in response['add'][0] assert response['add'][0]['name'] == 'xterm' assert 'version' in response['add'][0] assert response['add'][0]['version'] == '2.9.2'
def test_cve_get_by_date_valid(mocker): """Test getting CVEs for (date).""" mocker.return_value = mock_response = Mock() mock_response.json.return_value = mocker_input cve = CveByDateEcosystemUtils('20160911') response = cve.get_cves_by_date() assert response assert 'add' in response assert response['add'][0]['cve_id'] == 'CVE-2018-0001' assert 'ecosystem' in response['add'][0] assert 'name' in response['add'][0] assert 'version' in response['add'][0]
def test_get_cves_by_date_ecosystem_add(mocker): """Test getting CVEs by date and ecosystem.""" mocker.return_value = mock_response = Mock() mock_response.json.return_value = mocker_input cve = CveByDateEcosystemUtils('20180911', 'maven') response = cve.get_cves_by_date_ecosystem() assert response assert 'add' in response assert response['add'][0]['cve_id'] == 'CVE-2018-0001' assert 'ecosystem' in response['add'][0] assert response['add'][0]['ecosystem'] == 'maven' assert 'name' in response['add'][0] assert 'version' in response['add'][0]
def test_get_cves_by_date_ecosystem_add(mocker): """Test getting CVEs by date and ecosystem.""" mocker.return_value = mock_response = Mock() mock_response.json.return_value = mocker_input_cve cve = CveByDateEcosystemUtils(None, 'all', '20190509', 'npm', 2) response = cve.get_cves_by_date_ecosystem() assert response assert 'add' in response assert response['add'][0]['cve_id'] == 'CVE-2019-0542' assert 'ecosystem' in response['add'][0] assert response['add'][0]['ecosystem'] == 'npm' assert 'cvss_v2' in response['add'][0] assert 'fixed_in' in response['add'][0] assert 'link' in response['add'][0] assert response['add'][0]['link'] == "https://nvd.nist.gov/vuln/detail/CVE-2019-0542"