thumbgate 1.37.3 → 1.39.0
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/.agents/skills/aws-strands-harness-not-clone/SKILL.md +53 -0
- package/.agents/skills/bolt-forge-opt-in-not-clone/SKILL.md +72 -0
- package/.agents/skills/decisive-step-evaluator/SKILL.md +47 -0
- package/.agents/skills/fiddler-control-plane-honesty/SKILL.md +61 -0
- package/.agents/skills/halo-trace-optimize-not-clone/SKILL.md +60 -0
- package/.agents/skills/harness-evolution-ceiling/SKILL.md +52 -0
- package/.agents/skills/infoq-architect-honesty-not-clone/SKILL.md +37 -0
- package/.agents/skills/meko-datapack-honesty-not-clone/SKILL.md +45 -0
- package/.agents/skills/mintlify-knowledge-honesty-not-clone/SKILL.md +49 -0
- package/.agents/skills/model-distress-governance/SKILL.md +56 -0
- package/.agents/skills/omp-coordination-honesty-not-clone/SKILL.md +94 -0
- package/.agents/skills/saas-moat-honesty-not-clone/SKILL.md +22 -0
- package/.agents/skills/salt-code-policy-honesty-not-clone/SKILL.md +76 -0
- package/.agents/skills/siren-mcp-governance/SKILL.md +50 -0
- package/.agents/skills/vs-coverage-gap-not-clone/SKILL.md +69 -0
- package/.agents/skills/wisdom-context-artifact-not-clone/SKILL.md +67 -0
- package/.claude-plugin/plugin.json +1 -1
- package/.well-known/mcp/server-card.json +1 -1
- package/adapters/claude/.mcp.json +2 -2
- 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/hotdata/hotdata-vector-store.js +575 -0
- package/adapters/mcp/server-stdio.js +1 -1
- package/adapters/opencode/opencode.json +1 -1
- package/adapters/strands/STRANDS.md +107 -0
- package/adapters/strands/strands-box-diode.js +344 -0
- package/adapters/strands/strands-decider-adapter.js +445 -0
- package/adapters/strands/strands-middleware.js +192 -0
- package/adapters/tailscale/.mcp.json +15 -0
- package/adapters/tailscale/TAILSCALE.md +117 -0
- package/adapters/tailscale/config.toml +16 -0
- package/bin/cli.js +602 -21
- package/config/gate-templates.json +109 -0
- package/config/gates/default.json +13 -0
- package/config/schemas/task-outcome-receipt.schema.json +12 -0
- package/package.json +150 -21
- package/public/blog/2026-09-28-pretool-secret-deny.html +83 -0
- package/public/blog/2026-10-01-aws-strands-harness-token-firewall.html +77 -0
- package/public/blog/2026-10-01-model-distress-relief-seeking-firewall.html +71 -0
- package/public/blog/2026-10-02-salt-code-honest-steal-40-guardrails.html +106 -0
- package/public/blog/2026-10-05-why-3-days-of-triage-wont-save-ai-speed-code.html +119 -0
- package/public/blog/2026-10-09-your-code-got-a-third-author-governance.html +141 -0
- package/public/connectors.html +329 -0
- package/public/enterprise-governance.html +311 -0
- package/public/gaming-playbook.html +732 -0
- package/public/index.html +77 -51
- package/public/install.html +7 -7
- package/public/learn.html +14 -0
- package/public/numbers.html +2 -2
- package/public/onboarding.html +794 -0
- package/public/operator-framework.html +385 -0
- package/public/pricing.html +14 -10
- package/scripts/activesaddler-curriculum-doctor.js +357 -0
- package/scripts/agent-context-artifact.js +325 -0
- package/scripts/agent-egress-policy.js +2 -2
- package/scripts/agent-operations-planner.js +1 -1
- package/scripts/agent-outcome-eval.js +1 -1
- package/scripts/agent-reliability-client.js +148 -0
- package/scripts/apple-minions-idle-compute-steal.js +428 -0
- package/scripts/autoresearch-runner.js +20 -1
- package/scripts/billing.js +0 -1
- package/scripts/cli-demo.js +505 -1
- package/scripts/cli-schema.js +36 -0
- package/scripts/colab-compute-honesty.js +93 -0
- package/scripts/corporate-email-isolation-diode.js +299 -0
- package/scripts/coverage-gap.js +396 -0
- package/scripts/dashboard-chat.js +3 -3
- package/scripts/dashboard.js +2 -2
- package/scripts/decisive-step-doctor.js +256 -0
- package/scripts/decisive-step-evaluator.js +390 -0
- package/scripts/entitlement.js +18 -7
- package/scripts/experiment-tracker.js +5 -3
- package/scripts/feedback-loop.js +26 -3
- package/scripts/fiddler-control-plane-honesty.js +303 -0
- package/scripts/financial-control-plane.js +10 -2
- package/scripts/gates-engine.js +3 -1
- package/scripts/github-license-compliance-diode.js +378 -0
- package/scripts/halo-trace-optimizer.js +631 -0
- package/scripts/harness-ceiling-doctor.js +326 -0
- package/scripts/hf-papers.js +1 -1
- package/scripts/human-escalation.js +7 -1
- package/scripts/hybrid-feedback-context.js +53 -7
- package/scripts/infoq-architect-honesty.js +362 -0
- package/scripts/lesson-graph.js +785 -0
- package/scripts/lesson-inference.js +1 -1
- package/scripts/lesson-retrieval.js +26 -18
- package/scripts/license.js +122 -21
- package/scripts/llm-behavior-monitor.js +1 -1
- package/scripts/llm-obs-honesty.js +52 -0
- package/scripts/local-model-profile.js +11 -7
- package/scripts/mailer/resend-mailer.js +6 -3
- package/scripts/mcp-transport-strategy.js +1 -1
- package/scripts/meko-datapack-honesty.js +414 -0
- package/scripts/migrate-lesson-graph.js +442 -0
- package/scripts/mintlify-knowledge-honesty.js +647 -0
- package/scripts/model-distress-detector.js +207 -0
- package/scripts/model-distress-doctor.js +368 -0
- package/scripts/multi-harness-invariants.js +305 -0
- package/scripts/omp-coordination-honesty.js +488 -0
- package/scripts/pro-local-dashboard.js +20 -3
- package/scripts/prompt-eval.js +1 -1
- package/scripts/prove-herdr-adapter.js +367 -3
- package/scripts/rag-embedding-identity.js +1 -1
- package/scripts/rrsi-regularizer.js +531 -0
- package/scripts/saas-moat-honesty.js +443 -0
- package/scripts/salt-code-policy-honesty.js +1204 -0
- package/scripts/secret-redaction.js +58 -0
- package/scripts/session-export-gate.js +368 -0
- package/scripts/siren-mcp-governance.js +539 -0
- package/scripts/strands-box-doctor.js +130 -0
- package/scripts/strands-harness-doctor.js +390 -0
- package/scripts/stripe-revenue-catalog-audit.js +12 -0
- package/scripts/stripe-revenue-catalog.js +40 -0
- package/scripts/switchyard-router.js +153 -0
- package/scripts/tailscale-p2p-doctor.js +252 -0
- package/scripts/task-outcomes.js +148 -3
- package/scripts/thumbgate-board-loop.js +4 -2
- package/scripts/thumbgate-daily-discoveries-publish.js +86 -38
- package/scripts/triage-savings-calculator.js +181 -0
- package/scripts/vector-store.js +41 -2
- package/scripts/vulnerability-pre-action-diode.js +319 -0
- package/scripts/windbg-evidence-diagnostics.js +241 -0
- package/scripts/workflow-intake-queue.js +1 -1
- package/scripts/workspace-agent-routines.js +534 -6
- package/scripts/workspace-evolver.js +143 -13
- package/server.json +2 -2
- package/skills/aws-strands-harness-not-clone/SKILL.md +53 -0
- package/skills/siren-mcp-governance/SKILL.md +50 -0
- package/src/api/server.js +191 -5
- package/src/mcp-writeguard.js +1 -1
- package/src/session-interactivity.js +284 -0
|
@@ -0,0 +1,378 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* scripts/github-license-compliance-diode.js
|
|
6
|
+
*
|
|
7
|
+
* Architectural Steal: GitHub Open Source License Compliance (GA Oct 16, 2026)
|
|
8
|
+
* Source: https://github.blog/changelog/2026-10-16-open-source-license-compliance-generally-available/
|
|
9
|
+
*
|
|
10
|
+
* Implements GitHub Enterprise Cloud's Open Source License Compliance engine
|
|
11
|
+
* as a zero-cost, <0.5ms local PreToolUse supply-chain diode (`gate:supply_chain:oss_license_compliance`):
|
|
12
|
+
*
|
|
13
|
+
* 1. Compound SPDX Expression Evaluator (`AND`, `OR`, `WITH`, parentheses):
|
|
14
|
+
* - Evaluates single & compound SPDX expressions against a baseline permitted-license policy.
|
|
15
|
+
* - `(MIT OR GPL-3.0-only)` -> ALLOWED (disjunction satisfied by MIT).
|
|
16
|
+
* - `(MIT AND AGPL-3.0-only)` -> BLOCKED (conjunction fails on AGPL-3.0-only).
|
|
17
|
+
* 2. Scoped Exceptions (`Enterprise Open-Source License Manager` approval model):
|
|
18
|
+
* - Supports `package`, `license`, and `package_pattern` exceptions at `enterprise` or `repository` scope.
|
|
19
|
+
* 3. Rollout Enforcement Modes (`open_source_license_compliance` custom property):
|
|
20
|
+
* - `inactive`: bypasses license evaluation.
|
|
21
|
+
* - `evaluate`: annotates noncompliant packages (`annotation` emitted) without blocking (`allowed: true` unless `requireConversationResolution: true`).
|
|
22
|
+
* - `active`: enforces `Require license compliance results before merging` (`allowed: false`, `decision: 'block'`).
|
|
23
|
+
* 4. Coding Agent Package-Check API & PreToolUse Interceptor:
|
|
24
|
+
* - Evaluates candidate packages before `npm install`, `pnpm add`, `yarn add`, `pip install`, or `cargo add` executes.
|
|
25
|
+
* 5. Live Repository Dependency Graph & SBOM License Audit (`auditRepositoryDependencyLicenses`):
|
|
26
|
+
* - Audits `package.json` + installed `node_modules` licenses and emits `license_compliance_policy` audit events.
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
const fs = require('node:fs');
|
|
30
|
+
const path = require('node:path');
|
|
31
|
+
const crypto = require('node:crypto');
|
|
32
|
+
|
|
33
|
+
const DEFAULT_PERMITTED_SPDX_LICENSES = [
|
|
34
|
+
'MIT',
|
|
35
|
+
'Apache-2.0',
|
|
36
|
+
'ISC',
|
|
37
|
+
'BSD-2-Clause',
|
|
38
|
+
'BSD-3-Clause',
|
|
39
|
+
'0BSD',
|
|
40
|
+
'BlueOak-1.0.0',
|
|
41
|
+
'CC0-1.0',
|
|
42
|
+
'CC-BY-3.0',
|
|
43
|
+
'CC-BY-4.0',
|
|
44
|
+
'Unlicense',
|
|
45
|
+
'Python-2.0',
|
|
46
|
+
'Zlib',
|
|
47
|
+
'Artistic-2.0',
|
|
48
|
+
];
|
|
49
|
+
|
|
50
|
+
const HIGH_RISK_COPYLEFT_OR_PROPRIETARY_LICENSES = [
|
|
51
|
+
'AGPL-3.0',
|
|
52
|
+
'AGPL-3.0-only',
|
|
53
|
+
'AGPL-3.0-or-later',
|
|
54
|
+
'GPL-2.0',
|
|
55
|
+
'GPL-2.0-only',
|
|
56
|
+
'GPL-3.0',
|
|
57
|
+
'GPL-3.0-only',
|
|
58
|
+
'GPL-3.0-or-later',
|
|
59
|
+
'SSPL-1.0',
|
|
60
|
+
'BUSL-1.1',
|
|
61
|
+
'Commons-Clause',
|
|
62
|
+
'UNLICENSED',
|
|
63
|
+
'NOASSERTION',
|
|
64
|
+
'NONE',
|
|
65
|
+
];
|
|
66
|
+
|
|
67
|
+
const LICENSE_COMPLIANCE_STEAL_MAP = [
|
|
68
|
+
{
|
|
69
|
+
githubFeature: 'Enterprise SPDX License Policy & compound expression evaluation (AND / OR / WITH)',
|
|
70
|
+
thumbgateRail: 'evaluateSpdxExpression() + DEFAULT_PERMITTED_SPDX_LICENSES',
|
|
71
|
+
decision: 'ADOPT',
|
|
72
|
+
value: 'Evaluates SPDX expressions locally in <0.1ms without requiring GHEC + GitHub Code Security seats',
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
githubFeature: 'Ruleset condition "Require license compliance results before merging" + custom property (inactive | evaluate | active)',
|
|
76
|
+
thumbgateRail: 'evaluatePackageLicenseCompliance() rolloutMode + requireConversationResolution',
|
|
77
|
+
decision: 'ADAPT',
|
|
78
|
+
value: 'Shifts enforcement left from PR merge time to PreToolUse before coding agents run npm/pip/cargo install',
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
githubFeature: 'Enterprise Open-Source License Manager scoped exceptions (package, license, package_pattern)',
|
|
82
|
+
thumbgateRail: 'matchesLicenseException() with enterprise vs repository scope + manager approval receipt',
|
|
83
|
+
decision: 'ADOPT',
|
|
84
|
+
value: 'Allows surgical package/pattern exceptions without weakening the global SPDX baseline',
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
githubFeature: 'Coding Agent Package-Check API & license_compliance_policy audit log events',
|
|
88
|
+
thumbgateRail: 'auditRepositoryDependencyLicenses() + buildLicensePolicyAuditEvent()',
|
|
89
|
+
decision: 'ADOPT',
|
|
90
|
+
value: 'Gives coding agents a local preflight check and emits structured policy audit events',
|
|
91
|
+
},
|
|
92
|
+
];
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Evaluate a single or compound SPDX license expression (`MIT`, `(MIT OR GPL-3.0-only)`, `Apache-2.0 WITH LLVM-exception`).
|
|
96
|
+
*/
|
|
97
|
+
function evaluateSpdxExpression(expression, permittedLicenses = DEFAULT_PERMITTED_SPDX_LICENSES) {
|
|
98
|
+
const permittedSet = new Set(permittedLicenses.map(l => String(l).trim().toUpperCase()));
|
|
99
|
+
const raw = String(expression || '').trim();
|
|
100
|
+
if (!raw) return false;
|
|
101
|
+
|
|
102
|
+
const upper = raw.toUpperCase();
|
|
103
|
+
if (upper === 'UNLICENSED' || upper === 'NONE' || upper === 'NOASSERTION') {
|
|
104
|
+
return false;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
function evalNode(expr) {
|
|
108
|
+
let s = expr.trim();
|
|
109
|
+
while (s.startsWith('(') && s.endsWith(')')) {
|
|
110
|
+
let depth = 0;
|
|
111
|
+
let wrapsAll = true;
|
|
112
|
+
for (let i = 0; i < s.length; i++) {
|
|
113
|
+
if (s[i] === '(') depth++;
|
|
114
|
+
else if (s[i] === ')') depth--;
|
|
115
|
+
if (depth === 0 && i < s.length - 1) {
|
|
116
|
+
wrapsAll = false;
|
|
117
|
+
break;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
if (wrapsAll) s = s.slice(1, -1).trim();
|
|
121
|
+
else break;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// Split top-level OR first (lowest precedence)
|
|
125
|
+
const orParts = splitTopLevel(s, 'OR');
|
|
126
|
+
if (orParts.length > 1) {
|
|
127
|
+
return orParts.some(part => evalNode(part));
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// Split top-level AND next
|
|
131
|
+
const andParts = splitTopLevel(s, 'AND');
|
|
132
|
+
if (andParts.length > 1) {
|
|
133
|
+
return andParts.every(part => evalNode(part));
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// Handle `WITH <exception>` by checking the base license identifier
|
|
137
|
+
const baseId = s.split(/\s+WITH\s+/i)[0].trim().toUpperCase();
|
|
138
|
+
return permittedSet.has(baseId);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
return evalNode(raw);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
function splitTopLevel(str, operator) {
|
|
145
|
+
const parts = [];
|
|
146
|
+
let depth = 0;
|
|
147
|
+
let lastIdx = 0;
|
|
148
|
+
const opRegex = new RegExp(`\\s+${operator}\\s+`, 'gi');
|
|
149
|
+
for (let i = 0; i < str.length; i++) {
|
|
150
|
+
if (str[i] === '(') depth++;
|
|
151
|
+
else if (str[i] === ')') depth--;
|
|
152
|
+
else if (depth === 0) {
|
|
153
|
+
opRegex.lastIndex = i;
|
|
154
|
+
const m = opRegex.exec(str);
|
|
155
|
+
if (m && m.index === i) {
|
|
156
|
+
parts.push(str.slice(lastIdx, i));
|
|
157
|
+
i += m[0].length - 1;
|
|
158
|
+
lastIdx = i + 1;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
parts.push(str.slice(lastIdx));
|
|
163
|
+
return parts;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* Check if a package or license matches an approved `Enterprise Open-Source License Manager` exception.
|
|
168
|
+
*/
|
|
169
|
+
function matchesLicenseException(pkg, exceptions = [], targetRepo = 'IgorGanapolsky/ThumbGate') {
|
|
170
|
+
const name = String(pkg.name || '').trim();
|
|
171
|
+
const license = String(pkg.license || '').trim();
|
|
172
|
+
for (const ex of exceptions) {
|
|
173
|
+
if (!ex || ex.approvedByRole !== 'Enterprise Open-Source License Manager') continue;
|
|
174
|
+
if (ex.scope === 'repository' && ex.repository && ex.repository !== targetRepo) continue;
|
|
175
|
+
|
|
176
|
+
if (ex.type === 'package' && ex.package === name) {
|
|
177
|
+
if (!ex.version || ex.version === pkg.version) return ex;
|
|
178
|
+
}
|
|
179
|
+
if (ex.type === 'license' && ex.license && ex.license.toUpperCase() === license.toUpperCase()) {
|
|
180
|
+
return ex;
|
|
181
|
+
}
|
|
182
|
+
if (ex.type === 'package_pattern' && ex.pattern) {
|
|
183
|
+
const prefix = String(ex.pattern).replace(/\*+$/, '');
|
|
184
|
+
if (name.startsWith(prefix)) return ex;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
return null;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* Evaluate a list of candidate packages against the Open Source License Compliance policy
|
|
192
|
+
* (coding agent package-check endpoint + PreToolUse gate).
|
|
193
|
+
*/
|
|
194
|
+
function evaluatePackageLicenseCompliance({
|
|
195
|
+
packages = [],
|
|
196
|
+
permittedLicenses = DEFAULT_PERMITTED_SPDX_LICENSES,
|
|
197
|
+
exceptions = [],
|
|
198
|
+
rolloutMode = 'active', // 'inactive' | 'evaluate' | 'active' (maps to open_source_license_compliance custom property)
|
|
199
|
+
requireConversationResolution = false,
|
|
200
|
+
targetRepo = 'IgorGanapolsky/ThumbGate',
|
|
201
|
+
} = {}) {
|
|
202
|
+
const startNs = process.hrtime.bigint();
|
|
203
|
+
|
|
204
|
+
if (rolloutMode === 'inactive') {
|
|
205
|
+
return {
|
|
206
|
+
decision: 'allow',
|
|
207
|
+
allowed: true,
|
|
208
|
+
rolloutMode,
|
|
209
|
+
gateId: 'gate:supply_chain:oss_license_inactive',
|
|
210
|
+
violations: [],
|
|
211
|
+
annotations: [],
|
|
212
|
+
latencyMs: Number((Number(process.hrtime.bigint() - startNs) / 1e6).toFixed(3)),
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
const violations = [];
|
|
217
|
+
const annotations = [];
|
|
218
|
+
const appliedExceptions = [];
|
|
219
|
+
|
|
220
|
+
for (const pkg of packages) {
|
|
221
|
+
const name = String(pkg.name || 'unknown-package');
|
|
222
|
+
const version = String(pkg.version || 'latest');
|
|
223
|
+
const license = String(pkg.license || 'NOASSERTION');
|
|
224
|
+
|
|
225
|
+
if (evaluateSpdxExpression(license, permittedLicenses)) {
|
|
226
|
+
continue;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
const matchedEx = matchesLicenseException({ name, version, license }, exceptions, targetRepo);
|
|
230
|
+
if (matchedEx) {
|
|
231
|
+
appliedExceptions.push({
|
|
232
|
+
package: name,
|
|
233
|
+
version,
|
|
234
|
+
license,
|
|
235
|
+
exceptionScope: matchedEx.scope || 'enterprise',
|
|
236
|
+
approvedByRole: matchedEx.approvedByRole,
|
|
237
|
+
});
|
|
238
|
+
continue;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
const violation = {
|
|
242
|
+
package: name,
|
|
243
|
+
version,
|
|
244
|
+
license,
|
|
245
|
+
dependencyType: pkg.transitive ? 'transitive' : 'direct',
|
|
246
|
+
remediation:
|
|
247
|
+
'Remove or replace the dependency, amend the enterprise SPDX license policy, or request a package exception from an Enterprise Open-Source License Manager.',
|
|
248
|
+
};
|
|
249
|
+
violations.push(violation);
|
|
250
|
+
annotations.push(
|
|
251
|
+
`[oss-license-compliance] Noncompliant dependency ${name}@${version} uses license '${license}' (${violation.dependencyType}).`
|
|
252
|
+
);
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
const hasViolations = violations.length > 0;
|
|
256
|
+
// In 'active' mode, violations always block.
|
|
257
|
+
// In 'evaluate' mode, violations annotate only — UNLESS branch protection requires comment resolution (which tracks license annotations).
|
|
258
|
+
const blocked =
|
|
259
|
+
hasViolations && (rolloutMode === 'active' || (rolloutMode === 'evaluate' && requireConversationResolution));
|
|
260
|
+
|
|
261
|
+
const latencyMs = Number((Number(process.hrtime.bigint() - startNs) / 1e6).toFixed(3));
|
|
262
|
+
return {
|
|
263
|
+
decision: blocked ? 'block' : hasViolations ? 'annotate' : 'allow',
|
|
264
|
+
allowed: !blocked,
|
|
265
|
+
rolloutMode,
|
|
266
|
+
requireConversationResolution,
|
|
267
|
+
gateId: blocked
|
|
268
|
+
? 'gate:supply_chain:oss_license_noncompliant'
|
|
269
|
+
: hasViolations
|
|
270
|
+
? 'gate:supply_chain:oss_license_evaluate_annotation'
|
|
271
|
+
: 'gate:supply_chain:oss_license_compliant',
|
|
272
|
+
violations,
|
|
273
|
+
annotations,
|
|
274
|
+
appliedExceptions,
|
|
275
|
+
latencyMs,
|
|
276
|
+
};
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
/**
|
|
280
|
+
* Emit a GitHub-compatible `license_compliance_policy` audit log event (`create` or `modify`).
|
|
281
|
+
*/
|
|
282
|
+
function buildLicensePolicyAuditEvent({
|
|
283
|
+
action = 'modify', // 'create' | 'modify'
|
|
284
|
+
actor = 'IgorGanapolsky',
|
|
285
|
+
role = 'Enterprise Open-Source License Manager',
|
|
286
|
+
permittedLicenses = DEFAULT_PERMITTED_SPDX_LICENSES,
|
|
287
|
+
exceptions = [],
|
|
288
|
+
} = {}) {
|
|
289
|
+
const normalizedAction = action === 'create' ? 'create' : 'modify';
|
|
290
|
+
const policyDigest = crypto
|
|
291
|
+
.createHash('sha256')
|
|
292
|
+
.update(JSON.stringify({ permittedLicenses, exceptions }))
|
|
293
|
+
.digest('hex');
|
|
294
|
+
return {
|
|
295
|
+
category: 'Policy Management',
|
|
296
|
+
eventType: `license_compliance_policy.${normalizedAction}`,
|
|
297
|
+
actor,
|
|
298
|
+
role,
|
|
299
|
+
policyDigest: `sha256:${policyDigest}`,
|
|
300
|
+
permittedCount: permittedLicenses.length,
|
|
301
|
+
exceptionCount: exceptions.length,
|
|
302
|
+
timestamp: new Date().toISOString(),
|
|
303
|
+
};
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
/**
|
|
307
|
+
* Audit the repository's direct production dependencies in `package.json` + `node_modules`
|
|
308
|
+
* against the SPDX license policy.
|
|
309
|
+
*/
|
|
310
|
+
function auditRepositoryDependencyLicenses(repoRoot = path.resolve(__dirname, '..')) {
|
|
311
|
+
const pkgPath = path.join(repoRoot, 'package.json');
|
|
312
|
+
const rootPkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));
|
|
313
|
+
const prodDeps = Object.keys(rootPkg.dependencies || {});
|
|
314
|
+
const packages = [];
|
|
315
|
+
|
|
316
|
+
// Include root package
|
|
317
|
+
packages.push({
|
|
318
|
+
name: rootPkg.name || 'thumbgate',
|
|
319
|
+
version: rootPkg.version || '0.0.0',
|
|
320
|
+
license: rootPkg.license || 'NOASSERTION',
|
|
321
|
+
transitive: false,
|
|
322
|
+
});
|
|
323
|
+
|
|
324
|
+
for (const dep of prodDeps) {
|
|
325
|
+
const depPkgPath = path.join(repoRoot, 'node_modules', dep, 'package.json');
|
|
326
|
+
if (fs.existsSync(depPkgPath)) {
|
|
327
|
+
const depPkg = JSON.parse(fs.readFileSync(depPkgPath, 'utf8'));
|
|
328
|
+
const lic =
|
|
329
|
+
typeof depPkg.license === 'string'
|
|
330
|
+
? depPkg.license
|
|
331
|
+
: depPkg.license && depPkg.license.type
|
|
332
|
+
? depPkg.license.type
|
|
333
|
+
: 'NOASSERTION';
|
|
334
|
+
packages.push({
|
|
335
|
+
name: dep,
|
|
336
|
+
version: depPkg.version || 'latest',
|
|
337
|
+
license: lic,
|
|
338
|
+
transitive: false,
|
|
339
|
+
});
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
return evaluatePackageLicenseCompliance({
|
|
344
|
+
packages,
|
|
345
|
+
rolloutMode: 'active',
|
|
346
|
+
});
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
if (require.main === module) {
|
|
350
|
+
const args = process.argv.slice(2);
|
|
351
|
+
const mapOnly = args.includes('--map-only');
|
|
352
|
+
const repoAudit = mapOnly ? null : auditRepositoryDependencyLicenses();
|
|
353
|
+
const auditEvent = buildLicensePolicyAuditEvent({ action: 'create' });
|
|
354
|
+
|
|
355
|
+
process.stdout.write(
|
|
356
|
+
`${JSON.stringify(
|
|
357
|
+
{
|
|
358
|
+
status: 'ok',
|
|
359
|
+
source: 'https://github.blog/changelog/2026-10-16-open-source-license-compliance-generally-available/',
|
|
360
|
+
stealMap: LICENSE_COMPLIANCE_STEAL_MAP,
|
|
361
|
+
...(mapOnly ? {} : { repoDependencyLicenseAudit: repoAudit, samplePolicyAuditEvent: auditEvent }),
|
|
362
|
+
},
|
|
363
|
+
null,
|
|
364
|
+
2
|
|
365
|
+
)}\n`
|
|
366
|
+
);
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
module.exports = {
|
|
370
|
+
DEFAULT_PERMITTED_SPDX_LICENSES,
|
|
371
|
+
HIGH_RISK_COPYLEFT_OR_PROPRIETARY_LICENSES,
|
|
372
|
+
LICENSE_COMPLIANCE_STEAL_MAP,
|
|
373
|
+
evaluateSpdxExpression,
|
|
374
|
+
matchesLicenseException,
|
|
375
|
+
evaluatePackageLicenseCompliance,
|
|
376
|
+
buildLicensePolicyAuditEvent,
|
|
377
|
+
auditRepositoryDependencyLicenses,
|
|
378
|
+
};
|