@cclabsnz/sf-audit 1.2.0 → 1.4.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 (142) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +135 -31
  3. package/lib/api/MetadataClient.d.ts +4 -0
  4. package/lib/api/MetadataClient.js +2 -0
  5. package/lib/api/MetadataClientImpl.d.ts +8 -0
  6. package/lib/api/MetadataClientImpl.js +22 -0
  7. package/lib/api/RestClient.d.ts +1 -0
  8. package/lib/api/RestClientImpl.d.ts +1 -0
  9. package/lib/api/RestClientImpl.js +6 -0
  10. package/lib/chains/CapabilityRegistry.js +19 -0
  11. package/lib/chains/namedChains.js +26 -4
  12. package/lib/checks/eventLogAccess.d.ts +14 -0
  13. package/lib/checks/eventLogAccess.js +33 -0
  14. package/lib/checks/impl/AnonymousApexAuditCheck.js +5 -5
  15. package/lib/checks/impl/ApexCrudFLSCheck.d.ts +1 -1
  16. package/lib/checks/impl/ApexCrudFLSCheck.js +4 -4
  17. package/lib/checks/impl/ApexLoggingCheck.js +10 -10
  18. package/lib/checks/impl/ApexRestEndpointCheck.js +5 -5
  19. package/lib/checks/impl/ApexSharingCheck.js +3 -3
  20. package/lib/checks/impl/ApiClientPermissionCheck.js +2 -2
  21. package/lib/checks/impl/AuthProvidersCheck.d.ts +17 -0
  22. package/lib/checks/impl/AuthProvidersCheck.js +88 -0
  23. package/lib/checks/impl/CertificateExpiryCheck.js +1 -1
  24. package/lib/checks/impl/ClassicSitesCheck.d.ts +17 -0
  25. package/lib/checks/impl/ClassicSitesCheck.js +65 -0
  26. package/lib/checks/impl/ConnectedAppInactivityCheck.d.ts +1 -1
  27. package/lib/checks/impl/ConnectedAppInactivityCheck.js +5 -5
  28. package/lib/checks/impl/ConnectedAppScopeCheck.d.ts +1 -1
  29. package/lib/checks/impl/ConnectedAppScopeCheck.js +4 -4
  30. package/lib/checks/impl/ConnectedAppsCheck.js +2 -2
  31. package/lib/checks/impl/ContentLinksCheck.js +6 -6
  32. package/lib/checks/impl/CorsAllowlistCheck.js +3 -3
  33. package/lib/checks/impl/CustomLabelsCredentialCheck.d.ts +1 -1
  34. package/lib/checks/impl/CustomLabelsCredentialCheck.js +7 -7
  35. package/lib/checks/impl/DataClassificationCheck.js +6 -6
  36. package/lib/checks/impl/DataExportAccessCheck.d.ts +19 -0
  37. package/lib/checks/impl/DataExportAccessCheck.js +79 -0
  38. package/lib/checks/impl/DebugLogAccessCheck.js +6 -6
  39. package/lib/checks/impl/DeploymentIdentityCheck.js +8 -8
  40. package/lib/checks/impl/EmailSecurityCheck.d.ts +10 -0
  41. package/lib/checks/impl/EmailSecurityCheck.js +117 -0
  42. package/lib/checks/impl/EncryptionCoverageCheck.d.ts +19 -0
  43. package/lib/checks/impl/EncryptionCoverageCheck.js +108 -0
  44. package/lib/checks/impl/EnhancedDomainsCheck.d.ts +1 -1
  45. package/lib/checks/impl/EnhancedDomainsCheck.js +6 -6
  46. package/lib/checks/impl/EscalationPermsCheck.js +2 -2
  47. package/lib/checks/impl/EventMonitoringCheck.js +14 -11
  48. package/lib/checks/impl/ExperienceCloudSiteCheck.js +3 -3
  49. package/lib/checks/impl/ExperienceCspCheck.d.ts +18 -0
  50. package/lib/checks/impl/ExperienceCspCheck.js +57 -0
  51. package/lib/checks/impl/ExternalCredentialsCheck.d.ts +17 -0
  52. package/lib/checks/impl/ExternalCredentialsCheck.js +74 -0
  53. package/lib/checks/impl/FailedLoginCheck.js +5 -5
  54. package/lib/checks/impl/FieldHistoryTrackingCheck.js +3 -3
  55. package/lib/checks/impl/FieldLevelSecurityCheck.js +2 -2
  56. package/lib/checks/impl/GuestApiAccessCheck.d.ts +19 -0
  57. package/lib/checks/impl/GuestApiAccessCheck.js +113 -0
  58. package/lib/checks/impl/GuestExecutableApexCheck.d.ts +1 -1
  59. package/lib/checks/impl/GuestExecutableApexCheck.js +5 -5
  60. package/lib/checks/impl/GuestObjectExposureCheck.d.ts +44 -0
  61. package/lib/checks/impl/GuestObjectExposureCheck.js +241 -0
  62. package/lib/checks/impl/GuestRecordAccessPolicyCheck.d.ts +34 -0
  63. package/lib/checks/impl/GuestRecordAccessPolicyCheck.js +120 -0
  64. package/lib/checks/impl/GuestSiteOptionsCheck.d.ts +18 -0
  65. package/lib/checks/impl/GuestSiteOptionsCheck.js +92 -0
  66. package/lib/checks/impl/GuestTrafficAnomalyCheck.d.ts +23 -0
  67. package/lib/checks/impl/GuestTrafficAnomalyCheck.js +343 -0
  68. package/lib/checks/impl/GuestUserAccessCheck.js +5 -5
  69. package/lib/checks/impl/HealthCheckCheck.js +2 -2
  70. package/lib/checks/impl/HighAssuranceSessionCheck.js +4 -4
  71. package/lib/checks/impl/InstalledPackagesCheck.js +5 -5
  72. package/lib/checks/impl/IntegrationUsersCheck.js +5 -5
  73. package/lib/checks/impl/InternalUserMfaCheck.js +2 -2
  74. package/lib/checks/impl/IpRestrictionsCheck.js +3 -3
  75. package/lib/checks/impl/LegacyApiVersionCheck.js +1 -1
  76. package/lib/checks/impl/LoginAccessPolicyCheck.d.ts +26 -0
  77. package/lib/checks/impl/LoginAccessPolicyCheck.js +117 -0
  78. package/lib/checks/impl/LoginAnomalyCheck.d.ts +17 -0
  79. package/lib/checks/impl/LoginAnomalyCheck.js +98 -0
  80. package/lib/checks/impl/MfaEnforcementCheck.js +3 -3
  81. package/lib/checks/impl/MfaMethodStrengthCheck.js +3 -3
  82. package/lib/checks/impl/MfaRegistrationCheck.js +2 -2
  83. package/lib/checks/impl/MyDomainLoginPolicyCheck.d.ts +1 -1
  84. package/lib/checks/impl/MyDomainLoginPolicyCheck.js +9 -9
  85. package/lib/checks/impl/NamedCredentialsCheck.js +3 -3
  86. package/lib/checks/impl/OutboundMessagesCheck.d.ts +10 -0
  87. package/lib/checks/impl/OutboundMessagesCheck.js +88 -0
  88. package/lib/checks/impl/PasswordSessionPolicyCheck.js +3 -3
  89. package/lib/checks/impl/PermissionsCheck.js +3 -3
  90. package/lib/checks/impl/PrivilegedAccessCheck.d.ts +11 -0
  91. package/lib/checks/impl/PrivilegedAccessCheck.js +111 -0
  92. package/lib/checks/impl/PublicContentExposureCheck.d.ts +10 -0
  93. package/lib/checks/impl/PublicContentExposureCheck.js +98 -0
  94. package/lib/checks/impl/PublicGroupSharingCheck.js +1 -1
  95. package/lib/checks/impl/ReleaseUpdatesCheck.js +2 -2
  96. package/lib/checks/impl/RemoteSitesCheck.js +1 -1
  97. package/lib/checks/impl/ReportFolderAccessCheck.d.ts +1 -1
  98. package/lib/checks/impl/ReportFolderAccessCheck.js +4 -4
  99. package/lib/checks/impl/SandboxDataMaskingCheck.d.ts +17 -0
  100. package/lib/checks/impl/SandboxDataMaskingCheck.js +85 -0
  101. package/lib/checks/impl/ScheduledApexCheck.js +1 -1
  102. package/lib/checks/impl/SeparationOfDutiesCheck.d.ts +11 -0
  103. package/lib/checks/impl/SeparationOfDutiesCheck.js +114 -0
  104. package/lib/checks/impl/SessionHardeningCheck.d.ts +21 -0
  105. package/lib/checks/impl/SessionHardeningCheck.js +134 -0
  106. package/lib/checks/impl/SharingModelCheck.d.ts +1 -1
  107. package/lib/checks/impl/SharingModelCheck.js +8 -8
  108. package/lib/checks/impl/SiemIntegrationCheck.js +4 -4
  109. package/lib/checks/impl/SsoEnforcementCheck.js +5 -5
  110. package/lib/checks/impl/StandardProfilesCheck.js +2 -2
  111. package/lib/checks/impl/ThreatDetectionCheck.d.ts +17 -0
  112. package/lib/checks/impl/ThreatDetectionCheck.js +91 -0
  113. package/lib/checks/impl/TransactionSecurityPolicyCheck.js +2 -2
  114. package/lib/checks/impl/TrustedIPRangesCheck.js +5 -5
  115. package/lib/checks/impl/VisualforceXssCheck.js +6 -6
  116. package/lib/checks/permCatalog.d.ts +15 -0
  117. package/lib/checks/permCatalog.js +42 -0
  118. package/lib/checks/registry.js +45 -0
  119. package/lib/commands/audit/diff.js +9 -5
  120. package/lib/commands/audit/events/pull.d.ts +17 -0
  121. package/lib/commands/audit/events/pull.js +88 -0
  122. package/lib/commands/audit/security.d.ts +4 -0
  123. package/lib/commands/audit/security.js +41 -17
  124. package/lib/compliance/mapping.js +34 -7
  125. package/lib/context/AuditCache.d.ts +12 -0
  126. package/lib/context/AuditContext.d.ts +2 -0
  127. package/lib/events/EventBaselineStore.d.ts +16 -0
  128. package/lib/events/EventBaselineStore.js +55 -0
  129. package/lib/events/eventLogQuery.d.ts +21 -0
  130. package/lib/events/eventLogQuery.js +34 -0
  131. package/lib/events/pullEventLogs.d.ts +51 -0
  132. package/lib/events/pullEventLogs.js +79 -0
  133. package/lib/findings/CheckMeta.js +24 -3
  134. package/lib/lib/wire.d.ts +2 -0
  135. package/lib/lib/wire.js +3 -0
  136. package/lib/renderers/ClientReportRenderer.js +4 -4
  137. package/lib/renderers/DiffHtmlRenderer.js +1 -1
  138. package/lib/renderers/HistoryRenderer.js +1 -1
  139. package/lib/renderers/HtmlRenderer.js +3 -3
  140. package/lib/renderers/MarkdownRenderer.js +2 -2
  141. package/messages/audit.security.md +30 -2
  142. package/package.json +14 -2
