@shieldaai/security-watch 1.2.1 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,30 @@
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.3.0
6
+
7
+ Security Watch hands findings to whoever writes temporary mitigations (runtime shields, blocking policies, firewall rules), shows which hosts a mitigation covers, works with [Shirudo](docs/shirudo.md), writes OpenVEX for other scanners, and reads CycloneDX up to 1.7. 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.3.0`.
8
+
9
+ ### Added
10
+
11
+ - **Fix links, fix commits, weaknesses and exploit code are kept.** OSV and GitHub advisories keep their typed links: code changes (commits, pull and merge requests, compare views of two releases, patches, kernel.org, gitweb, googlesource and Mercurial commits) are `fix`; a page typed as a fix that is not a code change, and any change to an advisory database, is an `advisory`. OSV keeps the commits its `GIT` ranges name as fixes, both keep their CWE identifiers, and cve.now keeps its Exploit-DB, Metasploit, Nuclei and GitHub proof-of-concept entries when they name something. Only https links to public names, without credentials or inner whitespace, at most 40 links, 20 commits and 20 weaknesses per advisory. A malformed value is dropped, never the advisory. They are never sent to models and are left out of an advisory's content hash and a finding's analysis basis, so the upgrade records no new evidence revision, re-sends nothing and asks no model again. `explain` shows them. New `Evidence` fields `references`, `fix_commits`, `weaknesses` and `exploit_sources`; exported types `AdvisoryReference`, `FixCommit` and `ReferenceType`.
12
+ - **`security-watch shield-candidates`.** Lists active findings that are critical or known or reported to be exploited (`--all` for every finding that may affect you), with a `readiness`: `fix_known` (the installed version is affected and an advisory links the fix for this package), `fixed_version_known`, `advisory_only` or `news_only`, and a `missing` list in plain words. News alone is never enough to write a mitigation, and is listed as such. An advisory that covers several packages counts its fix links only for the package they name. `--unmitigated` leaves out findings that every source proves mitigated on every host now; `--omit-location` leaves out system IDs, names, owners, notes, package URL qualifiers, news links and mitigation details; `--output NEW.json` writes a new private file. Read-only. Library function `shieldCandidates` and its types.
13
+ - **Mitigation status, optional.** A `mitigations` list (up to ten sources) reads JSON Lines files that your tools write on a timer, in Shirudo's `node_vulns` format or a [generic format](docs/mitigations.md#mitigation-status) any tool can write (with an optional `expires_at`), and shows per finding how many hosts of the system are mitigated, waiting, failed, excluded, withdrawn, expired or not mitigated, and what is in place: in alerts, digests, `explain`, `findings`, `shield-candidates` and `vex` (`Assessment.mitigations`, exported types `MitigationStatus`, `MitigationState`, `MitigationSource` and `MitigationFormat`). Like EPSS it is shown only: it changes no applicability, priority or routing, creates no revision and never closes a finding. A missing, unreadable, empty, out-of-date or future-dated file, values the release does not know, and rows that all miss the inventory are monitoring-health errors; `doctor` checks every file. A saved status is judged again when read, so `findings`, `explain`, `shield-candidates` and `vex` never show it as current after scans stop or a mitigation expires. Security Watch never connects to a mitigation tool.
14
+ - **`security-watch shirudo-sboms`.** Copies the SBOMs of Shirudo's images from a local copy of its SBOM store into the SBOM folder, one system per image (the image ID, stable across upgrades). With the export it watches the images machines run, merging the SBOMs of versions that run side by side; without it, the newest version. It writes, replaces and removes only its own files, compactly and atomically; it removes a file only when its image is known to be gone, never because a read failed, the store is empty or the export is incomplete, and removes more than half of its images only with `--allow-removals`; it reports an image whose ID another system uses (with `--config`, also systems described by hand); and it shows its plan unless `--apply` is given. Library function `syncShirudoSboms`.
15
+ - **`security-watch vex`.** Writes an OpenVEX 0.2.0 document for library findings with an exact package version: `affected` with the action (update, follow the advisory, remove a malicious package, and a current mitigation), `under_investigation`, and `not_affected` only with `--include-not-affected`. Package URLs come from the inventory with only descriptive qualifiers (`classifier`, `type`, `arch`, `distro`, `os`, `epoch`), or are built per the package URL specification. Statements of the same package in several systems are merged to the most severe. An unchanged state gives the same document identifier. `--omit-mitigations` leaves the mitigation part of the action out. Library function `openVex`.
16
+ - **CycloneDX 1.2 to 1.7.** SBOMs from CycloneDX 1.2 up to 1.7 are read (1.4 to 1.6 before); a later 1.x is read by the 1.7 rules with a notice that does not degrade monitoring; 2.x and malformed versions are refused. A CycloneDX document without a `components` list is an empty system instead of an error. `security-watch sbom` still writes 1.6, which more tools read.
17
+ - Guides: [temporary mitigations](docs/mitigations.md) and [Security Watch with Shirudo](docs/shirudo.md).
18
+
19
+ ### Verified
20
+
21
+ - The VEX output was loaded into Trivy 0.71.2 (`trivy sbom --vex`): `not_affected` statements suppressed exactly their CVEs for npm (including a scoped package whose inventory purl was written with a literal `@`) and for a Maven package whose purl Security Watch built; `affected` and `under_investigation` statements left the findings in the report.
22
+
23
+ ### Not verified
24
+
25
+ - The Shirudo integration follows Shirudo's documentation of 24 November 2026 and is tested against files in that format, not against a running Shirudo deployment, which needs Shirudo's kernel patches and a TPM. Shirudo is pre-release.
26
+ - Upgrading is tested with a database written by the released 1.2.1 build (`test/fixtures/watch-1.2.1.db`): no revision, fingerprint, delivery or analysis basis changes.
27
+ - How often advisories carry fix links and exploit entries was measured on one advisory (Log4Shell), not on a corpus.
28
+
5
29
  ## 1.2.1
6
30
 
7
31
  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`.
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.1
89
+ - uses: ShieldaAI/security-watch@v1.3.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.2.1 sbom --system-id my-app --upload https://watch.example.com:8787
99
+ npx --yes @shieldaai/security-watch@1.3.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.
@@ -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.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.
133
+ **Version 1.3.0.** This is `@shieldaai/security-watch` 1.3.0, a minor release of the first stable version (1.0.0). It lists the findings worth a temporary mitigation with what is known for writing one (`shield-candidates`), shows which hosts a mitigation covers, works with [Shirudo](docs/shirudo.md), writes OpenVEX for other scanners and reads CycloneDX up to 1.7; 1.2 read scores and exploitation reports from news and added EPSS, and 1.1 added SBOM generation, 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
 
