-
Notifications
You must be signed in to change notification settings - Fork 0
178 lines (151 loc) · 5.6 KB
/
Copy pathcve-scan.yml
File metadata and controls
178 lines (151 loc) · 5.6 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
name: CVE Security Scan
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
schedule:
- cron: '0 2 * * *'
workflow_dispatch:
permissions:
contents: read
security-events: write
env:
SEVERITY_CUTOFF: ${{ vars.SECURITY_SEVERITY_CUTOFF || 'CRITICAL,HIGH' }}
jobs:
security-scan:
if: github.ref != 'refs/heads/gh-pages'
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
submodules: true
- name: Trivy filesystem scan
uses: aquasecurity/trivy-action@master
with:
scan-type: 'fs'
scan-ref: '.'
format: 'sarif'
output: 'trivy-results.sarif'
severity: ${{ env.SEVERITY_CUTOFF }}
exit-code: '1'
- name: Upload Trivy SARIF to GitHub Security
uses: github/codeql-action/upload-sarif@v4
if: always() && hashFiles('trivy-results.sarif') != ''
continue-on-error: true
with:
sarif_file: 'trivy-results.sarif'
- name: License compatibility check
if: always()
run: |
python3 << 'EOF'
import json
import sys
COMPATIBLE_LICENSES = {
'MIT', 'BSD-2-Clause', 'BSD-3-Clause', 'Apache-2.0',
'ISC', 'Unlicense', 'BSL-1.0', 'Zlib', 'PostgreSQL',
'Public Domain',
}
CONDITIONAL_LICENSES = {
'LGPL-2.1': 'dynamic linking required',
'LGPL-2.1-or-later': 'dynamic linking required',
'LGPL-3.0': 'dynamic linking required',
}
INCOMPATIBLE_LICENSES = {
'GPL-2.0', 'GPL-2.0-only', 'GPL-2.0-or-later',
'GPL-3.0', 'GPL-3.0-only', 'GPL-3.0-or-later',
'AGPL-3.0',
}
with open('vcpkg.json', 'r') as f:
manifest = json.load(f)
project = manifest.get('name', 'unknown')
project_license = manifest.get('license', 'unknown')
print(f"License Compatibility Check: {project} ({project_license})")
print("=" * 60)
known_licenses = {
'asio': 'BSL-1.0',
'fmt': 'MIT',
'zlib': 'Zlib',
'openssl': 'Apache-2.0',
'spdlog': 'MIT',
'gtest': 'BSD-3-Clause',
'benchmark': 'Apache-2.0',
'simdutf': 'MIT',
'libmariadb': 'LGPL-2.1',
'libpq': 'PostgreSQL',
'libpqxx': 'BSD-3-Clause',
'sqlite3': 'Public Domain',
'hiredis': 'BSD-3-Clause',
'grpc': 'Apache-2.0',
'protobuf': 'BSD-3-Clause',
'opentelemetry-cpp': 'Apache-2.0',
'mongo-cxx-driver': 'Apache-2.0',
}
all_ok = True
def collect_deps(deps_list):
names = []
for dep in deps_list:
if isinstance(dep, str):
names.append(dep)
elif isinstance(dep, dict):
names.append(dep.get('name', 'unknown'))
return names
dep_names = collect_deps(manifest.get('dependencies', []))
for feat_data in manifest.get('features', {}).values():
dep_names.extend(collect_deps(feat_data.get('dependencies', [])))
dep_names = sorted(set(dep_names))
for dep_name in dep_names:
if dep_name.startswith('kcenon-'):
print(f" {dep_name:25} {'BSD-3-Clause':15} ECOSYSTEM")
continue
license_id = known_licenses.get(dep_name)
if license_id is None:
print(f" {dep_name:25} {'UNKNOWN':15} REVIEW NEEDED")
continue
if license_id in COMPATIBLE_LICENSES:
print(f" {dep_name:25} {license_id:15} COMPATIBLE")
elif license_id in CONDITIONAL_LICENSES:
note = CONDITIONAL_LICENSES[license_id]
print(f" {dep_name:25} {license_id:15} CONDITIONAL ({note})")
elif license_id in INCOMPATIBLE_LICENSES:
print(f" {dep_name:25} {license_id:15} INCOMPATIBLE")
all_ok = False
else:
print(f" {dep_name:25} {license_id:15} REVIEW NEEDED")
print("=" * 60)
if all_ok:
print("All dependencies are license compatible")
else:
print("License compatibility issues found!")
sys.exit(1)
EOF
- name: Generate security report
if: always()
run: |
echo "# Security Scan Report" > security-report.md
echo "" >> security-report.md
echo "**Scan Date**: $(date -u)" >> security-report.md
echo "**Repository**: ${{ github.repository }}" >> security-report.md
echo "**Branch**: ${{ github.ref_name }}" >> security-report.md
echo "**Commit**: ${{ github.sha }}" >> security-report.md
echo "**Severity Threshold**: ${{ env.SEVERITY_CUTOFF }}" >> security-report.md
echo "" >> security-report.md
if [ -f "trivy-results.sarif" ]; then
echo "## Vulnerability Scan" >> security-report.md
echo "" >> security-report.md
echo "Trivy filesystem scan completed. Check the GitHub Security tab" >> security-report.md
echo "for detailed results." >> security-report.md
else
echo "## Vulnerability Scan" >> security-report.md
echo "" >> security-report.md
echo "Scan failed or no results generated." >> security-report.md
fi
- name: Upload security report
uses: actions/upload-artifact@v7
if: always()
continue-on-error: true
with:
name: security-report-${{ github.sha }}
path: security-report.md
retention-days: 30