-
Notifications
You must be signed in to change notification settings - Fork 106
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Restore scan in CI-PR and Provide alternative Trivy repo. (#578)
Added enviromental variables with multiple trivy repos. Restore scan after build. Backported scan folders from main. Added action to install Trivy.
- Loading branch information
Corneil du Plessis
authored
Nov 20, 2024
1 parent
bcc0cd4
commit d147451
Showing
4 changed files
with
62 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/bin/bash | ||
SCDIR=$(dirname "$(readlink -f "${BASH_SOURCE[0]}")") | ||
SCDIR=$(realpath $SCDIR) | ||
if [ -f $SCDIR/runs.sarif ]; then | ||
rm $SCDIR/runs.sarif | ||
fi | ||
export TRIVY_UPLOAD=true | ||
while [ "$1" != "" ]; do | ||
if [ "$1" == "table" ]; then | ||
export TRIVY_UPLOAD=false | ||
fi | ||
shift | ||
done | ||
REAL_PATH=$(realpath $PWD) | ||
echo "Scanning in $REAL_PATH" | ||
find . -type d -name target -exec bash "$SCDIR/scan-jars.sh" '{}' \; | ||
echo "{\"version\": \"2.1.0\", \"\$schema\": \"https://raw.githubusercontent.com/oasis-tcs/sarif-spec/master/Schemata/sarif-schema-2.1.0.json\", \"runs\": [" > "$SCDIR/scan.sarif" | ||
if [ -f "$SCDIR/runs.sarif" ]; then | ||
cat "$SCDIR/runs.sarif" >> "$SCDIR/scan.sarif" | ||
fi | ||
echo "]}" >> "$SCDIR/scan.sarif" | ||
echo "Created $SCDIR/scan.sarif" |
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,24 @@ | ||
#!/bin/bash | ||
SCDIR=$(dirname "$(readlink -f "${BASH_SOURCE[0]}")") | ||
SCDIR=$(realpath $SCDIR) | ||
if [[ "$1" != *"-sources.jar" ]] && [[ "$1" != *"-javadoc.jar" ]]; then | ||
if [ "$TRIVY_UPLOAD" == "true" ]; then | ||
echo "Scanning:$1" | ||
echo "trivy rootfs --format sarif -o \"$1.sarif\" \"$1\"" | ||
trivy rootfs --format sarif -o "$1.sarif" "$1" | ||
if [ -f "$1.sarif" ]; then | ||
if [ -f $SCDIR/runs.sarif ]; then | ||
echo "," >> "$SCDIR/runs.sarif" | ||
fi | ||
jq -c '.runs | .[]' "$1.sarif" >> "$SCDIR/runs.sarif" | ||
else | ||
echo "Could not find:$1.sarif" | ||
fi | ||
else | ||
trivy rootfs -q "$1" | ||
fi | ||
else | ||
if [ "$TRIVY_UPLOAD" == "true" ]; then | ||
echo "Skipping $1" | ||
fi | ||
fi |
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,7 @@ | ||
#!/bin/bash | ||
SCDIR=$(dirname "$(readlink -f "${BASH_SOURCE[0]}")") | ||
SCDIR=$(realpath $SCDIR) | ||
if [ "$TRIVY_UPLOAD" == "true" ]; then | ||
echo "Scanning $1" | ||
fi | ||
find $1 -type f -name "*.jar" -exec bash "$SCDIR/scan-jar.sh" '{}' \; |