@@ -142,6 +142,7 @@ Related projects: [Agent Guard](https://github.com/ShieldaAI/agent-guard) for to
142
142
  - Separate alert thresholds for libraries, products and news, plus review digests and configurable overrides for potentially critical findings, known exploitation and malware.
143
143
  - Slack incoming webhooks and SMTP email, backed by a SQLite delivery queue. An email is retried automatically only when it provably never left. A Slack message is retried when Slack answers HTTP 429 or 5xx or the connection fails before the request is sent; in rare cases Slack may have posted a message it answered 5xx for. Any other uncertain delivery is recorded for manual review and retry.
144
144
  - Per-source coverage receipts, bounded CycloneDX and SPDX import (output of Trivy, Syft, cdxgen and GitHub's dependency graph) with package URLs and dependency relationships, and inventory drift reports. Optional artifact kinds cover MCP servers/clients, plugins, skills and models; signature, attestation and remediation lifecycle fields record operator-supplied evidence. They do not perform verification or close findings. See [deployment evidence](docs/configuration.md#agent-deployment-evidence-sboms-and-drift).
145
+ - [Temporary mitigations](docs/mitigations.md): `shield-candidates` lists critical and exploited findings with what someone writing a runtime shield, a blocking policy or a firewall rule needs (fix commits and patch links, installed and fixed versions, weakness types, public exploit code) and says what is still missing; news alone is never enough. Alerts can say how many hosts a mitigation covers, read from files your tools write ([Shirudo](docs/shirudo.md) or a generic format). `vex` writes OpenVEX for scanners such as Trivy and Grype. Mitigations are shown only: they never lower a priority or close a finding.
145
146
  - Finding history, revision-bound AI dismissal review, acknowledgement, suppression with an expiry, source checkpoints and model budgets. Optional external heartbeats, bounded retention and verified backups support ongoing operation.
146
147
 
147
148
  | Inventory item | Coverage |
@@ -170,7 +171,7 @@ To build and install from a source checkout:
170
171
  npm ci
171
172
  npm run check
172
173
  npm pack
173
- npm install --global ./shieldaai-security-watch-1.2.1.tgz
174
+ npm install --global ./shieldaai-security-watch-1.3.0.tgz
174
175
  ```
175
176
 
176
177
  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
@@ -34,6 +34,8 @@ Each configured AI model defaults to the `minimal` disclosure profile. It receiv
34
34
 
35
35
  Inventory notes (the `note` field on systems, libraries and products) are the operator's own pointers to where something runs. They are stored in the local database and shown in notifications together with the system name and owner. They are never sent to advisory sources and are excluded from model requests under both disclosure profiles. Do not put secrets in a note.
36
36
 
37
+ `shield-candidates` prints system IDs and the same inventory names, owners and notes, plus package names, versions and advisory links, as local JSON. `--omit-location` leaves out system IDs (often a system's name), names, owners, notes, package URL qualifiers (which can name a private registry) and links to news articles (a feed can be internal); use it before giving the list to an agent or service outside your network. Identifiers, package names and versions stay, because a mitigation is written from them. `vex` writes package URLs from your inventory with only descriptive qualifiers (`classifier`, `type`, `arch`, `distro`, `os`, `epoch`), and its action statements can name your mitigation tool and host counts unless `--omit-mitigations` is given; read a document before you publish it. Mitigation status files are local files that Security Watch only reads; it connects to no Shirudo, ClickHouse or other mitigation service and holds no credential for one. `shirudo-sboms` reads a local copy of Shirudo's SBOM store, follows no symbolic links, and writes, replaces and removes only the files it marked as its own in the SBOM folder.
38
+
37
39
  Notifications disclose formatted finding context, the inventory names and notes above, and source links to Slack or the configured email recipients under separate routing policy; model disclosure settings do not filter notification payloads or public inventory queries. There is no automatic application telemetry. An optional, operator-configured heartbeat endpoint receives bodyless success pings and normal request metadata. It receives no inventory, finding content or logs.
38
40
 
39
41
  Credential values are read from environment variables, not placed in model prompts or intentionally persisted in SQLite. Do not insert keys into model names, feed URLs, inventory text or configuration substitutions. Use your service manager or secret manager to supply credentials; the CLI does not automatically load `.env` files. Do not commit configuration, database files, backups or `.env` files to source control.
@@ -48,9 +50,10 @@ SQLite stores evidence, finding revisions, model analysis excerpts, caches, budg
48
50
  - 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
51
  - 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
52
  - 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).
53
+ - Mitigation status is the operator's file, read as written: Security Watch does not verify that a shield, policy or rule is loaded, signed or effective. It is shown only and never lowers a priority or closes a finding. `shield-candidates` readiness describes the information the advisories provide, not whether a mitigation is possible or safe, and fix links and exploit entries are only as complete as the advisories. `vex --include-not-affected` makes claims that other scanners act on by hiding the vulnerability; they rest on published version ranges. See [temporary mitigations](docs/mitigations.md).
51
54
  - Source requests and model inputs have size and request limits. Incomplete collection or analysis reports degraded monitoring and requires review.
52
55
  - 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.
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.
56
+ - CycloneDX JSON 1.2–1.7 (later 1.x with a notice) and SPDX JSON 2.2/2.3 package metadata import, and SBOM generation from lockfiles and manifests (`security-watch sbom`), are supported, and OpenVEX output (`vex`), 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.
54
57
  - Notifications are not exactly-once delivery. A timeout can occur after a destination accepts a message. Verify receipt before retrying an `unknown` job.
55
58
 
56
59
  Review `status`, `deliveries`, source-health findings and service logs. Optional external success pings stop when monitoring is unhealthy, but the receiving service must be configured to detect missing pings. Loss of the host or every delivery channel cannot be reported through that same failed infrastructure.
package/dist/cli.js CHANGED
@@ -4,10 +4,14 @@ import { existsSync, linkSync, mkdirSync, mkdtempSync, readFileSync, renameSync,
4
4
  import { basename, dirname, extname, join, resolve } from 'node:path';
5
5
  import { createInterface } from 'node:readline/promises';
6
6
  import { setTimeout as delay } from 'node:timers/promises';
7
- import { stringify } from 'yaml';
7
+ import { parse as parseYaml, stringify } from 'yaml';
8
8
  import { z } from 'zod';
9
9
  import { loadConfig, parseConfig, missingCredentials } from './config.js';
10
10
  import { loadInventory } from './inventory.js';
11
+ import { shieldCandidates } from './shield-candidates.js';
12
+ import { openVex } from './vex.js';
13
+ import { exportProblems, maxAges, readMitigationExport, withCurrentMitigations } from './mitigations.js';
14
+ import { syncShirudoSboms } from './shirudo-sboms.js';
11
15
  import { importSbom } from './sbom.js';
12
16
  import { DEPENDENCY_FILES, generateSbom } from './manifests.js';
13
17
  import { intakeDirectory, startIntake } from './intake.js';
@@ -85,6 +89,9 @@ const help = `Shielda Security Watch ${VERSION}
85
89
  security-watch rehearse --config PATH --input SCENARIO.json [--sink disabled|accepted|failed|unknown] [--output NEW.json]
86
90
  security-watch start [--config PATH]
87
91
  security-watch findings | status | deliveries | budget
92
+ security-watch shield-candidates [--all] [--unmitigated] [--omit-location] [--output NEW.json]
93
+ security-watch vex [--system ID] [--include-not-affected] [--omit-mitigations] [--author TEXT] [--output NEW.json]
94
+ security-watch shirudo-sboms --store DIR --directory SBOM_DIR [--running EXPORT.jsonl] [--config PATH] [--apply] [--allow-removals]
88
95
  security-watch pilot-report (--database PATH | --backup PATH) --from YYYY-MM-DD --until YYYY-MM-DD [--output NEW.json]
89
96
  security-watch pilot-recall --backup PATH --from YYYY-MM-DD --until YYYY-MM-DD --input INCIDENTS.json [--responses RESPONSES.json] [--output NEW.json]
90
97
  security-watch pilot-cases --backup PATH --from YYYY-MM-DD --until YYYY-MM-DD --output NEW.json
@@ -110,6 +117,11 @@ init --project creates a monitor for that project in one step. With an intake se
110
117
  configuration, start also receives SBOMs from CI (sbom --upload, upload); intake runs only that.
111
118
  Upload tokens are read from SECURITY_WATCH_INTAKE_TOKEN unless --token-env names another variable.
112
119
 
120
+ shield-candidates lists critical and exploited findings with what is known for writing a temporary
121
+ runtime shield (fix links, versions, exploit code) and what is missing; vex writes OpenVEX for
122
+ other scanners; both change nothing. shirudo-sboms copies Shirudo's image SBOMs into the SBOM
123
+ folder, showing its plan unless --apply is given.
124
+
113
125
  Default config: ./security-watch.yaml. scan records findings; --dry-run writes no state,
114
126
  disables models and sends nothing. --notify sends due jobs. start runs the foreground scheduler and
115
127
  configured notification routes. Model/feed requests can leave this machine; fixture
@@ -179,6 +191,15 @@ function argumentsFromCommandLine() {
179
191
  url: { type: 'string' },
180
192
  'token-env': { type: 'string' },
181
193
  'allow-http': { type: 'boolean' },
194
+ 'omit-location': { type: 'boolean' },
195
+ unmitigated: { type: 'boolean' },
196
+ 'allow-removals': { type: 'boolean' },
197
+ 'include-not-affected': { type: 'boolean' },
198
+ 'omit-mitigations': { type: 'boolean' },
199
+ author: { type: 'string' },
200
+ system: { type: 'string' },
201
+ store: { type: 'string' },
202
+ running: { type: 'string' },
182
203
  },
183
204
  });
