Skip to content

Commit 2b3b24e

Browse files
committed
verify trivy in build
1 parent c3fe81a commit 2b3b24e

3 files changed

Lines changed: 42 additions & 6 deletions

File tree

.github/workflows/build_all_images.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,35 @@ jobs:
3333
echo "node_24_languages=$node_24_language_folders"
3434
echo "projects=$project_folders"
3535
} >> "$GITHUB_OUTPUT"
36+
download_trivy:
37+
runs-on: ubuntu-latest
38+
steps:
39+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
40+
- name: Install cosign
41+
run: |
42+
./scripts/install_cosign.sh
43+
env:
44+
INSTALL_DIR: ${HOME}/.local/bin
45+
- name: Get amd64 trivy
46+
run: |
47+
./scripts/install_trivy.sh
48+
env:
49+
INSTALL_DIR: trivy_amd64
50+
ARCH: 64bit
51+
- name: Get arm64 trivy
52+
run: |
53+
./scripts/install_trivy.sh
54+
env:
55+
INSTALL_DIR: trivy_arm64
56+
ARCH: ARM64
57+
- uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f
58+
name: Upload trivy
59+
with:
60+
name: "trivy"
61+
path: |
62+
trivy_amd64/trivy
63+
trivy_arm64/trivy
64+
3665
package_base_docker_image:
3766
uses: ./.github/workflows/build_multi_arch_image.yml
3867
with:

.github/workflows/build_multi_arch_image.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,14 @@ jobs:
6363
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
6464
with:
6565
fetch-depth: 0
66-
- name: setup trivy
67-
uses: aquasecurity/setup-trivy@3fb12ec12f41e471780db15c232d5dd185dcb514
66+
- name: Download trivy
67+
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c
6868
with:
69-
version: v0.69.3
69+
name: trivy
70+
- name: setup trivy
71+
run: |
72+
sudo cp "trivy/trivy_${ARCH}/trivy" /usr/local/bin/
73+
chmod +x /usr/local/bin/trivy
7074
- name: setup node
7175
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f
7276
with:

scripts/install_trivy.sh

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,13 @@ set -euo pipefail
44
DEFAULT_INSTALL_DIR="/usr/local/bin"
55
INSTALL_DIR="${INSTALL_DIR:-$DEFAULT_INSTALL_DIR}"
66
VERSION="v0.69.3"
7+
DEFAULT_ARCH="64bit"
8+
ARCH="${ARCH:-$DEFAULT_ARCH}"
9+
#trivy_0.69.3_Linux-64bit.tar.gz
10+
#trivy_0.69.3_Linux-ARM64.tar.gz
711
RELEASE_NUMBER="${VERSION#v}"
812
BASE_URL="https://github.com/aquasecurity/trivy/releases/download/${VERSION}"
9-
ARCHIVE="trivy_${RELEASE_NUMBER}_Linux-64bit.tar.gz"
13+
ARCHIVE="trivy_${RELEASE_NUMBER}_Linux-${ARCH}.tar.gz"
1014
BUNDLE="${ARCHIVE}.sigstore.json"
1115
CERT_IDENTITY="https://github.com/aquasecurity/trivy/.github/workflows/reusable-release.yaml@refs/tags/${VERSION}"
1216

@@ -53,9 +57,8 @@ cosign verify-blob-attestation "${ARCHIVE_PATH}" \
5357

5458
echo "Sigstore verification passed"
5559
tar -xzf "${ARCHIVE_PATH}" -C "${TMP_DIR}"
60+
5661
mkdir -p "$INSTALL_DIR"
5762
install -m 0755 "$TMP_DIR/trivy" "${INSTALL_DIR}/trivy"
5863

59-
"${INSTALL_DIR}/trivy" version
60-
6164
echo "trivy ${VERSION} installed to ${INSTALL_DIR}"

0 commit comments

Comments
 (0)