This repository was archived by the owner on Apr 15, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
201 lines (172 loc) · 6.07 KB
/
validate-modules.yml
File metadata and controls
201 lines (172 loc) · 6.07 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
name: Validate Cryptographic Modules
on:
push:
branches: [main]
paths:
- 'modules/**/*.yaml'
- 'modules/**/*.yml'
- 'schemas/**'
- 'tools/validate.py'
pull_request:
branches: [main]
paths:
- 'modules/**/*.yaml'
- 'modules/**/*.yml'
- 'schemas/**'
workflow_dispatch:
schedule:
# Run daily at 6 AM UTC for continuous compliance monitoring
- cron: '0 6 * * *'
permissions:
contents: read
pull-requests: write
issues: write
jobs:
lint-yaml:
name: Lint YAML Files
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Run yamllint
uses: ibiqlik/action-yamllint@v3
with:
file_or_dir: modules/
config_file: .yamllint.yaml
validate-schema:
name: Validate Against JSON Schema
runs-on: ubuntu-latest
needs: lint-yaml
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
cache: 'pip'
- name: Install dependencies
run: |
pip install -r tools/requirements.txt
- name: Validate module files (schema only)
run: |
python tools/validate.py \
--schema schemas/v1/crypto-module.schema.json \
--modules modules/ \
--output validation-schema.json \
--format github-actions
- name: Upload schema validation results
uses: actions/upload-artifact@v4
if: always()
with:
name: validation-schema
path: validation-schema.json
validate-cmvp:
name: Validate Against CMVP Cache
runs-on: ubuntu-latest
needs: validate-schema
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
cache: 'pip'
- name: Install dependencies
run: pip install -r tools/requirements.txt
- name: Restore CMVP cache
uses: actions/cache@v4
with:
path: cmvp-cache/
key: cmvp-cache-${{ hashFiles('cmvp-cache/metadata.json') }}
restore-keys: |
cmvp-cache-
- name: Validate certificates against CMVP
id: cmvp-validation
run: |
python tools/validate.py \
--modules modules/ \
--schema schemas/v1/crypto-module.schema.json \
--cmvp-cache cmvp-cache/ \
--output validation-cmvp.json \
--format github-actions
- name: Upload CMVP validation results
uses: actions/upload-artifact@v4
if: always()
with:
name: validation-cmvp
path: validation-cmvp.json
- name: Comment on PR with results
if: github.event_name == 'pull_request' && always()
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
let results;
try {
results = JSON.parse(fs.readFileSync('validation-cmvp.json', 'utf8'));
} catch (e) {
console.log('Could not read validation results:', e.message);
return;
}
let comment = '## Cryptographic Module Validation Results\n\n';
// Summary table
comment += '| Metric | Count |\n';
comment += '|--------|-------|\n';
comment += `| Total Modules | ${results.totalModules} |\n`;
comment += `| Valid | ${results.validModules} |\n`;
comment += `| Invalid | ${results.invalidModules} |\n`;
comment += `| Warnings | ${results.warningsCount} |\n\n`;
if (results.errors && results.errors.length > 0) {
comment += '### :x: Validation Errors\n\n';
for (const error of results.errors.slice(0, 10)) {
comment += `- **${error.module}**: ${error.message}\n`;
}
if (results.errors.length > 10) {
comment += `\n*...and ${results.errors.length - 10} more errors*\n`;
}
}
if (results.warnings && results.warnings.length > 0) {
comment += '\n### :warning: Warnings\n\n';
for (const warning of results.warnings.slice(0, 10)) {
comment += `- **${warning.module}**: ${warning.message}\n`;
}
if (results.warnings.length > 10) {
comment += `\n*...and ${results.warnings.length - 10} more warnings*\n`;
}
}
if (results.invalidModules === 0) {
comment += '\n### :white_check_mark: All modules validated successfully!\n';
}
comment += `\n---\n*Validated at ${results.timestamp}*`;
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: comment
});
generate-json:
name: Generate JSON Files
runs-on: ubuntu-latest
needs: validate-cmvp
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
cache: 'pip'
- name: Install dependencies
run: pip install -r tools/requirements.txt
- name: Generate JSON from YAML
run: |
python tools/convert.py modules/ --merge -o modules/_generated/all-modules.json
python tools/convert.py modules/data-in-transit -f json -o modules/_generated/data-in-transit
python tools/convert.py modules/data-at-rest -f json -o modules/_generated/data-at-rest
python tools/convert.py modules/data-in-use -f json -o modules/_generated/data-in-use
- name: Commit generated files
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: "chore: Generate JSON files from YAML [skip ci]"
file_pattern: "modules/_generated/**"