@shieldaai/security-watch 1.0.0 → 1.1.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/dist/sbom.d.ts CHANGED
@@ -4,10 +4,25 @@ export interface SbomImport {
4
4
  warnings: string[];
5
5
  dependencies: DependencyRelationship[];
6
6
  source: {
7
- format: 'CycloneDX';
7
+ format: 'CycloneDX' | 'SPDX';
8
8
  spec_version: string;
9
9
  digest: string;
10
10
  };
11
+ /**
12
+ * What the document says about the system it describes: its name, when it was created, and the
13
+ * `security-watch:*` properties written by `security-watch sbom`. Used by an SBOM folder.
14
+ */
15
+ subject?: {
16
+ name?: string;
17
+ created?: string;
18
+ properties: Record<string, string>;
19
+ };
11
20
  }
12
21
  /** Bounded local metadata import: never follows references, runs scripts or fetches packages. */
13
22
  export declare function importCycloneDx(path: string): SbomImport;
23
+ /**
24
+ * Imports a CycloneDX (1.4 to 1.6) or SPDX (2.2, 2.3) JSON document, whichever the file is. This
25
+ * accepts the output of `security-watch sbom`, Trivy, Syft, cdxgen and GitHub's dependency-graph
26
+ * export ("Export SBOM", or the REST API's `{ "sbom": ... }` response) without conversion.
27
+ */
28
+ export declare function importSbom(path: string): SbomImport;
package/dist/sbom.js CHANGED
@@ -5,21 +5,136 @@ import { eq as samePythonVersion, valid as validPython } from '@renovatebot/pep4
5
5
  import { hash, LINE_BREAKING } from './util.js';
6
6
  const object = (value) => typeof value === 'object' && value !== null && !Array.isArray(value);
7
7
  const text = (value) => typeof value === 'string' && value.length > 0 && value.length <= 1000 && !LINE_BREAKING.test(value);
