@shieldaai/security-watch 1.2.1 → 1.3.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/CHANGELOG.md +24 -0
- package/README.md +5 -4
- package/SECURITY.md +4 -1
- package/dist/cli.js +186 -4
- package/dist/config.d.ts +22 -0
- package/dist/config.js +32 -0
- package/dist/cve-now.js +2 -0
- package/dist/delivery.js +30 -0
- package/dist/engine.d.ts +25 -0
- package/dist/engine.js +64 -4
- package/dist/index.d.ts +8 -1
- package/dist/index.js +3 -0
- package/dist/inventory.js +1 -1
- package/dist/mitigations.d.ts +137 -0
- package/dist/mitigations.js +426 -0
- package/dist/rehearsal.d.ts +25 -0
- package/dist/rehearsal.js +2 -0
- package/dist/sbom.d.ts +12 -1
- package/dist/sbom.js +37 -7
- package/dist/shield-candidates.d.ts +97 -0
- package/dist/shield-candidates.js +251 -0
- package/dist/shield-inputs.d.ts +49 -0
- package/dist/shield-inputs.js +297 -0
- package/dist/shirudo-sboms.d.ts +62 -0
- package/dist/shirudo-sboms.js +598 -0
- package/dist/sources.js +10 -0
- package/dist/store.js +6 -4
- package/dist/types.d.ts +31 -0
- package/dist/vex.d.ts +62 -0
- package/dist/vex.js +246 -0
- package/docs/configuration.md +20 -1
- package/docs/mitigations.md +139 -0
- package/docs/offline-advisory-preview.md +2 -2
- package/docs/sbom.md +4 -4
- package/docs/shirudo.md +113 -0
- package/package.json +1 -1
package/dist/types.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ModelProvider, OutputFormat } from './providers.js';
|
|
2
2
|
import type { Ecosystem } from './ecosystems.js';
|
|
3
|
+
import type { MitigationSource, MitigationStatus } from './mitigations.js';
|
|
3
4
|
export type Severity = 'unknown' | 'low' | 'medium' | 'high' | 'critical';
|
|
4
5
|
export type Category = 'library' | 'product' | 'news' | 'malware' | 'health';
|
|
5
6
|
export type Applicability = 'affected' | 'not_affected' | 'unknown' | 'conflicting' | 'relevant';
|
|
@@ -155,6 +156,29 @@ export interface Evidence {
|
|
|
155
156
|
withdrawn?: boolean;
|
|
156
157
|
exploited?: boolean;
|
|
157
158
|
malware?: boolean;
|
|
159
|
+
/**
|
|
160
|
+
* Links the advisory publishes, most specific first. Inputs for whoever writes a fix or a runtime
|
|
161
|
+
* shield. Never sent to models; not part of the evidence content hash.
|
|
162
|
+
*/
|
|
163
|
+
references?: AdvisoryReference[];
|
|
164
|
+
/** Commits the advisory records as fixing the problem (OSV `GIT` ranges). Same rules as references. */
|
|
165
|
+
fix_commits?: FixCommit[];
|
|
166
|
+
/** Weakness identifiers such as CWE-502. Same rules as references. */
|
|
167
|
+
weaknesses?: string[];
|
|
168
|
+
/**
|
|
169
|
+
* Public exploit code the source reports, such as `exploit-db` or `github-poc` (cve.now). Published
|
|
170
|
+
* code, not exploitation in the wild. Same rules as references.
|
|
171
|
+
*/
|
|
172
|
+
exploit_sources?: string[];
|
|
173
|
+
}
|
|
174
|
+
export type ReferenceType = 'fix' | 'evidence' | 'advisory' | 'report' | 'detection' | 'introduced' | 'package' | 'source' | 'web';
|
|
175
|
+
export interface AdvisoryReference {
|
|
176
|
+
type: ReferenceType;
|
|
177
|
+
url: string;
|
|
178
|
+
}
|
|
179
|
+
export interface FixCommit {
|
|
180
|
+
repo: string;
|
|
181
|
+
commit: string;
|
|
158
182
|
}
|
|
159
183
|
export interface ModelSpec {
|
|
160
184
|
provider: ModelProvider;
|
|
@@ -247,6 +271,11 @@ export interface Config {
|
|
|
247
271
|
/** Required to listen beyond loopback without TLS, for example behind a TLS proxy. */
|
|
248
272
|
allow_plain_http: boolean;
|
|
249
273
|
};
|
|
274
|
+
/**
|
|
275
|
+
* Runtime mitigation status read from JSON Lines exports (Shirudo's `node_vulns`, or the generic
|
|
276
|
+
* format). Shown in alerts and `shield-candidates`; never changes applicability, priority or routing.
|
|
277
|
+
*/
|
|
278
|
+
mitigations?: MitigationSource[];
|
|
250
279
|
maintenance?: {
|
|
251
280
|
interval_hours: number;
|
|
252
281
|
retention?: {
|
|
@@ -278,6 +307,8 @@ export interface Assessment {
|
|
|
278
307
|
location?: FindingLocation;
|
|
279
308
|
/** EPSS for the finding's CVE when `sources.epss` is on. Shown only; changes nothing. */
|
|
280
309
|
epss?: EpssScore;
|
|
310
|
+
/** Runtime mitigation status, one per configured source that covers the system. Shown only; changes nothing. */
|
|
311
|
+
mitigations?: MitigationStatus[];
|
|
281
312
|
/** News-only or generic product context without deterministic package applicability. */
|
|
282
313
|
news_candidate?: boolean;
|
|
283
314
|
/**
|
package/dist/vex.d.ts
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import type { Assessment, Component, Evidence, Inventory } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* An OpenVEX v0.2.0 document for the findings Security Watch holds about installed libraries.
|
|
4
|
+
*
|
|
5
|
+
* A VEX statement says whether a product is affected by a vulnerability, so only findings that name
|
|
6
|
+
* one exact package version can be written. News, product and health findings have no package to
|
|
7
|
+
* point at and are counted as skipped, not guessed at.
|
|
8
|
+
*/
|
|
9
|
+
export interface VexInput {
|
|
10
|
+
findings: Assessment[];
|
|
11
|
+
evidence: (ids: readonly string[]) => Evidence[];
|
|
12
|
+
inventory: Inventory;
|
|
13
|
+
/** Only this system's findings. */
|
|
14
|
+
systemId?: string;
|
|
15
|
+
/** Also write `not_affected` statements. Default false: they are a claim consumers rely on. */
|
|
16
|
+
includeNotAffected?: boolean;
|
|
17
|
+
/** Default `Security Watch`. */
|
|
18
|
+
author?: string;
|
|
19
|
+
now?: number;
|
|
20
|
+
/** One line about runtime mitigations for a finding, from elsewhere. Appended to action statements. */
|
|
21
|
+
mitigationNote?: (finding: Assessment) => string | undefined;
|
|
22
|
+
}
|
|
23
|
+
export interface VexStatement {
|
|
24
|
+
vulnerability: {
|
|
25
|
+
name: string;
|
|
26
|
+
aliases?: string[];
|
|
27
|
+
};
|
|
28
|
+
products: {
|
|
29
|
+
'@id': string;
|
|
30
|
+
}[];
|
|
31
|
+
status: 'affected' | 'not_affected' | 'under_investigation';
|
|
32
|
+
/** Required by OpenVEX for `affected`. */
|
|
33
|
+
action_statement?: string;
|
|
34
|
+
/** OpenVEX requires a justification or an impact statement for `not_affected`. */
|
|
35
|
+
justification?: 'vulnerable_code_not_present';
|
|
36
|
+
impact_statement?: string;
|
|
37
|
+
}
|
|
38
|
+
export interface VexDocument {
|
|
39
|
+
'@context': 'https://openvex.dev/ns/v0.2.0';
|
|
40
|
+
'@id': string;
|
|
41
|
+
author: string;
|
|
42
|
+
timestamp: string;
|
|
43
|
+
version: 1;
|
|
44
|
+
tooling: 'Security Watch';
|
|
45
|
+
statements: VexStatement[];
|
|
46
|
+
}
|
|
47
|
+
/** Undefined when the ecosystem has no package URL type or the name has no usable parts. */
|
|
48
|
+
export declare function buildPurl(component: Pick<Component, 'ecosystem' | 'name' | 'version'>): string | undefined;
|
|
49
|
+
/**
|
|
50
|
+
* The inventory's package URL, made fit to publish: the type in lower case, only descriptive
|
|
51
|
+
* qualifiers, no subpath, a scoped npm `@` written as `%40`, and the component's version added when
|
|
52
|
+
* the URL has none. `mismatch` when its version is not the component's: the statement would be about
|
|
53
|
+
* another version. Nothing when it cannot be read; the caller builds one instead.
|
|
54
|
+
*/
|
|
55
|
+
export declare function publishablePurl(purl: string, version: string): {
|
|
56
|
+
purl?: string;
|
|
57
|
+
mismatch?: boolean;
|
|
58
|
+
};
|
|
59
|
+
export declare function openVex(input: VexInput): {
|
|
60
|
+
document: VexDocument;
|
|
61
|
+
skipped: Record<string, number>;
|
|
62
|
+
};
|
package/dist/vex.js
ADDED
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
import { timestamp } from './util.js';
|
|
3
|
+
/** The package URL type for each ecosystem. This inverts the mapping the SBOM import reads. */
|
|
4
|
+
const PURL_TYPES = {
|
|
5
|
+
npm: 'npm',
|
|
6
|
+
PyPI: 'pypi',
|
|
7
|
+
Packagist: 'composer',
|
|
8
|
+
Go: 'golang',
|
|
9
|
+
Maven: 'maven',
|
|
10
|
+
'crates.io': 'cargo',
|
|
11
|
+
RubyGems: 'gem',
|
|
12
|
+
NuGet: 'nuget',
|
|
13
|
+
Hex: 'hex',
|
|
14
|
+
Pub: 'pub',
|
|
15
|
+
Hackage: 'hackage',
|
|
16
|
+
SwiftURL: 'swift',
|
|
17
|
+
};
|
|
18
|
+
/** The package URL specification encodes everything but unreserved characters; a colon stays as is. */
|
|
19
|
+
function encode(segment) {
|
|
20
|
+
return encodeURIComponent(segment)
|
|
21
|
+
.replace(/[!'()*]/g, (char) => `%${char.charCodeAt(0).toString(16).toUpperCase()}`)
|
|
22
|
+
.replace(/%3A/gi, ':');
|
|
23
|
+
}
|
|
24
|
+
/** Undefined when the ecosystem has no package URL type or the name has no usable parts. */
|
|
25
|
+
export function buildPurl(component) {
|
|
26
|
+
const type = PURL_TYPES[component.ecosystem];
|
|
27
|
+
if (!type || !component.version)
|
|
28
|
+
return undefined;
|
|
29
|
+
let name = component.name;
|
|
30
|
+
// Maven names are group:artifact; the group is the namespace. Anything else is not a Maven name.
|
|
31
|
+
if (component.ecosystem === 'Maven') {
|
|
32
|
+
if (name.split(':').length !== 2)
|
|
33
|
+
return undefined;
|
|
34
|
+
name = name.replace(':', '/');
|
|
35
|
+
}
|
|
36
|
+
// The specification lowercases PyPI names and writes underscores as dashes, and lowercases the
|
|
37
|
+
// case-insensitive Composer, Hex and Pub names.
|
|
38
|
+
if (component.ecosystem === 'PyPI')
|
|
39
|
+
name = name.toLowerCase().replace(/_/g, '-');
|
|
40
|
+
if (component.ecosystem === 'Packagist' || component.ecosystem === 'Hex' || component.ecosystem === 'Pub')
|
|
41
|
+
name = name.toLowerCase();
|
|
42
|
+
const parts = name.split('/').filter((part) => part.length > 0);
|
|
43
|
+
if (parts.length === 0)
|
|
44
|
+
return undefined;
|
|
45
|
+
try {
|
|
46
|
+
return `pkg:${type}/${parts.map(encode).join('/')}@${encode(component.version)}`;
|
|
47
|
+
}
|
|
48
|
+
catch {
|
|
49
|
+
// A lone surrogate cannot be encoded: the component is skipped, not the document.
|
|
50
|
+
return undefined;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
/** The CVE, GHSA and other identifiers the finding's advisories publish, without the event itself. */
|
|
54
|
+
function aliasesOf(finding, evidence) {
|
|
55
|
+
const ids = new Set();
|
|
56
|
+
for (const item of evidence) {
|
|
57
|
+
// News only mentions identifiers; an advisory or the exploited-vulnerability catalog states them.
|
|
58
|
+
if (item.withdrawn || (item.kind !== 'advisory' && item.kind !== 'kev'))
|
|
59
|
+
continue;
|
|
60
|
+
for (const alias of item.aliases)
|
|
61
|
+
if (alias.trim())
|
|
62
|
+
ids.add(alias.trim());
|
|
63
|
+
}
|
|
64
|
+
ids.delete(finding.event_id);
|
|
65
|
+
return [...ids].sort();
|
|
66
|
+
}
|
|
67
|
+
function actionStatement(finding, name, note) {
|
|
68
|
+
const base = finding.category === 'malware'
|
|
69
|
+
? `Remove ${name}: it is reported as a malicious package.`
|
|
70
|
+
: finding.fix
|
|
71
|
+
? `Update ${name} to ${finding.fix}.`
|
|
72
|
+
: 'No fixed version is published; follow the advisory.';
|
|
73
|
+
const extra = note?.trim();
|
|
74
|
+
return extra ? `${base} ${extra}` : base;
|
|
75
|
+
}
|
|
76
|
+
/** The same statements give the same identifier, so an unchanged state is the same document. */
|
|
77
|
+
function documentId(author, statements) {
|
|
78
|
+
const hex = createHash('sha256').update(JSON.stringify({ author, statements })).digest('hex');
|
|
79
|
+
// Shaped as a version 4 UUID: version nibble 4, variant bits 10.
|
|
80
|
+
const variant = ((parseInt(hex[16], 16) & 0x3) | 0x8).toString(16);
|
|
81
|
+
return `urn:uuid:${hex.slice(0, 8)}-${hex.slice(8, 12)}-4${hex.slice(13, 16)}-${variant}${hex.slice(17, 20)}-${hex.slice(20, 32)}`;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Qualifiers that describe the package itself and are kept. Others (`repository_url`, `download_url`,
|
|
85
|
+
* `vcs_url`, a vendor's `registry=`) can name a private registry, and a VEX document is read outside.
|
|
86
|
+
*/
|
|
87
|
+
const PUBLIC_QUALIFIERS = new Set(['classifier', 'type', 'arch', 'distro', 'os', 'epoch']);
|
|
88
|
+
/**
|
|
89
|
+
* The inventory's package URL, made fit to publish: the type in lower case, only descriptive
|
|
90
|
+
* qualifiers, no subpath, a scoped npm `@` written as `%40`, and the component's version added when
|
|
91
|
+
* the URL has none. `mismatch` when its version is not the component's: the statement would be about
|
|
92
|
+
* another version. Nothing when it cannot be read; the caller builds one instead.
|
|
93
|
+
*/
|
|
94
|
+
export function publishablePurl(purl, version) {
|
|
95
|
+
const text = purl.trim().split('#')[0];
|
|
96
|
+
const [head, query] = text.split('?', 2);
|
|
97
|
+
const match = /^pkg:([A-Za-z][A-Za-z0-9.+-]*)\/(.+)$/.exec(head);
|
|
98
|
+
if (!match)
|
|
99
|
+
return {};
|
|
100
|
+
const [, type, rest] = match;
|
|
101
|
+
// The version follows the last @ after the last slash; an @ that starts a namespace is part of it.
|
|
102
|
+
const slash = rest.lastIndexOf('/');
|
|
103
|
+
const at = rest.lastIndexOf('@');
|
|
104
|
+
const path = at > slash && at > 0 ? rest.slice(0, at) : rest;
|
|
105
|
+
const given = at > slash && at > 0 ? rest.slice(at + 1) : undefined;
|
|
106
|
+
if (!path || path.split('/').some((part) => !part))
|
|
107
|
+
return {};
|
|
108
|
+
let decoded;
|
|
109
|
+
try {
|
|
110
|
+
decoded = given === undefined ? undefined : decodeURIComponent(given);
|
|
111
|
+
}
|
|
112
|
+
catch {
|
|
113
|
+
return {};
|
|
114
|
+
}
|
|
115
|
+
if (decoded !== undefined && decoded !== version)
|
|
116
|
+
return { mismatch: true };
|
|
117
|
+
const qualifiers = (query ?? '')
|
|
118
|
+
.split('&')
|
|
119
|
+
.filter((pair) => PUBLIC_QUALIFIERS.has(pair.split('=')[0].toLowerCase()) && pair.includes('='))
|
|
120
|
+
.sort();
|
|
121
|
+
try {
|
|
122
|
+
const namespace = path.replace(/^@/, '%40');
|
|
123
|
+
return {
|
|
124
|
+
purl: `pkg:${type.toLowerCase()}/${namespace}@${given ?? encode(version)}${qualifiers.length ? `?${qualifiers.join('&')}` : ''}`,
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
catch {
|
|
128
|
+
return {};
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
const STATUS_ORDER = {
|
|
132
|
+
affected: 0,
|
|
133
|
+
under_investigation: 1,
|
|
134
|
+
not_affected: 2,
|
|
135
|
+
};
|
|
136
|
+
function compare(first, second) {
|
|
137
|
+
return first < second ? -1 : first > second ? 1 : 0;
|
|
138
|
+
}
|
|
139
|
+
export function openVex(input) {
|
|
140
|
+
const skipped = {};
|
|
141
|
+
const skip = (reason) => {
|
|
142
|
+
skipped[reason] = (skipped[reason] ?? 0) + 1;
|
|
143
|
+
};
|
|
144
|
+
const components = new Map(input.inventory.systems.map((system) => [
|
|
145
|
+
system.id,
|
|
146
|
+
new Map(system.components.map((item) => [item.id, item])),
|
|
147
|
+
]));
|
|
148
|
+
const statements = [];
|
|
149
|
+
for (const finding of input.findings) {
|
|
150
|
+
if (input.systemId !== undefined && finding.system_id !== input.systemId)
|
|
151
|
+
continue;
|
|
152
|
+
if (finding.active === false || finding.withdrawn) {
|
|
153
|
+
skip('inactive');
|
|
154
|
+
continue;
|
|
155
|
+
}
|
|
156
|
+
if (finding.category !== 'library' && finding.category !== 'malware') {
|
|
157
|
+
skip('not_library');
|
|
158
|
+
continue;
|
|
159
|
+
}
|
|
160
|
+
const component = finding.component_id
|
|
161
|
+
? components.get(finding.system_id)?.get(finding.component_id)
|
|
162
|
+
: undefined;
|
|
163
|
+
if (!component) {
|
|
164
|
+
skip('no_component');
|
|
165
|
+
continue;
|
|
166
|
+
}
|
|
167
|
+
if (!component.version) {
|
|
168
|
+
skip('no_version');
|
|
169
|
+
continue;
|
|
170
|
+
}
|
|
171
|
+
// The inventory's own package URL is what other tools match on, so it is kept, made fit to publish.
|
|
172
|
+
// The inventory's own package URL when it can be published, else one built from the component.
|
|
173
|
+
const published = component.purl?.trim() ? publishablePurl(component.purl, component.version) : {};
|
|
174
|
+
if (published.mismatch) {
|
|
175
|
+
skip('purl_version_mismatch');
|
|
176
|
+
continue;
|
|
177
|
+
}
|
|
178
|
+
const purl = published.purl ?? buildPurl(component);
|
|
179
|
+
if (!purl) {
|
|
180
|
+
skip('no_purl_type');
|
|
181
|
+
continue;
|
|
182
|
+
}
|
|
183
|
+
const vulnerability = { name: finding.event_id };
|
|
184
|
+
const aliases = aliasesOf(finding, input.evidence(finding.evidence_ids));
|
|
185
|
+
if (aliases.length > 0)
|
|
186
|
+
vulnerability.aliases = aliases;
|
|
187
|
+
// Statements carry no time of their own (they inherit the document's), so an unchanged state
|
|
188
|
+
// gives the same statements and the same document identifier on every run.
|
|
189
|
+
const base = { vulnerability, products: [{ '@id': purl }] };
|
|
190
|
+
if (finding.applicability === 'affected') {
|
|
191
|
+
statements.push({
|
|
192
|
+
...base,
|
|
193
|
+
status: 'affected',
|
|
194
|
+
action_statement: actionStatement(finding, component.name, input.mitigationNote?.(finding)),
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
else if (finding.applicability === 'unknown' || finding.applicability === 'conflicting') {
|
|
198
|
+
statements.push({ ...base, status: 'under_investigation' });
|
|
199
|
+
}
|
|
200
|
+
else if (finding.applicability === 'not_affected') {
|
|
201
|
+
if (!input.includeNotAffected) {
|
|
202
|
+
skip('not_affected_omitted');
|
|
203
|
+
continue;
|
|
204
|
+
}
|
|
205
|
+
statements.push({
|
|
206
|
+
...base,
|
|
207
|
+
status: 'not_affected',
|
|
208
|
+
justification: 'vulnerable_code_not_present',
|
|
209
|
+
impact_statement: 'The installed version is outside the affected versions the advisories publish.',
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
else {
|
|
213
|
+
skip('applicability_not_reportable');
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
// The same package version in several systems is one statement. When systems disagree, the most
|
|
217
|
+
// severe status stands (affected, then under investigation, then not affected): a consumer must
|
|
218
|
+
// never hide a vulnerability that one of the systems is affected by.
|
|
219
|
+
const byProduct = new Map();
|
|
220
|
+
for (const statement of statements) {
|
|
221
|
+
const key = `${statement.vulnerability.name}\u0000${statement.products[0]['@id']}`;
|
|
222
|
+
const known = byProduct.get(key);
|
|
223
|
+
if (!known ||
|
|
224
|
+
STATUS_ORDER[statement.status] < STATUS_ORDER[known.status] ||
|
|
225
|
+
(statement.status === known.status &&
|
|
226
|
+
compare(statement.action_statement ?? '', known.action_statement ?? '') < 0))
|
|
227
|
+
byProduct.set(key, statement);
|
|
228
|
+
}
|
|
229
|
+
statements.length = 0;
|
|
230
|
+
statements.push(...byProduct.values());
|
|
231
|
+
statements.sort((a, b) => compare(a.vulnerability.name, b.vulnerability.name) ||
|
|
232
|
+
compare(a.products[0]['@id'], b.products[0]['@id']));
|
|
233
|
+
const author = input.author ?? 'Security Watch';
|
|
234
|
+
return {
|
|
235
|
+
document: {
|
|
236
|
+
'@context': 'https://openvex.dev/ns/v0.2.0',
|
|
237
|
+
'@id': documentId(author, statements),
|
|
238
|
+
author,
|
|
239
|
+
timestamp: timestamp(input.now),
|
|
240
|
+
version: 1,
|
|
241
|
+
tooling: 'Security Watch',
|
|
242
|
+
statements,
|
|
243
|
+
},
|
|
244
|
+
skipped,
|
|
245
|
+
};
|
|
246
|
+
}
|
package/docs/configuration.md
CHANGED
|
@@ -267,6 +267,25 @@ For an existing installation, configuration fields set to `true` stay enabled. T
|
|
|
267
267
|
|
|
268
268
|
References: [cve.now machine-readable API guide](https://cve.now/llms.txt), [The Hacker News](https://thehackernews.com/), [OSV batch queries](https://google.github.io/osv.dev/post-v1-querybatch/), [GitHub global advisory API](https://docs.github.com/en/rest/security-advisories/global-advisories), [CISA KEV data](https://github.com/cisagov/kev-data).
|
|
269
269
|
|
|
270
|
+
## Temporary mitigations
|
|
271
|
+
|
|
272
|
+
Advisories from OSV and GitHub keep their typed links (fix commits, pull requests and patches first), OSV's fix commits and both sources' CWE identifiers; cve.now records keep their Exploit-DB, Metasploit, Nuclei and GitHub proof-of-concept entries. Only https links without credentials are kept, at most 40 links, 20 commits and 20 weaknesses per advisory. They are never sent to models and are not part of an advisory's revision. `explain` shows them per advisory.
|
|
273
|
+
|
|
274
|
+
`security-watch shield-candidates [--all] [--unmitigated] [--omit-location] [--output NEW.json]` lists the findings worth a temporary mitigation, with a `readiness` from `fix_known` to `news_only` and what is still `missing`. `security-watch vex [--system ID] [--include-not-affected] [--omit-mitigations] [--author TEXT] [--output NEW.json]` writes an OpenVEX document. Both read the database and change nothing.
|
|
275
|
+
|
|
276
|
+
An optional `mitigations` list (at most ten) shows how many hosts of an affected system a mitigation covers, read from JSON Lines files that your tools write:
|
|
277
|
+
|
|
278
|
+
```yaml
|
|
279
|
+
mitigations:
|
|
280
|
+
- format: shirudo # shirudo (Shirudo's node_vulns export) or generic
|
|
281
|
+
file: ./shirudo/node-vulns.jsonl # relative to this file
|
|
282
|
+
name: Shirudo # optional; default Shirudo or Mitigations; unique
|
|
283
|
+
max_age_minutes: 120 # 5 to 10080; an older file is a monitoring-health error
|
|
284
|
+
systems: {} # the file's system key -> system ID; an unmapped key is the system ID
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
The status is shown in alerts, digests, `explain`, `findings`, `shield-candidates` and `vex` as `mitigations`. Like EPSS it is shown only: it changes no applicability, priority, rule or decision, creates no revision and never closes a finding. Files are limited to 64 MiB and 500,000 rows. See [temporary mitigations](mitigations.md) for the generic format, and [Security Watch with Shirudo](shirudo.md) for the export query and `shirudo-sboms`.
|
|
288
|
+
|
|
270
289
|
## Model configuration
|
|
271
290
|
|
|
272
291
|
Before enabling real delivery, [offline rehearsal](offline-rehearsal.md) can replay a bounded sequence of normalized evidence and optional inventory snapshots through the existing policy, queue and simulated delivery transports. It preserves configured channel selection while replacing destinations with in-process sinks, forces models/sources off, and verifies a temporary SQLite backup/restore. The command does not load credentials or open the configured database. Its private report omits raw identifiers, source text and destinations; it does not measure live coverage or model/analyst quality.
|
|
@@ -622,7 +641,7 @@ systems:
|
|
|
622
641
|
LANGFLOW_WEBHOOK_AUTH_ENABLE: true
|
|
623
642
|
```
|
|
624
643
|
|
|
625
|
-
`sbom` imports a local CycloneDX JSON 1.
|
|
644
|
+
`sbom` imports a local CycloneDX JSON 1.2 to 1.7 file (a later 1.x is read by the 1.7 rules, with a notice), or an SPDX JSON 2.2 or 2.3 file (including
|
|
626
645
|
GitHub's `{"sbom": ...}` API response). To have every SBOM in a folder become a system of its own, set
|
|
627
646
|
`sbom_directory` at the top of the inventory instead; see [the SBOM folder](sbom.md#the-sbom-folder).
|
|
628
647
|
`security-watch sbom` writes such a file from a project's lockfiles ([guide](sbom.md)). A component's
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
# Temporary mitigations: shields, policies and VEX
|
|
2
|
+
|
|
3
|
+
A fix takes time to test and roll out. In the meantime a temporary mitigation can block the attack: a runtime shield that blocks one code path ([Shirudo](shirudo.md)), an eBPF policy (Tetragon, KubeArmor), a firewall rule in front of the service, or a live kernel patch. Security Watch does not write, sign or load any of these. It runs nothing on your machines and needs no privileges there, and a mitigation that blocks the wrong thing can take production down. It helps in three ways:
|
|
4
|
+
|
|
5
|
+
1. **`shield-candidates`** lists the findings worth a mitigation, with what is known for writing one and what is missing.
|
|
6
|
+
2. **Mitigation status** shows, in alerts and reports, how many of the hosts running an affected system are covered, read from a file your mitigation tool writes.
|
|
7
|
+
3. **`vex`** writes an OpenVEX document so that other scanners know what Security Watch knows.
|
|
8
|
+
|
|
9
|
+
A mitigation is temporary. Security Watch never closes a finding because of one: the finding stays open until the fix is deployed and the next inventory shows the fixed version.
|
|
10
|
+
|
|
11
|
+
## What a mitigation needs
|
|
12
|
+
|
|
13
|
+
A shield or a narrow policy blocks one code path or one kind of request, so someone has to find it first. These help, best first:
|
|
14
|
+
|
|
15
|
+
1. **The fix itself**: a fix commit or patch link. Its diff shows the vulnerable function.
|
|
16
|
+
2. **The package, the installed version and the fixed version.** The difference between the two releases contains the fix, with more noise.
|
|
17
|
+
3. **Public exploit code**, to test that the mitigation stops the attack and nothing else.
|
|
18
|
+
4. **The weakness type** (CWE) and the conditions for exploitation, to keep it narrow.
|
|
19
|
+
|
|
20
|
+
A news story that says something is being exploited usually has none of the first three. News alone is therefore never enough: such a finding is listed as `news_only`, with "wait for an advisory".
|
|
21
|
+
|
|
22
|
+
Security Watch keeps these inputs from the sources it already reads: links with their type from OSV and GitHub advisories (code changes such as commits, pull requests and patches are marked `fix`), fix commits from OSV, CWE identifiers from OSV and GitHub, and Exploit-DB, Metasploit, Nuclei and GitHub proof-of-concept entries from cve.now. Only https links without credentials are kept, at most 40 links, 20 commits and 20 weaknesses per advisory. A link to an advisory database (GitHub's, PyPA's, RustSec, the Go and CVE lists) is never a fix. They are not sent to models and are not part of an advisory's revision, so upgrading creates no new revisions, alerts or analyses. OSV advisories gain them at the next scan; GitHub and cve.now advisories when the source next sends them. `explain` shows them per advisory.
|
|
23
|
+
|
|
24
|
+
## Shield candidates
|
|
25
|
+
|
|
26
|
+
```sh
|
|
27
|
+
security-watch shield-candidates --config ./watch/security-watch.yaml
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
The command reads the database and changes nothing. By default it lists active findings that are critical, or known or reported to be exploited, and leaves out suppressed ones. A malicious package is never listed: it is removed, not mitigated.
|
|
31
|
+
|
|
32
|
+
| Option | Does |
|
|
33
|
+
| ------------------- | ------------------------------------------------------------------------------------------ |
|
|
34
|
+
| `--all` | Every finding that may affect you, suppressed ones included. |
|
|
35
|
+
| `--unmitigated` | Leaves out findings that a current (not out-of-date) status shows mitigated on every host. |
|
|
36
|
+
| `--omit-location` | Leaves out what identifies your systems; use it before handing the list to anyone outside. |
|
|
37
|
+
| `--output NEW.json` | Writes the list to a new private file; never replaces one. |
|
|
38
|
+
|
|
39
|
+
Each candidate has a `readiness`, most ready first:
|
|
40
|
+
|
|
41
|
+
| Readiness | Means |
|
|
42
|
+
| --------------------- | ---------------------------------------------------------------------------------------------------- |
|
|
43
|
+
| `fix_known` | The installed version is affected, and an advisory links the fix commit or patch. |
|
|
44
|
+
| `fixed_version_known` | The installed version is affected and a fixed version is published, but no fix link. |
|
|
45
|
+
| `advisory_only` | An advisory exists, but the installed version is not confirmed affected (no version, product match). |
|
|
46
|
+
| `news_only` | Only news so far. Wait for an advisory or a vendor bulletin. |
|
|
47
|
+
|
|
48
|
+
`missing` lists in plain words what is not known yet, for example that no public exploit code is reported, so the mitigation has to be tested against the fix instead. A candidate also carries its identifiers, the package with its installed and fixed versions, `fix_links`, `fix_commits`, other `references`, `weaknesses`, `public_exploit`, EPSS, the advisories it rests on, its `mitigations` status and where to look.
|
|
49
|
+
|
|
50
|
+
```json
|
|
51
|
+
{
|
|
52
|
+
"finding_id": "1e35fbcd…",
|
|
53
|
+
"readiness": "fix_known",
|
|
54
|
+
"missing": [
|
|
55
|
+
"No public exploit code reported by the sources read, so a shield cannot be tested against a real attack; test it against the fix instead."
|
|
56
|
+
],
|
|
57
|
+
"identifiers": ["CVE-2026-20001", "GHSA-aaaa-bbbb-cccc"],
|
|
58
|
+
"package": { "ecosystem": "Maven", "name": "org.example:parser", "installed": "2.4.1", "fixed": "2.4.2" },
|
|
59
|
+
"fix_links": ["https://github.com/example/parser/commit/abcdef1234"],
|
|
60
|
+
"weaknesses": ["CWE-502"],
|
|
61
|
+
"exploited": true,
|
|
62
|
+
"mitigations": [{ "source": "Shirudo", "summary": "Shirudo: mitigated on 0 of 4 hosts; 4 not mitigated." }]
|
|
63
|
+
}
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
**Before you hand the list to an agent or a service outside your network**, add `--omit-location`. Without it the list includes system IDs, names, owners and the notes from your inventory, package URLs with their qualifiers (which can name a private registry), and links to news articles (a feed can be internal). With it, those are left out and a candidate is known by its `finding_id`; advisory identifiers, package names and versions stay, because a mitigation is written from them.
|
|
67
|
+
|
|
68
|
+
When the inventory cannot be read, a package and its installed version are shown only where an advisory matched exactly one package by version.
|
|
69
|
+
|
|
70
|
+
## Mitigation status
|
|
71
|
+
|
|
72
|
+
Each mitigation tool writes a [JSON Lines](https://jsonlines.org/) file on a timer (one JSON object per line), and Security Watch reads it at every scan. Up to ten sources:
|
|
73
|
+
|
|
74
|
+
```yaml
|
|
75
|
+
# watch/security-watch.yaml
|
|
76
|
+
mitigations:
|
|
77
|
+
- format: shirudo # Shirudo's node_vulns export; see the Shirudo guide
|
|
78
|
+
file: ./shirudo/node-vulns.jsonl # relative to this file
|
|
79
|
+
- format: generic # anything else
|
|
80
|
+
name: Edge WAF # shown in alerts; default Shirudo or Mitigations; each source needs its own
|
|
81
|
+
file: ./waf/mitigations.jsonl
|
|
82
|
+
max_age_minutes: 60 # 5 to 10080, default 120: an older file is reported, and its status marked out of date
|
|
83
|
+
systems: # optional: the file's system key -> Security Watch system ID
|
|
84
|
+
shop-frontend: web-shop # without an entry, the key is the system ID
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
The generic format has one row per host and finding, and one `none` row for a host with nothing to report, so that it is counted:
|
|
88
|
+
|
|
89
|
+
```json
|
|
90
|
+
{"system_id": "web-shop", "host": "web-1", "identifier": "CVE-2026-20001", "package": "org.example:parser", "status": "mitigated", "mitigation": "waf-rule-42", "expires_at": "2026-12-01T00:00:00Z"}
|
|
91
|
+
{"system_id": "web-shop", "host": "web-2", "identifier": "CVE-2026-20001", "package": "org.example:parser", "status": "unmitigated"}
|
|
92
|
+
{"system_id": "web-shop", "host": "web-3", "status": "none"}
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
| Field | Required | Meaning |
|
|
96
|
+
| ------------ | ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
97
|
+
| `system_id` | yes | The system, or a key that `systems` maps to one. |
|
|
98
|
+
| `host` | yes | A host, node or instance. The same name in two systems is two hosts. |
|
|
99
|
+
| `identifier` | unless `none` | The CVE, GHSA or other advisory identifier. |
|
|
100
|
+
| `package` | no | Needed for a library finding: the package name as Security Watch writes it (Maven `group:artifact`); compared without case, and for PyPI also without `-`, `_`, `.` differences. One CVE can name several packages, so a row without a package applies only to findings without one (products, news, kernel). |
|
|
101
|
+
| `kernel` | no | `true` for a kernel row: it matches by identifier alone. |
|
|
102
|
+
| `status` | yes | `mitigated`, `pending`, `failed`, `excluded`, `withdrawn`, `expired`, `unmitigated`, `unknown` or `none`. Any other value is `unknown`. |
|
|
103
|
+
| `mitigation` | no | The rule, policy, shield or patch, named in alerts while it is in place or waiting to load. |
|
|
104
|
+
| `expires_at` | no | An ISO time. A `mitigated` or `pending` row past it counts as `expired`. |
|
|
105
|
+
|
|
106
|
+
Write the file under a temporary name and rename it into place (`mv`), so that a scan never reads half of it: its modification time is the export time.
|
|
107
|
+
|
|
108
|
+
At each scan, rows are matched to findings by system, by identifier (the finding's own, or a CVE or GHSA alias of one of its current advisories, not one a news article cites) and, for a library, by package name. A status or exposure value this release does not know is read as `unknown` and reported, in case the tool added one. Each host counts once, by its worst row (not mitigated, expired, withdrawn, excluded, failed, unknown, pending, mitigated). Alerts and digests show up to three sources, and `explain`, `findings` and `shield-candidates` show all:
|
|
109
|
+
|
|
110
|
+
```text
|
|
111
|
+
Edge WAF: mitigated on 3 of 4 hosts; 1 not mitigated. (export 2026-11-24 11:55 UTC; a mitigation is temporary and does not close the finding) In place: waf-rule-42
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
When the hosts of a system have no row for a finding, the status says the source lists no such finding there, so nothing is linked to it. That is the most useful line for whoever runs the tool: Security Watch knows of a problem the tool does not.
|
|
115
|
+
|
|
116
|
+
**The status is shown only.** It does not change applicability, priority or routing. A change in it creates no new revision, re-sends nothing and asks no model for a new analysis. A missing, unreadable or empty file is a monitoring-health error, as a failed source is, and findings then show no status from it rather than an old one. A file older than `max_age_minutes`, or dated in the future, is reported the same way, and its status is marked out of date. Lines that cannot be read are skipped, counted and reported; the rest are used. `doctor` reads every file and names system keys that match no system. Rehearsal (`rehearse`) never reads these files.
|
|
117
|
+
|
|
118
|
+
Files are limited to 64 MiB and 500,000 rows. Fields are single-line text of at most 512 characters.
|
|
119
|
+
|
|
120
|
+
## VEX for other tools
|
|
121
|
+
|
|
122
|
+
```sh
|
|
123
|
+
security-watch vex --config ./watch/security-watch.yaml --output security-watch.vex.json
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
`vex` writes an [OpenVEX](https://github.com/openvex/spec) 0.2.0 document for library findings that name an exact package version, so that scanners which read VEX (Trivy, Grype, Docker Scout) and the people reading their reports know what Security Watch knows. It reads the database and the inventory and changes nothing.
|
|
127
|
+
|
|
128
|
+
| Finding | Statement |
|
|
129
|
+
| --------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
130
|
+
| Affected | `affected`, with the action: update to the fixed version, or follow the advisory; plus, when a current source shows hosts mitigated, how many, by which source and as of when. |
|
|
131
|
+
| Malicious package | `affected`, action: remove it. |
|
|
132
|
+
| Unknown or conflicting | `under_investigation`. |
|
|
133
|
+
| Not affected (version outside the published ranges) | Only with `--include-not-affected`: `not_affected`, `vulnerable_code_not_present`. |
|
|
134
|
+
|
|
135
|
+
A scanner that reads `not_affected` hides the vulnerability from its own report. Security Watch reaches that conclusion from published version ranges, which can be wrong, so it is left out unless you ask for it.
|
|
136
|
+
|
|
137
|
+
The product is the package URL from your inventory, published with only descriptive qualifiers (`classifier`, `type`, `arch`, `distro`, `os`, `epoch`; others, such as `repository_url`, can name a private registry) and the component's version, or one built from the ecosystem, name and version when the inventory's cannot be read. A package URL whose version is not the component's is left out. The mitigation part of an action names your tool and host counts; `--omit-mitigations` leaves it out. News, product and health findings have no package to point at and are left out; with `--output`, the command says how many were left out and why. `--system ID` limits the document to one system, `--author TEXT` names who stands behind it (default `Security Watch`). The document identifier depends only on the statements, so an unchanged state gives the same identifier on every run. A mitigation never changes a status: a mitigated finding is still `affected`. Checked with Trivy 0.71.2: `trivy sbom --vex security-watch.vex.json your.cdx.json` hides the `not_affected` vulnerabilities and keeps the others.
|
|
138
|
+
|
|
139
|
+
Statuses are saved at each scan and judged again whenever they are read: `findings`, `explain`, `shield-candidates` and `vex` mark a status out of date (`stale_reason`) when its export is now older than `max_age_minutes`, its source is no longer configured, or a mitigation it counted has expired, so an old status is never shown as current after scans stop.
|
|
@@ -4,7 +4,7 @@ Security Watch compares a system inventory with advisory evidence and records
|
|
|
4
4
|
why a finding applies. Begin with its published fictional inventory and advisory
|
|
5
5
|
fixture, then inspect the result before configuring real monitoring.
|
|
6
6
|
|
|
7
|
-
This example uses `@shieldaai/security-watch@1.
|
|
7
|
+
This example uses `@shieldaai/security-watch@1.3.0`, an in-memory database,
|
|
8
8
|
no provider credentials and no notification delivery. It is a fixture check of
|
|
9
9
|
matching behavior, not an audit of real dependencies.
|
|
10
10
|
|
|
@@ -16,7 +16,7 @@ Use Node.js 24.10 or newer in a new directory:
|
|
|
16
16
|
mkdir watch-demo
|
|
17
17
|
cd watch-demo
|
|
18
18
|
npm init -y
|
|
19
|
-
npm install --ignore-scripts --save-exact @shieldaai/security-watch@1.
|
|
19
|
+
npm install --ignore-scripts --save-exact @shieldaai/security-watch@1.3.0
|
|
20
20
|
```
|
|
21
21
|
|
|
22
22
|
## Run the fictional inventory
|
package/docs/sbom.md
CHANGED
|
@@ -103,7 +103,7 @@ systems: [] # systems you describe by hand can sit beside them
|
|
|
103
103
|
- **A file that cannot be read** is reported as an import warning (`doctor`, and a monitoring-health finding at scan time) and left out; the other systems are still watched.
|
|
104
104
|
- **Operating-system packages** (deb, rpm, apk and similar, found in container-image SBOMs) are not matched against advisories. They are listed once as a notice, which does not degrade monitoring. Use your image scanner for them.
|
|
105
105
|
|
|
106
|
-
CycloneDX JSON 1.
|
|
106
|
+
CycloneDX JSON 1.2 to 1.7 and SPDX JSON 2.2 and 2.3 are accepted; a later CycloneDX 1.x is read by the 1.7 rules and named once as a notice, and 2.x is refused. `security-watch sbom` writes 1.6, which more tools read. GitHub's REST response is accepted too (`{"sbom": {...}}`). Each file is bounded to 20 MiB and 20,000 packages, and the folder to 1,000 files. For Docker, mount the folder read-only beside the inventory, for example `--mount type=bind,src="$(pwd)/watch/sboms",dst=/config/sboms,readonly`.
|
|
107
107
|
|
|
108
108
|
## From a CI pipeline
|
|
109
109
|
|
|
@@ -127,7 +127,7 @@ jobs:
|
|
|
127
127
|
steps:
|
|
128
128
|
- uses: actions/checkout@v7
|
|
129
129
|
- id: sbom
|
|
130
|
-
uses: ShieldaAI/security-watch@v1.
|
|
130
|
+
uses: ShieldaAI/security-watch@v1.3.0
|
|
131
131
|
with:
|
|
132
132
|
system-id: checkout-api
|
|
133
133
|
owner: Dana, platform team
|
|
@@ -143,7 +143,7 @@ To use an SBOM made by another tool, pass it as `sbom-file`; the action checks t
|
|
|
143
143
|
|
|
144
144
|
```yaml
|
|
145
145
|
- run: trivy image --format cyclonedx --output image.cdx.json "$IMAGE"
|
|
146
|
-
- uses: ShieldaAI/security-watch@v1.
|
|
146
|
+
- uses: ShieldaAI/security-watch@v1.3.0
|
|
147
147
|
with:
|
|
148
148
|
sbom-file: image.cdx.json
|
|
149
149
|
system-id: checkout-image
|
|
@@ -160,7 +160,7 @@ Any job with Node.js 24.10 or newer can run the command:
|
|
|
160
160
|
security-watch-sbom:
|
|
161
161
|
image: node:24-slim
|
|
162
162
|
script:
|
|
163
|
-
- npx --yes @shieldaai/security-watch@1.
|
|
163
|
+
- npx --yes @shieldaai/security-watch@1.3.0 sbom --system-id checkout-api --output security-watch.cdx.json --upload https://watch.example.com:8787
|
|
164
164
|
artifacts:
|
|
165
165
|
paths: [security-watch.cdx.json]
|
|
166
166
|
```
|