@shieldaai/security-watch 1.2.0 → 1.2.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 +16 -0
- package/README.md +4 -4
- package/dist/cli.js +6 -3
- package/dist/engine.js +31 -2
- package/dist/heartbeat.js +4 -1
- package/dist/inventory.js +1 -1
- package/dist/manifests.js +23 -13
- package/dist/matching.js +6 -0
- package/dist/operations.js +2 -1
- package/dist/store.js +24 -8
- package/docs/offline-advisory-preview.md +2 -2
- package/docs/sbom.md +4 -4
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,22 @@
|
|
|
2
2
|
|
|
3
3
|
Versions follow [semantic versioning](https://semver.org/). What counts as a compatible change is defined in the [compatibility policy](docs/compatibility.md).
|
|
4
4
|
|
|
5
|
+
## 1.2.1
|
|
6
|
+
|
|
7
|
+
Fixes from an edge-case review: alerts sent twice for analysed news, packages missed in Python and Go projects, and a worker that paused when the clock stepped back. No configuration change. To be published under the default `latest` tag; the GitHub Action is used as `uses: ShieldaAI/security-watch@v1.2.1`.
|
|
8
|
+
|
|
9
|
+
### Fixed
|
|
10
|
+
|
|
11
|
+
- **Alerts sent again for analysed news.** With models on, a news finding the model had confirmed was sent again after any change to its analysis basis, such as one unrelated package added to the system: the scan saved it without its analysis first, and the same conclusion after analysis was a new revision. A known-exploited or critical one was sent twice more. Its queued alerts are now held until the analysis is redone and sent only if the conclusion changes or was not yet delivered; routing that does not depend on the model (an override, a source severity) still applies at once.
|
|
12
|
+
- **A shorter suppression now releases the alert.** `suppress --hours 720` followed by `suppress --hours 1` kept the queued alert waiting 30 days while `explain` said it was not suppressed.
|
|
13
|
+
- **Clock set back.** When the system clock stepped back (an NTP correction), the worker stopped scanning, writing its heartbeat, pinging the external monitor and running maintenance until the clock reached the old time again. Slack retry times and digest times are still wall-clock times.
|
|
14
|
+
- **`pyproject.toml` beside a requirements file.** A folder with `pyproject.toml` and only `requirements-dev.txt` lost the pyproject's packages, so their advisories were missed. A requirements file no longer hides the pyproject; it adds what the requirements files lack. A real lockfile still does.
|
|
15
|
+
- **go.mod `replace` with a version.** `replace golang.org/x/net v0.1.0 => golang.org/x/net v0.18.0` was applied to every version, so a required v0.17.0 was reported as the fixed v0.18.0. A replace that names a version now applies to that version only.
|
|
16
|
+
- **News naming a Python package by its published spelling** (`ruamel.yaml`, `typing_extensions`) now matches the package, which is kept in its normalised form (`ruamel-yaml`).
|
|
17
|
+
- Git and URL entries in an npm v1 lockfile, and Git, path and URL packages in `pdm.lock`, are no longer watched as registry packages of the same name.
|
|
18
|
+
- A Yarn Berry resolution with archive parameters (`lodash@npm:4.17.20::__archiveUrl=…`) keeps its version.
|
|
19
|
+
- An inventory `lockfile:` that starts with a byte order mark is read instead of failing the inventory.
|
|
20
|
+
|
|
5
21
|
## 1.2.0
|
|
6
22
|
|
|
7
23
|
News that no advisory has scored yet gets a level from what the articles say, and findings can show EPSS. Existing configurations and inventories work unchanged. To be published under the default `latest` tag; the GitHub Action is used as `uses: ShieldaAI/security-watch@v1.2.0`.
|
package/README.md
CHANGED
|
@@ -86,7 +86,7 @@ intake:
|
|
|
86
86
|
|
|
87
87
|
```yaml
|
|
88
88
|
# GitHub Actions: makes the SBOM and sends it; the job fails if the monitor refuses it
|
|
89
|
-
- uses: ShieldaAI/security-watch@v1.2.
|
|
89
|
+
- uses: ShieldaAI/security-watch@v1.2.1
|
|
90
90
|
with:
|
|
91
91
|
system-id: my-app
|
|
92
92
|
owner: Dana, platform team
|
|
@@ -96,7 +96,7 @@ intake:
|
|
|
96
96
|
|
|
97
97
|
```sh
|
|
98
98
|
# Any other pipeline with Node.js 24 and SECURITY_WATCH_INTAKE_TOKEN set
|
|
99
|
-
npx --yes @shieldaai/security-watch@1.2.
|
|
99
|
+
npx --yes @shieldaai/security-watch@1.2.1 sbom --system-id my-app --upload https://watch.example.com:8787
|
|
100
100
|
```
|
|
101
101
|
|
|
102
102
|
[Watch a project from its dependency files](docs/sbom.md) covers the files that are read, GitLab CI, the receiver (tokens limited to some systems, TLS, Docker), other ways to deliver SBOMs, and SBOMs from Trivy, Syft, cdxgen or GitHub's dependency graph, which are accepted as they are.
|
|
@@ -130,7 +130,7 @@ If your list contains libraries that are not npm packages (Python, PHP, Java, Go
|
|
|
130
130
|
|
|
131
131
|
To try it with no network access and fictional data first, follow the [offline advisory preview](docs/offline-advisory-preview.md). The rest of this page covers the options in detail.
|
|
132
132
|
|
|
133
|
-
**Version 1.2.
|
|
133
|
+
**Version 1.2.1.** This is `@shieldaai/security-watch` 1.2.1, a patch release of 1.2.0, the minor release of the first stable version (1.0.0) that reads CVSS scores, vendor ratings and exploitation reports from news for findings that no advisory has scored yet, and can show FIRST's EPSS for each CVE; 1.1 added SBOM generation from dependency files, an SBOM folder for pipelines, SPDX import and a GitHub Action. It is published under the default `latest` tag and has no independent security audit. Read the [coverage and security limits](SECURITY.md) before relying on it, the [compatibility policy](docs/compatibility.md) for what stays stable, and the [changelog](CHANGELOG.md) for what changed.
|
|
134
134
|
|
|
135
135
|
Related projects: [Agent Guard](https://github.com/ShieldaAI/agent-guard) for tool permissions and approvals, and [SafeCall Node](https://github.com/GuardianMesh/llm-safecall-node) or [SafeCall Python](https://github.com/GuardianMesh/llm-safecall) for model response validation. The [package selection guide](https://github.com/ShieldaAI/agent-guard/blob/main/docs/package-guide.md) explains how they fit together.
|
|
136
136
|
|
|
@@ -170,7 +170,7 @@ To build and install from a source checkout:
|
|
|
170
170
|
npm ci
|
|
171
171
|
npm run check
|
|
172
172
|
npm pack
|
|
173
|
-
npm install --global ./shieldaai-security-watch-1.2.
|
|
173
|
+
npm install --global ./shieldaai-security-watch-1.2.1.tgz
|
|
174
174
|
```
|
|
175
175
|
|
|
176
176
|
Choose one setup command below. To start from your own code, use `init --project` as in [step 2](#get-started-in-four-steps). For a fictional example with AI disabled:
|
package/dist/cli.js
CHANGED
|
@@ -1324,10 +1324,13 @@ async function main() {
|
|
|
1324
1324
|
try {
|
|
1325
1325
|
firstScanNotice(config, store, false);
|
|
1326
1326
|
while (!stop) {
|
|
1327
|
-
|
|
1327
|
+
const tick = Date.now();
|
|
1328
|
+
// A clock set back must not pause the worker until it reaches the old time again.
|
|
1329
|
+
if (tick - lastHeartbeat >= 15_000 || tick < lastHeartbeat)
|
|
1328
1330
|
heartbeat('running');
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
+
const interval = config.poll_interval_minutes * 60_000;
|
|
1332
|
+
if (!scanning && !maintaining && (tick >= nextScan || nextScan - tick > interval)) {
|
|
1333
|
+
nextScan = tick + interval;
|
|
1331
1334
|
scanning = (async () => {
|
|
1332
1335
|
try {
|
|
1333
1336
|
const report = await runScan({
|
package/dist/engine.js
CHANGED
|
@@ -235,6 +235,35 @@ export async function runScan(options) {
|
|
|
235
235
|
}
|
|
236
236
|
return canRetainPriority(previous, finding) ? { ...finding, priority: previous.priority } : finding;
|
|
237
237
|
};
|
|
238
|
+
// Before analysis, a news finding whose basis changed loses its previous analysis. Saving it so
|
|
239
|
+
// would make a new revision, and the same conclusion after analysis would be sent again.
|
|
240
|
+
const reconcile = (finding, basisHash) => {
|
|
241
|
+
const current = interim(finding, basisHash);
|
|
242
|
+
const previous = previousById.get(finding.id);
|
|
243
|
+
if (!config.models.enabled ||
|
|
244
|
+
!previous?.ai ||
|
|
245
|
+
previous.active === false ||
|
|
246
|
+
current.ai ||
|
|
247
|
+
!(current.news_candidate || current.news_only) ||
|
|
248
|
+
current.applicability === 'not_affected' ||
|
|
249
|
+
current.withdrawn)
|
|
250
|
+
return persist(current);
|
|
251
|
+
const decision = decide(current, config);
|
|
252
|
+
// Its routing waits for the model: hold its queued notifications, so that an old conclusion
|
|
253
|
+
// cannot escape meanwhile, and send them if analysis confirms it.
|
|
254
|
+
if (decision.action === 'record')
|
|
255
|
+
return store.holdPending(finding.id);
|
|
256
|
+
// Routing that does not depend on the model (an override, a source severity) is applied at
|
|
257
|
+
// once; the previous analysis is shown until it is redone.
|
|
258
|
+
const kept = {
|
|
259
|
+
...current,
|
|
260
|
+
...(previous.applicability === 'unknown' ? { applicability: 'unknown' } : {}),
|
|
261
|
+
...(previous.relevance ? { relevance: previous.relevance } : {}),
|
|
262
|
+
...(previous.news_analysis ? { news_analysis: previous.news_analysis } : {}),
|
|
263
|
+
ai: previous.ai,
|
|
264
|
+
};
|
|
265
|
+
persist(decide(kept, config).action === decision.action ? kept : current);
|
|
266
|
+
};
|
|
238
267
|
const cached = store.evidence();
|
|
239
268
|
if (!options.fixture && previousById.size) {
|
|
240
269
|
// Apply known inventory changes before yielding to network I/O. The worker can deliver concurrently.
|
|
@@ -247,7 +276,7 @@ export async function runScan(options) {
|
|
|
247
276
|
const ids = new Set(current.map((a) => a.id));
|
|
248
277
|
for (const finding of current)
|
|
249
278
|
if (previousById.has(finding.id))
|
|
250
|
-
|
|
279
|
+
reconcile(finding, basis(finding, cachedById, collectedAt));
|
|
251
280
|
for (const previous of previousById.values())
|
|
252
281
|
if (previous.category !== 'health' && previous.active !== false && !ids.has(previous.id))
|
|
253
282
|
retire(previous);
|
|
@@ -315,7 +344,7 @@ export async function runScan(options) {
|
|
|
315
344
|
}
|
|
316
345
|
// Reconcile every finding before delivery, including exclusions, withdrawals and removals.
|
|
317
346
|
// Otherwise an old pending alert could be sent while unrelated AI analysis is running.
|
|
318
|
-
findings.forEach((finding) =>
|
|
347
|
+
findings.forEach((finding) => reconcile(finding, bases.get(finding.id)));
|
|
319
348
|
const currentIds = new Set(findings.map((a) => a.id));
|
|
320
349
|
for (const previous of store.findings())
|
|
321
350
|
if (previous.category !== 'health' && previous.active !== false && !currentIds.has(previous.id))
|
package/dist/heartbeat.js
CHANGED
|
@@ -5,7 +5,10 @@ export class HeartbeatMonitor {
|
|
|
5
5
|
nextAt = 0;
|
|
6
6
|
async tick(store, config, http, now = Date.now(), signal) {
|
|
7
7
|
const settings = config.monitoring;
|
|
8
|
-
if (!settings || signal?.aborted
|
|
8
|
+
if (!settings || signal?.aborted)
|
|
9
|
+
return undefined;
|
|
10
|
+
// A next time further away than one interval means the clock was set back.
|
|
11
|
+
if (now < this.nextAt && this.nextAt - now <= settings.interval_seconds * 1000)
|
|
9
12
|
return undefined;
|
|
10
13
|
this.nextAt = now + settings.interval_seconds * 1000;
|
|
11
14
|
let lastSuccess = null;
|
package/dist/inventory.js
CHANGED
|
@@ -187,7 +187,7 @@ function record(value) {
|
|
|
187
187
|
}
|
|
188
188
|
/** Imports metadata only. No install scripts or package manager commands are executed. */
|
|
189
189
|
function importLockfile(path) {
|
|
190
|
-
const lock = JSON.parse(readBounded(path, 20 * 1024 * 1024));
|
|
190
|
+
const lock = JSON.parse(readBounded(path, 20 * 1024 * 1024).replace(/^\uFEFF/, ''));
|
|
191
191
|
if (!record(lock) || (lock.lockfileVersion !== 2 && lock.lockfileVersion !== 3) || !record(lock.packages)) {
|
|
192
192
|
throw new Error(`Expected package-lock v2 or v3 with a packages map: ${path}`);
|
|
193
193
|
}
|
package/dist/manifests.js
CHANGED
|
@@ -93,14 +93,12 @@ const npmPackageLock = (text) => {
|
|
|
93
93
|
if (!record(value))
|
|
94
94
|
continue;
|
|
95
95
|
const version = string(value.version) ? value.version : undefined;
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
}
|
|
100
|
-
else if (version && /^(?:file|link|git|git\+|https?):/.test(version))
|
|
96
|
+
// `npm:` aliases, and Git (`github:user/repo#sha`), file and URL sources, as in package.json.
|
|
97
|
+
const target = version === undefined ? { name, range: undefined } : npmSpecifier(name, version);
|
|
98
|
+
if (!target)
|
|
101
99
|
skipped++;
|
|
102
100
|
else
|
|
103
|
-
packages.push(found('npm', name,
|
|
101
|
+
packages.push(found('npm', target.name, target.range, value.dev === true));
|
|
104
102
|
visit(value.dependencies, depth + 1);
|
|
105
103
|
}
|
|
106
104
|
};
|
|
@@ -120,8 +118,9 @@ const yarnLock = (text) => {
|
|
|
120
118
|
if (fields.resolution !== undefined) {
|
|
121
119
|
const resolution = unquote(fields.resolution);
|
|
122
120
|
const match = /^((?:@[^@/]+\/)?[^@]+)@npm:(.+)$/.exec(resolution);
|
|
121
|
+
// `lodash@npm:4.17.21::__archiveUrl=…`: the parameters after `::` are not the version.
|
|
123
122
|
if (match)
|
|
124
|
-
packages.push(found('npm', match[1], match[2]));
|
|
123
|
+
packages.push(found('npm', match[1], match[2].split('::')[0]));
|
|
125
124
|
else
|
|
126
125
|
skipped++;
|
|
127
126
|
return;
|
|
@@ -319,7 +318,8 @@ const poetryLock = (text) => {
|
|
|
319
318
|
if (!string(table.name))
|
|
320
319
|
continue;
|
|
321
320
|
const source = table['source.type'];
|
|
322
|
-
|
|
321
|
+
// pdm.lock writes these sources as keys of the package itself.
|
|
322
|
+
if ((source && source !== 'legacy') || table.git || table.path || table.url) {
|
|
323
323
|
skipped++;
|
|
324
324
|
continue;
|
|
325
325
|
}
|
|
@@ -411,13 +411,14 @@ const pyprojectToml = (text) => {
|
|
|
411
411
|
// ------------------------------------------------------------------------------------- Go and Rust
|
|
412
412
|
const goMod = (text) => {
|
|
413
413
|
const required = [];
|
|
414
|
+
// Keyed by module, or by module and version: `replace a v1.0.0 => b v1.1.0` applies to a v1.0.0 only.
|
|
414
415
|
const replaced = new Map();
|
|
415
416
|
let block;
|
|
416
417
|
const replace = (line) => {
|
|
417
|
-
const match = /^(\S+)(?:\s
|
|
418
|
+
const match = /^(\S+)(?:\s+(\S+))?\s*=>\s*(\S+)(?:\s+(\S+))?$/.exec(line);
|
|
418
419
|
if (!match)
|
|
419
420
|
return;
|
|
420
|
-
replaced.set(match[1], /^(?:\.|\/)/.test(match[
|
|
421
|
+
replaced.set(match[2] ? `${match[1]} ${match[2]}` : match[1], /^(?:\.|\/)/.test(match[3]) || !match[4] ? null : { name: match[3], version: match[4] });
|
|
421
422
|
};
|
|
422
423
|
for (const raw of text.split(/\r?\n/)) {
|
|
423
424
|
const line = raw.replace(/\/\/.*$/, '').trim();
|
|
@@ -451,7 +452,8 @@ const goMod = (text) => {
|
|
|
451
452
|
const packages = [];
|
|
452
453
|
let skipped = 0;
|
|
453
454
|
for (const module of required) {
|
|
454
|
-
const
|
|
455
|
+
const exact = `${module.name} ${module.version}`;
|
|
456
|
+
const replacement = replaced.has(exact) ? replaced.get(exact) : replaced.get(module.name);
|
|
455
457
|
if (replacement === null)
|
|
456
458
|
skipped++;
|
|
457
459
|
else
|
|
@@ -948,6 +950,11 @@ function discover(root, warnings) {
|
|
|
948
950
|
const locked = new Set(candidates
|
|
949
951
|
.filter((file) => file.kind === 'lockfile')
|
|
950
952
|
.map((file) => `${dirname(file.absolute)}\0${file.ecosystem}`));
|
|
953
|
+
// A requirements file often lists only some packages (requirements-dev.txt), so it does not hide
|
|
954
|
+
// the pyproject.toml beside it: that is read like a workspace member, for what the file lacks.
|
|
955
|
+
const resolved = new Set(candidates
|
|
956
|
+
.filter((file) => file.kind === 'lockfile' && file.read !== requirementsTxt)
|
|
957
|
+
.map((file) => `${dirname(file.absolute)}\0${file.ecosystem}`));
|
|
951
958
|
const coveredBy = (file) => {
|
|
952
959
|
for (let folder = dirname(dirname(file.absolute)); folder.length >= root.length; folder = dirname(folder)) {
|
|
953
960
|
if (locked.has(`${folder}\0${file.ecosystem}`))
|
|
@@ -958,8 +965,11 @@ function discover(root, warnings) {
|
|
|
958
965
|
return false;
|
|
959
966
|
};
|
|
960
967
|
return candidates
|
|
961
|
-
.filter((file) => file.kind === 'lockfile' || !
|
|
962
|
-
.map((file) =>
|
|
968
|
+
.filter((file) => file.kind === 'lockfile' || !resolved.has(`${dirname(file.absolute)}\0${file.ecosystem}`))
|
|
969
|
+
.map((file) => file.kind === 'manifest' &&
|
|
970
|
+
(coveredBy(file) || locked.has(`${dirname(file.absolute)}\0${file.ecosystem}`))
|
|
971
|
+
? { ...file, workspace: true }
|
|
972
|
+
: file)
|
|
963
973
|
.sort((a, b) => Number(a.kind === 'manifest') - Number(b.kind === 'manifest'));
|
|
964
974
|
}
|
|
965
975
|
// ---------------------------------------------------------------------------------------- Package URLs
|
package/dist/matching.js
CHANGED
|
@@ -229,6 +229,12 @@ export function packageMentioned(text, component) {
|
|
|
229
229
|
const artifact = mavenArtifact(component);
|
|
230
230
|
if (artifact && packageMentioned(text, { ecosystem: 'Maven', name: artifact }))
|
|
231
231
|
return true;
|
|
232
|
+
// PyPI names are kept in their normalised form (`ruamel-yaml`); prose writes the published one,
|
|
233
|
+
// `ruamel.yaml` or `typing_extensions`.
|
|
234
|
+
if (component.ecosystem === 'PyPI' && name.includes('-'))
|
|
235
|
+
for (const separator of ['.', '_'])
|
|
236
|
+
if (packageMentioned(text, { ecosystem: 'PyPI', name: name.replaceAll('-', separator) }))
|
|
237
|
+
return true;
|
|
232
238
|
// One story is compared with every component, and a story that cites many advisories is
|
|
233
239
|
// compared again for each of them: remember the answers for the texts seen last.
|
|
234
240
|
let seen = recent.get(text);
|
package/dist/operations.js
CHANGED
|
@@ -56,7 +56,8 @@ export class MaintenanceScheduler {
|
|
|
56
56
|
attempted +
|
|
57
57
|
(previous.ok ? settings.interval_hours : Math.min(settings.interval_hours, 1)) * 3_600_000;
|
|
58
58
|
}
|
|
59
|
-
|
|
59
|
+
// A next time further away than one interval means the clock was set back.
|
|
60
|
+
if (now < this.nextAt && this.nextAt - now <= settings.interval_hours * 3_600_000)
|
|
60
61
|
return undefined;
|
|
61
62
|
this.nextAt = now + Math.min(settings.interval_hours, 1) * 3_600_000;
|
|
62
63
|
const report = {
|
package/dist/store.js
CHANGED
|
@@ -7,6 +7,9 @@ import { decide } from './assessment.js';
|
|
|
7
7
|
import { aggregatePilotReport, validatePilotWindow, PilotReportError, } from './pilot-report.js';
|
|
8
8
|
import { validateRetentionPolicy, } from './maintenance.js';
|
|
9
9
|
export const SCHEMA_VERSION = 7;
|
|
10
|
+
/** A queued notification held back while its finding waits for a new analysis. */
|
|
11
|
+
const HELD = 'Held for reassessment';
|
|
12
|
+
const OPEN = `(status='pending' OR (status='failed' AND last_error='${HELD}'))`;
|
|
10
13
|
function verifyFile(path) {
|
|
11
14
|
// Closing any descriptor for a live SQLite inode releases this process's POSIX locks.
|
|
12
15
|
// Inspect existing files without opening them, including when another Store is already open.
|
|
@@ -424,14 +427,14 @@ export class Store {
|
|
|
424
427
|
.run(assessment.id, revision, decision.review, JSON.stringify(references), now);
|
|
425
428
|
if (changed)
|
|
426
429
|
this.#db
|
|
427
|
-
.prepare(
|
|
430
|
+
.prepare(`UPDATE notifications SET status='failed',last_error='Superseded by a newer assessment' WHERE finding_id=? AND ${OPEN}`)
|
|
428
431
|
.run(assessment.id);
|
|
429
432
|
// A changed routing configuration can stop a pending delivery without creating a duplicate in retained channels.
|
|
430
433
|
const channels = decision.action === 'record' ? [] : [...new Set(decision.channels)];
|
|
431
434
|
for (const channel of ['slack', 'email'])
|
|
432
435
|
if (!channels.includes(channel)) {
|
|
433
436
|
this.#db
|
|
434
|
-
.prepare(
|
|
437
|
+
.prepare(`UPDATE notifications SET status='failed',last_error='Notification policy no longer selects this destination' WHERE finding_id=? AND channel=? AND ${OPEN}`)
|
|
435
438
|
.run(assessment.id, channel);
|
|
436
439
|
}
|
|
437
440
|
const payload = JSON.stringify({ assessment, reason: decision.reason, mode: decision.action });
|
|
@@ -449,8 +452,9 @@ export class Store {
|
|
|
449
452
|
this.#db
|
|
450
453
|
.prepare(`INSERT INTO notifications(id,finding_id,revision,channel,payload,status,available_at)
|
|
451
454
|
VALUES(?,?,?,?,?,'pending',?) ON CONFLICT(finding_id,revision,channel) DO UPDATE SET
|
|
452
|
-
payload=excluded.payload,status='pending',available_at=
|
|
453
|
-
|
|
455
|
+
payload=excluded.payload,status='pending',last_error=NULL,available_at=CASE WHEN notifications.last_error='${HELD}'
|
|
456
|
+
THEN notifications.available_at ELSE MAX(notifications.available_at,excluded.available_at) END
|
|
457
|
+
WHERE notifications.status='failed' AND notifications.last_error IN ('Notification policy no longer selects this destination','${HELD}')`)
|
|
454
458
|
.run(randomUUID(), assessment.id, revision, channel, payload, availableAt);
|
|
455
459
|
});
|
|
456
460
|
}
|
|
@@ -617,7 +621,7 @@ export class Store {
|
|
|
617
621
|
.prepare(`SELECT
|
|
618
622
|
SUM(CASE WHEN n.status='failed' AND COALESCE(n.last_error,'') NOT IN (
|
|
619
623
|
'Notification policy no longer selects this destination', 'Notification urgency changed under the current policy',
|
|
620
|
-
'Finding is no longer active', 'Superseded by a newer assessment', 'Finding acknowledged before delivery') THEN 1 ELSE 0 END) AS failed,
|
|
624
|
+
'Finding is no longer active', 'Superseded by a newer assessment', 'Finding acknowledged before delivery', '${HELD}') THEN 1 ELSE 0 END) AS failed,
|
|
621
625
|
SUM(CASE WHEN n.status='unknown' THEN 1 ELSE 0 END) AS unknown,
|
|
622
626
|
SUM(CASE WHEN n.status='pending' AND MAX(n.available_at,CASE WHEN n.channel='slack' THEN ? ELSE 0 END)<=? THEN 1 ELSE 0 END) AS overdue_pending
|
|
623
627
|
FROM notifications n JOIN findings f ON f.id=n.finding_id
|
|
@@ -740,6 +744,16 @@ export class Store {
|
|
|
740
744
|
.run(now, id);
|
|
741
745
|
});
|
|
742
746
|
}
|
|
747
|
+
/**
|
|
748
|
+
* Keep a finding's queued notifications from being sent until it is saved again. Saving the same
|
|
749
|
+
* revision queues them again with their schedule; a new revision supersedes them.
|
|
750
|
+
* @internal Used by the scan worker; not part of the public API.
|
|
751
|
+
*/
|
|
752
|
+
holdPending(findingId) {
|
|
753
|
+
this.#db
|
|
754
|
+
.prepare(`UPDATE notifications SET status='failed',last_error=? WHERE finding_id=? AND status='pending'`)
|
|
755
|
+
.run(HELD, findingId);
|
|
756
|
+
}
|
|
743
757
|
/** @internal Used by the scan and delivery workers; not part of the public API. */
|
|
744
758
|
recoverSending(now = Date.now()) {
|
|
745
759
|
this.#db
|
|
@@ -782,13 +796,15 @@ export class Store {
|
|
|
782
796
|
if (!Number.isSafeInteger(until) || until <= Date.now() || !reason.trim())
|
|
783
797
|
throw new Error('Suppression needs a future expiry and a reason');
|
|
784
798
|
this.#transaction(() => {
|
|
799
|
+
// A delivery held until an earlier expiry follows the new one, also when it is shorter.
|
|
800
|
+
this.#db
|
|
801
|
+
.prepare(`UPDATE notifications SET available_at=MAX(?,CASE WHEN available_at=(SELECT suppressed_until FROM findings WHERE id=?)
|
|
802
|
+
THEN 0 ELSE available_at END) WHERE finding_id=? AND status='pending'`)
|
|
803
|
+
.run(until, id, id);
|
|
785
804
|
if (!this.#db
|
|
786
805
|
.prepare('UPDATE findings SET suppressed_until=?,suppression_reason=? WHERE id=?')
|
|
787
806
|
.run(until, reason.trim(), id).changes)
|
|
788
807
|
throw new Error('Finding not found');
|
|
789
|
-
this.#db
|
|
790
|
-
.prepare("UPDATE notifications SET available_at=MAX(available_at,?) WHERE finding_id=? AND status='pending'")
|
|
791
|
-
.run(until, id);
|
|
792
808
|
});
|
|
793
809
|
}
|
|
794
810
|
/** @internal Used by the scan and delivery workers; not part of the public API. */
|
|
@@ -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.2.
|
|
7
|
+
This example uses `@shieldaai/security-watch@1.2.1`, 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.2.
|
|
19
|
+
npm install --ignore-scripts --save-exact @shieldaai/security-watch@1.2.1
|
|
20
20
|
```
|
|
21
21
|
|
|
22
22
|
## Run the fictional inventory
|
package/docs/sbom.md
CHANGED
|
@@ -41,7 +41,7 @@ Then add the Slack address and start, as in the [README](../README.md#get-starte
|
|
|
41
41
|
|
|
42
42
|
The whole folder is searched, up to 12 levels deep. Folders that hold installed or generated copies (`node_modules`, `vendor`, `.venv`, `target`, `dist`, `build` and similar), test data (`fixtures`, `testdata`) and hidden folders are skipped. Symbolic links are not followed.
|
|
43
43
|
|
|
44
|
-
Where a lockfile and a manifest of the same ecosystem sit in one folder, only the lockfile is read. A manifest below a folder with a lockfile (a workspace member) adds only packages the lockfile does not already have. A package that is known only by name is watched by name: Security Watch can find advisories for it, but cannot say whether your version is affected. Commit lockfiles for exact versions.
|
|
44
|
+
Where a lockfile and a manifest of the same ecosystem sit in one folder, only the lockfile is read. A manifest below a folder with a lockfile (a workspace member) adds only packages the lockfile does not already have, as does a `pyproject.toml` beside `requirements*.txt` files, which often list only some packages. A package that is known only by name is watched by name: Security Watch can find advisories for it, but cannot say whether your version is affected. Commit lockfiles for exact versions.
|
|
45
45
|
|
|
46
46
|
Development-only dependencies are included and marked `scope: optional`, because a malicious build tool reaches your pipeline even if it never ships. Add `--production` to leave them out where the file says which they are: `package-lock.json`, `package.json`, `pnpm-lock.yaml` 5 and 6, `poetry.lock` (older `category = "dev"`), Poetry dev groups and PEP 735 dependency groups in `pyproject.toml`, `Pipfile.lock`, `composer.lock`, `composer.json`, `pubspec.lock`, `pubspec.yaml`, Maven `test` scope and Gradle test configurations.
|
|
47
47
|
|
|
@@ -127,7 +127,7 @@ jobs:
|
|
|
127
127
|
steps:
|
|
128
128
|
- uses: actions/checkout@v7
|
|
129
129
|
- id: sbom
|
|
130
|
-
uses: ShieldaAI/security-watch@v1.2.
|
|
130
|
+
uses: ShieldaAI/security-watch@v1.2.1
|
|
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.2.
|
|
146
|
+
- uses: ShieldaAI/security-watch@v1.2.1
|
|
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.2.
|
|
163
|
+
- npx --yes @shieldaai/security-watch@1.2.1 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
|
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shieldaai/security-watch",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.1",
|
|
4
4
|
"description": "Self-hosted security alerts for the software you run: reads your lockfiles (npm, Python, Go, Rust, Java and 7 more ecosystems) or any SBOM, watches new advisories and security news, and alerts you on Slack or email.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "Apache-2.0",
|