Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scan images and upload results before pushing them #132

Merged
merged 8 commits into from
Jul 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,3 @@ jobs:
with:
comment_tag: bot-comment
filePath: pr-message

55 changes: 55 additions & 0 deletions .github/workflows/reusable-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,61 @@ jobs:
echo "lables: ${{ steps.meta.outputs.labels }}"
echo "tags: ${{ steps.meta.outputs.tags }}"
echo "version: ${{ steps.meta.outputs.version }}"
# Build amd64 image to scan for vulnerabilities
- name: Build framework
uses: docker/build-push-action@v6
with:
load: true
sbom: false
platforms: linux/amd64
push: false
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
target: final
build-args: |
SECURITY_PROFILE=${{ inputs.security_profile }}
- name: Run Trivy vulnerability scanner on PR
if: ${{ github.event_name == 'pull_request' }}
uses: aquasecurity/[email protected]
with:
image-ref: ${{ steps.meta.outputs.tags }}
exit-code: '1'
format: 'table'
severity: 'CRITICAL'
- name: Run Grype vulnerability scanner on PR
if: ${{ github.event_name == 'pull_request' }}
uses: anchore/scan-action@v3
with:
image: ${{ steps.meta.outputs.tags }}
severity-cutoff: critical
output-format: 'table'
fail-build: true
- name: Run Trivy vulnerability scanner on push
if: ${{ github.event_name == 'push' }}
uses: aquasecurity/[email protected]
with:
image-ref: ${{ steps.meta.outputs.tags }}
format: 'sarif'
output: 'trivy-results.sarif'
- name: Run Grype vulnerability scanner on push
if: ${{ github.event_name == 'push' }}
id: grype
uses: anchore/scan-action@v3
with:
image: ${{ steps.meta.outputs.tags }}
severity-cutoff: critical
output-format: 'sarif'
fail-build: false
- name: Upload Trivy scan results to GitHub Security tab
if: ${{ github.event_name == 'push' }}
uses: github/codeql-action/upload-sarif@v2
with:
sarif_file: 'trivy-results.sarif'
- name: Upload Grype scan results to GitHub Security tab
if: ${{ github.event_name == 'push' }}
uses: github/codeql-action/upload-sarif@v2
with:
sarif_file: ${{ steps.grype.outputs.sarif }}
- name: Build and push framework
uses: docker/build-push-action@v6
with:
Expand Down