7878 id : image
7979 run : echo "name=${{ inputs.image_name || github.repository }}" >> $GITHUB_OUTPUT
8080
81- - name : Create ignore file for Trivy if not present
81+ - name : Check trivy ignore file
82+ id : ignorefile
8283 run : |
83- test -f .trivyignore.yml || touch .trivyignore.yml
84+ if [ -f .trivyignore.yml ]; then
85+ echo "param=--ignorefile .trivyignore.yml" >> $GITHUB_OUTPUT
86+ else
87+ touch .trivyignore.yml
88+ echo "param=" >> $GITHUB_OUTPUT
89+ fi
8490
8591 - name : Run Trivy
8692 uses : aquasecurity/trivy-action@0.33.1 # NOSONAR githubactions:S7637 - verified action creator
@@ -167,14 +173,10 @@ jobs:
167173 INPUT_IMAGE_REPOSITORY : ${{ inputs.image_repository }}
168174 INPUT_SEVERITIES : ${{ inputs.severities }}
169175 run : |
170- IGNOREFILE_FLAG=""
171- if [ -f ".trivyignore.yml" ]; then
172- IGNOREFILE_FLAG="--ignorefile .trivyignore.yml"
173- fi
174176 echo "## 🛠️ To verify the scan results locally, run the following command from the extensions directory:" >> $GITHUB_STEP_SUMMARY
175177 echo '```bash' >> $GITHUB_STEP_SUMMARY
176178 echo "docker pull $INPUT_IMAGE_REPOSITORY/${{ steps.image.outputs.name }}:$INPUT_IMAGE_TAG" >> $GITHUB_STEP_SUMMARY
177- echo "trivy image --severity $INPUT_SEVERITIES ${IGNOREFILE_FLAG } --format table --show-suppressed $INPUT_IMAGE_REPOSITORY/${{ steps.image.outputs.name }}:$INPUT_IMAGE_TAG" >> $GITHUB_STEP_SUMMARY
179+ echo "trivy image --severity $INPUT_SEVERITIES ${{ steps.ignorefile.outputs.param } } --format table --show-suppressed $INPUT_IMAGE_REPOSITORY/${{ steps.image.outputs.name }}:$INPUT_IMAGE_TAG" >> $GITHUB_STEP_SUMMARY
178180 echo '```' >> $GITHUB_STEP_SUMMARY
179181
180182 - name : Add hint for local verification (fs)
@@ -183,16 +185,12 @@ jobs:
183185 INPUT_SEVERITIES : ${{ inputs.severities }}
184186 INPUT_CHECKOUT_REF : ${{ inputs.checkout_ref }}
185187 run : |
186- IGNOREFILE_FLAG=""
187- if [ -f ".trivyignore.yml" ]; then
188- IGNOREFILE_FLAG="--ignorefile .trivyignore.yml"
189- fi
190188 echo "## 🛠️ To verify the scan results locally, run the following command from the extensions directory:" >> $GITHUB_STEP_SUMMARY
191189 echo '```bash' >> $GITHUB_STEP_SUMMARY
192190 if [ -n "$INPUT_CHECKOUT_REF" ]; then
193191 echo "git checkout $INPUT_CHECKOUT_REF && git pull" >> $GITHUB_STEP_SUMMARY
194192 fi
195- echo "trivy fs --severity $INPUT_SEVERITIES ${IGNOREFILE_FLAG } --format table --show-suppressed ." >> $GITHUB_STEP_SUMMARY
193+ echo "trivy fs --severity $INPUT_SEVERITIES ${{ steps.ignorefile.outputs.param } } --format table --show-suppressed ." >> $GITHUB_STEP_SUMMARY
196194 echo '```' >> $GITHUB_STEP_SUMMARY
197195
198196 - name : Convert Trivy JSON to SARIF
0 commit comments