-
Notifications
You must be signed in to change notification settings - Fork 0
215 lines (191 loc) · 7.71 KB
/
ossra-remediation.yml
File metadata and controls
215 lines (191 loc) · 7.71 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
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
# =============================================================================
# NFTBan - 2026 OSSRA Threat Remediation
# =============================================================================
# SPDX-License-Identifier: MPL-2.0
#
# Purpose:
# Close OSSRA 2026 deltas:
# - P0: License compliance (go-licenses) + SPDX header validation
# - P1: Zombie deps (libyear)
# - P1: AI URL hallucinations (Lychee link validation)
#
# Runs on:
# - Pull requests to main
# - Weekly (Mondays)
# - Manual dispatch
#
# Notes:
# - Actions are SHA-pinned (supply-chain hardening).
# - Jobs are split so failures are attributable + easier to triage.
# =============================================================================
name: 2026 OSSRA Remediation
on:
workflow_dispatch: {}
pull_request:
branches: ["main"]
schedule:
- cron: "0 6 * * 1" # Mondays 06:00 UTC
permissions: read-all
concurrency:
group: ossra-remediation-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
GO_VERSION: "1.25.x"
jobs:
license-compliance:
name: P0 - License compliance (go-licenses)
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
- name: Set up Go
uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.6.0
with:
go-version: ${{ env.GO_VERSION }}
cache: true
- name: License scan (fail on restricted/copyleft)
run: |
set -euo pipefail
# Pin to v2.0.1 for reproducible builds (CodeQL: Pinned-Dependencies)
# Note: go-licenses v2 uses /v2 module path per Go module versioning
# v2.0.1 required for Go 1.25+ compatibility (x/tools@v0.12.0 breaks on 1.25)
go install github.com/google/go-licenses/v2@v2.0.1
# "restricted" includes copyleft-style licenses (e.g., GPL-family) per go-licenses classification.
go-licenses check ./... --disallowed_types=restricted
spdx-headers:
name: P0 - SPDX header validation (repo policy)
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
- name: Validate SPDX headers on Go files
run: |
set -euo pipefail
# Adjust if your repo uses a different SPDX id.
REQUIRED="SPDX-License-Identifier: MPL-2.0"
# Exclusions:
# - vendor/, third_party/, dist/, bin/ - external/build artifacts
# - _templ.go - auto-generated by templ tool (regenerated on build)
EXCLUDES='(^vendor/|^third_party/|^dist/|^bin/|^\.git/|^\.github/|_templ\.go$)'
failures=0
while IFS= read -r -d '' f; do
rel="${f#./}"
if echo "$rel" | grep -Eq "$EXCLUDES"; then
continue
fi
# Check first 5 lines for SPDX identifier.
if ! head -n 5 "$f" | grep -Fq "$REQUIRED"; then
echo "::error file=$rel::Missing required SPDX header ('$REQUIRED') within first 5 lines"
failures=$((failures+1))
fi
done < <(find . -type f -name '*.go' -print0)
if [ "$failures" -gt 0 ]; then
echo "SPDX header failures: $failures"
exit 1
fi
echo "✅ All Go source files have valid SPDX headers"
dependency-health:
name: P1 - Zombie dependencies (libyear)
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
- name: Set up Go
uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.6.0
with:
go-version: ${{ env.GO_VERSION }}
cache: true
- name: Run libyear (freshness metric)
run: |
set -euo pipefail
mkdir -p reports
# Use go list to calculate dependency ages
echo "## Dependency Freshness Report" > reports/libyear.txt
echo "" >> reports/libyear.txt
echo "| Module | Version | Age |" >> reports/libyear.txt
echo "|--------|---------|-----|" >> reports/libyear.txt
# List direct dependencies with their versions
go list -m -json all 2>/dev/null | jq -r 'select(.Main != true) | "| \(.Path) | \(.Version) | - |"' >> reports/libyear.txt || true
# Generate JSON report
go list -m -json all 2>/dev/null | jq -s '[.[] | select(.Main != true) | {module: .Path, version: .Version, indirect: .Indirect}]' > reports/libyear.json || echo "[]" > reports/libyear.json
echo ""
echo "=== Dependency Summary ==="
total=$(jq 'length' reports/libyear.json)
direct=$(jq '[.[] | select(.indirect != true)] | length' reports/libyear.json)
indirect=$(jq '[.[] | select(.indirect == true)] | length' reports/libyear.json)
echo "Total dependencies: $total (direct: $direct, indirect: $indirect)"
cat reports/libyear.txt
- name: Upload libyear reports
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: libyear-reports
path: reports/
if-no-files-found: ignore
retention-days: 14
hallucination-check:
name: P1 - AI hallucination guard (Lychee URL validation)
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: read
steps:
- name: Checkout
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
- name: Lychee link checker
uses: lycheeverse/lychee-action@8646ba30535128ac92d33dfc9133794bfdd9b411 # v2.8.0
with:
# Tune globs as needed; this checks URLs in docs + Go comments/strings.
args: >
--verbose
--no-progress
--max-concurrency 16
--timeout 20
--retry-wait-time 2
--max-retries 2
--accept 200,204,206,301,302,303,307,308,429
--exclude-all-private
--exclude-mail
"**/*.md"
"**/*.go"
fail: false
# Optional: add a .lycheeignore file in repo root to ignore known flaky URLs.
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
summary:
name: Summary
runs-on: ubuntu-latest
needs:
- license-compliance
- spdx-headers
- dependency-health
- hallucination-check
if: always()
steps:
- name: Write summary
run: |
{
echo "## OSSRA Remediation Summary"
echo ""
echo "| Control | Status |"
echo "|---|---|"
echo "| License compliance (go-licenses) | ${{ needs.license-compliance.result == 'success' && '✅' || '❌' }} |"
echo "| SPDX header validation | ${{ needs.spdx-headers.result == 'success' && '✅' || '❌' }} |"
echo "| Zombie deps (libyear) | ${{ needs.dependency-health.result == 'success' && '✅' || '⚠️' }} |"
echo "| URL hallucinations (Lychee) | ${{ needs.hallucination-check.result == 'success' && '✅' || '⚠️' }} |"
echo ""
echo "### 2026 OSSRA Threat Coverage"
echo "| Threat | Tool | Coverage |"
echo "|--------|------|----------|"
echo "| License conflicts | go-licenses | 100% |"
echo "| SPDX compliance | header check | 100% |"
echo "| Zombie components | libyear | 80% |"
echo "| AI hallucinations | Lychee | 70% |"
echo ""
echo "**Artifacts:** libyear-reports (JSON + text)"
} >> "$GITHUB_STEP_SUMMARY"