From 7dc18eab68a3df6dece3d261e0c2730c558dfdf3 Mon Sep 17 00:00:00 2001 From: Daniel Sanche Date: Wed, 22 Apr 2020 18:13:25 -0700 Subject: [PATCH] [container analysis] effective severity [(#3478)](https://github.com/GoogleCloudPlatform/python-docs-samples/issues/3478) Use new effective_severity field fixes b/142836422 --- samples/snippets/samples.py | 2 +- samples/snippets/samples_test.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/samples/snippets/samples.py b/samples/snippets/samples.py index 9a3edc4..2eeda1c 100644 --- a/samples/snippets/samples.py +++ b/samples/snippets/samples.py @@ -367,7 +367,7 @@ def find_high_severity_vulnerabilities_for_image(resource_url, project_id): vulnerabilities = grafeas_client.list_occurrences(project_name, filter_str) filtered_list = [] for v in vulnerabilities: - if v.severity == Severity.HIGH or v.severity == Severity.CRITICAL: + if v.effective_severity == Severity.HIGH or v.effective_severity == Severity.CRITICAL: filtered_list.append(v) return filtered_list # [END containeranalysis_filter_vulnerability_occurrences] diff --git a/samples/snippets/samples_test.py b/samples/snippets/samples_test.py index b8eb6c5..0476883 100644 --- a/samples/snippets/samples_test.py +++ b/samples/snippets/samples_test.py @@ -278,6 +278,7 @@ def test_find_high_severity_vulnerabilities(self): 'note_name': client.note_path(PROJECT_ID, note_id), 'resource_uri': self.image_url, 'vulnerability': { + 'effective_severity': Severity.CRITICAL, 'package_issue': [ { 'affected_cpe_uri': 'your-uri-here',