@cclabsnz/sf-audit 1.8.1 → 1.9.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.
Files changed (77) hide show
  1. package/CHANGELOG.md +199 -0
  2. package/README.md +138 -758
  3. package/lib/chains/CapabilityRegistry.d.ts +6 -2
  4. package/lib/chains/CapabilityRegistry.js +48 -2
  5. package/lib/chains/namedChains.js +140 -7
  6. package/lib/checks/impl/AgentActionSurfaceCheck.d.ts +1 -1
  7. package/lib/checks/impl/AgentChannelExposureCheck.d.ts +1 -1
  8. package/lib/checks/impl/AgentChannelExposureCheck.js +52 -10
  9. package/lib/checks/impl/AgentInventoryCheck.d.ts +1 -1
  10. package/lib/checks/impl/AgentMonitoringCoverageCheck.d.ts +1 -1
  11. package/lib/checks/impl/AgentUserPrivilegeCheck.d.ts +1 -1
  12. package/lib/checks/impl/ApexCrudFLSCheck.d.ts +1 -1
  13. package/lib/checks/impl/ApexCrudFLSCheck.js +3 -3
  14. package/lib/checks/impl/ApexLoggingCheck.d.ts +1 -1
  15. package/lib/checks/impl/ApexRestEndpointCheck.d.ts +1 -1
  16. package/lib/checks/impl/ApexRestEndpointCheck.js +0 -3
  17. package/lib/checks/impl/ApexSharingCheck.d.ts +1 -1
  18. package/lib/checks/impl/CodeSecurityCheck.d.ts +1 -1
  19. package/lib/checks/impl/ConnectedAppInactivityCheck.d.ts +1 -1
  20. package/lib/checks/impl/ConnectedAppsCheck.d.ts +1 -1
  21. package/lib/checks/impl/CspTrustedSitesCheck.d.ts +1 -1
  22. package/lib/checks/impl/CustomLabelsCredentialCheck.js +1 -1
  23. package/lib/checks/impl/DataClassificationCheck.js +15 -1
  24. package/lib/checks/impl/DeploymentIdentityCheck.d.ts +1 -1
  25. package/lib/checks/impl/EventMonitoringCheck.d.ts +1 -1
  26. package/lib/checks/impl/FailedLoginCheck.js +16 -1
  27. package/lib/checks/impl/FieldLevelSecurityCheck.js +29 -16
  28. package/lib/checks/impl/GuestExecutableApexCheck.d.ts +1 -1
  29. package/lib/checks/impl/GuestTrafficAnomalyCheck.d.ts +1 -1
  30. package/lib/checks/impl/GuestUserAccessCheck.d.ts +1 -1
  31. package/lib/checks/impl/GuestUserVisibilityCheck.d.ts +35 -0
  32. package/lib/checks/impl/GuestUserVisibilityCheck.js +168 -0
  33. package/lib/checks/impl/HardcodedCredentialsCheck.d.ts +2 -2
  34. package/lib/checks/impl/HardcodedCredentialsCheck.js +0 -1
  35. package/lib/checks/impl/HealthCheckCheck.d.ts +1 -1
  36. package/lib/checks/impl/HealthCheckCheck.js +1 -3
  37. package/lib/checks/impl/IntegrationLeastPrivilegeCheck.d.ts +42 -0
  38. package/lib/checks/impl/IntegrationLeastPrivilegeCheck.js +467 -0
  39. package/lib/checks/impl/IntegrationUsersCheck.js +48 -52
  40. package/lib/checks/impl/InternalUserMfaCheck.js +0 -1
  41. package/lib/checks/impl/IpRestrictionsCheck.js +39 -5
  42. package/lib/checks/impl/MfaMethodStrengthCheck.d.ts +1 -1
  43. package/lib/checks/impl/MfaRegistrationCheck.d.ts +1 -1
  44. package/lib/checks/impl/NamedCredentialsCheck.d.ts +1 -1
  45. package/lib/checks/impl/PrivilegedAccessCheck.d.ts +1 -1
  46. package/lib/checks/impl/PublicGroupSharingCheck.d.ts +1 -1
  47. package/lib/checks/impl/PublicGroupSharingCheck.js +21 -2
  48. package/lib/checks/impl/RemoteSitesCheck.d.ts +1 -1
  49. package/lib/checks/impl/ScheduledApexCheck.d.ts +1 -1
  50. package/lib/checks/impl/ScheduledApexCheck.js +0 -1
  51. package/lib/checks/impl/SeparationOfDutiesCheck.d.ts +1 -1
  52. package/lib/checks/impl/SessionHardeningCheck.d.ts +1 -1
  53. package/lib/checks/impl/SiemIntegrationCheck.d.ts +1 -1
  54. package/lib/checks/impl/SoapLoginApiAuthCheck.d.ts +10 -0
  55. package/lib/checks/impl/SoapLoginApiAuthCheck.js +151 -0
  56. package/lib/checks/impl/SsoEnforcementCheck.js +0 -1
  57. package/lib/checks/impl/TrustedUrlHygieneCheck.d.ts +1 -1
  58. package/lib/checks/impl/TrustedUrlHygieneCheck.js +3 -1
  59. package/lib/checks/impl/VisualforceXssCheck.d.ts +1 -1
  60. package/lib/checks/registry.js +4 -0
  61. package/lib/checks/support/integrationAccounts.d.ts +35 -0
  62. package/lib/checks/support/integrationAccounts.js +209 -0
  63. package/lib/commands/audit/security.d.ts +12 -1
  64. package/lib/commands/audit/security.js +32 -9
  65. package/lib/compliance/catalogs/gdpr.d.ts +3 -0
  66. package/lib/compliance/catalogs/gdpr.js +54 -0
  67. package/lib/compliance/catalogs/hipaa.d.ts +3 -0
  68. package/lib/compliance/catalogs/hipaa.js +97 -0
  69. package/lib/compliance/catalogs/index.js +4 -0
  70. package/lib/compliance/mapping.js +111 -36
  71. package/lib/findings/CheckMeta.js +2 -0
  72. package/lib/findings/exitCode.d.ts +28 -0
  73. package/lib/findings/exitCode.js +46 -0
  74. package/lib/findings/loadScoringConfig.js +5 -5
  75. package/lib/renderers/HtmlRenderer.js +1 -1
  76. package/messages/audit.security.md +6 -0
  77. package/package.json +16 -11
