@shieldaai/security-watch 1.1.1 → 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 CHANGED
@@ -2,6 +2,42 @@
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
+
21
+ ## 1.2.0
22
+
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`.
24
+
25
+ ### Added
26
+
27
+ - **News signals.** For a news finding with no advisory severity (a zero-day without a CVE, a CVE that is reserved but not published, a vendor bulletin), the articles are read, without a model, for a CVSS score, a vendor's word rating, a report of exploitation, a denial of exploitation and public exploit code. A score or rating raises the finding's priority to at least its level; a report of exploitation raises it to critical, so with `urgent_unknown` (the default) the finding is sent at once as possibly critical. A statement counts only when it is tied to the finding's subject (its CVE or GHSA identifier, or the product or package it matched); negated and hedged statements and "zero-day" alone are not reports. Signals never lower, dismiss or mark a finding as known exploited, and stop being read once an advisory with a severity joins the finding. Alerts and digests have a `News signals:` line with the score, rating and subject only; `explain` shows the sentences they were read from. See [news signals](docs/configuration.md#news-signals).
28
+ - `policy.news_signals` (default `true`) turns news signals off.
29
+ - **EPSS, optional.** `sources.epss: true` looks up FIRST's EPSS for the CVEs of each current finding (including the CVE aliases of a GHSA-keyed library finding) and shows the highest, with its CVE, in alerts, digests, `explain`, `findings` and the scan report (`Assessment.epss`, exported type `EpssScore`). Only CVE identifiers are sent to `api.first.org`, in batches of 50, at most ten requests a scan, each score refreshed once a day. It is shown only: it changes no priority or decision, and a new daily score creates no finding revision, reopens no review and asks no model for a new analysis. A failed lookup is a notice, and findings keep the last score. See [EPSS](docs/configuration.md#epss).
30
+ - `Assessment.news_signals` and the exported types `NewsSignals` and `NewsStatement`.
31
+ - The configuration guide lists feeds that carry full articles with scores or exploitation reports (Rapid7, Tenable, The Register, Security Affairs, the Zero Day Initiative) and those that carry only headlines.
32
+
33
+ ### Changed
34
+
35
+ - **Louder for unscored news.** A news finding that an article reports as exploited, or that an article scores at 9.0 or above, now alerts at once where 1.1 put it in the digest. Measured on one week of real articles against a 20-product inventory: five findings were raised and one more immediate alert was sent (an actively exploited ScreenConnect plugin). The first scan after the upgrade reassesses news findings still in the news window, so a raised one is sent once.
36
+
37
+ ### Not verified
38
+
39
+ - Measured on 256 articles from one week of November 2026, labelled by the developer, not by an independent reviewer. The human-labelled pilot and a real Slack and email delivery remain open, as in 1.0.
40
+
5
41
  ## 1.1.1
6
42
 
7
43
  Fixes for feeds that were read wrongly and for two checks that trusted a name. No configuration change. To be published under the default `latest` tag; the GitHub Action is used as `uses: ShieldaAI/security-watch@v1.1.1`.
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.1.1
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.1.1 sbom --system-id my-app --upload https://watch.example.com:8787
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.
@@ -126,11 +126,11 @@ Everything after `#` on a library line is the note for that library. Keep the qu
126
126
 
127
127
  If your list contains libraries that are not npm packages (Python, PHP, Java, Go and so on), also open `watch/security-watch.yaml` and change `osv: false` to `osv: true`. That turns on the advisory database that covers those ecosystems; it receives the library names and versions you list. `init --project` does this for you when it finds such packages.
128
128
 