@@ -0,0 +1,108 @@
1
+ const MAX_OBJECTS = 25; // cap describe calls
2
+ /**
3
+ * Cross-references data classification against ACTUAL field encryption. `data-
4
+ * classification` confirms Shield is licensed and that fields are classified;
5
+ * this check answers the next question: are the fields marked sensitive (PII/PHI
6
+ * via ComplianceGroup) actually encrypted at rest? Classified-but-plaintext
7
+ * fields are the gap that matters for a health/PII org — the data is labelled
8
+ * sensitive yet stored in the clear.
9
+ */
10
+ export class EncryptionCoverageCheck {
11
+ id = 'encryption-coverage';
12
+ name = 'Encryption Coverage for Sensitive Fields';
13
+ category = 'Data Security';
14
+ description = 'Flags fields classified as sensitive (PII/PHI via ComplianceGroup) that are not encrypted at rest with Shield Platform Encryption';
15
+ async run(ctx) {
16
+ const findings = [];
17
+ const baseUrl = ctx.orgInfo.instanceUrl;
18
+ // 1. Sensitive fields = those with a ComplianceGroup (PII/PCI/HIPAA/GDPR/...).
19
+ let classified;
20
+ try {
21
+ classified = await ctx.tooling.query(`SELECT EntityDefinition.QualifiedApiName obj, QualifiedApiName field
22
+ FROM FieldDefinition WHERE ComplianceGroup != null`);
23
+ }
24
+ catch {
25
+ findings.push(this.inconclusive('Classified fields could not be queried (Tooling API access needed)'));
26
+ return { findings };
27
+ }
28
+ const fieldsByObj = new Map();
29
+ for (const c of classified) {
30
+ if (!c.obj || !c.field)
31
+ continue;
32
+ const set = fieldsByObj.get(c.obj) ?? new Set();
33
+ set.add(c.field);
34
+ fieldsByObj.set(c.obj, set);
35
+ }
36
+ if (fieldsByObj.size === 0) {
37
+ findings.push({
38
+ id: 'encryption-coverage-no-classification',
39
+ category: this.category,
40
+ riskLevel: 'LOW',
41
+ 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.',
44
+ remediation: 'Classify PII/PHI fields (Setup → Data Classification) first, then encrypt the sensitive ones with Shield Platform Encryption.',
45
+ });
46
+ return { findings };
47
+ }
48
+ // 2. For each classified object, describe it and read per-field encryption.
49
+ const unencrypted = [];
50
+ let describedAny = false;
51
+ for (const [obj, fields] of [...fieldsByObj.entries()].slice(0, MAX_OBJECTS)) {
52
+ let desc;
53
+ try {
54
+ desc = await ctx.rest.get(`/sobjects/${obj}/describe`);
55
+ }
56
+ catch {
57
+ continue;
58
+ }
59
+ if (!desc.fields)
60
+ continue;
61
+ describedAny = true;
62
+ const encryptedNames = new Set(desc.fields.filter((f) => f.encrypted).map((f) => f.name));
63
+ for (const field of fields) {
64
+ if (!encryptedNames.has(field))
65
+ unencrypted.push(`${obj}.${field}`);
66
+ }
67
+ }
68
+ if (!describedAny) {
69
+ findings.push(this.inconclusive('Object describes were not accessible, so field encryption could not be confirmed'));
70
+ return { findings };
71
+ }
72
+ if (unencrypted.length > 0) {
73
+ findings.push({
74
+ id: 'encryption-coverage-unencrypted-sensitive',
75
+ category: this.category,
76
+ riskLevel: 'HIGH',
77
+ title: `${unencrypted.length} field(s) classified sensitive but NOT encrypted at rest`,
78
+ detail: 'These fields are labelled sensitive (PII/PHI/PCI via a ComplianceGroup) yet are stored in plaintext — Shield Platform Encryption is not applied. For a health/PII org this is the gap that matters: the data is known-sensitive but unprotected at rest, exposed to anyone who can read the field, and to at-rest/export exposure.',
79
+ remediation: 'Enable Shield Platform Encryption on these fields (Setup → Platform Encryption → Encryption Policy). Prefer probabilistic encryption unless a field must be filtered/sorted; if deterministic is required, treat it as weaker and document the tradeoff. Re-encrypt existing data after enabling.',
80
+ affectedItems: unencrypted.slice(0, 50).map((f) => ({ label: f, url: `${baseUrl}/lightning/setup/PlatformEncryptionPolicy/home` })),
81
+ });
82
+ }
83
+ else {
84
+ findings.push({
85
+ id: 'encryption-coverage-ok',
86
+ category: this.category,
87
+ riskLevel: 'LOW',
88
+ passed: true,
89
+ 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.`,
91
+ remediation: 'Keep encryption policy in sync as new sensitive fields are added and classified.',
92
+ });
93
+ }
94
+ return { findings };
95
+ }
96
+ inconclusive(what) {
97
+ return {
98
+ id: 'encryption-coverage-inconclusive',
99
+ category: this.category,
100
+ riskLevel: 'INFO',
101
+ inconclusive: true,
102
+ 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.',
105
+ };
106
+ }
107
+ }
108
+ //# sourceMappingURL=EncryptionCoverageCheck.js.map
@@ -4,7 +4,7 @@ export declare class EnhancedDomainsCheck implements SecurityCheck {
4
4
  readonly id = "enhanced-domains";
5
5
  readonly name = "Enhanced Domains";
6
6
  readonly category = "Authentication";
7
- readonly description = "Verifies Enhanced Domains is enabled \u2014 prevents cross-org cookie leakage and enables org-specific URL isolation (required since Spring 2023)";
7
+ readonly description = "Verifies Enhanced Domains is enabled: prevents cross-org cookie leakage and enables org-specific URL isolation (required since Spring 2023)";
8
8
  run(ctx: AuditContext): Promise<CheckResult>;
9
9
  }
10
10
  //# sourceMappingURL=EnhancedDomainsCheck.d.ts.map
@@ -15,7 +15,7 @@ export class EnhancedDomainsCheck {
15
15
  id = 'enhanced-domains';
16
16
  name = 'Enhanced Domains';
17
17
  category = 'Authentication';
18
- description = 'Verifies Enhanced Domains is enabled — prevents cross-org cookie leakage and enables org-specific URL isolation (required since Spring 2023)';
18
+ description = 'Verifies Enhanced Domains is enabled: prevents cross-org cookie leakage and enables org-specific URL isolation (required since Spring 2023)';
19
19
  async run(ctx) {
20
20
  const findings = [];
21
21
  const baseUrl = ctx.orgInfo.instanceUrl;
@@ -45,8 +45,8 @@ export class EnhancedDomainsCheck {
45
45
  id: 'enhanced-domains-no-my-domain',
46
46
  category: this.category,
47
47
  riskLevel: isSandbox ? 'MEDIUM' : 'HIGH',
48
- title: 'My Domain is not configured — Enhanced Domains cannot be enabled',
49
- detail: `Enhanced Domains (required for production orgs since Spring 2023) depends on My Domain being configured first. Without My Domain, the org uses shared Salesforce infrastructure URLs, which means cookies and sessions are not isolated to this specific org — increasing the risk of cross-org credential leakage. My Domain also enables SSO, Lightning Experience, and granular login policies.`,
48
+ title: 'My Domain is not configured: Enhanced Domains cannot be enabled',
49
+ detail: `Enhanced Domains (required for production orgs since Spring 2023) depends on My Domain being configured first. Without My Domain, the org uses shared Salesforce infrastructure URLs, which means cookies and sessions are not isolated to this specific org, increasing the risk of cross-org credential leakage. My Domain also enables SSO, Lightning Experience, and granular login policies.`,
50
50
  remediation: 'Configure My Domain in Setup → My Domain. After testing, deploy to all users. Then enable Enhanced Domains in Setup → My Domain → Enable Enhanced Domains.',
51
51
  affectedItems: [{ label: 'My Domain Setup', url: domainSetupUrl, note: 'Configure My Domain as a prerequisite for Enhanced Domains' }],
52
52
  });
@@ -58,7 +58,7 @@ export class EnhancedDomainsCheck {
58
58
  category: this.category,
59
59
  riskLevel: 'LOW',
60
60
  passed: true,
61
- title: `Enhanced Domains is active — org uses isolated subdomain (${myDomain})`,
61
+ title: `Enhanced Domains is active: org uses isolated subdomain (${myDomain})`,
62
62
  detail: `The org instance URL (${instanceUrl}) uses the Enhanced Domain format, confirming that Enhanced Domains is enabled. This means Visualforce pages, Experience Cloud sites, and Lightning apps are served from org-specific subdomains, preventing cross-org cookie leakage and improving URL isolation between Salesforce customers on shared infrastructure.`,
63
63
  remediation: 'Verify that any hardcoded legacy URLs (force.com, visualforce.com, site.com) in integrations, bookmarks, or email templates have been updated to the new Enhanced Domain URLs.',
64
64
  });
@@ -68,13 +68,13 @@ export class EnhancedDomainsCheck {
68
68
  id: 'enhanced-domains-not-detected',
69
69
  category: this.category,
70
70
  riskLevel: isSandbox ? 'LOW' : 'MEDIUM',
71
- title: `Enhanced Domains may not be enabled — org URL appears to use a legacy format`,
71
+ title: `Enhanced Domains may not be enabled: org URL appears to use a legacy format`,
72
72
  detail: `The org instance URL (${instanceUrl}) does not match the Enhanced Domain URL pattern (*.my.salesforce.com). The org has My Domain (${myDomain}) but may not have completed the Enhanced Domains migration. Enhanced Domains was required for all production orgs as of Spring 2023 and provides critical URL isolation that prevents cross-org cookie leakage.`,
73
73
  remediation: 'Enable Enhanced Domains in Setup → My Domain → Enable Enhanced Domains. Review Salesforce release notes for your org edition to confirm Enhanced Domains is available and required. Update any hardcoded legacy URLs after migration.',
74
74
  affectedItems: [{
75
75
  label: myDomain,
76
76
  url: domainSetupUrl,
77
- note: `Instance URL: ${instanceUrl} — expected *.my.salesforce.com format`,
77
+ note: `Instance URL: ${instanceUrl} (expected *.my.salesforce.com format)`,
78
78
  }],
79
79
  });
80
80
  }
@@ -63,10 +63,10 @@ export class EscalationPermsCheck {
63
63
  riskLevel: 'HIGH',
64
64
  title: `${affected.length} escalation-permission grant(s) across active users`,
65
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.',
66
+ 'or register auth providers: the primitives an attacker uses for lateral movement and persistence after an initial foothold.',
67
67
  remediation: 'Remove these permissions from non-administrator profiles/permission sets and document who legitimately needs each one.',
68
68
  affectedItems: affected.map((a) => ({
69
- label: `${a.username} — ${a.perm}`,
69
+ label: `${a.username}: ${a.perm}`,
70
70
  url: `${baseUrl}/${a.userId}`,
71
71
  note: 'Review and remove if not essential',
72
72
  })),
@@ -1,3 +1,4 @@
1
+ import { classifyEventLogAccessError } from '../eventLogAccess.js';
1
2
  export class EventMonitoringCheck {
2
3
  id = 'event-monitoring';
3
4
  name = 'Event Monitoring Storage';
@@ -26,16 +27,16 @@ export class EventMonitoringCheck {
26
27
  return r.earliestDate;
27
28
  return r.earliestDate < earliest ? r.earliestDate : earliest;
28
29
  }, null);
29
- // Populate cache for SiemIntegrationCheck at zero extra API cost
30
- ctx.cache.eventLogSummary = { earliestDate, totalFiles, eventTypes };
30
+ // Populate cache for SiemIntegrationCheck + GuestTrafficAnomalyCheck at zero extra API cost
31
+ ctx.cache.eventLogSummary = { earliestDate, totalFiles, eventTypes, accessible: true };
31
32
  if (totalFiles === 0) {
32
33
  findings.push({
33
34
  id: 'event-monitoring-disabled',
34
35
  category: this.category,
35
36
  riskLevel: 'HIGH',
36
- title: 'No Event Monitoring log files found in the last 35 days — SBS-MON-001',
37
+ title: 'No Event Monitoring log files found in the last 35 days: SBS-MON-001',
37
38
  detail: 'SBS-MON-001 requires Event Monitoring storage to be enabled so that login, API access, and data export events are captured. No EventLogFile records exist for the past 35 days, indicating Event Monitoring is either not licensed or not configured.',
38
- remediation: 'Enable Event Monitoring in Setup → Event Monitoring Settings. If the feature is not licensed, raise with your Salesforce account team — SBS-MON-001 compliance requires it.',
39
+ remediation: 'Enable Event Monitoring in Setup → Event Monitoring Settings. If the feature is not licensed, raise with your Salesforce account team. SBS-MON-001 compliance requires it.',
39
40
  affectedItems: [{ label: 'Event Monitoring Setup', url: setupUrl, note: 'Enable event log storage' }],
40
41
  });
41
42
  return { findings };
@@ -46,7 +47,7 @@ export class EventMonitoringCheck {
46
47
  category: this.category,
47
48
  riskLevel: 'LOW',
48
49
  passed: true,
49
- title: `Event Monitoring active — ${totalFiles} log file(s) across ${eventTypes.length} event type(s) — SBS-MON-001`,
50
+ title: `Event Monitoring active: ${totalFiles} log file(s) across ${eventTypes.length} event type(s) (SBS-MON-001)`,
50
51
  detail: `SBS-MON-001 requires Event Monitoring to be enabled and actively capturing events. Found ${totalFiles} EventLogFile records covering ${eventTypes.length} distinct event types over the past 35 days. Event types captured: ${eventTypes.slice(0, 12).join(', ')}${eventTypes.length > 12 ? ` (+${eventTypes.length - 12} more)` : ''}.`,
51
52
  remediation: 'Review the list of monitored event types and ensure Login, API, DataExport, and LightningInteraction events are included.',
52
53
  });
@@ -58,23 +59,25 @@ export class EventMonitoringCheck {
58
59
  id: 'event-monitoring-retention-short',
59
60
  category: this.category,
60
61
  riskLevel: 'MEDIUM',
61
- title: `Event logs cover only ${daysCovered} day(s) — SBS-INT-004 requires 30-day minimum`,
62
+ title: `Event logs cover only ${daysCovered} day(s): SBS-INT-004 requires 30-day minimum`,
62
63
  detail: `SBS-INT-004 requires API event logs to be retained for at least 30 days to support incident investigation. The earliest EventLogFile available is from ${new Date(earliestDate).toISOString().split('T')[0]}, giving only ${daysCovered} day(s) of coverage within the past 35-day window.`,
63
64
  remediation: `Export EventLogFile records to an external storage system or SIEM on a daily or weekly basis to maintain 30+ days of retention. Salesforce's native event log retention is typically 1–30 days depending on edition and Event Monitoring tier.`,
64
65
  });
65
66
  }
66
67
  }
67
68
  }
