-
Notifications
You must be signed in to change notification settings - Fork 2
235 lines (203 loc) · 7.23 KB
/
Copy pathsecurity.yml
File metadata and controls
235 lines (203 loc) · 7.23 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
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
name: 🔒 Security Analysis
on:
push:
branches: ["main"]
pull_request:
branches: ["main"]
schedule:
# Run security scan every day at 6:00 AM UTC
- cron: "0 6 * * *"
workflow_dispatch:
permissions:
actions: read
contents: read
security-events: write
issues: write
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
GO_VERSION: "1.26.4"
jobs:
# ===================================
# Static Analysis Security Testing
# ===================================
sast:
name: 🔍 Static Analysis
uses: ./.github/workflows/_reusable-security-scan.yml
with:
go-version: "1.26.4"
upload-sarif: true
run-vulncheck: false
# ===================================
# Vulnerability Scanning
# ===================================
vulnerability-scan:
name: 🛡️ Vulnerability Scan
uses: ./.github/workflows/_reusable-security-scan.yml
with:
go-version: "1.26.4"
upload-sarif: false
run-vulncheck: true
# ===================================
# License Compliance Check
# ===================================
license-check:
name: 📜 License Compliance
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: 📂 Checkout code
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: 🐹 Set up Go
uses: actions/setup-go@v6
with:
go-version: ${{ env.GO_VERSION }}
cache: true
- name: 📥 Download dependencies
run: go mod download
- name: 📜 Install go-licenses
run: go install github.com/google/go-licenses@latest
- name: 🔍 Check license compliance
id: license-check
run: |
echo "🔍 Checking license compliance..."
# Create licenses directory
mkdir -p licenses
# Generate license report
{
echo "## 📜 License Compliance Report"
echo ""
echo "**Generated:** $(date -u '+%Y-%m-%d %H:%M:%S UTC')"
echo ""
} > licenses/report.md
# Check for forbidden licenses (variable defined for future use)
# FORBIDDEN_LICENSES="GPL-2.0,GPL-3.0,AGPL-1.0,AGPL-3.0"
if go-licenses check ./...; then
echo "result=compliant" >> "$GITHUB_OUTPUT"
{
echo "### ✅ License Compliance"
echo "All dependencies use compatible licenses."
} >> licenses/report.md
else
echo "result=issues_found" >> "$GITHUB_OUTPUT"
{
echo "### ⚠️ License Issues Found"
echo "Some dependencies may have licensing issues. Review required."
} >> licenses/report.md
fi
{
echo ""
echo "### 📋 Dependency Licenses"
echo ""
} >> licenses/report.md
# List all licenses
go-licenses report ./... >> licenses/report.md 2>/dev/null || echo "Unable to generate detailed license report" >> licenses/report.md
- name: 📤 Upload license compliance results
uses: actions/upload-artifact@v7
with:
name: license-compliance-results
path: licenses/
retention-days: 30
# ===================================
# Secrets Detection
# ===================================
secrets-detection:
name: 🔐 Secrets Detection
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: 📂 Checkout code
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: 🔐 Run TruffleHog secrets detection
uses: trufflesecurity/trufflehog@main
with:
base: main
path: ./
extra_args: --results=verified,unknown
# ===================================
# Container Security Scanning
# ===================================
container-security:
name: 🐳 Container Security
runs-on: ubuntu-latest
timeout-minutes: 20
if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch'
strategy:
matrix:
os: [alpine, ubuntu-jammy]
steps:
- name: 📂 Checkout code
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: 🐳 Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: 🔨 Build container image
uses: docker/build-push-action@v7
with:
context: .
file: build/deploy/${{ matrix.os }}/Dockerfile
tags: yap-${{ matrix.os }}:security-scan
load: true
cache-from: type=gha
cache-to: type=gha,mode=max
# ===================================
# Security Summary Report
# ===================================
security-summary:
name: 📊 Security Summary
runs-on: ubuntu-latest
timeout-minutes: 5
needs: [sast, vulnerability-scan, license-check, secrets-detection]
if: always()
steps:
- name: 📥 Download security artifacts
uses: actions/download-artifact@v8
with:
pattern: "*-results"
merge-multiple: true
- name: 📝 Generate security summary
run: |
{
echo "## 🔒 Security Analysis Summary"
echo ""
echo "**Analysis Date:** $(date -u '+%Y-%m-%d %H:%M:%S UTC')"
echo "**Trigger:** ${{ github.event_name }}"
echo ""
echo "### 📋 Security Checks"
echo "| Check | Status | Details |"
echo "|-------|--------|---------|"
echo "| 🔍 Static Analysis | ${{ needs.sast.result }} | Gosec security scanner |"
echo "| 🛡️ Vulnerability Scan | ${{ needs.vulnerability-scan.result }} | Go vulnerability database |"
echo "| 📜 License Compliance | ${{ needs.license-check.result }} | Dependency license check |"
echo "| 🔐 Secrets Detection | ${{ needs.secrets-detection.result }} | TruffleHog scan |"
echo ""
} >> "$GITHUB_STEP_SUMMARY"
# Overall security status
if [[ "${{ needs.sast.result }}" == "success" && \
"${{ needs.vulnerability-scan.result }}" == "success" && \
"${{ needs.license-check.result }}" == "success" && \
"${{ needs.secrets-detection.result }}" == "success" ]]; then
{
echo "### ✅ Overall Security Status: PASS"
echo "All security checks completed successfully."
} >> "$GITHUB_STEP_SUMMARY"
else
{
echo "### ⚠️ Overall Security Status: REVIEW REQUIRED"
echo "Some security checks require attention. Please review the failed checks above."
} >> "$GITHUB_STEP_SUMMARY"
fi
{
echo ""
echo "### 🔗 Security Resources"
echo "- [Security Policy](https://github.com/${{ github.repository }}/security/policy)"
echo "- [Security Advisories](https://github.com/${{ github.repository }}/security/advisories)"
echo "- [Dependency Graph](https://github.com/${{ github.repository }}/network/dependencies)"
echo "- [Go Vulnerability Database](https://vuln.go.dev/)"
} >> "$GITHUB_STEP_SUMMARY"