184
205
  }
@@ -649,6 +670,7 @@ async function main() {
649
670
  ecosystems: [],
650
671
  'normalize-libraries': ['input', 'ecosystem', 'output'],
651
672
  'import-sbom': ['input', 'output'],
673
+ 'shirudo-sboms': ['store', 'directory', 'running', 'apply', 'allow-removals', 'config'],
652
674
  coverage: ['config'],
653
675
  'inventory-drift': ['config'],
654
676
  doctor: ['config', 'no-ai'],
@@ -662,6 +684,8 @@ async function main() {
662
684
  'pilot-report': ['database', 'backup', 'from', 'until', 'output'],
663
685
  start: ['config', 'no-ai'],
664
686
  findings: ['config'],
687
+ 'shield-candidates': ['config', 'all', 'omit-location', 'unmitigated', 'output'],
688
+ vex: ['config', 'system', 'include-not-affected', 'omit-mitigations', 'author', 'output'],
665
689
  status: ['config'],
666
690
  deliveries: ['config'],
667
691
  budget: ['config'],
@@ -719,6 +743,37 @@ async function main() {
719
743
  await sendSbom(body, values['system-id'] ?? systemIdOf(body, path));
720
744
  return;
721
745
  }
746
+ if (command === 'shirudo-sboms') {
747
+ if (!values.store || !values.directory)
748
+ throw new Error('--store DIR and --directory SBOM_DIR required');
749
+ // With --config, systems described by hand in the inventory are known, so an image with the same
750
+ // ID is reported instead of being refused by every scan.
751
+ let reserved = [];
752
+ if (values.config) {
753
+ const inventoryPath = loadConfig(resolve(values.config)).inventory;
754
+ const raw = parseYaml(readFileSync(inventoryPath, 'utf8'), { maxAliasCount: 0 });
755
+ const systems = raw && typeof raw === 'object' ? raw.systems : undefined;
756
+ reserved = Array.isArray(systems)
757
+ ? systems
758
+ .map((system) => system && typeof system === 'object' ? system.id : undefined)
759
+ .filter((value) => typeof value === 'string')
760
+ : [];
761
+ }
762
+ const plan = syncShirudoSboms({
763
+ reserved,
764
+ allowRemovals: Boolean(values['allow-removals']),
765
+ store: resolve(values.store),
766
+ output: resolve(values.directory),
767
+ ...(values.running ? { exposure: resolve(values.running) } : {}),
768
+ apply: Boolean(values.apply),
769
+ });
770
+ output(plan);
771
+ if (!values.apply && (plan.images.some((item) => item.action === 'write') || plan.remove.length))
772
+ console.error('Nothing was written. Run again with --apply to write this plan.');
773
+ if (plan.problems.length)
774
+ process.exitCode = 2;
775
+ return;
776
+ }
722
777
  if (command === 'import-sbom') {
723
778
  if (!values.input)
724
779
  throw new Error('--input PATH required');
@@ -860,6 +915,38 @@ async function main() {
860
915
  ? process.env[config.notifications.slack.webhook_url_env]
861
916
  : undefined;
862
917
  const heartbeat = config.monitoring ? process.env[config.monitoring.heartbeat_url_env] : undefined;
918
+ // Each mitigation export is read as a scan reads it; what it covers is shown so a mapping
919
+ // mistake (an image ID that is no system ID) is seen before the first alert.
920
+ const systemIds = new Set(inventory.systems.map((system) => system.id));
921
+ const mitigationProblems = [];
922
+ const mitigations = (config.mitigations ?? []).map((source) => {
923
+ try {
924
+ const exported = readMitigationExport(source, Date.now());
925
+ mitigationProblems.push(...exportProblems(exported, source, Date.now()));
926
+ const keys = new Set(exported.rows.map((row) => row.system));
927
+ const systems = [...keys].map((key) => Object.hasOwn(source.systems, key) ? source.systems[key] : key);
928
+ const unknown = systems.filter((id) => !systemIds.has(id));
929
+ if (unknown.length)
930
+ mitigationProblems.push(`${source.name}: ${unknown.length} system key(s) in the export match no system in the inventory (${unknown
931
+ .slice(0, 5)
932
+ .join(', ')}${unknown.length > 5 ? ', …' : ''}); map them with systems: or add those systems.`);
933
+ return {
934
+ name: source.name,
935
+ format: source.format,
936
+ rows: exported.rows.length,
937
+ hosts: new Set(exported.rows.map((row) => `${row.system}\u0000${row.host}`)).size,
938
+ systems_matched: systems.filter((id) => systemIds.has(id)).length,
939
+ exported_at: exported.exported_at,
940
+ stale: exported.stale,
941
+ };
942
+ }
943
+ catch (error) {
944
+ mitigationProblems.push(`${source.name}: the export cannot be read: ${error.code === 'ENOENT'
945
+ ? 'the file does not exist'
946
+ : error.message}.`);
947
+ return { name: source.name, format: source.format, readable: false };
948
+ }
949
+ });
863
950
  const problems = [
864
951
  // Delivery refuses such an address on every attempt; say so before the first alert is due.
865
952
  ...(slack && slackProblem(slack)
@@ -871,6 +958,7 @@ async function main() {
871
958
  ]
872
959
  : []),
873
960
  ...intakeProblems(config),
961
+ ...mitigationProblems,
874
962
  // The heartbeat refuses such an address on every ping.
875
963
  ...(heartbeat && heartbeatProblem(heartbeat, config.monitoring.allow_private_endpoint)
876
964
  ? [`${config.monitoring.heartbeat_url_env}: the external heartbeat address cannot be used.`]
@@ -903,6 +991,7 @@ async function main() {
903
991
  feeds: config.sources.feeds.length + Number(config.sources.hacker_news),
904
992
  notification_routes: routes,
905
993
  notification_channels: enabledChannels,
994
+ ...(mitigations.length ? { mitigations } : {}),
906
995
  ecosystems: [
907
996
  ...new Set(inventory.systems.flatMap((system) => system.components.map((component) => component.ecosystem))),
908
997
  ],
@@ -964,6 +1053,8 @@ async function main() {
964
1053
  'scan',
965
1054
  'start',
966
1055
  'findings',
1056
+ 'shield-candidates',
1057
+ 'vex',
967
1058
  'status',
968
1059
  'coverage',
969
1060
  'inventory-drift',
@@ -991,6 +1082,8 @@ async function main() {
991
1082
  const readonly = (command === 'prune' && !values.apply) ||
992
1083
  [
993
1084
  'findings',
1085
+ 'shield-candidates',
1086
+ 'vex',
994
1087
  'status',
995
1088
  'coverage',
996
1089
  'inventory-drift',
@@ -1079,7 +1172,91 @@ async function main() {
1079
1172
  return;
1080
1173
  }
1081
1174
  if (command === 'findings') {
1082
- output(store.findings());
1175
+ const ages = maxAges(config.mitigations);
1176
+ output(store.findings().map((finding) => withCurrentMitigations(finding, ages, Date.now())));
1177
+ return;
1178
+ }
1179
+ if (command === 'vex') {
1180
+ const author = values.author ?? 'Security Watch';
1181
+ if (!author.trim() ||
1182
+ author.length > 200 ||
1183
+ /[\u0000-\u001f\u007f-\u009f\u200b-\u200f\u2028-\u202e\u2066-\u2069\ufeff]/.test(author))
1184
+ throw new Error('--author must be one line of at most 200 characters');
1185
+ // The packages and their versions come from the inventory as it is now.
1186
+ const inventory = loadInventory(config.inventory);
1187
+ if (values.system !== undefined && !inventory.systems.some((system) => system.id === values.system))
1188
+ throw new Error(`No system ${values.system} in the inventory`);
1189
+ const ages = maxAges(config.mitigations);
1190
+ const { document, skipped } = openVex({
1191
+ findings: store.findings().map((finding) => withCurrentMitigations(finding, ages, Date.now())),
1192
+ evidence: (ids) => store.getEvidence(ids),
1193
+ inventory,
1194
+ ...(values.system !== undefined ? { systemId: values.system } : {}),
1195
+ includeNotAffected: Boolean(values['include-not-affected']),
1196
+ author: author.trim(),
1197
+ // Fresh runtime mitigations are worth telling a consumer; they never change the status.
1198
+ mitigationNote: (finding) => {
1199
+ // Only a current status that covers at least one host is worth saying outside, with its time.
1200
+ if (values['omit-mitigations'])
1201
+ return undefined;
1202
+ const fresh = (finding.mitigations ?? []).filter((status) => !status.stale && !status.not_listed && (status.states.mitigated ?? 0) > 0);
1203
+ return fresh.length
1204
+ ? `Temporary runtime mitigation on ${fresh
1205
+ .map((status) => `${status.states.mitigated} of ${status.hosts} host(s) (${status.source}, ${status.exported_at.slice(0, 16).replace('T', ' ')} UTC)`)
1206
+ .join('; ')}.`
1207
+ : undefined;
1208
+ },
1209
+ });
1210
+ if (values.output) {
1211
+ writeFileSync(resolve(values.output), JSON.stringify(document, null, 2) + '\n', {
1212
+ flag: 'wx',
1213
+ mode: 0o600,
1214
+ });
1215
+ const left = Object.entries(skipped)
1216
+ .map(([reason, count]) => `${count} ${reason.replaceAll('_', ' ')}`)
1217
+ .join(', ');
1218
+ console.log(`${document.statements.length} VEX statement(s) saved.${left ? ` Not written: ${left}.` : ''}`);
1219
+ }
1220
+ else {
1221
+ output(document);
1222
+ const left = Object.entries(skipped)
1223
+ .map(([reason, count]) => `${count} ${reason.replaceAll('_', ' ')}`)
1224
+ .join(', ');
1225
+ if (left)
1226
+ console.error(`Not written: ${left}.`);
1227
+ }
1228
+ return;
1229
+ }
1230
+ if (command === 'shield-candidates') {
1231
+ // The inventory as it is now gives package versions; a stored location is the fallback.
1232
+ let inventory;
1233
+ try {
1234
+ inventory = loadInventory(config.inventory);
1235
+ }
1236
+ catch {
1237
+ inventory = undefined;
1238
+ }
1239
+ const report = shieldCandidates({
1240
+ findings: store.findings(),
1241
+ evidence: (ids) => store.getEvidence(ids),
1242
+ ...(inventory ? { inventory } : {}),
1243
+ controls: (findingId) => store.controls(findingId),
1244
+ all: Boolean(values.all),
1245
+ omitLocation: Boolean(values['omit-location']),
1246
+ unmitigatedOnly: Boolean(values.unmitigated),
1247
+ mitigationMaxAge: maxAges(config.mitigations),
1248
+ });
1249
+ if (!inventory)
1250
+ report.notes.push('The inventory could not be read: a package and its installed version are shown only where an advisory matched exactly one package by version.');
1251
+ if (values.output) {
1252
+ writeFileSync(resolve(values.output), JSON.stringify(report, null, 2) + '\n', {
1253
+ flag: 'wx',
1254
+ mode: 0o600,
1255
+ });
1256
+ console.log(`${report.candidates.length} shield candidate(s) saved.`);
1257
+ }
1258
+ else
1259
+ output(report);
1083
1260
  return;
1084
1261
  }
1085
1262
  if (command === 'deliveries') {
@@ -1118,9 +1295,10 @@ async function main() {
1118
1295
  return;
1119
1296
  }
1120
1297
  if (command === 'explain') {
1121
- const finding = id ? store.getFinding(id) : undefined;
1122
- if (!finding)
1298
+ const saved = id ? store.getFinding(id) : undefined;
1299
+ if (!saved)
1123
1300
  throw new Error('Finding not found');
1301
+ const finding = withCurrentMitigations(saved, maxAges(config.mitigations), Date.now());
1124
1302
  output({
1125
1303
  finding,
1126
1304
  decision: decide(finding, config),
@@ -1133,6 +1311,10 @@ async function main() {
1133
1311
  fetched_at: e.fetched_at,
1134
1312
  withdrawn: e.withdrawn ?? false,
1135
1313
  ...(e.cvss_v4 ? { cvss_v4: e.cvss_v4 } : {}),
1314
+ ...(e.references ? { references: e.references } : {}),
1315
+ ...(e.fix_commits ? { fix_commits: e.fix_commits } : {}),
1316
+ ...(e.weaknesses ? { weaknesses: e.weaknesses } : {}),
1317
+ ...(e.exploit_sources ? { exploit_sources: e.exploit_sources } : {}),
1136
1318
  })),
1137
1319
  note: 'Applicability reflects the cited evidence as last fetched. Inspect monitoring health for source outages.',
1138
1320
  });
package/dist/config.d.ts CHANGED
@@ -293,6 +293,28 @@ export declare const configSchema: z.ZodObject<{
293
293
  tls_key_file: z.ZodOptional<z.ZodString>;
294
294
  allow_plain_http: z.ZodDefault<z.ZodBoolean>;
295
295
  }, z.core.$strict>>;
296
+ mitigations: z.ZodOptional<z.ZodArray<z.ZodPipe<z.ZodObject<{
297
+ name: z.ZodOptional<z.ZodString>;
298
+ format: z.ZodEnum<{
299
+ generic: "generic";
300
+ shirudo: "shirudo";
301
+ }>;
302
+ file: z.ZodString;
303
+ max_age_minutes: z.ZodDefault<z.ZodNumber>;
304
+ systems: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
305
+ }, z.core.$strict>, z.ZodTransform<{
306
+ format: "generic" | "shirudo";
307
+ file: string;
308
+ max_age_minutes: number;
309
+ systems: Record<string, string>;
310
+ name: string;
311
+ }, {
312
+ name?: string | undefined;
313
+ format: "generic" | "shirudo";
314
+ file: string;
315
+ max_age_minutes: number;
316
+ systems: Record<string, string>;
317
+ }>>>>;
296
318
  maintenance: z.ZodOptional<z.ZodObject<{
297
319
  interval_hours: z.ZodDefault<z.ZodNumber>;
298
320
  retention: z.ZodOptional<z.ZodObject<{
package/dist/config.js CHANGED
@@ -260,6 +260,36 @@ export const configSchema = z
260
260
  ctx.addIssue({ code: 'custom', message: 'Each token needs its own token_env', path: ['tokens'] });
261
261
  })
262
262
  .optional(),
263
+ mitigations: z
264
+ .array(z
265
+ .object({
266
+ name: z
267
+ .string()
268
+ .trim()
269
+ .min(1)
270
+ .max(40)
271
+ .regex(/^[^\u0000-\u001f\u007f-\u009f\u200b-\u200f\u2028-\u202e\u2066-\u2069\ufeff]+$/, 'Use a short single-line name')
272
+ .optional(),
273
+ format: z.enum(['shirudo', 'generic']),
274
+ file: z.string().trim().min(1).max(4096),
275
+ max_age_minutes: z.number().int().min(5).max(10080).default(120),
276
+ systems: z
277
+ .record(z.string().trim().min(1).max(255), z.string().trim().min(1).max(200))
278
+ .refine((map) => Object.keys(map).length <= 1000, 'At most 1,000 system mappings')
279
+ .default({}),
280
+ })
281
+ .strict()
282
+ .transform(({ name, ...source }) => ({
283
+ ...source,
284
+ name: name ?? (source.format === 'shirudo' ? 'Shirudo' : 'Mitigations'),
285
+ })))
286
+ .max(10)
287
+ .superRefine((sources, ctx) => {
288
+ const names = sources.map((source) => source.name.toLowerCase());
289
+ if (new Set(names).size !== names.length)
290
+ ctx.addIssue({ code: 'custom', message: 'Give each mitigation source its own name' });
291
+ })
292
+ .optional(),
263
293
  maintenance: z
264
294
  .object({
265
295
  interval_hours: z.number().int().min(1).max(168).default(24),
@@ -435,6 +465,8 @@ export function loadConfig(path) {
435
465
  config.intake.tls_cert_file = resolve(dirname(resolve(path)), config.intake.tls_cert_file);
436
466
  if (config.intake?.tls_key_file)
437
467
  config.intake.tls_key_file = resolve(dirname(resolve(path)), config.intake.tls_key_file);
468
+ for (const source of config.mitigations ?? [])
469
+ source.file = resolve(dirname(resolve(path)), source.file);
438
470
  if (config.maintenance?.backup)
439
471
  config.maintenance.backup.directory = resolve(dirname(resolve(path)), config.maintenance.backup.directory);
440
472
  return config;
package/dist/cve-now.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import { compare, valid } from 'semver';
2
2
  import { cleanText, highest, timestamp } from './util.js';
3
+ import { cveNowExploitSources, shieldInputs } from './shield-inputs.js';
3
4
  import { normalizeEcosystem, normalizePackageName, packageKey } from './ecosystems.js';
4
5
  import { inventoryMatcher } from './matching.js';
5
6
  import { PartialSourceError, SourceError, SourceHttpError, SourceItemFailures, sourceCanceled, throwSourceFailure, } from './source-error.js';
@@ -238,6 +239,7 @@ function parseEntry(data, now, expected, matched) {
238
239
  exploited: knownExploited,
239
240
  malware: /^MAL-/i.test(id),
240
241
  withdrawn: data.status !== 'published',
242
+ ...shieldInputs({ exploit_sources: cveNowExploitSources(exploitation) }),
241
243
  modified_at: modified,
242
244
  fetched_at: timestamp(now),
243
245
  ...(published ? { published_at: published } : {}),
package/dist/delivery.js CHANGED
@@ -305,6 +305,34 @@ function epssLine(a) {
305
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
306
  ];
307
307
  }
308
+ /** Runtime mitigation status from the operator's exports, when configured. Shown only. */
309
+ function mitigationLines(a) {
310
+ const statuses = Array.isArray(a.mitigations) ? a.mitigations : [];
311
+ const lines = statuses.slice(0, 3).flatMap((status) => {
312
+ if (!status || typeof status.summary !== 'string')
313
+ return [];
314
+ const when = Date.parse(status.exported_at);
315
+ const at = Number.isFinite(when)
316
+ ? new Date(when).toISOString().slice(0, 16).replace('T', ' ')
317
+ : 'unknown time';
318
+ // The export time, an out-of-date mark and the reminder come before the mitigation names, which
319
+ // are the operator's free text and are shortened on their own, so they can never push those out.
320
+ // A mitigation that expires is covered only until then; a digest read later must say so.
321
+ const expires = typeof status.expires_at === 'string' ? Date.parse(status.expires_at) : Number.NaN;
322
+ const until = Number.isFinite(expires)
323
+ ? new Date(expires).toISOString().slice(0, 16).replace('T', ' ')
324
+ : undefined;
325
+ const ids = (Array.isArray(status.mitigations) ? status.mitigations.slice(0, 3) : [])
326
+ .filter((id) => typeof id === 'string')
327
+ .map((id) => single(id, 40));
328
+ return [
329
+ single(`${single(status.summary, 260)} (export ${at} UTC${status.stale ? ', out of date' : ''}${until ? `; expires ${until} UTC` : ''}; a mitigation is temporary and does not close the finding)${ids.length ? ` In place: ${ids.join(', ')}` : ''}`, 480),
330
+ ];
331
+ });
332
+ if (statuses.length > 3)
333
+ lines.push(`${statuses.length - 3} more mitigation source(s): see explain.`);
334
+ return lines;
335
+ }
308
336
  export function notificationText(job) {
309
337
  const { assessment: a, reason } = JSON.parse(job.payload);
310
338
  const subject = single(`[${a.priority.toUpperCase()}] ${a.title}`, 180);
@@ -320,6 +348,7 @@ export function notificationText(job) {
320
348
  ...(a.exploited ? ['Known exploitation reported.'] : []),
321
349
  ...newsSignalLine(a),
322
350
  ...epssLine(a),
351
+ ...mitigationLines(a),
323
352
  `Summary: ${single(a.summary, 750)}`,
324
353
  ];
325
354
  // In the order they give way when the text is too long for one Slack section: the last of these
@@ -406,6 +435,7 @@ export function digestText(jobs) {
406
435
  `Applicability: ${single(a.applicability, 40)}; source: ${single(a.source_severity, 40)}`,
407
436
  ...newsSignalLine(a),
408
437
  ...epssLine(a),
438
+ ...mitigationLines(a),
409
439
  ...(a.news_analysis
410
440
  ? [
411
441
  `AI news: ${single(a.news_analysis.classification, 60)}; impact: ${single(a.news_analysis.impact, 60)}`,
package/dist/engine.d.ts CHANGED
@@ -65,6 +65,31 @@ export declare const evidenceSchema: z.ZodObject<{
65
65
  withdrawn: z.ZodOptional<z.ZodBoolean>;
66
66
  exploited: z.ZodOptional<z.ZodBoolean>;
67
67
  malware: z.ZodOptional<z.ZodBoolean>;
68
+ references: z.ZodOptional<z.ZodArray<z.ZodObject<{
69
+ type: z.ZodEnum<{
70
+ advisory: "advisory";
71
+ detection: "detection";
72
+ evidence: "evidence";
73
+ fix: "fix";
74
+ introduced: "introduced";
75
+ package: "package";
76
+ report: "report";
77
+ source: "source";
78
+ web: "web";
79
+ }>;
80
+ url: z.ZodURL;
81
+ }, z.core.$strict>>>;
82
+ fix_commits: z.ZodOptional<z.ZodArray<z.ZodObject<{
83
+ repo: z.ZodURL;
84
+ commit: z.ZodString;
85
+ }, z.core.$strict>>>;
86
+ weaknesses: z.ZodOptional<z.ZodArray<z.ZodString>>;
87
+ exploit_sources: z.ZodOptional<z.ZodArray<z.ZodEnum<{
88
+ "exploit-db": "exploit-db";
89
+ "github-poc": "github-poc";
90
+ metasploit: "metasploit";
91
+ nuclei: "nuclei";
92
+ }>>>;
68
93
  }, z.core.$strict>;
69
94
  export declare function readFixture(path: string): Evidence[];
70
95
  export declare function healthFinding(source: string, message: string, now?: number): Assessment;