@craswitch/mcp-server 0.0.0-stage → 2.0.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/README.md +99 -2
- package/dist/cli.js +8 -0
- package/dist/core/badge.js +156 -0
- package/dist/core/crypto-utils.js +199 -0
- package/dist/core/enisa.js +909 -0
- package/dist/core/evidence.js +350 -0
- package/dist/core/feeds.js +1175 -0
- package/dist/core/guardrails.js +537 -0
- package/dist/core/index.js +16 -0
- package/dist/core/lockfiles.js +1107 -0
- package/dist/core/sbom.js +191 -0
- package/dist/core/types.js +918 -0
- package/dist/core/vex.js +722 -0
- package/dist/core/x402.js +467 -0
- package/dist/crypto.js +214 -0
- package/dist/http-client.js +336 -0
- package/dist/index.js +17 -0
- package/dist/kev-baseline.js +186 -0
- package/dist/server.js +1075 -0
- package/package.json +39 -4
- package/server.json +63 -0
|
@@ -0,0 +1,537 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Section 0 Hard Non-Negotiable Outreach & Automation Guardrails + Loop A Ecosystem Filter.
|
|
3
|
+
* Zero external runtime dependencies; compatible with Cloudflare Workers & Node 22.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
import { parsePurl } from './lockfiles.js';
|
|
14
|
+
|
|
15
|
+
export const SOFTWARE_PACKAGE_ECOSYSTEMS = [
|
|
16
|
+
'npm',
|
|
17
|
+
'pypi',
|
|
18
|
+
'cargo',
|
|
19
|
+
'golang',
|
|
20
|
+
'maven',
|
|
21
|
+
'gem',
|
|
22
|
+
'nuget',
|
|
23
|
+
] ;
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
/** Hard role-account email blocklist regex (Section 0 v3 guardrail). */
|
|
28
|
+
export const GTM_ROLE_BLOCKLIST_REGEX =
|
|
29
|
+
/^(security|psirt|vuln|cert|abuse|dpo|privacy|infosec|hostmaster|postmaster)@/i;
|
|
30
|
+
|
|
31
|
+
/** Statutory classification badges for Loop A supply-chain advisories. */
|
|
32
|
+
export const GTM_CLASSIFICATION_BADGES = {
|
|
33
|
+
ACTIVE_EXPLOITATION: '[ACTIVE EXPLOITATION — POTENTIAL EU CRA ART. 14 TRIGGER]',
|
|
34
|
+
WATCHLIST_ONLY: '[WATCHLIST ONLY — NOT YET MANDATORY UNDER CRA ART. 14]',
|
|
35
|
+
} ;
|
|
36
|
+
|
|
37
|
+
/** All 27 EU Member States + EU union code (GDPR / UWG cold-outreach protection). */
|
|
38
|
+
export const EU_MEMBER_STATE_CODES = new Set ([
|
|
39
|
+
'AT', 'BE', 'BG', 'HR', 'CY', 'CZ', 'DK', 'EE', 'FI',
|
|
40
|
+
'FR', 'DE', 'GR', 'HU', 'IE', 'IT', 'LV', 'LT', 'LU',
|
|
41
|
+
'MT', 'NL', 'PL', 'PT', 'RO', 'SK', 'SI', 'ES', 'SE',
|
|
42
|
+
'EU',
|
|
43
|
+
]);
|
|
44
|
+
|
|
45
|
+
/** EEA + CH + CASL (CA) + Australian Spam Act (AU) explicitly blocked country codes. */
|
|
46
|
+
const BLOCKED_EXTRA_COUNTRY_CODES = new Set (['IS', 'LI', 'NO', 'CH', 'CA', 'AU']);
|
|
47
|
+
|
|
48
|
+
const EU_TLD_SET = new Set ([
|
|
49
|
+
...Array.from(EU_MEMBER_STATE_CODES).map((c) => `.${c.toLowerCase()}`),
|
|
50
|
+
'.is',
|
|
51
|
+
'.li',
|
|
52
|
+
'.no',
|
|
53
|
+
'.ch',
|
|
54
|
+
'.ca',
|
|
55
|
+
'.au',
|
|
56
|
+
]);
|
|
57
|
+
|
|
58
|
+
const SECURITY_MAILBOX_KEYWORDS = [
|
|
59
|
+
'security',
|
|
60
|
+
'psirt',
|
|
61
|
+
'cert',
|
|
62
|
+
'csirt',
|
|
63
|
+
'abuse',
|
|
64
|
+
'vuln',
|
|
65
|
+
'vulnerability',
|
|
66
|
+
'infosec',
|
|
67
|
+
'secops',
|
|
68
|
+
'bugbounty',
|
|
69
|
+
'disclosure',
|
|
70
|
+
'cve',
|
|
71
|
+
'sirt',
|
|
72
|
+
'dpo',
|
|
73
|
+
'privacy',
|
|
74
|
+
'hostmaster',
|
|
75
|
+
'postmaster',
|
|
76
|
+
] ;
|
|
77
|
+
|
|
78
|
+
const FREE_PERSONAL_WEBMAIL_DOMAINS = new Set ([
|
|
79
|
+
'gmail.com',
|
|
80
|
+
'googlemail.com',
|
|
81
|
+
'outlook.com',
|
|
82
|
+
'outlook.co.uk',
|
|
83
|
+
'hotmail.com',
|
|
84
|
+
'hotmail.co.uk',
|
|
85
|
+
'live.com',
|
|
86
|
+
'live.co.uk',
|
|
87
|
+
'yahoo.com',
|
|
88
|
+
'yahoo.co.uk',
|
|
89
|
+
'btinternet.com',
|
|
90
|
+
'btopenworld.com',
|
|
91
|
+
'sky.com',
|
|
92
|
+
'virginmedia.com',
|
|
93
|
+
'talktalk.net',
|
|
94
|
+
'blueyonder.co.uk',
|
|
95
|
+
'ntlworld.com',
|
|
96
|
+
'icloud.com',
|
|
97
|
+
'me.com',
|
|
98
|
+
'mac.com',
|
|
99
|
+
'proton.me',
|
|
100
|
+
'protonmail.com',
|
|
101
|
+
'pm.me',
|
|
102
|
+
'tutanota.com',
|
|
103
|
+
'tuta.io',
|
|
104
|
+
'gmx.de',
|
|
105
|
+
'gmx.net',
|
|
106
|
+
'gmx.at',
|
|
107
|
+
'web.de',
|
|
108
|
+
't-online.de',
|
|
109
|
+
'orange.fr',
|
|
110
|
+
'free.fr',
|
|
111
|
+
'laposte.net',
|
|
112
|
+
'libero.it',
|
|
113
|
+
'wp.pl',
|
|
114
|
+
'onet.pl',
|
|
115
|
+
'seznam.cz',
|
|
116
|
+
'ziggo.nl',
|
|
117
|
+
'kpnmail.nl',
|
|
118
|
+
]);
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
function isSecurityMailboxEmail(email , localPart ) {
|
|
131
|
+
if (GTM_ROLE_BLOCKLIST_REGEX.test(email)) return true;
|
|
132
|
+
const lower = localPart.toLowerCase();
|
|
133
|
+
const base = lower.split('+')[0] ?? lower;
|
|
134
|
+
const tokens = base.split(/[-_.]+/).filter(Boolean);
|
|
135
|
+
for (const kw of SECURITY_MAILBOX_KEYWORDS) {
|
|
136
|
+
if (base === kw || tokens.includes(kw)) {
|
|
137
|
+
return true;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
return false;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
function isValidHttpsUrl(raw ) {
|
|
144
|
+
if (!raw || raw.trim().length === 0) return false;
|
|
145
|
+
try {
|
|
146
|
+
const parsed = new URL(raw.trim());
|
|
147
|
+
return parsed.protocol === 'https:' && parsed.hostname.includes('.');
|
|
148
|
+
} catch {
|
|
149
|
+
return false;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
function isUkCorporateEntity(legalEntityType ) {
|
|
154
|
+
if (!legalEntityType) return false;
|
|
155
|
+
const norm = legalEntityType.trim().toLowerCase();
|
|
156
|
+
return norm === 'ltd' || norm === 'plc';
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
function isSecuritySourcePath(sourcePath ) {
|
|
160
|
+
const norm = sourcePath.replace(/\\/g, '/').trim().toLowerCase();
|
|
161
|
+
const base = norm.slice(norm.lastIndexOf('/') + 1);
|
|
162
|
+
return (
|
|
163
|
+
base === 'security.md' ||
|
|
164
|
+
base === 'security.txt' ||
|
|
165
|
+
base === 'security.rst' ||
|
|
166
|
+
base === 'security.adoc' ||
|
|
167
|
+
norm.endsWith('/.well-known/security.txt')
|
|
168
|
+
);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Enforces Section 0 hard non-negotiable guardrails (CRA-Switch v3 — US & UK Corporate ONLY):
|
|
173
|
+
* - Blocks auto-filing to ENISA
|
|
174
|
+
* - Blocks public shadow "Red Alert" portals for non-opted-in orgs
|
|
175
|
+
* - Blocks unsolicited GitHub Issues / PRs on third-party repos
|
|
176
|
+
* - Blocks SECURITY.md / security.txt sources and security@/psirt@/vuln@/cert@/abuse@/dpo@/privacy@/infosec@/hostmaster@/postmaster@ mailboxes
|
|
177
|
+
* - Strictly allows ONLY `countryCode === 'US'` (corporate email) OR `countryCode === 'GB'` with
|
|
178
|
+
* `legalEntityType` in `['Ltd', 'PLC']` (case-insensitive) AND valid `https://` `contactSourceUrl`
|
|
179
|
+
* - Hard-rejects ALL 27 EU/EEA countries, Canada (CA / CASL), Australia (AU / Spam Act),
|
|
180
|
+
* UK sole traders/partnerships, personal free webmail, and missing/other country codes.
|
|
181
|
+
*/
|
|
182
|
+
export function evaluateOutreachTarget(input ) {
|
|
183
|
+
const reasons = [];
|
|
184
|
+
let blockedRule ;
|
|
185
|
+
|
|
186
|
+
const recordBlock = (
|
|
187
|
+
rule ,
|
|
188
|
+
reason ,
|
|
189
|
+
) => {
|
|
190
|
+
if (!blockedRule) blockedRule = rule;
|
|
191
|
+
reasons.push(reason);
|
|
192
|
+
};
|
|
193
|
+
|
|
194
|
+
if (input.actionType === 'auto_enisa_filing') {
|
|
195
|
+
recordBlock(
|
|
196
|
+
'auto_enisa_filing',
|
|
197
|
+
'CRA-Switch NEVER auto-submits Article 14 reports to ENISA; manual vendor submission via EU Login + MFA is mandatory.',
|
|
198
|
+
);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
if (input.actionType === 'shadow_red_alert' && input.optedIn !== true) {
|
|
202
|
+
recordBlock(
|
|
203
|
+
'shadow_red_alert',
|
|
204
|
+
'Publishing public/indexable Red Alert or Active KEV shadow portals for non-opted-in organizations is prohibited.',
|
|
205
|
+
);
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
if (
|
|
209
|
+
(input.actionType === 'github_issue' || input.actionType === 'github_pr') &&
|
|
210
|
+
input.optedIn !== true
|
|
211
|
+
) {
|
|
212
|
+
recordBlock(
|
|
213
|
+
'unsolicited_issue_pr',
|
|
214
|
+
'Opening unsolicited GitHub Issues or Pull Requests on third-party repositories is prohibited.',
|
|
215
|
+
);
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
if (input.sourcePath && isSecuritySourcePath(input.sourcePath)) {
|
|
219
|
+
recordBlock(
|
|
220
|
+
'security_mailbox',
|
|
221
|
+
`Contacts sourced from vulnerability disclosure files (${input.sourcePath}) must NEVER be used for sales or outreach.`,
|
|
222
|
+
);
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
const isEmailOrProspectCheck =
|
|
226
|
+
input.actionType === undefined ||
|
|
227
|
+
input.actionType === 'email' ||
|
|
228
|
+
input.email !== undefined ||
|
|
229
|
+
input.countryCode !== undefined;
|
|
230
|
+
|
|
231
|
+
const countryUpper = input.countryCode?.trim().toUpperCase() ?? '';
|
|
232
|
+
const isEuCountry = countryUpper.length > 0 && EU_MEMBER_STATE_CODES.has(countryUpper);
|
|
233
|
+
|
|
234
|
+
if (input.email && input.email.trim().length > 0) {
|
|
235
|
+
const email = input.email.trim().toLowerCase();
|
|
236
|
+
const atIdx = email.lastIndexOf('@');
|
|
237
|
+
if (atIdx <= 0 || atIdx === email.length - 1) {
|
|
238
|
+
recordBlock('eu_personal_email', `Invalid email address: ${input.email}`);
|
|
239
|
+
} else {
|
|
240
|
+
const localPart = email.slice(0, atIdx);
|
|
241
|
+
const rawDomain = email.slice(atIdx + 1);
|
|
242
|
+
const hasTrailingDot = rawDomain.endsWith('.');
|
|
243
|
+
const domain = rawDomain.replace(/\.+$/, '');
|
|
244
|
+
|
|
245
|
+
if (isSecurityMailboxEmail(email, localPart)) {
|
|
246
|
+
recordBlock(
|
|
247
|
+
'security_mailbox',
|
|
248
|
+
`Security/role mailbox (${email}) is strictly blocked from outreach.`,
|
|
249
|
+
);
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
if (!domain) {
|
|
253
|
+
recordBlock('eu_personal_email', `Invalid email address domain: ${input.email}`);
|
|
254
|
+
} else {
|
|
255
|
+
const lastDot = domain.lastIndexOf('.');
|
|
256
|
+
const tld = lastDot !== -1 ? domain.slice(lastDot) : '';
|
|
257
|
+
const isBlockedTld = EU_TLD_SET.has(tld);
|
|
258
|
+
const isFreeWebmail = FREE_PERSONAL_WEBMAIL_DOMAINS.has(domain);
|
|
259
|
+
|
|
260
|
+
if (isBlockedTld && input.optedIn !== true) {
|
|
261
|
+
recordBlock(
|
|
262
|
+
'eu_personal_email',
|
|
263
|
+
`Cold outreach to restricted jurisdiction TLD (${tld}) is blocked under v3 guardrails.`,
|
|
264
|
+
);
|
|
265
|
+
} else if (isFreeWebmail && input.optedIn !== true) {
|
|
266
|
+
recordBlock(
|
|
267
|
+
'eu_personal_email',
|
|
268
|
+
`Personal free-webmail address (${domain}) is blocked from outbound prospecting.`,
|
|
269
|
+
);
|
|
270
|
+
} else if (hasTrailingDot && input.optedIn !== true) {
|
|
271
|
+
recordBlock(
|
|
272
|
+
'eu_personal_email',
|
|
273
|
+
`Trailing-dot FQDN email address (${input.email}) is rejected under v3 guardrails.`,
|
|
274
|
+
);
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
if (isEmailOrProspectCheck && input.optedIn !== true) {
|
|
281
|
+
if (!countryUpper) {
|
|
282
|
+
recordBlock(
|
|
283
|
+
'eu_personal_email',
|
|
284
|
+
'Missing countryCode: v3 outreach strictly requires US or UK (GB) corporate jurisdiction.',
|
|
285
|
+
);
|
|
286
|
+
} else if (isEuCountry) {
|
|
287
|
+
recordBlock(
|
|
288
|
+
'eu_personal_email',
|
|
289
|
+
`Cold outreach to EU member-state prospect (${countryUpper}) is blocked under GDPR / German UWG guardrails.`,
|
|
290
|
+
);
|
|
291
|
+
} else if (BLOCKED_EXTRA_COUNTRY_CODES.has(countryUpper)) {
|
|
292
|
+
recordBlock(
|
|
293
|
+
'eu_personal_email',
|
|
294
|
+
`Cold outreach to restricted jurisdiction (${countryUpper}: EEA/CASL/AU Spam Act) is blocked.`,
|
|
295
|
+
);
|
|
296
|
+
} else if (countryUpper === 'GB') {
|
|
297
|
+
if (!isUkCorporateEntity(input.legalEntityType)) {
|
|
298
|
+
recordBlock(
|
|
299
|
+
'eu_personal_email',
|
|
300
|
+
'UK (GB) outreach requires explicit corporate legalEntityType ("Ltd" or "PLC"); sole traders and partnerships are blocked under PECR.',
|
|
301
|
+
);
|
|
302
|
+
}
|
|
303
|
+
if (!isValidHttpsUrl(input.contactSourceUrl)) {
|
|
304
|
+
recordBlock(
|
|
305
|
+
'eu_personal_email',
|
|
306
|
+
'UK (GB) corporate outreach requires a valid public https:// contactSourceUrl.',
|
|
307
|
+
);
|
|
308
|
+
}
|
|
309
|
+
} else if (countryUpper !== 'US') {
|
|
310
|
+
recordBlock(
|
|
311
|
+
'eu_personal_email',
|
|
312
|
+
`Jurisdiction "${countryUpper}" is not allowlisted; only US and UK (GB) corporate prospects are permitted.`,
|
|
313
|
+
);
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
if (reasons.length > 0) {
|
|
318
|
+
return {
|
|
319
|
+
allowed: false,
|
|
320
|
+
reasons,
|
|
321
|
+
blockedRule,
|
|
322
|
+
};
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
return {
|
|
326
|
+
allowed: true,
|
|
327
|
+
reasons: [],
|
|
328
|
+
};
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
/**
|
|
332
|
+
* Checks whether an ecosystem identifier belongs to a supported software package ecosystem
|
|
333
|
+
* for Loop A supply-chain advisories (`npm`, `pypi`, `cargo`, `golang`, `maven`, `gem`, `nuget`).
|
|
334
|
+
*/
|
|
335
|
+
export function isSoftwarePackageEcosystem(ecosystem ) {
|
|
336
|
+
if (!ecosystem) return false;
|
|
337
|
+
const lower = ecosystem.trim().toLowerCase();
|
|
338
|
+
if (lower === 'npm') return true;
|
|
339
|
+
if (lower === 'pypi' || lower === 'python' || lower === 'pip') return true;
|
|
340
|
+
if (lower === 'cargo' || lower === 'crates.io' || lower === 'rust') return true;
|
|
341
|
+
if (lower === 'golang' || lower === 'go') return true;
|
|
342
|
+
if (lower === 'maven' || lower === 'java') return true;
|
|
343
|
+
if (lower === 'gem' || lower === 'rubygems' || lower === 'ruby') return true;
|
|
344
|
+
if (lower === 'nuget' || lower === 'dotnet' || lower === '.net') return true;
|
|
345
|
+
return false;
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
|
|
349
|
+
|
|
350
|
+
|
|
351
|
+
|
|
352
|
+
|
|
353
|
+
|
|
354
|
+
|
|
355
|
+
|
|
356
|
+
|
|
357
|
+
|
|
358
|
+
/**
|
|
359
|
+
* Classifies an advisory's EU CRA Article 14 applicability:
|
|
360
|
+
* - `active_exploitation_art14`: confirmed actively exploited (CISA KEV, ENISA EUVD, or activelyExploited)
|
|
361
|
+
* - `watchlist_only`: high EPSS (>= 0.70) or public PoC without confirmed active exploitation
|
|
362
|
+
*/
|
|
363
|
+
export function classifyAdvisoryApplicability(
|
|
364
|
+
item ,
|
|
365
|
+
) {
|
|
366
|
+
if (
|
|
367
|
+
item.inCisaKev === true ||
|
|
368
|
+
item.inEnisaEuvd === true ||
|
|
369
|
+
item.source === 'cisa_kev' ||
|
|
370
|
+
item.source === 'enisa_euvd' ||
|
|
371
|
+
item.activelyExploited === true
|
|
372
|
+
) {
|
|
373
|
+
return 'active_exploitation_art14';
|
|
374
|
+
}
|
|
375
|
+
return 'watchlist_only';
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
/**
|
|
379
|
+
* Determines whether an advisory qualifies for the Loop A public software-ecosystem feed:
|
|
380
|
+
* must target a software package ecosystem AND be either actively exploited (Art. 14 trigger)
|
|
381
|
+
* OR high-signal watchlist (`epssScore >= 0.70` or `hasPublicPoc === true`).
|
|
382
|
+
*/
|
|
383
|
+
export function shouldIncludeInAdvisoryFeed(item ) {
|
|
384
|
+
if (!isSoftwarePackageEcosystem(item.ecosystem)) return false;
|
|
385
|
+
if (classifyAdvisoryApplicability(item) === 'active_exploitation_art14') return true;
|
|
386
|
+
if (typeof item.epssScore === 'number' && item.epssScore >= 0.7) return true;
|
|
387
|
+
if (item.hasPublicPoc === true) return true;
|
|
388
|
+
return false;
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
|
|
392
|
+
|
|
393
|
+
|
|
394
|
+
|
|
395
|
+
|
|
396
|
+
|
|
397
|
+
|
|
398
|
+
|
|
399
|
+
function inferFeedItemEcosystem(item ) {
|
|
400
|
+
const candidates = [];
|
|
401
|
+
|
|
402
|
+
if (item.ecosystem && item.ecosystem.trim().length > 0) {
|
|
403
|
+
candidates.push(item.ecosystem.trim());
|
|
404
|
+
}
|
|
405
|
+
for (const range of item.affectedRanges ?? []) {
|
|
406
|
+
if (range?.ecosystem && range.ecosystem.trim().length > 0) {
|
|
407
|
+
candidates.push(range.ecosystem.trim());
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
for (const purl of item.purls ?? []) {
|
|
411
|
+
const parsed = parsePurl(purl);
|
|
412
|
+
if (parsed) {
|
|
413
|
+
candidates.push(parsed.ecosystem);
|
|
414
|
+
continue;
|
|
415
|
+
}
|
|
416
|
+
const match = /^pkg:([a-z0-9.+-]+)\//i.exec(purl.trim());
|
|
417
|
+
if (match?.[1]) {
|
|
418
|
+
candidates.push(match[1].toLowerCase());
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
for (const candidate of candidates) {
|
|
423
|
+
if (isSoftwarePackageEcosystem(candidate)) {
|
|
424
|
+
return candidate;
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
return candidates[0];
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
/**
|
|
431
|
+
* Classifies an ExploitFeedItem for CRA-Switch v3 Loop A GTM advisory drafting:
|
|
432
|
+
* - Strictly filters to the 7 software package ecosystems (npm, pypi, cargo, golang, maven, gem, nuget).
|
|
433
|
+
* Returns `null` for OS-kernel, hardware, browser, or appliance CVEs.
|
|
434
|
+
* - Returns `'ACTIVE_EXPLOITATION'` for CISA KEV / ENISA EUVD / actively exploited items.
|
|
435
|
+
* - Returns `'WATCHLIST_ONLY'` when `epssScore >= 0.70` or `hasPublicPoc === true`.
|
|
436
|
+
* - Returns `null` otherwise.
|
|
437
|
+
*/
|
|
438
|
+
export function classifyGtmAdvisory(
|
|
439
|
+
item ,
|
|
440
|
+
) {
|
|
441
|
+
const eco = inferFeedItemEcosystem(item);
|
|
442
|
+
if (!isSoftwarePackageEcosystem(eco)) {
|
|
443
|
+
return null;
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
if (
|
|
447
|
+
item.source === 'cisa_kev' ||
|
|
448
|
+
item.source === 'enisa_euvd' ||
|
|
449
|
+
item.activelyExploited === true ||
|
|
450
|
+
item.inCisaKev === true ||
|
|
451
|
+
item.inEnisaEuvd === true
|
|
452
|
+
) {
|
|
453
|
+
return 'ACTIVE_EXPLOITATION';
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
if (
|
|
457
|
+
(typeof item.epssScore === 'number' && item.epssScore >= 0.7) ||
|
|
458
|
+
item.hasPublicPoc === true
|
|
459
|
+
) {
|
|
460
|
+
return 'WATCHLIST_ONLY';
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
return null;
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
|
|
467
|
+
|
|
468
|
+
|
|
469
|
+
|
|
470
|
+
|
|
471
|
+
|
|
472
|
+
|
|
473
|
+
|
|
474
|
+
/**
|
|
475
|
+
* Renders a CAN-SPAM / PECR-compliant plain-text outreach email pointing strictly to a
|
|
476
|
+
* private, `noindex`, 7-day ephemeral clean/informational OpenVEX preview URL.
|
|
477
|
+
* Throws if `postalAddress` is empty or `previewUrl` is not a valid `https://.../preview/...` URL.
|
|
478
|
+
*/
|
|
479
|
+
export function renderCompliantOutreachEmail(input )
|
|
480
|
+
|
|
481
|
+
|
|
482
|
+
{
|
|
483
|
+
const companyName = input.companyName.trim();
|
|
484
|
+
const publicRepo = input.publicRepo.trim();
|
|
485
|
+
const postalAddress = input.postalAddress.trim();
|
|
486
|
+
const previewUrl = input.previewUrl.trim();
|
|
487
|
+
|
|
488
|
+
if (!companyName) {
|
|
489
|
+
throw new Error('renderCompliantOutreachEmail requires a non-empty companyName');
|
|
490
|
+
}
|
|
491
|
+
if (!publicRepo) {
|
|
492
|
+
throw new Error('renderCompliantOutreachEmail requires a non-empty publicRepo');
|
|
493
|
+
}
|
|
494
|
+
if (!postalAddress) {
|
|
495
|
+
throw new Error(
|
|
496
|
+
'renderCompliantOutreachEmail requires a non-empty CAN-SPAM physical postalAddress',
|
|
497
|
+
);
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
let parsedUrl ;
|
|
501
|
+
try {
|
|
502
|
+
parsedUrl = new URL(previewUrl);
|
|
503
|
+
} catch {
|
|
504
|
+
throw new Error(`Invalid previewUrl: "${input.previewUrl}"`);
|
|
505
|
+
}
|
|
506
|
+
if (
|
|
507
|
+
parsedUrl.protocol !== 'https:' ||
|
|
508
|
+
!parsedUrl.hostname.includes('.') ||
|
|
509
|
+
!/^\/preview\/[^/]+/.test(parsedUrl.pathname)
|
|
510
|
+
) {
|
|
511
|
+
throw new Error(
|
|
512
|
+
`previewUrl must be a valid https://.../preview/... URL, got "${input.previewUrl}"`,
|
|
513
|
+
);
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
const greetingName = input.contactName?.trim() || `${companyName} team`;
|
|
517
|
+
const subject = `Signed OpenVEX buyer-proof preview for ${publicRepo}`;
|
|
518
|
+
const body = [
|
|
519
|
+
`Hi ${greetingName},`,
|
|
520
|
+
'',
|
|
521
|
+
`EU enterprise buyers are starting to ask commercial software vendors for machine-readable EU Cyber Resilience Act (CRA) Article 14 readiness artifacts alongside public SDKs and CLIs.`,
|
|
522
|
+
'',
|
|
523
|
+
`I generated a private, non-indexed, read-only CycloneDX + Ed25519-signed OpenVEX buyer-proof preview for ${publicRepo} (purely informational — expires automatically in 7 days):`,
|
|
524
|
+
'',
|
|
525
|
+
`${previewUrl}`,
|
|
526
|
+
'',
|
|
527
|
+
`CRA-Switch is free for public GitHub repositories if you ever want a live /.well-known/vex.json endpoint and README posture badge for EU procurement reviews.`,
|
|
528
|
+
'',
|
|
529
|
+
`If this isn't relevant to your team, just reply "no" and I will permanently suppress your address.`,
|
|
530
|
+
'',
|
|
531
|
+
'—',
|
|
532
|
+
'CRA-Switch · https://craswitch.dev',
|
|
533
|
+
postalAddress,
|
|
534
|
+
].join('\n');
|
|
535
|
+
|
|
536
|
+
return { subject, body };
|
|
537
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @cra-switch/core — Zero-dependency pure TypeScript compliance engine.
|
|
3
|
+
* Re-exports all canonical contracts and core modules.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
export * from './types.js';
|
|
7
|
+
export * from './crypto-utils.js';
|
|
8
|
+
export * from './lockfiles.js';
|
|
9
|
+
export * from './sbom.js';
|
|
10
|
+
export * from './feeds.js';
|
|
11
|
+
export * from './vex.js';
|
|
12
|
+
export * from './enisa.js';
|
|
13
|
+
export * from './evidence.js';
|
|
14
|
+
export * from './guardrails.js';
|
|
15
|
+
export * from './x402.js';
|
|
16
|
+
export * from './badge.js';
|