@cclabsnz/sf-audit 1.0.1 → 1.2.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 (196) hide show
  1. package/README.md +228 -31
  2. package/lib/api/ToolingClientImpl.js +5 -2
  3. package/lib/chains/AttackChain.d.ts +20 -0
  4. package/lib/chains/AttackChain.js +2 -0
  5. package/lib/chains/Capability.d.ts +7 -0
  6. package/lib/chains/Capability.js +11 -0
  7. package/lib/chains/CapabilityRegistry.d.ts +18 -0
  8. package/lib/chains/CapabilityRegistry.js +53 -0
  9. package/lib/chains/ChainEngine.d.ts +13 -0
  10. package/lib/chains/ChainEngine.js +137 -0
  11. package/lib/chains/namedChains.d.ts +14 -0
  12. package/lib/chains/namedChains.js +99 -0
  13. package/lib/checks/CheckEngine.js +33 -5
  14. package/lib/checks/impl/AnonymousApexAuditCheck.d.ts +10 -0
  15. package/lib/checks/impl/AnonymousApexAuditCheck.js +106 -0
  16. package/lib/checks/impl/ApexCrudFLSCheck.d.ts +11 -0
  17. package/lib/checks/impl/ApexCrudFLSCheck.js +98 -0
  18. package/lib/checks/impl/ApexLoggingCheck.d.ts +11 -0
  19. package/lib/checks/impl/ApexLoggingCheck.js +124 -0
  20. package/lib/checks/impl/ApexRestEndpointCheck.d.ts +11 -0
  21. package/lib/checks/impl/ApexRestEndpointCheck.js +94 -0
  22. package/lib/checks/impl/ApexSharingCheck.js +29 -0
  23. package/lib/checks/impl/ApiClientPermissionCheck.d.ts +10 -0
  24. package/lib/checks/impl/ApiClientPermissionCheck.js +59 -0
  25. package/lib/checks/impl/AuditTrailCheck.js +29 -0
  26. package/lib/checks/impl/CertificateExpiryCheck.d.ts +10 -0
  27. package/lib/checks/impl/CertificateExpiryCheck.js +123 -0
  28. package/lib/checks/impl/CodeSecurityCheck.d.ts +2 -1
  29. package/lib/checks/impl/CodeSecurityCheck.js +46 -6
  30. package/lib/checks/impl/ConnectedAppInactivityCheck.d.ts +11 -0
  31. package/lib/checks/impl/ConnectedAppInactivityCheck.js +86 -0
  32. package/lib/checks/impl/ConnectedAppScopeCheck.d.ts +10 -0
  33. package/lib/checks/impl/ConnectedAppScopeCheck.js +125 -0
  34. package/lib/checks/impl/ConnectedAppsCheck.d.ts +1 -0
  35. package/lib/checks/impl/ConnectedAppsCheck.js +37 -2
  36. package/lib/checks/impl/ContentLinksCheck.d.ts +10 -0
  37. package/lib/checks/impl/ContentLinksCheck.js +115 -0
  38. package/lib/checks/impl/CorsAllowlistCheck.d.ts +10 -0
  39. package/lib/checks/impl/CorsAllowlistCheck.js +80 -0
  40. package/lib/checks/impl/CspTrustedSitesCheck.d.ts +10 -0
  41. package/lib/checks/impl/CspTrustedSitesCheck.js +55 -0
  42. package/lib/checks/impl/CustomLabelsCredentialCheck.d.ts +10 -0
  43. package/lib/checks/impl/CustomLabelsCredentialCheck.js +97 -0
  44. package/lib/checks/impl/DataClassificationCheck.d.ts +10 -0
  45. package/lib/checks/impl/DataClassificationCheck.js +112 -0
  46. package/lib/checks/impl/DebugLogAccessCheck.d.ts +10 -0
  47. package/lib/checks/impl/DebugLogAccessCheck.js +81 -0
  48. package/lib/checks/impl/DeploymentIdentityCheck.d.ts +11 -0
  49. package/lib/checks/impl/DeploymentIdentityCheck.js +144 -0
  50. package/lib/checks/impl/EnhancedDomainsCheck.d.ts +10 -0
  51. package/lib/checks/impl/EnhancedDomainsCheck.js +84 -0
  52. package/lib/checks/impl/EscalationPermsCheck.d.ts +10 -0
  53. package/lib/checks/impl/EscalationPermsCheck.js +77 -0
  54. package/lib/checks/impl/EventMonitoringCheck.d.ts +11 -0
  55. package/lib/checks/impl/EventMonitoringCheck.js +84 -0
  56. package/lib/checks/impl/ExperienceCloudSiteCheck.d.ts +10 -0
  57. package/lib/checks/impl/ExperienceCloudSiteCheck.js +91 -0
  58. package/lib/checks/impl/FailedLoginCheck.d.ts +10 -0
  59. package/lib/checks/impl/FailedLoginCheck.js +122 -0
  60. package/lib/checks/impl/FieldHistoryTrackingCheck.d.ts +10 -0
  61. package/lib/checks/impl/FieldHistoryTrackingCheck.js +70 -0
  62. package/lib/checks/impl/FieldLevelSecurityCheck.js +28 -18
  63. package/lib/checks/impl/GuestExecutableApexCheck.d.ts +11 -0
  64. package/lib/checks/impl/GuestExecutableApexCheck.js +93 -0
  65. package/lib/checks/impl/GuestUserAccessCheck.js +74 -66
  66. package/lib/checks/impl/HardcodedCredentialsCheck.js +2 -2
  67. package/lib/checks/impl/HighAssuranceSessionCheck.d.ts +10 -0
  68. package/lib/checks/impl/HighAssuranceSessionCheck.js +103 -0
  69. package/lib/checks/impl/InactiveUsersCheck.js +38 -19
  70. package/lib/checks/impl/InstalledPackagesCheck.d.ts +10 -0
  71. package/lib/checks/impl/InstalledPackagesCheck.js +94 -0
  72. package/lib/checks/impl/IntegrationUsersCheck.d.ts +10 -0
  73. package/lib/checks/impl/IntegrationUsersCheck.js +108 -0
  74. package/lib/checks/impl/InternalUserMfaCheck.d.ts +10 -0
  75. package/lib/checks/impl/InternalUserMfaCheck.js +81 -0
  76. package/lib/checks/impl/IpRestrictionsCheck.js +86 -23
  77. package/lib/checks/impl/LegacyApiVersionCheck.d.ts +10 -0
  78. package/lib/checks/impl/LegacyApiVersionCheck.js +91 -0
  79. package/lib/checks/impl/MfaEnforcementCheck.d.ts +10 -0
  80. package/lib/checks/impl/MfaEnforcementCheck.js +76 -0
  81. package/lib/checks/impl/MfaMethodStrengthCheck.d.ts +11 -0
  82. package/lib/checks/impl/MfaMethodStrengthCheck.js +116 -0
  83. package/lib/checks/impl/MfaRegistrationCheck.d.ts +11 -0
  84. package/lib/checks/impl/MfaRegistrationCheck.js +95 -0
  85. package/lib/checks/impl/MyDomainLoginPolicyCheck.d.ts +10 -0
  86. package/lib/checks/impl/MyDomainLoginPolicyCheck.js +105 -0
  87. package/lib/checks/impl/NamedCredentialsCheck.js +37 -2
  88. package/lib/checks/impl/PermissionsCheck.js +67 -14
  89. package/lib/checks/impl/PublicGroupSharingCheck.js +20 -9
  90. package/lib/checks/impl/ReleaseUpdatesCheck.d.ts +10 -0
  91. package/lib/checks/impl/ReleaseUpdatesCheck.js +106 -0
  92. package/lib/checks/impl/ReportFolderAccessCheck.d.ts +10 -0
  93. package/lib/checks/impl/ReportFolderAccessCheck.js +54 -0
  94. package/lib/checks/impl/ScheduledApexCheck.d.ts +1 -0
  95. package/lib/checks/impl/ScheduledApexCheck.js +3 -0
  96. package/lib/checks/impl/SharingModelCheck.d.ts +1 -1
  97. package/lib/checks/impl/SharingModelCheck.js +103 -32
  98. package/lib/checks/impl/SiemIntegrationCheck.d.ts +11 -0
  99. package/lib/checks/impl/SiemIntegrationCheck.js +102 -0
  100. package/lib/checks/impl/SsoEnforcementCheck.d.ts +10 -0
  101. package/lib/checks/impl/SsoEnforcementCheck.js +90 -0
  102. package/lib/checks/impl/StandardProfilesCheck.d.ts +10 -0
  103. package/lib/checks/impl/StandardProfilesCheck.js +68 -0
  104. package/lib/checks/impl/TransactionSecurityPolicyCheck.d.ts +10 -0
  105. package/lib/checks/impl/TransactionSecurityPolicyCheck.js +62 -0
  106. package/lib/checks/impl/TrustedIPRangesCheck.d.ts +10 -0
  107. package/lib/checks/impl/TrustedIPRangesCheck.js +106 -0
  108. package/lib/checks/impl/UsersAndAdminsCheck.js +50 -20
  109. package/lib/checks/impl/VisualforceXssCheck.d.ts +11 -0
  110. package/lib/checks/impl/VisualforceXssCheck.js +150 -0
  111. package/lib/checks/registry.js +97 -12
  112. package/lib/commands/audit/diff.d.ts +17 -0
  113. package/lib/commands/audit/diff.js +76 -0
  114. package/lib/commands/audit/history.d.ts +15 -0
  115. package/lib/commands/audit/history.js +59 -0
  116. package/lib/commands/audit/security.d.ts +5 -0
  117. package/lib/commands/audit/security.js +38 -9
  118. package/lib/compliance/catalogs/hiso10029.d.ts +3 -0
  119. package/lib/compliance/catalogs/hiso10029.js +35 -0
  120. package/lib/compliance/catalogs/index.d.ts +4 -0
  121. package/lib/compliance/catalogs/index.js +21 -0
  122. package/lib/compliance/catalogs/iso27001.d.ts +3 -0
  123. package/lib/compliance/catalogs/iso27001.js +39 -0
  124. package/lib/compliance/catalogs/nzism.d.ts +3 -0
  125. package/lib/compliance/catalogs/nzism.js +31 -0
  126. package/lib/compliance/catalogs/owasp.d.ts +3 -0
  127. package/lib/compliance/catalogs/owasp.js +37 -0
  128. package/lib/compliance/catalogs/privacyAct.d.ts +3 -0
  129. package/lib/compliance/catalogs/privacyAct.js +17 -0
  130. package/lib/compliance/catalogs/sbs.d.ts +3 -0
  131. package/lib/compliance/catalogs/sbs.js +61 -0
  132. package/lib/compliance/catalogs/soc2.d.ts +3 -0
  133. package/lib/compliance/catalogs/soc2.js +42 -0
  134. package/lib/compliance/mapping.d.ts +2 -0
  135. package/lib/compliance/mapping.js +111 -0
  136. package/lib/compliance/resolve.d.ts +12 -0
  137. package/lib/compliance/resolve.js +49 -0
  138. package/lib/compliance/types.d.ts +13 -0
  139. package/lib/compliance/types.js +2 -0
  140. package/lib/context/AuditCache.d.ts +20 -0
  141. package/lib/context/AuditContext.d.ts +0 -2
  142. package/lib/findings/AuditResult.d.ts +3 -0
  143. package/lib/findings/CheckMeta.d.ts +9 -0
  144. package/lib/findings/CheckMeta.js +67 -0
  145. package/lib/findings/ComplianceMapping.d.ts +3 -0
  146. package/lib/findings/ComplianceMapping.js +75 -0
  147. package/lib/findings/Finding.d.ts +20 -0
  148. package/lib/findings/loadScoringConfig.js +9 -2
  149. package/lib/findings/scoring.d.ts +2 -1
  150. package/lib/findings/scoring.js +20 -7
  151. package/lib/history/AuditDiff.d.ts +26 -0
  152. package/lib/history/AuditDiff.js +2 -0
  153. package/lib/history/DiffEngine.d.ts +4 -0
  154. package/lib/history/DiffEngine.js +61 -0
  155. package/lib/history/HistoryStore.d.ts +11 -0
  156. package/lib/history/HistoryStore.js +56 -0
  157. package/lib/history/metricMeta.d.ts +9 -0
  158. package/lib/history/metricMeta.js +28 -0
  159. package/lib/index.d.ts +7 -1
  160. package/lib/index.js +2 -1
  161. package/lib/lib/wire.d.ts +1 -2
  162. package/lib/lib/wire.js +1 -2
  163. package/lib/renderers/AuditRenderer.d.ts +2 -0
  164. package/lib/renderers/ClientReportRenderer.d.ts +29 -0
  165. package/lib/renderers/ClientReportRenderer.js +205 -0
  166. package/lib/renderers/DiffHtmlRenderer.d.ts +8 -0
  167. package/lib/renderers/DiffHtmlRenderer.js +164 -0
  168. package/lib/renderers/DiffJsonRenderer.d.ts +8 -0
  169. package/lib/renderers/DiffJsonRenderer.js +8 -0
  170. package/lib/renderers/DiffRenderer.d.ts +7 -0
  171. package/lib/renderers/DiffRenderer.js +2 -0
  172. package/lib/renderers/HistoryRenderer.d.ts +6 -0
  173. package/lib/renderers/HistoryRenderer.js +140 -0
  174. package/lib/renderers/HtmlRenderer.d.ts +1 -0
  175. package/lib/renderers/HtmlRenderer.js +354 -60
  176. package/lib/renderers/MarkdownRenderer.js +34 -1
  177. package/lib/renderers/html-utils.d.ts +2 -0
  178. package/lib/renderers/html-utils.js +8 -0
  179. package/lib/report/ComplianceMatrix.d.ts +19 -0
  180. package/lib/report/ComplianceMatrix.js +47 -0
  181. package/lib/report/ExecutivePriorities.d.ts +8 -0
  182. package/lib/report/ExecutivePriorities.js +22 -0
  183. package/lib/report/RemediationRoadmap.d.ts +9 -0
  184. package/lib/report/RemediationRoadmap.js +18 -0
  185. package/lib/report/branding.d.ts +18 -0
  186. package/lib/report/branding.js +19 -0
  187. package/lib/report/fonts.d.ts +2 -0
  188. package/lib/report/fonts.js +22 -0
  189. package/package.json +4 -3
  190. package/src/assets/fonts/dm-sans-italic-latin.woff2 +0 -0
  191. package/src/assets/fonts/dm-sans-normal-latin.woff2 +0 -0
  192. package/src/assets/fonts/dm-serif-display-italic-latin.woff2 +0 -0
  193. package/src/assets/fonts/dm-serif-display-normal-latin.woff2 +0 -0
  194. package/config/queries/soql.json +0 -24
  195. package/config/queries/tooling.json +0 -28
  196. package/config/scoring.json +0 -17
