From 28a1e669bc73e344bfe959f70b9481cfb3a0224c Mon Sep 17 00:00:00 2001 From: jperezde Date: Tue, 10 Oct 2023 17:53:50 +0200 Subject: [PATCH] csmock-snyk-plugin: no supported projects fix Fix: https://issues.redhat.com/browse/OSH-329 If no supported project is detected using the snyk plugin, it no longer crashes but it does return 0 --- py/plugins/snyk.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/py/plugins/snyk.py b/py/plugins/snyk.py index f5715b9..35af4cd 100644 --- a/py/plugins/snyk.py +++ b/py/plugins/snyk.py @@ -170,7 +170,11 @@ def scan_hook(results, mock, props): mock.exec_chroot_cmd("/bin/rm -fv %s" % auth_token_dst) # check exit code of snyk code itself - if ec not in [0, 1]: + if ec == 3: + # If there are no supported project, we just return a successful scan without results + results.print_with_ts("snyk-code: no supported projects detected") + return 0 + elif ec not in [0, 1]: results.error("snyk code returned unexpected exit status: %d" % ec, ec=ec) # returning non-zero would prevent csmock from archiving SNYK_LOG