-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from neuvector/NVSHAS-8797-support-exempt-vulne…
…rability [NVSHAS-8797] Support NeuVector accepts vulnerability when using GitHub Actions scans
- Loading branch information
Showing
6 changed files
with
68 additions
and
23 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#!/usr/bin/env bash | ||
|
||
function filterOutExemptCVEsFromJson() { | ||
local scanResult="$1" | ||
local exemptCVEsJson="$2" | ||
|
||
local filterJson="$(cat "$scanResult")" | ||
|
||
# Filter out the exempted CVEs from the top-level vulnerabilities array | ||
filterJson=$(jq --argjson exemptions "$exemptCVEsJson" ' | ||
.report.vulnerabilities |= map(select(.name as $name | $exemptions | index($name) | not)) | ||
' <<<"$filterJson") | ||
|
||
# Filter out the exempted CVEs from the cves array in each module | ||
filterJson=$(jq --argjson exemptions "$exemptCVEsJson" ' | ||
.report.modules |= map( | ||
if .cves then | ||
.cves |= map(select(.name as $name | $exemptions | index($name) | not)) | ||
else | ||
. | ||
end | ||
) | ||
' <<<"$filterJson") | ||
|
||
if [ -n "$filterJson" ]; then | ||
echo "$filterJson" > "$scanResult" | ||
else | ||
echo "Error: Filtered Scan result JSON is empty. The original file will not be modified." | ||
exit 1 | ||
fi | ||
} |