fix(ci): fix Trivy grep reading wrong stdin in scan scripts#395
Open
mdryaan wants to merge 1 commit into
Open
Conversation
Signed-off-by: mdryaan <alikhurshid4u@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Both
base-image-critical.shandbinary-image-critical.shused awhile read -r lineloop that redirected the scan file to the loop's stdin. Inside the loop,grep -o "CRITICAL: [0-9]*"received no file argument, so it consumed from that same shared stdin — not from$line, which was never passed to it. The CRITICAL summary was consumed byreadon the first iteration;grepsaw nothing and returned empty.$sumwas always 0 and the security gate never triggered regardless of actual CVE counts.Fixed by removing the
while readloop entirely and passing the scan file directly togrepas a file argument. All matches are captured in one pass; theexisting
for i in $xloop sums them correctly.Fixes #394
How Has This Been Tested?
/tmp/final.txtcontainingCRITICAL: 5, HIGH: 12, MEDIUM: 3, LOW: 1base image critical value is 0— gate does not fire (bug confirmed)base image critical value is 5+CRITICAL vulnerabilities found+Exit code: 1— gate fires correctly (fix verified)- The before line: OLD: base image critical value is 0 (expected 5)
- The after lines: base image critical value is 5 + CRITICAL vulnerabilities found + Exit code: 1
Checklist:
Does this PR introduce a breaking change for other components like worker-operator?
No