Skip to content

Commit

Permalink
Fix critical vulnerability counter (#2712)
Browse files Browse the repository at this point in the history
  • Loading branch information
madelondohmen authored and dekkers committed Apr 1, 2024
1 parent 52f99ac commit 99f923c
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,7 @@ def is_mail_compliant(result):
recommendations = list(set(filter(None, recommendations)))
total_ips = len(unique_ips)
total_hostnames = len(unique_hostnames)
total_criticals = sum(vulnerability["summary"]["total_criticals"] for vulnerability in vulnerabilities.values())

summary = {
# _("General recommendations"): "",
Expand Down
28 changes: 27 additions & 1 deletion rocky/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,19 @@ def software() -> Software:
return Software(name="DICOM")


@pytest.fixture
def cve_finding_type_2023_38408() -> CVEFindingType:
return CVEFindingType(
id="CVE-2023-38408",
description="The PKCS#11 feature in ssh-agent in OpenSSH before 9.3p2 has an insufficiently "
"trustworthy search path, leading to remote code execution if an agent is forwarded to an "
"attacker-controlled system. ",
source="https://cve.circl.lu/cve/CVE-2023-38408",
risk_score=9.8,
risk_severity=RiskLevelSeverity.CRITICAL,
)


@pytest.fixture
def cve_finding_type_2019_8331() -> CVEFindingType:
return CVEFindingType(
Expand All @@ -515,6 +528,19 @@ def cve_finding_type_2019_2019() -> CVEFindingType:
)


@pytest.fixture
def cve_finding_2023_38408() -> Finding:
return Finding(
finding_type=Reference.from_str("CVEFindingType|CVE-2023-38408"),
ooi=Reference.from_str(
"Finding|SoftwareInstance|HostnameHTTPURL|https|internet|mispo.es|443|/|Software|Bootstrap|3.3.7|cpe:/a:getbootstrap:bootstrap|CVE-2023-38408"
),
proof=None,
description="Vulnerability CVE-2023-38408 detected",
reproduce=None,
)


@pytest.fixture
def cve_finding_2019_8331() -> Finding:
return Finding(
Expand Down Expand Up @@ -545,7 +571,7 @@ def cve_finding_2019_2019() -> Finding:
def cve_finding_type_no_score() -> CVEFindingType:
return CVEFindingType(
id="CVE-0000-0001",
description="CVE Finding without scopre",
description="CVE Finding without score",
source="https://cve.circl.lu/cve/CVE-0000-0001",
risk_severity=RiskLevelSeverity.UNKNOWN,
)
Expand Down
13 changes: 7 additions & 6 deletions rocky/tests/reports/test_vulnerability_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ def test_vulnerability_report_finding_no_score(
valid_time,
ipaddressv4,
hostname,
cve_finding_2019_8331,
cve_finding_type_2019_8331,
cve_finding_2023_38408,
cve_finding_type_2023_38408,
cve_finding_no_score,
cve_finding_type_no_score,
):
Expand All @@ -90,20 +90,21 @@ def test_vulnerability_report_finding_no_score(
},
"IPAddress.<address [is ResolvedHostname]"
".hostname.<netloc [is HostnameHTTPURL].<ooi [is SoftwareInstance].<ooi [is Finding]": {
ipaddressv4.reference: [cve_finding_2019_8331, cve_finding_no_score],
ipaddressv4.reference: [cve_finding_2023_38408, cve_finding_no_score],
},
"IPAddress.<address [is ResolvedHostname]"
".hostname.<netloc [is HostnameHTTPURL].<ooi [is SoftwareInstance].<ooi [is Finding].finding_type": {
ipaddressv4.reference: [cve_finding_type_2019_8331, cve_finding_type_no_score],
ipaddressv4.reference: [cve_finding_type_2023_38408, cve_finding_type_no_score],
},
}

report = VulnerabilityReport(mock_octopoes_api_connector)

data = report.collect_data([str(hostname.reference)], valid_time)[str(hostname.reference)]

assert data[str(ipaddressv4.reference)]["vulnerabilities"]["CVE-2019-8331"]["cvss"]["score"] == 6.1
assert data[str(ipaddressv4.reference)]["summary"]["total_criticals"] == 0
assert data[str(ipaddressv4.reference)]["vulnerabilities"]["CVE-2023-38408"]["cvss"]["score"] == 9.8
assert data[str(ipaddressv4.reference)]["vulnerabilities"]["CVE-0000-0001"]["cvss"]["score"] is None
assert data[str(ipaddressv4.reference)]["summary"]["total_criticals"] == 1
assert data[str(ipaddressv4.reference)]["summary"]["total_findings"] == 2


Expand Down

0 comments on commit 99f923c

Please sign in to comment.