-
Notifications
You must be signed in to change notification settings - Fork 0
96 lines (80 loc) · 2.78 KB
/
sca_anchore.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
## Scan a docker image -> get a SARIF/SBOM report
name: SCA/Anchore
on:
workflow_dispatch:
inputs:
docker_image:
description: 'The Docker image to scan'
required: true
default: 'appsecco/dvna:sqlite'
# env:
# REGISTRY: ghcr.io
# IMAGE_NAME: ${{ github.repository }}
# SHA: ${{ github.event.pull_request.head.sha || github.event.after }}
jobs:
anchore:
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
security-events: write
steps:
- name: Checkout code
uses: actions/checkout@v4
## Optional: login if your image is private
# - name: Login to Dockerhub
# uses: docker/login-action@v3
# with:
# username: ${{ secrets.DOCKERHUB_USERNAME }}
# password: ${{ secrets.DOCKERHUB_TOKEN }}
# - name: Login to GHCR
# uses: docker/login-action@v3
# with:
# registry: ${{ env.REGISTRY }}
# username: ${{ github.actor }}
# password: ${{ secrets.GITHUB_TOKEN }}
# Pull the github input image or use the default
- name: Pull the image
run: docker pull ${{ github.event.inputs.docker_image }}
- name: Run the Anchore Grype scan action
uses: anchore/scan-action@v4
id: scan
with:
image: ${{ github.event.inputs.docker_image }}
fail-build: false
only-fixed: true
output-format: sarif
#severity-cutoff: critical
- name: Upload SARIF file as an artifact
uses: actions/upload-artifact@v4
with:
name: sca_anchore.sarif
path: ${{ steps.scan.outputs.sarif }}
- name: Generate CycloneDX report
run: grype -o cyclonedx-json ${{ github.event.inputs.docker_image }} > sca_anchore.cyclonedx.json
- name: Upload SARIF file as an artifact
uses: actions/upload-artifact@v4
with:
name: sca_anchore.cyclonedx.json
path: sca_anchore.cyclonedx.json
- name: Run the Anchore Syft sbom action
uses: anchore/sbom-action@v0
id: syft
with:
image: ${{ github.event.inputs.docker_image }}
format: spdx-json
output-file: sbom_anchore.spdx.json
upload-artifact: false
- name: Upload SBOM file as an artifact
uses: actions/upload-artifact@v4
with:
name: sbom_anchore.spdx.json
path: sbom_anchore.spdx.json
# Only available on Github Enterprise or public repositories
- name: Upload SARIF file
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: ${{ steps.scan.outputs.sarif }}
category: Security/SCA
- name: SBOM upload
uses: advanced-security/[email protected]