@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
@@ -12,7 +12,7 @@ export class ConnectedAppScopeCheck {
12
12
  id = 'connected-app-scope';
13
13
  name = 'Connected App OAuth Scopes & Token Policy';
14
14
  category = 'App Security';
15
- description = 'Flags connected apps granting Full OAuth scope or using infinite refresh token policies — both expand the blast radius of a compromised token';
15
+ description = 'Flags connected apps granting Full OAuth scope or using infinite refresh token policies: both expand the blast radius of a compromised token';
16
16
  async run(ctx) {
17
17
  const findings = [];
18
18
  const setupUrl = `${ctx.orgInfo.instanceUrl}/lightning/setup/ConnectedApplication/home`;
@@ -63,7 +63,7 @@ export class ConnectedAppScopeCheck {
63
63
  category: this.category,
64
64
  riskLevel: 'HIGH',
65
65
  title: `${fullScopeApps.length} connected app(s) grant the "Full" OAuth scope`,
66
- detail: 'The Full OAuth scope gives a connected app the same access rights as the authorising user — including Modify All Data if the user is an admin. A stolen access or refresh token from a Full-scope app can be used to read, write, and delete any record the user could access. Full scope is almost never necessary; specific scopes (Api, Web, CustomPermissions) should be used instead.',
66
+ detail: 'The Full OAuth scope gives a connected app the same access rights as the authorising user, including Modify All Data if the user is an admin. A stolen access or refresh token from a Full-scope app can be used to read, write, and delete any record the user could access. Full scope is almost never necessary; specific scopes (Api, Web, CustomPermissions) should be used instead.',
67
67
  remediation: 'Edit each connected app in Setup → Connected Apps → OAuth Policies and replace "Full" scope with the minimum scopes the integration actually requires. Common replacements: "Api" for REST API access, "Web" for web-based flows, "OpenID" + "Profile" for identity only. Rotating client secrets after scope changes is also recommended.',
68
68
  affectedItems: fullScopeApps.map((app) => ({
69
69
  label: app.Name,
@@ -97,13 +97,13 @@ export class ConnectedAppScopeCheck {
97
97
  id: 'connected-app-full-scope-infinite-token',
98
98
  category: this.category,
99
99
  riskLevel: 'CRITICAL',
100
- title: `${fullAndInfinite.length} connected app(s) combine Full scope with an infinite refresh token — stolen token = permanent full access`,
100
+ title: `${fullAndInfinite.length} connected app(s) combine Full scope with an infinite refresh token: stolen token = permanent full access`,
101
101
  detail: 'These apps issue never-expiring tokens that grant complete access to the org as the authorising user. A single leaked token is equivalent to a permanent credential with admin-level reach if the user is an admin. This is the highest-risk connected app configuration.',
102
102
  remediation: 'Immediately restrict scopes to the minimum required and set an explicit refresh token expiry. If Full scope cannot be removed, at minimum set a refresh token validity period of 90 days or less and enable refresh token rotation.',
103
103
  affectedItems: fullAndInfinite.map((app) => ({
104
104
  label: app.Name,
105
105
  url: setupUrl,
106
- note: `Full scope + infinite refresh token — highest risk combination`,
106
+ note: `Full scope + infinite refresh token: highest risk combination`,
107
107
  })),
108
108
  });
109
109
  }
@@ -57,8 +57,8 @@ export class ConnectedAppsCheck {
57
57
  label: app.Name,
58
58
  url: `${baseUrl}/${app.Id}`,
59
59
  note: app.SessionTimeout === null || app.SessionTimeout === 0
60
- ? 'No explicit timeout — inherits org default (likely > 15 min)'
61
- : `Session timeout: ${app.SessionTimeout} min — reduce to ≤ 15`,
60
+ ? 'No explicit timeout: inherits org default (likely > 15 min)'
61
+ : `Session timeout: ${app.SessionTimeout} min, reduce to ≤ 15`,
62
62
  })),
63
63
  });
64
64
  }
@@ -54,13 +54,13 @@ export class ContentLinksCheck {
54
54
  id: 'content-links-no-expiry',
55
55
  category: this.category,
56
56
  riskLevel: noExpiry.length > 20 ? 'HIGH' : 'MEDIUM',
57
- title: `${noExpiry.length} public content link(s) have no expiry date — SBS-FILE-001`,
57
+ title: `${noExpiry.length} public content link(s) have no expiry date: SBS-FILE-001`,
58
58
  detail: 'SBS-FILE-001 requires all public content distribution links to have an expiry date. Links without expiry remain active indefinitely, allowing anyone with the URL to continue accessing potentially sensitive documents even after the sharing purpose has ended.',
59
59
  remediation: 'Set an expiry date on all active public links. Establish a policy requiring expiry dates when creating new content distribution links, and configure Salesforce to enforce expiry via the Content Distribution settings.',
60
60
  affectedItems: noExpiry.slice(0, 50).map((r) => ({
61
61
  label: r.Name,
62
62
  url: `${baseUrl}/${r.ContentDocumentId}`,
63
- note: `created: ${new Date(r.CreatedDate).toISOString().split('T')[0]} — set an expiry date`,
63
+ note: `created: ${new Date(r.CreatedDate).toISOString().split('T')[0]}, set an expiry date`,
64
64
  })),
65
65
  });
66
66
  }
