Repository navigation
116 lines (105 loc) · 4.13 KB
/
Copy pathsecurity.yml
File metadata and controls
116 lines (105 loc) · 4.13 KB
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
name: Security Checks
# SPEC-03 §4 / §5: gitleaks, Semgrep and Trivy run on every PR. The gate is
# staged (ADR-03): at M1 Trivy is REPORT ONLY (exit-code 0); gitleaks, Semgrep,
# the manifest check and the private-URL policy are blocking from M1.
# Every `uses:` is pinned to a commit SHA; the comment names the tag it was
# resolved from.
on:
pull_request:
branches:
- develop
push:
branches:
- develop
permissions:
contents: read
jobs:
gitleaks:
name: Secret scan (gitleaks)
runs-on: ubuntu-latest
steps:
- name: Checkout (full history)
uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
with:
fetch-depth: 0
- name: Run gitleaks over the whole history
# .gitleaks.toml extends the default rules ([extend] useDefault = true)
# and allowlists only whole manifest SHA / digest lines.
run: |
docker run --rm -v "$PWD:/repo" -w /repo ghcr.io/gitleaks/gitleaks:v8.21.2 \
detect --source . --config .gitleaks.toml --redact --exit-code 1 \
--report-format json --report-path gitleaks-results.json || status=$?
test -z "${status:-}" || { echo "::error::gitleaks found possible secrets"; exit "$status"; }
- name: Upload report
if: always()
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
with:
name: gitleaks-report
path: gitleaks-results.json
if-no-files-found: ignore
semgrep:
name: Semgrep static analysis
runs-on: ubuntu-latest
container:
image: semgrep/semgrep:1.97.0
steps:
- name: Checkout
uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
- name: Run semgrep (p/default)
run: semgrep scan --config p/default --error --metrics=off .
trivy:
name: Trivy filesystem scan (report only at M1)
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
- name: Trivy fs scan (table, HIGH/CRITICAL)
# SPEC-03 §5 staged gate: M1-M3 = report only, so exit-code is '0'.
# Change exit-code to '1' at M4 (stop on HIGH) per ADR-03.
uses: aquasecurity/trivy-action@ed142fd0673e97e23eac54620cfb913e5ce36c25 # v0.36.0
with:
scan-type: fs
scan-ref: .
scanners: vuln,misconfig,secret
severity: HIGH,CRITICAL
exit-code: '0'
format: table
skip-dirs: site
- name: Trivy fs scan (SARIF report artifact)
# Same scan, machine-readable. Also report only at M1 (see above).
uses: aquasecurity/trivy-action@ed142fd0673e97e23eac54620cfb913e5ce36c25 # v0.36.0
with:
scan-type: fs
scan-ref: .
scanners: vuln,misconfig,secret
severity: HIGH,CRITICAL
exit-code: '0'
format: sarif
output: trivy-results.sarif
skip-dirs: site
skip-setup-trivy: true
- name: Upload Trivy report
if: always()
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
with:
name: trivy-report
path: trivy-results.sarif
if-no-files-found: ignore
manifest-check:
name: Manifest validation and private-URL policy
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
- name: Set up Python
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5
with:
python-version: '3.11'
- name: Manifest check (SPEC-01 MC-01..MC-11, MC-13; exit 20 on failure)
run: python3 tools/manifest_check.py --manifest-only
- name: Private-URL and token policy (all tracked files; exit 1 on failure)
# SPEC-01 rule 5 / SPEC-06 §5: no URL to -private or -dev2027
# repositories, no token-like strings, no private keys anywhere.
run: python3 tools/manifest_check.py --policy-only
- name: Unit tests for the checkers
run: python3 -m unittest discover -s tools/tests -v