@shieldaai/security-watch 1.1.0 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,37 @@
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.0
6
+
7
+ 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`.
8
+
9
+ ### Added
10
+
11
+ - **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).
12
+ - `policy.news_signals` (default `true`) turns news signals off.
13
+ - **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).
14
+ - `Assessment.news_signals` and the exported types `NewsSignals` and `NewsStatement`.
15
+ - 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.
16
+
17
+ ### Changed
18
+
19
+ - **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.
20
+
21
+ ### Not verified
22
+
23
+ - 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.
24
+
25
+ ## 1.1.1
26
+
27
+ 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`.
28
+
29
+ ### Fixed
30
+
31
+ - **Feeds with an image in `<media:content>` were read without their text.** The article in `<description>` was ignored whenever an item also had a `<media:content>` element, so every item from feeds such as Rapid7's blog and Dark Reading arrived with an empty description and could match only by its title. The first of `content:encoded`, `content`, `description` and `summary` that holds text is now used. An empty `content:encoded` also falls through to the description.
32
+ - **Feeds that escape their HTML with entities showed the tags as text.** A description written as `&lt;p&gt;` (Tenable's blog, the seclists.org lists) arrived as the literal text `<p>`, `<br>` and similar, which reached matching, models and alerts. A field that carries HTML (RSS `description` and `content:encoded`, Atom `content` and `summary` with `type="html"`) and holds no raw `<`, which escaped XML text never does, is now unescaped once as XML (the five predefined entities and character references only; DTDs are still refused) before it is read as HTML. CDATA and plain-text fields (titles, Atom text content) are read as before, so `&lt;script&gt;` in a title stays text. The first scan after the upgrade records a new revision of items from such feeds that are still in the news window.
33
+ - **A name that starts like a loopback address no longer counts as one.** `intake.listen: 127.example.com:8787` was accepted without TLS or `allow_plain_http`, because the check read the text of the host. Only `localhost`, an IPv4 address in 127.0.0.0/8 and the IPv6 loopback address count now.
34
+ - **`sbom --project FILE` refuses a symbolic link.** A link named like a dependency file was followed to whatever it pointed at, unlike files found inside a project folder, which were already skipped. A project folder given as a link is still read.
35
+
5
36
  ## 1.1.0
6
37
 
7
38
  Start from your code instead of a hand-written inventory, and keep the inventory current from CI. 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.1.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.1.0
89
+ - uses: ShieldaAI/security-watch@v1.2.0
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.0 sbom --system-id my-app --upload https://watch.example.com:8787
99
+ npx --yes @shieldaai/security-watch@1.2.0 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.0.** This is `@shieldaai/security-watch` 1.1.0, a minor release of the first stable version (1.0.0) that adds 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.0.** This is `@shieldaai/security-watch` 1.2.0, a minor release of the first stable version (1.0.0). It 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.0.tgz
173
+ npm install --global ./shieldaai-security-watch-1.2.0.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/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) => {
@@ -241,7 +245,10 @@ export const configSchema = z
241
245
  path: ['tls_cert_file'],
242
246
  });
243
247
  const host = intake.listen.slice(0, intake.listen.lastIndexOf(':')).replace(/^\[|\]$/g, '');
244
- const loopback = host === 'localhost' || host === '::1' || /^127\./.test(host);
248
+ // An address, not a name that starts like one: `127.example.com` can point anywhere.
249
+ const loopback = host.toLowerCase() === 'localhost' ||
250
+ (isIP(host) === 4 && host.startsWith('127.')) ||
251
+ (isIP(host) === 6 && /^(?:0*:)*:?0*1$/.test(host));
245
252
  if (!loopback && !intake.tls_cert_file && !intake.allow_plain_http)
