From 12e251ad47fabc8c01501b5ecb9ee846271c7455 Mon Sep 17 00:00:00 2001 From: Federico Barcelona Date: Thu, 19 Nov 2020 18:57:18 +0100 Subject: [PATCH] fix: Return the correct policyID and policyName in get_image_scanning_results --- sdcclient/_scanning.py | 2 ++ specs/secure/scanning/policy_evaluation_spec.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/sdcclient/_scanning.py b/sdcclient/_scanning.py index 93f32c30..d181f307 100644 --- a/sdcclient/_scanning.py +++ b/sdcclient/_scanning.py @@ -1279,6 +1279,8 @@ def get_image_scanning_results(self, image_name, policy_id=None): policy_results = [result for result in json_res["results"] if result["policyId"] == policy_id] if policy_results: filtered_result_by_policy_id = policy_results[0] + result["policy_id"] = filtered_result_by_policy_id["policyId"] + result["policy_name"] = filtered_result_by_policy_id["policyName"] result["total_stop"] = filtered_result_by_policy_id["nStop"] result["total_warn"] = filtered_result_by_policy_id["nWarn"] result["warn_results"] = [rule_result["checkOutput"] diff --git a/specs/secure/scanning/policy_evaluation_spec.py b/specs/secure/scanning/policy_evaluation_spec.py index 2010589b..c1336953 100644 --- a/specs/secure/scanning/policy_evaluation_spec.py +++ b/specs/secure/scanning/policy_evaluation_spec.py @@ -37,7 +37,7 @@ total_warn=be_above_or_equal(0), total_stop=be_above_or_equal(0), last_evaluation=be_an(datetime), status="pass", image_tag="docker.io/alpine:latest", - policy_id="*", policy_name="All policies", + policy_id="default", policy_name="DefaultPolicy", warn_results=not_(be_empty)) )