@@ -71,13 +71,13 @@ export class ContentLinksCheck {
71
71
  id: 'content-links-no-password',
72
72
  category: this.category,
73
73
  riskLevel: 'LOW',
74
- title: `${noPassword.length} public content link(s) are not password-protected — SBS-FILE-002`,
74
+ title: `${noPassword.length} public content link(s) are not password-protected: SBS-FILE-002`,
75
75
  detail: 'SBS-FILE-002 recommends password-protecting public content sharing links, particularly for documents containing sensitive or confidential information. Links without a password can be accessed by anyone with the URL.',
76
76
  remediation: 'Enable password protection for public content links that share sensitive content. Review each link to determine if the shared content warrants the additional protection layer.',
77
77
  affectedItems: noPassword.slice(0, 50).map((r) => ({
78
78
  label: r.Name,
79
79
  url: `${baseUrl}/${r.ContentDocumentId}`,
80
- note: `created: ${new Date(r.CreatedDate).toISOString().split('T')[0]} — assess whether password protection is needed`,
80
+ note: `created: ${new Date(r.CreatedDate).toISOString().split('T')[0]}, assess whether password protection is needed`,
81
81
  })),
82
82
  });
83
83
  }
@@ -88,13 +88,13 @@ export class ContentLinksCheck {
88
88
  id: 'content-links-stale',
89
89
  category: this.category,
90
90
  riskLevel: 'MEDIUM',
91
- title: `${stale.length} public content link(s) are over ${STALE_DAYS} days old with no expiry — SBS-FILE-003`,
91
+ title: `${stale.length} public content link(s) are over ${STALE_DAYS} days old with no expiry: SBS-FILE-003`,
92
92
  detail: `SBS-FILE-003 requires periodic cleanup of public content sharing links. ${stale.length} link(s) were created more than ${STALE_DAYS} days ago and have no expiry date, meaning they have been publicly accessible indefinitely. These likely represent sharing relationships that are no longer active.`,
93
93
  remediation: `Review and expire or delete all content links older than ${STALE_DAYS} days where the sharing purpose is no longer active. Establish a quarterly review process for all active content distribution links.`,
94
94
  affectedItems: stale.slice(0, 50).map((r) => ({
95
95
  label: r.Name,
96
96
  url: `${baseUrl}/${r.ContentDocumentId}`,
97
- note: `created: ${new Date(r.CreatedDate).toISOString().split('T')[0]} — review and expire or delete`,
97
+ note: `created: ${new Date(r.CreatedDate).toISOString().split('T')[0]}, review and expire or delete`,
98
98
  })),
99
99
  });
100
100
  }
@@ -47,9 +47,9 @@ export class CorsAllowlistCheck {
47
47
  category: this.category,
48
48
  riskLevel: 'HIGH',
49
49
  title: `${wildcard.length} CORS allowlist entry(ies) use a full wildcard origin`,
50
- detail: 'A wildcard CORS origin lets ANY website make authenticated cross-origin requests to your org from a logged-in user\'s browser and read the responses — enabling session-scoped data and token theft.',
50
+ detail: 'A wildcard CORS origin lets ANY website make authenticated cross-origin requests to your org from a logged-in user\'s browser and read the responses, enabling session-scoped data and token theft.',
51
51
  remediation: 'Replace wildcard origins with exact, fully-qualified HTTPS origins for each trusted application.',
52
- affectedItems: wildcard.map((r) => ({ label: r.UrlPattern, url: setupUrl, note: 'Full wildcard — remove immediately' })),
52
+ affectedItems: wildcard.map((r) => ({ label: r.UrlPattern, url: setupUrl, note: 'Full wildcard: remove immediately' })),
53
53
  });
54
54
  }
55
55
  if (broad.length > 0) {
@@ -60,7 +60,7 @@ export class CorsAllowlistCheck {
60
60
  title: `${broad.length} CORS allowlist entry(ies) use a broad subdomain wildcard`,
61
61
  detail: 'Subdomain-wildcard CORS origins trust every current and future subdomain, widening the set of sites that can make authenticated cross-origin requests. A single compromised or attacker-controlled subdomain can steal session-scoped data.',
62
62
  remediation: 'Pin CORS origins to the exact subdomains that need access rather than a wildcard.',
63
- affectedItems: broad.map((r) => ({ label: r.UrlPattern, url: setupUrl, note: 'Broad wildcard — narrow to exact origins' })),
63
+ affectedItems: broad.map((r) => ({ label: r.UrlPattern, url: setupUrl, note: 'Broad wildcard: narrow to exact origins' })),
64
64
  });
65
65
  }
