@cclabsnz/sf-audit 1.14.0 → 1.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -11,6 +11,66 @@ published note and carries the signed provenance attestation and CycloneDX SBOM
11
11
 
12
12
  Merged to `main`, not yet released.
13
13
 
14
+ ## [v1.15.0](https://github.com/cclabsnz/sf-audit-plugin/releases/tag/v1.15.0) — 2026-10-06
15
+
16
+ One new check, and four existing checks that stop reporting conclusions they had not established.
17
+
18
+ ### Added
19
+
20
+ - **`lightning-message-channel`** flags Lightning Message Service channels with `isExposed=true`,
21
+ which outside namespaces, including every installed managed package, can publish to and
22
+ subscribe on. Sharing rules, org-wide defaults and field-level security do not reach the bus.
23
+ Salesforce's AppExchange Security Review requires `isExposed=false`, and the setting cannot be
24
+ reversed once true, so remediation is a new channel plus migrating its publishers and
25
+ subscribers, not a toggle. Installed channels are reported separately at LOW, since the fix sits
26
+ with the vendor. The finding says what the metadata cannot show: what a channel carries is
27
+ visible only in the publishing component. One Tooling query; grants no attack-chain capability.
28
+ Check count is now **93**.
29
+
30
+ ### Fixed
31
+
32
+ - **Four checks no longer report conclusions they had not established.** Each was both untested and
33
+ held a `catch` that swallowed a query failure; writing the tests is what surfaced the defects, as
34
+ it has every previous time.
35
+
36
+ - **`mfa-enforcement` asserted a HIGH finding on a failed query.** When
37
+ `PermissionsMultiFactorForUiLogins` could not be read - the field is absent in some editions -
38
+ the empty result was treated as "nobody has MFA enforced", so every external user fell into the
39
+ shortfall bucket and the check named them, at HIGH, as lacking MFA. Over-reporting was not the
40
+ safe direction: it produced a remediation task against real users and an SBS-AUTH-004 claim on
41
+ no evidence. Now inconclusive.
42
+ - **`audit-trail` charged a clean org for being clean.** Zero sensitive-section changes in seven
43
+ days produced an unmarked LOW finding, and `scoring.ts` excludes only passed and inconclusive
44
+ findings from the penalty numerator - so a quiet week cost health score. Now marked passed. Its
45
+ Manage Event Log Files query also failed silently, leaving SBS-MON-002 looking satisfied rather
46
+ than unevaluated; now inconclusive.
47
+ - **`named-credentials` discarded a HIGH finding it had already established.** A failed Apex scan
48
+ returned early, which also threw away the plaintext-HTTP (SBS-INT-003) and anonymous-principal
49
+ findings - both derived purely from the credential records, which had been read successfully.
50
+ The Apex scan only ever informed the unused analysis, so only that is now skipped, and it says
51
+ so. `unusedNamedCredentialsCount` is omitted rather than reported as zero when not computed.
52
+ - **`legacy-api-version` left no trace when RemoteProxy could not be filtered.** The absence of a
53
+ SOAP remote-site finding was indistinguishable from having established there are none. The
54
+ sibling `remote-sites` check is not cover for it: that reports remote sites in general and makes
55
+ no SOAP determination. Now inconclusive.
56
+
57
+ - **`named-credentials` no longer prints the word "null" into operator advice.** `Endpoint` is
58
+ nullable for External Credential-backed entries. The inventory finding handled that; the unused,
59
+ HTTP and anonymous notes interpolated it directly.
60
+
61
+ ### Security
62
+
63
+ - Removed `sprintf-js` from the dependency tree (GHSA-hp3w-g68c-fv3c, no patched release). It
64
+ reached the tree only through Jest's coverage loader via `js-yaml` 3; that loader now resolves
65
+ `js-yaml` 4, which does not depend on it. Development-only, and not in the shipped runtime.
66
+
67
+ ### Changed
68
+
69
+ - npm description corrected from 88 to 93 checks, with keywords for event monitoring, guest-user
70
+ and incident-response searches. The README feature list now includes `sf audit incident`.
71
+ - 57 unit tests across those four checks, taking the untested-check count from 33 of 93 to 29 and
72
+ the suite to 151 files / 1519 tests. Branch coverage 75%, statements 84%.
73
+
14
74
  ## [v1.14.0](https://github.com/cclabsnz/sf-audit-plugin/releases/tag/v1.14.0) — 2026-10-06
15
75
 
16
76
  Two investigation commands for Real-Time Event Monitoring **Guest User Anomaly** alerts, and every
