Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix critical vulnerability counter #2712

Merged
merged 3 commits into from
Mar 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -501,6 +501,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 @@ -527,6 +540,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 @@ -557,7 +583,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