-
Notifications
You must be signed in to change notification settings - Fork 1
/
action.yml
143 lines (143 loc) · 4.45 KB
/
action.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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
---
name: MCVS-docker-action
description: |
Mission Critical Vulnerability Scanner (MCVS) Docker action.
inputs:
build-args:
description: Docker build arguments.
dockle-accept-key:
description: |
One of the Dockle checks is the inspection of use of secrets in
environment variables. Currently, there is a reported bug
`goodwithtech/dockle/issues/250`, i.e. if a specific version of a package
will be installed then an error will be thrown by Dockle, which is
incorrect. To mitigate this one has to specify the packages that are
applicable, e.g.: `libcrypto3,libssl3`.
images:
description: The name of the to be created image.
default: ghcr.io/${{ github.repository }}
trivy-action-db:
default: "public.ecr.aws/aquasecurity/trivy-db:2"
description: |
OCI repository to retrieve trivy-db from.
trivy-action-java-db:
default: "public.ecr.aws/aquasecurity/trivy-java-db:1"
description: |
OCI repository to retrieve trivy-java-db from.
token:
description: |
A token is required to allow the mcvs-docker-action to push the
image that it has been built, to the packages repository of the GitHub
repository where the action has been run.
required: true
runs:
using: "composite"
steps:
#
# YAML linting.
#
- run: |
pip install --user yamllint==1.35.1
yamllint .
shell: bash
#
# Dockerfile linting (static).
#
- uses: hadolint/[email protected]
with:
dockerfile: Dockerfile
#
# Determine image name and tag.
#
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/[email protected]
with:
flavor: |
latest=false
images: ${{ inputs.images }}
#
# Build a docker image.
#
- name: Build an image from a dockerfile
uses: docker/[email protected]
with:
build-args: APPLICATION=${{ inputs.build-args }}
context: .
labels: ${{ steps.meta.outputs.labels }}
push: false
tags: ${{ steps.meta.outputs.tags }}
#
# Docker image linting (dynamic).
#
- uses: goodwithtech/[email protected]
if: "false" # Disabled until the bug (#45) is fixed.
with:
image: ${{ steps.meta.outputs.tags }}
ignore: CIS-DI-0005,CIS-DI-0006
accept-key: ${{ inputs.dockle-accept-key }}
#
# Detect waste in the docker image.
#
- uses: 030/[email protected]
if: "false" # Disabled until the bug (#46) is fixed.
with:
image: ${{ steps.meta.outputs.tags }}
#
# Code and docker image security scanning.
#
- uses: anchore/[email protected]
with:
only-fixed: false
output-format: table
path: "."
severity-cutoff: high
- name: Scan image using Grype
uses: anchore/[email protected]
with:
image: ${{ steps.meta.outputs.tags }}
only-fixed: false
output-format: table
severity-cutoff: high
- uses: 030/[email protected]
- uses: aquasecurity/[email protected]
env:
TRIVY_DB_REPOSITORY: ${{ inputs.trivy-action-db }}
TRIVY_JAVA_DB_REPOSITORY: ${{ inputs.trivy-action-java-db }}
TRIVY_PASSWORD: ${{ inputs.token }}
TRIVY_USERNAME: ${{ github.actor }}
with:
scan-type: "fs"
scan-ref: "."
exit-code: "1"
ignore-unfixed: true
severity: "CRITICAL,HIGH"
trivyignores: .trivyignore
- uses: aquasecurity/[email protected]
env:
TRIVY_DB_REPOSITORY: ${{ inputs.trivy-action-db }}
TRIVY_JAVA_DB_REPOSITORY: ${{ inputs.trivy-action-java-db }}
TRIVY_PASSWORD: ${{ inputs.token }}
TRIVY_USERNAME: ${{ github.actor }}
with:
image-ref: ${{ steps.meta.outputs.tags }}
format: "table"
exit-code: "1"
ignore-unfixed: true
vuln-type: "os,library"
severity: "CRITICAL,HIGH"
trivyignores: .trivyignore
#
# Log in to GitHub packages and push the image.
#
- name: Log in to the Container registry
uses: docker/[email protected]
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ inputs.token }}
- name: Build and push Docker image
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
run: |
docker push --all-tags ${{ inputs.images }}
shell: bash