From a253eb88991790c7cf69cee971e26b48a7dcb499 Mon Sep 17 00:00:00 2001 From: Adam Varsano Date: Tue, 4 Jul 2023 16:39:13 +0300 Subject: [PATCH] fix tests --- checkov/common/sca/output.py | 6 +++--- checkov/common/typing.py | 3 ++- tests/sca_package_2/test_runner.py | 4 ++-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/checkov/common/sca/output.py b/checkov/common/sca/output.py index 5711b0dcc85..d60e5294397 100644 --- a/checkov/common/sca/output.py +++ b/checkov/common/sca/output.py @@ -436,7 +436,7 @@ def add_cve_record_to_report(vulnerability_details: dict[str, Any], package_name used_private_registry=used_private_registry ) suppressed = apply_cves_inline_suppressions( - record=cve_record, vulnerability_details=vulnerability_details, inline_suppressions_maps=inline_suppressions_maps + record=cve_record, inline_suppressions_maps=inline_suppressions_maps ) if not suppressed and not runner_filter.should_run_check( @@ -458,13 +458,13 @@ def add_cve_record_to_report(vulnerability_details: dict[str, Any], package_name def apply_cves_inline_suppressions( - record: Record, vulnerability_details: dict[str, Any], inline_suppressions_maps: _ScaSuppressionsMaps | None = None + record: Record, inline_suppressions_maps: _ScaSuppressionsMaps | None = None ) -> bool: """Applies the inline suppression and returns an accomplish status""" if inline_suppressions_maps: if inline_suppressions_maps.get("cve_by_cve_map"): - cve_suppression = inline_suppressions_maps["cve_by_cve_map"].get(vulnerability_details.get("cveId", "")) + cve_suppression = inline_suppressions_maps["cve_by_cve_map"].get(record.vulnerability_details.get("id", "")) if cve_suppression: record.check_result = { "result": CheckResult.SKIPPED, diff --git a/checkov/common/typing.py b/checkov/common/typing.py index 72d0cb4cb76..6cc85d6fa2e 100644 --- a/checkov/common/typing.py +++ b/checkov/common/typing.py @@ -44,10 +44,11 @@ class _SkippedCheck(TypedDict, total=False): class _ScaSuppressionsMaps(TypedDict, total=False): - cve_by_cve_map: dict[str, _SuppressedCves] + cve_by_cveap: dict[str, _SuppressedCves] licenses_by_policy_and_package_map: dict[str, _SuppressedLicenses] +# _ScaSuppressions fields are in camel case because this is the output of the server report class _ScaSuppressions(TypedDict, total=False): cves: _CvesSuppressions licenses: _LicensesSuppressions diff --git a/tests/sca_package_2/test_runner.py b/tests/sca_package_2/test_runner.py index 7e2d865f7a5..8e5fc4b61c8 100644 --- a/tests/sca_package_2/test_runner.py +++ b/tests/sca_package_2/test_runner.py @@ -126,8 +126,8 @@ def test_run(sca_package_2_report): } assert len(report.passed_checks) == 3 - assert len(report.failed_checks) == 9 - assert len(report.skipped_checks) == 1 + assert len(report.failed_checks) == 7 + assert len(report.skipped_checks) == 3 assert len(report.parsing_errors) == 0 cve_record = next((c for c in report.failed_checks if