@cclabsnz/sf-audit 1.16.0 → 1.18.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 (170) hide show
  1. package/CHANGELOG.md +172 -1
  2. package/PERMISSIONS.md +139 -0
  3. package/README.md +98 -26
  4. package/config/scoring.sample.json +104 -5
  5. package/docs/permissionset/SF_Audit_ReadOnly.permissionset-meta.xml +54 -0
  6. package/lib/apps/analyzeApps.d.ts +8 -2
  7. package/lib/apps/analyzeApps.js +7 -2
  8. package/lib/apps/apiLogSource.d.ts +39 -0
  9. package/lib/apps/apiLogSource.js +75 -0
  10. package/lib/apps/appResolver.js +30 -4
  11. package/lib/apps/grantedAccess.js +16 -3
  12. package/lib/apps/leastPrivilege.d.ts +3 -1
  13. package/lib/apps/leastPrivilege.js +7 -3
  14. package/lib/apps/permissionSetGenerator.d.ts +22 -0
  15. package/lib/apps/permissionSetGenerator.js +100 -0
  16. package/lib/apps/types.d.ts +6 -0
  17. package/lib/apps/usageCollector.d.ts +7 -1
  18. package/lib/apps/usageCollector.js +57 -26
  19. package/lib/chains/CapabilityRegistry.js +26 -0
  20. package/lib/chains/ChainEngine.js +11 -1
  21. package/lib/chains/namedChains.js +130 -24
  22. package/lib/checks/CheckEngine.d.ts +3 -1
  23. package/lib/checks/CheckEngine.js +65 -26
  24. package/lib/checks/impl/AgentUserPrivilegeCheck.js +5 -4
  25. package/lib/checks/impl/AnonymousApexAuditCheck.js +41 -8
  26. package/lib/checks/impl/ApexCrudFLSCheck.js +45 -10
  27. package/lib/checks/impl/ApexSharingCheck.js +19 -26
  28. package/lib/checks/impl/ApiClientPermissionCheck.js +21 -5
  29. package/lib/checks/impl/AuditTrailCheck.js +23 -8
  30. package/lib/checks/impl/AuthProviderRegistrationHandlerCheck.d.ts +10 -0
  31. package/lib/checks/impl/AuthProviderRegistrationHandlerCheck.js +131 -0
  32. package/lib/checks/impl/CertificateExpiryCheck.js +2 -1
  33. package/lib/checks/impl/ConnectedAppScopeCheck.js +61 -5
  34. package/lib/checks/impl/ConnectedAppsCheck.js +60 -5
  35. package/lib/checks/impl/ContentLinksCheck.js +33 -9
  36. package/lib/checks/impl/CorsAllowlistCheck.js +3 -2
  37. package/lib/checks/impl/DataClassificationCheck.js +15 -13
  38. package/lib/checks/impl/DataCloudDataSpaceIsolationCheck.d.ts +10 -0
  39. package/lib/checks/impl/DataCloudDataSpaceIsolationCheck.js +116 -0
  40. package/lib/checks/impl/DebugLogAccessCheck.js +4 -4
  41. package/lib/checks/impl/DelegatedAdministrationGroupsCheck.d.ts +10 -0
  42. package/lib/checks/impl/DelegatedAdministrationGroupsCheck.js +76 -0
  43. package/lib/checks/impl/DelegatedAuthenticationExposureCheck.d.ts +10 -0
  44. package/lib/checks/impl/DelegatedAuthenticationExposureCheck.js +105 -0
  45. package/lib/checks/impl/DeploymentIdentityCheck.js +32 -5
  46. package/lib/checks/impl/EmailSecurityCheck.d.ts +1 -1
  47. package/lib/checks/impl/EmailSecurityCheck.js +14 -34
  48. package/lib/checks/impl/EncryptionCoverageCheck.js +21 -15
  49. package/lib/checks/impl/EnhancedDomainsCheck.js +17 -2
  50. package/lib/checks/impl/EscalationPermsCheck.d.ts +2 -0
  51. package/lib/checks/impl/EscalationPermsCheck.js +88 -21
  52. package/lib/checks/impl/ExperienceCloudSiteCheck.js +56 -5
  53. package/lib/checks/impl/ExternalAccountHierarchyExposureCheck.d.ts +10 -0
  54. package/lib/checks/impl/ExternalAccountHierarchyExposureCheck.js +65 -0
  55. package/lib/checks/impl/ExternalCredentialsCheck.js +6 -3
  56. package/lib/checks/impl/FailedLoginCheck.js +36 -9
  57. package/lib/checks/impl/FieldHistoryTrackingCheck.js +14 -11
  58. package/lib/checks/impl/FlowHttpCalloutCredentialBypassCheck.d.ts +10 -0
  59. package/lib/checks/impl/FlowHttpCalloutCredentialBypassCheck.js +115 -0
  60. package/lib/checks/impl/GenAiPromptTemplateGroundingCheck.d.ts +10 -0
  61. package/lib/checks/impl/GenAiPromptTemplateGroundingCheck.js +227 -0
  62. package/lib/checks/impl/GuestExecutableApexCheck.d.ts +1 -1
  63. package/lib/checks/impl/GuestExecutableApexCheck.js +105 -14
  64. package/lib/checks/impl/GuestRecordAccessPolicyCheck.js +52 -11
  65. package/lib/checks/impl/HardcodedCredentialsCheck.js +7 -2
  66. package/lib/checks/impl/HealthCheckCheck.js +1 -0
  67. package/lib/checks/impl/HighAssuranceSessionCheck.js +16 -11
  68. package/lib/checks/impl/InactiveUsersCheck.js +1 -1
  69. package/lib/checks/impl/InboundEmailHandlerExposureCheck.d.ts +10 -0
  70. package/lib/checks/impl/InboundEmailHandlerExposureCheck.js +136 -0
  71. package/lib/checks/impl/IntegrationLeastPrivilegeCheck.js +7 -6
  72. package/lib/checks/impl/InternalUserMfaCheck.js +26 -8
  73. package/lib/checks/impl/IpRestrictionsCheck.js +35 -16
  74. package/lib/checks/impl/LoginAccessPolicyCheck.js +5 -4
  75. package/lib/checks/impl/LoginAnomalyCheck.js +10 -7
  76. package/lib/checks/impl/LoginSessionCheck.js +2 -0
  77. package/lib/checks/impl/MfaEnforcementCheck.js +23 -6
  78. package/lib/checks/impl/MfaMethodStrengthCheck.js +18 -3
  79. package/lib/checks/impl/MfaRegistrationCheck.js +4 -3
  80. package/lib/checks/impl/MyDomainLoginPolicyCheck.js +23 -10
  81. package/lib/checks/impl/OauthDeviceAndAssetTokenFlowsCheck.d.ts +10 -0
  82. package/lib/checks/impl/OauthDeviceAndAssetTokenFlowsCheck.js +84 -0
  83. package/lib/checks/impl/OrgWideEmailSpoofingCheck.d.ts +10 -0
  84. package/lib/checks/impl/OrgWideEmailSpoofingCheck.js +106 -0
  85. package/lib/checks/impl/OutboundMessagesCheck.js +48 -6
  86. package/lib/checks/impl/PackagePostInstallSupplyChainCheck.d.ts +10 -0
  87. package/lib/checks/impl/PackagePostInstallSupplyChainCheck.js +89 -0
  88. package/lib/checks/impl/PlatformEventSubscriberContextCheck.d.ts +10 -0
  89. package/lib/checks/impl/PlatformEventSubscriberContextCheck.js +88 -0
  90. package/lib/checks/impl/PrivilegedAccessCheck.js +12 -5
  91. package/lib/checks/impl/ReleaseUpdatesCheck.js +18 -3
  92. package/lib/checks/impl/RemoteSitesCheck.js +4 -4
  93. package/lib/checks/impl/RestrictionRulesIntegrityCheck.d.ts +10 -0
  94. package/lib/checks/impl/RestrictionRulesIntegrityCheck.js +105 -0
  95. package/lib/checks/impl/SeparationOfDutiesCheck.js +14 -3
  96. package/lib/checks/impl/ShieldTenantSecretLifecycleCheck.d.ts +10 -0
  97. package/lib/checks/impl/ShieldTenantSecretLifecycleCheck.js +90 -0
  98. package/lib/checks/impl/SoapLoginApiAuthCheck.js +20 -8
  99. package/lib/checks/impl/SsoEnforcementCheck.js +16 -5
  100. package/lib/checks/impl/TransactionSecurityPolicyCheck.js +5 -5
  101. package/lib/checks/impl/TrustedIPRangesCheck.js +18 -9
  102. package/lib/checks/impl/UsersAndAdminsCheck.js +24 -4
  103. package/lib/checks/permCatalog.js +1 -1
  104. package/lib/checks/registry.js +30 -0
  105. package/lib/checks/support/apexAccess.d.ts +56 -0
  106. package/lib/checks/support/apexAccess.js +127 -0
  107. package/lib/checks/support/missingObject.d.ts +13 -0
  108. package/lib/checks/support/missingObject.js +37 -0
  109. package/lib/checks/support/schema.d.ts +17 -0
  110. package/lib/checks/support/schema.js +41 -0
  111. package/lib/commands/audit/apps.d.ts +1 -0
  112. package/lib/commands/audit/apps.js +86 -30
  113. package/lib/commands/audit/diff.js +2 -2
  114. package/lib/commands/audit/events/pull.js +3 -1
  115. package/lib/commands/audit/history.js +2 -2
  116. package/lib/commands/audit/incident/collect.js +3 -1
  117. package/lib/commands/audit/incident/report.js +2 -2
  118. package/lib/commands/audit/security.d.ts +3 -0
  119. package/lib/commands/audit/security.js +65 -10
  120. package/lib/commands/audit/timeline.js +2 -2
  121. package/lib/compliance/mapping.js +28 -7
  122. package/lib/findings/AuditResult.d.ts +10 -0
  123. package/lib/findings/CheckMeta.js +15 -0
  124. package/lib/findings/Finding.d.ts +4 -0
  125. package/lib/findings/ScoringConfig.d.ts +10 -8
  126. package/lib/findings/ScoringConfig.js +12 -5
  127. package/lib/findings/coverage.d.ts +34 -0
  128. package/lib/findings/coverage.js +42 -0
  129. package/lib/findings/exitCode.js +1 -1
  130. package/lib/findings/loadScoringConfig.js +51 -8
  131. package/lib/findings/scoring.js +61 -10
  132. package/lib/history/HistoryStore.js +9 -3
  133. package/lib/history/archivePolicy.d.ts +19 -0
  134. package/lib/history/archivePolicy.js +34 -0
  135. package/lib/incident/bundleIo.js +4 -3
  136. package/lib/incident/collect/collectBundle.d.ts +1 -1
  137. package/lib/incident/collect/collectBundle.js +4 -3
  138. package/lib/incident/collect/streamGuestLogs.d.ts +1 -1
  139. package/lib/incident/collect/streamGuestLogs.js +3 -2
  140. package/lib/incident/csv.js +4 -4
  141. package/lib/incident/render/evidence.js +3 -3
  142. package/lib/incident/render/html.js +2 -3
  143. package/lib/index.d.ts +2 -0
  144. package/lib/index.js +2 -0
  145. package/lib/lib/packageInfo.d.ts +6 -0
  146. package/lib/lib/packageInfo.js +19 -0
  147. package/lib/preflight/permissionMap.d.ts +2 -20
  148. package/lib/preflight/permissionMap.js +2 -43
  149. package/lib/preflight/permissions.d.ts +25 -0
  150. package/lib/preflight/permissions.js +50 -0
  151. package/lib/renderers/AttackChainDagRenderer.d.ts +7 -0
  152. package/lib/renderers/AttackChainDagRenderer.js +139 -0
  153. package/lib/renderers/ClientReportRenderer.d.ts +2 -0
  154. package/lib/renderers/ClientReportRenderer.js +34 -6
  155. package/lib/renderers/DiffHtmlRenderer.js +2 -7
  156. package/lib/renderers/HistoryRenderer.js +19 -11
  157. package/lib/renderers/HtmlRenderer.js +23 -6
  158. package/lib/renderers/MarkdownRenderer.js +11 -1
  159. package/lib/renderers/SarifRenderer.d.ts +43 -0
  160. package/lib/renderers/SarifRenderer.js +250 -0
  161. package/lib/report/ExecutivePriorities.js +1 -1
  162. package/lib/report/RemediationRoadmap.d.ts +5 -1
  163. package/lib/report/RemediationRoadmap.js +6 -2
  164. package/lib/waivers/WaiverLoader.d.ts +28 -0
  165. package/lib/waivers/WaiverLoader.js +103 -0
  166. package/lib/waivers/WaiverModel.d.ts +32 -0
  167. package/lib/waivers/WaiverModel.js +28 -0
  168. package/lib/waivers/applyWaivers.d.ts +22 -0
  169. package/lib/waivers/applyWaivers.js +85 -0
  170. package/package.json +6 -4
