Skip to content

Commit 60e7c4c

Browse files
committed
vuln import on tag only
1 parent 1843d46 commit 60e7c4c

File tree

8 files changed

+97
-65
lines changed

8 files changed

+97
-65
lines changed

.github/workflows/build.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: build_image
1+
name: build-image
22

33
on:
44
workflow_call:

.github/workflows/import.yaml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: import-vulnerabilities
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
image_digest:
7+
description: 'Fully-qualified image uri (repo/image@digest)'
8+
required: true
9+
type: string
10+
auth_provider:
11+
description: 'OIDC provider ID'
12+
required: true
13+
type: string
14+
auth_user:
15+
description: 'OIDC user ID'
16+
required: true
17+
type: string
18+
target_project:
19+
description: 'Target project ID where vulnerability scan will be imported'
20+
required: true
21+
type: string
22+
report_path:
23+
description: 'Path to vulnerability scan report'
24+
type: string
25+
default: 'report.json'
26+
27+
permissions:
28+
contents: read
29+
30+
jobs:
31+
import:
32+
runs-on: ubuntu-latest
33+
permissions:
34+
actions: read
35+
id-token: write
36+
steps:
37+
38+
- name: Checkout Code
39+
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
40+
41+
- id: auth
42+
name: Auth GCP
43+
uses: google-github-actions/auth@ef5d53e30bbcd8d0836f4288f5e50ff3e086997d # v1.0.0
44+
with:
45+
token_format: "access_token"
46+
workload_identity_provider: ${{ inputs.auth_provider }}
47+
service_account: ${{ inputs.auth_user }}
48+
49+
- id: scan
50+
name: Vulnerability Scan
51+
uses: aquasecurity/trivy-action@master
52+
with:
53+
image-ref: ${{ inputs.image_digest }}
54+
scanners: vuln
55+
format: json
56+
output: ${{ inputs.report_path }}
57+
timeout: 5m
58+
hide-progress: true
59+
60+
- uses: mchmarny/vulctl@main
61+
with:
62+
project: ${{ inputs.target_project }}
63+
digest: ${{ inputs.image_digest }}
64+
file: ${{ inputs.report_path }}
65+
format: trivy

.github/workflows/on-push-import.yaml

Lines changed: 0 additions & 55 deletions
This file was deleted.

.github/workflows/on-tag-img.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ jobs:
1515
PROVIDER_ID: projects/689738033528/locations/global/workloadIdentityPools/vulctl-github-pool/providers/github-provider
1616
REG_URI: us-west1-docker.pkg.dev/cloudy-build/vulctl
1717
18+
PROJECT_ID: cloudy-build
1819

1920
# Defaults
2021
BUILDER_VERSION: v1.4.0
@@ -34,6 +35,7 @@ jobs:
3435
provider_id: ${{ steps.conf.outputs.provider_id }}
3536
registry_uri: ${{ steps.conf.outputs.registry_uri }}
3637
service_account: ${{ steps.conf.outputs.service_account }}
38+
project_id: ${{ steps.conf.outputs.project_id }}
3739
steps:
3840

3941
- name: Export Config
@@ -47,6 +49,7 @@ jobs:
4749
echo "provider_id=${{ env.PROVIDER_ID }}" >> $GITHUB_OUTPUT
4850
echo "registry_uri=${{ env.REG_URI }}" >> $GITHUB_OUTPUT
4951
echo "service_account=${{ env.SA_EMAIL }}" >> $GITHUB_OUTPUT
52+
echo "project_id=${{ env.PROJECT_ID }}" >> $GITHUB_OUTPUT
5053
5154
test:
5255
needs:
@@ -107,3 +110,18 @@ jobs:
107110
auth_provider: ${{ needs.conf.outputs.provider_id }}
108111
auth_user: ${{ needs.conf.outputs.service_account }}
109112
image_digest: ${{ needs.image.outputs.digest }}
113+
114+
import:
115+
needs:
116+
- conf
117+
- image
118+
permissions:
119+
contents: read
120+
actions: read
121+
id-token: write
122+
uses: ./.github/workflows/import.yaml
123+
with:
124+
auth_provider: ${{ needs.conf.outputs.provider_id }}
125+
auth_user: ${{ needs.conf.outputs.service_account }}
126+
image_digest: ${{ needs.image.outputs.digest }}
127+
target_project: ${{ needs.conf.outputs.project_id }}

.github/workflows/sign.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: sign_image
1+
name: sign-image
22

33
on:
44
workflow_call:

.github/workflows/slsa.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: slsa_provenance_create
1+
name: slsa-provenance-create
22

33
on:
44
workflow_call:

.version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v0.2.9
1+
v0.2.10

examples/github-actions/README.md

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,17 @@ none
1515

1616
## usage
1717

18+
Below example, shows how to import vulnerabilities from previously generated report.
19+
20+
> Make sure to use the latest tag release (e.g. `v0.2.10`)
21+
1822
```yaml
19-
uses: actions/vulctl@main
23+
uses: mchmarny/vulctl@v0.2.10
2024
with:
21-
project: cloudy-demo
22-
digest: ${{ env.IMAGE_DIGEST }}
23-
file: report.json
24-
format: snyk
25+
project: ${{ env.PROJECT_ID }}
26+
digest: ${{ steps.build.outputs.digest }}
27+
file: ${{ steps.scan.outputs.output }}
28+
format: ${{ steps.scan.outputs.format }}
2529
```
2630
27-
> Fully working example can be found in [.github/workflows/on-push-import.yaml](../../.github/workflows/on-push-import.yaml).
31+
> Fully working example can be found in [.github/workflows/import.yaml](../../.github/workflows/import.yaml).

0 commit comments

Comments
 (0)