@@ -0,0 +1,106 @@
1
+ function ipToInt(ip) {
2
+ return ip.split('.').reduce((acc, octet) => (acc << 8) | parseInt(octet, 10), 0) >>> 0;
3
+ }
4
+ function rangeSize(start, end) {
5
+ return ipToInt(end) - ipToInt(start) + 1;
6
+ }
7
+ export class TrustedIPRangesCheck {
8
+ id = 'trusted-ip-ranges';
9
+ name = 'Trusted IP Ranges';
10
+ category = 'Authentication';
11
+ description = 'Identifies trusted IP ranges that completely bypass MFA, including overly broad ranges';
12
+ async run(ctx) {
13
+ const findings = [];
14
+ const baseUrl = ctx.orgInfo.instanceUrl;
15
+ const setupUrl = `${baseUrl}/lightning/setup/SecurityNetworkAccess/home`;
16
+ let ranges = [];
17
+ try {
18
+ const result = await ctx.soql.query(`SELECT Id, StartAddress, EndAddress, Description
19
+ FROM NetworkAccess
20
+ ORDER BY StartAddress
21
+ LIMIT 200`);
22
+ ranges = result.records;
23
+ }
24
+ catch {
25
+ findings.push({
26
+ id: 'trusted-ip-inaccessible',
27
+ category: this.category,
28
+ riskLevel: 'INFO',
29
+ inconclusive: true,
30
+ title: 'Trusted IP ranges could not be retrieved',
31
+ detail: 'The NetworkAccess object was not accessible. This may indicate insufficient permissions to query network access settings.',
32
+ remediation: 'Review trusted IP ranges manually in Setup → Security → Network Access. Ensure the audit user has "View Setup and Configuration" permission.',
33
+ affectedItems: [{ label: 'Network Access Setup', url: setupUrl }],
34
+ });
35
+ return { findings };
36
+ }
37
+ if (ranges.length === 0) {
38
+ findings.push({
39
+ id: 'trusted-ip-none',
40
+ category: this.category,
41
+ riskLevel: 'LOW',
42
+ passed: true,
43
+ title: 'No trusted IP ranges configured — MFA applies to all login locations',
44
+ detail: 'No NetworkAccess (trusted IP range) records are configured. All users are subject to MFA and login challenge enforcement regardless of their network location.',
45
+ remediation: 'Continue to avoid configuring trusted IP ranges unless there is a documented, justified business requirement with compensating controls.',
46
+ });
47
+ return { findings };
48
+ }
49
+ const broadRanges = ranges.filter((r) => {
50
+ try {
51
+ return rangeSize(r.StartAddress, r.EndAddress) > 65_536;
52
+ }
53
+ catch {
54
+ return false;
55
+ }
56
+ });
57
+ if (broadRanges.length > 0) {
58
+ findings.push({
59
+ id: 'trusted-ip-broad-ranges',
60
+ category: this.category,
61
+ riskLevel: 'HIGH',
62
+ title: `${broadRanges.length} trusted IP range(s) cover more than 65,536 hosts (broader than /16)`,
63
+ detail: 'Trusted IP ranges completely bypass Salesforce MFA — any user logging in from a trusted IP is not challenged for a second factor. Ranges broader than /16 cover entire enterprise network blocks or ISP ranges, creating an extremely large MFA bypass surface. If an attacker or insider gains access to any host within that range, they can log in without MFA.',
64
+ remediation: 'Narrow each trusted IP range to the minimum required set of specific host addresses or subnets. Remove overly broad ranges immediately. If broad ranges are required, document the business justification and ensure compensating controls (network-level MFA, VPN enforcement, EDR) are in place.',
65
+ affectedItems: broadRanges.map((r) => {
66
+ let size;
67
+ try {
68
+ size = rangeSize(r.StartAddress, r.EndAddress).toLocaleString();
69
+ }
70
+ catch {
71
+ size = 'unknown';
72
+ }
73
+ return {
74
+ label: `${r.StartAddress}–${r.EndAddress}`,
75
+ url: setupUrl,
76
+ note: `${r.Description ?? 'no description'} — ${size} hosts`,
77
+ };
78
+ }),
79
+ });
80
+ }
81
+ findings.push({
82
+ id: 'trusted-ip-exists',
83
+ category: this.category,
84
+ riskLevel: 'MEDIUM',
85
+ title: `${ranges.length} trusted IP range(s) configured — MFA is bypassed for logins from these addresses`,
86
+ detail: 'Trusted IP ranges in Salesforce completely bypass MFA enforcement. Any user authenticating from a listed IP address is not required to provide a second factor. Each range must have documented justification and be reviewed regularly. Without this review, ranges can accumulate and silently expand the MFA bypass surface over time.',
87
+ remediation: 'Review each trusted IP range and confirm it has a documented business justification. Remove any ranges that are no longer required or cannot be justified. Ensure compensating network controls (VPN with MFA, NAC, EDR) protect the trusted network segments.',
88
+ affectedItems: ranges.map((r) => {
89
+ let size;
90
+ try {
91
+ size = rangeSize(r.StartAddress, r.EndAddress).toLocaleString();
92
+ }
93
+ catch {
94
+ size = 'unknown';
95
+ }
96
+ return {
97
+ label: `${r.StartAddress}–${r.EndAddress}`,
98
+ url: setupUrl,
99
+ note: `${r.Description ?? 'no description'} — ${size} hosts`,
100
+ };
101
+ }),
102
+ });
103
+ return { findings };
104
+ }
105
+ }
106
+ //# sourceMappingURL=TrustedIPRangesCheck.js.map
@@ -14,10 +14,52 @@ export class UsersAndAdminsCheck {
14
14
  // Total active, non-frozen users
15
15
  const activeUsersResult = await ctx.soql.query('SELECT COUNT() FROM User WHERE IsActive = true AND Id NOT IN (SELECT UserId FROM UserLogin WHERE IsFrozen = true)');
16
16
  const totalActiveUsers = activeUsersResult.totalSize;
17
- // Modify All Data
18
- const modifyAllResult = await ctx.soql.query('SELECT Assignee.Id, Assignee.Username, Assignee.Name, Assignee.Profile.Name, PermissionSet.Name, PermissionSet.IsOwnedByProfile FROM PermissionSetAssignment WHERE PermissionSet.PermissionsModifyAllData = true AND Assignee.IsActive = true AND AssigneeId NOT IN (SELECT UserId FROM UserLogin WHERE IsFrozen = true)');
19
- const modifyAllUsers = modifyAllResult.records;
20
- const modifyAllCount = modifyAllUsers.length;
17
+ const broadPermResult = await ctx.soql.query(`SELECT Assignee.Id, Assignee.Username, Assignee.Name, Assignee.Profile.Name,
18
+ PermissionSet.Name, PermissionSet.IsOwnedByProfile,
19
+ PermissionSet.PermissionsModifyAllData, PermissionSet.PermissionsViewAllData,
20
+ PermissionSet.PermissionsManageUsers, PermissionSet.PermissionsCustomizeApplication,
21
+ PermissionSet.PermissionsAuthorApex
22
+ FROM PermissionSetAssignment
23
+ WHERE (PermissionSet.PermissionsModifyAllData = true
24
+ OR PermissionSet.PermissionsViewAllData = true
25
+ OR PermissionSet.PermissionsManageUsers = true
26
+ OR PermissionSet.PermissionsCustomizeApplication = true
27
+ OR PermissionSet.PermissionsAuthorApex = true)
28
+ AND Assignee.IsActive = true
29
+ AND AssigneeId NOT IN (SELECT UserId FROM UserLogin WHERE IsFrozen = true)`);
30
+ const broadPerms = broadPermResult.records;
31
+ // Group by permission — a user may appear multiple times (once per permission set granting them)
32
+ const modifyAllUsers = broadPerms.filter((r) => r.PermissionSet.PermissionsModifyAllData);
33
+ const viewAllUsers = broadPerms.filter((r) => r.PermissionSet.PermissionsViewAllData);
34
+ const manageUsersRows = broadPerms.filter((r) => r.PermissionSet.PermissionsManageUsers);
35
+ const customizeAppUsers = broadPerms.filter((r) => r.PermissionSet.PermissionsCustomizeApplication);
36
+ const authorApexUsers = broadPerms.filter((r) => r.PermissionSet.PermissionsAuthorApex);
37
+ // Deduplicate by Assignee.Id for counting unique users
38
+ const uniqueIds = (rows) => new Set(rows.map((r) => r.Assignee.Id));
39
+ const modifyAllIds = uniqueIds(modifyAllUsers);
40
+ const viewAllIds = uniqueIds(viewAllUsers);
41
+ const manageUsersIds = uniqueIds(manageUsersRows);
42
+ const modifyAllCount = modifyAllIds.size;
43
+ const viewAllCount = viewAllIds.size;
44
+ const customizeAppCount = uniqueIds(customizeAppUsers).size;
45
+ const authorApexCount = uniqueIds(authorApexUsers).size;
46
+ // SBS-ACS-004: flag users with ALL THREE super-admin permissions simultaneously
47
+ const superAdminIds = [...modifyAllIds].filter((id) => viewAllIds.has(id) && manageUsersIds.has(id));
48
+ if (superAdminIds.length > 0) {
49
+ const superAdminItems = superAdminIds.map((id) => {
50
+ const row = modifyAllUsers.find((r) => r.Assignee.Id === id);
51
+ return userItem(row);
52
+ });
53
+ findings.push({
54
+ id: 'users-super-admin-combo',
55
+ category: this.category,
56
+ riskLevel: 'CRITICAL',
57
+ title: `${superAdminIds.length} user(s) hold the super-admin permission combination (ViewAllData + ModifyAllData + ManageUsers)`,
58
+ detail: 'SBS-ACS-004 requires documented justification for any user holding all three of ViewAllData, ModifyAllData, and ManageUsers simultaneously. This combination is equivalent to unrestricted org control.',
59
+ remediation: 'Reduce to the minimum necessary permissions. Document justification for each user in the system of record. Consider breaking this into role-specific permission sets.',
60
+ affectedItems: superAdminItems,
61
+ });
62
+ }
21
63
  const modifyRisk = modifyAllCount > 5 ? 'CRITICAL' : modifyAllCount > 3 ? 'HIGH' : 'LOW';
22
64
  findings.push({
23
65
  id: 'users-modify-all-data',
@@ -26,12 +68,8 @@ export class UsersAndAdminsCheck {
26
68
  title: `${modifyAllCount} user(s) have Modify All Data permission`,
27
69
  detail: 'Modify All Data grants unrestricted write access across all objects. This is one of the most powerful permissions in Salesforce.',
28
70
  remediation: 'Limit Modify All Data to essential system administrators only. Review each user and remove the permission from any non-essential accounts.',
29
- affectedItems: modifyAllUsers.map(userItem),
71
+ affectedItems: modifyAllUsers.map((r) => userItem(r)),
30
72
  });
31
- // View All Data
32
- const viewAllResult = await ctx.soql.query('SELECT Assignee.Id, Assignee.Username, Assignee.Name, Assignee.Profile.Name, PermissionSet.Name, PermissionSet.IsOwnedByProfile FROM PermissionSetAssignment WHERE PermissionSet.PermissionsViewAllData = true AND Assignee.IsActive = true AND AssigneeId NOT IN (SELECT UserId FROM UserLogin WHERE IsFrozen = true)');
33
- const viewAllUsers = viewAllResult.records;
34
- const viewAllCount = viewAllUsers.length;
35
73
  const viewRisk = viewAllCount > 10 ? 'HIGH' : viewAllCount > 5 ? 'MEDIUM' : 'LOW';
36
74
  findings.push({
37
75
  id: 'users-view-all-data',
@@ -40,12 +78,8 @@ export class UsersAndAdminsCheck {
40
78
  title: `${viewAllCount} user(s) have View All Data permission`,
41
79
  detail: 'View All Data grants unrestricted read access across all objects, bypassing sharing rules and record-level security.',
42
80
  remediation: 'Limit View All Data to essential users. Consider using permission sets scoped to specific objects instead.',
43
- affectedItems: viewAllUsers.map(userItem),
81
+ affectedItems: viewAllUsers.map((r) => userItem(r)),
44
82
  });
45
- // Customize Application
46
- const customizeAppResult = await ctx.soql.query('SELECT Assignee.Id, Assignee.Username, Assignee.Profile.Name, PermissionSet.Name, PermissionSet.IsOwnedByProfile FROM PermissionSetAssignment WHERE PermissionSet.PermissionsCustomizeApplication = true AND Assignee.IsActive = true AND AssigneeId NOT IN (SELECT UserId FROM UserLogin WHERE IsFrozen = true)');
47
- const customizeAppUsers = customizeAppResult.records;
48
- const customizeAppCount = customizeAppUsers.length;
49
83
  if (customizeAppCount > 5) {
50
84
  findings.push({
51
85
  id: 'users-customize-application',
@@ -54,13 +88,9 @@ export class UsersAndAdminsCheck {
54
88
  title: `${customizeAppCount} user(s) have Customize Application permission`,
55
89
  detail: 'Customize Application allows users to make metadata changes, including modifying page layouts, custom fields, and application settings.',
56
90
  remediation: 'Customize Application allows metadata changes. Review and reduce to essential configuration administrators.',
57
- affectedItems: customizeAppUsers.map(userItem),
91
+ affectedItems: customizeAppUsers.map((r) => userItem(r)),
58
92
  });
59
93
  }
60
- // Author Apex
61
- const authorApexResult = await ctx.soql.query('SELECT Assignee.Id, Assignee.Username, Assignee.Profile.Name, PermissionSet.Name, PermissionSet.IsOwnedByProfile FROM PermissionSetAssignment WHERE PermissionSet.PermissionsAuthorApex = true AND Assignee.IsActive = true AND AssigneeId NOT IN (SELECT UserId FROM UserLogin WHERE IsFrozen = true)');
62
- const authorApexUsers = authorApexResult.records;
63
- const authorApexCount = authorApexUsers.length;
64
94
  if (authorApexCount > 3) {
65
95
  findings.push({
66
96
  id: 'users-author-apex',
@@ -69,7 +99,7 @@ export class UsersAndAdminsCheck {
69
99
  title: `${authorApexCount} user(s) have Author Apex permission`,
70
100
  detail: 'Author Apex allows users to write and deploy Apex code, which can execute server-side logic with elevated privileges.',
71
101
  remediation: 'Author Apex allows code deployment. Limit to developers with a genuine need.',
72
- affectedItems: authorApexUsers.map(userItem),
102
+ affectedItems: authorApexUsers.map((r) => userItem(r)),
73
103
  });
74
104
  }
75
105
  return {
@@ -0,0 +1,11 @@
1
+ import type { AuditContext } from '../../context/AuditContext.js';
2
+ import type { SecurityCheck, CheckResult } from '../SecurityCheck.js';
3
+ export declare class VisualforceXssCheck implements SecurityCheck {
4
+ readonly id = "visualforce-xss";
5
+ readonly name = "Visualforce XSS Patterns";
6
+ readonly category = "Code Security";
7
+ readonly description = "Scans Visualforce page markup for common XSS patterns: escape=\"false\", unencoded merge fields in script blocks and HTML attributes";
8
+ readonly populatesCache: readonly ["vfPageBodies"];
9
+ run(ctx: AuditContext): Promise<CheckResult>;
10
+ }
11
+ //# sourceMappingURL=VisualforceXssCheck.d.ts.map
@@ -0,0 +1,150 @@
1
+ // Unescaped output in <apex:outputText> or <apex:outputField>
2
+ // escape="false" bypasses Salesforce's automatic HTML encoding
3
+ const ESCAPE_FALSE_RE = /escape\s*=\s*["']false["']/i;
4
+ // {!variable} merge fields inside <script> blocks are not HTML-encoded — they need JSENCODE/JSINHTMLENCODE
5
+ // This regex approximates: a script tag that contains a {!...} not wrapped in JSENCODE/JSINHTMLENCODE
6
+ const JS_UNENCODED_MERGE_RE = /<script[^>]*>[\s\S]*?\{!(?!JSENCODE\(|JSINHTMLENCODE\()[^}]+\}[\s\S]*?<\/script>/gi;
7
+ // href/src/action attributes with unencoded merge fields — potential open redirect or injection
8
+ const ATTR_MERGE_UNENCODED_RE = /(?:href|src|action|onclick)\s*=\s*["'][^"']*\{!(?!HTMLENCODE\(|JSENCODE\(|URLENCODE\()[^}]+\}/gi;
9
+ export class VisualforceXssCheck {
10
+ id = 'visualforce-xss';
11
+ name = 'Visualforce XSS Patterns';
12
+ category = 'Code Security';
13
+ description = 'Scans Visualforce page markup for common XSS patterns: escape="false", unencoded merge fields in script blocks and HTML attributes';
14
+ populatesCache = ['vfPageBodies'];
15
+ async run(ctx) {
16
+ const findings = [];
17
+ const baseUrl = ctx.orgInfo.instanceUrl;
18
+ const setupUrl = `${baseUrl}/lightning/setup/ApexPages/home`;
19
+ // Query 1: COUNT to detect truncation before fetching markup
20
+ let totalPageCount = 0;
21
+ try {
22
+ const countResult = await ctx.soql.query(`SELECT COUNT() FROM ApexPage WHERE NamespacePrefix = null`);
23
+ totalPageCount = countResult.totalSize;
24
+ }
25
+ catch {
26
+ // COUNT unavailable — proceed with markup query and detect truncation empirically
27
+ }
28
+ let pages;
29
+ try {
30
+ // Query 2: fetch markup (Tooling API only — regular SOQL does not expose Markup)
31
+ pages = await ctx.tooling.query(`SELECT Name, Markup FROM ApexPage WHERE NamespacePrefix = null LIMIT 500`);
32
+ }
33
+ catch {
34
+ ctx.cache.vfPageBodies = [];
35
+ findings.push({
36
+ id: 'visualforce-xss-inaccessible',
37
+ category: this.category,
38
+ riskLevel: 'INFO',
39
+ inconclusive: true,
40
+ title: 'Visualforce page markup could not be accessed — XSS check skipped',
41
+ detail: 'The Tooling API ApexPage query was not accessible. This may indicate the audit user lacks Tooling API access.',
42
+ remediation: 'Grant Tooling API access to the audit user and re-run.',
43
+ });
44
+ return { findings };
45
+ }
46
+ const effectiveTotal = totalPageCount > 0 ? totalPageCount : pages.length;
47
+ if (effectiveTotal > 500) {
48
+ findings.push({
49
+ id: 'visualforce-xss-incomplete-scan',
50
+ category: this.category,
51
+ riskLevel: 'INFO',
52
+ inconclusive: true,
53
+ title: `Visualforce XSS scan incomplete — only ${pages.length} of ${effectiveTotal} pages scanned (API LIMIT 500)`,
54
+ detail: `This org has ${effectiveTotal} Visualforce pages, but the Tooling API imposes a hard LIMIT of 500 rows per query. The remaining ${effectiveTotal - pages.length} pages were not analysed for XSS patterns. Findings below reflect only the scanned subset and may understate the true exposure.`,
55
+ remediation: 'Use the Salesforce CLI (sf apex list page) or a dedicated SAST tool (PMD, CodeScan) to perform a complete scan of all Visualforce pages outside the 500-row API limit.',
56
+ });
57
+ }
58
+ // Cache page markup for potential future checks
59
+ ctx.cache.vfPageBodies = pages.map((p) => ({ name: p.Name, markup: p.Markup ?? '' }));
60
+ if (pages.length === 0) {
61
+ findings.push({
62
+ id: 'visualforce-xss-no-pages',
63
+ category: this.category,
64
+ riskLevel: 'LOW',
65
+ passed: true,
66
+ title: 'No custom Visualforce pages found',
67
+ detail: 'No Visualforce pages in the org namespace were found.',
68
+ remediation: 'Continue monitoring as new pages are added.',
69
+ });
70
+ return { findings };
71
+ }
72
+ const escapeFalsePages = [];
73
+ const jsUncodedPages = [];
74
+ const attrUncodedPages = [];
75
+ for (const { Name, Markup } of pages) {
76
+ if (!Markup)
77
+ continue;
78
+ if (ESCAPE_FALSE_RE.test(Markup))
79
+ escapeFalsePages.push(Name);
80
+ JS_UNENCODED_MERGE_RE.lastIndex = 0;
81
+ if (JS_UNENCODED_MERGE_RE.test(Markup))
82
+ jsUncodedPages.push(Name);
83
+ ATTR_MERGE_UNENCODED_RE.lastIndex = 0;
84
+ if (ATTR_MERGE_UNENCODED_RE.test(Markup))
85
+ attrUncodedPages.push(Name);
86
+ }
87
+ let hasFindings = false;
88
+ if (escapeFalsePages.length > 0) {
89
+ hasFindings = true;
90
+ findings.push({
91
+ id: 'visualforce-xss-escape-false',
92
+ category: this.category,
93
+ riskLevel: 'HIGH',
94
+ title: `${escapeFalsePages.length} Visualforce page(s) use escape="false" — XSS risk`,
95
+ detail: `\`escape="false"\` on \`<apex:outputText>\` or similar components disables Salesforce's automatic HTML encoding. If the rendered value contains user-controlled content, an attacker can inject arbitrary JavaScript into the page, leading to stored or reflected XSS. Salesforce defaults to \`escape="true"\` specifically to prevent this.`,
96
+ remediation: 'Remove `escape="false"` unless the value being rendered is fully trusted (e.g., hardcoded HTML from a developer). For user-controlled content, ensure it is sanitised before storage and rely on the default escaping. Replace with HTMLENCODE() if explicit encoding is needed.',
97
+ affectedItems: escapeFalsePages.map((name) => ({
98
+ label: name,
99
+ url: setupUrl,
100
+ note: 'escape="false" found — review all output components for user-controlled content',
101
+ })),
102
+ });
103
+ }
104
+ if (jsUncodedPages.length > 0) {
105
+ hasFindings = true;
106
+ findings.push({
107
+ id: 'visualforce-xss-js-merge-field',
108
+ category: this.category,
109
+ riskLevel: 'HIGH',
110
+ title: `${jsUncodedPages.length} Visualforce page(s) use merge fields inside <script> blocks without JSENCODE`,
111
+ detail: `Merge fields used inside \`<script>\` tags must be wrapped with \`{!JSENCODE(variable)}\` or \`{!JSINHTMLENCODE(variable)}\`. Without encoding, an attacker who controls the value can break out of the JavaScript string context and execute arbitrary code. HTML-encoding alone (the default in VF) does NOT prevent JavaScript injection.`,
112
+ remediation: 'Wrap all merge fields inside `<script>` blocks with JSENCODE(): `{!JSENCODE(variable)}`. For values placed in HTML event handlers (onclick, etc.), use JSINHTMLENCODE().',
113
+ affectedItems: jsUncodedPages.map((name) => ({
114
+ label: name,
115
+ url: setupUrl,
116
+ note: '{!var} in <script> block without JSENCODE — wrap with {!JSENCODE(var)}',
117
+ })),
118
+ });
119
+ }
120
+ if (attrUncodedPages.length > 0) {
121
+ hasFindings = true;
122
+ findings.push({
123
+ id: 'visualforce-xss-attr-merge-field',
124
+ category: this.category,
125
+ riskLevel: 'MEDIUM',
126
+ title: `${attrUncodedPages.length} Visualforce page(s) use merge fields in href/src/action attributes without encoding`,
127
+ detail: `Merge fields in URL-context HTML attributes (href, src, action) without URLENCODE() or HTMLENCODE() can enable open redirects or attribute injection. An attacker may be able to manipulate the URL or inject additional attributes.`,
128
+ remediation: 'Wrap merge fields used in URL attributes with URLENCODE() for URL values, or HTMLENCODE() for full attribute values. Validate that URL values cannot redirect to external untrusted hosts.',
129
+ affectedItems: attrUncodedPages.map((name) => ({
130
+ label: name,
131
+ url: setupUrl,
132
+ note: '{!var} in href/src/action without URLENCODE — encode or validate',
133
+ })),
134
+ });
135
+ }
136
+ if (!hasFindings) {
137
+ findings.push({
138
+ id: 'visualforce-xss-ok',
139
+ category: this.category,
140
+ riskLevel: 'LOW',
141
+ passed: true,
142
+ title: `All ${pages.length} Visualforce page(s) passed XSS pattern scan`,
143
+ detail: `No common XSS patterns (escape="false", unencoded merge fields in script blocks or URL attributes) were found in the ${pages.length} custom Visualforce pages scanned.`,
144
+ remediation: 'Continue monitoring as new pages are developed. Consider adding a static analysis step to your CI/CD pipeline for ongoing VF XSS detection.',
145
+ });
146
+ }
147
+ return { findings };
148
+ }
149
+ }
150
+ //# sourceMappingURL=VisualforceXssCheck.js.map
@@ -11,6 +11,7 @@ import { PasswordSessionPolicyCheck } from './impl/PasswordSessionPolicyCheck.js
11
11
  import { IpRestrictionsCheck } from './impl/IpRestrictionsCheck.js';
12
12
  import { GuestUserAccessCheck } from './impl/GuestUserAccessCheck.js';
13
13
  import { RemoteSitesCheck } from './impl/RemoteSitesCheck.js';
14
+ import { CspTrustedSitesCheck } from './impl/CspTrustedSitesCheck.js';
14
15
  import { NamedCredentialsCheck } from './impl/NamedCredentialsCheck.js';
15
16
  import { HardcodedCredentialsCheck } from './impl/HardcodedCredentialsCheck.js';
16
17
  import { ApexSharingCheck } from './impl/ApexSharingCheck.js';
@@ -20,30 +21,114 @@ import { FieldLevelSecurityCheck } from './impl/FieldLevelSecurityCheck.js';
20
21
  import { ScheduledApexCheck } from './impl/ScheduledApexCheck.js';
21
22
  import { CodeSecurityCheck } from './impl/CodeSecurityCheck.js';
22
23
  import { CustomSettingsCheck } from './impl/CustomSettingsCheck.js';
24
+ // Net-new SBS checks
25
+ import { StandardProfilesCheck } from './impl/StandardProfilesCheck.js';
26
+ import { SsoEnforcementCheck } from './impl/SsoEnforcementCheck.js';
27
+ import { MfaEnforcementCheck } from './impl/MfaEnforcementCheck.js';
28
+ import { ApiClientPermissionCheck } from './impl/ApiClientPermissionCheck.js';
29
+ import { IntegrationUsersCheck } from './impl/IntegrationUsersCheck.js';
30
+ import { ContentLinksCheck } from './impl/ContentLinksCheck.js';
31
+ import { FieldHistoryTrackingCheck } from './impl/FieldHistoryTrackingCheck.js';
32
+ import { DataClassificationCheck } from './impl/DataClassificationCheck.js';
33
+ import { DeploymentIdentityCheck } from './impl/DeploymentIdentityCheck.js';
34
+ import { ApexLoggingCheck } from './impl/ApexLoggingCheck.js';
35
+ import { EventMonitoringCheck } from './impl/EventMonitoringCheck.js';
36
+ import { SiemIntegrationCheck } from './impl/SiemIntegrationCheck.js';
37
+ // Additional security checks + recent Salesforce security improvements
38
+ import { ApexCrudFLSCheck } from './impl/ApexCrudFLSCheck.js';
39
+ import { ApexRestEndpointCheck } from './impl/ApexRestEndpointCheck.js';
40
+ import { VisualforceXssCheck } from './impl/VisualforceXssCheck.js';
41
+ import { CertificateExpiryCheck } from './impl/CertificateExpiryCheck.js';
42
+ import { InstalledPackagesCheck } from './impl/InstalledPackagesCheck.js';
43
+ import { TrustedIPRangesCheck } from './impl/TrustedIPRangesCheck.js';
44
+ import { AnonymousApexAuditCheck } from './impl/AnonymousApexAuditCheck.js';
45
+ import { DebugLogAccessCheck } from './impl/DebugLogAccessCheck.js';
46
+ import { ConnectedAppInactivityCheck } from './impl/ConnectedAppInactivityCheck.js';
47
+ import { MyDomainLoginPolicyCheck } from './impl/MyDomainLoginPolicyCheck.js';
48
+ import { InternalUserMfaCheck } from './impl/InternalUserMfaCheck.js';
49
+ import { MfaRegistrationCheck } from './impl/MfaRegistrationCheck.js';
50
+ import { MfaMethodStrengthCheck } from './impl/MfaMethodStrengthCheck.js';
51
+ import { HighAssuranceSessionCheck } from './impl/HighAssuranceSessionCheck.js';
52
+ import { EnhancedDomainsCheck } from './impl/EnhancedDomainsCheck.js';
53
+ import { ReleaseUpdatesCheck } from './impl/ReleaseUpdatesCheck.js';
54
+ import { LegacyApiVersionCheck } from './impl/LegacyApiVersionCheck.js';
55
+ import { ConnectedAppScopeCheck } from './impl/ConnectedAppScopeCheck.js';
56
+ import { TransactionSecurityPolicyCheck } from './impl/TransactionSecurityPolicyCheck.js';
57
+ import { FailedLoginCheck } from './impl/FailedLoginCheck.js';
58
+ import { ExperienceCloudSiteCheck } from './impl/ExperienceCloudSiteCheck.js';
59
+ import { CustomLabelsCredentialCheck } from './impl/CustomLabelsCredentialCheck.js';
60
+ import { ReportFolderAccessCheck } from './impl/ReportFolderAccessCheck.js';
61
+ // Attack-chain ingredient checks
62
+ import { EscalationPermsCheck } from './impl/EscalationPermsCheck.js';
63
+ import { CorsAllowlistCheck } from './impl/CorsAllowlistCheck.js';
64
+ import { GuestExecutableApexCheck } from './impl/GuestExecutableApexCheck.js';
23
65
  // Order matters: a check's dependsOnCache must be satisfied by a preceding check's populatesCache.
24
66
  // CheckEngine.validateCacheOrdering() enforces this at startup.
25
67
  export const CHECKS = [
26
68
  new HealthCheckCheck(), // writes: healthCheckRisks, healthCloudInstalled
27
- new UsersAndAdminsCheck(), // writes: metrics (totalActiveUsers, etc.)
28
- new PermissionsCheck(), // writes: metrics (permissionSetCount, profileCount)
29
- new LoginSessionCheck(), // writes: metrics (failedLogins30d)
30
- new ConnectedAppsCheck(), // writes: metrics (connectedAppsCount)
31
- new SharingModelCheck(), // no deps, no cache
32
- new ApiLimitsCheck(), // no deps, no cache
33
- new AuditTrailCheck(), // no deps, no cache
34
- new InactiveUsersCheck(), // writes: metrics (inactiveUsers90d)
35
- new PasswordSessionPolicyCheck(), // reads: healthCheckRisks (from HealthCheckCheck)
36
- new IpRestrictionsCheck(), // no cache deps
69
+ new UsersAndAdminsCheck(), // no cache deps
70
+ new PermissionsCheck(), // no cache deps
71
+ new LoginSessionCheck(), // no cache deps
72
+ new ConnectedAppsCheck(), // writes: connectedAppNames
73
+ new SharingModelCheck(), // no deps
74
+ new ApiLimitsCheck(), // no deps
75
+ new AuditTrailCheck(), // no deps
76
+ new InactiveUsersCheck(), // no deps
77
+ new PasswordSessionPolicyCheck(), // reads: healthCheckRisks
78
+ new IpRestrictionsCheck(), // no deps
37
79
  new GuestUserAccessCheck(), // reads: healthCloudInstalled
38
80
  new RemoteSitesCheck(), // writes: remoteSiteUrls
81
+ new CspTrustedSitesCheck(), // no deps
39
82
  new NamedCredentialsCheck(), // writes: namedCredentialEndpoints
40
83
  new HardcodedCredentialsCheck(), // reads: namedCredentialEndpoints, remoteSiteUrls; writes: apexBodies
41
84
  new ApexSharingCheck(), // reads: apexBodies
42
85
  new FlowsWithoutSharingCheck(), // no deps
43
86
  new PublicGroupSharingCheck(), // reads: healthCloudInstalled
44
87
  new FieldLevelSecurityCheck(), // no deps
45
- new ScheduledApexCheck(), // no deps
46
- new CodeSecurityCheck(), // writes: metrics (apexClassCount, etc.)
88
+ new ScheduledApexCheck(), // writes: scheduledApexClassNames
89
+ new CodeSecurityCheck(), // reads: apexBodies
47
90
  new CustomSettingsCheck(), // no deps
91
+ // SBS gap checks — no cache deps
92
+ new StandardProfilesCheck(), // SBS-ACS-005
93
+ new SsoEnforcementCheck(), // SBS-AUTH-001/002
94
+ new MfaEnforcementCheck(), // SBS-AUTH-004 (portal users)
95
+ new ApiClientPermissionCheck(), // SBS-ACS-006
96
+ new IntegrationUsersCheck(), // SBS-ACS-007/008/009
97
+ new ContentLinksCheck(), // SBS-FILE-001/002/003
98
+ new FieldHistoryTrackingCheck(), // SBS-DATA-004
99
+ new DataClassificationCheck(), // SBS-DATA-001/002/003
100
+ // Additional security checks — no cache deps
101
+ new CertificateExpiryCheck(), // cert store expiry
102
+ new InstalledPackagesCheck(), // managed/unmanaged package inventory
103
+ new TrustedIPRangesCheck(), // MFA-bypass IP ranges
104
+ new AnonymousApexAuditCheck(), // anonymous Apex in production
105
+ new DebugLogAccessCheck(), // active debug traces
106
+ new MyDomainLoginPolicyCheck(), // My Domain + AuthConfig SSO enforcement
107
+ new HighAssuranceSessionCheck(), // connected app session timeout policies
108
+ new EnhancedDomainsCheck(), // Enhanced Domains URL isolation
109
+ new InternalUserMfaCheck(), // MFA for all internal standard users
110
+ new ReleaseUpdatesCheck(), // pending Salesforce release updates
111
+ new LegacyApiVersionCheck(), // old Apex API versions + SOAP remote sites
112
+ new ConnectedAppScopeCheck(), // OAuth scopes + refresh token policy
113
+ new TransactionSecurityPolicyCheck(), // automated threat detection policies
114
+ new FailedLoginCheck(), // brute-force / credential stuffing detection
115
+ new ExperienceCloudSiteCheck(), // self-registration + guest access on live sites
116
+ new CustomLabelsCredentialCheck(), // credentials stored in globally-readable labels
117
+ new ReportFolderAccessCheck(), // public report folders — mass data exfiltration risk
118
+ new EscalationPermsCheck(), // priv-esc permission cluster (chain ingredient)
119
+ new CorsAllowlistCheck(), // wildcard/broad CORS origins (chain ingredient)
120
+ // Cache-dependent checks — must come after their producers
121
+ new DeploymentIdentityCheck(), // reads connectedAppNames
122
+ new ApexLoggingCheck(), // reads apexBodies + scheduledApexClassNames
123
+ new ConnectedAppInactivityCheck(), // reads connectedAppNames
124
+ new ApexCrudFLSCheck(), // reads apexBodies
125
+ new GuestExecutableApexCheck(), // reads apexBodies — guest-reachable Apex sharing
126
+ new ApexRestEndpointCheck(), // reads apexBodies
127
+ new VisualforceXssCheck(), // writes vfPageBodies
128
+ new EventMonitoringCheck(), // writes eventLogSummary
129
+ new MfaRegistrationCheck(), // writes mfaRegistrations
130
+ new SiemIntegrationCheck(), // reads namedCredentialEndpoints, remoteSiteUrls,
131
+ // connectedAppNames, scheduledApexClassNames, eventLogSummary
132
+ new MfaMethodStrengthCheck(), // reads mfaRegistrations
48
133
  ];
49
134
  //# sourceMappingURL=registry.js.map
@@ -0,0 +1,17 @@
1
+ import { SfCommand } from '@salesforce/sf-plugins-core';
2
+ import type { AuditDiff } from '../../history/AuditDiff.js';
3
+ export default class AuditDiffCommand extends SfCommand<AuditDiff> {
4
+ static summary: string;
5
+ static description: string;
6
+ static examples: string[];
7
+ static args: {
8
+ baseline: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
9
+ current: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
10
+ };
11
+ static flags: {
12
+ output: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
13
+ format: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
14
+ };
15
+ run(): Promise<AuditDiff>;
16
+ }
17
+ //# sourceMappingURL=diff.d.ts.map
@@ -0,0 +1,76 @@
1
+ // src/commands/audit/diff.ts
2
+ import * as fs from 'node:fs';
3
+ import * as path from 'node:path';
4
+ import { Args } from '@oclif/core';
5
+ import { SfCommand, Flags } from '@salesforce/sf-plugins-core';
6
+ import { HistoryStore } from '../../history/HistoryStore.js';
7
+ import { computeDiff } from '../../history/DiffEngine.js';
8
+ import { DiffHtmlRenderer } from '../../renderers/DiffHtmlRenderer.js';
9
+ import { DiffJsonRenderer } from '../../renderers/DiffJsonRenderer.js';
10
+ const DIFF_RENDERERS = {
11
+ html: new DiffHtmlRenderer(),
12
+ json: new DiffJsonRenderer(),
13
+ };
14
+ export default class AuditDiffCommand extends SfCommand {
15
+ static summary = 'Compare two audit report JSON files and show what changed';
16
+ static description = 'Loads two audit report JSON files, computes the diff, and writes HTML and/or JSON diff reports.';
17
+ static examples = [
18
+ '<%= config.bin %> <%= command.id %> baseline.json current.json',
19
+ '<%= config.bin %> <%= command.id %> baseline.json current.json --output ./reports --format html',
20
+ ];
21
+ static args = {
22
+ baseline: Args.string({ required: true, description: 'Path to the baseline (older) audit JSON report' }),
23
+ current: Args.string({ required: true, description: 'Path to the current (newer) audit JSON report' }),
24
+ };
25
+ static flags = {
26
+ output: Flags.string({
27
+ char: 'o',
28
+ summary: 'Directory to write diff reports. Defaults to current directory.',
29
+ default: '.',
30
+ }),
31
+ format: Flags.string({
32
+ char: 'f',
33
+ summary: 'Output format(s), comma-separated: html, json',
34
+ default: 'html,json',
35
+ }),
36
+ };
37
+ async run() {
38
+ const { args, flags } = await this.parse(AuditDiffCommand);
39
+ const store = new HistoryStore();
40
+ const baseline = store.load(args['baseline']);
41
+ const current = store.load(args['current']);
42
+ if (baseline.orgId !== current.orgId) {
43
+ this.warn(`Org IDs differ: baseline=${baseline.orgId}, current=${current.orgId}. Continuing anyway.`);
44
+ }
45
+ const diff = computeDiff(baseline, current);
46
+ const formats = flags.format.split(',').map((f) => f.trim());
47
+ const baseTs = baseline.generatedAt.getTime();
48
+ const curTs = current.generatedAt.getTime();
49
+ fs.mkdirSync(flags.output, { recursive: true });
50
+ for (const format of formats) {
51
+ const renderer = DIFF_RENDERERS[format];
52
+ if (!renderer) {
53
+ this.warn(`Unknown format '${format}' — skipping. Valid formats: html, json`);
54
+ continue;
55
+ }
56
+ const filename = `sf-audit-diff-${baseline.orgId}-${baseTs}-vs-${curTs}${renderer.fileExtension}`;
57
+ const outputPath = path.join(flags.output, filename);
58
+ fs.writeFileSync(outputPath, renderer.render(diff), 'utf-8');
59
+ this.log(`Diff report written: ${outputPath}`);
60
+ }
61
+ const scoreDeltaStr = diff.scoreDelta >= 0 ? `+${diff.scoreDelta}` : `${diff.scoreDelta}`;
62
+ const newCount = diff.findingChanges.filter((c) => c.type === 'new').length;
63
+ const resolvedCount = diff.findingChanges.filter((c) => c.type === 'resolved').length;
64
+ this.log('');
65
+ this.log('─────────────────────────────');
66
+ this.log(' Diff Summary');
67
+ this.log('─────────────────────────────');
68
+ this.log(` Score delta ${scoreDeltaStr.padStart(6)}`);
69
+ this.log(` Grade ${diff.gradeDelta}`);
70
+ this.log(` New ${String(newCount).padStart(6)}`);
71
+ this.log(` Resolved ${String(resolvedCount).padStart(6)}`);
72
+ this.log('─────────────────────────────');
73
+ return diff;
74
+ }
75
+ }
76
+ //# sourceMappingURL=diff.js.map
@@ -0,0 +1,15 @@
1
+ import { SfCommand } from '@salesforce/sf-plugins-core';
2
+ import type { AuditResult } from '../../findings/AuditResult.js';
3
+ export default class AuditHistoryCommand extends SfCommand<AuditResult[]> {
4
+ static summary: string;
5
+ static description: string;
6
+ static examples: string[];
7
+ static flags: {
8
+ 'target-org': import("@oclif/core/interfaces").OptionFlag<import("@salesforce/core").Org, import("@oclif/core/interfaces").CustomOptions>;
9
+ 'reports-dir': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
10
+ output: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
11
+ limit: import("@oclif/core/interfaces").OptionFlag<number | undefined, import("@oclif/core/interfaces").CustomOptions>;
12
+ };
13
+ run(): Promise<AuditResult[]>;
14
+ }
15
+ //# sourceMappingURL=history.d.ts.map