@cclabsnz/sf-audit 1.6.0 → 1.7.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 (182) hide show
  1. package/README.md +110 -1
  2. package/lib/apps/analyzeApps.d.ts +1 -1
  3. package/lib/apps/appResolver.d.ts +1 -1
  4. package/lib/apps/grantedAccess.d.ts +1 -1
  5. package/lib/chains/AttackChain.d.ts +1 -1
  6. package/lib/chains/namedChains.d.ts +1 -1
  7. package/lib/checks/CheckEngine.d.ts +1 -1
  8. package/lib/checks/SecurityCheck.d.ts +3 -3
  9. package/lib/checks/impl/AgentActionSurfaceCheck.d.ts +1 -1
  10. package/lib/checks/impl/AgentActionSurfaceCheck.js +1 -1
  11. package/lib/checks/impl/AgentChannelExposureCheck.d.ts +1 -1
  12. package/lib/checks/impl/AgentInventoryCheck.d.ts +1 -1
  13. package/lib/checks/impl/AgentInventoryCheck.js +1 -1
  14. package/lib/checks/impl/AgentMonitoringCoverageCheck.d.ts +1 -1
  15. package/lib/checks/impl/AgentUserPrivilegeCheck.d.ts +1 -1
  16. package/lib/checks/impl/AnonymousApexAuditCheck.d.ts +1 -1
  17. package/lib/checks/impl/ApexCrudFLSCheck.d.ts +1 -1
  18. package/lib/checks/impl/ApexLoggingCheck.d.ts +1 -1
  19. package/lib/checks/impl/ApexRestEndpointCheck.d.ts +1 -1
  20. package/lib/checks/impl/ApexSharingCheck.d.ts +1 -1
  21. package/lib/checks/impl/ApexSharingCheck.js +3 -2
  22. package/lib/checks/impl/ApiClientPermissionCheck.d.ts +1 -1
  23. package/lib/checks/impl/ApiLimitsCheck.d.ts +1 -1
  24. package/lib/checks/impl/AuditTrailCheck.d.ts +1 -1
  25. package/lib/checks/impl/AuthProvidersCheck.d.ts +1 -1
  26. package/lib/checks/impl/CertificateExpiryCheck.d.ts +1 -1
  27. package/lib/checks/impl/ClassicSitesCheck.d.ts +1 -1
  28. package/lib/checks/impl/CodeSecurityCheck.d.ts +1 -1
  29. package/lib/checks/impl/CodeSecurityCheck.js +5 -5
  30. package/lib/checks/impl/ConnectedAppInactivityCheck.d.ts +1 -1
  31. package/lib/checks/impl/ConnectedAppScopeCheck.d.ts +1 -1
  32. package/lib/checks/impl/ConnectedAppsCheck.d.ts +1 -1
  33. package/lib/checks/impl/ContentLinksCheck.d.ts +1 -1
  34. package/lib/checks/impl/CorsAllowlistCheck.d.ts +1 -1
  35. package/lib/checks/impl/CspTrustedSitesCheck.d.ts +1 -1
  36. package/lib/checks/impl/CustomLabelsCredentialCheck.d.ts +1 -1
  37. package/lib/checks/impl/CustomSettingsCheck.d.ts +1 -1
  38. package/lib/checks/impl/DataClassificationCheck.d.ts +1 -1
  39. package/lib/checks/impl/DataExportAccessCheck.d.ts +1 -1
  40. package/lib/checks/impl/DebugLogAccessCheck.d.ts +1 -1
  41. package/lib/checks/impl/DeploymentIdentityCheck.d.ts +1 -1
  42. package/lib/checks/impl/EmailSecurityCheck.d.ts +1 -1
  43. package/lib/checks/impl/EncryptionCoverageCheck.d.ts +1 -1
  44. package/lib/checks/impl/EnhancedDomainsCheck.d.ts +1 -1
  45. package/lib/checks/impl/EnhancedDomainsCheck.js +18 -4
  46. package/lib/checks/impl/EscalationPermsCheck.d.ts +1 -1
  47. package/lib/checks/impl/EventMonitoringCheck.d.ts +1 -1
  48. package/lib/checks/impl/EventMonitoringCheck.js +1 -1
  49. package/lib/checks/impl/ExperienceCloudSiteCheck.d.ts +1 -1
  50. package/lib/checks/impl/ExperienceCspCheck.d.ts +1 -1
  51. package/lib/checks/impl/ExternalCredentialsCheck.d.ts +1 -1
  52. package/lib/checks/impl/FailedLoginCheck.d.ts +1 -1
  53. package/lib/checks/impl/FieldHistoryTrackingCheck.d.ts +1 -1
  54. package/lib/checks/impl/FieldLevelSecurityCheck.d.ts +1 -1
  55. package/lib/checks/impl/FlowsWithoutSharingCheck.d.ts +1 -1
  56. package/lib/checks/impl/FlowsWithoutSharingCheck.js +10 -9
  57. package/lib/checks/impl/GuestApiAccessCheck.d.ts +1 -1
  58. package/lib/checks/impl/GuestExecutableApexCheck.d.ts +1 -1
  59. package/lib/checks/impl/GuestExecutableApexCheck.js +4 -3
  60. package/lib/checks/impl/GuestObjectExposureCheck.d.ts +1 -1
  61. package/lib/checks/impl/GuestRecordAccessPolicyCheck.d.ts +1 -1
  62. package/lib/checks/impl/GuestSiteOptionsCheck.d.ts +1 -1
  63. package/lib/checks/impl/GuestTrafficAnomalyCheck.d.ts +1 -1
  64. package/lib/checks/impl/GuestTrafficAnomalyCheck.js +1 -1
  65. package/lib/checks/impl/GuestUserAccessCheck.d.ts +1 -1
  66. package/lib/checks/impl/HardcodedCredentialsCheck.d.ts +1 -1
  67. package/lib/checks/impl/HardcodedCredentialsCheck.js +8 -1
  68. package/lib/checks/impl/HealthCheckCheck.d.ts +1 -1
  69. package/lib/checks/impl/HighAssuranceSessionCheck.d.ts +1 -1
  70. package/lib/checks/impl/InactiveUsersCheck.d.ts +1 -1
  71. package/lib/checks/impl/InstalledPackagesCheck.d.ts +1 -1
  72. package/lib/checks/impl/IntegrationUsersCheck.d.ts +1 -1
  73. package/lib/checks/impl/InternalUserMfaCheck.d.ts +1 -1
  74. package/lib/checks/impl/IpRestrictionsCheck.d.ts +1 -1
  75. package/lib/checks/impl/LegacyApiVersionCheck.d.ts +1 -1
  76. package/lib/checks/impl/LoginAccessPolicyCheck.d.ts +1 -1
  77. package/lib/checks/impl/LoginAnomalyCheck.d.ts +1 -1
  78. package/lib/checks/impl/LoginSessionCheck.d.ts +1 -1
  79. package/lib/checks/impl/MfaEnforcementCheck.d.ts +1 -1
  80. package/lib/checks/impl/MfaMethodStrengthCheck.d.ts +1 -1
  81. package/lib/checks/impl/MfaRegistrationCheck.d.ts +1 -1
  82. package/lib/checks/impl/MyDomainLoginPolicyCheck.d.ts +1 -1
  83. package/lib/checks/impl/NamedCredentialsCheck.d.ts +1 -1
  84. package/lib/checks/impl/NamedCredentialsCheck.js +7 -6
  85. package/lib/checks/impl/OutboundMessagesCheck.d.ts +1 -1
  86. package/lib/checks/impl/PasswordSessionPolicyCheck.d.ts +2 -2
  87. package/lib/checks/impl/PermissionsCheck.d.ts +1 -1
  88. package/lib/checks/impl/PrivilegedAccessCheck.d.ts +1 -1
  89. package/lib/checks/impl/PublicContentExposureCheck.d.ts +1 -1
  90. package/lib/checks/impl/PublicGroupSharingCheck.d.ts +1 -1
  91. package/lib/checks/impl/ReleaseUpdatesCheck.d.ts +1 -1
  92. package/lib/checks/impl/RemoteSitesCheck.d.ts +1 -1
  93. package/lib/checks/impl/ReportFolderAccessCheck.d.ts +1 -1
  94. package/lib/checks/impl/SandboxDataMaskingCheck.d.ts +1 -1
  95. package/lib/checks/impl/ScheduledApexCheck.d.ts +1 -1
  96. package/lib/checks/impl/SeparationOfDutiesCheck.d.ts +1 -1
  97. package/lib/checks/impl/SessionHardeningCheck.d.ts +1 -1
  98. package/lib/checks/impl/SharingModelCheck.d.ts +1 -1
  99. package/lib/checks/impl/SiemIntegrationCheck.d.ts +1 -1
  100. package/lib/checks/impl/SsoEnforcementCheck.d.ts +1 -1
  101. package/lib/checks/impl/StandardProfilesCheck.d.ts +1 -1
  102. package/lib/checks/impl/ThreatDetectionCheck.d.ts +1 -1
  103. package/lib/checks/impl/TransactionSecurityPolicyCheck.d.ts +1 -1
  104. package/lib/checks/impl/TrustedIPRangesCheck.d.ts +1 -1
  105. package/lib/checks/impl/TrustedUrlHygieneCheck.d.ts +1 -1
  106. package/lib/checks/impl/UsersAndAdminsCheck.d.ts +1 -1
  107. package/lib/checks/impl/VisualforceXssCheck.d.ts +1 -1
  108. package/lib/commands/audit/events/pull.d.ts +1 -1
  109. package/lib/commands/audit/events/pull.js +3 -3
  110. package/lib/commands/audit/security.js +3 -1
  111. package/lib/findings/AuditResult.d.ts +1 -1
  112. package/lib/findings/Finding.d.ts +1 -1
  113. package/lib/findings/ScoringConfig.d.ts +9 -217
  114. package/lib/findings/scoring.d.ts +2 -2
  115. package/lib/findings/scoring.js +1 -1
  116. package/lib/history/AuditDiff.d.ts +1 -1
  117. package/lib/history/metricMeta.d.ts +1 -1
  118. package/lib/index.d.ts +2 -2
  119. package/lib/lib/wire.d.ts +6 -6
  120. package/lib/lib/wire.js +4 -4
  121. package/lib/renderers/ClientReportRenderer.d.ts +1 -1
  122. package/lib/renderers/ClientReportRenderer.js +6 -3
  123. package/lib/renderers/HistoryRenderer.js +2 -1
  124. package/lib/renderers/HtmlRenderer.js +3 -4
  125. package/lib/renderers/MarkdownRenderer.js +1 -1
  126. package/lib/renderers/chartAsset.d.ts +12 -0
  127. package/lib/renderers/chartAsset.js +25 -0
  128. package/package.json +26 -28
  129. package/lib/api/ApiError.d.ts +0 -6
  130. package/lib/api/ApiError.js +0 -6
  131. package/lib/api/MetadataClient.d.ts +0 -4
  132. package/lib/api/MetadataClient.js +0 -2
  133. package/lib/api/MetadataClientImpl.d.ts +0 -8
  134. package/lib/api/MetadataClientImpl.js +0 -22
  135. package/lib/api/RestClient.d.ts +0 -6
  136. package/lib/api/RestClient.js +0 -2
  137. package/lib/api/RestClientImpl.d.ts +0 -10
  138. package/lib/api/RestClientImpl.js +0 -45
  139. package/lib/api/SoqlClient.d.ts +0 -10
  140. package/lib/api/SoqlClient.js +0 -2
  141. package/lib/api/SoqlClientImpl.d.ts +0 -9
  142. package/lib/api/SoqlClientImpl.js +0 -19
  143. package/lib/api/ToolingClient.d.ts +0 -5
  144. package/lib/api/ToolingClient.js +0 -2
  145. package/lib/api/ToolingClientImpl.d.ts +0 -10
  146. package/lib/api/ToolingClientImpl.js +0 -29
  147. package/lib/api/index.d.ts +0 -9
  148. package/lib/api/index.js +0 -5
  149. package/lib/checks/eventLogAccess.d.ts +0 -14
  150. package/lib/checks/eventLogAccess.js +0 -33
  151. package/lib/context/AuditCache.d.ts +0 -78
  152. package/lib/context/AuditCache.js +0 -2
  153. package/lib/context/AuditContext.d.ts +0 -19
  154. package/lib/context/AuditContext.js +0 -2
  155. package/lib/context/OrgInfo.d.ts +0 -9
  156. package/lib/context/OrgInfo.js +0 -2
  157. package/lib/context/OrgMetrics.d.ts +0 -20
  158. package/lib/context/OrgMetrics.js +0 -20
  159. package/lib/events/EventBaselineStore.d.ts +0 -16
  160. package/lib/events/EventBaselineStore.js +0 -55
  161. package/lib/events/eventLogQuery.d.ts +0 -21
  162. package/lib/events/eventLogQuery.js +0 -34
  163. package/lib/events/pullEventLogs.d.ts +0 -51
  164. package/lib/events/pullEventLogs.js +0 -79
  165. package/lib/findings/ComplianceMapping.d.ts +0 -3
  166. package/lib/findings/ComplianceMapping.js +0 -75
  167. package/lib/findings/RiskLevel.d.ts +0 -3
  168. package/lib/findings/RiskLevel.js +0 -2
  169. package/lib/queries/QueryDefinition.d.ts +0 -48
  170. package/lib/queries/QueryDefinition.js +0 -11
  171. package/lib/queries/QueryRegistry.d.ts +0 -13
  172. package/lib/queries/QueryRegistry.js +0 -93
  173. package/lib/renderers/html-utils.d.ts +0 -2
  174. package/lib/renderers/html-utils.js +0 -8
  175. package/lib/report/branding.d.ts +0 -18
  176. package/lib/report/branding.js +0 -19
  177. package/lib/report/fonts.d.ts +0 -2
  178. package/lib/report/fonts.js +0 -22
  179. package/src/assets/fonts/dm-sans-italic-latin.woff2 +0 -0
  180. package/src/assets/fonts/dm-sans-normal-latin.woff2 +0 -0
  181. package/src/assets/fonts/dm-serif-display-italic-latin.woff2 +0 -0
  182. package/src/assets/fonts/dm-serif-display-normal-latin.woff2 +0 -0