package/CHANGELOG.md ADDED
@@ -0,0 +1,199 @@
1
+ # Changelog
2
+
3
+ All notable changes to `@cclabsnz/sf-audit` are recorded here. The format follows
4
+ [Keep a Changelog](https://keepachangelog.com/en/1.1.0/) loosely, and the project uses
5
+ [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
+
7
+ Each entry mirrors the [GitHub Release](https://github.com/cclabsnz/sf-audit-plugin/releases) for that tag, which is the canonical
8
+ published note and carries the signed provenance attestation and CycloneDX SBOM for the build.
9
+
10
+ ## [Unreleased]
11
+
12
+ Merged to `main`, not yet released.
13
+
14
+ ## [v1.9.0](https://github.com/cclabsnz/sf-audit-plugin/releases/tag/v1.9.0) — 2026-09-07
15
+
16
+ Two compliance catalogs, three attack chains, and a restructured documentation set — but
17
+ the reason to upgrade is the `--fail-on` fix. That flag never worked: any pipeline using it
18
+ exited 1 on every run, whatever the org looked like. If you gate CI on this plugin, this is
19
+ the release that makes the gate mean something.
20
+
21
+ ### Fixed
22
+
23
+ - **`--fail-on` fired on every audit.** The threshold comparison ranked findings with
24
+ `ORDER.indexOf(level) <= threshold`, and `INFO` is absent from that order, so it
25
+ scored `-1` — more severe than `CRITICAL` at every threshold. Because passing and
26
+ inconclusive checks both carry `INFO`, and every audit produces passes, any pipeline
27
+ using `--fail-on` exited 1 regardless of what was actually found. Gateable severities
28
+ are now matched explicitly, and passed/inconclusive findings can never be violations.
29
+
30
+ ### Added
31
+
32
+ - **`--fail-on-inconclusive`** — exit 3 when a check could not gather evidence, so CI can
33
+ tell a clean org apart from an audit user that could not see enough to judge. Off by
34
+ default. A finding at or above `--fail-on` still takes precedence and exits 1.
35
+
36
+ - **HIPAA Security Rule and GDPR compliance catalogs** — 26 source-verified controls, taking the
37
+ catalog from 93 to 119. HIPAA pins the operative 2013 Omnibus rule (the 2025 NPRM remains
38
+ proposed) and preserves each implementation specification's Required/Addressable designation;
39
+ GDPR is mapped at paragraph level. Reachable via `--frameworks hipaa`, `gdpr` or `all`, which
40
+ previously rendered nothing for either. (#75)
41
+ - **Three attack chains** — `sandbox-pii-exposure`, `insider-bulk-exfil` and
42
+ `undetected-compromise` — plus capability grants for 14 previously unmodelled findings, lifting
43
+ chain coverage from roughly 30 to 43 of the 88 checks. Guest chains now name the concrete
44
+ request path an attacker uses. (#75)
45
+
46
+ ### Fixed
47
+
48
+ - **`MessagingChannel` was never readable.** The Agentforce channel check selected a
49
+ non-existent `ChannelType` field; the resulting `INVALID_FIELD` error was swallowed by a
50
+ defensive catch, so every org reported zero messaging channels. The field is `MessageType`.
51
+ Channels of type `EmbeddedMessaging` or `WebChat` are now surfaced as public channel
52
+ candidates. (#75)
53
+
54
+ ### Changed
55
+
56
+ - **Publish workflow** installs the pinned npm with `--ignore-scripts` and asserts the resulting
57
+ version, so a lifecycle script cannot run beside the OIDC publish credential and a failed
58
+ upgrade cannot reach `npm publish`. (#76)
59
+ - **Documentation restructured.** The README is an overview (935 to 226 lines); the full check
60
+ inventory, attack chains, compliance detail, command reference and trust material moved to
61
+ `docs/`. Drift guards follow the tables they protect. (#75, #77)
62
+ - Dead code removed and unused declarations are now a compile error. (#79)
63
+
64
+ ### Removed
65
+
66
+ - `ts-node`, which was unused — Jest 30 parses `jest.config.ts` natively. (#75)
67
+
68
+ ## [v1.8.2](https://github.com/cclabsnz/sf-audit-plugin/releases/tag/v1.8.2) — 2026-08-10
69
+
70
+ Maintenance release. No user-facing behaviour changed — the check set, flags and report formats are identical to v1.8.1.
71
+
72
+ ### Security
73
+
74
+ - **js-yaml** override raised to `^3.15.1`, closing Dependabot alert #27 (high — GHSA-5p4m-2wfm-xmqj, quadratic CPU consumption in `!!omap` resolution). Development-scope transitive dependency; not in the shipped runtime. (#64)
75
+
76
+ ### Toolchain
77
+
78
+ - **TypeScript 5.9.3 → 7.0.2.** TS7 is the native compiler and no longer exposes the JavaScript compiler API ts-jest is built on, and no TS7-compatible ts-jest exists, so transforms moved to `@swc/jest`. Because swc only strips types, an explicit `pnpm run typecheck` step was added and runs ahead of jest. This also fixed a `tsconfig.test.json` config bug that had been leaving every file under `test/` out of the type-check program. (#62)
79
+ - **Pinned actions:** codeql-action v4.37.4, upload-artifact v7.0.1, action-gh-release v3.0.2. (#61)
80
+ - **@oclif/core** 4.13.0 → 4.13.2. (#54)
81
+
82
+ ### Docs
83
+
84
+ - README blog links point at the canonical `www` host. (#63)
85
+
86
+ ---
87
+
88
+ Build clean, 85 suites / 629 tests passing (including the read-only and network-egress invariants), `pnpm audit --prod --audit-level high` clean, 0 open Dependabot alerts.
89
+
90
+ ## [v1.8.1](https://github.com/cclabsnz/sf-audit-plugin/releases/tag/v1.8.1) — 2026-08-05
91
+
92
+ Metadata and documentation only. No functional change to any check, and no change to what the tool does against your org.
93
+
94
+ **npm discoverability.** The package carried no keywords at all, which made it effectively invisible to npm search. Adds 17 terms spanning the plugin ecosystem (`sf-plugin`, `sfdx-plugin`, `oclif-plugin`), the problem space (`security-audit`, `compliance`, `devsecops`) and the frameworks the tool maps findings to (`owasp`, `soc2`, `iso27001`, `nzism`). Sets `homepage` and `bugs`, which were unset, so npm now links to the README and the issue tracker. The description now states the check count, attack-chain correlation, risk grading and framework coverage, and corrects the count to 88.
95
+
96
+ **The unsigned-plugin warning is now explained at the install step.** Salesforce's signature verification only accepts public keys served from `developer.salesforce.com`, with certificate pinning to that host, so no third-party plugin can be signed for it and every community plugin produces the same prompt. Previously the README handed you an install command and let you discover that warning unaided, which is a poor first impression from a security tool. It now says why the warning appears, points at the guarantees you can verify yourself (signed npm provenance, the read-only invariant test) instead of asking for trust, and documents the `unsignedPluginAllowList.json` path for CI installs where an interactive prompt would hang the job.
97
+
98
+ ## [v1.8.0 — forensic timeline](https://github.com/cclabsnz/sf-audit-plugin/releases/tag/v1.8.0) — 2026-08-05
99
+
100
+ Adds `sf audit timeline`. Existing usage is unaffected: no command, flag or output contract
101
+ changed, the check count is the same, and the security grade is untouched.
102
+
103
+ ### `sf audit timeline`
104
+
105
+ Salesforce splits one actor's activity across event types that share no common identifier. On a
106
+ real capture, **four types carry no `CLIENT_IP` column at all** — so filtering an event log by
107
+ address finds a fraction of the activity and misses every SOQL execution. Filtering by user finds
108
+ everything the *guest* user did, which on a community is everyone.
109
+
110
+ ```bash
111
+ sf audit timeline --window yesterday --seed ip:203.0.113.50
112
+ ```
113
+
114
+ It correlates a seed across every captured event type and writes a defensible timeline —
115
+ `timeline.csv`, `timeline.json` and `summary.md`. It runs **entirely offline** against captures
116
+ written by `sf audit events pull`, so it still works long after the org's retention window has
117
+ expired or its credentials have been revoked.
118
+
119
+ ### What it refuses to do
120
+
121
+ Cross-event correlation is easy to get confidently wrong, and a wrong answer reads as evidence.
122
+
123
+ - **A blank field never joins.** A blank `REQUEST_ID` used as a key stops identifying anything and
124
+ starts matching every row whose value is also blank.
125
+ - **A shared identity is not expanded.** A community guest user can stand for hundreds of
126
+ visitors. Refused by default, with the evidence reported rather than applied quietly.
127
+
128
+ Every output leads with what was actually captured, because *"no rows matched"* means two
129
+ opposite things: the actor did nothing, or nobody captured the hour they did it in.
130
+
131
+ ### Saying when
132
+
133
+ `--window` takes `yesterday`, `today`, `2h`, `90m`, a bare date (the whole day), a bare timestamp
134
+ (the hour containing it), or an exact ISO interval. Times are UTC. Omitting `--seed` returns the
135
+ whole window uncorrelated — where you look to find something worth seeding on. Asking for an
136
+ uncaptured window lists the days that were captured.
137
+
138
+ ### Also in this release
139
+
140
+ - `@cclabsnz/sf-core` 0.3.0 — hourly and Real-Time Event capture, atomic writes
141
+ - Security overrides raised to `fast-uri` 3.1.5 and `brace-expansion` 5.0.9
142
+ - `NamedCredentialsCheck` no longer crashes, or silently matches the wrong credential, when a
143
+ label contains regular-expression metacharacters
144
+
145
+ Full documentation in the README under *Forensic timeline*.
146
+
147
+ ## [v1.7.0](https://github.com/cclabsnz/sf-audit-plugin/releases/tag/v1.7.0) — 2026-08-03
148
+
149
+ Sixty-two commits since 1.6.1. No command, flag, or output contract changed —
150
+ existing usage is unaffected.
151
+
152
+ ### Shared platform layer
153
+
154
+ Flow and Apex reads now route through `@cclabsnz/sf-core`, consumed from the
155
+ registry. Report branding, fonts and HTML utilities moved there too.
156
+
157
+ sf-core 0.1.5 declares `@salesforce/core` as a **peer** dependency rather than
158
+ bundling its own. Every reference inside it is an `import type` — 4 `.d.ts`
159
+ mentions, 0 `.js` — so a runtime dependency only ever forced a second copy into
160
+ consumers and broke type unification across a major bump. sf-core now ships with
161
+ no runtime dependencies.
162
+
163
+ ### Security
164
+
165
+ - Read-only invariant coverage restored, and a network-egress invariant added —
166
+ both enforced in CI, so "cannot write to an org" and "nothing leaves the
167
+ machine" are tested rather than asserted
168
+ - Generated reports are self-contained: no CDN fetches, so opening a report
169
+ cannot phone out
170
+ - Org-data guard repaired. Its instance-host check had been failing open: a
171
+ negative lookahead under `grep -E`, which ERE does not support, so the branch
172
+ matched nothing while the step reported clean
173
+
174
+ ### Dependencies
175
+
176
+ `@salesforce/core` 9, `@salesforce/sf-plugins-core` 13, jest 30, `@types/node` 26.
177
+
178
+ TypeScript stays at 5 — TS 7 is the native rewrite and no published ts-jest
179
+ supports it yet (latest peers `>=4.3 <7`).
180
+
181
+ ### Repository
182
+
183
+ Flattened back to a single package now that the shared layer ships from the
184
+ registry and the intel plugin has its own repository.
185
+
186
+ ## [v1.6.1](https://github.com/cclabsnz/sf-audit-plugin/releases/tag/v1.6.1) — 2026-07-26
187
+
188
+ Security + supply-chain assurance release. First release published via the hardened, OIDC pipeline.
189
+
190
+ ### Fixes
191
+ - **fix(deps):** brace-expansion pinned to `5.0.8` — resolves high-severity DoS advisory [GHSA-mh99-v99m-4gvg](https://github.com/advisories/GHSA-mh99-v99m-4gvg) reaching production via `@oclif/core`.
192
+ - **fix(security):** Enhanced Domains check now parses the hostname and uses anchored patterns, so a URL that merely contains `.my.salesforce.com` can no longer be misclassified (CodeQL `js/regex/missing-regexp-anchor`, high).
193
+
194
+ ### Supply-chain assurance
195
+ - Published via **npm Trusted Publishing (OIDC)** with **build provenance** — the npm page shows a signed attestation linking this tarball to its source commit. No long-lived token.
196
+ - **CycloneDX SBOM** attached to this release.
197
+ - CI enforces a **read-only invariant** (build fails on any org-write path), plus CodeQL, OpenSSF Scorecard, a `pnpm audit` gate, and SHA-pinned actions with least-privilege permissions.
198
+
199
+ Install: `sf plugins install @cclabsnz/sf-audit`