Skip to content

Commit 7b55c07

Browse files
author
Tim Middleton
authored
Update to use trivy action (#249)
* Update to use trivy action * Minor fix
1 parent eec9a1b commit 7b55c07

File tree

2 files changed

+6
-45
lines changed

2 files changed

+6
-45
lines changed

.github/workflows/build-trivy.yaml

Lines changed: 6 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -27,36 +27,9 @@ jobs:
2727
with:
2828
fetch-depth: 0
2929

30-
- name: Setup oras
31-
run: |
32-
VERSION="1.2.0"
33-
curl -LO "https://github.com/oras-project/oras/releases/download/v${VERSION}/oras_${VERSION}_linux_amd64.tar.gz"
34-
mkdir -p oras-install/
35-
tar -zxf oras_${VERSION}_*.tar.gz -C oras-install/
36-
sudo mv oras-install/oras /usr/local/bin/
37-
rm -rf oras_${VERSION}_*.tar.gz oras-install/
38-
39-
- name: Get current date
40-
id: date
41-
run: echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT
42-
43-
- name: Download and extract the vulnerability DB
44-
run: |
45-
mkdir -p $GITHUB_WORKSPACE/.cache/trivy/db
46-
oras pull ghcr.io/aquasecurity/trivy-db:2
47-
tar -xzf db.tar.gz -C $GITHUB_WORKSPACE/.cache/trivy/db
48-
rm db.tar.gz
49-
50-
- name: Download and extract the Java DB
51-
run: |
52-
mkdir -p $GITHUB_WORKSPACE/.cache/trivy/java-db
53-
oras pull ghcr.io/aquasecurity/trivy-java-db:1
54-
tar -xzf javadb.tar.gz -C $GITHUB_WORKSPACE/.cache/trivy/java-db
55-
rm javadb.tar.gz
56-
57-
- name: Trivy Scan
58-
shell: bash
59-
run: |
60-
echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $ --password-stdin
61-
export TRIVY_CACHE=$GITHUB_WORKSPACE/.cache/trivy
62-
make trivy-scan
30+
- name: Run Trivy vulnerability scanner to scan repo
31+
uses: aquasecurity/trivy-action@0.29.0
32+
with:
33+
scan-type: 'fs'
34+
skip-dirs: 'java'
35+
exit-code: 1

Makefile

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -395,10 +395,6 @@ golangci: $(TOOLS_BIN)/golangci-lint ## Go code review
395395
# ======================================================================================================================
396396
##@ Miscellaneous
397397

398-
.PHONY: trivy-scan
399-
trivy-scan: gettrivy ## Scan the CLI using trivy
400-
$(TOOLS_BIN)/trivy fs --cache-dir ${TRIVY_CACHE} --exit-code 1 .
401-
402398
# ======================================================================================================================
403399
# Test targets
404400
# ======================================================================================================================
@@ -590,14 +586,6 @@ getcopyright: ## Download copyright jar locally if necessary.
590586
@test -f scripts/$(COPYRIGHT_JAR) || curl -o scripts/$(COPYRIGHT_JAR) \
591587
https://repo.maven.apache.org/maven2/org/glassfish/copyright/glassfish-copyright-maven-plugin/2.4/glassfish-copyright-maven-plugin-2.4.jar
592588

593-
# ----------------------------------------------------------------------------------------------------------------------
594-
# Find or download trivy
595-
# ----------------------------------------------------------------------------------------------------------------------
596-
.PHONY: gettrivy
597-
gettrivy:
598-
@mkdir -p $(TOOLS_BIN)
599-
curl -sfL https://raw.githubusercontent.com/aquasecurity/trivy/main/contrib/install.sh | sh -s -- -b $(TOOLS_BIN) v0.51.2
600-
601589
# go-get-tool will 'go get' any package $2 and install it to $1.
602590
PROJECT_DIR := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST))))
603591
define go-get-tool

0 commit comments

Comments
 (0)