-
Notifications
You must be signed in to change notification settings - Fork 12
114 lines (90 loc) · 3.91 KB
/
build.yaml
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
name: Build
on:
push:
branches:
- master
pull_request:
types:
- opened
- reopened
- synchronize
jobs:
scanner-build:
runs-on: ubuntu-latest
container:
image: quay.io/stackrox-io/apollo-ci:scanner-test-0.3.61
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}
- name: genesis-dump
run: |
#!/usr/bin/env bash
set -euo pipefail
info() { echo "INFO: $(date): $*" }
generate_genesis_dump() {
info "Building updater"
make build-updater
info "Generating genesis dump"
mkdir -p /tmp/genesis-dump
"$ROOT/bin/updater" generate-dump --out-file /tmp/genesis-dump/genesis-dump.zip
ls -lrt /tmp/genesis-dump
info "Printing some stats"
"$ROOT/bin/updater" print-stats /tmp/genesis-dump/genesis-dump.zip
info "Extracting dumps"
mkdir -p /tmp/vuln-dump
zip /tmp/genesis-dump/genesis-dump.zip 'nvd/*' --copy --out /tmp/vuln-dump/nvd-definitions.zip
zip /tmp/genesis-dump/genesis-dump.zip 'k8s/*' --copy --out /tmp/vuln-dump/k8s-definitions.zip
zip /tmp/genesis-dump/genesis-dump.zip 'istio/*' --copy --out /tmp/vuln-dump/istio-definitions.zip
zip /tmp/genesis-dump/genesis-dump.zip 'rhelv2/repository-to-cpe.json' --copy --out /tmp/vuln-dump/repo2cpe.zip
}
generate_genesis_dump
- name: build-bundle
run: |
#!/usr/bin/env bash
set -euo pipefail
info() { echo "INFO: $(date): $*" }
cleanup_image() {
info "Reducing the image size"
set +e
rm -rf /go/{bin,pkg}
rm -rf /root/{.cache,.npm}
rm -rf /usr/local/share/.cache
rm -rf .git
rm -rf "$ROOT/image/scanner/bin"
rm -rf "$ROOT/image/scanner/rhel/THIRD_PARTY_NOTICES"
set -e
}
get_genesis_dump() {
info "Retrieving Genesis dump"
ls -lrt /tmp/vuln-dump || info "No local genesis dump"
if is_in_PR_context && ! pr_has_label "generate-dumps-on-pr"; then
info "Label generate-dumps-on-pr not set. Pulling dumps from GCS bucket"
mkdir -p /tmp/vuln-dump
gsutil cp gs://stackrox-scanner-ci-vuln-dump/nvd-definitions.zip /tmp/vuln-dump/nvd-definitions.zip
gsutil cp gs://stackrox-scanner-ci-vuln-dump/k8s-definitions.zip /tmp/vuln-dump/k8s-definitions.zip
gsutil cp gs://stackrox-scanner-ci-vuln-dump/istio-definitions.zip /tmp/vuln-dump/istio-definitions.zip
gsutil cp gs://stackrox-scanner-ci-vuln-dump/repo2cpe.zip /tmp/vuln-dump/repo2cpe.zip
fi
unzip -d "$ROOT/image/scanner/dump" /tmp/vuln-dump/nvd-definitions.zip
unzip -d "$ROOT/image/scanner/dump" /tmp/vuln-dump/k8s-definitions.zip
unzip -d "$ROOT/image/scanner/dump" /tmp/vuln-dump/istio-definitions.zip
unzip -d "$ROOT/image/scanner/dump" /tmp/vuln-dump/repo2cpe.zip
}
build_bundle() {
# avoid a -dirty tag
info "Reset to remove Dockerfile modification by OpenShift CI"
git restore .
git status
info "Building Scanner binary"
make scanner-build-nodeps
info "Making THIRD_PARTY_NOTICES"
make ossls-notice
get_genesis_dump
info "Creating Scanner bundle"
"$ROOT/image/scanner/rhel/create-bundle.sh" "$ROOT/image/scanner" "$ROOT/image/scanner/rhel"
cleanup_image
}
build_bundle