forked from signalfx/splunk-otel-collector
-
Notifications
You must be signed in to change notification settings - Fork 0
255 lines (242 loc) · 8.21 KB
/
vuln-scans.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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
name: vulnerability scans
on:
push:
branches:
- main
pull_request:
paths:
- '.github/workflows/vuln-scans.yml'
- '.grype.yaml'
- '.trivyignore'
- '.snyk'
env:
GO_VERSION: '1.21.10'
concurrency:
group: vuln-scans-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
trivy-fs-scan:
# Use 20.04.5 until https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/16450 is resolved
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
- name: Run trivy filesystem scan
uses: aquasecurity/trivy-action@0.21.0
with:
scan-type: 'fs'
scan-ref: '.'
skip-dirs: 'deployments,examples,instrumentation/packaging,internal/buildscripts/packaging,tests'
format: 'table'
exit-code: '1'
severity: 'CRITICAL,HIGH'
ignore-unfixed: true
anchore-fs-scan:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
- uses: anchore/scan-action@v3
with:
severity-cutoff: "high"
only-fixed: true
add-cpes-if-none: true
output-format: "table"
path: "."
docker-otelcol:
runs-on: ubuntu-20.04
strategy:
matrix:
ARCH: [ "amd64", "arm64" ]
fail-fast: false
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
cache-dependency-path: '**/go.sum'
- uses: actions/cache@v4
id: bundle-cache
with:
path: .cache/buildx/agent-bundle-${{ matrix.ARCH }}
key: agent-bundle-buildx-${{ matrix.ARCH }}-${{ hashFiles('internal/signalfx-agent/bundle/**') }}
restore-keys: |
agent-bundle-buildx-${{ matrix.ARCH }}-
- uses: docker/setup-qemu-action@v3
if: ${{ matrix.ARCH != 'amd64' }}
with:
platforms: ${{ matrix.ARCH }}
image: tonistiigi/binfmt:qemu-v7.0.0
- run: |
make docker-otelcol ARCH=${{ matrix.ARCH }}
env:
DOCKER_BUILDKIT: '1'
BUNDLE_CACHE_HIT: "${{ steps.bundle-cache.outputs.cache-hit }}"
- run: mkdir -p dist && docker save -o dist/image.tar otelcol:latest
- uses: actions/upload-artifact@v4
with:
name: otelcol-${{ matrix.ARCH }}
path: ./dist
binaries-windows_amd64:
runs-on: ubuntu-20.04
steps:
- name: Check out the codebase.
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
cache-dependency-path: '**/go.sum'
- run: make binaries-windows_amd64
- uses: actions/upload-artifact@v4
with:
name: binaries-windows_amd64
path: |
./bin/*
trivy-image-scan:
# Use 20.04.5 until https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/16450 is resolved
runs-on: ubuntu-20.04
needs: docker-otelcol
strategy:
matrix:
ARCH: [ "amd64", "arm64" ]
fail-fast: false
steps:
- uses: actions/checkout@v4
- uses: docker/setup-qemu-action@v3
if: ${{ matrix.ARCH != 'amd64' }}
with:
platforms: ${{ matrix.ARCH }}
image: tonistiigi/binfmt:qemu-v7.0.0
- uses: actions/download-artifact@v4
with:
name: otelcol-${{ matrix.ARCH }}
path: ./dist
- run: docker load -i ./dist/image.tar
- name: Run trivy image scan
uses: aquasecurity/trivy-action@0.21.0
with:
scan-type: 'image'
image-ref: 'otelcol:latest'
format: 'table'
exit-code: '1'
severity: 'CRITICAL,HIGH'
ignore-unfixed: true
anchore-image-scan:
runs-on: ubuntu-20.04
needs: docker-otelcol
strategy:
matrix:
ARCH: [ "amd64", "arm64" ]
fail-fast: false
env:
GRYPE_PLATFORM: ${{ matrix.ARCH }}
steps:
- uses: actions/checkout@v4
- uses: docker/setup-qemu-action@v3
if: ${{ matrix.ARCH != 'amd64' }}
with:
platforms: ${{ matrix.ARCH }}
image: tonistiigi/binfmt:qemu-v7.0.0
- uses: actions/download-artifact@v4
with:
name: otelcol-${{ matrix.ARCH }}
path: ./dist
- run: docker load -i ./dist/image.tar
- uses: anchore/scan-action@v3
with:
severity-cutoff: "high"
only-fixed: true
add-cpes-if-none: true
output-format: "table"
image: "otelcol:latest"
anchore-win-image-scan:
runs-on: windows-2022
needs: [ "binaries-windows_amd64" ]
env:
PIP_CACHE_DIR: ${{ github.workspace }}/.cache/pip
steps:
- name: Check out the codebase.
uses: actions/checkout@v4
- name: Downloading binaries-windows_amd64
uses: actions/download-artifact@v4
with:
name: binaries-windows_amd64
path: ./bin
- uses: actions/cache@v4
with:
path: ${{ env.PIP_CACHE_DIR }}
key: agent-bundle-windows-pip-${{ hashFiles('internal/signalfx-agent/bundle/collectd-plugins.yaml', 'internal/signalfx-agent/bundle/scripts/requirements.txt') }}
- run: ./internal/signalfx-agent/bundle/scripts/windows/make.ps1 bundle
- name: Build docker image
run: |
$ErrorActionPreference = 'Stop'
Copy-Item .\bin\otelcol_windows_amd64.exe .\cmd\otelcol\otelcol.exe
Copy-Item .\dist\agent-bundle_windows_amd64.zip .\cmd\otelcol\agent-bundle_windows_amd64.zip
docker build -t otelcol-windows --build-arg BASE_IMAGE=mcr.microsoft.com/windows/servercore:ltsc2022 --build-arg JMX_METRIC_GATHERER_RELEASE=$(Get-Content internal\buildscripts\packaging\jmx-metric-gatherer-release.txt) -f .\cmd\otelcol\Dockerfile.windows .\cmd\otelcol\
Remove-Item .\cmd\otelcol\otelcol.exe
Remove-Item .\cmd\otelcol\agent-bundle_windows_amd64.zip
- run: choco install -y grype
- run: grype --fail-on high --only-fixed -o table otelcol-windows:latest
snyk-fs-scan:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Run Snyk to check for vulnerabilities
uses: snyk/actions/golang@master
continue-on-error: true # To make sure that SARIF upload gets called
env:
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
with:
command: code test
args: --severity-threshold=high --sarif-file-output=snyk.sarif --policy-path=.snyk
- name: Upload result to GitHub Code Scanning
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: snyk.sarif
snyk-docker-scan:
runs-on: ubuntu-latest
needs: docker-otelcol
strategy:
matrix:
ARCH: [ "amd64", "arm64" ]
fail-fast: false
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: otelcol-${{ matrix.ARCH }}
path: ./dist
- run: docker load -i ./dist/image.tar
- uses: snyk/actions/docker@master
env:
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
with:
image: "otelcol:latest"
args: --file=cmd/otelcol/Dockerfile --severity-threshold=high --sarif-file-output=snyk.sarif --policy-path=.snyk
- name: Upload result to GitHub Code Scanning
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: snyk.sarif
govulncheck:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout Repo
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Setup Go
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
with:
go-version: ${{ env.GO_VERSION }}
cache: false
- name: Cache Go
id: go-cache
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
with:
path: |
~/go/bin
~/go/pkg/mod
key: go-cache-${{ runner.os }}-${{ hashFiles('**/go.sum') }}
- name: Install Tools
if: steps.go-cache.outputs.cache-hit != 'true'
run: make install-tools
- name: Run `govulncheck`
run: make govulncheck