68
- catch {
69
- // EventLogFile may not be accessible without Event Monitoring license
70
- ctx.cache.eventLogSummary = { earliestDate: null, totalFiles: 0, eventTypes: [] };
69
+ catch (e) {
70
+ // EventLogFile may not be accessible without Event Monitoring license, or the
71
+ // audit user may lack "View Event Log Files". Record which, so downstream
72
+ // checks can phrase their blind spot precisely instead of re-querying.
73
+ ctx.cache.eventLogSummary = { earliestDate: null, totalFiles: 0, eventTypes: [], accessible: false, accessError: classifyEventLogAccessError(e) };
71
74
  findings.push({
72
75
  id: 'event-monitoring-inaccessible',
73
76
  category: this.category,
74
77
  riskLevel: 'MEDIUM',
75
78
  inconclusive: true,
76
- title: 'Event Monitoring log files could not be accessed — SBS-MON-001 cannot be verified',
77
- detail: 'SBS-MON-001 requires Event Monitoring storage to be enabled. EventLogFile was not accessible — this may indicate the feature is not licensed or the audit user lacks the "View Event Log Files" permission.',
79
+ title: 'Event Monitoring log files could not be accessed: SBS-MON-001 cannot be verified',
80
+ detail: 'SBS-MON-001 requires Event Monitoring storage to be enabled. EventLogFile was not accessible. This may indicate the feature is not licensed or the audit user lacks the "View Event Log Files" permission.',
78
81
  remediation: 'Grant "View Event Log Files" permission to the audit user, or verify Event Monitoring is licensed and enabled in Setup → Event Monitoring Settings.',
79
82
  });
80
83
  }
@@ -50,7 +50,7 @@ export class ExperienceCloudSiteCheck {
50
50
  affectedItems: selfRegSites.map((n) => ({
51
51
  label: n.Name,
52
52
  url: `${baseUrl}/lightning/setup/SetupNetworks/home`,
53
- note: `Self-registration enabled — SelfRegProfileId: ${n.SelfRegProfileId}`,
53
+ note: `Self-registration enabled, SelfRegProfileId: ${n.SelfRegProfileId}`,
54
54
  })),
55
55
  });
