From e71f29ea5212447450cfb5a0db8d58aacb0111c9 Mon Sep 17 00:00:00 2001 From: Miaha Cybersec Date: Thu, 25 Jul 2024 12:19:09 -0600 Subject: [PATCH] Refactor error handling Signed-off-by: Miaha Cybersec --- integration/patch_test.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/integration/patch_test.go b/integration/patch_test.go index 101517e1..7bfd2a81 100644 --- a/integration/patch_test.go +++ b/integration/patch_test.go @@ -94,7 +94,10 @@ func TestPatch(t *testing.T) { t.Log("patching image") patch(t, ref, tagPatched, dir, img.IgnoreErrors, reportFile) - if reportFile { + switch { + case strings.Contains(img.Image, "oracle"): + t.Log("Oracle image detected. Skipping Trivy scan.") + case reportFile: t.Log("scanning patched image") scanner(). withIgnoreFile(ignoreFile). @@ -102,9 +105,7 @@ func TestPatch(t *testing.T) { // here we want a non-zero exit code because we are expecting no vulnerabilities. withExitCode(1). scan(t, patchedRef, img.IgnoreErrors) - } else if strings.Contains(img.Image, "oracle") { - t.Log("Oracle image detected. Skipping Trivy scan.") - } else { + default: t.Log("scanning patched image") scanner(). withIgnoreFile(ignoreFile). @@ -114,7 +115,7 @@ func TestPatch(t *testing.T) { } // currently validation is only present when patching with a scan report - if reportFile { + if reportFile && !strings.Contains(img.Image, "oracle") { t.Log("verifying the vex output") validVEXJSON(t, dir) }