@cclabsnz/sf-audit 1.6.1 → 1.8.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/README.md +258 -5
- package/lib/apps/analyzeApps.d.ts +1 -1
- package/lib/apps/appResolver.d.ts +1 -1
- package/lib/apps/grantedAccess.d.ts +1 -1
- package/lib/chains/AttackChain.d.ts +1 -1
- package/lib/chains/namedChains.d.ts +1 -1
- package/lib/checks/CheckEngine.d.ts +1 -1
- package/lib/checks/SecurityCheck.d.ts +3 -3
- package/lib/checks/impl/AgentActionSurfaceCheck.d.ts +1 -1
- package/lib/checks/impl/AgentActionSurfaceCheck.js +1 -1
- package/lib/checks/impl/AgentChannelExposureCheck.d.ts +1 -1
- package/lib/checks/impl/AgentInventoryCheck.d.ts +1 -1
- package/lib/checks/impl/AgentInventoryCheck.js +1 -1
- package/lib/checks/impl/AgentMonitoringCoverageCheck.d.ts +1 -1
- package/lib/checks/impl/AgentUserPrivilegeCheck.d.ts +1 -1
- package/lib/checks/impl/AnonymousApexAuditCheck.d.ts +1 -1
- package/lib/checks/impl/ApexCrudFLSCheck.d.ts +1 -1
- package/lib/checks/impl/ApexLoggingCheck.d.ts +1 -1
- package/lib/checks/impl/ApexRestEndpointCheck.d.ts +1 -1
- package/lib/checks/impl/ApexSharingCheck.d.ts +1 -1
- package/lib/checks/impl/ApexSharingCheck.js +3 -2
- package/lib/checks/impl/ApiClientPermissionCheck.d.ts +1 -1
- package/lib/checks/impl/ApiLimitsCheck.d.ts +1 -1
- package/lib/checks/impl/AuditTrailCheck.d.ts +1 -1
- package/lib/checks/impl/AuthProvidersCheck.d.ts +1 -1
- package/lib/checks/impl/CertificateExpiryCheck.d.ts +1 -1
- package/lib/checks/impl/ClassicSitesCheck.d.ts +1 -1
- package/lib/checks/impl/CodeSecurityCheck.d.ts +1 -1
- package/lib/checks/impl/CodeSecurityCheck.js +5 -5
- package/lib/checks/impl/ConnectedAppInactivityCheck.d.ts +1 -1
- package/lib/checks/impl/ConnectedAppScopeCheck.d.ts +1 -1
- package/lib/checks/impl/ConnectedAppsCheck.d.ts +1 -1
- package/lib/checks/impl/ContentLinksCheck.d.ts +1 -1
- package/lib/checks/impl/CorsAllowlistCheck.d.ts +1 -1
- package/lib/checks/impl/CspTrustedSitesCheck.d.ts +1 -1
- package/lib/checks/impl/CustomLabelsCredentialCheck.d.ts +1 -1
- package/lib/checks/impl/CustomSettingsCheck.d.ts +1 -1
- package/lib/checks/impl/DataClassificationCheck.d.ts +1 -1
- package/lib/checks/impl/DataExportAccessCheck.d.ts +1 -1
- package/lib/checks/impl/DebugLogAccessCheck.d.ts +1 -1
- package/lib/checks/impl/DeploymentIdentityCheck.d.ts +1 -1
- package/lib/checks/impl/EmailSecurityCheck.d.ts +1 -1
- package/lib/checks/impl/EncryptionCoverageCheck.d.ts +1 -1
- package/lib/checks/impl/EnhancedDomainsCheck.d.ts +1 -1
- package/lib/checks/impl/EnhancedDomainsCheck.js +2 -2
- package/lib/checks/impl/EscalationPermsCheck.d.ts +1 -1
- package/lib/checks/impl/EventMonitoringCheck.d.ts +1 -1
- package/lib/checks/impl/EventMonitoringCheck.js +1 -1
- package/lib/checks/impl/ExperienceCloudSiteCheck.d.ts +1 -1
- package/lib/checks/impl/ExperienceCspCheck.d.ts +1 -1
- package/lib/checks/impl/ExternalCredentialsCheck.d.ts +1 -1
- package/lib/checks/impl/FailedLoginCheck.d.ts +1 -1
- package/lib/checks/impl/FieldHistoryTrackingCheck.d.ts +1 -1
- package/lib/checks/impl/FieldLevelSecurityCheck.d.ts +1 -1
- package/lib/checks/impl/FlowsWithoutSharingCheck.d.ts +1 -1
- package/lib/checks/impl/FlowsWithoutSharingCheck.js +10 -9
- package/lib/checks/impl/GuestApiAccessCheck.d.ts +1 -1
- package/lib/checks/impl/GuestExecutableApexCheck.d.ts +1 -1
- package/lib/checks/impl/GuestExecutableApexCheck.js +4 -3
- package/lib/checks/impl/GuestObjectExposureCheck.d.ts +1 -1
- package/lib/checks/impl/GuestRecordAccessPolicyCheck.d.ts +1 -1
- package/lib/checks/impl/GuestSiteOptionsCheck.d.ts +1 -1
- package/lib/checks/impl/GuestTrafficAnomalyCheck.d.ts +1 -1
- package/lib/checks/impl/GuestTrafficAnomalyCheck.js +1 -1
- package/lib/checks/impl/GuestUserAccessCheck.d.ts +1 -1
- package/lib/checks/impl/HardcodedCredentialsCheck.d.ts +1 -1
- package/lib/checks/impl/HardcodedCredentialsCheck.js +8 -1
- package/lib/checks/impl/HealthCheckCheck.d.ts +1 -1
- package/lib/checks/impl/HighAssuranceSessionCheck.d.ts +1 -1
- package/lib/checks/impl/InactiveUsersCheck.d.ts +1 -1
- package/lib/checks/impl/InstalledPackagesCheck.d.ts +1 -1
- package/lib/checks/impl/IntegrationUsersCheck.d.ts +1 -1
- package/lib/checks/impl/InternalUserMfaCheck.d.ts +1 -1
- package/lib/checks/impl/IpRestrictionsCheck.d.ts +1 -1
- package/lib/checks/impl/LegacyApiVersionCheck.d.ts +1 -1
- package/lib/checks/impl/LoginAccessPolicyCheck.d.ts +1 -1
- package/lib/checks/impl/LoginAnomalyCheck.d.ts +1 -1
- package/lib/checks/impl/LoginSessionCheck.d.ts +1 -1
- package/lib/checks/impl/MfaEnforcementCheck.d.ts +1 -1
- package/lib/checks/impl/MfaMethodStrengthCheck.d.ts +1 -1
- package/lib/checks/impl/MfaRegistrationCheck.d.ts +1 -1
- package/lib/checks/impl/MyDomainLoginPolicyCheck.d.ts +1 -1
- package/lib/checks/impl/NamedCredentialsCheck.d.ts +1 -1
- package/lib/checks/impl/NamedCredentialsCheck.js +13 -9
- package/lib/checks/impl/OutboundMessagesCheck.d.ts +1 -1
- package/lib/checks/impl/PasswordSessionPolicyCheck.d.ts +2 -2
- package/lib/checks/impl/PermissionsCheck.d.ts +1 -1
- package/lib/checks/impl/PrivilegedAccessCheck.d.ts +1 -1
- package/lib/checks/impl/PublicContentExposureCheck.d.ts +1 -1
- package/lib/checks/impl/PublicGroupSharingCheck.d.ts +1 -1
- package/lib/checks/impl/ReleaseUpdatesCheck.d.ts +1 -1
- package/lib/checks/impl/RemoteSitesCheck.d.ts +1 -1
- package/lib/checks/impl/ReportFolderAccessCheck.d.ts +1 -1
- package/lib/checks/impl/SandboxDataMaskingCheck.d.ts +1 -1
- package/lib/checks/impl/ScheduledApexCheck.d.ts +1 -1
- package/lib/checks/impl/SeparationOfDutiesCheck.d.ts +1 -1
- package/lib/checks/impl/SessionHardeningCheck.d.ts +1 -1
- package/lib/checks/impl/SharingModelCheck.d.ts +1 -1
- package/lib/checks/impl/SiemIntegrationCheck.d.ts +1 -1
- package/lib/checks/impl/SsoEnforcementCheck.d.ts +1 -1
- package/lib/checks/impl/StandardProfilesCheck.d.ts +1 -1
- package/lib/checks/impl/ThreatDetectionCheck.d.ts +1 -1
- package/lib/checks/impl/TransactionSecurityPolicyCheck.d.ts +1 -1
- package/lib/checks/impl/TrustedIPRangesCheck.d.ts +1 -1
- package/lib/checks/impl/TrustedUrlHygieneCheck.d.ts +1 -1
- package/lib/checks/impl/UsersAndAdminsCheck.d.ts +1 -1
- package/lib/checks/impl/VisualforceXssCheck.d.ts +1 -1
- package/lib/commands/audit/events/pull.d.ts +1 -1
- package/lib/commands/audit/events/pull.js +3 -3
- package/lib/commands/audit/security.js +3 -1
- package/lib/commands/audit/timeline.d.ts +26 -0
- package/lib/commands/audit/timeline.js +189 -0
- package/lib/findings/AuditResult.d.ts +1 -1
- package/lib/findings/Finding.d.ts +1 -1
- package/lib/findings/ScoringConfig.d.ts +9 -217
- package/lib/findings/scoring.d.ts +2 -2
- package/lib/findings/scoring.js +1 -1
- package/lib/history/AuditDiff.d.ts +1 -1
- package/lib/history/metricMeta.d.ts +1 -1
- package/lib/index.d.ts +2 -2
- package/lib/lib/apexRefs.d.ts +2 -0
- package/lib/lib/apexRefs.js +30 -0
- package/lib/lib/wire.d.ts +6 -6
- package/lib/lib/wire.js +4 -4
- package/lib/renderers/ClientReportRenderer.d.ts +1 -1
- package/lib/renderers/ClientReportRenderer.js +6 -3
- package/lib/renderers/HistoryRenderer.js +2 -1
- package/lib/renderers/HtmlRenderer.js +3 -4
- package/lib/renderers/MarkdownRenderer.js +1 -1
- package/lib/renderers/chartAsset.d.ts +12 -0
- package/lib/renderers/chartAsset.js +25 -0
- package/lib/timeline/CaptureIndex.d.ts +34 -0
- package/lib/timeline/CaptureIndex.js +82 -0
- package/lib/timeline/CardinalityIndex.d.ts +28 -0
- package/lib/timeline/CardinalityIndex.js +47 -0
- package/lib/timeline/CorrelationEngine.d.ts +65 -0
- package/lib/timeline/CorrelationEngine.js +0 -0
- package/lib/timeline/EventRow.d.ts +69 -0
- package/lib/timeline/EventRow.js +14 -0
- package/lib/timeline/JoinKeys.d.ts +50 -0
- package/lib/timeline/JoinKeys.js +63 -0
- package/lib/timeline/loadCaptures.d.ts +87 -0
- package/lib/timeline/loadCaptures.js +424 -0
- package/lib/timeline/normalise.d.ts +26 -0
- package/lib/timeline/normalise.js +161 -0
- package/lib/timeline/parseWindow.d.ts +29 -0
- package/lib/timeline/parseWindow.js +133 -0
- package/lib/timeline/render.d.ts +33 -0
- package/lib/timeline/render.js +120 -0
- package/package.json +22 -20
- package/lib/api/ApiError.d.ts +0 -6
- package/lib/api/ApiError.js +0 -6
- package/lib/api/MetadataClient.d.ts +0 -4
- package/lib/api/MetadataClient.js +0 -2
- package/lib/api/MetadataClientImpl.d.ts +0 -8
- package/lib/api/MetadataClientImpl.js +0 -22
- package/lib/api/RestClient.d.ts +0 -6
- package/lib/api/RestClient.js +0 -2
- package/lib/api/RestClientImpl.d.ts +0 -10
- package/lib/api/RestClientImpl.js +0 -45
- package/lib/api/SoqlClient.d.ts +0 -10
- package/lib/api/SoqlClient.js +0 -2
- package/lib/api/SoqlClientImpl.d.ts +0 -9
- package/lib/api/SoqlClientImpl.js +0 -19
- package/lib/api/ToolingClient.d.ts +0 -5
- package/lib/api/ToolingClient.js +0 -2
- package/lib/api/ToolingClientImpl.d.ts +0 -10
- package/lib/api/ToolingClientImpl.js +0 -29
- package/lib/api/index.d.ts +0 -9
- package/lib/api/index.js +0 -5
- package/lib/checks/eventLogAccess.d.ts +0 -14
- package/lib/checks/eventLogAccess.js +0 -33
- package/lib/context/AuditCache.d.ts +0 -78
- package/lib/context/AuditCache.js +0 -2
- package/lib/context/AuditContext.d.ts +0 -19
- package/lib/context/AuditContext.js +0 -2
- package/lib/context/OrgInfo.d.ts +0 -9
- package/lib/context/OrgInfo.js +0 -2
- package/lib/context/OrgMetrics.d.ts +0 -20
- package/lib/context/OrgMetrics.js +0 -20
- package/lib/events/EventBaselineStore.d.ts +0 -16
- package/lib/events/EventBaselineStore.js +0 -55
- package/lib/events/eventLogQuery.d.ts +0 -21
- package/lib/events/eventLogQuery.js +0 -34
- package/lib/events/pullEventLogs.d.ts +0 -51
- package/lib/events/pullEventLogs.js +0 -79
- package/lib/findings/RiskLevel.d.ts +0 -3
- package/lib/findings/RiskLevel.js +0 -2
- package/lib/renderers/html-utils.d.ts +0 -2
- package/lib/renderers/html-utils.js +0 -8
- package/lib/report/branding.d.ts +0 -18
- package/lib/report/branding.js +0 -19
- package/lib/report/fonts.d.ts +0 -2
- package/lib/report/fonts.js +0 -22
- package/src/assets/fonts/dm-sans-italic-latin.woff2 +0 -0
- package/src/assets/fonts/dm-sans-normal-latin.woff2 +0 -0
- package/src/assets/fonts/dm-serif-display-italic-latin.woff2 +0 -0
- package/src/assets/fonts/dm-serif-display-normal-latin.woff2 +0 -0
package/README.md
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
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
|
|
|
3
7
|
[](https://github.com/cclabsnz/sf-audit-plugin/actions/workflows/ci.yml)
|
|
4
8
|
[](https://github.com/cclabsnz/sf-audit-plugin/actions/workflows/codeql.yml)
|
|
9
|
+
[](https://github.com/cclabsnz/sf-audit-plugin/actions/workflows/semgrep.yml)
|
|
5
10
|
[](https://securityscorecards.dev/viewer/?uri=github.com/cclabsnz/sf-audit-plugin)
|
|
6
11
|
[](https://www.npmjs.com/package/@cclabsnz/sf-audit)
|
|
7
|
-
[](https://www.npmjs.com/package/@cclabsnz/sf-audit#provenance)
|
|
8
13
|
[](LICENSE)
|
|
9
14
|
|
|
10
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.
|
|
@@ -286,7 +291,7 @@ Findings are mapped to controls across eight security and privacy frameworks. Th
|
|
|
286
291
|
|
|
287
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).
|
|
288
293
|
|
|
289
|
-
**Further reading:** [Mapping Salesforce security to NZISM, the NZ Privacy Act and ISO 27001](https://
|
|
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).
|
|
290
295
|
|
|
291
296
|
## Scope & Liability
|
|
292
297
|
|
|
@@ -305,11 +310,52 @@ Findings are mapped to controls across eight security and privacy frameworks. Th
|
|
|
305
310
|
|
|
306
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:
|
|
307
312
|
|
|
308
|
-
- **Read-only, enforced in CI.** The "no writes to your org" promise is a passing test, not a footnote. `test/unit/
|
|
309
|
-
- **
|
|
310
|
-
|
|
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.
|
|
311
327
|
- **Least privilege & disclosure.** See [PERMISSIONS.md](PERMISSIONS.md) for the minimal access it needs and [SECURITY.md](SECURITY.md) for private vulnerability reporting.
|
|
312
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
|
+
|
|
313
359
|
## Scoring
|
|
314
360
|
|
|
315
361
|
Each finding is assigned a risk level with a corresponding weight:
|
|
@@ -540,6 +586,168 @@ sfelf-triage analyze ~/.sf/event-baseline/<orgId> # triage (companion)
|
|
|
540
586
|
|
|
541
587
|
See the [sfelf-triage README](https://github.com/cclabsnz/sfelf-triage#readme) for install and usage.
|
|
542
588
|
|
|
589
|
+
## Forensic timeline
|
|
590
|
+
|
|
591
|
+
Salesforce splits one actor's activity across many event types, and each carries a different
|
|
592
|
+
subset of identifying fields — so no single log answers *"what did this actor do"*. Filtering by
|
|
593
|
+
IP finds the requests but misses every SOQL execution, because the query log has no `CLIENT_IP`
|
|
594
|
+
column at all. Filtering by user finds everything the *guest* user did, which on a community is
|
|
595
|
+
everyone.
|
|
596
|
+
|
|
597
|
+
`sf audit timeline` correlates a seed across every captured event type and writes a defensible
|
|
598
|
+
timeline:
|
|
599
|
+
|
|
600
|
+
```bash
|
|
601
|
+
sf audit timeline --window 2026-08-02T04:00Z/PT1H --seed ip:203.0.113.50
|
|
602
|
+
```
|
|
603
|
+
|
|
604
|
+
It runs **entirely offline** against captures written by `sf audit events pull` — no org
|
|
605
|
+
connection is opened, so it still works long after the org's retention window has expired or its
|
|
606
|
+
credentials have been revoked. The org id is inferred from the capture directory when only one
|
|
607
|
+
org has been captured.
|
|
608
|
+
|
|
609
|
+
### What it will not do
|
|
610
|
+
|
|
611
|
+
Cross-event correlation is easy to get confidently wrong, and a wrong answer here reads as
|
|
612
|
+
evidence. Two rules are enforced and both are visible in the output:
|
|
613
|
+
|
|
614
|
+
- **A blank field is never a join key.** A blank `REQUEST_ID` used as a key stops identifying
|
|
615
|
+
anything and starts matching every other row whose value is also blank — quietly attributing
|
|
616
|
+
strangers' sessions to your actor.
|
|
617
|
+
- **A shared identity is not expanded.** A community guest user can stand for hundreds of
|
|
618
|
+
distinct visitors. Expanding through it would present the whole crowd's activity as one
|
|
619
|
+
actor's, so it is refused by default and the refusal is reported with its evidence:
|
|
620
|
+
|
|
621
|
+
```
|
|
622
|
+
Expansion refused: userId 005xx0000000000 is shared by 1371 distinct addresses
|
|
623
|
+
(threshold 8). Override with --allow-shared-identity.
|
|
624
|
+
```
|
|
625
|
+
|
|
626
|
+
Every output also leads with what was actually captured, because *"no rows matched"* means two
|
|
627
|
+
entirely different things — the actor did nothing, or nobody captured the hour they did it in:
|
|
628
|
+
|
|
629
|
+
```
|
|
630
|
+
Window — coverage INCOMPLETE
|
|
631
|
+
captured AuraRequest, ListViewEvent
|
|
632
|
+
MISSING LightningInteraction (not-in-core-set)
|
|
633
|
+
MISSING GuestUserAnomalyEventStore (storage-disabled)
|
|
634
|
+
|
|
635
|
+
No activity in captured sources. Coverage incomplete — 2 sources missing.
|
|
636
|
+
```
|
|
637
|
+
|
|
638
|
+
**Flags:**
|
|
639
|
+
|
|
640
|
+
| Flag | Description | Default |
|
|
641
|
+
|------|-------------|---------|
|
|
642
|
+
| `--window` | When to look — see below | required |
|
|
643
|
+
| `--seed` | Typed and repeatable: `ip:` `user:` `session:` `request:` `login:` `transaction:` `event:` | *(whole window)* |
|
|
644
|
+
| `--org-id` | Which captured org to read | *(inferred when unambiguous)* |
|
|
645
|
+
| `--input` | Capture base directory | `~/.sf/event-baseline` |
|
|
646
|
+
| `--allow-shared-identity` | Expand through identities shared by many actors | `false` |
|
|
647
|
+
| `--max-cardinality` | Distinct-actor ceiling above which a key is not expanded | `8` |
|
|
648
|
+
| `--format` | Comma-separated: `csv,json,md` | all three |
|
|
649
|
+
| `--output` | Directory to write into | `.` |
|
|
650
|
+
|
|
651
|
+
**Finding your way in.** Two things you do not have to know up front. Omit `--seed` and you get
|
|
652
|
+
the whole window, uncorrelated — which is where you look to find something worth seeding on.
|
|
653
|
+
Ask for a window that was never captured and the error lists the days that *were*:
|
|
654
|
+
|
|
655
|
+
```
|
|
656
|
+
No captures for 2026-07-01 under ~/.sf/event-baseline/00Dxx0000000000EAA.
|
|
657
|
+
|
|
658
|
+
Captured days for this org:
|
|
659
|
+
2026-08-01 11 event type(s), whole day
|
|
660
|
+
2026-08-02 14 event type(s), whole day
|
|
661
|
+
|
|
662
|
+
Try: --window 2026-08-02
|
|
663
|
+
```
|
|
664
|
+
|
|
665
|
+
**Saying when.** `--window` takes whichever form is nearest to hand — you should not have to
|
|
666
|
+
compose an ISO 8601 interval while an incident is running:
|
|
667
|
+
|
|
668
|
+
| You type | You get |
|
|
669
|
+
|---|---|
|
|
670
|
+
| `yesterday` | the whole of yesterday, UTC |
|
|
671
|
+
| `today` | midnight UTC until now |
|
|
672
|
+
| `2h` · `90m` | the last two hours; the last ninety minutes |
|
|
673
|
+
| `2026-08-02` | that whole day — the shape the free tier captures in |
|
|
674
|
+
| `2026-08-02T04:17Z` | the hour containing that instant, for a timestamp pasted from an alert |
|
|
675
|
+
| `2026-08-02T04:00Z/PT1H` | an exact interval, start and duration |
|
|
676
|
+
| `2026-08-02T04:00Z/2026-08-02T06:00Z` | an exact interval, start and end |
|
|
677
|
+
|
|
678
|
+
Times are UTC, because every capture is stored in UTC — a bare timestamp with no zone is read
|
|
679
|
+
that way rather than as local time. A window has to fall inside one UTC day; one that crosses
|
|
680
|
+
midnight is refused, and the error names the two runs that would cover it.
|
|
681
|
+
|
|
682
|
+
```bash
|
|
683
|
+
# Follow one address across every captured event type
|
|
684
|
+
sf audit timeline --window yesterday --seed ip:203.0.113.50
|
|
685
|
+
|
|
686
|
+
# Start from a request and walk outward, including its Apex cascade
|
|
687
|
+
sf audit timeline --window 2026-08-02T04:00Z/PT1H --seed request:abc123
|
|
688
|
+
|
|
689
|
+
# Several orgs captured — name the one to read
|
|
690
|
+
sf audit timeline --org-id 00Dxx0000000000EAA --window 2026-08-02T04:00Z/PT2H --seed user:005xx000000000
|
|
691
|
+
|
|
692
|
+
# Machine-readable only, into an evidence directory
|
|
693
|
+
sf audit timeline --window 2026-08-02T04:00Z/PT1H --seed ip:203.0.113.50 \
|
|
694
|
+
--format json --output ./evidence/incident-2026-08-02
|
|
695
|
+
```
|
|
696
|
+
|
|
697
|
+
**Outputs:**
|
|
698
|
+
|
|
699
|
+
| File | Contents |
|
|
700
|
+
|------|----------|
|
|
701
|
+
| `timeline.csv` | The correlated rows, one schema across all sources, chronological |
|
|
702
|
+
| `timeline.json` | The same rows plus the provenance — seeds, every key expanded through, and every refusal |
|
|
703
|
+
| `summary.md` | Narrative: coverage, per-type counts, what tied each row in, refusals, and whether records left |
|
|
704
|
+
|
|
705
|
+
Each row records **which join key tied it in**, so attribution is checkable rather than asserted.
|
|
706
|
+
The `rows_processed` and `records_returned` columns are populated only from Real-Time Event
|
|
707
|
+
objects — no `EventLogFile` type records them — and when none were captured the summary says the
|
|
708
|
+
question is unanswerable rather than going quiet, since silence there reads as *"nothing left"*.
|
|
709
|
+
|
|
710
|
+
### Checking a claim against its control group
|
|
711
|
+
|
|
712
|
+
When a seed's rows share an identity with many other people — a community guest user, a shared
|
|
713
|
+
integration account — *"this actor did X"* needs something to be checked against. Otherwise the
|
|
714
|
+
claim is unfalsifiable: nobody can tell your 15 rows from the other 600 behind the same user.
|
|
715
|
+
|
|
716
|
+
The refusal message already gives you the denominator:
|
|
717
|
+
|
|
718
|
+
```
|
|
719
|
+
Expansion refused: userId 005xx000000000 is shared by 1371 distinct addresses (threshold 8).
|
|
720
|
+
```
|
|
721
|
+
|
|
722
|
+
To see the peer set itself, run the command a second time seeded on that identity, with expansion
|
|
723
|
+
allowed:
|
|
724
|
+
|
|
725
|
+
```bash
|
|
726
|
+
# 1. The claim — narrow, seeded on something that identifies one actor
|
|
727
|
+
sf audit timeline --window 2026-08-02T04:00Z/PT1H --seed request:REQ000000 \
|
|
728
|
+
--output ./evidence/actor
|
|
729
|
+
|
|
730
|
+
# 2. The control — everyone behind the identity those rows share
|
|
731
|
+
sf audit timeline --window 2026-08-02T04:00Z/PT1H --seed user:005xx000000000 \
|
|
732
|
+
--allow-shared-identity --output ./evidence/peers
|
|
733
|
+
```
|
|
734
|
+
|
|
735
|
+
Both use the same schema, so they concatenate and diff directly:
|
|
736
|
+
|
|
737
|
+
```bash
|
|
738
|
+
# How much of the identity's activity is actually your actor?
|
|
739
|
+
# (tail -n +2 skips the header row, so these are data rows)
|
|
740
|
+
echo "actor: $(tail -n +2 ./evidence/actor/timeline.csv | wc -l)"
|
|
741
|
+
echo "control: $(tail -n +2 ./evidence/peers/timeline.csv | wc -l)"
|
|
742
|
+
```
|
|
743
|
+
|
|
744
|
+
An actor accounting for 15 of 603 rows — 2.5%, and separable by request id — is a different
|
|
745
|
+
finding from one accounting for 580 of 603. The second command is what lets a reviewer tell
|
|
746
|
+
which they are looking at, rather than taking the first on trust.
|
|
747
|
+
|
|
748
|
+
> `sf audit timeline` adds **no checks** and does not affect the security grade. It is an
|
|
749
|
+
> investigation command, not a `SecurityCheck`.
|
|
750
|
+
|
|
543
751
|
## Connected-app least-privilege
|
|
544
752
|
|
|
545
753
|
Connected-app over-privilege was at the centre of the 2025-2026 wave of Salesforce data-theft
|
|
@@ -600,3 +808,48 @@ npm run clean # remove compiled output
|
|
|
600
808
|
```
|
|
601
809
|
|
|
602
810
|
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).
|
|
811
|
+
|
|
812
|
+
## Further reading
|
|
813
|
+
|
|
814
|
+
Deep dives on this tool and the topics it checks, from our engineering blog **[softwareinsights.dev](https://softwareinsights.dev)**.
|
|
815
|
+
|
|
816
|
+
**How the commands work:**
|
|
817
|
+
|
|
818
|
+
- [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`
|
|
819
|
+
- [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
|
|
820
|
+
- [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)
|
|
821
|
+
- [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
|
|
822
|
+
- [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)
|
|
823
|
+
- [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
|
|
824
|
+
|
|
825
|
+
**The access model the privilege checks encode** — the reasoning behind [Users, Permissions & Privilege](#users-permissions--privilege):
|
|
826
|
+
|
|
827
|
+
- [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
|
|
828
|
+
- [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
|
|
829
|
+
- [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
|
|
830
|
+
- [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
|
|
831
|
+
|
|
832
|
+
**Platform changes the checks track:**
|
|
833
|
+
|
|
834
|
+
- [Hardening Agentforce against prompt injection (post-ForcedLeak)](https://softwareinsights.dev/posts/salesforce-agentforce-forcedleak-prompt-injection-hardening/) — feeds the Agentforce / GenAI checks
|
|
835
|
+
- [Audit your Agentforce footprint: every agent, agent user, and permission](https://softwareinsights.dev/posts/salesforce-agentforce-footprint-audit/) — the manual SOQL behind Agent Inventory
|
|
836
|
+
- [Agentforce agent user least privilege](https://softwareinsights.dev/posts/salesforce-agentforce-agent-user-least-privilege/) — feeds the Agent User Privilege check
|
|
837
|
+
- [Salesforce MFA enforcement: the revised 2026 dates](https://softwareinsights.dev/posts/salesforce-mfa-enforcement-paused-revised-dates-2026/) — feeds the MFA checks
|
|
838
|
+
- [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
|
|
839
|
+
- [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
|
|
840
|
+
- [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
|
|
841
|
+
- [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
|
|
842
|
+
- [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
|
|
843
|
+
- [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
|
|
844
|
+
- [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
|
|
845
|
+
|
|
846
|
+
**Compliance and NZ context** — background for the [framework mappings](#compliance-frameworks):
|
|
847
|
+
|
|
848
|
+
- [Mapping Salesforce security to NZISM, the NZ Privacy Act and ISO 27001](https://softwareinsights.dev/posts/salesforce-security-nzism-nz-privacy-act/)
|
|
849
|
+
- [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
|
|
850
|
+
- [IPP 3A indirect collection notices](https://softwareinsights.dev/posts/salesforce-nz-privacy-ipp3a-indirect-collection-notice/) — feeds the NZ Privacy Act control mappings
|
|
851
|
+
- [Why Salesforce Health Cloud needs its own security review](https://softwareinsights.dev/posts/salesforce-health-cloud-security-review/) — the HISO 10029 context
|
|
852
|
+
|
|
853
|
+
## Commercial support
|
|
854
|
+
|
|
855
|
+
`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 '
|
|
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 '
|
|
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 '
|
|
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,5 +1,5 @@
|
|
|
1
1
|
import type { SecurityCheck } from './SecurityCheck.js';
|
|
2
|
-
import type { AuditContext } from '
|
|
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 '
|
|
1
|
+
import type { AuditContext } from '@cclabsnz/sf-core';
|
|
2
2
|
import type { Finding } from '../findings/Finding.js';
|
|
3
|
-
import type { AuditCache } from '
|
|
4
|
-
import type { OrgMetrics } from '
|
|
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 '
|
|
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 '
|
|
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 '
|
|
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 '
|
|
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 '
|
|
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 '
|
|
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 '
|
|
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 '
|
|
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 '
|
|
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 '
|
|
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 '
|
|
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 '
|
|
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.
|
|
34
|
-
apexBodies = records.map((r) => ({ name: r.
|
|
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 '
|
|
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 '
|
|
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 '
|
|
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 '
|
|
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 '
|
|
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 '
|
|
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 '
|
|
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
|
|
19
|
-
|
|
20
|
-
|
|
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 '
|
|
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 '
|
|
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 '
|
|
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 '
|
|
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 '
|
|
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 '
|
|
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 '
|
|
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 '
|
|
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 '
|
|
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";
|