56
56
  }
@@ -65,7 +65,7 @@ export class ExperienceCloudSiteCheck {
65
65
  affectedItems: guestSites.map((n) => ({
66
66
  label: n.Name,
67
67
  url: setupUrl,
68
- note: `Guest access enabled — verify Guest Profile permissions`,
68
+ note: `Guest access enabled: verify Guest Profile permissions`,
69
69
  })),
70
70
  });
71
71
  }
@@ -75,7 +75,7 @@ export class ExperienceCloudSiteCheck {
75
75
  category: this.category,
76
76
  riskLevel: 'LOW',
77
77
  passed: true,
78
- title: `${networks.length} live Experience Cloud site(s) — no self-registration or open guest access`,
78
+ title: `${networks.length} live Experience Cloud site(s): no self-registration or open guest access`,
79
79
  detail: `All ${networks.length} live site(s) have self-registration disabled and no active guest users. Portal access requires an explicit user account.`,
80
80
  remediation: 'Continue to monitor site configuration as sites are updated. Review portal user object permissions periodically.',
81
81
  affectedItems: networks.map((n) => ({
@@ -0,0 +1,18 @@
1
+ import type { AuditContext } from '../../context/AuditContext.js';
2
+ import type { SecurityCheck, CheckResult } from '../SecurityCheck.js';
3
+ /**
4
+ * Advisory review of Experience Cloud CSP / Lightning Web Security posture.
5
+ * The per-site CSP level ("Strict" vs "Relaxed") and the Lightning Web Security
6
+ * toggle are not reliably exposed to SOQL/Tooling, so for each live site this
7
+ * emits a targeted manual-verification item rather than a false pass. Relaxed CSP
8
+ * or disabled LWS on a public site widens the XSS / script-injection surface that
9
+ * unauthenticated visitors can reach.
10
+ */
11
+ export declare class ExperienceCspCheck implements SecurityCheck {
12
+ readonly id = "experience-csp";
13
+ readonly name = "Experience Cloud CSP & Lightning Web Security";
14
+ readonly category = "Access Control";
15
+ readonly description = "Advises verifying Strict CSP and Lightning Web Security on live Experience Cloud sites (not reliably API-readable), to limit XSS/script-injection exposure";
16
+ run(ctx: AuditContext): Promise<CheckResult>;
17
+ }
18
+ //# sourceMappingURL=ExperienceCspCheck.d.ts.map
@@ -0,0 +1,57 @@
1
+ /**
2
+ * Advisory review of Experience Cloud CSP / Lightning Web Security posture.
3
+ * The per-site CSP level ("Strict" vs "Relaxed") and the Lightning Web Security
4
+ * toggle are not reliably exposed to SOQL/Tooling, so for each live site this
5
+ * emits a targeted manual-verification item rather than a false pass. Relaxed CSP
6
+ * or disabled LWS on a public site widens the XSS / script-injection surface that
7
+ * unauthenticated visitors can reach.
8
+ */
9
+ export class ExperienceCspCheck {
10
+ id = 'experience-csp';
11
+ name = 'Experience Cloud CSP & Lightning Web Security';
12
+ category = 'Access Control';
13
+ description = 'Advises verifying Strict CSP and Lightning Web Security on live Experience Cloud sites (not reliably API-readable), to limit XSS/script-injection exposure';
14
+ async run(ctx) {
15
+ const findings = [];
16
+ const baseUrl = ctx.orgInfo.instanceUrl;
17
+ let networks;
18
+ try {
19
+ networks = await ctx.soql.queryAll("SELECT Id, Name, Status FROM Network WHERE Status = 'Live'");
20
+ }
21
+ catch {
22
+ findings.push({
23
+ id: 'experience-csp-inconclusive',
24
+ category: this.category,
25
+ riskLevel: 'INFO',
26
+ inconclusive: true,
27
+ title: 'Experience Cloud sites could not be queried (insufficient access)',
28
+ detail: 'The Network object was not accessible, so CSP/LWS posture could not be assessed. This may mean no Experience Cloud licence.',
29
+ remediation: 'Grant the audit user View Setup and Configuration and re-run. If Experience Cloud is unused, this check is not applicable.',
30
+ });
31
+ return { findings };
32
+ }
33
+ if (networks.length === 0) {
34
+ findings.push({
35
+ id: 'experience-csp-none',
36
+ category: this.category,
37
+ riskLevel: 'LOW',
38
+ passed: true,
39
+ title: 'No live Experience Cloud sites',
40
+ detail: 'No live Experience Cloud sites exist, so there is no CSP/LWS surface to review.',
41
+ remediation: 'When a site goes live, set Security to "Strict CSP" and enable Lightning Web Security.',
42
+ });
43
+ return { findings };
44
+ }
45
+ findings.push({
46
+ id: 'experience-csp-verify',
47
+ category: this.category,
48
+ riskLevel: 'INFO',
49
+ title: `Verify Strict CSP + Lightning Web Security on ${networks.length} live Experience Cloud site(s)`,
50
+ detail: 'The per-site Content Security Policy level and Lightning Web Security toggle are not reliably exposed to the API, so they must be confirmed manually. A "Relaxed CSP" level or disabled Lightning Web Security lets inline/third-party scripts run on pages an unauthenticated guest can reach, widening the XSS and script-injection surface.',
51
+ remediation: 'For each site: Setup → Digital Experiences → (site) → Administration → Security & Privacy — set the CSP level to "Strict CSP" and enable Lightning Web Security. Review any Trusted Sites/URLs added to relax CSP.',
52
+ affectedItems: networks.slice(0, 30).map((n) => ({ label: n.Name, url: `${baseUrl}/lightning/setup/SetupNetworks/home` })),
53
+ });
54
+ return { findings };
55
+ }
56
+ }
57
+ //# sourceMappingURL=ExperienceCspCheck.js.map
@@ -0,0 +1,17 @@
1
+ import type { AuditContext } from '../../context/AuditContext.js';
2
+ import type { SecurityCheck, CheckResult } from '../SecurityCheck.js';
3
+ /**
4
+ * Reviews External Credentials (the modern auth half of Named Credentials) for
5
+ * weak authentication. Complements `named-credentials` (which inventories the
6
+ * endpoints) by grading HOW the org authenticates to them: a credential with no
7
+ * authentication, or a hand-rolled custom scheme, is a soft target for spoofing
8
+ * the remote system or leaking a static secret.
9
+ */
10
+ export declare class ExternalCredentialsCheck implements SecurityCheck {
11
+ readonly id = "external-credentials";
12
+ readonly name = "External Credential Authentication";
13
+ readonly category = "External Connectivity";
14
+ readonly description = "Grades External Credential authentication protocols, flagging callouts that use no authentication or a custom (non-standard) scheme";
15
+ run(ctx: AuditContext): Promise<CheckResult>;
16
+ }
17
+ //# sourceMappingURL=ExternalCredentialsCheck.d.ts.map
@@ -0,0 +1,74 @@
1
+ // Authentication protocols that mean the callout carries no server-verified
2
+ // credential — either fully anonymous, or a static/custom secret that is easy to
3
+ // leak or replay.
4
+ const WEAK_PROTOCOLS = new Set(['NoAuthentication', 'Custom']);
5
+ /**
6
+ * Reviews External Credentials (the modern auth half of Named Credentials) for
7
+ * weak authentication. Complements `named-credentials` (which inventories the
8
+ * endpoints) by grading HOW the org authenticates to them: a credential with no
9
+ * authentication, or a hand-rolled custom scheme, is a soft target for spoofing
10
+ * the remote system or leaking a static secret.
11
+ */
12
+ export class ExternalCredentialsCheck {
13
+ id = 'external-credentials';
14
+ name = 'External Credential Authentication';
15
+ category = 'External Connectivity';
16
+ description = 'Grades External Credential authentication protocols, flagging callouts that use no authentication or a custom (non-standard) scheme';
17
+ async run(ctx) {
18
+ const findings = [];
19
+ const baseUrl = ctx.orgInfo.instanceUrl;
20
+ let creds;
21
+ try {
22
+ creds = await ctx.soql.queryAll('SELECT Id, DeveloperName, AuthenticationProtocol FROM ExternalCredential');
23
+ }
24
+ catch {
25
+ findings.push({
26
+ id: 'external-credentials-inconclusive',
27
+ category: this.category,
28
+ riskLevel: 'INFO',
29
+ inconclusive: true,
30
+ 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.',
32
+ remediation: 'Grant the audit user View Setup and Configuration and re-run. Also review Setup → Named Credentials → External Credentials manually.',
33
+ });
34
+ return { findings };
35
+ }
36
+ if (creds.length === 0) {
37
+ findings.push({
38
+ id: 'external-credentials-none',
39
+ category: this.category,
40
+ riskLevel: 'LOW',
41
+ passed: true,
42
+ title: 'No External Credentials configured',
43
+ detail: 'No ExternalCredential records exist, so there is no external-credential authentication surface to grade.',
44
+ remediation: 'When adding External Credentials, prefer OAuth/JWT or AWS SigV4 over custom or no-authentication schemes.',
45
+ });
46
+ return { findings };
47
+ }
48
+ const weak = creds.filter((c) => WEAK_PROTOCOLS.has(c.AuthenticationProtocol ?? ''));
49
+ if (weak.length > 0) {
50
+ findings.push({
51
+ id: 'external-credentials-weak-auth',
52
+ category: this.category,
53
+ riskLevel: 'MEDIUM',
54
+ title: `${weak.length} External Credential(s) use no or custom authentication`,
55
+ detail: 'These External Credentials authenticate with "No Authentication" or a "Custom" scheme. No-auth callouts can be spoofed or redirected without detection, and custom schemes typically embed a static secret that is easy to leak or replay. Standard protocols (OAuth, JWT, AWS SigV4) provide server-verified, rotatable credentials.',
56
+ remediation: 'Move these callouts to a standard authentication protocol (OAuth 2.0, JWT bearer, or AWS SigV4) with a rotatable secret, and confirm the paired Named Credential targets an HTTPS endpoint.',
57
+ affectedItems: weak.map((c) => ({ label: `${c.DeveloperName} (${c.AuthenticationProtocol})`, url: `${baseUrl}/lightning/setup/NamedCredential/home` })),
58
+ });
59
+ }
60
+ else {
61
+ findings.push({
62
+ id: 'external-credentials-ok',
63
+ category: this.category,
64
+ riskLevel: 'LOW',
65
+ passed: true,
66
+ title: `${creds.length} External Credential(s); all use standard authentication`,
67
+ detail: 'No External Credential uses "No Authentication" or a custom scheme.',
68
+ remediation: 'Continue to prefer OAuth/JWT/SigV4 and rotate secrets on a schedule.',
69
+ });
70
+ }
71
+ return { findings };
72
+ }
73
+ }
74
+ //# sourceMappingURL=ExternalCredentialsCheck.js.map
@@ -23,7 +23,7 @@ export class FailedLoginCheck {
23
23
  category: this.category,
24
24
  riskLevel: 'INFO',
25
25
  inconclusive: true,
26
- title: 'LoginHistory could not be queried — failed login analysis skipped',
26
+ title: 'LoginHistory could not be queried: failed login analysis skipped',
27
27
  detail: 'The LoginHistory SOQL query was not accessible. This may indicate the audit user lacks "View All Users" or event monitoring access.',
28
28
  remediation: 'Grant "View All Users" to the audit user. For event-level access, enable Event Monitoring.',
29
29
  });
@@ -68,7 +68,7 @@ export class FailedLoginCheck {
68
68
  affectedItems: heavyTargets.map((r) => ({
69
69
  label: r.Username,
70
70
  url: setupUrl,
71
- note: `${r.expr0} failed attempts in 7 days — likely automated attack`,
71
+ note: `${r.expr0} failed attempts in 7 days: likely automated attack`,
72
72
  })),
73
73
  });
74
74
  }
@@ -94,13 +94,13 @@ export class FailedLoginCheck {
94
94
  category: this.category,
95
95
  riskLevel: 'HIGH',
96
96
  title: `${totalFailures} failed logins across the org in the last 7 days`,
97
- detail: `The org has recorded ${totalFailures} failed login attempts in 7 days distributed across many accounts. This pattern is consistent with broad credential stuffing — attackers using large lists of username/password combinations from data breaches, targeting the entire org rather than specific accounts. Even a low success rate across many attempts can yield multiple compromised accounts.`,
97
+ detail: `The org has recorded ${totalFailures} failed login attempts in 7 days distributed across many accounts. This pattern is consistent with broad credential stuffing: attackers using large lists of username/password combinations from data breaches, targeting the entire org rather than specific accounts. Even a low success rate across many attempts can yield multiple compromised accounts.`,
98
98
  remediation: 'Review Login History for patterns (source IPs, time clustering, usernames). Enable Transaction Security Policies to rate-limit or block logins from suspicious IPs. Consider enabling Salesforce Shield or Event Monitoring for deeper login analytics.',
99
99
  affectedItems: [
100
100
  {
101
101
  label: 'Org-wide login activity',
102
102
  url: setupUrl,
103
- note: `${totalFailures} failures in 7 days — review for patterns`,
103
+ note: `${totalFailures} failures in 7 days: review for patterns`,
104
104
  },
105
105
  ],
106
106
  });