package/README.md CHANGED
@@ -1,5 +1,17 @@
1
+ <p align="center">
2
+ <a href="https://cloudcounsel.co.nz"><img src="https://raw.githubusercontent.com/cclabsnz/sf-audit-plugin/main/assets/cloudcounsel-lockup.png" width="240" alt="CloudCounsel Ltd" /></a>
3
+ </p>
4
+
1
5
  # @cclabsnz/sf-audit
2
6
 
7
+ [![CI](https://github.com/cclabsnz/sf-audit-plugin/actions/workflows/ci.yml/badge.svg)](https://github.com/cclabsnz/sf-audit-plugin/actions/workflows/ci.yml)
8
+ [![CodeQL](https://github.com/cclabsnz/sf-audit-plugin/actions/workflows/codeql.yml/badge.svg)](https://github.com/cclabsnz/sf-audit-plugin/actions/workflows/codeql.yml)
9
+ [![Semgrep](https://github.com/cclabsnz/sf-audit-plugin/actions/workflows/semgrep.yml/badge.svg)](https://github.com/cclabsnz/sf-audit-plugin/actions/workflows/semgrep.yml)
10
+ [![OpenSSF Scorecard](https://api.securityscorecards.dev/projects/github.com/cclabsnz/sf-audit-plugin/badge)](https://securityscorecards.dev/viewer/?uri=github.com/cclabsnz/sf-audit-plugin)
11
+ [![npm version](https://img.shields.io/npm/v/@cclabsnz/sf-audit)](https://www.npmjs.com/package/@cclabsnz/sf-audit)
12
+ [![npm provenance](https://img.shields.io/badge/npm-signed%20provenance-brightgreen)](https://www.npmjs.com/package/@cclabsnz/sf-audit#provenance)
13
+ [![License: Apache-2.0](https://img.shields.io/badge/license-Apache--2.0-blue.svg)](LICENSE)
14
+
3
15
  A Salesforce CLI (`sf`) plugin that runs a complete, **read-only** security audit against any Salesforce org, risk-scores it with an A–F grade, and turns the result into a report your security team (or your client's) can act on.
4
16
 
5
17
  - **88 read-only checks** across identity, access, data, code, integrations, monitoring, and Agentforce / GenAI
@@ -279,7 +291,7 @@ Findings are mapped to controls across eight security and privacy frameworks. Th
279
291
 
280
292
  > **Not an attestation.** A control rendering "No findings detected" means this audit's checks surfaced no issues mapped to it. It is **not** a statement of compliance or certification. See [Scope & Liability](#scope--liability).
281
293
 
282
- **Further reading:** [Mapping Salesforce security to NZISM, the NZ Privacy Act and ISO 27001](https://www.softwareinsights.dev/posts/salesforce-security-nzism-nz-privacy-act) and [Why Salesforce Health Cloud needs its own security review](https://www.softwareinsights.dev/posts/salesforce-health-cloud-security-review).
294
+ **Further reading:** [Mapping Salesforce security to NZISM, the NZ Privacy Act and ISO 27001](https://softwareinsights.dev/posts/salesforce-security-nzism-nz-privacy-act/) and [Why Salesforce Health Cloud needs its own security review](https://softwareinsights.dev/posts/salesforce-health-cloud-security-review/). More in [Further reading](#further-reading).
283
295
 
284
296
  ## Scope & Liability
285
297
 
@@ -294,6 +306,56 @@ Findings are mapped to controls across eight security and privacy frameworks. Th
294
306
 
295
307
  **No warranty.** This software is provided "as is", without warranty of any kind, express or implied. To the maximum extent permitted by law, the authors and CloudCounsel Limited accept no liability for any loss, damage, or claim arising from use of this tool or reliance on its output. Findings are informational and should be validated by a qualified Salesforce security practitioner before any remediation action is taken.
296
308
 
309
+ ## Trust & verification
310
+
311
+ Because this tool authenticates against production orgs, "is it safe to run?" deserves a verifiable answer, not just a claim. Here's how you can check for yourself:
312
+
313
+ - **Read-only, enforced in CI.** The "no writes to your org" promise is a passing test, not a footnote. `test/unit/invariants/readonly-invariant.test.ts` statically scans this package's entire source tree and fails the build if any jsforce mutation API, HTTP write verb, or bulk/composite write path ever appears. Every org request funnels through the core clients (`@cclabsnz/sf-core`, `src/api/*ClientImpl.ts`), which issue only SOQL queries, REST **GET**s, and Metadata reads. Each package in the monorepo runs the same guard against its own source, so nothing is covered by omission.
314
+ - **Nothing phones home, enforced the same way.** `test/unit/invariants/network-egress.test.ts` fails the build on any third-party HTTP client, raw `node:http`/`https` use, telemetry/analytics/LLM endpoint, or websocket — and on any remote asset (`<script src>`, `<link href>`, `@import`) in a generated report. The only network destination is the org you authenticated against. Generated HTML reports are **fully self-contained**: webfonts are embedded as data URIs and Chart.js is inlined, so opening a report never calls out to a CDN — which matters, because reports carry sensitive findings and are often opened offline. Run both guards yourself:
315
+
316
+ ```bash
317
+ pnpm --filter @cclabsnz/sf-audit test test/unit/invariants
318
+ ```
319
+ - **What you install matches the public source.** Releases are published from GitHub Actions via [npm trusted publishing (OIDC)](https://docs.npmjs.com/trusted-publishers) with [build provenance](https://docs.npmjs.com/generating-provenance-statements) — no long-lived token, and the npm page shows a signed attestation linking the tarball to the exact public commit that built it. Verify it yourself:
320
+
321
+ ```bash
322
+ npm audit signatures # reports "verified attestations" for @cclabsnz/sf-audit
323
+ ```
324
+
325
+ - **Independent scans on every change.** Two static-analysis engines — [CodeQL](https://github.com/cclabsnz/sf-audit-plugin/security/code-scanning) (`security-extended`, of both the source **and** the CI workflows) and [Semgrep](https://github.com/cclabsnz/sf-audit-plugin/actions/workflows/semgrep.yml) (OWASP Top 10 + security-audit rulesets) — an [OpenSSF Scorecard](https://securityscorecards.dev/viewer/?uri=github.com/cclabsnz/sf-audit-plugin) supply-chain review, a PR **dependency-review** gate (vulnerabilities **and** a copyleft-license policy), and a `pnpm audit` gate — plus Dependabot, and GitHub secret scanning with push protection. All GitHub Actions are pinned to commit SHAs. Each release ships a CycloneDX **SBOM**.
326
+ - **Regulated-environment readiness.** The above give reviewers a paper trail for procurement: SBOM per release, an enforced dependency **license policy**, signed provenance, and independent SAST/supply-chain scans.
327
+ - **Least privilege & disclosure.** See [PERMISSIONS.md](PERMISSIONS.md) for the minimal access it needs and [SECURITY.md](SECURITY.md) for private vulnerability reporting.
328
+
329
+ ### What third-party scanners flag, and why
330
+
331
+ [Socket](https://socket.dev/npm/package/@cclabsnz/sf-audit) raises two **supply-chain risk** alerts against this package. Neither is a vulnerability — both are behavioural heuristics — and rather than suppress them quietly, here is exactly what triggers each and how you can confirm it. The triage is committed as [`socket.yml`](../../socket.yml).
332
+
333
+ | Alert | What triggers it | Why it is expected |
334
+ | --- | --- | --- |
335
+ | **Filesystem access** | `node:fs` reads and writes | It is a CLI that writes your audit reports (HTML/MD/JSON) to disk and reads local inputs: report-branding overrides, event-log baselines under `~/.sf/audit-history`, and its own history archive. Every path is one you pass on the command line or the tool's own dot-directory. |
336
+ | **URL strings** | `https://` literals in the shipped code | These are inert citation links rendered as `<a href>` in reports — OWASP, NZISM, the NZ Privacy Act, Te Whatu Ora and CIS-style benchmark references cited by compliance findings. They are never fetched. |
337
+
338
+ Check the second one yourself — this lists every URL in the published build:
339
+
340
+ ```bash
341
+ npm pack @cclabsnz/sf-audit && tar xzf cclabsnz-sf-audit-*.tgz
342
+ grep -rhoE 'https?://[a-zA-Z0-9][a-zA-Z0-9.-]*\.[a-zA-Z]{2,}[^"'"'"'`,;) ]*' package/lib | sort -u
343
+ ```
344
+
345
+ As of v1.6.1 that prints seven results, every one a standards-body or documentation link:
346
+
347
+ ```
348
+ https://docs.securitybenchmark.org/controls-at-a-glance.html
349
+ https://genai.owasp.org/llm-top-10/
350
+ https://nzism.gcsb.govt.nz/ism-document
351
+ https://owasp.org/Top10/2021/
352
+ https://privacy.org.nz/privacy-act-2020/privacy-principles/
353
+ https://www.legislation.govt.nz/act/public/2020/0031/latest/LMS23342.html
354
+ https://www.tewhatuora.govt.nz/health-services-and-programmes/cyber-hub/cyber-standards
355
+ ```
356
+
357
+ No CDN, telemetry, or analytics endpoints — and the network-egress invariant above fails the build if one is ever added.
358
+
297
359
  ## Scoring
298
360
 
299
361
  Each finding is assigned a risk level with a corresponding weight:
@@ -582,3 +644,50 @@ npm test # run all tests
582
644
  npm run test:unit # unit tests only
583
645
  npm run clean # remove compiled output
584
646
  ```
647
+
648
+ Maintainers: see **[docs/RELEASE.md](docs/RELEASE.md)** for the release checklist and the one-time repository-hardening steps (npm provenance token, branch protection, and the CodeQL / Scorecard setup behind the badges above).
649
+
650
+ ## Further reading
651
+
652
+ Deep dives on this tool and the topics it checks, from our engineering blog **[softwareinsights.dev](https://softwareinsights.dev)**.
653
+
654
+ **How the commands work:**
655
+
656
+ - [How sf-audit works — checks, attack chains, and compliance mapping](https://softwareinsights.dev/posts/sf-audit-61-checks-attack-chains-compliance-mapping/) — the design walkthrough behind `sf audit security`
657
+ - [Free Salesforce Event Monitoring: a baseline from EventLogFile without Shield](https://softwareinsights.dev/posts/salesforce-free-event-monitoring-eventlogfile-baseline/) — why [`sf audit events pull`](#free-event-baseline) exists and how to cron it
658
+ - [Which connected apps use less than they're granted? Ask your own logs](https://softwareinsights.dev/posts/salesforce-connected-app-least-privilege-granted-vs-used/) — the granted-vs-used method behind [`sf audit apps`](#connected-app-least-privilege)
659
+ - [Scanner or breach? Triage EventLogFile in one command](https://softwareinsights.dev/posts/salesforce-eventlogfile-guest-traffic-triage-scanner-or-breach/) — pairing an `events pull` baseline with the [sfelf-triage](https://github.com/cclabsnz/sfelf-triage) companion
660
+ - [Salesforce guest user exposure, graded by real reachability](https://softwareinsights.dev/posts/sf-audit-guest-user-exposure-reachability/) — the UI-API reachability tiering behind the [guest checks](#guest--external-facing-access)
661
+ - [sf-audit vs sf-cli-security-audit](https://softwareinsights.dev/posts/sf-audit-vs-sf-cli-security-audit/) — how this plugin differs from a configurable policy engine, and when to reach for each
662
+
663
+ **The access model the privilege checks encode** — the reasoning behind [Users, Permissions & Privilege](#users-permissions--privilege):
664
+
665
+ - [Why your developers don't need Modify All Data](https://softwareinsights.dev/posts/salesforce-developers-modify-all-data-what-they-need-instead/) — part 1 of a four-part series on delivery-team access; feeds Users & Admins and Privileged Access & Shadow Admins
666
+ - [The access model: tiers and roles](https://softwareinsights.dev/posts/salesforce-delivery-team-access-model-tiers-and-roles/) — the tiering that Separation of Duties and Privilege Escalation Permissions test against
667
+ - [Sizing the model to your team](https://softwareinsights.dev/posts/salesforce-access-model-sizing-internal-vs-external-admin-teams/) — internal vs external admins, and what the model costs to run
668
+ - [Deployable permission sets](https://softwareinsights.dev/posts/salesforce-delivery-team-deployable-permission-sets/) — the metadata and the CI identity, which the Integration / Service Accounts check inventories
669
+
670
+ **Platform changes the checks track:**
671
+
672
+ - [Hardening Agentforce against prompt injection (post-ForcedLeak)](https://softwareinsights.dev/posts/salesforce-agentforce-forcedleak-prompt-injection-hardening/) — feeds the Agentforce / GenAI checks
673
+ - [Audit your Agentforce footprint: every agent, agent user, and permission](https://softwareinsights.dev/posts/salesforce-agentforce-footprint-audit/) — the manual SOQL behind Agent Inventory
674
+ - [Agentforce agent user least privilege](https://softwareinsights.dev/posts/salesforce-agentforce-agent-user-least-privilege/) — feeds the Agent User Privilege check
675
+ - [Salesforce MFA enforcement: the revised 2026 dates](https://softwareinsights.dev/posts/salesforce-mfa-enforcement-paused-revised-dates-2026/) — feeds the MFA checks
676
+ - [The MFA enforcement admin guide](https://softwareinsights.dev/posts/salesforce-mfa-enforcement-2026-admin-guide/) — what the MFA Enforcement / Registration / Method Strength checks are measuring against
677
+ - [MFA lockout recovery and break-glass accounts](https://softwareinsights.dev/posts/salesforce-mfa-lockout-recovery-break-glass-accounts/) — the operational side of the MFA and High Assurance Session checks
678
+ - [OAuth username-password (ROPC) flow retirement in Winter '27](https://softwareinsights.dev/posts/salesforce-oauth-username-password-flow-retirement-winter-27/) — feeds the SSO Enforcement and Connected App OAuth Scopes checks
679
+ - [Email change verification retirement and Authorized Email Domains](https://softwareinsights.dev/posts/salesforce-email-change-verification-retirement-authorized-email-domains/) — feeds the Email Security check
680
+ - [Summer '26: SAML retirement & Apex secure-by-default](https://softwareinsights.dev/posts/salesforce-summer-26-saml-retirement-apex-secure-by-default/) — feeds the SSO / Apex checks
681
+ - [Salesforce security enforcement in 2026 — every change and date](https://softwareinsights.dev/posts/salesforce-security-enforcement-2026-complete-guide/) — the overall posture this tool measures
682
+ - [Report-export step-up enforcement: known issues](https://softwareinsights.dev/posts/salesforce-transaction-security-policy-report-export-known-issues/) — feeds the data-export / transaction-security checks
683
+
684
+ **Compliance and NZ context** — background for the [framework mappings](#compliance-frameworks):
685
+
686
+ - [Mapping Salesforce security to NZISM, the NZ Privacy Act and ISO 27001](https://softwareinsights.dev/posts/salesforce-security-nzism-nz-privacy-act/)
687
+ - [Data sovereignty for New Zealand Salesforce orgs](https://softwareinsights.dev/posts/salesforce-data-sovereignty-new-zealand/) — residency vs sovereignty, and why the `nz` framework pack exists
688
+ - [IPP 3A indirect collection notices](https://softwareinsights.dev/posts/salesforce-nz-privacy-ipp3a-indirect-collection-notice/) — feeds the NZ Privacy Act control mappings
689
+ - [Why Salesforce Health Cloud needs its own security review](https://softwareinsights.dev/posts/salesforce-health-cloud-security-review/) — the HISO 10029 context
690
+
691
+ ## Commercial support
692
+
693
+ `sf-audit` is free and open source. If you'd like hands-on help — interpreting findings, prioritising remediation, or a full Salesforce security and architecture review — **[CloudCounsel](https://cloudcounsel.co.nz)**, the team behind this plugin, offers Salesforce security consulting. Reach us at [hello@cloudcounsel.co.nz](mailto:hello@cloudcounsel.co.nz).
@@ -1,5 +1,5 @@
1
1
  import type { AppFinding } from './types.js';
2
- import type { SoqlClient } from '../api/SoqlClient.js';
2
+ import type { SoqlClient } from '@cclabsnz/sf-core';
3
3
  export declare function analyzeApps(restApiCsv: string, soql: SoqlClient, opts: {
4
4
  since: number;
5
5
  soakDays: number;
@@ -1,4 +1,4 @@
1
1
  import type { ResolvedApp } from './types.js';
2
- import type { SoqlClient } from '../api/SoqlClient.js';
2
+ import type { SoqlClient } from '@cclabsnz/sf-core';
3
3
  export declare function resolveApps(appIds: string[], soql: SoqlClient, userIds: string[]): Promise<ResolvedApp[]>;
4
4
  //# sourceMappingURL=appResolver.d.ts.map
@@ -1,4 +1,4 @@
1
1
  import type { GrantedAccess } from './types.js';
2
- import type { SoqlClient } from '../api/SoqlClient.js';
2
+ import type { SoqlClient } from '@cclabsnz/sf-core';
3
3
  export declare function computeGranted(appId: string, runAsUsers: string[], soql: SoqlClient, scope: string | null): Promise<GrantedAccess>;
4
4
  //# sourceMappingURL=grantedAccess.d.ts.map
@@ -1,4 +1,4 @@
1
- import type { RiskLevel } from '../findings/RiskLevel.js';
1
+ import type { RiskLevel } from '@cclabsnz/sf-core';
2
2
  import type { Capability } from './Capability.js';
3
3
  export interface AttackChainStep {
4
4
  findingId: string;
@@ -1,4 +1,4 @@
1
- import type { RiskLevel } from '../findings/RiskLevel.js';
1
+ import type { RiskLevel } from '@cclabsnz/sf-core';
2
2
  import type { Finding } from '../findings/Finding.js';
3
3
  import type { Capability } from './Capability.js';
4
4
  export interface NamedChainDef {
@@ -1,5 +1,5 @@
1
1
  import type { SecurityCheck } from './SecurityCheck.js';
2
- import type { AuditContext } from '../context/AuditContext.js';
2
+ import type { AuditContext } from '@cclabsnz/sf-core';
3
3
  import type { AuditResult } from '../findings/AuditResult.js';
4
4
  import type { ScoringConfig } from '../findings/ScoringConfig.js';
5
5
  export declare class CheckEngine {
@@ -1,7 +1,7 @@
1
- import type { AuditContext } from '../context/AuditContext.js';
1
+ import type { AuditContext } from '@cclabsnz/sf-core';
2
2
  import type { Finding } from '../findings/Finding.js';
3
- import type { AuditCache } from '../context/AuditCache.js';
4
- import type { OrgMetrics } from '../context/OrgMetrics.js';
3
+ import type { AuditCache } from '@cclabsnz/sf-core';
4
+ import type { OrgMetrics } from '@cclabsnz/sf-core';
5
5
  export interface CheckResult {
6
6
  findings: Finding[];
7
7
  metrics?: Partial<OrgMetrics>;
@@ -1,4 +1,4 @@
1
- import type { AuditContext } from '../../context/AuditContext.js';
1
+ import type { AuditContext } from '@cclabsnz/sf-core';
2
2
  import type { SecurityCheck, CheckResult } from '../SecurityCheck.js';
3
3
  export declare class AgentActionSurfaceCheck implements SecurityCheck {
4
4
  readonly id = "agent-action-surface";
@@ -1,4 +1,4 @@
1
- import { isApiError } from '../../api/ApiError.js';
1
+ import { isApiError } from '@cclabsnz/sf-core';
2
2
  // An agent carrying more than this many actions has a large, hard-to-review surface. Info
3
3
  // only — a big surface is not a vulnerability by itself, but it is worth surfacing.
4
4
  const ACTION_COUNT_THRESHOLD = 15;
@@ -1,4 +1,4 @@
1
- import type { AuditContext } from '../../context/AuditContext.js';
1
+ import type { AuditContext } from '@cclabsnz/sf-core';
2
2
  import type { SecurityCheck, CheckResult } from '../SecurityCheck.js';
3
3
  export declare class AgentChannelExposureCheck implements SecurityCheck {
4
4
  readonly id = "agent-channel-exposure";
@@ -1,4 +1,4 @@
1
- import type { AuditContext } from '../../context/AuditContext.js';
1
+ import type { AuditContext } from '@cclabsnz/sf-core';
2
2
  import type { SecurityCheck, CheckResult } from '../SecurityCheck.js';
3
3
  export declare class AgentInventoryCheck implements SecurityCheck {
4
4
  readonly id = "agent-inventory";
@@ -1,4 +1,4 @@
1
- import { isApiError } from '../../api/ApiError.js';
1
+ import { isApiError } from '@cclabsnz/sf-core';
2
2
  // BotDefinition.Type values that denote an Agentforce / GenAI agent rather than a
3
3
  // classic Einstein Bot. Matched case-insensitively; anything else (typically 'Bot')
4
4
  // is treated as a classic bot. LIKE-style matching so exact enum spellings across
@@ -1,4 +1,4 @@
1
- import type { AuditContext } from '../../context/AuditContext.js';
1
+ import type { AuditContext } from '@cclabsnz/sf-core';
2
2
  import type { SecurityCheck, CheckResult } from '../SecurityCheck.js';
3
3
  export declare class AgentMonitoringCoverageCheck implements SecurityCheck {
4
4
  readonly id = "agent-monitoring-coverage";
@@ -1,4 +1,4 @@
1
- import type { AuditContext } from '../../context/AuditContext.js';
1
+ import type { AuditContext } from '@cclabsnz/sf-core';
2
2
  import type { SecurityCheck, CheckResult } from '../SecurityCheck.js';
3
3
  export declare class AgentUserPrivilegeCheck implements SecurityCheck {
4
4
  readonly id = "agent-user-privilege";
@@ -1,4 +1,4 @@
1
- import type { AuditContext } from '../../context/AuditContext.js';
1
+ import type { AuditContext } from '@cclabsnz/sf-core';
2
2
  import type { SecurityCheck, CheckResult } from '../SecurityCheck.js';
3
3
  export declare class AnonymousApexAuditCheck implements SecurityCheck {
4
4
  readonly id = "anonymous-apex-audit";
@@ -1,4 +1,4 @@
1
- import type { AuditContext } from '../../context/AuditContext.js';
1
+ import type { AuditContext } from '@cclabsnz/sf-core';
2
2
  import type { SecurityCheck, CheckResult } from '../SecurityCheck.js';
3
3
  export declare class ApexCrudFLSCheck implements SecurityCheck {
4
4
  readonly id = "apex-crud-fls";
@@ -1,4 +1,4 @@
1
- import type { AuditContext } from '../../context/AuditContext.js';
1
+ import type { AuditContext } from '@cclabsnz/sf-core';
2
2
  import type { SecurityCheck, CheckResult } from '../SecurityCheck.js';
3
3
  export declare class ApexLoggingCheck implements SecurityCheck {
4
4
  readonly id = "apex-logging";
@@ -1,4 +1,4 @@
1
- import type { AuditContext } from '../../context/AuditContext.js';
1
+ import type { AuditContext } from '@cclabsnz/sf-core';
2
2
  import type { SecurityCheck, CheckResult } from '../SecurityCheck.js';
3
3
  export declare class ApexRestEndpointCheck implements SecurityCheck {
4
4
  readonly id = "apex-rest-endpoint";
@@ -1,4 +1,4 @@
1
- import type { AuditContext } from '../../context/AuditContext.js';
1
+ import type { AuditContext } from '@cclabsnz/sf-core';
2
2
  import type { SecurityCheck, CheckResult } from '../SecurityCheck.js';
3
3
  export declare class ApexSharingCheck implements SecurityCheck {
4
4
  readonly id = "apex-sharing";
@@ -1,3 +1,4 @@
1
+ import { ApexRepository } from '@cclabsnz/sf-core';
1
2
  const INHERITED_SHARING = /\binherited\s+sharing\b/i;
2
3
  const WITHOUT_SHARING = /\bwithout\s+sharing\b/i;
3
4
  const WITH_SHARING = /\bwith\s+sharing\b/i;
@@ -30,8 +31,8 @@ export class ApexSharingCheck {
30
31
  let apexBodies = ctx.cache.apexBodies;
31
32
  if (!apexBodies) {
32
33
  // Fall back to querying if cache not populated
33
- const records = await ctx.tooling.query('SELECT Id, Name, Body, NamespacePrefix FROM ApexClass WHERE NamespacePrefix = null');
34
- apexBodies = records.map((r) => ({ name: r.Name, body: r.Body }));
34
+ const records = await new ApexRepository(ctx.tooling).listClasses({ excludeManaged: true });
35
+ apexBodies = records.map((r) => ({ name: r.name, body: r.body ?? '' }));
35
36
  }
36
37
  const withSharingClasses = [];
37
38
  const withoutSharingClasses = [];
@@ -1,4 +1,4 @@
1
- import type { AuditContext } from '../../context/AuditContext.js';
1
+ import type { AuditContext } from '@cclabsnz/sf-core';
2
2
  import type { SecurityCheck, CheckResult } from '../SecurityCheck.js';
3
3
  export declare class ApiClientPermissionCheck implements SecurityCheck {
4
4
  readonly id = "api-client-permission";
@@ -1,4 +1,4 @@
1
- import type { AuditContext } from '../../context/AuditContext.js';
1
+ import type { AuditContext } from '@cclabsnz/sf-core';
2
2
  import type { SecurityCheck, CheckResult } from '../SecurityCheck.js';
3
3
  export declare class ApiLimitsCheck implements SecurityCheck {
4
4
  readonly id = "api-limits";
@@ -1,4 +1,4 @@
1
- import type { AuditContext } from '../../context/AuditContext.js';
1
+ import type { AuditContext } from '@cclabsnz/sf-core';
2
2
  import type { SecurityCheck, CheckResult } from '../SecurityCheck.js';
3
3
  export declare class AuditTrailCheck implements SecurityCheck {
4
4
  readonly id = "audit-trail";
@@ -1,4 +1,4 @@
1
- import type { AuditContext } from '../../context/AuditContext.js';
1
+ import type { AuditContext } from '@cclabsnz/sf-core';
2
2
  import type { SecurityCheck, CheckResult } from '../SecurityCheck.js';
3
3
  /**
4
4
  * Reviews external identity federation — Auth Providers and SAML SSO configs.
@@ -1,4 +1,4 @@
1
- import type { AuditContext } from '../../context/AuditContext.js';
1
+ import type { AuditContext } from '@cclabsnz/sf-core';
2
2
  import type { SecurityCheck, CheckResult } from '../SecurityCheck.js';
3
3
  export declare class CertificateExpiryCheck implements SecurityCheck {
4
4
  readonly id = "certificate-expiry";
@@ -1,4 +1,4 @@
1
- import type { AuditContext } from '../../context/AuditContext.js';
1
+ import type { AuditContext } from '@cclabsnz/sf-core';
2
2
  import type { SecurityCheck, CheckResult } from '../SecurityCheck.js';
3
3
  /**
4
4
  * Audits classic Force.com Sites (Visualforce sites), a public unauthenticated
@@ -1,4 +1,4 @@
1
- import type { AuditContext } from '../../context/AuditContext.js';
1
+ import type { AuditContext } from '@cclabsnz/sf-core';
2
2
  import type { SecurityCheck, CheckResult } from '../SecurityCheck.js';
3
3
  export declare class CodeSecurityCheck implements SecurityCheck {
4
4
  readonly id = "code-security";
@@ -1,3 +1,4 @@
1
+ import { ApexRepository } from '@cclabsnz/sf-core';
1
2
  // SBS-CODE-002: dynamic SOQL with string concatenation is the primary SOQL injection vector.
2
3
  // Pattern: Database.query( or Database.countQuery( followed by a + operator before the closing paren/semicolon.
3
4
  const DYNAMIC_SOQL_INJECTION = /Database\.(query|countQuery)\s*\([^;)]*\+[^;)]*[);]/gi;
@@ -15,13 +16,12 @@ export class CodeSecurityCheck {
15
16
  // Fire all three independent Tooling queries in parallel.
16
17
  // COUNT(Id) expr0 puts the result in records[0].expr0; COUNT() without a field
17
18
  // puts it in totalSize which is not in the typed return value.
18
- const [classCountResults, triggerCountResults, coverageResults] = await Promise.all([
19
- ctx.tooling.query('SELECT COUNT(Id) expr0 FROM ApexClass WHERE NamespacePrefix = null'),
20
- ctx.tooling.query('SELECT COUNT(Id) expr0 FROM ApexTrigger WHERE NamespacePrefix = null'),
19
+ const apex = new ApexRepository(ctx.tooling);
20
+ const [classCount, triggerCount, coverageResults] = await Promise.all([
21
+ apex.countClasses({ excludeManaged: true }),
22
+ apex.countTriggers({ excludeManaged: true }),
21
23
  ctx.tooling.query('SELECT PercentCovered FROM ApexOrgWideCoverage'),
22
24
  ]);
23
- const classCount = classCountResults[0]?.expr0 ?? 0;
24
- const triggerCount = triggerCountResults[0]?.expr0 ?? 0;
25
25
  if (coverageResults.length > 0) {
26
26
  const coverage = coverageResults[0].PercentCovered;
27
27
  let riskLevel = 'LOW';
@@ -1,4 +1,4 @@
1
- import type { AuditContext } from '../../context/AuditContext.js';
1
+ import type { AuditContext } from '@cclabsnz/sf-core';
2
2
  import type { SecurityCheck, CheckResult } from '../SecurityCheck.js';
3
3
  export declare class ConnectedAppInactivityCheck implements SecurityCheck {
4
4
  readonly id = "connected-app-inactivity";
@@ -1,4 +1,4 @@
1
- import type { AuditContext } from '../../context/AuditContext.js';
1
+ import type { AuditContext } from '@cclabsnz/sf-core';
2
2
  import type { SecurityCheck, CheckResult } from '../SecurityCheck.js';
3
3
  export declare class ConnectedAppScopeCheck implements SecurityCheck {
4
4
  readonly id = "connected-app-scope";
@@ -1,4 +1,4 @@
1
- import type { AuditContext } from '../../context/AuditContext.js';
1
+ import type { AuditContext } from '@cclabsnz/sf-core';
2
2
  import type { SecurityCheck, CheckResult } from '../SecurityCheck.js';
3
3
  export declare class ConnectedAppsCheck implements SecurityCheck {
4
4
  readonly id = "connected-apps";
@@ -1,4 +1,4 @@
1
- import type { AuditContext } from '../../context/AuditContext.js';
1
+ import type { AuditContext } from '@cclabsnz/sf-core';
2
2
  import type { SecurityCheck, CheckResult } from '../SecurityCheck.js';
3
3
  export declare class ContentLinksCheck implements SecurityCheck {
4
4
  readonly id = "content-links";
@@ -1,4 +1,4 @@
1
- import type { AuditContext } from '../../context/AuditContext.js';
1
+ import type { AuditContext } from '@cclabsnz/sf-core';
2
2
  import type { SecurityCheck, CheckResult } from '../SecurityCheck.js';
3
3
  export declare class CorsAllowlistCheck implements SecurityCheck {
4
4
  readonly id = "cors-allowlist";
@@ -1,5 +1,5 @@
1
1
  import type { SecurityCheck, CheckResult } from '../SecurityCheck.js';
2
- import type { AuditContext } from '../../context/AuditContext.js';
2
+ import type { AuditContext } from '@cclabsnz/sf-core';
3
3
  export declare class CspTrustedSitesCheck implements SecurityCheck {
4
4
  readonly id = "csp-trusted-sites";
5
5
  readonly name = "CSP Trusted Sites";
@@ -1,4 +1,4 @@
1
- import type { AuditContext } from '../../context/AuditContext.js';
1
+ import type { AuditContext } from '@cclabsnz/sf-core';
2
2
  import type { SecurityCheck, CheckResult } from '../SecurityCheck.js';
3
3
  export declare class CustomLabelsCredentialCheck implements SecurityCheck {
4
4
  readonly id = "custom-labels-credential";
@@ -1,4 +1,4 @@
1
- import type { AuditContext } from '../../context/AuditContext.js';
1
+ import type { AuditContext } from '@cclabsnz/sf-core';
2
2
  import type { SecurityCheck, CheckResult } from '../SecurityCheck.js';
3
3
  export declare class CustomSettingsCheck implements SecurityCheck {
4
4
  readonly id = "custom-settings";
@@ -1,4 +1,4 @@
1
- import type { AuditContext } from '../../context/AuditContext.js';
1
+ import type { AuditContext } from '@cclabsnz/sf-core';
2
2
  import type { SecurityCheck, CheckResult } from '../SecurityCheck.js';
3
3
  export declare class DataClassificationCheck implements SecurityCheck {
4
4
  readonly id = "data-classification";
@@ -1,4 +1,4 @@
1
- import type { AuditContext } from '../../context/AuditContext.js';
1
+ import type { AuditContext } from '@cclabsnz/sf-core';
2
2
  import type { SecurityCheck, CheckResult } from '../SecurityCheck.js';
3
3
  /**
4
4
  * Finds the profiles / permission sets that grant a bulk data-extraction
@@ -1,4 +1,4 @@
1
- import type { AuditContext } from '../../context/AuditContext.js';
1
+ import type { AuditContext } from '@cclabsnz/sf-core';
2
2
  import type { SecurityCheck, CheckResult } from '../SecurityCheck.js';
3
3
  export declare class DebugLogAccessCheck implements SecurityCheck {
4
4
  readonly id = "debug-log-access";
@@ -1,4 +1,4 @@
1
- import type { AuditContext } from '../../context/AuditContext.js';
1
+ import type { AuditContext } from '@cclabsnz/sf-core';
2
2
  import type { SecurityCheck, CheckResult } from '../SecurityCheck.js';
3
3
  export declare class DeploymentIdentityCheck implements SecurityCheck {
4
4
  readonly id = "deployment-identity";
@@ -1,4 +1,4 @@
1
- import type { AuditContext } from '../../context/AuditContext.js';
1
+ import type { AuditContext } from '@cclabsnz/sf-core';
2
2
  import type { SecurityCheck, CheckResult } from '../SecurityCheck.js';
3
3
  export declare class EmailSecurityCheck implements SecurityCheck {
4
4
  readonly id = "email-security";
@@ -1,4 +1,4 @@
1
- import type { AuditContext } from '../../context/AuditContext.js';
1
+ import type { AuditContext } from '@cclabsnz/sf-core';
2
2
  import type { SecurityCheck, CheckResult } from '../SecurityCheck.js';
3
3
  /**
4
4
  * Cross-references data classification against ACTUAL field encryption. `data-
@@ -1,4 +1,4 @@
1
- import type { AuditContext } from '../../context/AuditContext.js';
1
+ import type { AuditContext } from '@cclabsnz/sf-core';
2
2
  import type { SecurityCheck, CheckResult } from '../SecurityCheck.js';
3
3
  export declare class EnhancedDomainsCheck implements SecurityCheck {
4
4
  readonly id = "enhanced-domains";
@@ -9,8 +9,21 @@
9
9
  // 1. My Domain exists (prerequisite)
10
10
  // 2. The instance URL uses the enhanced domain format (contains .my.salesforce.com or .develop.my.salesforce.com)
11
11
  // 3. Org is not still on a shared instance URL like na1.salesforce.com
12
- const ENHANCED_DOMAIN_PATTERN = /\.my\.salesforce\.com|\.sandbox\.my\.salesforce\.com|\.develop\.my\.salesforce\.com|\.scratch\.my\.salesforce\.com/i;
13
- const LEGACY_INSTANCE_PATTERN = /^https:\/\/[a-z]{2}\d+\.salesforce\.com/i;
12
+ // Patterns are matched against the parsed hostname and anchored to its end, so a URL
13
+ // that merely *contains* the string (an attacker-controlled host with a path of
14
+ // `/x.my.salesforce.com`) cannot be mistaken for an enhanced-domain org. All enhanced variants
15
+ // (sandbox/develop/scratch) are subdomains of my.salesforce.com, so one suffix suffices.
16
+ const ENHANCED_DOMAIN_PATTERN = /\.my\.salesforce\.com$/i;
17
+ const LEGACY_INSTANCE_PATTERN = /^[a-z]{2}\d+\.salesforce\.com$/i;
18
+ /** Parse the hostname from an instance URL; fall back to the raw string if unparseable. */
19
+ function hostnameOf(url) {
20
+ try {
21
+ return new URL(url).hostname;
22
+ }
23
+ catch {
24
+ return url;
25
+ }
26
+ }
14
27
  export class EnhancedDomainsCheck {
15
28
  id = 'enhanced-domains';
16
29
  name = 'Enhanced Domains';
@@ -36,9 +49,10 @@ export class EnhancedDomainsCheck {
36
49
  }
37
50
  const { MyDomain: myDomain, IsSandbox: isSandbox } = org;
38
51
  const instanceUrl = baseUrl;
52
+ const instanceHost = hostnameOf(instanceUrl);
39
53
  // Check if Enhanced Domains is active based on the instance URL format
40
- const hasEnhancedDomainUrl = ENHANCED_DOMAIN_PATTERN.test(instanceUrl);
41
- const hasLegacyUrl = LEGACY_INSTANCE_PATTERN.test(instanceUrl);
54
+ const hasEnhancedDomainUrl = ENHANCED_DOMAIN_PATTERN.test(instanceHost);
55
+ const hasLegacyUrl = LEGACY_INSTANCE_PATTERN.test(instanceHost);
42
56
  const hasMyDomain = !!myDomain;
43
57
  if (!hasMyDomain) {
44
58
  findings.push({
@@ -1,4 +1,4 @@
1
- import type { AuditContext } from '../../context/AuditContext.js';
1
+ import type { AuditContext } from '@cclabsnz/sf-core';
2
2
  import type { SecurityCheck, CheckResult } from '../SecurityCheck.js';
3
3
  export declare class EscalationPermsCheck implements SecurityCheck {
4
4
  readonly id = "escalation-perms";
@@ -1,4 +1,4 @@
1
- import type { AuditContext } from '../../context/AuditContext.js';
1
+ import type { AuditContext } from '@cclabsnz/sf-core';
2
2
  import type { SecurityCheck, CheckResult } from '../SecurityCheck.js';
3
3
  export declare class EventMonitoringCheck implements SecurityCheck {
4
4
  readonly id = "event-monitoring";
@@ -1,4 +1,4 @@
1
- import { classifyEventLogAccessError } from '../eventLogAccess.js';
1
+ import { classifyEventLogAccessError } from '@cclabsnz/sf-core';
2
2
  export class EventMonitoringCheck {
3
3
  id = 'event-monitoring';
4
4
  name = 'Event Monitoring Storage';
@@ -1,4 +1,4 @@
1
- import type { AuditContext } from '../../context/AuditContext.js';
1
+ import type { AuditContext } from '@cclabsnz/sf-core';
2
2
  import type { SecurityCheck, CheckResult } from '../SecurityCheck.js';
3
3
  export declare class ExperienceCloudSiteCheck implements SecurityCheck {
4
4
  readonly id = "experience-cloud-site";
@@ -1,4 +1,4 @@
1
- import type { AuditContext } from '../../context/AuditContext.js';
1
+ import type { AuditContext } from '@cclabsnz/sf-core';
2
2
  import type { SecurityCheck, CheckResult } from '../SecurityCheck.js';
3
3
  /**
4
4
  * Advisory review of Experience Cloud CSP / Lightning Web Security posture.
@@ -1,4 +1,4 @@
1
- import type { AuditContext } from '../../context/AuditContext.js';
1
+ import type { AuditContext } from '@cclabsnz/sf-core';
2
2
  import type { SecurityCheck, CheckResult } from '../SecurityCheck.js';
3
3
  /**
4
4
  * Reviews External Credentials (the modern auth half of Named Credentials) for
@@ -1,4 +1,4 @@
1
- import type { AuditContext } from '../../context/AuditContext.js';
1
+ import type { AuditContext } from '@cclabsnz/sf-core';
2
2
  import type { SecurityCheck, CheckResult } from '../SecurityCheck.js';
3
3
  export declare class FailedLoginCheck implements SecurityCheck {
4
4
  readonly id = "failed-login-detection";
@@ -1,4 +1,4 @@
1
- import type { AuditContext } from '../../context/AuditContext.js';
1
+ import type { AuditContext } from '@cclabsnz/sf-core';
2
2
  import type { SecurityCheck, CheckResult } from '../SecurityCheck.js';
3
3
  export declare class FieldHistoryTrackingCheck implements SecurityCheck {
4
4
  readonly id = "field-history-tracking";
@@ -1,4 +1,4 @@
1
- import type { AuditContext } from '../../context/AuditContext.js';
1
+ import type { AuditContext } from '@cclabsnz/sf-core';
2
2
  import type { SecurityCheck, CheckResult } from '../SecurityCheck.js';
3
3
  export declare class FieldLevelSecurityCheck implements SecurityCheck {
4
4
  readonly id = "field-level-security";