Skip to content

Commit 82ec0dd

Browse files
authored
Include args when using trivy config file (#231)
Previously, arguments provided using regular flags were ignored if a trivy config file was provided Note that this pull request makes no effort to deduce or merge desired argument if the same configuration with different values are provided both within the config file and as flags. Behaviour for this case would develop on the implementation of trivy
1 parent e5f4313 commit 82ec0dd

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

entrypoint.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ if [ "${format}" == "sarif" ] && [ "${limitSeveritiesForSARIF}" != "true" ]; the
177177
trivy --quiet ${scanType} --format sarif --output ${output} $SARIF_ARGS ${artifactRef}
178178
elif [ $trivyConfig ]; then
179179
echo "Running Trivy with trivy.yaml config from: " $trivyConfig
180-
trivy --config $trivyConfig ${scanType} ${artifactRef}
180+
trivy --config $trivyConfig ${ARGS} ${scanType} ${artifactRef}
181181
returnCode=$?
182182
else
183183
echo "Running trivy with options: trivy ${scanType} ${ARGS}" "${artifactRef}"

test/data/trivy-reduced.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
vulnerability:
2+
type: os
3+
output: yamlconfig.test

test/test.bats

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,3 +81,11 @@ bats_load_library bats-file
8181
echo "$output"
8282
assert_files_equal yamlconfig.test ./test/data/yamlconfig.test
8383
}
84+
85+
@test "trivy image with trivy.yaml config and args" {
86+
# trivy --config=./test/data/trivy-reduced.yaml image alpine:3.10
87+
run ./entrypoint.sh "-v ./test/data/trivy-reduced.yaml" "-a image" "-i alpine:3.10" "-b json" "-g CRITICAL"
88+
run diff yamlconfig.test ./test/data/yamlconfig.test
89+
echo "$output"
90+
assert_files_equal yamlconfig.test ./test/data/yamlconfig.test
91+
}

0 commit comments

Comments
 (0)