@@ -111,7 +111,7 @@ export class FailedLoginCheck {
111
111
  category: this.category,
112
112
  riskLevel: 'LOW',
113
113
  passed: true,
114
- title: `${totalFailures} failed login(s) in 7 days — no brute-force patterns detected`,
114
+ title: `${totalFailures} failed login(s) in 7 days: no brute-force patterns detected`,
115
115
  detail: `${totalFailures} failed login attempts recorded in the last 7 days, but no single account exceeded the brute-force threshold (${BRUTE_FORCE_PER_USER} failures). This volume appears consistent with normal user error.`,
116
116
  remediation: 'Continue monitoring. Configure Transaction Security Policies to alert on anomalous login activity as volumes change.',
117
117
  });
@@ -33,7 +33,7 @@ export class FieldHistoryTrackingCheck {
33
33
  category: this.category,
34
34
  riskLevel: 'LOW',
35
35
  passed: true,
36
- title: 'Field history tracking enabled on all checked sensitive objects — SBS-DATA-004',
36
+ title: 'Field history tracking enabled on all checked sensitive objects: SBS-DATA-004',
37
37
  detail: `SBS-DATA-004 requires field history tracking on sensitive objects to support incident investigation and compliance evidence. All ${SENSITIVE_OBJECTS.length} checked objects have at least one tracked field. Objects: ${withTracking.map((o) => `${o} (${trackedMap.get(o)} field(s))`).join(', ')}.`,
38
38
  remediation: 'Periodically review which specific fields are tracked to ensure key sensitive fields (email address, phone, revenue, status) are included.',
39
39
  });
