Skip to content

Commit 73f6ca3

Browse files
authored
Update trivy scan (#104)
1 parent f7fe48b commit 73f6ca3

File tree

1 file changed

+29
-6
lines changed

1 file changed

+29
-6
lines changed

.github/workflows/build-trivy.yaml

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,38 @@ jobs:
4848
with:
4949
fetch-depth: 0
5050

51-
- name: Set up JDK
52-
uses: actions/setup-java@v4
53-
with:
54-
java-version: '11'
55-
distribution: 'zulu'
51+
- name: Setup oras
52+
run: |
53+
VERSION="1.2.0"
54+
curl -LO "https://github.com/oras-project/oras/releases/download/v${VERSION}/oras_${VERSION}_linux_amd64.tar.gz"
55+
mkdir -p oras-install/
56+
tar -zxf oras_${VERSION}_*.tar.gz -C oras-install/
57+
sudo mv oras-install/oras /usr/local/bin/
58+
rm -rf oras_${VERSION}_*.tar.gz oras-install/
59+
60+
- name: Get current date
61+
id: date
62+
run: echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT
63+
64+
- name: Download and extract the vulnerability DB
65+
run: |
66+
mkdir -p $GITHUB_WORKSPACE/.cache/trivy/db
67+
oras pull ghcr.io/aquasecurity/trivy-db:2
68+
tar -xzf db.tar.gz -C $GITHUB_WORKSPACE/.cache/trivy/db
69+
rm db.tar.gz
70+
71+
- name: Download and extract the Java DB
72+
run: |
73+
mkdir -p $GITHUB_WORKSPACE/.cache/trivy/java-db
74+
oras pull ghcr.io/aquasecurity/trivy-java-db:1
75+
tar -xzf javadb.tar.gz -C $GITHUB_WORKSPACE/.cache/trivy/java-db
76+
rm javadb.tar.gz
5677
5778
- name: Trivy Scan
5879
shell: bash
5980
run: |
6081
DIR=`mktemp -d`
6182
curl -sfL https://raw.githubusercontent.com/aquasecurity/trivy/main/contrib/install.sh | sh -s -- -b ${DIR} v0.51.2
62-
${DIR}/trivy fs --exit-code 1 .
83+
echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $ --password-stdin
84+
export TRIVY_CACHE=$GITHUB_WORKSPACE/.cache/trivy
85+
${DIR}/trivy fs --cache-dir ${TRIVY_CACHE} --exit-code 1 .

0 commit comments

Comments
 (0)