66
66
  if (wildcard.length === 0 && broad.length === 0) {
@@ -4,7 +4,7 @@ export declare class CustomLabelsCredentialCheck implements SecurityCheck {
4
4
  readonly id = "custom-labels-credential";
5
5
  readonly name = "Custom Labels Credential Exposure";
6
6
  readonly category = "Secrets Management";
7
- readonly description = "Scans Custom Labels for API keys, tokens, and credentials \u2014 labels are globally readable by all authenticated users via {!$Label.X} merge fields";
7
+ readonly description = "Scans Custom Labels for API keys, tokens, and credentials. Labels are globally readable by all authenticated users via {!$Label.X} merge fields";
8
8
  run(ctx: AuditContext): Promise<CheckResult>;
9
9
  }
10
10
  //# sourceMappingURL=CustomLabelsCredentialCheck.d.ts.map
@@ -6,7 +6,7 @@ export class CustomLabelsCredentialCheck {
6
6
  id = 'custom-labels-credential';
7
7
  name = 'Custom Labels Credential Exposure';
8
8
  category = 'Secrets Management';
9
- description = 'Scans Custom Labels for API keys, tokens, and credentials — labels are globally readable by all authenticated users via {!$Label.X} merge fields';
9
+ description = 'Scans Custom Labels for API keys, tokens, and credentials. Labels are globally readable by all authenticated users via {!$Label.X} merge fields';
10
10
  async run(ctx) {
11
11
  const findings = [];
12
12
  const baseUrl = ctx.orgInfo.instanceUrl;
@@ -21,7 +21,7 @@ export class CustomLabelsCredentialCheck {
21
21
  category: this.category,
22
22
  riskLevel: 'INFO',
23
23
  inconclusive: true,
24
- title: 'Custom Labels could not be queried — credential scan skipped',
24
+ title: 'Custom Labels could not be queried: credential scan skipped',
25
25
  detail: 'The Tooling API ExternalString query was not accessible. This may indicate the audit user lacks Tooling API access.',
26
26
  remediation: 'Grant Tooling API access to the audit user and re-run.',
27
27
  });
@@ -56,12 +56,12 @@ export class CustomLabelsCredentialCheck {
56
56
  category: this.category,
57
57
  riskLevel: 'HIGH',
58
58
  title: `${nameMatches.length} Custom Label(s) have names suggesting credential storage`,
59
- detail: `Custom Labels with names like "ApiKey", "ClientSecret", or "AuthToken" strongly suggest they store sensitive credentials. This is a critical misconfiguration: Custom Labels are globally readable by every authenticated Salesforce user via the \`{!\$Label.X}\` merge field in Visualforce pages, Flows, and Apex. Any user who can query the Tooling API or view source markup containing the merge field can read the label value — including attacker accounts, compromised users, and over-permissioned portal users. Unlike Named Credentials or Protected Custom Metadata, Custom Labels have no access control.`,
60
- remediation: 'Migrate these credentials to Named Credentials or Protected Custom Metadata (visibility: "Protected"). Named Credentials encrypt stored values and provide managed authentication. Protected Custom Metadata is only accessible from the managed package — not from arbitrary user queries.',
59
+ detail: `Custom Labels with names like "ApiKey", "ClientSecret", or "AuthToken" strongly suggest they store sensitive credentials. This is a critical misconfiguration: Custom Labels are globally readable by every authenticated Salesforce user via the \`{!\$Label.X}\` merge field in Visualforce pages, Flows, and Apex. Any user who can query the Tooling API or view source markup containing the merge field can read the label value, including attacker accounts, compromised users, and over-permissioned portal users. Unlike Named Credentials or Protected Custom Metadata, Custom Labels have no access control.`,
60
+ remediation: 'Migrate these credentials to Named Credentials or Protected Custom Metadata (visibility: "Protected"). Named Credentials encrypt stored values and provide managed authentication. Protected Custom Metadata is only accessible from the managed package, not from arbitrary user queries.',
61
61
  affectedItems: nameMatches.map((l) => ({
62
62
  label: l.Name,
63
63
  url: setupUrl,
64
- note: `Name indicates credential — migrate to Named Credential or Protected Custom Metadata`,
64
+ note: `Name indicates credential: migrate to Named Credential or Protected Custom Metadata`,
65
65
  })),
66
66
  });
67
67
  }
@@ -76,7 +76,7 @@ export class CustomLabelsCredentialCheck {
76
76
  affectedItems: valueMatches.map((l) => ({
77
77
  label: l.Name,
78
78
  url: setupUrl,
79
- note: `Value matches secret pattern — rotate credential and migrate storage`,
79
+ note: `Value matches secret pattern: rotate credential and migrate storage`,
80
80
  })),
81
81
  });
82
82
  }
@@ -86,7 +86,7 @@ export class CustomLabelsCredentialCheck {
86
86
  category: this.category,
87
87
  riskLevel: 'LOW',
88
88
  passed: true,
89
- title: `${labels.length} Custom Label(s) scanned — no obvious credential patterns found`,
89
+ title: `${labels.length} Custom Label(s) scanned: no obvious credential patterns found`,
90
90
  detail: `All ${labels.length} custom labels were scanned for name and value patterns indicating credential storage. No obvious secrets were found. Note: custom labels with obfuscated names or non-standard encoding may not be detected.`,
91
91
  remediation: 'Maintain the practice of using Named Credentials or Protected Custom Metadata for all secrets. Periodically review Custom Labels for new entries that may inadvertently store sensitive values.',
92
92
  });
@@ -48,7 +48,7 @@ export class DataClassificationCheck {
48
48
  category: this.category,
49
49
  riskLevel: 'INFO',
50
50
  inconclusive: true,
51
- title: 'Data classification status could not be determined — Tooling API access needed',
51
+ title: 'Data classification status could not be determined: Tooling API access needed',
52
52
  detail: 'SBS-DATA-001 requires all data fields to be classified by sensitivity. SBS-DATA-002 requires PII fields to be explicitly identified. The Tooling API FieldDefinition query was not accessible with the current user permissions.',
53
53
  remediation: 'Enable Tooling API access for the audit user, or manually review data classification in Setup → Data Management → Data Classification for Account, Contact, Lead, Opportunity, Case, Contract, and User.',
54
54
  });