@@ -43,13 +43,13 @@ export class FieldHistoryTrackingCheck {
43
43
  id: 'field-history-tracking-missing',
44
44
  category: this.category,
45
45
  riskLevel: withoutTracking.length >= 3 ? 'HIGH' : 'MEDIUM',
46
- title: `${withoutTracking.length} sensitive object(s) have no field history tracking — SBS-DATA-004`,
46
+ title: `${withoutTracking.length} sensitive object(s) have no field history tracking: SBS-DATA-004`,
47
47
  detail: `SBS-DATA-004 requires field history tracking on sensitive objects to capture who changed what data and when, enabling post-incident investigation and audit evidence. The following objects have no tracked fields: ${withoutTracking.join(', ')}. ${withTracking.length > 0 ? `Objects already configured: ${withTracking.map((o) => `${o} (${trackedMap.get(o)} field(s))`).join(', ')}.` : ''}`,
48
48
  remediation: 'Enable field history tracking on each listed object in Setup → Object Manager → [Object] → Fields & Relationships → Set History Tracking. At minimum track key sensitive fields: email addresses, phone numbers, revenue fields, owner changes, and status changes.',
49
49
  affectedItems: withoutTracking.map((name) => ({
50
50
  label: name,
51
51
  url: `${setupUrl}/list?objectType=${name}`,
52
- note: 'No fields have history tracking enabled — configure via Object Manager → Set History Tracking',
52
+ note: 'No fields have history tracking enabled: configure via Object Manager → Set History Tracking',
53
53
  })),
54
54
  });