246
253
  ctx.addIssue({
247
254
  code: 'custom',
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,
@@ -253,6 +260,7 @@ export async function runScan(options) {
253
260
  const evidence = store.evidence();
254
261
  remediationEvidence = evidence;
255
262
  const evidenceById = new Map(evidence.map((e) => [e.id, e]));
263
+ epssEvidence = evidenceById;
256
264
  const findings = assess(inventory, evidence, config, now, now, knownEvents, knownFindings);
257
265
  const bases = new Map(findings.map((a) => [a.id, basis(a, evidenceById)]));
258
266
  const errors = [
@@ -284,6 +292,17 @@ export async function runScan(options) {
284
292
  !config.models.enabled)
285
293
  // Running without a model is a supported setup, not a fault: say what it means and carry on.
286
294
  notices.push('AI is disabled. System news receives candidate matching only; enable an analysis model to distinguish vulnerability impact from general system coverage.');
295
+ if (config.sources.epss && !options.fixture) {
296
+ const refreshed = await refreshEpss(findings
297
+ .filter((finding) => finding.category !== 'health')
298
+ .flatMap((finding) => findingCves(finding, evidenceById)), epssCache, http, now);
299
+ checkCancellation(signal);
300
+ epssCache = refreshed.cache;
301
+ store.setMeta('epss:cache', JSON.stringify(epssCache));
302
+ // Shown only, so a failed lookup is a notice, not degraded monitoring.
303
+ if (refreshed.failed)
304
+ notices.push('EPSS scores could not be refreshed from api.first.org; findings keep the scores of the last successful lookup.');
305
+ }
287
306
  for (const system of inventory.systems) {
288
307
  const updated = Date.parse(system.updated_at);
289
308
  if (!Number.isFinite(updated) ||
@@ -345,7 +364,8 @@ export async function runScan(options) {
345
364
  if (!errors.some((e) => e.source === 'models' && e.message === code))
346
365
  errors.push({ source: 'models', message: code });
347
366
  }
348
- enriched = attachRemediation(enriched, inventory, evidence, config, now);
367
+ // After analysis, so a model never receives it and a new score never asks for a new one.
368
+ enriched = attachEpss(attachRemediation(enriched, inventory, evidence, config, now), epssCache, findingCves(enriched, evidenceById));
349
369
  analyzed.push(enriched);
350
370
  persist(enriched);
351
371
  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 {};
package/dist/epss.js ADDED
@@ -0,0 +1,166 @@
1
+ /**
2
+ * EPSS (FIRST's Exploit Prediction Scoring System): the estimated probability that a CVE is
3
+ * exploited in the next 30 days. Shown with a finding; it decides nothing. FIRST updates scores
4
+ * daily, so they are kept apart from everything that makes a finding revision, a review or a model
5
+ * analysis: a new score never re-sends an alert or reopens a review.
6
+ *
7
+ * Only CVE identifiers are sent, to `api.first.org`. No inventory data.
8
+ */
9
+ const ENDPOINT = 'https://api.first.org/data/v1/epss';
10
+ /** The API answers at most 100 rows a page; 50 identifiers keep one request one page. */
11
+ const BATCH = 50;
12
+ /** Requests per scan; the rest wait for the next scan, the longest unrefreshed first. */
13
+ const MAX_REQUESTS = 10;
14
+ /** A score is refreshed once a day, as FIRST publishes them. */
15
+ const REFRESH_MS = 86_400_000;
16
+ /** Identifiers kept at most. */
17
+ const MAX_IDENTIFIERS = 20_000;
18
+ /**
19
+ * A CVE no current finding needs is kept this long after its last lookup, so a scan without
20
+ * findings (an empty inventory for a moment) does not throw every score away.
21
+ */
22
+ const KEEP_UNUSED_MS = 30 * 86_400_000;
23
+ /** A score a successful answer left out is kept while FIRST's date is this recent. */
24
+ const KEEP_OMITTED_MS = 7 * 86_400_000;
25
+ const CVE = /^CVE-\d{4}-\d{4,19}$/;
26
+ const DATE = /^\d{4}-\d{2}-\d{2}$/;
27
+ /** Reads a stored cache, dropping anything malformed rather than failing the scan. */
28
+ export function readEpssCache(value) {
29
+ const cache = {};
30
+ if (!value)
31
+ return cache;
32
+ let parsed;
33
+ try {
34
+ parsed = JSON.parse(value);
35
+ }
36
+ catch {
37
+ return cache;
38
+ }
39
+ if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed))
40
+ return cache;
41
+ for (const [id, raw] of Object.entries(parsed)) {
42
+ if (!CVE.test(id) || !raw || typeof raw !== 'object')
43
+ continue;
44
+ const entry = raw;
45
+ if (typeof entry.fetched !== 'number' || !Number.isFinite(entry.fetched))
46
+ continue;
47
+ const score = validScore(entry.score);
48
+ cache[id] = score ? { fetched: entry.fetched, score } : { fetched: entry.fetched };
49
+ }
50
+ return cache;
51
+ }
52
+ function validScore(value) {
53
+ if (!value || typeof value !== 'object')
54
+ return undefined;
55
+ const { probability, percentile, date } = value;
56
+ return typeof probability === 'number' &&
57
+ probability >= 0 &&
58
+ probability <= 1 &&
59
+ typeof percentile === 'number' &&
60
+ percentile >= 0 &&
61
+ percentile <= 1 &&
62
+ typeof date === 'string' &&
63
+ DATE.test(date)
64
+ ? { probability, percentile, date }
65
+ : undefined;
66
+ }
67
+ /** One row of the API's `data` array, or undefined when it is not one. */
68
+ function row(value) {
69
+ if (!value || typeof value !== 'object')
70
+ return undefined;
71
+ const { cve, epss, percentile, date } = value;
72
+ if (typeof cve !== 'string' || !CVE.test(cve.toUpperCase()))
73
+ return undefined;
74
+ // The API writes numbers as strings ("0.016400000").
75
+ const probability = typeof epss === 'string' && /^\d(?:\.\d{1,12})?$/.test(epss) ? Number(epss) : NaN;
76
+ const rank = typeof percentile === 'string' && /^\d(?:\.\d{1,12})?$/.test(percentile) ? Number(percentile) : NaN;
77
+ const score = validScore({ probability, percentile: rank, date });
78
+ return score ? { cve: cve.toUpperCase(), score } : undefined;
79
+ }
80
+ /**
81
+ * Looks up the CVEs that are due: never looked up, or looked up more than a day ago, the oldest
82
+ * first, in batches, within the scan's request budget. The first failure ends the lookups of this
83
+ * scan. The returned cache holds only the given CVEs.
84
+ */
85
+ export async function refreshEpss(identifiers, stored, http, now) {
86
+ const wanted = [...new Set(identifiers.map((id) => id.toUpperCase()).filter((id) => CVE.test(id)))].slice(0, MAX_IDENTIFIERS);
87
+ const cache = {};
88
+ for (const id of wanted)
89
+ if (stored[id])
90
+ cache[id] = stored[id];
91
+ const due = wanted
92
+ .filter((id) => !cache[id] || !(cache[id].fetched <= now) || now - cache[id].fetched >= REFRESH_MS)
93
+ .sort((a, b) => (cache[a]?.fetched ?? -1) - (cache[b]?.fetched ?? -1) || a.localeCompare(b));
94
+ let failed = 0;
95
+ let sent = 0;
96
+ for (let index = 0; index < due.length && sent < MAX_REQUESTS; index += BATCH) {
97
+ const batch = due.slice(index, index + BATCH);
98
+ sent++;
99
+ try {
100
+ const response = await http(`${ENDPOINT}?cve=${batch.join(',')}`, {
101
+ maxBytes: 200_000,
102
+ headers: { accept: 'application/json' },
103
+ });
104
+ if (response.status !== 200)
105
+ throw new Error('EPSS_HTTP');
106
+ const body = JSON.parse(response.body);
107
+ if (body.status !== 'OK' || !Array.isArray(body.data))
108
+ throw new Error('EPSS_SCHEMA');
109
+ const scores = new Map();
110
+ for (const item of body.data) {
111
+ const parsed = row(item);
112
+ if (parsed && batch.includes(parsed.cve))
113
+ scores.set(parsed.cve, parsed.score);
114
+ }
115
+ for (const id of batch) {
116
+ // A CVE FIRST has scored before and leaves out once keeps its recent score; the date shows its age.
117
+ const earlier = cache[id]?.score;
118
+ const score = scores.get(id) ??
119
+ (earlier && now - Date.parse(`${earlier.date}T00:00:00Z`) <= KEEP_OMITTED_MS ? earlier : undefined);
120
+ cache[id] = score ? { fetched: now, score } : { fetched: now };
121
+ }
122
+ }
123
+ catch {
124
+ // A cancelled scan fails here too; the engine checks for cancellation right after.
125
+ failed++;
126
+ break;
127
+ }
128
+ }
129
+ const pending = wanted.filter((id) => !cache[id] || !(cache[id].fetched <= now) || now - cache[id].fetched >= REFRESH_MS).length;
130
+ // Recently looked-up CVEs that no current finding needs, the most recent first, within the bound.
131
+ const unused = Object.entries(stored)
132
+ .filter(([id, entry]) => !(id in cache) && entry.fetched <= now && now - entry.fetched < KEEP_UNUSED_MS)
133
+ .sort(([, a], [, b]) => b.fetched - a.fetched)
134
+ .slice(0, Math.max(0, MAX_IDENTIFIERS - Object.keys(cache).length));
135
+ for (const [id, entry] of unused)
136
+ cache[id] = entry;
137
+ return { cache, failed, pending };
138
+ }
139
+ /**
140
+ * The CVEs a finding is about: its event when that is a CVE, and the CVE aliases of its advisory and
141
+ * known-exploited evidence (a library finding is often keyed by its GHSA identifier). Not the CVEs a
142
+ * news story cites: a roundup cites many.
143
+ */
144
+ export function findingCves(assessment, evidence) {
145
+ const ids = [assessment.event_id];
146
+ for (const id of assessment.evidence_ids) {
147
+ const item = evidence.get(id);
148
+ if (item && item.kind !== 'news' && item.kind !== 'health')
149
+ ids.push(...item.aliases);
150
+ }
151
+ return [...new Set(ids.map((id) => id.toUpperCase()).filter((id) => CVE.test(id)))].sort();
152
+ }
153
+ /**
154
+ * The finding with the cached score of its CVE, or the highest of its CVEs' scores, or without
155
+ * one. Never part of its conclusion.
156
+ */
157
+ export function attachEpss(assessment, cache, cves) {
158
+ const { epss: _old, ...rest } = assessment;
159
+ let best;
160
+ for (const cve of cves) {
161
+ const score = cache[cve.toUpperCase()]?.score;
162
+ if (score && (!best || score.probability > best.probability))
163
+ best = { cve: cve.toUpperCase(), ...score };
164
+ }
165
+ return best ? { ...rest, epss: best } : rest;
166
+ }
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export type { Severity, Category, Applicability, Channel, Provenance, DeploymentObservation, ArtifactKind, DeclaredVerification, DependencyLink, DependencyRelationship, DeclaredRemediation, InventoryEvidence, Component, Product, FindingLocation, System, Inventory, PackageClaim, CvssV4BaseScore, Evidence, ModelSpec, Config, Rule, Assessment, AiReviewReason, AiReview, Decision, Notification, HttpOptions, HttpResult, HttpClient, CoverageReceipt, InventoryDrift, RemediationEvidence, SourceResult, AiAnalysis, NewsAnalysis, } from './types.js';
1
+ export type { Severity, Category, Applicability, Channel, Provenance, DeploymentObservation, ArtifactKind, DeclaredVerification, DependencyLink, DependencyRelationship, DeclaredRemediation, InventoryEvidence, Component, Product, FindingLocation, System, Inventory, PackageClaim, CvssV4BaseScore, Evidence, ModelSpec, Config, Rule, Assessment, AiReviewReason, AiReview, Decision, Notification, HttpOptions, HttpResult, HttpClient, CoverageReceipt, InventoryDrift, RemediationEvidence, SourceResult, AiAnalysis, NewsAnalysis, NewsSignals, NewsStatement, EpssScore, } from './types.js';
2
2
  export { scorePilotResponses, type PilotResponseRegister, type PilotResponseScore, } from './pilot-responses.js';
3
3
  export { loadConfig, parseConfig, configSchema } from './config.js';
4
4
  export { loadInventory } from './inventory.js';
package/dist/manifests.js CHANGED
@@ -892,6 +892,10 @@ export const DEPENDENCY_FILES = {
892
892
  /** Walks a project for dependency files without following links or entering installed-package folders. */
893
893
  function discover(root, warnings) {
894
894
  const stat = statSync(root);
895
+ // A link named like a dependency file can point at any file on the machine. The folder given as
896
+ // the project may be a link (the user chose it); a file must be the file itself.
897
+ if (stat.isFile() && lstatSync(root).isSymbolicLink())
898
+ throw new Error(`${basename(root)} is a symbolic link; give the dependency file itself.`);
895
899
  if (stat.isFile()) {
896
900
  const kind = classify(basename(root), basename(dirname(root)));
897
901
  if (!kind)
@@ -13,6 +13,12 @@ export declare function packageMentioned(text: string, component: {
13
13
  ecosystem: Ecosystem;
14
14
  name: string;
15
15
  }): boolean;
16
+ /**
17
+ * Where a sentence ends: after ".", "!" or "?" and before a capital letter or a digit, but not after
18
+ * a common abbreviation ("e.g.", "i.e.", "incl.", "vs.") or a single lower-case letter. After "etc." and
19
+ * initials ("the U.S. Package scams") it does end.
20
+ */
21
+ export declare const SENTENCE_END: RegExp;
16
22
  export interface InventoryMatcher {
17
23
  /** Identity keys of every inventory component. */
18
24
  packages: Set<string>;