@@ -63,7 +63,7 @@ export class DataClassificationCheck {
63
63
  category: this.category,
64
64
  riskLevel: 'LOW',
65
65
  passed: true,
66
- title: `Data classification configured on all ${CLASSIFICATION_OBJECTS.length} key objects — SBS-DATA-001/002`,
66
+ title: `Data classification configured on all ${CLASSIFICATION_OBJECTS.length} key objects: SBS-DATA-001/002`,
67
67
  detail: `SBS-DATA-001 requires data to be classified by sensitivity and SBS-DATA-002 requires PII to be identified. All checked objects have at least one classified field (total: ${totalClassifiedFields} classified fields across ${classifiedObjects.length} objects).`,
68
68
  remediation: 'Extend classification to any custom objects that store sensitive or personally identifiable data.',
69
69
  });
@@ -73,13 +73,13 @@ export class DataClassificationCheck {
73
73
  id: 'data-classification-missing',
74
74
  category: this.category,
75
75
  riskLevel: unclassifiedObjects.length >= 4 ? 'HIGH' : 'MEDIUM',
76
- title: `${unclassifiedObjects.length} of ${CLASSIFICATION_OBJECTS.length} key object(s) have no data classification — SBS-DATA-001/002`,
76
+ title: `${unclassifiedObjects.length} of ${CLASSIFICATION_OBJECTS.length} key object(s) have no data classification: SBS-DATA-001/002`,
77
77
  detail: `SBS-DATA-001 requires all data to be classified by sensitivity and SBS-DATA-002 requires PII to be identified. ${unclassifiedObjects.length} key object(s) have no fields with a Compliance Group set: ${unclassifiedObjects.join(', ')}. ${classifiedObjects.length > 0 ? `Objects with classification already configured: ${classifiedObjects.map((o) => `${o} (${classifiedMap.get(o)} field(s))`).join(', ')}.` : ''}`,
78
78
  remediation: 'Enable and configure the Salesforce Data Classification feature in Setup → Data Management → Data Classification. Assign compliance groups (PII, PCI, HIPAA, GDPR, etc.) to sensitive fields on all objects that store personal or regulated data. Prioritise email, phone, address, financial, and health-related fields.',
79
79
  affectedItems: unclassifiedObjects.map((name) => ({
80
80
  label: name,
81
81
  url: `${baseUrl}/lightning/setup/ObjectManager/${name}/FieldsAndRelationships/view`,
82
- note: 'No fields classified — configure Compliance Group via Data Classification in Setup',
82
+ note: 'No fields classified: configure Compliance Group via Data Classification in Setup',
83
83
  })),
84
84
  });
85
85
  }
@@ -91,7 +91,7 @@ export class DataClassificationCheck {
91
91
  category: this.category,
92
92
  riskLevel: 'LOW',
93
93
  passed: true,
94
- title: `Shield Platform Encryption active — ${encryptionKeyCount} encryption key(s) found — SBS-DATA-003`,
94
+ title: `Shield Platform Encryption active: ${encryptionKeyCount} encryption key(s) found (SBS-DATA-003)`,
95
95
  detail: `SBS-DATA-003 requires sensitive data to be encrypted at rest commensurate with its classification. ${encryptionKeyCount} Shield Platform Encryption key(s) are configured, indicating encryption-at-rest is in use.`,
96
96
  remediation: 'Verify encryption is applied to all fields classified as sensitive or PII. Review the Encryption Statistics page in Setup → Security → Platform Encryption to confirm field-level coverage.',
97
97
  });
@@ -101,7 +101,7 @@ export class DataClassificationCheck {
101
101
  id: 'data-encryption-not-detected',
102
102
  category: this.category,
103
103
  riskLevel: 'MEDIUM',
104
- title: 'Shield Platform Encryption not detected — SBS-DATA-003',
104
+ title: 'Shield Platform Encryption not detected: SBS-DATA-003',
105
105
  detail: 'SBS-DATA-003 requires data at rest to be encrypted in line with its assigned classification. No Shield Platform Encryption keys were found, indicating either Shield is not licensed or encryption has not been configured for this org.',
106
106
  remediation: 'Evaluate Salesforce Shield Platform Encryption for fields classified as sensitive or PII. If Shield is not available in your edition, document the compensating control (e.g., Classic Encryption for specific fields, or infrastructure-level disk encryption), and assess whether it meets the intent of SBS-DATA-003.',
107
107
  });
