Skip to content

Commit 44d7a71

Browse files
jpayne3506Copilot
andauthored
[backport v1.7] ci: Workflow hardening: add govulncheck and zizmor static analysis workflows (#4302) (#4328)
ci: Workflow hardening: add govulncheck and zizmor static analysis workflows (#4302) * Initial plan * add govulncheck and zizmor workflow files with SHA-pinned actions Agent-Logs-Url: https://github.com/Azure/azure-container-networking/sessions/fa67252f-bb36-48c3-bd99-0aabf2f99b12 * govulncheck: add matrix for all go.mod files and coverage guard job Agent-Logs-Url: https://github.com/Azure/azure-container-networking/sessions/298ba314-3726-40bc-adab-1c3ffcf85a98 * fix: repo-checkout: false * ci: include bpf files * fix: match go version * fix: reorder bpf generation --------- Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
1 parent 6ba6238 commit 44d7a71

2 files changed

Lines changed: 159 additions & 0 deletions

File tree

.github/workflows/govulncheck.yaml

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
name: govulncheck
2+
on:
3+
workflow_dispatch:
4+
pull_request:
5+
types:
6+
- opened
7+
- reopened
8+
- synchronize
9+
- ready_for_review
10+
merge_group:
11+
types:
12+
- checks_requested
13+
14+
permissions:
15+
contents: read
16+
17+
jobs:
18+
govulncheck:
19+
name: Run govulncheck (${{ matrix.module }})
20+
runs-on: ubuntu-latest
21+
strategy:
22+
fail-fast: false
23+
matrix:
24+
module:
25+
- .
26+
- azure-ip-masq-merger
27+
- azure-ipam
28+
- azure-iptables-monitor
29+
- bpf-prog/ipv6-hp-bpf
30+
- cilium-log-collector
31+
- dropgz
32+
- pkgerrlint
33+
- tools/azure-npm-to-cilium-validator
34+
- zapai
35+
include:
36+
- module: .
37+
bpf: true
38+
- module: bpf-prog/ipv6-hp-bpf
39+
bpf: true
40+
- module: azure-iptables-monitor
41+
bpf: true
42+
steps:
43+
- name: Checkout repository
44+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
45+
46+
- name: Set up Go
47+
uses: actions/setup-go@4b73464bb391d4059bd26b0524d20df3927bd417 # v6.3.0
48+
if: matrix.bpf
49+
with:
50+
go-version-file: go.mod
51+
52+
- name: Build BPF lib
53+
if: matrix.bpf
54+
run: make bpf-lib
55+
56+
- name: Go generate
57+
if: matrix.bpf
58+
run: go generate ./...
59+
60+
- name: Set up Go
61+
uses: actions/setup-go@4b73464bb391d4059bd26b0524d20df3927bd417 # v6.3.0
62+
with:
63+
go-version-file: ${{ matrix.module }}/go.mod
64+
65+
- name: Run govulncheck
66+
uses: golang/govulncheck-action@b625fbe08f3bccbe446d94fbf87fcc875a4f50ee # v1.0.4
67+
with:
68+
go-version-file: ${{ matrix.module }}/go.mod
69+
work-dir: ${{ matrix.module }}
70+
go-package: ./...
71+
repo-checkout: false
72+
73+
check-gomod-coverage:
74+
name: Check all go.mod files are in matrix
75+
runs-on: ubuntu-latest
76+
steps:
77+
- name: Checkout repository
78+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
79+
80+
- name: Verify matrix covers all go.mod files
81+
run: |
82+
MATRIX_MODULES=(
83+
"."
84+
"azure-ip-masq-merger"
85+
"azure-ipam"
86+
"azure-iptables-monitor"
87+
"bpf-prog/ipv6-hp-bpf"
88+
"cilium-log-collector"
89+
"dropgz"
90+
"pkgerrlint"
91+
"tools/azure-npm-to-cilium-validator"
92+
"zapai"
93+
)
94+
95+
mapfile -t FOUND_MODULES < <(
96+
find . -name "go.mod" -not -path "*/vendor/*" \
97+
| xargs -I{} dirname {} \
98+
| sed 's|^\./||' \
99+
| sort
100+
)
101+
102+
MISSING=()
103+
for mod in "${FOUND_MODULES[@]}"; do
104+
found=false
105+
for matrix_mod in "${MATRIX_MODULES[@]}"; do
106+
if [[ "$mod" == "$matrix_mod" ]]; then
107+
found=true
108+
break
109+
fi
110+
done
111+
if [[ "$found" == "false" ]]; then
112+
MISSING+=("$mod")
113+
fi
114+
done
115+
116+
if [[ ${#MISSING[@]} -gt 0 ]]; then
117+
echo "ERROR: The following go.mod files are not in the govulncheck matrix:"
118+
for m in "${MISSING[@]}"; do
119+
echo " - $m"
120+
done
121+
echo ""
122+
echo "Add them to the 'matrix.module' list in .github/workflows/govulncheck.yaml"
123+
exit 1
124+
fi
125+
126+
echo "All go.mod files are covered by the govulncheck matrix."

.github/workflows/zizmor.yaml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: zizmor
2+
on:
3+
workflow_dispatch:
4+
pull_request:
5+
types:
6+
- opened
7+
- reopened
8+
- synchronize
9+
- ready_for_review
10+
merge_group:
11+
types:
12+
- checks_requested
13+
14+
permissions:
15+
contents: read
16+
17+
jobs:
18+
zizmor:
19+
name: GitHub Actions static analysis
20+
runs-on: ubuntu-latest
21+
permissions:
22+
contents: read
23+
security-events: write
24+
steps:
25+
- name: Checkout repository
26+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
27+
with:
28+
persist-credentials: false
29+
30+
- name: Run zizmor
31+
uses: zizmorcore/zizmor-action@71321a20a9ded102f6e9ce5718a2fcec2c4f70d8 # v0.5.2
32+
env:
33+
GH_TOKEN: ${{ github.token }}

0 commit comments

Comments
 (0)