-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaction.yml
More file actions
61 lines (57 loc) · 2 KB
/
action.yml
File metadata and controls
61 lines (57 loc) · 2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# -----------------------------------------------------------------------------
# Install Trivy
#
# Description:
# This GitHub Action installs the Trivy Software Composition Analysis (SCA) tool
# on the runner environment. Trivy is a comprehensive vulnerability scanner that
# is used to detect security issues in container images, file systems, and
# software dependencies.
#
# Usage Example:
# jobs:
# sca:
# runs-on: ubuntu-latest
# steps:
# - name: Checkout code
# uses: actions/checkout@v6
#
# - name: Install Trivy
# uses: 2Toad/actions/install-trivy@v2
# with:
# version: "0.69.3" # optional, defaults to 0.69.3
#
# - name: Run Trivy SCA Scan
# uses: 2Toad/actions/run-trivy@v2
# with:
# path: "./src"
# severity: "MEDIUM,HIGH,CRITICAL"
#
# -----------------------------------------------------------------------------
name: "Install Trivy"
description: "Install Trivy SCA tool"
inputs:
version:
description: "The version of Trivy to install (e.g., 0.69.3)"
required: false
default: "0.69.3"
runs:
using: "composite"
steps:
- name: Install Trivy
shell: bash
env:
INPUT_VERSION: ${{ inputs.version }}
run: |
deb_url="https://github.com/aquasecurity/trivy/releases/download/v${INPUT_VERSION}/trivy_${INPUT_VERSION}_Linux-64bit.deb"
checksums_url="https://github.com/aquasecurity/trivy/releases/download/v${INPUT_VERSION}/trivy_${INPUT_VERSION}_checksums.txt"
wget -q "$deb_url" -O trivy.deb
wget -q "$checksums_url" -O checksums.txt
# Verify checksum
expected=$(grep "trivy_${INPUT_VERSION}_Linux-64bit.deb" checksums.txt | awk '{print $1}')
actual=$(sha256sum trivy.deb | awk '{print $1}')
if [ "$expected" != "$actual" ]; then
echo "Checksum mismatch: expected $expected, got $actual"
exit 1
fi
sudo dpkg -i trivy.deb
rm trivy.deb checksums.txt