@@ -0,0 +1,19 @@
1
+ import type { AuditContext } from '../../context/AuditContext.js';
2
+ import type { SecurityCheck, CheckResult } from '../SecurityCheck.js';
3
+ /**
4
+ * Finds the profiles / permission sets that grant a bulk data-extraction
5
+ * capability — the mechanisms an attacker (or a departing insider) uses to
6
+ * exfiltrate en masse, which the report/sharing checks do not cover:
7
+ * - "Weekly Data Export" (PermissionsDataExport): full-org CSV export.
8
+ * - "API Enabled" combined with View/Modify All Data: unrestricted Bulk/REST pull
9
+ * of every record.
10
+ * The toxic combination (export or API + ViewAll) is graded highest.
11
+ */
12
+ export declare class DataExportAccessCheck implements SecurityCheck {
13
+ readonly id = "data-export-access";
14
+ readonly name = "Mass Data Export Access";
15
+ readonly category = "Data Access Control";
16
+ readonly description = "Flags profiles/permission sets granting Weekly Data Export or API access combined with View/Modify All Data \u2014 the bulk data-exfiltration capability";
17
+ run(ctx: AuditContext): Promise<CheckResult>;
18
+ }
19
+ //# sourceMappingURL=DataExportAccessCheck.d.ts.map
@@ -0,0 +1,79 @@
1
+ /**
2
+ * Finds the profiles / permission sets that grant a bulk data-extraction
3
+ * capability — the mechanisms an attacker (or a departing insider) uses to
4
+ * exfiltrate en masse, which the report/sharing checks do not cover:
5
+ * - "Weekly Data Export" (PermissionsDataExport): full-org CSV export.
6
+ * - "API Enabled" combined with View/Modify All Data: unrestricted Bulk/REST pull
7
+ * of every record.
8
+ * The toxic combination (export or API + ViewAll) is graded highest.
9
+ */
10
+ export class DataExportAccessCheck {
11
+ id = 'data-export-access';
12
+ name = 'Mass Data Export Access';
13
+ category = 'Data Access Control';
14
+ description = 'Flags profiles/permission sets granting Weekly Data Export or API access combined with View/Modify All Data — the bulk data-exfiltration capability';
15
+ async run(ctx) {
16
+ const findings = [];
17
+ const baseUrl = ctx.orgInfo.instanceUrl;
18
+ let rows;
19
+ try {
20
+ rows = await ctx.soql.queryAll(`SELECT Id, Label, Type, Profile.Name, PermissionsDataExport, PermissionsApiEnabled,
21
+ PermissionsViewAllData, PermissionsModifyAllData
22
+ FROM PermissionSet
23
+ WHERE PermissionsDataExport = true OR (PermissionsApiEnabled = true AND (PermissionsViewAllData = true OR PermissionsModifyAllData = true))`);
24
+ }
25
+ catch {
26
+ findings.push({
27
+ id: 'data-export-access-inconclusive',
28
+ category: this.category,
29
+ riskLevel: 'INFO',
30
+ inconclusive: true,
31
+ title: 'Data-export permissions could not be queried (insufficient access)',
32
+ detail: 'PermissionSet was not accessible, so mass-export capability could not be evaluated.',
33
+ remediation: 'Grant the audit user access to PermissionSet (View Setup and Configuration) and re-run.',
34
+ });
35
+ return { findings };
36
+ }
37
+ const label = (r) => (r.Type === 'Profile' && r.Profile ? `Profile: ${r.Profile.Name}` : `Permission Set: ${r.Label}`);
38
+ const exportGrants = rows.filter((r) => r.PermissionsDataExport);
39
+ const bulkApiGrants = rows.filter((r) => r.PermissionsApiEnabled && (r.PermissionsViewAllData || r.PermissionsModifyAllData));
40
+ if (exportGrants.length > 0) {
41
+ findings.push({
42
+ id: 'data-export-weekly-export',
43
+ category: this.category,
44
+ riskLevel: 'HIGH',
45
+ title: `${exportGrants.length} profile(s)/permission set(s) grant "Weekly Data Export"`,
46
+ detail: 'The "Weekly Data Export" permission lets the holder export the entire org to CSV on demand. Granted beyond a small set of trusted administrators, it is a one-click mass-exfiltration capability with no per-object gating.',
47
+ remediation: 'Remove "Weekly Data Export" from all but a minimal set of named administrators. Prefer a monitored, purpose-built integration for scheduled extracts, and alert on Data Export events via Event Monitoring.',
48
+ affectedItems: exportGrants.slice(0, 40).map((r) => ({ label: label(r), url: `${baseUrl}/lightning/setup/PermSets/home` })),
49
+ });
50
+ }
51
+ if (bulkApiGrants.length > 0) {
52
+ findings.push({
53
+ id: 'data-export-bulk-api-viewall',
54
+ category: this.category,
55
+ riskLevel: 'HIGH',
56
+ title: `${bulkApiGrants.length} profile(s)/permission set(s) combine API access with View/Modify All Data`,
57
+ detail: 'API Enabled together with View All Data or Modify All Data lets the holder pull (or alter) every record in the org through the Bulk/REST API from any client — a programmatic bulk-exfiltration path that bypasses UI and sharing.',
58
+ remediation: 'Split these grants: integration/service accounts should hold API access scoped by object permissions, not View/Modify All. Remove View/Modify All from any account that only needs targeted API access, and restrict API clients via "API Access Control".',
59
+ affectedItems: bulkApiGrants.slice(0, 40).map((r) => ({
60
+ label: `${label(r)}${r.PermissionsModifyAllData ? ' (Modify All)' : ' (View All)'}`,
61
+ url: `${baseUrl}/lightning/setup/PermSets/home`,
62
+ })),
63
+ });
64
+ }
65
+ if (findings.length === 0) {
66
+ findings.push({
67
+ id: 'data-export-access-ok',
68
+ category: this.category,
69
+ riskLevel: 'LOW',
70
+ passed: true,
71
+ title: 'No broad mass-export capability found',
72
+ detail: 'No profiles/permission sets grant Weekly Data Export, nor API access combined with View/Modify All Data.',
73
+ remediation: 'Keep Weekly Data Export and View/Modify-All limited to trusted admins, and prefer scoped integration users for extracts.',
74
+ });
75
+ }
76
+ return { findings };
77
+ }
78
+ }
79
+ //# sourceMappingURL=DataExportAccessCheck.js.map
@@ -24,7 +24,7 @@ export class DebugLogAccessCheck {
24
24
  category: this.category,
25
25
  riskLevel: 'INFO',
26
26
  inconclusive: true,
27
- title: 'TraceFlag records could not be retrieved — active debug traces cannot be verified',
27
+ title: 'TraceFlag records could not be retrieved: active debug traces cannot be verified',
28
28
  detail: 'The TraceFlag object was not accessible. This may indicate the audit user lacks API access or the required permission to manage debug logs.',
29
29
  remediation: 'Grant "Manage Users" or "View All Data" permission to the audit user, or review active debug traces manually in Setup → Debug Logs.',
30
30
  affectedItems: [{ label: 'Debug Log Setup', url: setupUrl }],
@@ -51,12 +51,12 @@ export class DebugLogAccessCheck {
51
51
  category: this.category,
52
52
  riskLevel: 'HIGH',
53
53
  title: `${userDebugTraces.length} active USER_DEBUG trace flag(s) are capturing all user activity`,
54
- detail: `In production, active debug traces on users should be reviewed — they capture sensitive field values and are accessible to administrators. USER_DEBUG traces record all DML operations, SOQL queries, and field values for the traced user, including data from sensitive objects such as financial records, PII, and health information. Debug logs are visible to any org admin and are not access-controlled at the record level.`,
54
+ detail: `In production, active debug traces on users should be reviewed: they capture sensitive field values and are accessible to administrators. USER_DEBUG traces record all DML operations, SOQL queries, and field values for the traced user, including data from sensitive objects such as financial records, PII, and health information. Debug logs are visible to any org admin and are not access-controlled at the record level.`,
55
55
  remediation: 'Remove all USER_DEBUG trace flags that are not actively being used for an approved troubleshooting session. Establish a policy requiring trace flags to be removed within 24 hours of creation. Consider using a dedicated sandbox for debugging rather than production.',
56
56
  affectedItems: userDebugTraces.map((t) => ({
57
57
  label: t.TracedEntityId,
58
58
  url: setupUrl,
59
- note: `LogType: ${t.LogType} — expires: ${new Date(t.ExpirationDate).toISOString().split('T')[0]} — level: ${t.DebugLevel?.DeveloperName ?? 'unknown'}`,
59
+ note: `LogType: ${t.LogType} (expires: ${new Date(t.ExpirationDate).toISOString().split('T')[0]}, level: ${t.DebugLevel?.DeveloperName ?? 'unknown'})`,
60
60
  })),
61
61
  });
