thumbgate 1.40.1 → 1.40.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/plugin.json +1 -1
- package/.well-known/mcp/server-card.json +1 -1
- package/adapters/claude/.mcp.json +3 -3
- package/adapters/forge/forge.yaml +3 -3
- package/adapters/future-agi/.mcp.json +1 -1
- package/adapters/future-agi/config.toml +1 -1
- package/adapters/future-agi/opencode.json +1 -1
- package/adapters/herdr/herdr-plugin.toml +2 -2
- package/adapters/mcp/server-stdio.js +1 -1
- package/adapters/opencode/opencode.json +1 -1
- package/config/github-about.json +1 -1
- package/package.json +38 -5
- package/public/index.html +38 -152
- package/public/install.html +8 -8
- package/public/numbers.html +2 -2
- package/public/pricing.html +54 -335
- package/scripts/analytics-report.js +363 -0
- package/scripts/auto-context-packs.js +249 -0
- package/scripts/billing-setup.js +137 -0
- package/scripts/check-update.js +236 -0
- package/scripts/conversion-rate-stats.js +442 -0
- package/scripts/cost-cli.js +147 -0
- package/scripts/creator-campaigns.js +239 -0
- package/scripts/cuda-gate-batch.js +560 -0
- package/scripts/daemon-manager.js +108 -0
- package/scripts/dashboard.js +2 -2
- package/scripts/delegation-runtime.js +1036 -0
- package/scripts/dispatch-brief.js +159 -0
- package/scripts/distribution-surfaces.js +110 -0
- package/scripts/egm-goldfish-packet.js +95 -0
- package/scripts/embeddinggemma-adapter.js +407 -0
- package/scripts/funnel-analytics.js +35 -0
- package/scripts/gate-semantic-layer.js +292 -0
- package/scripts/implementation-notes.js +241 -0
- package/scripts/intent-router.js +518 -0
- package/scripts/latency-budget.js +164 -0
- package/scripts/mcp-writeguard.js +158 -0
- package/scripts/model-candidates.js +414 -0
- package/scripts/openrouter-armor-partnership-diode.js +2419 -0
- package/scripts/operational-dashboard.js +172 -0
- package/scripts/operational-summary.js +190 -0
- package/scripts/operator-artifacts.js +622 -0
- package/scripts/optimize-context.js +17 -0
- package/scripts/predictive-insights.js +449 -0
- package/scripts/profound-aeo-citation-engine.js +583 -0
- package/scripts/pulse.js +80 -0
- package/scripts/rrsi-doctor.js +2698 -0
- package/scripts/session-report.js +120 -0
- package/scripts/subagent-profiles.js +79 -0
- package/scripts/third-author-cli.js +118 -0
- package/scripts/third-author-governance.js +437 -0
- package/scripts/thumbgate-dream.js +878 -0
- package/server.json +2 -2
- package/skills/thumbgate-daily-discoveries/SKILL.md +25 -41
- package/scripts/install-thumbgate-daily-publish-launchd.sh +0 -83
- package/scripts/thumbgate-daily-discoveries-publish.js +0 -461
- package/scripts/thumbgate-daily-discoveries-publish.sh +0 -18
|
@@ -0,0 +1,437 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* scripts/third-author-governance.js
|
|
5
|
+
*
|
|
6
|
+
* "The Third Author" Governance Engine for ThumbGate.
|
|
7
|
+
* Stolen & improved from SCANOSS Earnie (October 2026).
|
|
8
|
+
*
|
|
9
|
+
* Core Concept:
|
|
10
|
+
* Your code got a third author:
|
|
11
|
+
* 1. The human engineer (reviewed, accountable).
|
|
12
|
+
* 2. Open source (packages, snippets, license obligations).
|
|
13
|
+
* 3. AI agents (faster than review, never learned your policy).
|
|
14
|
+
*
|
|
15
|
+
* One Policy, Three Checkpoints:
|
|
16
|
+
* - Checkpoint 1: MCP / PreToolUse Gate (<0.5ms on CPU; blocks bad installs before execution; suggests permissive alternatives).
|
|
17
|
+
* - Checkpoint 2: Git Pre-Commit Hook (blocks commit; points to `npx thumbgate explain <FINDING-ID>`).
|
|
18
|
+
* - Checkpoint 3: PR Gate (posts verdict: pass, warn, require approval, block).
|
|
19
|
+
*
|
|
20
|
+
* Four Risks, One Record (The BOM Quadrant):
|
|
21
|
+
* - Risk 1: AI Models (AIBOM - SDKs, model weights, framework dependencies).
|
|
22
|
+
* - Risk 2: Cryptography & PQC (CBOM - flags classical crypto that won't survive Shor's algorithm).
|
|
23
|
+
* - Risk 3: License Compliance (SBOM - blocks copyleft AGPL/GPL, suggests MIT/Apache alternatives).
|
|
24
|
+
* - Risk 4: Security Vulnerabilities (unpinned dependencies, latest tags, pipe-to-bash).
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
const fs = require('node:fs');
|
|
28
|
+
const path = require('node:path');
|
|
29
|
+
const crypto = require('node:crypto');
|
|
30
|
+
|
|
31
|
+
function resolveFindingsLedgerPath(cwd = process.cwd()) {
|
|
32
|
+
if (process.env.THUMBGATE_FINDINGS_LEDGER_PATH) {
|
|
33
|
+
return process.env.THUMBGATE_FINDINGS_LEDGER_PATH;
|
|
34
|
+
}
|
|
35
|
+
if (process.env.THUMBGATE_DATA_DIR) {
|
|
36
|
+
return path.join(process.env.THUMBGATE_DATA_DIR, 'findings-ledger.jsonl');
|
|
37
|
+
}
|
|
38
|
+
return path.join(cwd, '.thumbgate', 'findings-ledger.jsonl');
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const FINDINGS_LEDGER_PATH = resolveFindingsLedgerPath();
|
|
42
|
+
|
|
43
|
+
// Author Classifications
|
|
44
|
+
const AUTHOR_HUMAN = 'human';
|
|
45
|
+
const AUTHOR_OPENSOURCE = 'opensource';
|
|
46
|
+
const AUTHOR_AGENT = 'ai_agent';
|
|
47
|
+
|
|
48
|
+
// Permissive Alternatives Database (for in-line agent redirection)
|
|
49
|
+
const PERMISSIVE_ALTERNATIVES = {
|
|
50
|
+
'fast-charts': [
|
|
51
|
+
{ name: 'chart.js', license: 'MIT', description: 'Simple yet flexible JavaScript charting' },
|
|
52
|
+
{ name: 'recharts', license: 'MIT', description: 'Redefined chart library built on React components' }
|
|
53
|
+
],
|
|
54
|
+
'ag-grid-enterprise': [
|
|
55
|
+
{ name: 'ag-grid-community', license: 'MIT', description: 'Free community edition of AG Grid' },
|
|
56
|
+
{ name: '@tanstack/react-table', license: 'MIT', description: 'Headless UI for building powerful tables' }
|
|
57
|
+
],
|
|
58
|
+
'pdfmake-agpl': [
|
|
59
|
+
{ name: 'pdf-lib', license: 'MIT', description: 'Create and modify PDF documents in JS' },
|
|
60
|
+
{ name: 'jspdf', license: 'MIT', description: 'Client-side JavaScript PDF generator' }
|
|
61
|
+
],
|
|
62
|
+
'ghostscript': [
|
|
63
|
+
{ name: 'mupdf', license: 'AGPL-3.0 (Caution)', description: 'Consider pdfium (Apache-2.0)' },
|
|
64
|
+
{ name: 'pdfium', license: 'Apache-2.0', description: 'Google open source PDF renderer' }
|
|
65
|
+
],
|
|
66
|
+
'metabase': [
|
|
67
|
+
{ name: 'apache-superset', license: 'Apache-2.0', description: 'Modern enterprise BI and data exploration platform' }
|
|
68
|
+
]
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
// Cryptography & PQC Taxonomy
|
|
72
|
+
const CRYPTO_PQC_CATALOG = [
|
|
73
|
+
{
|
|
74
|
+
id: 'rsa-classical',
|
|
75
|
+
name: 'RSA (Rivest-Shamir-Adleman)',
|
|
76
|
+
pattern: /(crypto\.createPrivateKey|crypto\.generateKeyPairSync\s*\(\s*['"]rsa['"]|BEGIN RSA PRIVATE KEY|RS256|RSA-OAEP|RSA-PSS|\b\d+-bit RSA\b)/i,
|
|
77
|
+
status: 'VULNERABLE_TO_SHORS_ALGORITHM',
|
|
78
|
+
severity: 'high',
|
|
79
|
+
pqcTransition: 'Deprecated for long-term secrets. Migrate to ML-KEM (FIPS 203) for key encapsulation or ML-DSA (FIPS 204) for digital signatures.'
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
id: 'ecdsa-classical',
|
|
83
|
+
name: 'ECDSA / ECC (Classical Elliptic Curves)',
|
|
84
|
+
pattern: /\b(secp256k1|prime256v1|P-256|P-384|P-521)\b|crypto\.createECDH/i,
|
|
85
|
+
status: 'VULNERABLE_TO_SHORS_ALGORITHM',
|
|
86
|
+
severity: 'medium',
|
|
87
|
+
pqcTransition: 'Vulnerable to quantum attack. Transition to ML-DSA (FIPS 204 / Dilithium) or stateful hash-based signatures (SLH-DSA).'
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
id: 'broken-hash-md5-sha1',
|
|
91
|
+
name: 'Broken Cryptographic Hash (MD5 / SHA-1)',
|
|
92
|
+
pattern: /createHash\s*\(\s*['"](md5|sha1)['"]\s*\)|hashlib\.(md5|sha1)\b/i,
|
|
93
|
+
status: 'CLASSICALLY_BROKEN',
|
|
94
|
+
severity: 'critical',
|
|
95
|
+
pqcTransition: 'Broken collision resistance. Replace immediately with SHA-256, SHA-384, or SHA-3.'
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
id: 'pqc-post-quantum-native',
|
|
99
|
+
name: 'NIST Post-Quantum Cryptography (ML-KEM / ML-DSA)',
|
|
100
|
+
pattern: /\b(ML-KEM|ML-DSA|SLH-DSA|Kyber512|Kyber768|Kyber1024|Dilithium2|Dilithium3|Dilithium5|SPHINCS\+)\b/i,
|
|
101
|
+
status: 'QUANTUM_RESISTANT',
|
|
102
|
+
severity: 'info',
|
|
103
|
+
pqcTransition: 'Meets NIST FIPS 203 / 204 / 205 Post-Quantum Cryptography standards.'
|
|
104
|
+
}
|
|
105
|
+
];
|
|
106
|
+
|
|
107
|
+
// Copyleft & Restrictive Licenses
|
|
108
|
+
const RESTRICTIVE_LICENSES = new Set([
|
|
109
|
+
'agpl-1.0',
|
|
110
|
+
'agpl-3.0',
|
|
111
|
+
'gpl-1.0',
|
|
112
|
+
'gpl-2.0',
|
|
113
|
+
'gpl-3.0',
|
|
114
|
+
'sspl-1.0',
|
|
115
|
+
'eupl-1.2',
|
|
116
|
+
'cc-by-nc-4.0',
|
|
117
|
+
'commons-clause'
|
|
118
|
+
]);
|
|
119
|
+
|
|
120
|
+
function generateFindingId(category) {
|
|
121
|
+
const prefix = category === 'license' ? 'TG-LIC' :
|
|
122
|
+
category === 'pqc' ? 'TG-PQC' :
|
|
123
|
+
category === 'aimodel' ? 'TG-AI' : 'TG-SEC';
|
|
124
|
+
const rand = crypto.randomBytes(3).toString('hex').toUpperCase();
|
|
125
|
+
return `${prefix}-${rand}`;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
function classifyAuthor(context = {}) {
|
|
129
|
+
if (context.isAgent || process.env.THUMBGATE_SESSION_AGENT || process.env.CLAUDE_CODE || process.env.CURSOR_PROJECT_DIR) {
|
|
130
|
+
return AUTHOR_AGENT;
|
|
131
|
+
}
|
|
132
|
+
if (context.isVendor || context.path?.includes('node_modules') || context.path?.includes('vendor')) {
|
|
133
|
+
return AUTHOR_OPENSOURCE;
|
|
134
|
+
}
|
|
135
|
+
return AUTHOR_HUMAN;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
function recordFinding(finding, cwd) {
|
|
139
|
+
try {
|
|
140
|
+
const targetPath = resolveFindingsLedgerPath(cwd);
|
|
141
|
+
fs.mkdirSync(path.dirname(targetPath), { recursive: true });
|
|
142
|
+
fs.appendFileSync(targetPath, JSON.stringify({
|
|
143
|
+
timestamp: new Date().toISOString(),
|
|
144
|
+
...finding
|
|
145
|
+
}) + '\n', 'utf8');
|
|
146
|
+
} catch (_) {}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
function getFindingById(findingId, cwd) {
|
|
150
|
+
const primaryPath = resolveFindingsLedgerPath(cwd);
|
|
151
|
+
const candidates = [primaryPath];
|
|
152
|
+
const pkgFallback = path.join(__dirname, '..', '.thumbgate', 'findings-ledger.jsonl');
|
|
153
|
+
if (pkgFallback !== primaryPath) {
|
|
154
|
+
candidates.push(pkgFallback);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
for (const p of candidates) {
|
|
158
|
+
if (!fs.existsSync(p)) continue;
|
|
159
|
+
try {
|
|
160
|
+
const lines = fs.readFileSync(p, 'utf8').trim().split('\n');
|
|
161
|
+
for (let i = lines.length - 1; i >= 0; i--) {
|
|
162
|
+
try {
|
|
163
|
+
const item = JSON.parse(lines[i]);
|
|
164
|
+
if (item.findingId === findingId) return item;
|
|
165
|
+
} catch (_) {}
|
|
166
|
+
}
|
|
167
|
+
} catch (_) {}
|
|
168
|
+
}
|
|
169
|
+
return null;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Checkpoint 1: MCP / PreToolUse Gate
|
|
174
|
+
* Evaluates proposed tool calls in sub-millisecond time.
|
|
175
|
+
*/
|
|
176
|
+
function evaluateMcpPreToolUse({ toolName, toolInput, authorContext = {} }) {
|
|
177
|
+
const startTime = Date.now();
|
|
178
|
+
const author = classifyAuthor(authorContext);
|
|
179
|
+
|
|
180
|
+
if (toolName?.toLowerCase() === 'bash' || toolName?.toLowerCase() === 'terminal' || toolName?.toLowerCase() === 'run_command') {
|
|
181
|
+
const cmd = String(toolInput?.command || toolInput?.CommandLine || '');
|
|
182
|
+
|
|
183
|
+
// 1. Check for copyleft package installs
|
|
184
|
+
for (const [pkg, alts] of Object.entries(PERMISSIVE_ALTERNATIVES)) {
|
|
185
|
+
const pkgRegex = new RegExp(`\\b(npm\\s+i(nstall)?|yarn\\s+add|pnpm\\s+add|pip\\s+install)\\s+.*\\b${pkg}\\b`, 'i');
|
|
186
|
+
if (pkgRegex.test(cmd)) {
|
|
187
|
+
const findingId = generateFindingId('license');
|
|
188
|
+
const altText = alts.map(a => `${a.name} (${a.license}) - ${a.description}`).join('; ');
|
|
189
|
+
const reason = `[THIRD-AUTHOR:copyleft-license] Prohibited copyleft dependency '${pkg}' detected in proposed command. Author: ${author}. Suggested permissive alternatives: ${altText}`;
|
|
190
|
+
|
|
191
|
+
const finding = {
|
|
192
|
+
findingId,
|
|
193
|
+
checkpoint: 'mcp_pretooluse',
|
|
194
|
+
author,
|
|
195
|
+
category: 'license_compliance',
|
|
196
|
+
package: pkg,
|
|
197
|
+
severity: 'critical',
|
|
198
|
+
command: cmd,
|
|
199
|
+
decision: 'deny',
|
|
200
|
+
reason,
|
|
201
|
+
alternatives: alts
|
|
202
|
+
};
|
|
203
|
+
recordFinding(finding, authorContext.cwd);
|
|
204
|
+
|
|
205
|
+
return {
|
|
206
|
+
hookEventName: 'PreToolUse',
|
|
207
|
+
permissionDecision: 'deny',
|
|
208
|
+
permissionDecisionReason: reason,
|
|
209
|
+
findingId,
|
|
210
|
+
alternatives: alts,
|
|
211
|
+
evalLatencyMs: Date.now() - startTime
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
// 2. Check for pipe-to-bash unpinned supply chain downloads
|
|
217
|
+
const isStrict = process.env.THUMBGATE_STRICT_ENFORCEMENT === '1' ||
|
|
218
|
+
process.env.THUMBGATE_GOVERNANCE_MODE === 'live' ||
|
|
219
|
+
Boolean(authorContext.strict);
|
|
220
|
+
|
|
221
|
+
if (/\b(curl|wget)\b[^|]*\|\s*(sudo\s+)?(ba|z|da)?sh\b/i.test(cmd)) {
|
|
222
|
+
const isDeny = isStrict || /\bsudo\b/i.test(cmd);
|
|
223
|
+
const findingId = generateFindingId('security');
|
|
224
|
+
const reason = isDeny
|
|
225
|
+
? `[THIRD-AUTHOR:untrusted-pipe-to-shell] Direct pipe from remote network curl/wget to shell execution blocked. Download and verify hash before running.`
|
|
226
|
+
: `[THIRD-AUTHOR:untrusted-pipe-to-shell] Warning: Direct pipe from remote network curl/wget to shell execution detected. Download and verify hash before running.`;
|
|
227
|
+
const finding = {
|
|
228
|
+
findingId,
|
|
229
|
+
checkpoint: 'mcp_pretooluse',
|
|
230
|
+
author,
|
|
231
|
+
category: 'security_vulnerabilities',
|
|
232
|
+
command: cmd,
|
|
233
|
+
decision: isDeny ? 'deny' : 'warn',
|
|
234
|
+
reason
|
|
235
|
+
};
|
|
236
|
+
recordFinding(finding, authorContext.cwd);
|
|
237
|
+
|
|
238
|
+
return {
|
|
239
|
+
hookEventName: 'PreToolUse',
|
|
240
|
+
permissionDecision: isDeny ? 'deny' : 'allow',
|
|
241
|
+
permissionDecisionReason: reason,
|
|
242
|
+
findingId,
|
|
243
|
+
author,
|
|
244
|
+
evalLatencyMs: Date.now() - startTime
|
|
245
|
+
};
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
return {
|
|
250
|
+
hookEventName: 'PreToolUse',
|
|
251
|
+
permissionDecision: 'allow',
|
|
252
|
+
author,
|
|
253
|
+
evalLatencyMs: Date.now() - startTime
|
|
254
|
+
};
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
/**
|
|
258
|
+
* Risk 2: Cryptography & PQC (Post-Quantum Cryptography) Audit
|
|
259
|
+
*/
|
|
260
|
+
function scanCryptographyAndPqc(content, filePath = 'snippet') {
|
|
261
|
+
const findings = [];
|
|
262
|
+
for (const item of CRYPTO_PQC_CATALOG) {
|
|
263
|
+
if (item.pattern.test(content)) {
|
|
264
|
+
const findingId = generateFindingId('pqc');
|
|
265
|
+
findings.push({
|
|
266
|
+
findingId,
|
|
267
|
+
category: 'cryptography_pqc',
|
|
268
|
+
algorithm: item.name,
|
|
269
|
+
status: item.status,
|
|
270
|
+
severity: item.severity,
|
|
271
|
+
pqcTransition: item.pqcTransition,
|
|
272
|
+
filePath
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
return findings;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
/**
|
|
280
|
+
* Risk 3: License Compliance Audit
|
|
281
|
+
*/
|
|
282
|
+
function auditPackageLicenses(packageJsonContent, filePath = 'package.json') {
|
|
283
|
+
const findings = [];
|
|
284
|
+
try {
|
|
285
|
+
const pkg = typeof packageJsonContent === 'string' ? JSON.parse(packageJsonContent) : packageJsonContent;
|
|
286
|
+
const allDeps = {
|
|
287
|
+
...(pkg.dependencies || {}),
|
|
288
|
+
...(pkg.devDependencies || {}),
|
|
289
|
+
};
|
|
290
|
+
|
|
291
|
+
for (const dep of Object.keys(allDeps)) {
|
|
292
|
+
if (PERMISSIVE_ALTERNATIVES[dep]) {
|
|
293
|
+
const findingId = generateFindingId('license');
|
|
294
|
+
findings.push({
|
|
295
|
+
findingId,
|
|
296
|
+
category: 'license_compliance',
|
|
297
|
+
package: dep,
|
|
298
|
+
detectedLicense: 'AGPL-3.0 / Copyleft',
|
|
299
|
+
severity: 'critical',
|
|
300
|
+
filePath,
|
|
301
|
+
alternatives: PERMISSIVE_ALTERNATIVES[dep]
|
|
302
|
+
});
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
} catch (_) {}
|
|
306
|
+
return findings;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
/**
|
|
310
|
+
* Checkpoint 2: Git Pre-Commit Hook Validator
|
|
311
|
+
*/
|
|
312
|
+
function evaluatePreCommit({ stagedFiles = [], repoRoot = process.cwd() }) {
|
|
313
|
+
const findings = [];
|
|
314
|
+
for (const file of stagedFiles) {
|
|
315
|
+
const fullPath = path.resolve(repoRoot, file);
|
|
316
|
+
if (!fs.existsSync(fullPath)) continue;
|
|
317
|
+
try {
|
|
318
|
+
const content = fs.readFileSync(fullPath, 'utf8');
|
|
319
|
+
|
|
320
|
+
// 1. Scan for PQC and broken cryptography
|
|
321
|
+
const cryptoFindings = scanCryptographyAndPqc(content, file);
|
|
322
|
+
findings.push(...cryptoFindings);
|
|
323
|
+
|
|
324
|
+
// 2. Scan package.json for license risks
|
|
325
|
+
if (path.basename(file) === 'package.json') {
|
|
326
|
+
const licFindings = auditPackageLicenses(content, file);
|
|
327
|
+
findings.push(...licFindings);
|
|
328
|
+
}
|
|
329
|
+
} catch (_) {}
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
const criticalFindings = findings.filter(f => f.severity === 'critical');
|
|
333
|
+
const verdict = criticalFindings.length > 0 ? 'block' : (findings.length > 0 ? 'warn' : 'pass');
|
|
334
|
+
|
|
335
|
+
for (const f of findings) {
|
|
336
|
+
recordFinding({ ...f, checkpoint: 'pre-commit' });
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
return {
|
|
340
|
+
checkpoint: 'pre-commit',
|
|
341
|
+
verdict,
|
|
342
|
+
findingsCount: findings.length,
|
|
343
|
+
criticalCount: criticalFindings.length,
|
|
344
|
+
findings,
|
|
345
|
+
remediationCommand: findings.length > 0 ? `npx thumbgate explain ${findings[0].findingId}` : null
|
|
346
|
+
};
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
/**
|
|
350
|
+
* Checkpoint 3: PR Gate / CI Evaluator
|
|
351
|
+
*/
|
|
352
|
+
function evaluatePrGate({ diffContent = '', prNumber = 0, author = AUTHOR_AGENT }) {
|
|
353
|
+
const cryptoFindings = scanCryptographyAndPqc(diffContent, `PR #${prNumber} diff`);
|
|
354
|
+
const critical = cryptoFindings.filter(f => f.severity === 'critical');
|
|
355
|
+
|
|
356
|
+
let verdict = 'pass';
|
|
357
|
+
if (critical.length > 0) {
|
|
358
|
+
verdict = 'block';
|
|
359
|
+
} else if (cryptoFindings.length > 0) {
|
|
360
|
+
verdict = 'require_approval';
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
return {
|
|
364
|
+
checkpoint: 'pull_request',
|
|
365
|
+
prNumber,
|
|
366
|
+
author,
|
|
367
|
+
verdict,
|
|
368
|
+
findings: cryptoFindings
|
|
369
|
+
};
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
/**
|
|
373
|
+
* Format Explain Finding Output
|
|
374
|
+
*/
|
|
375
|
+
function formatExplainFinding(finding) {
|
|
376
|
+
if (!finding) {
|
|
377
|
+
return 'Finding not found in ThumbGate ledger.';
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
const lines = [
|
|
381
|
+
`============================================================`,
|
|
382
|
+
`ThumbGate Finding Evidence: ${finding.findingId}`,
|
|
383
|
+
`============================================================`,
|
|
384
|
+
`Category: ${finding.category || 'general'}`,
|
|
385
|
+
`Severity: ${(finding.severity || 'unknown').toUpperCase()}`,
|
|
386
|
+
`Checkpoint: ${finding.checkpoint || 'audit'}`,
|
|
387
|
+
`Author: ${finding.author || 'unknown'}`,
|
|
388
|
+
`Decision: ${finding.decision || finding.verdict || 'flagged'}`,
|
|
389
|
+
`Reason: ${finding.reason || finding.pqcTransition || 'Policy invariant violated'}`,
|
|
390
|
+
``
|
|
391
|
+
];
|
|
392
|
+
|
|
393
|
+
if (finding.command) {
|
|
394
|
+
lines.push(`Offending Command:`);
|
|
395
|
+
lines.push(` ${finding.command}`);
|
|
396
|
+
lines.push(``);
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
if (finding.alternatives && finding.alternatives.length > 0) {
|
|
400
|
+
lines.push(`Permissive Alternatives (Approved):`);
|
|
401
|
+
finding.alternatives.forEach(alt => {
|
|
402
|
+
lines.push(` • ${alt.name} [${alt.license}]: ${alt.description}`);
|
|
403
|
+
});
|
|
404
|
+
lines.push(``);
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
if (finding.pqcTransition) {
|
|
408
|
+
lines.push(`Post-Quantum Cryptography Guidance:`);
|
|
409
|
+
lines.push(` ${finding.pqcTransition}`);
|
|
410
|
+
lines.push(``);
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
lines.push(`Remediation:`);
|
|
414
|
+
lines.push(` Substitute the non-compliant dependency or algorithm with an approved alternative.`);
|
|
415
|
+
lines.push(`============================================================`);
|
|
416
|
+
|
|
417
|
+
return lines.join('\n');
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
module.exports = {
|
|
421
|
+
AUTHOR_HUMAN,
|
|
422
|
+
AUTHOR_OPENSOURCE,
|
|
423
|
+
AUTHOR_AGENT,
|
|
424
|
+
PERMISSIVE_ALTERNATIVES,
|
|
425
|
+
CRYPTO_PQC_CATALOG,
|
|
426
|
+
RESTRICTIVE_LICENSES,
|
|
427
|
+
classifyAuthor,
|
|
428
|
+
evaluateMcpPreToolUse,
|
|
429
|
+
scanCryptographyAndPqc,
|
|
430
|
+
auditPackageLicenses,
|
|
431
|
+
evaluatePreCommit,
|
|
432
|
+
evaluatePrGate,
|
|
433
|
+
getFindingById,
|
|
434
|
+
recordFinding,
|
|
435
|
+
formatExplainFinding,
|
|
436
|
+
resolveFindingsLedgerPath
|
|
437
|
+
};
|