package/README.md CHANGED
@@ -15,13 +15,14 @@
15
15
 
16
16
  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.
17
17
 
18
- - **92 read-only checks** across identity, access, data, code, integrations, monitoring, and Agentforce / GenAI
18
+ - **93 read-only checks** across identity, access, data, code, integrations, monitoring, and Agentforce / GenAI
19
19
  - **Attack-chain correlation:** links individual findings into named, multi-step attack scenarios — sixteen modelled chains, plus an emergent pass for combinations nobody has named yet (see [Attack chains](#attack-chains))
20
20
  - **Compliance mapping:** every finding mapped to **source-verified** controls across 10 frameworks (OWASP, OWASP LLM Top 10, SOC 2, ISO/IEC 27001:2022, Security Benchmark for Salesforce, NZ Privacy Act, HISO 10029, NZISM, HIPAA Security Rule, GDPR)
21
21
  - **Outputs:** a technical `html` / `md` / `json` report, or a branded, client-ready **executive report** (print-to-PDF) with priorities, remediation roadmap, and a compliance coverage matrix
22
22
  - **History & diff:** archives each run and shows security-posture drift over time
23
23
  - **Free event baseline:** `sf audit events pull` captures the org's free daily `EventLogFile` logs to local disk before the 1-day retention window drops them — no Event Monitoring / Shield add-on needed
24
24
  - **Connected-app least-privilege:** `sf audit apps` reads the `RestApi` EventLogFile to see which objects each connected app actually uses, compares that against what its run-as user is granted, and reports the over-grant per object and read/write bit — plus a suggested least-privilege permission set
25
+ - **Guest User Anomaly investigation:** `sf audit incident collect` saves the guest user's evidence for each anomaly wave, and `sf audit incident report` analyses it offline into a cited verdict: who it was, whether content came back, and whether anyone logged in ([walkthrough](https://www.softwareinsights.dev/posts/salesforce-guest-user-anomaly-investigation-sf-audit-incident/))
25
26
  - Strictly read-only (SOQL/Tooling/REST GETs + Metadata API reads); see [PERMISSIONS.md](PERMISSIONS.md) for the least-privilege access it needs
26
27
 
27
28
  ## Installation
@@ -44,7 +45,7 @@ guarantees here are checkable rather than asserted — see [Trust & verification
44
45
  sf audit security --target-org <orgAlias>
45
46
  ```
46
47
 
47
- Runs all 92 checks and writes an HTML report to the current directory. `sf audit list` prints every
48
+ Runs all 93 checks and writes an HTML report to the current directory. `sf audit list` prints every
48
49
  check id.
49
50
 
50
51
  | Flag | Default | |
@@ -94,7 +95,7 @@ All twelve flags, more examples, and what the executive report contains:
94
95
 
95
96
  ## What It Checks
96
97
 
97
- **92 read-only checks** across ten domains. Every finding is risk-rated CRITICAL → INFO, mapped to
98
+ **93 read-only checks** across ten domains. Every finding is risk-rated CRITICAL → INFO, mapped to
98
99
  compliance controls, and correlated into [attack chains](#attack-chains).
99
100
 
100
101
  | Domain | Checks |
@@ -105,7 +106,7 @@ compliance controls, and correlated into [attack chains](#attack-chains).
105
106
  | Guest & External-Facing Access | 12 |
106
107
  | Integrations, Connected Apps & Deployments | 11 |
107
108
  | Monitoring & Threat Detection | 10 |
108
- | Apex & Code Security | 9 |
109
+ | Apex & Code Security | 10 |
109
110
  | AI & Agents (Agentforce / GenAI) | 6 |
110
111
  | Org Health & Configuration | 5 |
111
112
  | Secrets & Credential Storage | 2 |
@@ -33,6 +33,10 @@ export class AuditTrailCheck {
33
33
  id: 'permission-security-changes',
34
34
  category: this.category,
35
35
  riskLevel: securityRiskLevel,
36
+ // Zero sensitive-section changes is a pass, not a LOW finding. scoring.ts excludes only
37
+ // passed and inconclusive findings from the penalty numerator, so leaving this unmarked
38
+ // charged a clean seven days against the org's health score.
39
+ passed: securityChangeCount === 0,
36
40
  title: `${securityChangeCount} permission or security configuration change(s) in the last 7 days`,
37
41
  detail: 'Frequent permission and security changes can indicate privilege escalation activity or risky configuration drift.',
38
42
  remediation: 'Review each change in Setup → Audit Trail. Investigate unexpected changes, especially outside change-management windows.',
@@ -90,7 +94,20 @@ export class AuditTrailCheck {
90
94
  }
91
95
  }
92
96
  catch {
93
- // PermissionsManageEventLogFiles may not exist in orgs without Event Monitoring — skip silently
97
+ // PermissionsManageEventLogFiles does not exist in orgs without Event Monitoring, so this
98
+ // query legitimately fails. Skipping silently was wrong: with no finding emitted, a reader
99
+ // cannot tell "nobody can delete event logs" from "we were unable to find out", and only
100
+ // the first of those is a pass. Declared inconclusive so it is scored as INFO, carries no
101
+ // penalty, and is still shown.
102
+ findings.push({
103
+ id: 'event-log-delete-permission-inconclusive',
104
+ category: this.category,
105
+ riskLevel: 'INFO',
106
+ inconclusive: true,
107
+ title: 'Manage Event Log Files assignments could not be queried',
108
+ detail: 'PermissionSetAssignment could not be filtered on PermissionsManageEventLogFiles. The field is absent in orgs without Event Monitoring, and the query also fails without access to PermissionSetAssignment, so who can delete event monitoring data is unestablished. SBS-MON-002 is unevaluated rather than satisfied.',
109
+ remediation: 'If the org has Event Monitoring, grant the audit user read access to PermissionSetAssignment and re-run. Otherwise there are no EventLogFile records to protect and no action is needed.',
110
+ });
94
111
  }
95
112
  return { findings };
96
113
  }
@@ -70,8 +70,20 @@ export class LegacyApiVersionCheck {
70
70
  }
71
71
  }
72
72
  catch {
73
- // RemoteProxy LIKE query may not be supported in all org editions — skip silently.
74
- // RemoteSitesCheck covers general remote site access concerns.
73
+ // The LIKE predicate on RemoteProxy is not supported in every edition, so this query
74
+ // legitimately fails. Skipping silently left no trace, which made the absence of a SOAP
75
+ // finding indistinguishable from having established that there are none. RemoteSitesCheck
76
+ // is not cover for this: it reports remote sites in general and makes no SOAP
77
+ // determination, so nothing else in the audit answers this question.
78
+ findings.push({
79
+ id: 'legacy-api-soap-remote-sites-inconclusive',
80
+ category: this.category,
81
+ riskLevel: 'INFO',
82
+ inconclusive: true,
83
+ title: 'Remote site settings could not be filtered for SOAP endpoints',
84
+ detail: 'Querying RemoteProxy with a LIKE predicate on EndpointUrl failed. The object is unavailable in some editions, and the query also fails without Tooling API access to it. Whether this org has active remote sites pointing at /services/Soap/ endpoints is therefore unestablished rather than answered in the negative.',
85
+ remediation: 'Grant the audit user Tooling API access to RemoteProxy and re-run. Otherwise review Setup → Remote Site Settings by hand for endpoints containing /services/Soap/.',
86
+ });
75
87
  }
76
88
  // Advisory: inbound SOAP API detection requires EventLogFile CSV analysis.
77
89
  // Salesforce stores API_TYPE per-call in EventLogFile (EventType = 'API'):
@@ -0,0 +1,10 @@
1
+ import type { SecurityCheck, CheckResult } from '../SecurityCheck.js';
2
+ import type { AuditContext } from '@cclabsnz/sf-core';
3
+ export declare class LightningMessageChannelCheck implements SecurityCheck {
4
+ readonly id = "lightning-message-channel";
5
+ readonly name = "Lightning Message Channel Exposure";
6
+ readonly category = "Code Security";
7
+ readonly description = "Finds Lightning Message Channels published to every namespace, where any component sharing the page can read or write the bus.";
8
+ run(ctx: AuditContext): Promise<CheckResult>;
9
+ }
10
+ //# sourceMappingURL=LightningMessageChannelCheck.d.ts.map
@@ -0,0 +1,107 @@
1
+ /** ManageableState values that mean the channel was defined in this org rather than installed. */
2
+ const LOCAL_STATES = new Set(['unmanaged', 'unpackaged', 'deprecatedEditable', 'released']);
3
+ export class LightningMessageChannelCheck {
4
+ id = 'lightning-message-channel';
5
+ name = 'Lightning Message Channel Exposure';
6
+ category = 'Code Security';
7
+ description = 'Finds Lightning Message Channels published to every namespace, where any component sharing the page can read or write the bus.';
8
+ async run(ctx) {
9
+ const channels = await ctx.tooling.query('SELECT Id, DeveloperName, MasterLabel, NamespacePrefix, ManageableState, IsExposed ' +
10
+ 'FROM LightningMessageChannel');
11
+ if (channels.length === 0) {
12
+ return {
13
+ findings: [{
14
+ id: 'lightning-message-channel-none',
15
+ category: this.category,
16
+ riskLevel: 'INFO',
17
+ passed: true,
18
+ title: 'No Lightning Message Channels defined',
19
+ detail: 'This org defines no Lightning Message Channels, so there is no cross-component message bus to expose.',
20
+ remediation: 'No action required.',
21
+ }],
22
+ };
23
+ }
24
+ const exposed = channels.filter((c) => c.IsExposed);
25
+ if (exposed.length === 0) {
26
+ return {
27
+ findings: [{
28
+ id: 'lightning-message-channel-ok',
29
+ category: this.category,
30
+ riskLevel: 'INFO',
31
+ passed: true,
32
+ title: `All ${channels.length} Lightning Message Channel(s) are scoped to their own namespace`,
33
+ detail: `None of the ${channels.length} channel(s) set isExposed, so each is usable only by components in the namespace that defines it.`,
34
+ remediation: 'No action required.',
35
+ }],
36
+ };
37
+ }
38
+ // Split by who can actually fix it. isExposed cannot be set back to false, so for an installed
39
+ // channel there is no remediation available inside this org at all.
40
+ const local = exposed.filter((c) => LOCAL_STATES.has(c.ManageableState ?? 'unmanaged'));
41
+ const installed = exposed.filter((c) => !LOCAL_STATES.has(c.ManageableState ?? 'unmanaged'));
42
+ const findings = [];
43
+ const setupUrl = `${ctx.orgInfo.instanceUrl}/lightning/setup/LightningMessageChannels/home`;
44
+ const label = (c) => `${c.NamespacePrefix ? `${c.NamespacePrefix}__` : ''}${c.DeveloperName}`;
45
+ if (local.length > 0) {
46
+ findings.push({
47
+ id: 'lightning-message-channel-exposed',
48
+ category: this.category,
49
+ riskLevel: 'MEDIUM',
50
+ title: `${local.length} Lightning Message Channel(s) are exposed to every namespace`,
51
+ detail: `${local.length} of ${channels.length} channel(s) set isExposed=true. Lightning Message Service is secure by default: ` +
52
+ 'per Salesforce, components in other namespaces cannot read a channel unless isExposed is true, and exposing it lets ' +
53
+ 'outside packages publish to and subscribe on it. This single boolean is therefore the whole of what separates the ' +
54
+ 'channel from code the org did not write. ' +
55
+ 'Who can take advantage is narrower than it first appears, and worth being precise about: subscribing requires importing ' +
56
+ 'the channel into a deployed component, so the actor is an installed managed package or anything else deployed into this ' +
57
+ 'org — not arbitrary script running on the page. That makes this a design exposure rather than a demonstrated leak. ' +
58
+ 'What it costs, where a channel carries record data, is that a message is a plain JavaScript object the publisher ' +
59
+ 'assembled. There is no record-level enforcement on a message, so a subscriber reads whatever was placed on the channel ' +
60
+ 'irrespective of what its own user is entitled to see, and a publisher can equally put a payload on the channel that a ' +
61
+ 'subscriber then treats as trusted input. ' +
62
+ 'Note that Visualforce supports only channels where isExposed is true, so a channel used from a Visualforce page is ' +
63
+ 'exposed because the platform requires it, not because anyone chose it. ' +
64
+ 'This check reads channel metadata only. It establishes that the door is open, not that anything sensitive passes ' +
65
+ 'through it: what each channel actually carries is visible only in the publishing component.',
66
+ remediation: 'Start by reading the publishing component to see what each channel carries, because that decides whether this is urgent ' +
67
+ 'or merely untidy: a channel passing a record id is a much smaller problem than one passing field values, and nothing in ' +
68
+ 'the metadata distinguishes them. Then check whether any installed package would be positioned to subscribe, since a ' +
69
+ 'channel exposed in an org with no third-party components on those pages has no audience today, though it will if one is ' +
70
+ 'installed later. ' +
71
+ 'If it needs closing, treat it as a design change rather than a setting change: isExposed cannot be set back to false ' +
72
+ 'once true, so closing a channel means defining a replacement with isExposed=false and migrating every publisher and ' +
73
+ 'subscriber to it. Make every subscriber validate the payload rather than trusting it, since the publisher cannot be ' +
74
+ 'authenticated. Where the channel exists only to support a Visualforce page, moving that page to a Lightning Web ' +
75
+ 'Component removes the constraint that forced the exposure.',
76
+ affectedItems: local.map((c) => ({
77
+ label: label(c),
78
+ note: c.MasterLabel && c.MasterLabel !== c.DeveloperName ? c.MasterLabel : undefined,
79
+ url: setupUrl,
80
+ })),
81
+ });
82
+ }
83
+ if (installed.length > 0) {
84
+ findings.push({
85
+ id: 'lightning-message-channel-exposed-installed',
86
+ category: this.category,
87
+ riskLevel: 'LOW',
88
+ title: `${installed.length} exposed Lightning Message Channel(s) came from an installed package`,
89
+ detail: `${installed.length} exposed channel(s) are owned by an installed package, so they cannot be changed in this org and ` +
90
+ 'the exposure is the publisher\'s decision rather than yours. They are listed separately because the reach is the same ' +
91
+ 'as a local exposed channel — any component in any namespace can read and write them — while the remediation is not ' +
92
+ 'available to you. Worth knowing because Salesforce\'s own AppExchange Security Review requires isExposed=false, so an ' +
93
+ 'installed package shipping an exposed channel is a reasonable question to put to the vendor.',
94
+ remediation: 'Raise it with the package publisher, citing the AppExchange Security Review requirement that isExposed be false. ' +
95
+ 'In the meantime, treat any page hosting the package\'s components as a shared bus and avoid placing components that ' +
96
+ 'publish sensitive payloads on the same page.',
97
+ affectedItems: installed.map((c) => ({
98
+ label: label(c),
99
+ note: c.ManageableState ?? undefined,
100
+ url: setupUrl,
101
+ })),
102
+ });
103
+ }
104
+ return { findings };
105
+ }
106
+ }
107
+ //# sourceMappingURL=LightningMessageChannelCheck.js.map
@@ -40,7 +40,25 @@ export class MfaEnforcementCheck {
40
40
  mfaEnforcedIds = new Set(mfaResult.records.map((r) => r.AssigneeId));
41
41
  }
42
42
  catch {
43
- // PermissionsMultiFactorForUiLogins may not exist in all editions — treat as none enforced
43
+ // PermissionsMultiFactorForUiLogins is absent in some editions, so this query legitimately
44
+ // fails. It previously fell through with an empty set, which is not a neutral default: with
45
+ // nothing enforced every portal user lands in `withoutMfa`, and the check then stated as
46
+ // established fact, at HIGH, that each named user lacks MFA. Over-reporting is not the safe
47
+ // direction — it produces a remediation task against real users and an SBS-AUTH-004 claim
48
+ // that no evidence supports. The MFA status is unknown, so say that and stop.
49
+ return {
50
+ findings: [
51
+ {
52
+ id: 'mfa-enforcement-inconclusive',
53
+ category: this.category,
54
+ riskLevel: 'INFO',
55
+ inconclusive: true,
56
+ title: `MFA enforcement for ${allPortalUsers.length} external/portal user(s) could not be determined`,
57
+ detail: `This org has ${allPortalUsers.length} active external/portal user(s), but PermissionSetAssignment could not be filtered on PermissionsMultiFactorForUiLogins. The field is absent in some editions, and the query also fails without access to PermissionSetAssignment. Whether these users have MFA enforced is therefore unestablished, so SBS-AUTH-004 is unevaluated rather than failed.`,
58
+ remediation: 'Grant the audit user read access to PermissionSetAssignment and re-run. If the permission does not exist in this edition, verify MFA for external users manually in Setup, and through the identity provider where portal logins are federated.',
59
+ },
60
+ ],
61
+ };
44
62
  }
45
63
  const withoutMfa = allPortalUsers.filter((u) => !mfaEnforcedIds.has(u.Id));
46
64
  const withMfa = allPortalUsers.filter((u) => mfaEnforcedIds.has(u.Id));
@@ -29,45 +29,45 @@ export class NamedCredentialsCheck {
29
29
  // Scan Apex code to find which named credentials are actually referenced
30
30
  // Named credentials are referenced as 'callout:DeveloperName' in Apex
31
31
  let apexBodies = ctx.cache.apexBodies ?? [];
32
+ // Whether the unused analysis has a basis. False only when the Apex read failed, which is
33
+ // not the same as finding no references — hence a flag rather than an empty-set default.
34
+ let apexScanned = true;
35
+ // Endpoint is nullable for External Credential-backed entries. Interpolating it directly put
36
+ // the literal "null" into advice shown to an operator.
37
+ const endpointNote = (endpoint, advice) => `${endpoint ?? '(no endpoint — External Credential)'}: ${advice}`;
32
38
  if (apexBodies.length === 0) {
33
39
  try {
34
40
  const apexRecords = await new ApexRepository(ctx.tooling).listClasses({ excludeManaged: true });
35
41
  apexBodies = apexRecords.map((r) => ({ name: r.name, body: r.body ?? '' }));
36
42
  }
37
43
  catch {
38
- // If we can't scan Apex, emit inventory only
39
- findings.push({
40
- id: 'named-credentials-inventory',
41
- category: this.category,
42
- riskLevel: 'INFO',
43
- title: `${count} named credential(s) configured`,
44
- detail: 'Named credentials provide a secure way to store endpoint URLs and authentication details for external callouts.',
45
- remediation: 'Periodically review named credentials to ensure endpoints are current and credentials remain valid.',
46
- affectedItems: records.map((r) => ({
47
- label: r.MasterLabel,
48
- url: setupUrl,
49
- note: r.Endpoint ?? '(no endpoint — External Credential)',
50
- })),
51
- });
52
- return { findings, metrics: { namedCredentialsCount: count, unusedNamedCredentialsCount: 0 } };
44
+ // Losing the Apex scan costs the unused analysis and nothing else. Returning here also
45
+ // discarded the HTTP-endpoint and anonymous-principal findings, which are derived purely
46
+ // from the credential records already in hand — including a HIGH finding for plaintext
47
+ // HTTP that was fully established. Carry on with what the records support.
48
+ apexScanned = false;
53
49
  }
54
50
  }
55
51
  const combinedApexSource = apexBodies.map((c) => c.body).join('\n');
56
- const unusedCredentials = records.filter((r) => {
57
- // Named credentials are referenced as callout:DeveloperName or callout:MasterLabel
58
- // Literal search, not a pattern built from the credential's own name: MasterLabel is free
59
- // text from Setup, and a bracket in it used to crash the check while a quantifier quietly
60
- // matched the wrong thing.
61
- return (!referencesCallout(combinedApexSource, r.DeveloperName) &&
62
- !referencesCallout(combinedApexSource, r.MasterLabel.replace(/\s+/g, '_')));
63
- });
64
- const usedCredentials = records.filter((r) => !unusedCredentials.includes(r));
52
+ const unusedCredentials = apexScanned
53
+ ? records.filter((r) => {
54
+ // Named credentials are referenced as callout:DeveloperName or callout:MasterLabel
55
+ // Literal search, not a pattern built from the credential's own name: MasterLabel is free
56
+ // text from Setup, and a bracket in it used to crash the check while a quantifier quietly
57
+ // matched the wrong thing.
58
+ return (!referencesCallout(combinedApexSource, r.DeveloperName) &&
59
+ !referencesCallout(combinedApexSource, r.MasterLabel.replace(/\s+/g, '_')));
60
+ })
61
+ : [];
62
+ const usedCredentials = apexScanned ? records.filter((r) => !unusedCredentials.includes(r)) : [];
65
63
  // Inventory finding
66
64
  findings.push({
67
65
  id: 'named-credentials-inventory',
68
66
  category: this.category,
69
67
  riskLevel: 'INFO',
70
- title: `${count} named credential(s) configured (${usedCredentials.length} used, ${unusedCredentials.length} unused in Apex)`,
68
+ title: apexScanned
69
+ ? `${count} named credential(s) configured (${usedCredentials.length} used, ${unusedCredentials.length} unused in Apex)`
70
+ : `${count} named credential(s) configured`,
71
71
  detail: 'Named credentials provide a secure way to store endpoint URLs and authentication details for external callouts.',
72
72
  remediation: 'Periodically review named credentials to ensure endpoints are current and credentials remain valid.',
73
73
  affectedItems: records.map((r) => ({
@@ -76,6 +76,17 @@ export class NamedCredentialsCheck {
76
76
  note: r.Endpoint ?? '(no endpoint — External Credential)',
77
77
  })),
78
78
  });
79
+ if (!apexScanned) {
80
+ findings.push({
81
+ id: 'named-credentials-unused-inconclusive',
82
+ category: this.category,
83
+ riskLevel: 'INFO',
84
+ inconclusive: true,
85
+ title: 'Apex could not be scanned: named credentials were not checked for references',
86
+ detail: 'Listing Apex classes through the Tooling API failed, so which credentials are referenced by code is unestablished. Absence of an "unused credentials" finding below therefore means the analysis did not run, not that every credential is in use. The endpoint and principal-type findings are unaffected: both derive from the credential records, which were read successfully.',
87
+ remediation: 'Grant the audit user Tooling API access to ApexClass and re-run to get the unused-credential analysis.',
88
+ });
89
+ }
79
90
  // Flag unused credentials
80
91
  if (unusedCredentials.length > 0) {
81
92
  findings.push({
@@ -88,7 +99,7 @@ export class NamedCredentialsCheck {
88
99
  affectedItems: unusedCredentials.map((r) => ({
89
100
  label: r.MasterLabel,
90
101
  url: setupUrl,
91
- note: `${r.Endpoint}: verify if still required, delete if orphaned`,
102
+ note: endpointNote(r.Endpoint, 'verify if still required, delete if orphaned'),
92
103
  })),
93
104
  });
94
105
  }
@@ -105,7 +116,7 @@ export class NamedCredentialsCheck {
105
116
  affectedItems: httpEndpoints.map((r) => ({
106
117
  label: r.MasterLabel,
107
118
  url: setupUrl,
108
- note: `${r.Endpoint}: migrate to HTTPS`,
119
+ note: endpointNote(r.Endpoint, 'migrate to HTTPS'),
109
120
  })),
110
121
  });
111
122
  }
@@ -123,7 +134,7 @@ export class NamedCredentialsCheck {
123
134
  affectedItems: anonymousCreds.map((r) => ({
124
135
  label: r.MasterLabel,
125
136
  url: setupUrl,
126
- note: `${r.Endpoint}: verify that no authentication is required`,
137
+ note: endpointNote(r.Endpoint, 'verify that no authentication is required'),
127
138
  })),
128
139
  });
129
140
  }
@@ -131,7 +142,9 @@ export class NamedCredentialsCheck {
131
142
  findings,
132
143
  metrics: {
133
144
  namedCredentialsCount: count,
134
- unusedNamedCredentialsCount: unusedCredentials.length,
145
+ // Omitted when the Apex scan failed: zero would be read as "none are unused", which was
146
+ // never established.
147
+ ...(apexScanned ? { unusedNamedCredentialsCount: unusedCredentials.length } : {}),
135
148
  },
136
149
  };
137
150
  }
@@ -40,6 +40,7 @@ import { SiemIntegrationCheck } from './impl/SiemIntegrationCheck.js';
40
40
  import { ApexCrudFLSCheck } from './impl/ApexCrudFLSCheck.js';
41
41
  import { ApexRestEndpointCheck } from './impl/ApexRestEndpointCheck.js';
42
42
  import { VisualforceXssCheck } from './impl/VisualforceXssCheck.js';
43
+ import { LightningMessageChannelCheck } from './impl/LightningMessageChannelCheck.js';
43
44
  import { CertificateExpiryCheck } from './impl/CertificateExpiryCheck.js';
44
45
  import { InstalledPackagesCheck } from './impl/InstalledPackagesCheck.js';
45
46
  import { TrustedIPRangesCheck } from './impl/TrustedIPRangesCheck.js';
@@ -187,6 +188,7 @@ export const CHECKS = [
187
188
  new GuestExecutableApexCheck(), // reads apexBodies — guest-reachable Apex sharing
188
189
  new ApexRestEndpointCheck(), // reads apexBodies
189
190
  new VisualforceXssCheck(), // writes vfPageBodies
191
+ new LightningMessageChannelCheck(), // no deps
190
192
  new EventMonitoringCheck(), // writes eventLogSummary
191
193
  new GuestTrafficAnomalyCheck(), // reads eventLogSummary — anonymizer IPs, bursts, GraphQL recon in guest logs
192
194
  new MfaRegistrationCheck(), // writes mfaRegistrations
@@ -44,6 +44,7 @@ const BASE_CHECK_CONTROL_MAP = {
44
44
  'apex-crud-fls': ['OWASP-A01', 'SOC2-CC6.1', 'ISO-A.8.3'],
45
45
  'apex-rest-endpoint': ['OWASP-A01', 'OWASP-A07', 'SOC2-CC6.1', 'ISO-A.8.3'],
46
46
  'visualforce-xss': ['OWASP-A03', 'SOC2-CC6.1', 'ISO-A.8.25'],
47
+ 'lightning-message-channel': ['OWASP-A01', 'OWASP-A03', 'SOC2-CC6.1', 'ISO-A.8.25'],
47
48
  'certificate-expiry': ['OWASP-A02', 'SOC2-CC6.7', 'ISO-A.8.24'],
48
49
  'installed-packages': ['OWASP-A06', 'OWASP-A08', 'SOC2-CC9.2', 'ISO-A.8.25'],
49
50
  'trusted-ip-ranges': ['OWASP-A07', 'SOC2-CC6.1', 'ISO-A.8.3', 'SBS-AUTH-003'],
@@ -131,7 +132,7 @@ const DOMAIN = {
131
132
  logging: ['audit-trail', 'apex-logging', 'event-monitoring', 'siem-integration', 'anonymous-apex-audit',
132
133
  'debug-log-access', 'transaction-security-policy', 'threat-detection', 'guest-traffic-anomaly',
133
134
  'login-anomaly'],
134
- devSecurity: ['code-security', 'visualforce-xss', 'scheduled-apex'],
135
+ devSecurity: ['code-security', 'visualforce-xss', 'scheduled-apex', 'lightning-message-channel'],
135
136
  network: ['remote-sites', 'csp-trusted-sites', 'connected-apps', 'connected-app-scope', 'connected-app-inactivity', 'oauth-token-inventory', 'cors-allowlist',
136
137
  'email-security', 'outbound-messages', 'experience-csp'],
137
138
  dataGovernance: ['data-classification', 'field-history-tracking', 'sandbox-data-masking'],
@@ -39,6 +39,7 @@ export const CHECK_META = {
39
39
  'apex-crud-fls': { effort: 'project', impact: 'Apex skipping CRUD/FLS checks lets callers read or write records and fields they have no rights to.' },
40
40
  'apex-rest-endpoint': { effort: 'project', impact: 'without-sharing @RestResource endpoints expose records to REST callers without record-level access control.' },
41
41
  'visualforce-xss': { effort: 'moderate', impact: 'Unescaped Visualforce merge fields let attackers inject scripts that run in victims’ sessions.' },
42
+ 'lightning-message-channel': { effort: 'project', impact: 'An exposed message channel is readable and writable by any component in any namespace, and the exposure cannot be reversed.' },
42
43
  'certificate-expiry': { effort: 'quick', impact: 'An expired certificate breaks integrations or, if ignored, invites insecure fallback.' },
43
44
  'installed-packages': { effort: 'moderate', impact: 'Unmanaged or beta packages in production can carry unvetted code with broad org access.' },
44
45
  'trusted-ip-ranges': { effort: 'quick', impact: 'Overly broad trusted IP ranges silently exempt large networks from MFA.' },
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cclabsnz/sf-audit",
3
- "version": "1.14.0",
4
- "description": "Read-only Salesforce security audit for the sf CLI: 88 checks, attack-chain correlation, A-F risk grading, and compliance mapping to OWASP, SOC 2, ISO 27001, NZISM and more.",
3
+ "version": "1.15.0",
4
+ "description": "Read-only Salesforce security audit for the sf CLI: 93 checks, attack-chain correlation, A-F risk grading, compliance mapping, free EventLogFile capture, and Guest User Anomaly investigation.",
5
5
  "keywords": [
6
6
  "salesforce",
7
7
  "salesforce-cli",
@@ -19,7 +19,16 @@
19
19
  "agentforce",
20
20
  "devsecops",
21
21
  "permissions",
22
- "audit"
22
+ "audit",
23
+ "salesforce-security",
24
+ "event-monitoring",
25
+ "eventlogfile",
26
+ "guest-user",
27
+ "experience-cloud",
28
+ "incident-response",
29
+ "forensics",
30
+ "connected-apps",
31
+ "health-check"
23
32
  ],
24
33
  "license": "Apache-2.0",
25
34
  "type": "module",
@@ -99,11 +108,11 @@
99
108
  "pnpm": {
100
109
  "overrides": {
101
110
  "form-data": "^4.0.6",
102
- "js-yaml@3": "^3.15.2",
103
111
  "handlebars": "^4.7.9",
104
112
  "brace-expansion": "^5.0.11",
105
113
  "fast-uri@3": "^3.1.8",
106
- "browserslist": "^4.28.7"
114
+ "browserslist": "^4.28.7",
115
+ "@istanbuljs/load-nyc-config>js-yaml": "^4.1.1"
107
116
  }
108
117
  }
109
118
  }