62
62
  }
@@ -65,13 +65,13 @@ export class DebugLogAccessCheck {
65
65
  id: 'debug-log-high-level',
66
66
  category: this.category,
67
67
  riskLevel: 'MEDIUM',
68
- title: `${highDetailTraces.length} active trace flag(s) use FINE/FINER/FINEST log level — all variable values are captured`,
69
- detail: `Active traces with ApexCode set to FINE, FINER, or FINEST capture the maximum level of detail, including all variable values at every line of code execution. This includes any field values read or written during the traced session, potentially exposing passwords, tokens, PII, and financial data in the debug log output. In production, active debug traces on users should be reviewed — they capture sensitive field values and are accessible to administrators.`,
68
+ title: `${highDetailTraces.length} active trace flag(s) use FINE/FINER/FINEST log level: all variable values are captured`,
69
+ detail: `Active traces with ApexCode set to FINE, FINER, or FINEST capture the maximum level of detail, including all variable values at every line of code execution. This includes any field values read or written during the traced session, potentially exposing passwords, tokens, PII, and financial data in the debug log output. In production, active debug traces on users should be reviewed: they capture sensitive field values and are accessible to administrators.`,
70
70
  remediation: 'Reduce log levels to ERROR or WARN for any traces that must remain active. Remove high-detail traces immediately after the debugging session is complete. Never leave FINEST-level traces active in production for extended periods.',
71
71
  affectedItems: highDetailTraces.map((t) => ({
72
72
  label: t.TracedEntityId,
73
73
  url: setupUrl,
74
- note: `ApexCode level: ${t.DebugLevel?.ApexCode ?? 'unknown'} — expires: ${new Date(t.ExpirationDate).toISOString().split('T')[0]}`,
74
+ note: `ApexCode level: ${t.DebugLevel?.ApexCode ?? 'unknown'} (expires: ${new Date(t.ExpirationDate).toISOString().split('T')[0]})`,
75
75
  })),
76
76
  });
77
77
  }
@@ -27,13 +27,13 @@ export class DeploymentIdentityCheck {
27
27
  category: this.category,
28
28
  riskLevel: 'LOW',
29
29
  passed: true,
30
- title: `${ciCdApps.length} CI/CD-related Connected App(s) detected — pipeline deployment likely in use`,
30
+ title: `${ciCdApps.length} CI/CD-related Connected App(s) detected: pipeline deployment likely in use`,
31
31
  detail: 'SBS-DEP-001 requires all deployments to be performed by a designated deployment identity, not individual admin accounts. Connected Apps with CI/CD tool names indicate pipeline-based deployments are in use, which is consistent with a controlled deployment process.',
32
32
  remediation: 'Confirm each CI/CD app authenticates as a dedicated deployment service account (not a shared admin user). Document the deployment identity and its owner in the system of record.',
33
33
  affectedItems: ciCdApps.map((name) => ({
34
34
  label: name,
35
35
  url: connectedAppsUrl,
36
- note: 'CI/CD Connected App — verify it uses a named, dedicated deployment user',
36
+ note: 'CI/CD Connected App: verify it uses a named, dedicated deployment user',
37
37
  })),
38
38
  });