@@ -6,6 +6,9 @@ const CI_CD_APP_PATTERNS = [
6
6
  /flosum/i, /ownbackup/i, /metazoa/i, /pipeline/i, /deploy/i,
7
7
  ];
8
8
  const ADMIN_PROFILE_RE = /admin|system administrator/i;
9
+ // SetupAuditTrail.Section cannot be filtered in SOQL; these are matched in code.
10
+ const DEPLOY_SECTIONS = new Set(['Change Sets', 'Developer Tools', 'Packages', 'Metadata']);
11
+ const MAX_TRAIL_ROWS = 10000;
9
12
  export class DeploymentIdentityCheck {
10
13
  id = 'deployment-identity';
11
14
  name = 'Deployment Identity';
@@ -40,29 +43,50 @@ export class DeploymentIdentityCheck {
40
43
  // Signal 2 (1 query): SetupAuditTrail entries in deploy-related sections over 90 days.
41
44
  // This reveals how many distinct users are performing deployment operations and whether
42
45
  // those users are individual admins rather than a designated deployment identity.
46
+ // SetupAuditTrail.Section cannot be filtered in SOQL: the trail is read (bounded) and the
47
+ // deploy sections are matched here. Up to 300 matches are analysed, as before.
43
48
  let deployRecords;
49
+ // True when the trail or the deploy matches were cut off, so deployers may be missing.
50
+ let truncated = false;
44
51
  try {
45
- deployRecords = await ctx.soql.queryAll(`SELECT CreatedDate, CreatedBy.Id, CreatedBy.Username, CreatedBy.Profile.Name,
52
+ const trail = await ctx.soql.queryAll(`SELECT CreatedDate, CreatedBy.Id, CreatedBy.Username, CreatedBy.Profile.Name,
46
53
  Section, Action, Display
47
54
  FROM SetupAuditTrail
48
55
  WHERE CreatedDate > LAST_N_DAYS:90
49
- AND Section IN ('Change Sets', 'Developer Tools', 'Packages', 'Metadata')
50
56
  ORDER BY CreatedDate DESC
51
- LIMIT 300`);
57
+ LIMIT ${MAX_TRAIL_ROWS}`);
58
+ const matches = trail.filter((r) => DEPLOY_SECTIONS.has(r.Section));
59
+ truncated = trail.length >= MAX_TRAIL_ROWS || matches.length > 300;
60
+ deployRecords = matches.slice(0, 300);
52
61
  }
53
- catch {
62
+ catch (err) {
54
63
  findings.push({
55
64
  id: 'deployment-audit-trail-inaccessible',
56
65
  category: this.category,
57
66
  riskLevel: 'MEDIUM',
58
67
  inconclusive: true,
59
68
  title: 'Deployment audit trail could not be read: SBS-DEP-003 unverified',
60
- detail: 'SetupAuditTrail was not accessible. Deployment activity from the past 90 days cannot be analyzed for unauthorized modifications. Without this data it is impossible to determine whether deployments are performed by a single designated identity.',
69
+ detail: `The SetupAuditTrail query failed (${err instanceof Error ? err.message : String(err)}). Deployment activity from the past 90 days cannot be analyzed for unauthorized modifications. Without this data it is impossible to determine whether deployments are performed by a single designated identity.`,
61
70
  remediation: 'Grant "View Setup and Configuration" permission to the audit user to enable audit trail analysis.',
62
71
  });
63
72
  return { findings };
64
73
  }
74
+ // MN-051: with the trail cut off, "nobody deployed" and "one identity deployed" are unproven.
75
+ const partialFinding = () => ({
76
+ id: 'deployment-identity-partial',
77
+ category: this.category,
78
+ riskLevel: 'INFO',
79
+ inconclusive: true,
80
+ title: `Deployment identity only partly assessed: the 90-day audit trail exceeds what was read`,
81
+ detail: `The 90-day Setup Audit Trail holds more than ${MAX_TRAIL_ROWS} entries (or more than 300 deployment entries), so only the most recent were analysed. Older deployers in the window may be missing, so a single-identity or no-activity result is not established.`,
82
+ remediation: 'Review deployment activity in Setup → View Setup Audit Trail, or export the full trail for review.',
83
+ affectedItems: [{ label: 'Setup Audit Trail', url: auditUrl }],
84
+ });
65
85
  if (deployRecords.length === 0 && ciCdApps.length === 0) {
86
+ if (truncated) {
87
+ findings.push(partialFinding());
88
+ return { findings };
89
+ }
66
90
  findings.push({
67
91
  id: 'deployment-no-activity',
68
92
  category: this.category,
@@ -109,6 +133,9 @@ export class DeploymentIdentityCheck {
109
133
  })),
110
134
  });
111
135
  }
136
+ else if (uniqueDeployers.length === 1 && truncated) {
137
+ findings.push(partialFinding());
138
+ }
112
139
  else if (uniqueDeployers.length === 1) {
113
140
  const d = uniqueDeployers[0];
114
141
  findings.push({
@@ -4,7 +4,7 @@ export declare class EmailSecurityCheck implements SecurityCheck {
4
4
  readonly id = "email-security";
5
5
  readonly name = "Email Security & Spoofing";
6
6
  readonly category = "External Connectivity";
7
- readonly description = "Flags inbound email services that accept mail from any sender or run Apex without authentication, and org-wide send-as addresses available to every profile";
7
+ readonly description = "Flags inbound email services that accept mail from any sender or run Apex without authentication";
8
8
  run(ctx: AuditContext): Promise<CheckResult>;
9
9
  }
10
10
  //# sourceMappingURL=EmailSecurityCheck.d.ts.map
@@ -22,45 +22,25 @@ export class EmailSecurityCheck {
22
22
  id = 'email-security';
23
23
  name = 'Email Security & Spoofing';
24
24
  category = 'External Connectivity';
25
- description = 'Flags inbound email services that accept mail from any sender or run Apex without authentication, and org-wide send-as addresses available to every profile';
25
+ description = 'Flags inbound email services that accept mail from any sender or run Apex without authentication';
26
26
  async run(ctx) {
27
27
  const findings = [];
28
28
  const baseUrl = ctx.orgInfo.instanceUrl;
29
- const owaUrl = `${baseUrl}/lightning/setup/OrgWideEmailAddresses/home`;
30
29
  const svcUrl = `${baseUrl}/lightning/setup/EmailToApex/home`;
31
- // 1. Org-wide email addresses available to all profiles — any user can send "as" them.
32
- const owa = await tryQuery(() => ctx.soql.queryAll('SELECT Id, Address, DisplayName, IsAllowAllProfiles FROM OrgWideEmailAddress'), findings, this.category, 'email-security-owa-inaccessible', 'Org-wide email addresses');
33
- if (owa) {
34
- const allProfiles = owa.filter((r) => r.IsAllowAllProfiles);
35
- if (allProfiles.length > 0) {
36
- findings.push({
37
- id: 'email-security-owa-all-profiles',
38
- category: this.category,
39
- riskLevel: 'MEDIUM',
40
- title: `${allProfiles.length} org-wide email address(es) are available to all profiles`,
41
- detail: 'An org-wide email address available to all profiles lets any user send email that appears to come from that address. This enables internal impersonation (e.g. spoofing a finance or executive sender) in phishing campaigns originating from inside the org.',
42
- remediation: 'Restrict each org-wide email address to the specific profiles that legitimately need to send as it, rather than allowing all profiles.',
43
- affectedItems: allProfiles.map((r) => ({
44
- label: r.Address,
45
- url: owaUrl,
46
- note: `${r.DisplayName || 'no display name'}: restrict to specific profiles`,
47
- })),
48
- });
49
- }
50
- else if (owa.length > 0) {
51
- findings.push({
52
- id: 'email-security-owa-ok',
53
- category: this.category,
54
- riskLevel: 'LOW',
55
- passed: true,
56
- title: `${owa.length} org-wide email address(es) are scoped to specific profiles`,
57
- detail: 'No org-wide email address is exposed to all profiles, limiting send-as impersonation.',
58
- remediation: 'Continue to scope org-wide addresses to the profiles that need them.',
59
- });
60
- }
61
- }
62
- // 2. Inbound email services (Email-to-Apex) — internet-reachable Apex triggers.
30
+ // Org-wide send-as addresses are reported once, by org-wide-email-spoofing.
31
+ // Inbound email services (Email-to-Apex) — internet-reachable Apex triggers.
63
32
  const services = await tryQuery(() => ctx.soql.queryAll('SELECT Id, FunctionName, IsActive, IsAuthenticationRequired FROM EmailServicesFunction WHERE IsActive = true'), findings, this.category, 'email-security-services-inaccessible', 'Inbound email services');
33
+ if (services && services.length === 0) {
34
+ findings.push({
35
+ id: 'email-security-services-none',
36
+ category: this.category,
37
+ riskLevel: 'LOW',
38
+ passed: true,
39
+ title: 'No active inbound email services',
40
+ detail: 'No inbound email service is active, so no Apex runs on receipt of email.',
41
+ remediation: 'If one is added, require authentication and restrict accepted senders.',
42
+ });
43
+ }
64
44
  if (services && services.length > 0) {
65
45
  const unauthenticated = services.filter((s) => !s.IsAuthenticationRequired);
66
46
  if (unauthenticated.length > 0) {
@@ -1,4 +1,7 @@
1
1
  const MAX_OBJECTS = 25; // cap describe calls
2
+ // FieldDefinition must be filtered by entity ("a filter on a reified column is required"), so the
3
+ // scan covers these key standard objects, the same set data-classification checks.
4
+ const SCANNED_OBJECTS = ['Account', 'Contact', 'Lead', 'Opportunity', 'Case', 'Contract', 'User', 'Individual'];
2
5
  /**
3
6
  * Cross-references data classification against ACTUAL field encryption. `data-
4
7
  * classification` confirms Shield is licensed and that fields are classified;
@@ -18,20 +21,23 @@ export class EncryptionCoverageCheck {
18
21
  // 1. Sensitive fields = those with a ComplianceGroup (PII/PCI/HIPAA/GDPR/...).
19
22
  let classified;
20
23
  try {
21
- classified = await ctx.tooling.query(`SELECT EntityDefinition.QualifiedApiName obj, QualifiedApiName field
22
- FROM FieldDefinition WHERE ComplianceGroup != null`);
24
+ classified = await ctx.tooling.query(`SELECT EntityDefinition.QualifiedApiName, QualifiedApiName
25
+ FROM FieldDefinition
26
+ WHERE EntityDefinition.QualifiedApiName IN (${SCANNED_OBJECTS.map((o) => `'${o}'`).join(', ')})
27
+ AND ComplianceGroup != null`);
23
28
  }
24
- catch {
25
- findings.push(this.inconclusive('Classified fields could not be queried (Tooling API access needed)'));
29
+ catch (err) {
30
+ findings.push(this.inconclusive('Classified fields could not be queried', `The Tooling API FieldDefinition query failed: ${err instanceof Error ? err.message : String(err)}`));
26
31
  return { findings };
27
32
  }
28
33
  const fieldsByObj = new Map();
29
34
  for (const c of classified) {
30
- if (!c.obj || !c.field)
35
+ const obj = c.EntityDefinition?.QualifiedApiName;
36
+ if (!obj || !c.QualifiedApiName)
31
37
  continue;
32
- const set = fieldsByObj.get(c.obj) ?? new Set();
33
- set.add(c.field);
34
- fieldsByObj.set(c.obj, set);
38
+ const set = fieldsByObj.get(obj) ?? new Set();
39
+ set.add(c.QualifiedApiName);
40
+ fieldsByObj.set(obj, set);
35
41
  }
36
42
  if (fieldsByObj.size === 0) {
37
43
  findings.push({
@@ -39,8 +45,8 @@ export class EncryptionCoverageCheck {
39
45
  category: this.category,
40
46
  riskLevel: 'LOW',
41
47
  passed: true,
42
- title: 'No fields are classified as sensitive',
43
- detail: 'No fields carry a ComplianceGroup (data classification), so encryption coverage cannot be assessed against a sensitivity baseline. Classification is the prerequisite — see the data-classification check.',
48
+ title: 'No fields are classified as sensitive on the key standard objects',
49
+ detail: `No fields on ${SCANNED_OBJECTS.join(', ')} carry a ComplianceGroup (data classification), so encryption coverage cannot be assessed against a sensitivity baseline. Custom objects are not scanned. Classification is the prerequisite — see the data-classification check.`,
44
50
  remediation: 'Classify PII/PHI fields (Setup → Data Classification) first, then encrypt the sensitive ones with Shield Platform Encryption.',
45
51
  });
46
52
  return { findings };
@@ -66,7 +72,7 @@ export class EncryptionCoverageCheck {
66
72
  }
67
73
  }
68
74
  if (!describedAny) {
69
- findings.push(this.inconclusive('Object describes were not accessible, so field encryption could not be confirmed'));
75
+ findings.push(this.inconclusive('Object describes were not accessible, so field encryption could not be confirmed', 'The audit user could not describe the classified objects, so per-field encryption is unknown.'));
70
76
  return { findings };
71
77
  }
72
78
  if (unencrypted.length > 0) {
@@ -87,21 +93,21 @@ export class EncryptionCoverageCheck {
87
93
  riskLevel: 'LOW',
88
94
  passed: true,
89
95
  title: 'All classified sensitive fields checked are encrypted at rest',
90
- detail: `Every classified field found across ${Math.min(fieldsByObj.size, MAX_OBJECTS)} object(s) is encrypted with Shield Platform Encryption.`,
96
+ detail: `Every classified field found across ${Math.min(fieldsByObj.size, MAX_OBJECTS)} object(s) is encrypted with Shield Platform Encryption. Scanned: ${SCANNED_OBJECTS.join(', ')}; custom objects are not scanned.`,
91
97
  remediation: 'Keep encryption policy in sync as new sensitive fields are added and classified.',
92
98
  });
93
99
  }
94
100
  return { findings };
95
101
  }
96
- inconclusive(what) {
102
+ inconclusive(what, detail) {
97
103
  return {
98
104
  id: 'encryption-coverage-inconclusive',
99
105
  category: this.category,
100
106
  riskLevel: 'INFO',
101
107
  inconclusive: true,
102
108
  title: `${what}`,
103
- detail: 'The audit user could not gather the classification/describe data needed to assess encryption coverage.',
104
- remediation: 'Grant the audit user Tooling API access and object describe (View Setup and Configuration), then re-run.',
109
+ detail: `${detail} Encryption coverage is unassessed, not clean.`,
110
+ remediation: 'Check the error above. If it is an access error, confirm the audit user has API Enabled and View Setup and Configuration, then re-run.',
105
111
  };
106
112
  }
107
113
  }
@@ -1,3 +1,17 @@
1
+ // Organization has no MyDomain field. Every org's My Domain is the subdomain of its instance URL
2
+ // (<name>.my.salesforce.com, or a sandbox/develop/scratch variant); a legacy instance host such as
3
+ // na1.salesforce.com means no My Domain.
4
+ const MY_DOMAIN_HOST = /^(.+?)\.(?:(?:sandbox|develop|scratch|trailblaze)\.)?my\.(?:salesforce\.com|salesforce\.mil|sfcrmproducts\.cn)$/i;
5
+ function myDomainOf(instanceUrl) {
6
+ let host = instanceUrl;
7
+ try {
8
+ host = new URL(instanceUrl).hostname;
9
+ }
10
+ catch {
11
+ // keep the raw string
12
+ }
13
+ return MY_DOMAIN_HOST.exec(host)?.[1] ?? null;
14
+ }
1
15
  // Enhanced Domains changes the URL format for Salesforce org pages, Experience Cloud sites,
2
16
  // Visualforce pages, and Lightning apps. The new format uses org-specific subdomains
3
17
  // that prevent cross-org cookie and credential leakage.
@@ -33,7 +47,7 @@ export class EnhancedDomainsCheck {
33
47
  const findings = [];
34
48
  const baseUrl = ctx.orgInfo.instanceUrl;
35
49
  const domainSetupUrl = `${baseUrl}/lightning/setup/MyDomain/home`;
36
- const orgResult = await ctx.soql.query(`SELECT MyDomain, IsSandbox, InstanceName FROM Organization LIMIT 1`);
50
+ const orgResult = await ctx.soql.query(`SELECT IsSandbox, InstanceName FROM Organization LIMIT 1`);
37
51
  const org = orgResult.records[0];
38
52
  if (!org) {
39
53
  findings.push({
@@ -47,7 +61,8 @@ export class EnhancedDomainsCheck {
47
61
  });
48
62
  return { findings };
49
63
  }
50
- const { MyDomain: myDomain, IsSandbox: isSandbox } = org;
64
+ const { IsSandbox: isSandbox } = org;
65
+ const myDomain = myDomainOf(baseUrl);
51
66
  const instanceUrl = baseUrl;
52
67
  const instanceHost = hostnameOf(instanceUrl);
53
68
  // Check if Enhanced Domains is active based on the instance URL format
@@ -6,5 +6,7 @@ export declare class EscalationPermsCheck implements SecurityCheck {
6
6
  readonly category = "Permissions";
7
7
  readonly description = "Flags users holding lateral-movement/persistence permissions (Manage Internal Users, Assign Permission Sets, Modify Metadata, Manage Auth Providers, etc.)";
8
8
  run(ctx: AuditContext): Promise<CheckResult>;
9
+ /** Active, unfrozen users holding Modify All Data, View All Data and Manage Users across their assignments. */
10
+ private superAdminIds;
9
11
  }
10
12
  //# sourceMappingURL=EscalationPermsCheck.d.ts.map
@@ -1,10 +1,14 @@
1
+ import { presentFields } from '../support/schema.js';
2
+ // Hygiene, not escalation: they weaken a credential or widen visibility, but give no way to grant
3
+ // oneself more access. Reported apart so they never stand in for an escalation path. RULE-077.
4
+ const HYGIENE = new Set(['Password Never Expires', 'View All Users']);
1
5
  const PERMS = [
2
6
  ['PermissionsManageInternalUsers', 'Manage Internal Users'],
3
7
  ['PermissionsAssignPermissionSets', 'Assign Permission Sets'],
4
8
  ['PermissionsModifyMetadata', 'Modify Metadata'],
5
9
  ['PermissionsManageAuthProviders', 'Manage Auth. Providers'],
6
10
  ['PermissionsManageConnectedApps', 'Manage Connected Apps'],
7
- ['PermissionsManageSession', 'Manage Session Permission Set Activations'],
11
+ ['PermissionsManageSessionPermissionSets', 'Manage Session Permission Set Activations'],
8
12
  ['PermissionsPasswordNeverExpires', 'Password Never Expires'],
9
13
  ['PermissionsViewAllUsers', 'View All Users'],
10
14
  ];
@@ -16,10 +20,15 @@ export class EscalationPermsCheck {
16
20
  async run(ctx) {
17
21
  const findings = [];
18
22
  const baseUrl = ctx.orgInfo.instanceUrl;
19
- const permFields = PERMS.map(([f]) => `PermissionSet.${f}`).join(', ');
20
- const permWhere = PERMS.map(([f]) => `PermissionSet.${f} = true`).join(' OR ');
21
23
  let rows;
24
+ // Manage Connected Apps and similar exist only in some orgs; one absent field fails the whole
25
+ // query. Select only those this org has: a permission it lacks cannot be held.
26
+ let perms = PERMS;
22
27
  try {
28
+ const present = new Set(await presentFields(ctx, 'PermissionSet', PERMS.map(([f]) => f)));
29
+ perms = PERMS.filter(([f]) => present.has(f));
30
+ const permFields = perms.map(([f]) => `PermissionSet.${f}`).join(', ');
31
+ const permWhere = perms.map(([f]) => `PermissionSet.${f} = true`).join(' OR ');
23
32
  rows = await ctx.soql.queryAll(`SELECT AssigneeId, Assignee.Username, ${permFields}
24
33
  FROM PermissionSetAssignment
25
34
  WHERE (${permWhere}) AND Assignee.IsActive = true`);
@@ -32,14 +41,29 @@ export class EscalationPermsCheck {
32
41
  riskLevel: 'INFO',
33
42
  inconclusive: true,
34
43
  title: 'Privilege-escalation permission check could not be completed',
35
- detail: `The PermissionSetAssignment query was not accessible: ${msg}`,
36
- remediation: 'Grant the audit user "View Setup and Configuration", then re-run the audit.',
44
+ detail: `Who holds escalation permissions could not be read, so this is unassessed. The org said: ${msg}`,
45
+ remediation: 'Check the error above. If it is an access error, confirm the audit user has "View Setup and Configuration", then re-run the audit.',
37
46
  });
38
47
  return { findings };
39
48
  }
49
+ // A super-admin (Modify All Data + View All Data + Manage Users) already has unrestricted control,
50
+ // rated by users-super-admin-combo. Escalation permissions matter on everyone else. RULE-077.
51
+ let superAdmins = new Set();
52
+ try {
53
+ superAdmins = await this.superAdminIds(ctx);
54
+ }
55
+ catch {
56
+ // Without the super-admin list, keep every holder: over-reporting beats hiding a holder.
57
+ }
40
58
  const affected = [];
59
+ let leftOut = 0;
41
60
  for (const row of rows) {
42
- for (const [field, label] of PERMS) {
61
+ if (superAdmins.has(row.AssigneeId)) {
62
+ if (perms.some(([field]) => row.PermissionSet[field]))
63
+ leftOut++;
64
+ continue;
65
+ }
66
+ for (const [field, label] of perms) {
43
67
  if (row.PermissionSet[field]) {
44
68
  affected.push({ username: row.Assignee?.Username ?? row.AssigneeId, userId: row.AssigneeId, perm: label });
45
69
  }
@@ -51,27 +75,70 @@ export class EscalationPermsCheck {
51
75
  category: this.category,
52
76
  riskLevel: 'LOW',
53
77
  passed: true,
54
- title: 'No users hold privilege-escalation permissions',
55
- detail: 'No active users were found holding lateral-movement or persistence permissions.',
78
+ title: leftOut > 0 ? 'Only super-admins hold privilege-escalation permissions' : 'No users hold privilege-escalation permissions',
79
+ detail: leftOut > 0
80
+ ? 'Escalation permissions are held only by super-admins, who already have unrestricted control and are rated in the super-admin finding (users-super-admin-combo).'
81
+ : 'No active users were found holding lateral-movement or persistence permissions.',
56
82
  remediation: 'Continue to review escalation permissions periodically.',
57
83
  });
58
84
  return { findings };
59
85
  }
60
- findings.push({
61
- id: 'escalation-perms-found',
62
- category: this.category,
63
- riskLevel: 'HIGH',
64
- title: `${affected.length} escalation-permission grant(s) across active users`,
65
- detail: 'These permissions let a user create accounts, reset passwords, assign permission sets, modify metadata, ' +
66
- 'or register auth providers: the primitives an attacker uses for lateral movement and persistence after an initial foothold.',
67
- remediation: 'Remove these permissions from non-administrator profiles/permission sets and document who legitimately needs each one.',
68
- affectedItems: affected.map((a) => ({
69
- label: `${a.username}: ${a.perm}`,
70
- url: `${baseUrl}/${a.userId}`,
71
- note: 'Review and remove if not essential',
72
- })),
86
+ const leftOutNote = leftOut > 0
87
+ ? ` ${new Set(rows.filter((r) => superAdmins.has(r.AssigneeId)).map((r) => r.AssigneeId)).size} super-admin(s) also hold them and are rated in the super-admin finding instead.`
88
+ : '';
89
+ const item = (a) => ({
90
+ label: `${a.username}: ${a.perm}`,
91
+ url: `${baseUrl}/${a.userId}`,
92
+ note: 'Review and remove if not essential',
73
93
  });
94
+ const escalation = affected.filter((a) => !HYGIENE.has(a.perm));
95
+ const hygiene = affected.filter((a) => HYGIENE.has(a.perm));
96
+ if (escalation.length > 0) {
97
+ findings.push({
98
+ id: 'escalation-perms-found',
99
+ category: this.category,
100
+ riskLevel: 'HIGH',
101
+ title: `${escalation.length} escalation-permission grant(s) across active users`,
102
+ detail: 'These permissions let a user create accounts, reset passwords, assign permission sets, modify metadata, ' +
103
+ 'or register auth providers: the primitives an attacker uses for lateral movement and persistence after an initial foothold.' +
104
+ leftOutNote,
105
+ remediation: 'Remove these permissions from non-administrator profiles/permission sets and document who legitimately needs each one.',
106
+ affectedItems: escalation.map(item),
107
+ });
108
+ }
109
+ if (hygiene.length > 0) {
110
+ findings.push({
111
+ id: 'escalation-perms-hygiene',
112
+ category: this.category,
113
+ riskLevel: 'MEDIUM',
114
+ title: `${hygiene.length} grant(s) of Password Never Expires or View All Users to non-administrators`,
115
+ detail: 'Password Never Expires keeps a leaked password valid indefinitely; View All Users exposes the full user roster for targeting. ' +
116
+ 'Neither lets a user grant themselves more access.' +
117
+ leftOutNote,
118
+ remediation: 'Limit these to service accounts and administrators that need them, and document each.',
119
+ affectedItems: hygiene.map(item),
120
+ });
121
+ }
74
122
  return { findings };
75
123
  }
124
+ /** Active, unfrozen users holding Modify All Data, View All Data and Manage Users across their assignments. */
125
+ async superAdminIds(ctx) {
126
+ const rows = await ctx.soql.queryAll(`SELECT AssigneeId, PermissionSet.PermissionsModifyAllData, PermissionSet.PermissionsViewAllData, PermissionSet.PermissionsManageUsers
127
+ FROM PermissionSetAssignment
128
+ WHERE (PermissionSet.PermissionsModifyAllData = true OR PermissionSet.PermissionsViewAllData = true OR PermissionSet.PermissionsManageUsers = true)
129
+ AND Assignee.IsActive = true`);
130
+ const held = new Map();
131
+ for (const r of rows) {
132
+ const s = held.get(r.AssigneeId) ?? new Set();
133
+ if (r.PermissionSet.PermissionsModifyAllData)
134
+ s.add('mad');
135
+ if (r.PermissionSet.PermissionsViewAllData)
136
+ s.add('vad');
137
+ if (r.PermissionSet.PermissionsManageUsers)
138
+ s.add('mu');
139
+ held.set(r.AssigneeId, s);
140
+ }
141
+ return new Set([...held].filter(([, s]) => s.size === 3).map(([id]) => id));
142
+ }
76
143
  }
77
144
  //# sourceMappingURL=EscalationPermsCheck.js.map
@@ -1,3 +1,16 @@
1
+ /**
2
+ * Network has no guest-user field: each Experience site's guest user is on its Site record
3
+ * (SiteType ChatterNetwork, or ChatterNetworkPicasso for Experience Builder sites). Site carries
4
+ * no network id, so a Site belongs to a network when its label is the network's name, or its path
5
+ * prefix is the network's, the network's followed by "/s", or (LWR sites) followed by "vforcesite".
6
+ */
7
+ function siteBelongsTo(site, network) {
8
+ if (site.MasterLabel && site.MasterLabel === network.Name)
9
+ return true;
10
+ const net = network.UrlPathPrefix ?? '';
11
+ const sp = site.UrlPathPrefix ?? '';
12
+ return sp === net || sp === (net === '' ? 's' : `${net}/s`) || sp === `${net}vforcesite`;
13
+ }
1
14
  export class ExperienceCloudSiteCheck {
2
15
  id = 'experience-cloud-site';
3
16
  name = 'Experience Cloud Site Security';
@@ -9,18 +22,18 @@ export class ExperienceCloudSiteCheck {
9
22
  const setupUrl = `${baseUrl}/lightning/setup/SetupNetworks/home`;
10
23
  let networks;
11
24
  try {
12
- networks = await ctx.soql.queryAll(`SELECT Id, Name, Status, UrlPathPrefix, SelfRegProfileId, GuestUserId
25
+ networks = await ctx.soql.queryAll(`SELECT Id, Name, Status, UrlPathPrefix, SelfRegProfileId
13
26
  FROM Network
14
27
  WHERE Status = 'Live'`);
15
28
  }
16
- catch {
29
+ catch (err) {
17
30
  findings.push({
18
31
  id: 'experience-cloud-site-inaccessible',
19
32
  category: this.category,
20
33
  riskLevel: 'INFO',
21
34
  inconclusive: true,
22
35
  title: 'Experience Cloud site configuration could not be queried',
23
- detail: 'The Network SOQL query was not accessible. This may indicate the audit user lacks access to Experience Cloud configuration or no sites are provisioned.',
36
+ detail: `The Network query failed: ${err instanceof Error ? err.message : String(err)}. If no Experience Cloud licence is active, this check is not applicable.`,
24
37
  remediation: 'Grant "View Setup and Configuration" to the audit user and re-run. If no Experience Cloud licence is active, this check is not applicable.',
25
38
  });
26
39
  return { findings };
@@ -38,7 +51,45 @@ export class ExperienceCloudSiteCheck {
38
51
  return { findings };
39
52
  }
40
53
  const selfRegSites = networks.filter((n) => n.SelfRegProfileId !== null);
41
- const guestSites = networks.filter((n) => n.GuestUserId !== null);
54
+ let sites;
55
+ try {
56
+ sites = await ctx.soql.queryAll(`SELECT MasterLabel, UrlPathPrefix, GuestUserId, GuestUser.IsActive
57
+ FROM Site
58
+ WHERE SiteType IN ('ChatterNetwork', 'ChatterNetworkPicasso') AND Status = 'Active'`);
59
+ }
60
+ catch {
61
+ sites = null;
62
+ }
63
+ const guestSites = sites === null
64
+ ? []
65
+ : networks.filter((n) => sites.some((s) => s.GuestUserId !== null && s.GuestUser?.IsActive !== false && siteBelongsTo(s, n)));
66
+ // A live network whose Site record could not be found has unknown guest access, not none.
67
+ const unmatched = sites === null ? [] : networks.filter((n) => !sites.some((s) => siteBelongsTo(s, n)));
68
+ if (unmatched.length > 0) {
69
+ findings.push({
70
+ id: 'experience-cloud-site-guest-unknown',
71
+ category: this.category,
72
+ riskLevel: 'INFO',
73
+ inconclusive: true,
74
+ title: `Guest access could not be determined for ${unmatched.length} live Experience Cloud site(s)`,
75
+ detail: 'No active Site record could be matched to these live networks by name or path prefix, so whether they allow unauthenticated access is unknown, not absent.',
76
+ remediation: 'Review each site\'s guest user in Setup → Digital Experiences.',
77
+ affectedItems: unmatched.map((n) => ({ label: n.Name, url: setupUrl, note: `URL prefix: ${n.UrlPathPrefix ?? '(default)'}` })),
78
+ });
79
+ }
80
+ if (sites === null) {
81
+ // Without the Site records, guest access is unknown, not absent.
82
+ findings.push({
83
+ id: 'experience-cloud-site-guest-unknown',
84
+ category: this.category,
85
+ riskLevel: 'INFO',
86
+ inconclusive: true,
87
+ title: 'Guest access on live Experience Cloud sites could not be determined',
88
+ detail: 'The Site records that carry each Experience site\'s guest user could not be read, so whether these sites allow unauthenticated access is unknown.',
89
+ remediation: 'Review each site\'s guest user in Setup → Digital Experiences, or grant "View Setup and Configuration" and re-run.',
90
+ affectedItems: networks.map((n) => ({ label: n.Name, url: setupUrl })),
91
+ });
92
+ }
42
93
  if (selfRegSites.length > 0) {
43
94
  findings.push({
44
95
  id: 'experience-cloud-site-self-registration',
@@ -69,7 +120,7 @@ export class ExperienceCloudSiteCheck {
69
120
  })),
70
121
  });
71
122
  }
72
- if (selfRegSites.length === 0 && guestSites.length === 0) {
123
+ if (selfRegSites.length === 0 && guestSites.length === 0 && sites !== null && unmatched.length === 0) {
73
124
  findings.push({
74
125
  id: 'experience-cloud-site-ok',
75
126
  category: this.category,
@@ -0,0 +1,10 @@
1
+ import type { AuditContext } from '@cclabsnz/sf-core';
2
+ import type { SecurityCheck, CheckResult } from '../SecurityCheck.js';
3
+ export declare class ExternalAccountHierarchyExposureCheck implements SecurityCheck {
4
+ readonly id = "external-account-hierarchy-exposure";
5
+ readonly name = "External Account Hierarchy & Partner Super User Exposure";
6
+ readonly category = "External-Facing Access";
7
+ readonly description = "Flags Partner Super User access and External Account Hierarchies that bypass external OWD and widen portal visibility.";
8
+ run(ctx: AuditContext): Promise<CheckResult>;
9
+ }
10
+ //# sourceMappingURL=ExternalAccountHierarchyExposureCheck.d.ts.map
@@ -0,0 +1,65 @@
1
+ import { queryIfPresent } from '../support/missingObject.js';
2
+ import { hasField } from '../support/schema.js';
3
+ export class ExternalAccountHierarchyExposureCheck {
4
+ id = 'external-account-hierarchy-exposure';
5
+ name = 'External Account Hierarchy & Partner Super User Exposure';
6
+ category = 'External-Facing Access';
7
+ description = 'Flags Partner Super User access and External Account Hierarchies that bypass external OWD and widen portal visibility.';
8
+ async run(ctx) {
9
+ const findings = [];
10
+ const baseUrl = ctx.orgInfo.instanceUrl;
11
+ const usersUrl = `${baseUrl}/lightning/setup/ManageUsers/home`;
12
+ // 1. Active users with Partner Super User access. User.IsPrmSuperUser only exists in orgs
13
+ // with a partner (PRM) licence; without it no user can be a super user, so the field is
14
+ // described first rather than queried blind. Query errors propagate so the check reports
15
+ // inconclusive rather than clean.
16
+ const superUsers = (await hasField(ctx, 'User', 'IsPrmSuperUser'))
17
+ ? await ctx.soql.queryAll('SELECT Id, Username, IsActive, IsPrmSuperUser FROM User WHERE IsPrmSuperUser = true AND IsActive = true')
18
+ : [];
19
+ if (superUsers.length > 0) {
20
+ findings.push({
21
+ id: 'external-account-hierarchy-super-users',
22
+ category: this.category,
23
+ riskLevel: 'HIGH',
24
+ title: `${superUsers.length} active portal user(s) granted Partner Super User Access (IsPrmSuperUser)`,
25
+ detail: 'Enabling Partner Super User Access grants external portal users visibility across all cases, opportunities, contacts, and custom objects owned by other partner users in their partner account hierarchy. This broadens data access beyond standard sharing rules and circumvents Private External Org-Wide Defaults.',
26
+ remediation: 'Review all users with Partner Super User Access in Setup → Users, and disable IsPrmSuperUser unless justified by strict business need.',
27
+ affectedItems: superUsers.map((u) => ({
28
+ label: u.Username,
29
+ url: `${baseUrl}/lightning/setup/ManageUsers/page?address=%2F${u.Id}`,
30
+ note: 'IsPrmSuperUser = true: cross-user record visibility in portal',
31
+ })),
32
+ });
33
+ }
34
+ // 2. Query ExternalAccountHierarchy records
35
+ const hierarchies = await queryIfPresent(() => ctx.soql.queryAll('SELECT Id, MasterLabel FROM ExternalAccountHierarchy'));
36
+ if (hierarchies.length > 0) {
37
+ findings.push({
38
+ id: 'external-account-hierarchy-active',
39
+ category: this.category,
40
+ riskLevel: 'HIGH',
41
+ title: `${hierarchies.length} active External Account Hierarchy relationship(s) configured`,
42
+ detail: 'External Account Hierarchies link separate partner and customer portal accounts into parent-child relationships, granting parent portal users upward and horizontal record visibility across child accounts without standard sharing rules.',
43
+ remediation: 'Audit all active External Account Hierarchy relationships in Setup → External Account Hierarchies to verify cross-account data exposure conforms to least-privilege sharing models.',
44
+ affectedItems: hierarchies.map((h) => ({
45
+ label: h.MasterLabel || h.Id,
46
+ url: usersUrl,
47
+ note: 'External Account Hierarchy active',
48
+ })),
49
+ });
50
+ }
51
+ if (superUsers.length === 0 && hierarchies.length === 0) {
52
+ findings.push({
53
+ id: 'external-account-hierarchy-ok',
54
+ category: this.category,
55
+ riskLevel: 'LOW',
56
+ passed: true,
57
+ title: 'No Partner Super Users or External Account Hierarchies widening portal visibility',
58
+ detail: 'External portal users are constrained to their own account boundaries without hierarchical over-sharing.',
59
+ remediation: 'Maintain standard Private external OWD and avoid unreviewed Super User grants.',
60
+ });
61
+ }
62
+ return { findings };
63
+ }
64
+ }
65
+ //# sourceMappingURL=ExternalAccountHierarchyExposureCheck.js.map
@@ -18,17 +18,20 @@ export class ExternalCredentialsCheck {
18
18
  const findings = [];
19
19
  const baseUrl = ctx.orgInfo.instanceUrl;
20
20
  let creds;
21
+ let error = '';
21
22
  try {
22
- creds = await ctx.soql.queryAll('SELECT Id, DeveloperName, AuthenticationProtocol FROM ExternalCredential');
23
+ // ExternalCredential is served by the Tooling API; the standard API does not support it.
24
+ creds = await ctx.tooling.query('SELECT Id, DeveloperName, AuthenticationProtocol FROM ExternalCredential');
23
25
  }
24
- catch {
26
+ catch (err) {
27
+ error = err instanceof Error ? err.message : String(err);
25
28
  findings.push({
26
29
  id: 'external-credentials-inconclusive',
27
30
  category: this.category,
28
31
  riskLevel: 'INFO',
29
32
  inconclusive: true,
30
33
  title: 'External Credentials could not be queried (insufficient access or unsupported)',
31
- detail: 'The ExternalCredential object was not accessible. This can mean the org has not migrated to External Credentials, or the audit user lacks access.',
34
+ detail: `The ExternalCredential Tooling query failed: ${error}`,
32
35
  remediation: 'Grant the audit user View Setup and Configuration and re-run. Also review Setup → Named Credentials → External Credentials manually.',
33
36
  });
34
37
  return { findings };