|
7 | 7 |
|
8 | 8 | set -e |
9 | 9 |
|
| 10 | +# Source centralized version configuration |
| 11 | +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" |
| 12 | +source "${SCRIPT_DIR}/trivy-version.sh" |
| 13 | + |
10 | 14 | GREEN='\033[0;32m' |
11 | 15 | YELLOW='\033[1;33m' |
12 | 16 | RED='\033[0;31m' |
13 | 17 | NC='\033[0m' # No Color |
14 | | - |
15 | | -TRIVY_VERSION="0.65.0" |
16 | 18 | HOST_DOWNLOAD_DIR="/tmp/trivy-airgapped-$(date +%s)" |
17 | 19 | SHOW_USAGE=false |
18 | 20 |
|
@@ -130,6 +132,8 @@ CACHE_DIR="${TRIVY_DIR}/cache" |
130 | 132 | TIMESTAMP=$(date +"%Y%m%d-%H%M%S") |
131 | 133 | CONTAINERD_ADDRESS="/run/k3s/containerd/containerd.sock" |
132 | 134 | TEMP_DIR="/tmp/trivy-export-$" |
| 135 | +# Get installed Trivy version for SARIF reports |
| 136 | +TRIVY_INSTALLED_VERSION=$(sudo ${TRIVY_DIR}/trivy --version 2>/dev/null | head -1 | awk '{print $2}' || echo "unknown") |
133 | 137 |
|
134 | 138 | # Ensure directories exist |
135 | 139 | mkdir -p ${REPORTS_DIR} |
@@ -226,7 +230,7 @@ scan_image_directly() { |
226 | 230 | echo "✓ SARIF report saved" |
227 | 231 | else |
228 | 232 | echo "WARNING: SARIF vulnerability scan failed for $image" |
229 | | - echo "{\"$schema\":\"https://raw.githubusercontent.com/oasis-tcs/sarif-spec/master/Schemata/sarif-schema-2.1.0.json\",\"version\":\"2.1.0\",\"runs\":[{\"tool\":{\"driver\":{\"name\":\"Trivy\",\"informationUri\":\"https://github.com/aquasecurity/trivy\",\"rules\":[],\"version\":\"0.65.0\"}},\"results\":[]}]}" > "${output_base}_critical.sarif" |
| 233 | + echo "{\"\$schema\":\"https://raw.githubusercontent.com/oasis-tcs/sarif-spec/master/Schemata/sarif-schema-2.1.0.json\",\"version\":\"2.1.0\",\"runs\":[{\"tool\":{\"driver\":{\"name\":\"Trivy\",\"informationUri\":\"https://github.com/aquasecurity/trivy\",\"rules\":[],\"version\":\"${TRIVY_INSTALLED_VERSION}\"}},\"results\":[]}]}" > "${output_base}_critical.sarif" |
230 | 234 | fi |
231 | 235 |
|
232 | 236 | echo "Reports saved to:" |
@@ -281,7 +285,7 @@ scan_image_tarball() { |
281 | 285 | echo "✓ SARIF report saved" |
282 | 286 | else |
283 | 287 | echo "WARNING: SARIF vulnerability scan failed for $image" |
284 | | - echo "{\"$schema\":\"https://raw.githubusercontent.com/oasis-tcs/sarif-spec/master/Schemata/sarif-schema-2.1.0.json\",\"version\":\"2.1.0\",\"runs\":[{\"tool\":{\"driver\":{\"name\":\"Trivy\",\"informationUri\":\"https://github.com/aquasecurity/trivy\",\"rules\":[],\"version\":\"0.65.0\"}},\"results\":[]}]}" > "${output_base}_critical.sarif" |
| 288 | + echo "{\"\$schema\":\"https://raw.githubusercontent.com/oasis-tcs/sarif-spec/master/Schemata/sarif-schema-2.1.0.json\",\"version\":\"2.1.0\",\"runs\":[{\"tool\":{\"driver\":{\"name\":\"Trivy\",\"informationUri\":\"https://github.com/aquasecurity/trivy\",\"rules\":[],\"version\":\"${TRIVY_INSTALLED_VERSION}\"}},\"results\":[]}]}" > "${output_base}_critical.sarif" |
285 | 289 | fi |
286 | 290 |
|
287 | 291 | echo "Reports saved to:" |
|
0 commit comments