39
39
  }
@@ -56,7 +56,7 @@ export class DeploymentIdentityCheck {
56
56
  category: this.category,
57
57
  riskLevel: 'MEDIUM',
58
58
  inconclusive: true,
59
- title: 'Deployment audit trail could not be read — SBS-DEP-003 unverified',
59
+ title: 'Deployment audit trail could not be read: SBS-DEP-003 unverified',
60
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.',
61
61
  remediation: 'Grant "View Setup and Configuration" permission to the audit user to enable audit trail analysis.',
62
62
  });
@@ -67,7 +67,7 @@ export class DeploymentIdentityCheck {
67
67
  id: 'deployment-no-activity',
68
68
  category: this.category,
69
69
  riskLevel: 'INFO',
70
- title: 'No deployment activity detected in the last 90 days — SBS-DEP-001/003',
70
+ title: 'No deployment activity detected in the last 90 days: SBS-DEP-001/003',
71
71
  detail: 'SBS-DEP-001 requires a designated deployment identity. No deployment-related SetupAuditTrail entries (Change Sets, Developer Tools, Packages, Metadata sections) and no CI/CD-named Connected Apps were found. Deployments via SF CLI JWT flow or Metadata API may not appear in the audit trail.',
72
72
  remediation: 'Verify deployment processes are documented with a designated identity. If using SF CLI with JWT, confirm the authenticating user is a dedicated service account, not an individual admin.',
73
73
  });