129
- **What gets sent.** With the starter settings you get an immediate message for a critical finding in a library, anything reported as actively exploited, a malicious package, and a possibly critical finding that still needs checking (a critical product or news finding is one of these until it is confirmed). High findings for a product or in the news usually arrive in the daily digest: a product match cannot be confirmed from version ranges, and news is sent at once only when a configured model confirms that it affects you. Less urgent findings that need a look arrive together in one daily digest. Everything else is recorded and shown by `security-watch findings`. The `policy` section of the configuration file changes these thresholds.
129
+ **What gets sent.** With the starter settings you get an immediate message for a critical finding in a library, anything reported as actively exploited, a malicious package, and a possibly critical finding that still needs checking (a critical product or news finding is one of these until it is confirmed). High findings for a product or in the news usually arrive in the daily digest: a product match cannot be confirmed from version ranges, and news is sent at once only when a configured model confirms that it affects you, or when an article reports that something on your list is being exploited. News that no advisory has scored yet takes the CVSS score or vendor rating an article states for it ([news signals](docs/configuration.md#news-signals)). Less urgent findings that need a look arrive together in one daily digest. Everything else is recorded and shown by `security-watch findings`. The `policy` section of the configuration file changes these thresholds.
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.1.1.** This is `@shieldaai/security-watch` 1.1.1, a patch release of 1.1.0, the minor release of the first stable version (1.0.0) that 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.
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.1.1.tgz
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/SECURITY.md CHANGED
@@ -28,7 +28,7 @@ Models can misinterpret sources, feeds can omit important facts, and advisories
28
28
 
29
29
  ## Data handling
30
30
 
31
- cve.now stack requests reveal deduplicated npm package names and exact versions through URL query parameters; lockfiles and system/deployment metadata are not uploaded. The Hacker News feed and article servers receive normal HTTP request metadata. Optional OSV requests reveal library ecosystem, package name and the installed version when supplied. Official vendor feeds receive normal request metadata. Other enabled advisory/feed servers receive normal request metadata, and GitHub may receive the configured API token.
31
+ cve.now stack requests reveal deduplicated npm package names and exact versions through URL query parameters; lockfiles and system/deployment metadata are not uploaded. The Hacker News feed and article servers receive normal HTTP request metadata. Optional OSV requests reveal library ecosystem, package name and the installed version when supplied. Official vendor feeds receive normal request metadata. With `sources.epss`, `api.first.org` receives the CVE identifiers of current findings, which together suggest which software you run. Other enabled advisory/feed servers receive normal request metadata, and GitHub may receive the configured API token.
32
32
 
33
33
  Each configured AI model defaults to the `minimal` disclosure profile. It receives selected relevant package ecosystem/name/version and product name/version, request-local IDs and inventory freshness status, plus target event and selected evidence fields/excerpts. Original inventory IDs, system name/owner, repository URLs, provenance, dependency graphs, verification declarations, remediation records and operator identities are excluded. `deployment-context` opts that specific model into environment/exposure/criticality and evidence-matching keywords, never other inventory metadata. The verifier applies its own profile independently. Allowed names and evidence text are not secret-redacted; do not place private content there unless the endpoint is approved to receive it. Full contracts and migration behavior are in [model disclosure configuration](docs/configuration.md#data-sent-to-models).
34
34
 
@@ -47,6 +47,7 @@ SQLite stores evidence, finding revisions, model analysis excerpts, caches, budg
47
47
  - Missing versions, unknown constraints and stale inventory remain uncertain. An empty advisory search does not establish that a system has no vulnerabilities.
48
48
  - CVSS v3.0/v3.1 calculation and supplied source labels/scores are supported. For OSV and GitHub records, CVSS v4 base vectors are scored with the pinned FIRST reference calculator; threat and environmental metrics are not applied, and unsupported vectors are counted and left unknown. See [CVSS v4 support](docs/cvss-v4-support.md).
49
49
  - A package named only in the prose of a news story is matched by rules, not by understanding: a name that is an English word must be named as a package, carry a release or be written as a name, a scoped package is matched by its full name only, and a Maven library by its coordinates or by an artifact name that is not an English word. Stories about such packages can be missed and, less often, an unrelated story can match; see the [matching rules](docs/configuration.md#sources-and-coverage). Advisories are matched by structured package claims and are not affected.
50
+ - News signals (stated CVSS scores, vendor ratings and exploitation reports read from articles for findings without an advisory severity) are text matching, not verification. An article can be wrong, out of date or written to mislead, and every feed you add is trusted to say what it means: a feed that falsely reports exploitation of a product you list raises that finding to critical and, with `urgent_unknown`, sends it at once. Signals only raise priority; they never lower, dismiss or mark a finding as known exploited, and statements that cannot be tied to the finding's subject in their sentence or clause are not read. A feed can still raise every product it names in a report of exploitation, one clause at a time; add only feeds you trust. See [news signals](docs/configuration.md#news-signals).
50
51
  - Source requests and model inputs have size and request limits. Incomplete collection or analysis reports degraded monitoring and requires review.
51
52
  - Recent cve.now entry collection, tracked/news-cited refreshes and exact npm stack queries do not establish exhaustive historical coverage for every product. The recent listing is read one week past the checkpoint; a record cve.now ingests more than a week after its publication date is found only through an exact npm match or a news citation. The Hacker News may block article access; the feed excerpt remains available for review without a confident impact conclusion.
52
53
  - CycloneDX JSON 1.4–1.6 and SPDX JSON 2.2/2.3 package metadata import, and SBOM generation from lockfiles and manifests (`security-watch sbom`), are supported, but not VEX ingestion, operating-system package matching, attestation verification or live deployment discovery. There is no authenticated web crawling, automatic remediation, distributed lock, multi-host worker or independent penetration-test certification.
@@ -3,6 +3,7 @@ import { pythonRangeStatus } from './python-version.js';
3
3
  import { hash, highest, severityRank, timestamp } from './util.js';
4
4
  import { exactLibraryVersion, normalizeEcosystem, packageKey } from './ecosystems.js';
5
5
  import { mentions, packageMentioned } from './matching.js';
6
+ import { newsSignals, signalLevel } from './news-signals.js';
6
7
  export function normalizeEventId(id) {
7
8
  return /^(?:CVE-|GHSA-)/i.test(id) ? id.toUpperCase() : id;
8
9
  }
@@ -247,6 +248,7 @@ knownFindings = new Set()) {
247
248
  index.set(system, byKey);
248
249
  }
249
250
  for (const group of groupEvidence(evidence, knownEvents)) {
251
+ const firstOfGroup = output.length;
250
252
  const advisories = group.evidence.filter((item) => item.kind === 'advisory');
251
253
  const isNews = advisories.length === 0;
252
254
  const identifiedNews = isNews && group.evidence.some((item) => identifiers(item).some(advisoryIdentifier));
@@ -392,9 +394,61 @@ knownFindings = new Set()) {
392
394
  result.summary = `Security news relevant to ${system.name}; review the linked evidence.`;
393
395
  output.push(result);
394
396
  }
397
+ if (config.policy?.news_signals !== false)
398
+ applyNewsSignals(group, output.slice(firstOfGroup), inventory);
395
399
  }
396
400
  return output.sort((a, b) => a.id.localeCompare(b.id));
397
401
  }
402
+ /**
403
+ * Raises the priority of news findings that have no advisory severity by what the articles state
404
+ * about their subject: a CVSS score, a vendor's word rating or a report of exploitation. Never
405
+ * lowers anything; the source severity stays what advisory sources said.
406
+ */
407
+ function applyNewsSignals(group, results, inventory) {
408
+ const articles = group.evidence.filter((item) => item.kind === 'news');
409
+ if (!articles.length)
410
+ return;
411
+ const ids = [
412
+ ...new Set([group.event, ...group.evidence.filter((item) => item.kind !== 'news').flatMap(identifiers)].filter(advisoryIdentifier)),
413
+ ];
414
+ const cache = new Map();
415
+ for (const result of results) {
416
+ if (result.source_severity !== 'unknown' || !(result.news_candidate || result.news_only))
417
+ continue;
418
+ const system = inventory.systems.find((item) => item.id === result.system_id);
419
+ if (!system)
420
+ continue;
421
+ const names = targetNames(result, system, articles);
422
+ const key = JSON.stringify(names);
423
+ if (!cache.has(key))
424
+ cache.set(key, newsSignals(articles, { identifiers: ids, names }));
425
+ const signals = cache.get(key);
426
+ if (!signals)
427
+ continue;
428
+ const { level, reasons } = signalLevel(signals);
429
+ result.news_signals = signals;
430
+ result.reasons.push(...reasons);
431
+ if (level !== 'unknown')
432
+ result.priority = highest(result.priority, contextualPriority(level, system, false));
433
+ }
434
+ }
435
+ /** The inventory names a finding was matched by, for tying article statements to it. */
436
+ function targetNames(result, system, articles) {
437
+ const product = result.component_id?.startsWith('product:')
438
+ ? system.products.find((item) => `product:${item.name.toLowerCase()}` === result.component_id)
439
+ : undefined;
440
+ if (product)
441
+ return [product.name, ...product.keywords];
442
+ const component = system.components.find((item) => item.id === result.component_id);
443
+ if (component)
444
+ return [component.name];
445
+ // A system-level news finding: its keywords and the installed packages the news names.
446
+ const text = articles.map((item) => `${item.title}\n${item.description}`).join('\n');
447
+ return [
448
+ ...system.keywords,
449
+ ...system.components.filter((item) => packageMentioned(text, item)).map((item) => item.name),
450
+ ];
451
+ }
398
452
  /** The source severity is always a floor; AI-proposed priority reductions cannot suppress it. */
399
453
  export function decide(assessment, config) {
400
454
  const policy = config.policy;
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
- if (Date.now() - lastHeartbeat >= 15_000)
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
- if (!scanning && !maintaining && Date.now() >= nextScan) {
1330
- nextScan = Date.now() + config.poll_interval_minutes * 60_000;
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/config.d.ts CHANGED
@@ -21,6 +21,7 @@ export declare const configSchema: z.ZodObject<{
21
21
  php: "php";
22
22
  python: "python";
23
23
  }>>>;
24
+ epss: z.ZodDefault<z.ZodBoolean>;
24
25
  }, z.core.$strict>>;
25
26
  models: z.ZodDefault<z.ZodObject<{
26
27
  enabled: z.ZodDefault<z.ZodBoolean>;
@@ -215,6 +216,7 @@ export declare const configSchema: z.ZodObject<{
215
216
  review: "review";
216
217
  }>>;
217
218
  review_before_news_suppression: z.ZodOptional<z.ZodBoolean>;
219
+ news_signals: z.ZodDefault<z.ZodBoolean>;
218
220
  health_channels: z.ZodDefault<z.ZodArray<z.ZodEnum<{
219
221
  email: "email";
220
222
  slack: "slack";
@@ -238,6 +240,7 @@ export declare const configSchema: z.ZodObject<{
238
240
  urgent_unknown: boolean;
239
241
  exploited_override: boolean;
240
242
  malware_override: boolean;
243
+ news_signals: boolean;
241
244
  health_channels: ("email" | "slack")[];
242
245
  ai_dismissals: "record" | "review";
243
246
  }, {
@@ -261,6 +264,7 @@ export declare const configSchema: z.ZodObject<{
261
264
  malware_override: boolean;
262
265
  ai_dismissals?: "record" | "review" | undefined;
263
266
  review_before_news_suppression?: boolean | undefined;
267
+ news_signals: boolean;
264
268
  health_channels: ("email" | "slack")[];
265
269
  }>>;
266
270
  notifications: z.ZodDefault<z.ZodObject<{
package/dist/config.js CHANGED
@@ -116,6 +116,7 @@ export const configSchema = z
116
116
  .max(3)
117
117
  .refine((values) => new Set(values).size === values.length, 'Duplicate vendor feed')
118
118
  .default([]),
119
+ epss: z.boolean().default(false),
119
120
  })
120
121
  .strict()
121
122
  .default({
@@ -127,6 +128,7 @@ export const configSchema = z
127
128
  kev: false,
128
129
  feeds: [],
129
130
  vendor_feeds: [],
131
+ epss: false,
130
132
  }),
131
133
  models: z
132
134
  .object({
@@ -159,6 +161,7 @@ export const configSchema = z
159
161
  malware_override: z.boolean().default(true),
160
162
  ai_dismissals: z.enum(['review', 'record']).optional(),
161
163
  review_before_news_suppression: z.boolean().optional(),
164
+ news_signals: z.boolean().default(true),
162
165
  health_channels: channels.default([]),
163
166
  })
164
167
  .strict()
@@ -170,6 +173,7 @@ export const configSchema = z
170
173
  exploited_override: true,
171
174
  malware_override: true,
172
175
  ai_dismissals: 'review',
176
+ news_signals: true,
173
177
  health_channels: [],
174
178
  })
175
179
  .superRefine((policy, ctx) => {
package/dist/delivery.js CHANGED
@@ -268,6 +268,43 @@ function fixLine(fix) {
268
268
  }
269
269
  /** One Slack section holds 3,000 characters. */
270
270
  const MESSAGE_LIMIT = 2900;
271
+ /**
272
+ * What articles state about a finding without an advisory severity, in one line. Built from the
273
+ * score, the rating word and the subject (an identifier or an inventory name); article sentences
274
+ * are never put in a message.
275
+ */
276
+ function newsSignalLine(a) {
277
+ const signals = a.news_signals;
278
+ if (!signals)
279
+ return [];
280
+ const parts = [
281
+ ...(signals.cvss
282
+ ? [
283
+ `CVSS ${signals.cvss.version ? `${signals.cvss.version} ` : ''}${signals.cvss.score} stated for ${signals.cvss.subject}`,
284
+ ]
285
+ : []),
286
+ ...(signals.rating ? [`rated "${signals.rating.word}" for ${signals.rating.subject}`] : []),
287
+ ...(signals.exploitation
288
+ ? ['exploitation reported by an article (not a known-exploited catalog entry)']
289
+ : []),
290
+ ...(!signals.exploitation && signals.no_known_exploitation
291
+ ? ['an article says no exploitation is known']
292
+ : []),
293
+ ...(signals.public_exploit ? ['public exploit code reported'] : []),
294
+ ];
295
+ return parts.length ? [single(`News signals: ${parts.join('; ')}`, 300)] : [];
296
+ }
297
+ /** FIRST's EPSS for the finding's CVE, when looked up. Numbers only. */
298
+ function epssLine(a) {
299
+ const epss = a.epss;
300
+ if (!epss || !Number.isFinite(epss.probability) || !Number.isFinite(epss.percentile))
301
+ return [];
302
+ const percent = epss.probability * 100;
303
+ const shown = percent < 0.1 ? 'under 0.1%' : `${percent < 10 ? percent.toFixed(1) : Math.round(percent)}%`;
304
+ return [
305
+ single(`EPSS for ${epss.cve}: ${shown} chance of exploitation in the next 30 days; higher than ${Math.floor(epss.percentile * 100)}% of scored CVEs (FIRST, ${epss.date})`, 200),
306
+ ];
307
+ }
271
308
  export function notificationText(job) {
272
309
  const { assessment: a, reason } = JSON.parse(job.payload);
273
310
  const subject = single(`[${a.priority.toUpperCase()}] ${a.title}`, 180);
@@ -281,6 +318,8 @@ export function notificationText(job) {
281
318
  ...locationLines(a, notes ? 300 : 0),
282
319
  `Applicability: ${single(a.applicability, 40)}; source severity: ${single(a.source_severity, 40)}; priority: ${single(a.priority, 40)}`,
283
320
  ...(a.exploited ? ['Known exploitation reported.'] : []),
321
+ ...newsSignalLine(a),
322
+ ...epssLine(a),
284
323
  `Summary: ${single(a.summary, 750)}`,
285
324
  ];
286
325
  // In the order they give way when the text is too long for one Slack section: the last of these
@@ -353,7 +392,8 @@ export function notificationText(job) {
353
392
  }
354
393
  return { subject, text };
355
394
  }
356
- function digestText(jobs) {
395
+ /** @internal Exported for tests; not part of the package root. */
396
+ export function digestText(jobs) {
357
397
  const subject = `Security Watch digest: ${jobs.length} findings`;
358
398
  const entries = jobs.map((job) => {
359
399
  const { assessment: a } = JSON.parse(job.payload);
@@ -364,6 +404,8 @@ function digestText(jobs) {
364
404
  `System: ${single(a.system_id, 60)}${a.component_id ? ` / ${single(a.component_id, 60)}` : ''}`,
365
405
  ...locationLines(a, 120),
366
406
  `Applicability: ${single(a.applicability, 40)}; source: ${single(a.source_severity, 40)}`,
407
+ ...newsSignalLine(a),
408
+ ...epssLine(a),
367
409
  ...(a.news_analysis
368
410
  ? [
369
411
  `AI news: ${single(a.news_analysis.classification, 60)}; impact: ${single(a.news_analysis.impact, 60)}`,
package/dist/engine.js CHANGED
@@ -3,6 +3,7 @@ import { z } from 'zod';
3
3
  import { cvssV4BaseScore } from './cvss4.js';
4
4
  import { assess, decide } from './assessment.js';
5
5
  import { collectSources } from './sources.js';
6
+ import { attachEpss, findingCves, readEpssCache, refreshEpss } from './epss.js';
6
7
  import { attachLocation, attachRemediation, compareInventories } from './inventory-evidence.js';
7
8
  import { ModelAnalyzer, PROMPT_VERSION } from './models.js';
8
9
  import { Store } from './store.js';
@@ -143,8 +144,12 @@ export async function runScan(options) {
143
144
  const knownFindings = new Set([...previousById.values()].filter((finding) => finding.active !== false).map((finding) => finding.id));
144
145
  const decisions = {};
145
146
  let remediationEvidence = store.evidence();
147
+ // EPSS is attached when a finding is saved, after its analysis basis is taken, and is left out of
148
+ // its revision and review: a score that changes daily must not re-send, reopen or re-analyse.
149
+ let epssCache = config.sources.epss ? readEpssCache(store.getMeta('epss:cache')) : {};
150
+ let epssEvidence = new Map(remediationEvidence.map((item) => [item.id, item]));
146
151
  const persist = (assessment) => {
147
- assessment = attachLocation(attachRemediation(assessment, inventory, remediationEvidence, config, now), inventory);
152
+ assessment = attachEpss(attachLocation(attachRemediation(assessment, inventory, remediationEvidence, config, now), inventory), epssCache, findingCves(assessment, epssEvidence));
148
153
  const decision = decide(assessment, config);
149
154
  decisions[assessment.id] = decision;
150
155
  store.saveAssessment(assessment, decision, now, config.digest_interval_hours * 3_600_000, decision.review
@@ -155,7 +160,9 @@ export async function runScan(options) {
155
160
  })
156
161
  : undefined);
157
162
  };
158
- const retire = (assessment) => {
163
+ const retire = (previous) => {
164
+ // A retired finding is not looked up any more; an ageing score would only mislead.
165
+ const { epss: _epss, ...assessment } = previous;
159
166
  store.saveAssessment({
160
167
  ...assessment,
161
168
  active: false,
@@ -228,6 +235,35 @@ export async function runScan(options) {
228
235
  }
229
236
  return canRetainPriority(previous, finding) ? { ...finding, priority: previous.priority } : finding;
230
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
+ };
231
267
  const cached = store.evidence();
232
268
  if (!options.fixture && previousById.size) {
233
269
  // Apply known inventory changes before yielding to network I/O. The worker can deliver concurrently.
@@ -240,7 +276,7 @@ export async function runScan(options) {
240
276
  const ids = new Set(current.map((a) => a.id));
241
277
  for (const finding of current)
242
278
  if (previousById.has(finding.id))
243
- persist(interim(finding, basis(finding, cachedById, collectedAt)));
279
+ reconcile(finding, basis(finding, cachedById, collectedAt));
244
280
  for (const previous of previousById.values())
245
281
  if (previous.category !== 'health' && previous.active !== false && !ids.has(previous.id))
246
282
  retire(previous);
@@ -253,6 +289,7 @@ export async function runScan(options) {
253
289
  const evidence = store.evidence();
254
290
  remediationEvidence = evidence;
255
291
  const evidenceById = new Map(evidence.map((e) => [e.id, e]));
292
+ epssEvidence = evidenceById;
256
293
  const findings = assess(inventory, evidence, config, now, now, knownEvents, knownFindings);
257
294
  const bases = new Map(findings.map((a) => [a.id, basis(a, evidenceById)]));
258
295
  const errors = [
@@ -284,6 +321,17 @@ export async function runScan(options) {
284
321
  !config.models.enabled)
285
322
  // Running without a model is a supported setup, not a fault: say what it means and carry on.
286
323
  notices.push('AI is disabled. System news receives candidate matching only; enable an analysis model to distinguish vulnerability impact from general system coverage.');
324
+ if (config.sources.epss && !options.fixture) {
325
+ const refreshed = await refreshEpss(findings
326
+ .filter((finding) => finding.category !== 'health')
327
+ .flatMap((finding) => findingCves(finding, evidenceById)), epssCache, http, now);
328
+ checkCancellation(signal);
329
+ epssCache = refreshed.cache;
330
+ store.setMeta('epss:cache', JSON.stringify(epssCache));
331
+ // Shown only, so a failed lookup is a notice, not degraded monitoring.
332
+ if (refreshed.failed)
333
+ notices.push('EPSS scores could not be refreshed from api.first.org; findings keep the scores of the last successful lookup.');
334
+ }
287
335
  for (const system of inventory.systems) {
288
336
  const updated = Date.parse(system.updated_at);
289
337
  if (!Number.isFinite(updated) ||
@@ -296,7 +344,7 @@ export async function runScan(options) {
296
344
  }
297
345
  // Reconcile every finding before delivery, including exclusions, withdrawals and removals.
298
346
  // Otherwise an old pending alert could be sent while unrelated AI analysis is running.
299
- findings.forEach((finding) => persist(interim(finding, bases.get(finding.id))));
347
+ findings.forEach((finding) => reconcile(finding, bases.get(finding.id)));
300
348
  const currentIds = new Set(findings.map((a) => a.id));
301
349
  for (const previous of store.findings())
302
350
  if (previous.category !== 'health' && previous.active !== false && !currentIds.has(previous.id))
@@ -345,7 +393,8 @@ export async function runScan(options) {
345
393
  if (!errors.some((e) => e.source === 'models' && e.message === code))
346
394
  errors.push({ source: 'models', message: code });
347
395
  }
348
- enriched = attachRemediation(enriched, inventory, evidence, config, now);
396
+ // After analysis, so a model never receives it and a new score never asks for a new one.
397
+ enriched = attachEpss(attachRemediation(enriched, inventory, evidence, config, now), epssCache, findingCves(enriched, evidenceById));
349
398
  analyzed.push(enriched);
350
399
  persist(enriched);
351
400
  store.setMeta(`assessment-basis:${finding.id}`, bases.get(finding.id));
package/dist/epss.d.ts ADDED
@@ -0,0 +1,37 @@
1
+ import type { Assessment, EpssScore, Evidence, HttpClient } from './types.js';
2
+ /** A score as FIRST publishes it, before it is tied to a finding. */
3
+ type Score = Omit<EpssScore, 'cve'>;
4
+ /** One cached lookup: a score, or none when FIRST has no score for the CVE yet. */
5
+ export interface EpssEntry {
6
+ /** Local time of the lookup, in milliseconds. */
7
+ fetched: number;
8
+ score?: Score;
9
+ }
10
+ export type EpssCache = Record<string, EpssEntry>;
11
+ export interface EpssRefresh {
12
+ cache: EpssCache;
13
+ /** Requests that failed; the scan keeps the earlier scores for their identifiers. */
14
+ failed: number;
15
+ /** Identifiers still due after this scan's request budget. */
16
+ pending: number;
17
+ }
18
+ /** Reads a stored cache, dropping anything malformed rather than failing the scan. */
19
+ export declare function readEpssCache(value: string | undefined): EpssCache;
20
+ /**
21
+ * Looks up the CVEs that are due: never looked up, or looked up more than a day ago, the oldest
22
+ * first, in batches, within the scan's request budget. The first failure ends the lookups of this
23
+ * scan. The returned cache holds only the given CVEs.
24
+ */
25
+ export declare function refreshEpss(identifiers: readonly string[], stored: EpssCache, http: HttpClient, now: number): Promise<EpssRefresh>;
26
+ /**
27
+ * The CVEs a finding is about: its event when that is a CVE, and the CVE aliases of its advisory and
28
+ * known-exploited evidence (a library finding is often keyed by its GHSA identifier). Not the CVEs a
29
+ * news story cites: a roundup cites many.
30
+ */
31
+ export declare function findingCves(assessment: Assessment, evidence: ReadonlyMap<string, Evidence>): string[];
32
+ /**
33
+ * The finding with the cached score of its CVE, or the highest of its CVEs' scores, or without
34
+ * one. Never part of its conclusion.
35
+ */
36
+ export declare function attachEpss(assessment: Assessment, cache: EpssCache, cves: readonly string[]): Assessment;
37
+ export {};