|
1 | 1 | #!/bin/bash |
2 | 2 | set -e |
3 | | -while getopts "a:b:c:d:e:f:g:h:i:j:k:l:m:n:o:" o; do |
| 3 | +while getopts "a:b:c:d:e:f:g:h:i:j:k:l:m:n:o:p:" o; do |
4 | 4 | case "${o}" in |
5 | 5 | a) |
6 | 6 | export scanType=${OPTARG} |
@@ -47,19 +47,23 @@ while getopts "a:b:c:d:e:f:g:h:i:j:k:l:m:n:o:" o; do |
47 | 47 | o) |
48 | 48 | export ignorePolicy=${OPTARG} |
49 | 49 | ;; |
| 50 | + p) |
| 51 | + export hideProgress=${OPTARG} |
| 52 | + ;; |
50 | 53 | esac |
51 | 54 | done |
52 | 55 |
|
53 | 56 | scanType=$(echo $scanType | tr -d '\r') |
54 | 57 | export artifactRef="${imageRef}" |
55 | | -if [ "${scanType}" = "fs" ];then |
| 58 | +if [ "${scanType}" = "fs" ] || [ "${scanType}" = "config" ];then |
56 | 59 | artifactRef=$(echo $scanRef | tr -d '\r') |
57 | 60 | fi |
58 | 61 | input=$(echo $input | tr -d '\r') |
59 | 62 | if [ $input ]; then |
60 | 63 | artifactRef="--input $input" |
61 | 64 | fi |
62 | 65 | ignoreUnfixed=$(echo $ignoreUnfixed | tr -d '\r') |
| 66 | +hideProgress=$(echo $hideProgress | tr -d '\r') |
63 | 67 |
|
64 | 68 | GLOBAL_ARGS="" |
65 | 69 | if [ $cacheDir ];then |
|
76 | 80 | if [ $exitCode ];then |
77 | 81 | ARGS="$ARGS --exit-code $exitCode" |
78 | 82 | fi |
79 | | -if [ "$ignoreUnfixed" == "true" ];then |
| 83 | +if [ "$ignoreUnfixed" == "true" ] && [ "$scanType" != "config" ];then |
80 | 84 | ARGS="$ARGS --ignore-unfixed" |
81 | 85 | fi |
82 | | -if [ $vulnType ];then |
| 86 | +if [ $vulnType ] && [ "$scanType" != "config" ];then |
83 | 87 | ARGS="$ARGS --vuln-type $vulnType" |
84 | 88 | fi |
85 | 89 | if [ $severity ];then |
|
100 | 104 | if [ $ignorePolicy ];then |
101 | 105 | ARGS="$ARGS --ignore-policy $ignorePolicy" |
102 | 106 | fi |
| 107 | +if [ "$hideProgress" == "true" ];then |
| 108 | + ARGS="$ARGS --no-progress" |
| 109 | +fi |
103 | 110 |
|
104 | | -echo "Running trivy with options: " --no-progress "${ARGS}" "${artifactRef}" |
| 111 | +echo "Running trivy with options: ${ARGS}" "${artifactRef}" |
105 | 112 | echo "Global options: " "${GLOBAL_ARGS}" |
106 | | -trivy $GLOBAL_ARGS ${scanType} --no-progress $ARGS ${artifactRef} |
| 113 | +trivy $GLOBAL_ARGS ${scanType} $ARGS ${artifactRef} |
0 commit comments