@@ -99,7 +99,7 @@ export class DeploymentIdentityCheck {
99
99
  id: 'deployment-multiple-identities',
100
100
  category: this.category,
101
101
  riskLevel: uniqueDeployers.length > 3 ? 'HIGH' : 'MEDIUM',
102
- title: `${uniqueDeployers.length} distinct user(s) performed deployment actions in the last 90 days — SBS-DEP-001`,
102
+ title: `${uniqueDeployers.length} distinct user(s) performed deployment actions in the last 90 days: SBS-DEP-001`,
103
103
  detail: `SBS-DEP-001 requires all deployments to be performed by a single designated deployment identity, not individual user accounts. ${uniqueDeployers.length} distinct users were found in deployment-related audit trail entries (Change Sets, Developer Tools, Packages, Metadata) over the past 90 days. Multiple deployers make it harder to audit changes and bypass change-management controls.`,
104
104
  remediation: 'Centralise deployments through a CI/CD pipeline that authenticates as a single named service account. Revoke direct deployment access from individual admin users.',
105
105
  affectedItems: uniqueDeployers.map(({ username, profile, count, latest }) => ({
@@ -116,7 +116,7 @@ export class DeploymentIdentityCheck {
116
116
  category: this.category,
117
117
  riskLevel: 'LOW',
118
118
  passed: true,
119
- title: 'All deployment activity in the last 90 days came from a single identity — SBS-DEP-001',
119
+ title: 'All deployment activity in the last 90 days came from a single identity: SBS-DEP-001',
120
120
  detail: `SBS-DEP-001 requires a designated deployment identity. All ${deployRecords.length} deployment-related audit trail entries over 90 days originate from the same user: ${d.username} (${d.profile}).`,
121
121
  remediation: 'Document this identity as the designated deployment user in your system of record. Verify it is a service account and not a personal admin account.',
122
122
  });
@@ -127,13 +127,13 @@ export class DeploymentIdentityCheck {
127
127
  id: 'deployment-admin-accounts',
128
128
  category: this.category,
129
129
  riskLevel: 'MEDIUM',
130
- title: `${adminDeployers.length} deployer(s) are admin-profile users — SBS-DEP-003`,
130
+ title: `${adminDeployers.length} deployer(s) are admin-profile users: SBS-DEP-003`,
131
131
  detail: 'SBS-DEP-003 requires monitoring for unauthorized deployment modifications. Deployments performed by administrator-profile users are harder to distinguish from emergency break-glass changes and are more likely to occur outside of a change-management window.',
132
132
  remediation: 'Replace admin-user deployments with a CI/CD pipeline using a dedicated integration user with only deployment-required permissions. Reserve individual admin accounts for emergency use only, and document any emergency deployments in the system of record.',
133
133
  affectedItems: adminDeployers.map(({ username, profile, count }) => ({
134
134
  label: username,
135
135
  url: auditUrl,
136
- note: `${count} deployment action(s) | profile: ${profile} — replace with dedicated deployment service account`,
136
+ note: `${count} deployment action(s) | profile: ${profile} | replace with dedicated deployment service account`,
137
137
  })),
138
138
  });
139
139
  }
@@ -0,0 +1,10 @@
1
+ import type { AuditContext } from '../../context/AuditContext.js';
2
+ import type { SecurityCheck, CheckResult } from '../SecurityCheck.js';
3
+ export declare class EmailSecurityCheck implements SecurityCheck {
4
+ readonly id = "email-security";
5
+ readonly name = "Email Security & Spoofing";
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";
8
+ run(ctx: AuditContext): Promise<CheckResult>;
9
+ }
10
+ //# sourceMappingURL=EmailSecurityCheck.d.ts.map
@@ -0,0 +1,117 @@
1
+ // Wraps a query so a single inaccessible source degrades to an inconclusive finding
2
+ // rather than failing the whole check (mirrors the project-wide permission-error pattern).
3
+ async function tryQuery(fn, findings, category, id, label) {
4
+ try {
5
+ return await fn();
6
+ }
7
+ catch (err) {
8
+ const msg = err instanceof Error ? err.message : String(err);
9
+ findings.push({
10
+ id,
11
+ category,
12
+ riskLevel: 'INFO',
13
+ inconclusive: true,
14
+ title: `${label} could not be read`,
15
+ detail: `The query was not accessible: ${msg}`,
16
+ remediation: 'Grant the audit user "View Setup and Configuration", then re-run the audit.',
17
+ });
18
+ return null;
19
+ }
20
+ }
21
+ export class EmailSecurityCheck {
22
+ id = 'email-security';
23
+ name = 'Email Security & Spoofing';
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';
26
+ async run(ctx) {
27
+ const findings = [];
28
+ const baseUrl = ctx.orgInfo.instanceUrl;
29
+ const owaUrl = `${baseUrl}/lightning/setup/OrgWideEmailAddresses/home`;
30
+ 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.
63
+ 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');
64
+ if (services && services.length > 0) {
65
+ const unauthenticated = services.filter((s) => !s.IsAuthenticationRequired);
66
+ if (unauthenticated.length > 0) {
67
+ findings.push({
68
+ id: 'email-security-services-no-auth',
69
+ category: this.category,
70
+ riskLevel: 'HIGH',
71
+ title: `${unauthenticated.length} active inbound email service(s) do not require authentication`,
72
+ detail: 'An inbound email service that does not require authentication runs Apex on receipt of email from any sender. Attackers can invoke the handler repeatedly with crafted payloads, abusing it for spam relay, data injection, or as an unauthenticated entry point into Apex logic.',
73
+ remediation: 'Enable "Advanced Email Security Settings" so the service requires authentication (SPF/DKIM/TLS), and restrict accepted senders on each email address.',
74
+ affectedItems: unauthenticated.map((s) => ({
75
+ label: s.FunctionName,
76
+ url: svcUrl,
77
+ note: 'Active service accepts unauthenticated email',
78
+ })),
79
+ });
80
+ }
81
+ else {
82
+ findings.push({
83
+ id: 'email-security-services-ok',
84
+ category: this.category,
85
+ riskLevel: 'LOW',
86
+ passed: true,
87
+ title: `${services.length} active inbound email service(s) require authentication`,
88
+ detail: 'All active inbound email services require authentication before running Apex.',
89
+ remediation: 'Continue to require authentication and restrict accepted senders.',
90
+ });
91
+ }
92
+ }
93
+ // 3. Inbound email service addresses with no authorized-sender restriction.
94
+ const addresses = await tryQuery(() => ctx.soql.queryAll('SELECT Id, LocalPart, EmailDomainName, IsActive, AuthorizedSenders FROM EmailServicesAddress WHERE IsActive = true'), findings, this.category, 'email-security-addresses-inaccessible', 'Inbound email service addresses');
95
+ if (addresses && addresses.length > 0) {
96
+ const open = addresses.filter((a) => !a.AuthorizedSenders || a.AuthorizedSenders.trim() === '');
97
+ if (open.length > 0) {
98
+ findings.push({
99
+ id: 'email-security-addresses-open',
100
+ category: this.category,
101
+ riskLevel: 'MEDIUM',
102
+ title: `${open.length} inbound email address(es) accept mail from any sender`,
103
+ detail: 'An email service address with no "Accept Email From" restriction processes messages from any sender on the internet. Combined with an Apex handler, this is an unauthenticated, internet-facing input surface.',
104
+ remediation: 'Populate "Accept Email From" on each active email service address with the specific domains or addresses that should be allowed to send to it.',
105
+ affectedItems: open.map((a) => ({
106
+ label: `${a.LocalPart}${a.EmailDomainName ? '@' + a.EmailDomainName : ''}`,
107
+ url: svcUrl,
108
+ note: 'No authorized-sender restriction',
109
+ })),
110
+ });
111
+ }
112
+ }
113
+ // If nothing was readable at all, the per-source inconclusive findings already explain why.
114
+ return { findings };
115
+ }
116
+ }
117
+ //# sourceMappingURL=EmailSecurityCheck.js.map
@@ -0,0 +1,19 @@
1
+ import type { AuditContext } from '../../context/AuditContext.js';
2
+ import type { SecurityCheck, CheckResult } from '../SecurityCheck.js';
3
+ /**
4
+ * Cross-references data classification against ACTUAL field encryption. `data-
5
+ * classification` confirms Shield is licensed and that fields are classified;
6
+ * this check answers the next question: are the fields marked sensitive (PII/PHI
7
+ * via ComplianceGroup) actually encrypted at rest? Classified-but-plaintext
8
+ * fields are the gap that matters for a health/PII org — the data is labelled
9
+ * sensitive yet stored in the clear.
10
+ */
11
+ export declare class EncryptionCoverageCheck implements SecurityCheck {
12
+ readonly id = "encryption-coverage";
13
+ readonly name = "Encryption Coverage for Sensitive Fields";
14
+ readonly category = "Data Security";
15
+ readonly description = "Flags fields classified as sensitive (PII/PHI via ComplianceGroup) that are not encrypted at rest with Shield Platform Encryption";
16
+ run(ctx: AuditContext): Promise<CheckResult>;
17
+ private inconclusive;
18
+ }
19
+ //# sourceMappingURL=EncryptionCoverageCheck.d.ts.map