Skip to content

Commit 2b70a98

Browse files
shahidhkclaude
andcommitted
Add Trivy vulnerability scanning to CI workflow
- Scan pushed Docker image for vulnerabilities - Upload scan results to Security Agent - Fail build on HIGH/CRITICAL vulnerabilities Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 6f4186f commit 2b70a98

1 file changed

Lines changed: 39 additions & 0 deletions

File tree

.github/workflows/ndc-python-lambda-connector.yaml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,45 @@ jobs:
121121
tags: ${{ steps.docker-metadata.outputs.tags }}
122122
labels: ${{ steps.docker-metadata.outputs.labels }}
123123

124+
- name: Get image tag for scanning
125+
id: get-image-tag
126+
run: |
127+
IMAGE_TAG="${{ env.DOCKER_REGISTRY }}/${{ env.DOCKER_IMAGE_NAME }}:${GITHUB_REF#refs/tags/}"
128+
echo "image_tag=$IMAGE_TAG" >> $GITHUB_OUTPUT
129+
130+
- name: Run Trivy vulnerability scanner (json output)
131+
uses: aquasecurity/trivy-action@0.32.0
132+
with:
133+
image-ref: ${{ steps.get-image-tag.outputs.image_tag }}
134+
format: json
135+
output: trivy-results.json
136+
scanners: vuln
137+
138+
- name: Upload Trivy scan results to Security Agent
139+
uses: hasura/security-agent-tools/upload-file@v1
140+
with:
141+
file_path: trivy-results.json
142+
security_agent_api_key: ${{ secrets.SECURITY_AGENT_API_KEY }}
143+
tags: |
144+
service=ndc-python-lambda
145+
source_code_path=ndc-python-lambda
146+
docker_file_path=Dockerfile
147+
scanner=trivy
148+
image_name=${{ steps.get-image-tag.outputs.image_tag }}
149+
product_domain=hasura-ddn
150+
team=platform
151+
152+
- name: Fail build on High/Critical Vulnerabilities
153+
uses: aquasecurity/trivy-action@0.32.0
154+
with:
155+
skip-setup-trivy: true
156+
image-ref: ${{ steps.get-image-tag.outputs.image_tag }}
157+
format: table
158+
severity: CRITICAL,HIGH
159+
scanners: vuln
160+
ignore-unfixed: true
161+
exit-code: 1
162+
124163
release-connector:
125164
name: Release connector
126165
runs-on: ubuntu-latest

0 commit comments

Comments
 (0)