8
- /** Bounded local metadata import: never follows references, runs scripts or fetches packages. */
9
- export function importCycloneDx(path) {
8
+ function readSbom(path) {
10
9
  const stat = statSync(path);
11
10
  if (!stat.isFile() || stat.size > 20 * 1024 * 1024)
12
11
  throw new Error('SBOM must be a regular JSON file of at most 20 MiB');
13
12
  const bytes = readFileSync(path);
14
13
  if (bytes.byteLength > 20 * 1024 * 1024)
15
14
  throw new Error('SBOM exceeds 20 MiB');
16
- const bom = JSON.parse(bytes.toString('utf8'));
15
+ let document;
16
+ try {
17
+ document = JSON.parse(bytes.toString('utf8').replace(/^\uFEFF/, ''));
18
+ }
19
+ catch {
20
+ throw new Error('SBOM is not valid JSON');
21
+ }
22
+ return { document, digest: `sha256:${createHash('sha256').update(bytes).digest('hex')}` };
23
+ }
24
+ /** Bounded local metadata import: never follows references, runs scripts or fetches packages. */
25
+ export function importCycloneDx(path) {
26
+ const { document, digest } = readSbom(path);
27
+ return importCycloneDxDocument(document, digest);
28
+ }
29
+ /**
30
+ * Imports a CycloneDX (1.4 to 1.6) or SPDX (2.2, 2.3) JSON document, whichever the file is. This
31
+ * accepts the output of `security-watch sbom`, Trivy, Syft, cdxgen and GitHub's dependency-graph
32
+ * export ("Export SBOM", or the REST API's `{ "sbom": ... }` response) without conversion.
33
+ */
34
+ export function importSbom(path) {
35
+ const { document, digest } = readSbom(path);
36
+ if (object(document) && document.bomFormat === 'CycloneDX')
37
+ return importCycloneDxDocument(document, digest);
38
+ const spdx = object(document) && object(document.sbom) ? document.sbom : document;
39
+ if (object(spdx) && typeof spdx.spdxVersion === 'string')
40
+ return importSpdxDocument(spdx, digest);
41
+ throw new Error('Expected a CycloneDX JSON (1.4 to 1.6) or SPDX JSON (2.2, 2.3) SBOM');
42
+ }
43
+ const SPDX_RELATIONSHIPS = 100_000;
44
+ /** SPDX packages become CycloneDX-shaped components so that both formats pass the same checks. */
45
+ function importSpdxDocument(spdx, digest) {
46
+ const version = /^SPDX-(2\.[23])$/.exec(String(spdx.spdxVersion));
47
+ if (!version || !Array.isArray(spdx.packages))
48
+ throw new Error('Expected SPDX JSON 2.2 or 2.3 with packages');
49
+ if (spdx.packages.length > 20_000)
50
+ throw new Error('SBOM exceeds 20000 component entries');
51
+ const relationships = spdx.relationships === undefined ? [] : spdx.relationships;
52
+ if (!Array.isArray(relationships) || relationships.length > SPDX_RELATIONSHIPS)
53
+ throw new Error('Invalid SPDX relationships');
54
+ // The package the document describes is the system itself, not one of its dependencies.
55
+ const described = new Set(Array.isArray(spdx.documentDescribes) ? spdx.documentDescribes.filter(text) : []);
56
+ for (const relation of relationships)
57
+ if (object(relation) && relation.relationshipType === 'DESCRIBES' && text(relation.relatedSpdxElement))
58
+ described.add(relation.relatedSpdxElement);
59
+ const warnings = [];
60
+ const components = [];
61
+ let root;
62
+ for (const [index, entry] of spdx.packages.entries()) {
63
+ if (!object(entry))
64
+ throw new Error('Invalid SBOM component');
65
+ const id = entry.SPDXID;
66
+ if (!text(id))
67
+ throw new Error('Invalid SBOM component reference');
68
+ const refs = Array.isArray(entry.externalRefs) ? entry.externalRefs : [];
69
+ const purl = refs.find((ref) => object(ref) && ref.referenceType === 'purl' && text(ref.referenceLocator));
70
+ if (described.has(id)) {
71
+ root ??= id;
72
+ continue;
73
+ }
74
+ const info = entry.versionInfo;
75
+ const component = {
76
+ 'bom-ref': id,
77
+ ...(purl ? { purl: purl.referenceLocator } : {}),
78
+ };
79
+ // The package URL is authoritative. A version field beside a versionless purl is used only when
80
+ // it is one exact version: GitHub writes manifest ranges (`^4.17.0`) there.
81
+ if (purl &&
82
+ !/@[^/]+$/.test(purl.referenceLocator.split(/[?#]/)[0]) &&
83
+ text(info) &&
84
+ info !== 'NOASSERTION') {
85
+ if (/^[A-Za-z0-9][A-Za-z0-9.!+_-]*$/.test(info) && !/^(?:latest|\*)$/i.test(info))
86
+ component.version = info;
87
+ else
88
+ warnings.push(`Component ${index + 1}: version ${info.slice(0, 40)} is a range; imported by name only.`);
89
+ }
90
+ if (Array.isArray(entry.checksums)) {
91
+ const sha = entry.checksums.find((value) => object(value) &&
92
+ value.algorithm === 'SHA256' &&
93
+ typeof value.checksumValue === 'string' &&
94
+ /^[a-fA-F0-9]{64}$/.test(value.checksumValue));
95
+ if (object(sha))
96
+ component.hashes = [{ alg: 'SHA-256', content: sha.checksumValue }];
97
+ }
98
+ components.push(component);
99
+ }
100
+ const edges = new Map();
101
+ for (const relation of relationships) {
102
+ if (!object(relation))
103
+ throw new Error('Invalid SPDX relationships');
104
+ const type = relation.relationshipType;
105
+ if (type !== 'DEPENDS_ON' && type !== 'DEPENDENCY_OF')
106
+ continue;
107
+ const [from, to] = type === 'DEPENDS_ON'
108
+ ? [relation.spdxElementId, relation.relatedSpdxElement]
109
+ : [relation.relatedSpdxElement, relation.spdxElementId];
110
+ if (!text(from) || !text(to))
111
+ throw new Error('Invalid SBOM dependency references');
112
+ const targets = edges.get(from) ?? [];
113
+ if (!targets.includes(to))
114
+ targets.push(to);
115
+ edges.set(from, targets);
116
+ }
117
+ const creation = object(spdx.creationInfo) ? spdx.creationInfo : {};
118
+ const result = importCycloneDxDocument({
119
+ bomFormat: 'CycloneDX',
120
+ specVersion: '1.6',
121
+ ...(root ? { metadata: { component: { 'bom-ref': root } } } : {}),
122
+ components,
123
+ ...(edges.size ? { dependencies: [...edges].map(([ref, dependsOn]) => ({ ref, dependsOn })) } : {}),
124
+ }, digest, 'SPDX');
125
+ result.source = { format: 'SPDX', spec_version: version[1], digest };
126
+ result.warnings.unshift(...warnings);
127
+ const name = text(spdx.name) ? spdx.name : undefined;
128
+ const created = text(creation.created) ? creation.created : undefined;
129
+ result.subject = { ...(name ? { name } : {}), ...(created ? { created } : {}), properties: {} };
130
+ return result;
131
+ }
132
+ function importCycloneDxDocument(bom, digest, provenance = 'CycloneDX') {
17
133
  if (!object(bom) ||
18
134
  bom.bomFormat !== 'CycloneDX' ||
19
135
  !['1.4', '1.5', '1.6'].includes(String(bom.specVersion)) ||
20
136
  !Array.isArray(bom.components))
21
137
  throw new Error('Expected CycloneDX JSON 1.4, 1.5 or 1.6 with components');
22
- const digest = `sha256:${createHash('sha256').update(bytes).digest('hex')}`;
23
138
  const result = {
24
139
  components: [],
25
140
  warnings: [],
@@ -125,8 +240,28 @@ export function importCycloneDx(path) {
125
240
  ? { artifact_kind: 'model' }
126
241
  : {}),
127
242
  ...(version === undefined ? {} : { version }),
128
- provenance: { source: 'CycloneDX', reference: digest },
243
+ provenance: { source: provenance, reference: digest },
129
244
  };
245
+ // `evidence.occurrences` (CycloneDX 1.5+) says which files the package was found in. That is
246
+ // where a reader of an alert should look, so it becomes the component's note.
247
+ const occurrences = object(entry.evidence) && Array.isArray(entry.evidence.occurrences) ? entry.evidence.occurrences : [];
248
+ const locations = [
249
+ ...new Set(occurrences
250
+ .slice(0, 100)
251
+ .map((occurrence) => (object(occurrence) ? occurrence.location : undefined))
252
+ .filter((location) => text(location) && location.length <= 300)),
253
+ ];
254
+ if (locations.length) {
255
+ let note = `found in ${locations[0]}`;
256
+ for (const location of locations.slice(1)) {
257
+ if (note.length + location.length + 2 > 480) {
258
+ note += ' and others';
259
+ break;
260
+ }
261
+ note += `, ${location}`;
262
+ }
263
+ component.note = note;
264
+ }
130
265
  if (entry.hashes !== undefined) {
131
266
  if (!Array.isArray(entry.hashes) || entry.hashes.length > 32)
132
267
  throw new Error('Invalid SBOM hashes');
@@ -189,5 +324,21 @@ export function importCycloneDx(path) {
189
324
  result.warnings.push(`Dependency target ${ref}: not an imported package; reference retained without resolved identity.`);
190
325
  }
191
326
  }
327
+ const metadata = object(bom.metadata) ? bom.metadata : {};
328
+ const subject = object(metadata.component) ? metadata.component : {};
329
+ const properties = {};
330
+ if (Array.isArray(metadata.properties))
331
+ for (const property of metadata.properties.slice(0, 200))
332
+ if (object(property) &&
333
+ text(property.name) &&
334
+ property.name.startsWith('security-watch:') &&
335
+ text(property.value) &&
336
+ !Object.hasOwn(properties, property.name))
337
+ properties[property.name] = property.value;
338
+ result.subject = {
339
+ ...(text(subject.name) ? { name: subject.name } : {}),
340
+ ...(text(metadata.timestamp) ? { created: metadata.timestamp } : {}),
341
+ properties,
342
+ };
192
343
  return result;
193
344
  }
package/dist/types.d.ts CHANGED
@@ -96,7 +96,10 @@ export interface System extends InventoryEvidence {
96
96
  export interface Inventory {
97
97
  systems: System[];
98
98
  import_warnings?: string[];
99
- /** Entries that are accepted as written but may not be what was meant. They do not degrade a scan. */
99
+ /**
100
+ * Things to read once that do not degrade a scan: entries accepted as written that may not be what
101
+ * was meant, and operating-system packages in an SBOM folder that are not matched.
102
+ */
100
103
  name_notices?: string[];
101
104
  }
102
105
  export interface PackageClaim {
@@ -209,6 +212,20 @@ export interface Config {
209
212
  interval_seconds: number;
210
213
  allow_private_endpoint: boolean;
211
214
  };
215
+ /** An HTTPS endpoint that accepts SBOM uploads from CI pipelines into the inventory's SBOM folder. */
216
+ intake?: {
217
+ /** `HOST:PORT`. Default `127.0.0.1:8787`. */
218
+ listen: string;
219
+ /** Bearer tokens, each read from an environment variable and limited to some system IDs. */
220
+ tokens: Array<{
221
+ token_env: string;
222
+ systems: string[];
223
+ }>;
224
+ tls_cert_file?: string;
225
+ tls_key_file?: string;
226
+ /** Required to listen beyond loopback without TLS, for example behind a TLS proxy. */
227
+ allow_plain_http: boolean;
228
+ };
212
229
  maintenance?: {
213
230
  interval_hours: number;
214
231
  retention?: {
@@ -0,0 +1,21 @@
1
+ import type { IntakeUpload } from './intake.js';
2
+ /** Sends an SBOM to a Security Watch intake (`security-watch upload`, the GitHub Action). */
3
+ export interface UploadOptions {
4
+ /** Base address of the intake, for example `https://watch.example.com:8787`. */
5
+ url: string;
6
+ systemId: string;
7
+ /** The SBOM JSON. */
8
+ body: string | Uint8Array;
9
+ token: string;
10
+ /** Permit plain HTTP to a host that is not this machine. */
11
+ allowHttp?: boolean;
12
+ /** Attempts in all, for network errors, 429 and 5xx answers. Default 3. */
13
+ attempts?: number;
14
+ /** Per attempt. Default 120 seconds. */
15
+ timeoutMs?: number;
16
+ fetch?: typeof fetch;
17
+ sleep?: (ms: number) => Promise<void>;
18
+ }
19
+ /** The upload address for one system, refusing addresses that would leak the token. */
20
+ export declare function intakeAddress(base: string, systemId: string, allowHttp?: boolean): URL;
21
+ export declare function uploadSbom(options: UploadOptions): Promise<IntakeUpload>;
package/dist/upload.js ADDED
@@ -0,0 +1,76 @@
1
+ import { isIP } from 'node:net';
2
+ const SYSTEM_ID = /^[a-z0-9][a-z0-9._-]{0,99}$/;
3
+ function loopback(hostname) {
4
+ const host = hostname.replace(/^\[|\]$/g, '');
5
+ return host === 'localhost' || host === '::1' || (isIP(host) === 4 && host.startsWith('127.'));
6
+ }
7
+ /** The upload address for one system, refusing addresses that would leak the token. */
8
+ export function intakeAddress(base, systemId, allowHttp = false) {
9
+ let url;
10
+ try {
11
+ url = new URL(base);
12
+ }
13
+ catch {
14
+ throw new Error('The intake address must be a URL, for example https://watch.example.com:8787');
15
+ }
16
+ if (url.username || url.password || url.search || url.hash)
17
+ throw new Error('The intake address must not contain credentials, a query or a fragment.');
18
+ if (url.protocol !== 'https:' && !(url.protocol === 'http:' && (loopback(url.hostname) || allowHttp)))
19
+ throw new Error('The intake address must use HTTPS, so that the upload token is not sent in clear text (plain HTTP is accepted for this machine only, or with --allow-http).');
20
+ if (!SYSTEM_ID.test(systemId))
21
+ throw new Error('A system ID is 1 to 100 lower-case letters, digits, dots, hyphens or underscores, starting with a letter or digit.');
22
+ url.pathname = `${url.pathname.replace(/\/+$/, '')}/v1/sboms/${encodeURIComponent(systemId)}`;
23
+ return url;
24
+ }
25
+ export async function uploadSbom(options) {
26
+ const url = intakeAddress(options.url, options.systemId, options.allowHttp);
27
+ const request = options.fetch ?? fetch;
28
+ const sleep = options.sleep ?? ((ms) => new Promise((done) => setTimeout(done, ms)));
29
+ const attempts = options.attempts ?? 3;
30
+ let last = 'no attempt was made';
31
+ for (let attempt = 1; attempt <= attempts; attempt++) {
32
+ let retryAfter = 2000 * attempt;
33
+ try {
34
+ const response = await request(url, {
35
+ method: 'PUT',
36
+ headers: { authorization: `Bearer ${options.token}`, 'content-type': 'application/json' },
37
+ body: typeof options.body === 'string' ? options.body : Buffer.from(options.body),
38
+ // A redirect would carry the token to another address.
39
+ redirect: 'error',
40
+ signal: AbortSignal.timeout(options.timeoutMs ?? 120_000),
41
+ });
42
+ const text = (await response.text()).slice(0, 10_000);
43
+ let body = {};
44
+ try {
45
+ body = JSON.parse(text);
46
+ }
47
+ catch {
48
+ // The error below says what came back.
49
+ }
50
+ if (response.ok && typeof body.system_id === 'string')
51
+ return body;
52
+ const reason = typeof body.error === 'string'
53
+ ? body.error
54
+ : `HTTP ${response.status} without a Security Watch answer`;
55
+ if (response.status !== 429 && response.status < 500)
56
+ throw Object.assign(new Error(`Upload refused (${response.status}): ${reason}`), { final: true });
57
+ last = `HTTP ${response.status}: ${reason}`;
58
+ const seconds = Number(response.headers.get('retry-after'));
59
+ if (Number.isFinite(seconds) && seconds > 0)
60
+ retryAfter = Math.min(seconds, 30) * 1000;
61
+ }
62
+ catch (error) {
63
+ if (error.final)
64
+ throw error;
65
+ last =
66
+ error instanceof Error
67
+ ? error.cause instanceof Error
68
+ ? error.cause.message
69
+ : error.message
70
+ : 'error';
71
+ }
72
+ if (attempt < attempts)
73
+ await sleep(retryAfter);
74
+ }
75
+ throw new Error(`Upload to ${url.origin} failed after ${attempts} attempts: ${last}`);
76
+ }
@@ -6,16 +6,16 @@ The policy binds from `1.0.0`, the first stable release. Prereleases of later ve
6
6
 
7
7
  ## What stays stable in 1.x
8
8
 
9
- | Area | Stable | Not covered |
10
- | ---------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------- |
11
- | **Configuration file** | Every documented setting of `version: 1` keeps its name, meaning and accepted values. New settings are optional with a default that keeps existing behaviour. | Undocumented settings. Validation may reject a value that never worked. |
12
- | **Inventory file** | The documented system, component, library and product fields, including `note`, and the library line syntax. Text fields are single-line: control characters are rejected. | The generated `library:` and `sbom:` component IDs. |
13
- | **Command line** | Command names, documented flags, and exit codes: 0 success, 1 error, 2 completed with a degraded or failed part. | The wording of human-readable messages and help text. |
14
- | **JSON output** | Existing fields of commands that print JSON keep their names and types. Fields may be added. | Field order; fields documented as diagnostic. |
15
- | **Database** | A database written by any 1.x version, or by the earlier alpha, opens in every later 1.x version; `scan` or `start` migrates it. Unchanged findings keep revision and acknowledgement. | Downgrading: restore a backup taken before the upgrade. Reading the SQLite file directly. |
16
- | **Library API** | The names listed in `scripts/public-api.json` and the type names in `scripts/public-types.json` (both in the source repository), with their published TypeScript declarations. | Anything marked `@internal`, anything imported from a path other than the package root, and the exact text of error messages. |
17
- | **Notifications** | The `Finding:`, `Delivery:`, `Where to look:` and `Affected item:` lines keep their labels. | Other wording and line order. Do not parse messages; use `findings` or `explain` for data. |
18
- | **Runtime** | Node.js 24.10 or newer on Linux and macOS. The minimum Node.js version rises only in a minor release, and only to a version that has been in long-term support for six months. | Windows: the private-file permission checks are skipped there and it is not tested. |
9
+ | Area | Stable | Not covered |
10
+ | ---------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------- |
11
+ | **Configuration file** | Every documented setting of `version: 1` keeps its name, meaning and accepted values. New settings are optional with a default that keeps existing behaviour. | Undocumented settings. Validation may reject a value that never worked. |
12
+ | **Inventory file** | The documented system, component, library and product fields, including `note`, and the library line syntax. Text fields are single-line: control characters are rejected. | The generated `library:` and `sbom:` component IDs. Which packages `security-watch sbom` finds, which may grow as its readers improve. |
13
+ | **Command line** | Command names, documented flags, and exit codes: 0 success, 1 error, 2 completed with a degraded or failed part. | The wording of human-readable messages and help text. |
14
+ | **JSON output** | Existing fields of commands that print JSON keep their names and types. Fields may be added. | Field order; fields documented as diagnostic. |
15
+ | **Database** | A database written by any 1.x version, or by the earlier alpha, opens in every later 1.x version; `scan` or `start` migrates it. Unchanged findings keep revision and acknowledgement. | Downgrading: restore a backup taken before the upgrade. Reading the SQLite file directly. |
16
+ | **Library API** | The names listed in `scripts/public-api.json` and the type names in `scripts/public-types.json` (both in the source repository), with their published TypeScript declarations. | Anything marked `@internal`, anything imported from a path other than the package root, and the exact text of error messages. |
17
+ | **Notifications** | The `Finding:`, `Delivery:`, `Where to look:` and `Affected item:` lines keep their labels. | Other wording and line order. Do not parse messages; use `findings` or `explain` for data. |
18
+ | **Runtime** | Node.js 24.10 or newer on Linux and macOS. The minimum Node.js version rises only in a minor release, and only to a version that has been in long-term support for six months. | Windows: the private-file permission checks are skipped there and it is not tested. |
19
19
 
20
20
  ## Security decisions are not frozen
21
21
 
@@ -138,6 +138,8 @@ Replace the example names and timestamp with verified deployment information. `u
138
138
  | Product `name`, `version`, `keywords` | Product context and matching terms; not a supported vendor version/backport decision |
139
139
  | System `keywords` | Explicit terms for news matching |
140
140
 
141
+ An inventory may also set `sbom_directory: ./sboms` (relative to the inventory file) above `systems`. Every `.json` SBOM in that folder becomes one more system, read again at every scan; `systems` may then be empty. The SBOM's creation time is that system's `updated_at`. See [the SBOM folder](sbom.md#the-sbom-folder) and [Watch a project from its dependency files](sbom.md).
142
+
141
143
  ### Notes: telling readers where to look
142
144
 
143
145
  A finding names a system and a library. The person who receives the alert usually needs one more fact: where that library is used and who can check it. Put that in a `note`:
@@ -476,6 +478,21 @@ This is optional; `init --heartbeat` adds the default environment-variable name
476
478
 
477
479
  Intervals may be 30–3,600 seconds. Requests have a five-second timeout, no redirects and a 4 KiB response cap. Public HTTPS is required unless `allow_private_endpoint: true` explicitly permits a trusted private/local HTTP(S) destination; plain HTTP to an address that is not private or local is refused even then. The URL is not included in recorded status or errors. `status` exposes the last external-heartbeat outcome independently of the local worker heartbeat. An external ping cannot itself notify you that it was never sent; the receiving service must detect that absence.
478
480
 
481
+ ## SBOM receiver
482
+
483
+ ```yaml
484
+ intake:
485
+ listen: 127.0.0.1:8787 # HOST:PORT; [::]:8787 for IPv6
486
+ tokens: # default: one token in SECURITY_WATCH_INTAKE_TOKEN for every system
487
+ - token_env: SECURITY_WATCH_INTAKE_TOKEN
488
+ systems: ['*'] # IDs, or prefixes ending in *
489
+ tls_cert_file: ./tls/cert.pem # both or neither; relative to this file
490
+ tls_key_file: ./tls/key.pem
491
+ allow_plain_http: false # required to listen beyond loopback without TLS
492
+ ```
493
+
494
+ With `intake` set, `start` accepts SBOM uploads from CI into the inventory's `sbom_directory`, and `security-watch intake` runs the receiver alone. The inventory must set `sbom_directory`. Tokens are read from the named environment variables and must be at least 32 characters. See [Receive SBOMs from pipelines](sbom.md#receive-sboms-from-pipelines).
495
+
479
496
  ## Retention and verified backups
480
497
 
481
498
  Every scan compares every stored news story with the inventory. Without retention the stored news grows by roughly 5,000 stories a year, and with a large inventory (thousands of components) that comparison takes a minute or more per scan after a year. Enable retention for news when the inventory is large.
@@ -575,7 +592,11 @@ systems:
575
592
  LANGFLOW_WEBHOOK_AUTH_ENABLE: true
576
593
  ```
577
594
 
578
- `sbom` imports a local CycloneDX JSON 1.4, 1.5 or 1.6 file. The importer is bounded to
595
+ `sbom` imports a local CycloneDX JSON 1.4, 1.5 or 1.6 file, or an SPDX JSON 2.2 or 2.3 file (including
596
+ GitHub's `{"sbom": ...}` API response). To have every SBOM in a folder become a system of its own, set
597
+ `sbom_directory` at the top of the inventory instead; see [the SBOM folder](sbom.md#the-sbom-folder).
598
+ `security-watch sbom` writes such a file from a project's lockfiles ([guide](sbom.md)). A component's
599
+ CycloneDX `evidence.occurrences` locations become its note (`found in package-lock.json`). The importer is bounded to
579
600
  20 MiB, 20,000 components and 32 nesting levels. Supported package URLs determine package
580
601
  identity and exact version; conflicting versions, duplicate references and invalid SHA-256
581
602
  hashes fail import. The same package listed twice without a reference of its own (nested under
@@ -589,7 +610,10 @@ relationships from an unknown source are retained with a warning. A declared Cyc
589
610
  root retains its outgoing edges without being treated as a missing package. Duplicate or malformed
590
611
  references fail import. Dependency edges are declarations, not verified reachability or
591
612
  transitive affectedness. Explicit `library`, `application`, `container` and machine-learning-model
592
- component types populate artifact kind; names do not establish MCP/plugin trust.
613
+ component types populate artifact kind; names do not establish MCP/plugin trust. In SPDX, a package
614
+ the document describes is the system, not a dependency; `DEPENDS_ON` and `DEPENDENCY_OF`
615
+ relationships become dependency edges, and a version range in `versionInfo` (GitHub writes manifest
616
+ ranges there) imports the package by name only, with a warning.
593
617
  References, scripts, vulnerabilities and remote artifacts in the SBOM are never fetched or
594
618
  executed. Unsupported ecosystems and missing package URLs are reported as incomplete
595
619
  inventory, never silently treated as safe. SBOM timestamps do not establish deployment freshness.
@@ -604,7 +628,7 @@ security-watch inventory-drift --config ./security-watch.yaml
604
628
 
605
629
  The import command creates a new private report file (never overwrites); warnings give exit
606
630
  code 2. `loadInventory` imports via `sbom` and scans emit monitoring-health findings for import
607
- warnings. Exported APIs include `importCycloneDx`, `compareInventories` and `refreshCoverage`.
631
+ warnings. Exported APIs include `importCycloneDx`, `importSbom`, `generateSbom`, `compareInventories` and `refreshCoverage`.
608
632
 
609
633
  Each completed scan compares the inventory with the previous completed scan. Drift reports
610
634
  additions, removals and changes in identity, version, digest, origin, provenance, environment,
@@ -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.0.0`, an in-memory database,
7
+ This example uses `@shieldaai/security-watch@1.1.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.0.0
19
+ npm install --ignore-scripts --save-exact @shieldaai/security-watch@1.1.0
20
20
  ```
21
21
 
22
22
  ## Run the fictional inventory