55
55
  }
@@ -121,7 +121,7 @@ export class FieldLevelSecurityCheck {
121
121
  return {
122
122
  label: r.Field,
123
123
  url: `${baseUrl}/lightning/setup/ObjectManager/${objectApiName}/FieldsAndRelationships/view`,
124
- note: `Readable by ${r.cnt} permission sets — restrict to minimum required`,
124
+ note: `Readable by ${r.cnt} permission sets: restrict to minimum required`,
125
125
  };
126
126
  }),
127
127
  detail: 'Widely-accessible sensitive fields increase the risk of data exposure. These fields may contain PII, PHI, or financial data.',
@@ -139,7 +139,7 @@ export class FieldLevelSecurityCheck {
139
139
  return {
140
140
  label: r.Field,
141
141
  url: `${baseUrl}/lightning/setup/ObjectManager/${objectApiName}/FieldsAndRelationships/view`,
142
- note: `Readable by ${r.cnt} permission sets — review and reduce access`,
142
+ note: `Readable by ${r.cnt} permission sets: review and reduce access`,
143
143
  };
144
144
  }),
145
145
  detail: 'Widely-accessible sensitive fields increase the risk of data exposure. These fields may contain PII, PHI, or financial data.',
@@ -0,0 +1,19 @@
1
+ import type { AuditContext } from '../../context/AuditContext.js';
2
+ import type { SecurityCheck, CheckResult } from '../SecurityCheck.js';
3
+ /**
4
+ * Flags guest (unauthenticated) users whose profile/permission-sets grant API or
5
+ * Bulk API access. The other guest checks cover the UI-API/GraphQL vector; this
6
+ * covers the *programmatic* one: a guest with "API Enabled" can drive the REST/SOAP/
7
+ * Bulk API directly, turning any readable object into a scriptable bulk pull, and
8
+ * "Bulk API Hard Delete" additionally lets an anonymous caller permanently destroy
9
+ * records (bypassing the recycle bin).
10
+ */
11
+ export declare class GuestApiAccessCheck implements SecurityCheck {
12
+ readonly id = "guest-api-access";
13
+ readonly name = "Guest API & Bulk Access";
14
+ readonly category = "Access Control";
15
+ readonly description = "Flags guest users granted API Enabled or Bulk API Hard Delete \u2014 programmatic bulk read/delete access for unauthenticated visitors";
16
+ run(ctx: AuditContext): Promise<CheckResult>;
17
+ private inconclusive;
18
+ }
19
+ //# sourceMappingURL=GuestApiAccessCheck.d.ts.map