|
85 | 85 | path: ./connector-definition/dist |
86 | 86 | compression-level: 0 # Already compressed |
87 | 87 |
|
| 88 | + security-scan: |
| 89 | + name: Build and scan Docker image |
| 90 | + runs-on: ubuntu-latest |
| 91 | + steps: |
| 92 | + - uses: actions/checkout@v4 |
| 93 | + |
| 94 | + - name: Set up Docker Buildx |
| 95 | + uses: docker/setup-buildx-action@v3 |
| 96 | + |
| 97 | + - name: Build Docker image |
| 98 | + uses: docker/build-push-action@v6 |
| 99 | + with: |
| 100 | + context: . |
| 101 | + load: true |
| 102 | + tags: ${{ env.DOCKER_REGISTRY }}/${{ env.DOCKER_IMAGE_NAME }}:${{ github.sha }} |
| 103 | + |
| 104 | + - name: Run Trivy vulnerability scanner (json output) |
| 105 | + uses: aquasecurity/trivy-action@0.32.0 |
| 106 | + with: |
| 107 | + image-ref: ${{ env.DOCKER_REGISTRY }}/${{ env.DOCKER_IMAGE_NAME }}:${{ github.sha }} |
| 108 | + format: json |
| 109 | + output: trivy-results.json |
| 110 | + scanners: vuln |
| 111 | + |
| 112 | + - name: Upload Trivy scan results to Security Agent |
| 113 | + uses: hasura/security-agent-tools/upload-file@v1 |
| 114 | + with: |
| 115 | + file_path: trivy-results.json |
| 116 | + security_agent_api_key: ${{ secrets.SECURITY_AGENT_API_KEY }} |
| 117 | + tags: | |
| 118 | + service=ndc-python-lambda |
| 119 | + source_code_path=. |
| 120 | + docker_file_path=Dockerfile |
| 121 | + scanner=trivy |
| 122 | + image_name=${{ env.DOCKER_REGISTRY }}/${{ env.DOCKER_IMAGE_NAME }}:${{ github.sha }} |
| 123 | + product_domain=hasura-ddn-data-plane,promptql-data-plane |
| 124 | + team=engine |
| 125 | +
|
| 126 | + - name: Fail build on High/Critical Vulnerabilities |
| 127 | + uses: aquasecurity/trivy-action@0.32.0 |
| 128 | + with: |
| 129 | + skip-setup-trivy: true |
| 130 | + image-ref: ${{ env.DOCKER_REGISTRY }}/${{ env.DOCKER_IMAGE_NAME }}:${{ github.sha }} |
| 131 | + format: table |
| 132 | + severity: CRITICAL,HIGH |
| 133 | + scanners: vuln |
| 134 | + ignore-unfixed: true |
| 135 | + exit-code: 1 |
| 136 | + |
88 | 137 | build-and-push-docker: |
89 | 138 | name: Build and push Docker image |
90 | 139 | needs: build-connector |
@@ -121,6 +170,45 @@ jobs: |
121 | 170 | tags: ${{ steps.docker-metadata.outputs.tags }} |
122 | 171 | labels: ${{ steps.docker-metadata.outputs.labels }} |
123 | 172 |
|
| 173 | + - name: Get image tag for scanning |
| 174 | + id: get-image-tag |
| 175 | + run: | |
| 176 | + IMAGE_TAG="${{ env.DOCKER_REGISTRY }}/${{ env.DOCKER_IMAGE_NAME }}:${GITHUB_REF#refs/tags/}" |
| 177 | + echo "image_tag=$IMAGE_TAG" >> $GITHUB_OUTPUT |
| 178 | +
|
| 179 | + - name: Run Trivy vulnerability scanner (json output) |
| 180 | + uses: aquasecurity/trivy-action@0.32.0 |
| 181 | + with: |
| 182 | + image-ref: ${{ steps.get-image-tag.outputs.image_tag }} |
| 183 | + format: json |
| 184 | + output: trivy-results.json |
| 185 | + scanners: vuln |
| 186 | + |
| 187 | + - name: Upload Trivy scan results to Security Agent |
| 188 | + uses: hasura/security-agent-tools/upload-file@v1 |
| 189 | + with: |
| 190 | + file_path: trivy-results.json |
| 191 | + security_agent_api_key: ${{ secrets.SECURITY_AGENT_API_KEY }} |
| 192 | + tags: | |
| 193 | + service=ndc-python-lambda |
| 194 | + source_code_path=. |
| 195 | + docker_file_path=Dockerfile |
| 196 | + scanner=trivy |
| 197 | + image_name=${{ steps.get-image-tag.outputs.image_tag }} |
| 198 | + product_domain=hasura-ddn-data-plane,promptql-data-plane |
| 199 | + team=engine |
| 200 | +
|
| 201 | + - name: Fail build on High/Critical Vulnerabilities |
| 202 | + uses: aquasecurity/trivy-action@0.32.0 |
| 203 | + with: |
| 204 | + skip-setup-trivy: true |
| 205 | + image-ref: ${{ steps.get-image-tag.outputs.image_tag }} |
| 206 | + format: table |
| 207 | + severity: CRITICAL,HIGH |
| 208 | + scanners: vuln |
| 209 | + ignore-unfixed: true |
| 210 | + exit-code: 1 |
| 211 | + |
124 | 212 | release-connector: |
125 | 213 | name: Release connector |
126 | 214 | runs-on: ubuntu-latest |
|
0 commit comments