@shieldaai/security-watch 0.1.0-alpha.0 → 1.0.1
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/CHANGELOG.md +178 -0
- package/CONTRIBUTING.md +4 -2
- package/README.md +173 -48
- package/SECURITY.md +24 -9
- package/dist/assessment.d.ts +12 -1
- package/dist/assessment.js +223 -52
- package/dist/cli.js +340 -27
- package/dist/config.d.ts +62 -2
- package/dist/config.js +88 -5
- package/dist/coverage.d.ts +4 -0
- package/dist/coverage.js +11 -0
- package/dist/cve-now.d.ts +32 -2
- package/dist/cve-now.js +715 -126
- package/dist/cvss4.d.ts +3 -0
- package/dist/cvss4.js +39 -0
- package/dist/delivery.d.ts +34 -2
- package/dist/delivery.js +391 -98
- package/dist/ecosystems.d.ts +23 -0
- package/dist/ecosystems.js +88 -10
- package/dist/engine.d.ts +55 -1
- package/dist/engine.js +101 -20
- package/dist/everyday-words.d.ts +11 -0
- package/dist/everyday-words.js +256 -0
- package/dist/health.d.ts +7 -0
- package/dist/health.js +55 -3
- package/dist/http.d.ts +7 -0
- package/dist/http.js +31 -2
- package/dist/index.d.ts +22 -4
- package/dist/index.js +12 -4
- package/dist/inventory-evidence.d.ts +10 -0
- package/dist/inventory-evidence.js +206 -0
- package/dist/inventory.d.ts +273 -0
- package/dist/inventory.js +210 -17
- package/dist/maintenance.d.ts +5 -0
- package/dist/maintenance.js +73 -5
- package/dist/matching.d.ts +29 -0
- package/dist/matching.js +537 -0
- package/dist/models.d.ts +17 -4
- package/dist/models.js +359 -29
- package/dist/pilot-cases.d.ts +171 -0
- package/dist/pilot-cases.js +330 -0
- package/dist/pilot-input.d.ts +16 -0
- package/dist/pilot-input.js +125 -0
- package/dist/pilot-recall.d.ts +166 -0
- package/dist/pilot-recall.js +231 -0
- package/dist/pilot-report.d.ts +113 -0
- package/dist/pilot-report.js +279 -0
- package/dist/pilot-responses.d.ts +111 -0
- package/dist/pilot-responses.js +159 -0
- package/dist/python-version.d.ts +3 -0
- package/dist/python-version.js +30 -0
- package/dist/rehearsal.d.ts +440 -0
- package/dist/rehearsal.js +372 -0
- package/dist/sbom.d.ts +13 -0
- package/dist/sbom.js +193 -0
- package/dist/source-error.d.ts +17 -1
- package/dist/source-error.js +18 -3
- package/dist/sources.d.ts +2 -2
- package/dist/sources.js +699 -45
- package/dist/store.d.ts +38 -13
- package/dist/store.js +325 -23
- package/dist/types.d.ts +159 -2
- package/dist/util.d.ts +23 -0
- package/dist/util.js +81 -1
- package/dist/vendor/cvss4-reference.d.ts +2 -0
- package/dist/vendor/cvss4-reference.js +789 -0
- package/dist/word-filter.d.ts +3 -0
- package/dist/word-filter.js +3291 -0
- package/docs/alert-outcome-evaluation.md +150 -0
- package/docs/compatibility.md +35 -0
- package/docs/configuration.md +289 -29
- package/docs/cvss-v4-support.md +41 -0
- package/docs/offline-advisory-preview.md +114 -0
- package/docs/offline-rehearsal.md +44 -0
- package/docs/pilot-cases.md +58 -0
- package/docs/pilot-recall.md +124 -0
- package/docs/pilot-report.md +52 -0
- package/docs/validation/alert-outcome-evaluation-2026-11-05.json +2935 -0
- package/docs/validation/cvss-v4-reference-parity-2026-11-05.json +93 -0
- package/docs/validation/rehearsal-accepted-2026-11-05.json +175 -0
- package/docs/validation/rehearsal-unknown-2026-11-05.json +175 -0
- package/docs/vendor/cvss-v4-LICENSE.txt +22 -0
- package/docs/vendor/cvss-v4-provenance.json +38 -0
- package/examples/agent-advisories-2026.json +145 -0
- package/examples/agent-advisory-cases-2026.json +397 -0
- package/examples/libraries.example.txt +4 -2
- package/examples/libraries.example.yaml +2 -0
- package/examples/offline-advisory-preview.mjs +42 -0
- package/examples/rehearsal.json +75 -0
- package/examples/systems.example.yaml +4 -0
- package/package.json +24 -7
- package/docs/quality-review.md +0 -104
package/dist/assessment.js
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import { satisfies,
|
|
1
|
+
import { satisfies, valid } from 'semver';
|
|
2
|
+
import { pythonRangeStatus } from './python-version.js';
|
|
2
3
|
import { hash, highest, severityRank, timestamp } from './util.js';
|
|
3
|
-
import { exactLibraryVersion, normalizeEcosystem,
|
|
4
|
-
|
|
4
|
+
import { exactLibraryVersion, normalizeEcosystem, packageKey } from './ecosystems.js';
|
|
5
|
+
import { mentions, packageMentioned } from './matching.js';
|
|
6
|
+
export function normalizeEventId(id) {
|
|
5
7
|
return /^(?:CVE-|GHSA-)/i.test(id) ? id.toUpperCase() : id;
|
|
6
8
|
}
|
|
7
9
|
function identifiers(evidence) {
|
|
8
|
-
return [...new Set([evidence.id, ...evidence.aliases].map(
|
|
10
|
+
return [...new Set([evidence.id, ...evidence.aliases].map(normalizeEventId))];
|
|
9
11
|
}
|
|
10
12
|
function advisoryIdentifier(value) {
|
|
11
13
|
return /^(?:CVE-\d{4}-\d{4,}|GHSA-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{4})$/i.test(value);
|
|
@@ -31,7 +33,7 @@ function eventId(ids) {
|
|
|
31
33
|
})[0];
|
|
32
34
|
}
|
|
33
35
|
/** Only advisory alias claims merge events. A multi-CVE news story must not merge its subjects. */
|
|
34
|
-
function groupEvidence(input) {
|
|
36
|
+
function groupEvidence(input, knownEvents = new Set()) {
|
|
35
37
|
const evidence = newestEvidence(input);
|
|
36
38
|
const parents = new Map();
|
|
37
39
|
const find = (value) => {
|
|
@@ -56,7 +58,7 @@ function groupEvidence(input) {
|
|
|
56
58
|
}
|
|
57
59
|
const groups = new Map();
|
|
58
60
|
for (const item of advisory) {
|
|
59
|
-
const root = find(
|
|
61
|
+
const root = find(normalizeEventId(item.id));
|
|
60
62
|
if (!groups.has(root))
|
|
61
63
|
groups.set(root, { event: '', evidence: [] });
|
|
62
64
|
groups.get(root).evidence.push(item);
|
|
@@ -64,7 +66,13 @@ function groupEvidence(input) {
|
|
|
64
66
|
const aliasGroups = new Map();
|
|
65
67
|
for (const group of groups.values()) {
|
|
66
68
|
const ids = [...new Set(group.evidence.flatMap(identifiers))];
|
|
67
|
-
|
|
69
|
+
// An event already reported under one of its identifiers keeps it: a record that gains a GHSA
|
|
70
|
+
// alias, or is re-filed under another identifier, is the same vulnerability and must not be
|
|
71
|
+
// retired and raised again as a new finding.
|
|
72
|
+
const known = ids.filter((id) => knownEvents.has(id));
|
|
73
|
+
group.event = eventId(known.length ? known : ids);
|
|
74
|
+
if (known.length > 1)
|
|
75
|
+
group.reported = [...known].sort((a, b) => a === group.event ? -1 : b === group.event ? 1 : a.localeCompare(b));
|
|
68
76
|
for (const id of ids)
|
|
69
77
|
aliasGroups.set(id, group);
|
|
70
78
|
}
|
|
@@ -87,21 +95,56 @@ function groupEvidence(input) {
|
|
|
87
95
|
}
|
|
88
96
|
}
|
|
89
97
|
}
|
|
98
|
+
// Known exploitation applies to a cited CVE whether or not an advisory record has arrived yet.
|
|
99
|
+
for (const item of evidence.filter((item) => item.kind === 'kev'))
|
|
100
|
+
for (const event of new Set(identifiers(item)))
|
|
101
|
+
news.get(event)?.evidence.push(item);
|
|
90
102
|
return [...groups.values(), ...news.values()];
|
|
91
103
|
}
|
|
92
|
-
/** Word/identifier boundaries prevent "express" matching "expressions" or another npm scope. */
|
|
93
|
-
function mentions(text, needle) {
|
|
94
|
-
if (needle.trim().length < 3)
|
|
95
|
-
return false;
|
|
96
|
-
const escaped = needle.trim().replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
97
|
-
return new RegExp(`(?<![\\p{L}\\p{N}_@/\\-])${escaped}(?![\\p{L}\\p{N}_@/\\-])`, 'iu').test(text);
|
|
98
|
-
}
|
|
99
104
|
function stale(system, config, now) {
|
|
100
105
|
const updated = Date.parse(system.updated_at);
|
|
101
106
|
return (!Number.isFinite(updated) ||
|
|
102
107
|
updated > now + 5 * 60_000 ||
|
|
103
108
|
now - updated > config.inventory_stale_days * 86_400_000);
|
|
104
109
|
}
|
|
110
|
+
/**
|
|
111
|
+
* Advisory sources publish plain comparator sets. The wider npm grammar (carets, tildes, hyphen and
|
|
112
|
+
* x-ranges) is not theirs, and npm reads `> 1.2` as `>= 1.3.0` where a source means `> 1.2.0`.
|
|
113
|
+
* Anything outside the comparator subset is unsupported and must not produce an exclusion.
|
|
114
|
+
*/
|
|
115
|
+
function comparatorRange(input) {
|
|
116
|
+
const alternatives = [];
|
|
117
|
+
for (const alternative of input.split('||')) {
|
|
118
|
+
// GitHub renders intersections with commas and a space after the operator; semver uses spaces.
|
|
119
|
+
const tokens = alternative
|
|
120
|
+
.replace(/,/g, ' ')
|
|
121
|
+
.replace(/(<=|>=|<|>|=)\s+/g, '$1')
|
|
122
|
+
.trim()
|
|
123
|
+
.split(/\s+/);
|
|
124
|
+
// OSV collection renders an unbounded range as a lone `*`.
|
|
125
|
+
if (tokens.length === 1 && tokens[0] === '*') {
|
|
126
|
+
alternatives.push('*');
|
|
127
|
+
continue;
|
|
128
|
+
}
|
|
129
|
+
const comparators = [];
|
|
130
|
+
for (const token of tokens) {
|
|
131
|
+
const match = /^(<=|>=|<|>|=)?(\d\S*)$/.exec(token);
|
|
132
|
+
if (!match)
|
|
133
|
+
return undefined;
|
|
134
|
+
const operator = match[1] ?? '=';
|
|
135
|
+
const version = match[2];
|
|
136
|
+
if (valid(version) === version)
|
|
137
|
+
comparators.push(`${operator}${version}`);
|
|
138
|
+
// `>= 1.2` and `< 1.2` mean the same bound in both readings; other partial forms do not.
|
|
139
|
+
else if (/^\d+(?:\.\d+)?$/.test(version) && (operator === '>=' || operator === '<'))
|
|
140
|
+
comparators.push(`${operator}${[...version.split('.'), '0', '0'].slice(0, 3).join('.')}`);
|
|
141
|
+
else
|
|
142
|
+
return undefined;
|
|
143
|
+
}
|
|
144
|
+
alternatives.push(comparators.join(' '));
|
|
145
|
+
}
|
|
146
|
+
return alternatives.join(' || ');
|
|
147
|
+
}
|
|
105
148
|
function claimStatus(claim, version) {
|
|
106
149
|
if (!version)
|
|
107
150
|
return 'unknown';
|
|
@@ -114,15 +157,16 @@ function claimStatus(claim, version) {
|
|
|
114
157
|
}
|
|
115
158
|
if (claim.matched_versions?.includes(version) || claim.versions?.includes(version))
|
|
116
159
|
return 'affected';
|
|
160
|
+
if (ecosystem === 'PyPI')
|
|
161
|
+
return pythonRangeStatus(version, claim.range);
|
|
117
162
|
// Other registries have their own ordering, epochs and prerelease rules.
|
|
118
163
|
// Exact positive queries/listed versions are evidence; a missing match is not an exclusion.
|
|
119
164
|
if (ecosystem !== 'npm')
|
|
120
165
|
return 'unknown';
|
|
121
166
|
if (!claim.range)
|
|
122
167
|
return 'unknown';
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
if (!range.trim() || !validRange(range))
|
|
168
|
+
const range = comparatorRange(claim.range);
|
|
169
|
+
if (!range)
|
|
126
170
|
return 'unknown';
|
|
127
171
|
const matches = satisfies(version, range);
|
|
128
172
|
// npm semver deliberately excludes most prereleases: that is not evidence of safety.
|
|
@@ -145,20 +189,25 @@ function contextualPriority(severity, system, exploited) {
|
|
|
145
189
|
return 'critical';
|
|
146
190
|
return severity;
|
|
147
191
|
}
|
|
148
|
-
function base(group, system, now, category, component) {
|
|
192
|
+
function base(group, system, now, category, component, knownFindings = new Set()) {
|
|
193
|
+
// Two events reported separately can turn out to be one (a GHSA that lists both CVEs). Each
|
|
194
|
+
// finding keeps the identifier it was reported under, so neither is retired and raised again.
|
|
195
|
+
const event = group.reported?.find((id) => knownFindings.has(hash([id, system.id, component ?? null]))) ?? group.event;
|
|
149
196
|
const sourceSeverity = highest(...group.evidence.filter((item) => !item.withdrawn).map((item) => item.severity));
|
|
150
197
|
const exploited = group.evidence.some((item) => item.exploited || item.kind === 'kev');
|
|
198
|
+
// A KEV entry adds an exploitation fact; it does not turn a news report into an advisory.
|
|
199
|
+
const reports = group.evidence.filter((item) => item.kind !== 'kev');
|
|
151
200
|
const title = group.evidence.find((item) => item.kind === 'advisory' && !item.withdrawn)?.title ??
|
|
152
|
-
group.evidence[0].title;
|
|
201
|
+
(reports[0] ?? group.evidence[0]).title;
|
|
153
202
|
return {
|
|
154
|
-
id: hash([
|
|
155
|
-
event_id:
|
|
203
|
+
id: hash([event, system.id, component ?? null]),
|
|
204
|
+
event_id: event,
|
|
156
205
|
system_id: system.id,
|
|
157
206
|
...(component ? { component_id: component } : {}),
|
|
158
207
|
category,
|
|
159
|
-
news_only:
|
|
160
|
-
news_candidate:
|
|
161
|
-
(category === 'product' &&
|
|
208
|
+
news_only: reports.every((item) => item.kind === 'news'),
|
|
209
|
+
news_candidate: reports.every((item) => item.kind === 'news') ||
|
|
210
|
+
(category === 'product' && reports.some((item) => item.kind === 'news')),
|
|
162
211
|
applicability: 'unknown',
|
|
163
212
|
source_severity: sourceSeverity,
|
|
164
213
|
priority: contextualPriority(sourceSeverity, system, exploited),
|
|
@@ -172,9 +221,32 @@ function base(group, system, now, category, component) {
|
|
|
172
221
|
};
|
|
173
222
|
}
|
|
174
223
|
/** Assess each deployment independently against package identity and version evidence. */
|
|
175
|
-
export function assess(inventory, evidence, config, now = Date.now()
|
|
224
|
+
export function assess(inventory, evidence, config, now = Date.now(),
|
|
225
|
+
/**
|
|
226
|
+
* The time against which the age of advisory evidence is judged; `now` unless given. A scan that
|
|
227
|
+
* reconciles stored evidence before refreshing it passes the time of the last collection, so
|
|
228
|
+
* evidence does not count as stale merely because the refresh has not happened yet.
|
|
229
|
+
*/
|
|
230
|
+
evidenceAsOf = now,
|
|
231
|
+
/** Event identifiers of findings already reported; an event keeps the one it was reported under. */
|
|
232
|
+
knownEvents = new Set(),
|
|
233
|
+
/** Identifiers of findings already reported, for an event that merges two reported ones. */
|
|
234
|
+
knownFindings = new Set()) {
|
|
176
235
|
const output = [];
|
|
177
|
-
|
|
236
|
+
const index = new Map();
|
|
237
|
+
for (const system of inventory.systems) {
|
|
238
|
+
const byKey = new Map();
|
|
239
|
+
for (const component of system.components) {
|
|
240
|
+
const key = packageKey(component);
|
|
241
|
+
if (!key)
|
|
242
|
+
continue;
|
|
243
|
+
if (!byKey.has(key))
|
|
244
|
+
byKey.set(key, []);
|
|
245
|
+
byKey.get(key).push(component);
|
|
246
|
+
}
|
|
247
|
+
index.set(system, byKey);
|
|
248
|
+
}
|
|
249
|
+
for (const group of groupEvidence(evidence, knownEvents)) {
|
|
178
250
|
const advisories = group.evidence.filter((item) => item.kind === 'advisory');
|
|
179
251
|
const isNews = advisories.length === 0;
|
|
180
252
|
const identifiedNews = isNews && group.evidence.some((item) => identifiers(item).some(advisoryIdentifier));
|
|
@@ -182,20 +254,52 @@ export function assess(inventory, evidence, config, now = Date.now()) {
|
|
|
182
254
|
.filter((item) => item.kind !== 'kev')
|
|
183
255
|
.map((item) => `${item.title}\n${item.description}`)
|
|
184
256
|
.join('\n');
|
|
257
|
+
const newsText = group.evidence
|
|
258
|
+
.filter((item) => item.kind === 'news')
|
|
259
|
+
.map((item) => `${item.title}\n${item.description}`)
|
|
260
|
+
.join('\n');
|
|
261
|
+
// An advisory record without a usable package claim identifies the event but says nothing about
|
|
262
|
+
// which inventory packages it concerns, so it must not retire a candidate the linked news already
|
|
263
|
+
// raised. A claim for an ecosystem or a name this application cannot match is no claim at all.
|
|
264
|
+
const unclaimedNews = !isNews &&
|
|
265
|
+
newsText.length > 0 &&
|
|
266
|
+
advisories.every((item) => item.packages.every((claim) => packageKey(claim) === undefined));
|
|
267
|
+
// Index the group's claims once; a scan compares every group with every component.
|
|
268
|
+
const claimed = new Map();
|
|
269
|
+
for (const item of advisories) {
|
|
270
|
+
const byKey = new Map();
|
|
271
|
+
for (const claim of item.packages) {
|
|
272
|
+
const key = packageKey(claim);
|
|
273
|
+
if (!key)
|
|
274
|
+
continue;
|
|
275
|
+
if (!byKey.has(key))
|
|
276
|
+
byKey.set(key, []);
|
|
277
|
+
byKey.get(key).push(claim);
|
|
278
|
+
}
|
|
279
|
+
for (const [key, claims] of byKey) {
|
|
280
|
+
if (!claimed.has(key))
|
|
281
|
+
claimed.set(key, []);
|
|
282
|
+
claimed.get(key).push({ item, claims });
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
const hasCandidates = identifiedNews || unclaimedNews;
|
|
185
286
|
for (const system of inventory.systems) {
|
|
186
287
|
let componentMatched = false;
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
288
|
+
// Without news candidates only components named by a claim can produce a finding.
|
|
289
|
+
const components = hasCandidates
|
|
290
|
+
? system.components
|
|
291
|
+
: [...claimed.keys()].flatMap((key) => index.get(system).get(key) ?? []);
|
|
292
|
+
for (const component of components) {
|
|
293
|
+
const key = claimed.size ? packageKey(component) : undefined;
|
|
294
|
+
const matching = (key && claimed.get(key)) || [];
|
|
194
295
|
if (!matching.length) {
|
|
195
|
-
if (
|
|
296
|
+
if (hasCandidates && packageMentioned(newsText, component)) {
|
|
196
297
|
componentMatched = true;
|
|
197
|
-
const result = base(group, system, now, 'library', component.id);
|
|
198
|
-
result.
|
|
298
|
+
const result = base(group, system, now, 'library', component.id, knownFindings);
|
|
299
|
+
result.news_candidate = true;
|
|
300
|
+
result.reasons.push(unclaimedNews
|
|
301
|
+
? `News about this advisory mentions the ${component.ecosystem} package name ${component.name}; the advisory record carries no structured package evidence.`
|
|
302
|
+
: `News identifies an advisory and mentions the ${component.ecosystem} package name ${component.name}; no structured affected-version evidence is available yet.`);
|
|
199
303
|
if (stale(system, config, now))
|
|
200
304
|
result.reasons.push('Inventory is stale; confirm the installed version before assessing applicability.');
|
|
201
305
|
result.summary = `Reported advisory for ${component.name}${component.version ? `@${component.version}` : ''} in ${system.name}: applicability unknown.`;
|
|
@@ -206,7 +310,7 @@ export function assess(inventory, evidence, config, now = Date.now()) {
|
|
|
206
310
|
componentMatched = true;
|
|
207
311
|
const applicableEvidence = group.evidence.filter((item) => item.kind !== 'advisory' || matching.some((match) => match.item === item));
|
|
208
312
|
const selected = { ...group, evidence: applicableEvidence };
|
|
209
|
-
const result = base(selected, system, now, matching.some((match) => match.item.malware) ? 'malware' : 'library', component.id);
|
|
313
|
+
const result = base(selected, system, now, matching.some((match) => match.item.malware) ? 'malware' : 'library', component.id, knownFindings);
|
|
210
314
|
const active = matching.filter((match) => !match.item.withdrawn);
|
|
211
315
|
const states = active.map((match) => recordStatus(match.claims, component.version));
|
|
212
316
|
const withdrewSome = active.length !== matching.length;
|
|
@@ -234,6 +338,19 @@ export function assess(inventory, evidence, config, now = Date.now()) {
|
|
|
234
338
|
result.applicability = 'unknown';
|
|
235
339
|
result.reasons.push('Inventory is stale or has an invalid/future timestamp; confirm the currently installed version before relying on this assessment.');
|
|
236
340
|
}
|
|
341
|
+
const staleEvidence = active.some(({ item }) => {
|
|
342
|
+
const fetched = Date.parse(item.fetched_at);
|
|
343
|
+
return (!Number.isFinite(fetched) ||
|
|
344
|
+
fetched > now + 300_000 ||
|
|
345
|
+
evidenceAsOf - fetched > Math.max(120_000, config.poll_interval_minutes * 120_000));
|
|
346
|
+
});
|
|
347
|
+
if (staleEvidence) {
|
|
348
|
+
if (result.applicability === 'not_affected') {
|
|
349
|
+
result.applicability = 'unknown';
|
|
350
|
+
result.stale_exclusion = true;
|
|
351
|
+
}
|
|
352
|
+
result.reasons.push('Advisory evidence is stale; retained positive matches are historical and cannot prove current exclusion.');
|
|
353
|
+
}
|
|
237
354
|
const fixes = [
|
|
238
355
|
...new Set(active.flatMap((match) => match.claims.map((claim) => claim.fixed).filter((value) => Boolean(value)))),
|
|
239
356
|
];
|
|
@@ -243,14 +360,14 @@ export function assess(inventory, evidence, config, now = Date.now()) {
|
|
|
243
360
|
output.push(result);
|
|
244
361
|
}
|
|
245
362
|
// Apply the component's policy to linked news as well as the advisory itself.
|
|
246
|
-
if (componentMatched && !isNews)
|
|
363
|
+
if (componentMatched && !isNews && !unclaimedNews)
|
|
247
364
|
continue;
|
|
248
365
|
let productMatched = false;
|
|
249
366
|
for (const product of system.products) {
|
|
250
367
|
if (![product.name, ...product.keywords].some((keyword) => mentions(text, keyword)))
|
|
251
368
|
continue;
|
|
252
369
|
productMatched = true;
|
|
253
|
-
const result = base(group, system, now, isNews ? 'news' : 'product', `product:${product.name.toLowerCase()}
|
|
370
|
+
const result = base(group, system, now, isNews ? 'news' : 'product', `product:${product.name.toLowerCase()}`, knownFindings);
|
|
254
371
|
result.applicability = isNews ? 'relevant' : 'unknown';
|
|
255
372
|
result.withdrawn = !isNews && advisories.every((item) => item.withdrawn);
|
|
256
373
|
if (!isNews && advisories.some((item) => item.withdrawn) && !result.withdrawn)
|
|
@@ -263,12 +380,13 @@ export function assess(inventory, evidence, config, now = Date.now()) {
|
|
|
263
380
|
result.summary = `${product.name}${product.version ? ` ${product.version}` : ''} in ${system.name}: ${result.applicability}.`;
|
|
264
381
|
output.push(result);
|
|
265
382
|
}
|
|
266
|
-
if (componentMatched || productMatched || !isNews)
|
|
383
|
+
if (componentMatched || productMatched || (!isNews && !unclaimedNews))
|
|
267
384
|
continue;
|
|
268
|
-
|
|
269
|
-
|
|
385
|
+
if (!system.keywords.some((keyword) => mentions(newsText, keyword)) &&
|
|
386
|
+
!system.components.some((component) => packageMentioned(newsText, component)))
|
|
270
387
|
continue;
|
|
271
388
|
const result = base(group, system, now, 'news');
|
|
389
|
+
result.news_candidate = true;
|
|
272
390
|
result.applicability = stale(system, config, now) ? 'unknown' : 'relevant';
|
|
273
391
|
result.reasons.push('An explicit system keyword or installed package name matches this news; relevance does not establish vulnerability applicability.');
|
|
274
392
|
result.summary = `Security news relevant to ${system.name}; review the linked evidence.`;
|
|
@@ -280,6 +398,7 @@ export function assess(inventory, evidence, config, now = Date.now()) {
|
|
|
280
398
|
/** The source severity is always a floor; AI-proposed priority reductions cannot suppress it. */
|
|
281
399
|
export function decide(assessment, config) {
|
|
282
400
|
const policy = config.policy;
|
|
401
|
+
const reviewAi = policy.review_before_news_suppression ?? policy.ai_dismissals !== 'record';
|
|
283
402
|
if (assessment.category === 'health')
|
|
284
403
|
return {
|
|
285
404
|
action: policy.health_channels.length ? 'notify' : 'record',
|
|
@@ -288,6 +407,8 @@ export function decide(assessment, config) {
|
|
|
288
407
|
};
|
|
289
408
|
const rule = policy[assessment.category === 'malware' ? 'library' : assessment.category];
|
|
290
409
|
const channels = [...new Set(rule.channels)];
|
|
410
|
+
if (assessment.active === false)
|
|
411
|
+
return { action: 'record', channels: [], reason: 'Finding is no longer active.' };
|
|
291
412
|
if (assessment.withdrawn)
|
|
292
413
|
return {
|
|
293
414
|
action: 'record',
|
|
@@ -304,8 +425,28 @@ export function decide(assessment, config) {
|
|
|
304
425
|
const severity = rule.basis === 'source_severity'
|
|
305
426
|
? assessment.source_severity
|
|
306
427
|
: highest(assessment.source_severity, assessment.priority);
|
|
307
|
-
|
|
428
|
+
const quietAi = reviewAi &&
|
|
429
|
+
assessment.ai?.status === 'complete' &&
|
|
430
|
+
assessment.source_severity !== 'critical' &&
|
|
431
|
+
!(assessment.exploited && policy.exploited_override) &&
|
|
432
|
+
(((assessment.news_candidate || assessment.news_only) &&
|
|
433
|
+
(assessment.news_analysis?.impact === 'not_affected' ||
|
|
434
|
+
(assessment.news_analysis?.classification === 'general_news' &&
|
|
435
|
+
assessment.news_analysis.impact === 'not_applicable'))) ||
|
|
436
|
+
(assessment.category === 'news' && assessment.relevance === 'irrelevant'));
|
|
437
|
+
if (!channels.length && !quietAi)
|
|
308
438
|
return { action: 'record', channels: [], reason: 'This category has no configured delivery channels.' };
|
|
439
|
+
// Every supported range excludes the installed version; only the age of the evidence is in
|
|
440
|
+
// question. That is a source outage, which the source's health finding reports on its own
|
|
441
|
+
// channels: an urgent alert for every exclusion would repeat it on every outage. As for a current
|
|
442
|
+
// exclusion, no override applies: an exploited or malicious advisory for other versions is not
|
|
443
|
+
// about the installed one.
|
|
444
|
+
if (assessment.stale_exclusion)
|
|
445
|
+
return {
|
|
446
|
+
action: 'digest',
|
|
447
|
+
channels,
|
|
448
|
+
reason: 'The advisory ranges exclude this installed version, but the advisory evidence is out of date (see the source health finding); included in the review digest.',
|
|
449
|
+
};
|
|
309
450
|
if (assessment.category === 'malware' && policy.malware_override)
|
|
310
451
|
return {
|
|
311
452
|
action: 'notify',
|
|
@@ -317,31 +458,51 @@ export function decide(assessment, config) {
|
|
|
317
458
|
if ((assessment.news_candidate || assessment.news_only) && assessment.source_severity !== 'critical') {
|
|
318
459
|
const news = assessment.news_analysis;
|
|
319
460
|
if (assessment.ai?.status === 'complete' && news) {
|
|
320
|
-
if (news.classification === 'general_news' && news.impact === 'not_applicable')
|
|
461
|
+
if (news.classification === 'general_news' && news.impact === 'not_applicable') {
|
|
462
|
+
if (reviewAi)
|
|
463
|
+
return {
|
|
464
|
+
action: 'digest',
|
|
465
|
+
channels,
|
|
466
|
+
review: 'ai_general_news',
|
|
467
|
+
reason: 'AI classifies this as general news; policy requires operator review before dismissal.',
|
|
468
|
+
};
|
|
321
469
|
return {
|
|
322
470
|
action: 'record',
|
|
323
471
|
channels: [],
|
|
324
472
|
reason: 'AI reviewed this as general system news, with no newly reported vulnerability or actionable vulnerability update.',
|
|
325
473
|
};
|
|
326
|
-
|
|
474
|
+
}
|
|
475
|
+
if (news.impact === 'not_affected') {
|
|
476
|
+
if (reviewAi)
|
|
477
|
+
return {
|
|
478
|
+
action: 'digest',
|
|
479
|
+
channels,
|
|
480
|
+
review: 'ai_not_affected',
|
|
481
|
+
reason: 'AI reports no deployment impact; policy requires operator review before suppressing this news finding.',
|
|
482
|
+
};
|
|
327
483
|
return {
|
|
328
484
|
action: 'record',
|
|
329
485
|
channels: [],
|
|
330
486
|
reason: 'AI found that the reported news does not affect this deployment; this is a news assessment, not a verified safety conclusion.',
|
|
331
487
|
};
|
|
488
|
+
}
|
|
332
489
|
if (news.impact === 'affected' &&
|
|
333
|
-
['new_vulnerability', 'known_vulnerability_update'].includes(news.classification))
|
|
334
|
-
|
|
490
|
+
['new_vulnerability', 'known_vulnerability_update'].includes(news.classification)) {
|
|
491
|
+
// News carries no source severity, so the validated priority is the only level available.
|
|
492
|
+
// A positive impact claim must never be quieter than an uncertain or unclassified one.
|
|
493
|
+
const level = highest(severity, assessment.priority);
|
|
494
|
+
return rule.levels.includes(level) || (policy.urgent_unknown && level === 'critical')
|
|
335
495
|
? {
|
|
336
496
|
action: 'notify',
|
|
337
497
|
channels,
|
|
338
|
-
reason: `AI reports an impacted system in ${news.classification}; matched ${assessment.category} rule at ${
|
|
498
|
+
reason: `AI reports an impacted system in ${news.classification}; matched ${assessment.category} rule at ${level}. Verify the cited versions and prerequisites.`,
|
|
339
499
|
}
|
|
340
500
|
: {
|
|
341
|
-
action: '
|
|
342
|
-
channels
|
|
343
|
-
reason:
|
|
501
|
+
action: 'digest',
|
|
502
|
+
channels,
|
|
503
|
+
reason: `AI reports an impacted system in ${news.classification}; ${level} is below the configured ${assessment.category} severity levels, so it is included in the review digest.`,
|
|
344
504
|
};
|
|
505
|
+
}
|
|
345
506
|
}
|
|
346
507
|
if (config.models.enabled && !assessment.ai)
|
|
347
508
|
return {
|
|
@@ -363,12 +524,22 @@ export function decide(assessment, config) {
|
|
|
363
524
|
}
|
|
364
525
|
if (assessment.category === 'news' &&
|
|
365
526
|
assessment.relevance === 'irrelevant' &&
|
|
366
|
-
assessment.source_severity !== 'critical')
|
|
527
|
+
assessment.source_severity !== 'critical') {
|
|
528
|
+
if (reviewAi && assessment.ai?.status === 'complete')
|
|
529
|
+
return {
|
|
530
|
+
action: 'digest',
|
|
531
|
+
channels,
|
|
532
|
+
review: 'ai_irrelevant',
|
|
533
|
+
reason: 'AI reports no relevant deployment context; policy requires operator review before dismissal.',
|
|
534
|
+
};
|
|
367
535
|
return {
|
|
368
536
|
action: 'record',
|
|
369
537
|
channels: [],
|
|
370
538
|
reason: 'Evidence-backed news relevance assessment found no relevant deployment context.',
|
|
371
539
|
};
|
|
540
|
+
}
|
|
541
|
+
if (!channels.length)
|
|
542
|
+
return { action: 'record', channels: [], reason: 'This category has no configured delivery channels.' };
|
|
372
543
|
if (uncertain) {
|
|
373
544
|
if (policy.urgent_unknown &&
|
|
374
545
|
severityRank[highest(assessment.source_severity, assessment.priority)] >= severityRank.critical) {
|