Interview Prep/Real-World Interview/Write-a-pipeline tasks

Write a workflow step that scans the image with Trivy and fails on HIGH/CRITICAL vulnerabilities.

BeginnerHands-onWrite-a-pipeline tasks
Answer
- name: Scan image
  uses: aquasecurity/[email protected]
  with:
    image-ref: myapp:${{ github.sha }}
    severity: HIGH,CRITICAL
    ignore-unfixed: true
    exit-code: "1"
    format: table

CLI equivalent: trivy image --severity HIGH,CRITICAL --ignore-unfixed --exit-code 1 myapp:tag.

Key trick → exit-code: 1 is what actually fails the build, because Trivy exits 0 by default. ignore-unfixed stops the gate blocking on CVEs nobody can patch yet. Pin the action to a version (or a SHA).

All Real-World Interview questions Roadmap: Interview readiness

More on Write-a-pipeline tasks