@cclabsnz/sf-audit 0.2.4 → 1.0.1

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.
@@ -54,6 +54,7 @@ export class ApiLimitsCheck {
54
54
  id: 'api-limits-healthy',
55
55
  category: this.category,
56
56
  riskLevel: 'LOW',
57
+ passed: true,
57
58
  title: 'All monitored API limits are within acceptable thresholds',
58
59
  detail: 'All monitored API and resource limits are below 50% utilization.',
59
60
  remediation: 'Continue monitoring limits as org activity grows.',
@@ -32,6 +32,7 @@ export class ConnectedAppsCheck {
32
32
  id: 'restricted-connected-apps',
33
33
  category: this.category,
34
34
  riskLevel: 'LOW',
35
+ passed: true,
35
36
  title: 'All connected apps restrict user access appropriately',
36
37
  detail: `All ${count} connected app(s) are configured to require admin pre-authorization.`,
37
38
  remediation: 'Continue monitoring as new connected apps are added.',
@@ -48,6 +48,7 @@ export class CustomSettingsCheck {
48
48
  id: 'custom-settings-clean',
49
49
  category: this.category,
50
50
  riskLevel: 'LOW',
51
+ passed: true,
51
52
  title: 'No obviously credential-related custom objects detected',
52
53
  detail: 'No custom objects with credential-related naming patterns were found.',
53
54
  remediation: 'Continue to avoid storing secrets in custom objects or custom settings. Use Named Credentials for external authentication.',
@@ -33,6 +33,7 @@ export class FieldLevelSecurityCheck {
33
33
  id: 'field-level-security-ok',
34
34
  category: this.category,
35
35
  riskLevel: 'LOW',
36
+ passed: true,
36
37
  title: 'Sensitive custom fields appear appropriately restricted',
37
38
  detail: 'No sensitive custom fields with excessive permission set access were found.',
38
39
  remediation: 'Continue to apply restrictive field-level security to any new sensitive fields.',
@@ -65,6 +66,7 @@ export class FieldLevelSecurityCheck {
65
66
  id: 'field-level-security-ok',
66
67
  category: this.category,
67
68
  riskLevel: 'LOW',
69
+ passed: true,
68
70
  title: 'Sensitive custom fields appear appropriately restricted',
69
71
  detail: 'No sensitive custom fields with excessive permission set access were found.',
70
72
  remediation: 'Continue to apply restrictive field-level security to any new sensitive fields.',
@@ -89,6 +91,7 @@ export class FieldLevelSecurityCheck {
89
91
  id: 'field-level-security-ok',
90
92
  category: this.category,
91
93
  riskLevel: 'LOW',
94
+ passed: true,
92
95
  title: 'Sensitive custom fields appear appropriately restricted',
93
96
  detail: 'No sensitive custom fields with excessive permission set access were found.',
94
97
  remediation: 'Continue to apply restrictive field-level security to any new sensitive fields.',
@@ -138,6 +141,7 @@ export class FieldLevelSecurityCheck {
138
141
  id: 'field-level-security-ok',
139
142
  category: this.category,
140
143
  riskLevel: 'LOW',
144
+ passed: true,
141
145
  title: 'Sensitive custom fields appear appropriately restricted',
142
146
  detail: 'No sensitive custom fields with excessive permission set access were found.',
143
147
  remediation: 'Continue to apply restrictive field-level security to any new sensitive fields.',
@@ -49,6 +49,7 @@ export class FlowsWithoutSharingCheck {
49
49
  id: 'flows-without-sharing-none',
50
50
  category: this.category,
51
51
  riskLevel: 'LOW',
52
+ passed: true,
52
53
  title: 'No active flows running without sharing context identified',
53
54
  detail: `All ${total} active flows either enforce user sharing context or are not autolaunched/screen flow types.`,
54
55
  remediation: 'Continue to review flow settings when new flows are activated.',
@@ -16,6 +16,7 @@ export class GuestUserAccessCheck {
16
16
  id: 'guest-user-none',
17
17
  category: this.category,
18
18
  riskLevel: 'LOW',
19
+ passed: true,
19
20
  title: 'No active guest users found',
20
21
  detail: 'There are no active guest users in this org, so guest user security misconfiguration is not a concern.',
21
22
  remediation: 'If an Experience Cloud site is added in the future, ensure guest user permissions are properly restricted.',
@@ -135,6 +135,7 @@ export class HardcodedCredentialsCheck {
135
135
  id: 'no-hardcoded-credentials',
136
136
  category: this.category,
137
137
  riskLevel: 'LOW',
138
+ passed: true,
138
139
  title: 'No hardcoded credentials or unprotected endpoints detected in Apex classes',
139
140
  detail: `Scanned ${total} custom Apex classes. No obvious hardcoded credential patterns or unprotected callout endpoints were found.`,
140
141
  remediation: 'Continue using Named Credentials for all external callouts and periodically re-scan as new code is added.',
@@ -83,6 +83,7 @@ export class IpRestrictionsCheck {
83
83
  id: 'ip-restrictions-ok',
84
84
  category: this.category,
85
85
  riskLevel: 'LOW',
86
+ passed: true,
86
87
  title: 'Login IP restrictions appear appropriately configured',
87
88
  detail: 'All checked admin profiles have login IP ranges configured and no connected apps bypass IP enforcement.',
88
89
  remediation: 'Periodically review IP restriction configuration as new admins and connected apps are added.',
@@ -89,6 +89,7 @@ export class PasswordSessionPolicyCheck {
89
89
  id: 'password-session-policy-compliant',
90
90
  category: this.category,
91
91
  riskLevel: 'LOW',
92
+ passed: true,
92
93
  title: 'Password and session policies appear compliant with security recommendations',
93
94
  detail: 'No password, session, or MFA-related deviations were detected in the Security Health Check results.',
94
95
  remediation: 'Continue monitoring password policies and MFA enforcement as Salesforce releases new security recommendations.',
@@ -15,6 +15,7 @@ export class PublicGroupSharingCheck {
15
15
  id: 'public-group-sharing-none',
16
16
  category: this.category,
17
17
  riskLevel: 'LOW',
18
+ passed: true,
18
19
  title: 'No records shared to All Internal Users groups via sharing rules',
19
20
  detail: 'No sharing rules were found targeting the "All Internal Users" group on key objects.',
20
21
  remediation: 'Continue to avoid broad sharing rules. Periodically review sharing configuration as the org grows.',
@@ -57,6 +58,7 @@ export class PublicGroupSharingCheck {
57
58
  id: 'public-group-sharing-none',
58
59
  category: this.category,
59
60
  riskLevel: 'LOW',
61
+ passed: true,
60
62
  title: 'No records shared to All Internal Users groups via sharing rules',
61
63
  detail: 'No sharing rules were found targeting the "All Internal Users" group on key objects.',
62
64
  remediation: 'Continue to avoid broad sharing rules. Periodically review sharing configuration as the org grows.',
@@ -37,6 +37,7 @@ export class RemoteSitesCheck {
37
37
  id: 'remote-sites-inventory',
38
38
  category: this.category,
39
39
  riskLevel: insecureSites.length === 0 ? 'LOW' : 'INFO',
40
+ passed: insecureSites.length === 0 ? true : undefined,
40
41
  title: `${count} active remote site setting(s) registered (${insecureSites.length} insecure, ${secureSites.length} secure)`,
41
42
  detail: 'Remote Site Settings control which external URLs Apex code can call. Entries should be reviewed periodically to remove unused entries.',
42
43
  remediation: 'Audit each remote site setting to confirm it is still actively used. Remove unused entries to reduce the attack surface.',
@@ -52,6 +53,7 @@ export class RemoteSitesCheck {
52
53
  id: 'no-remote-sites',
53
54
  category: this.category,
54
55
  riskLevel: 'LOW',
56
+ passed: true,
55
57
  title: 'No active remote site settings found',
56
58
  detail: 'No active Remote Site Settings are registered in this org.',
57
59
  remediation: 'This is expected if the org does not make outbound callouts. Monitor as integrations are added.',
@@ -50,6 +50,7 @@ export class SharingModelCheck {
50
50
  id: 'sharing-model-secure',
51
51
  category: this.category,
52
52
  riskLevel: 'LOW',
53
+ passed: true,
53
54
  title: 'No objects have Public Read/Write org-wide defaults',
54
55
  detail: 'All checked standard objects have appropriately restrictive org-wide default sharing settings.',
55
56
  remediation: 'Continue monitoring OWD settings as new objects and customizations are introduced.',
@@ -15,7 +15,7 @@ export class UsersAndAdminsCheck {
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
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 Assignee.Id NOT IN (SELECT UserId FROM UserLogin WHERE IsFrozen = true)');
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
19
  const modifyAllUsers = modifyAllResult.records;
20
20
  const modifyAllCount = modifyAllUsers.length;
21
21
  const modifyRisk = modifyAllCount > 5 ? 'CRITICAL' : modifyAllCount > 3 ? 'HIGH' : 'LOW';
@@ -29,7 +29,7 @@ export class UsersAndAdminsCheck {
29
29
  affectedItems: modifyAllUsers.map(userItem),
30
30
  });
31
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 Assignee.Id NOT IN (SELECT UserId FROM UserLogin WHERE IsFrozen = true)');
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
33
  const viewAllUsers = viewAllResult.records;
34
34
  const viewAllCount = viewAllUsers.length;
35
35
  const viewRisk = viewAllCount > 10 ? 'HIGH' : viewAllCount > 5 ? 'MEDIUM' : 'LOW';
@@ -43,7 +43,7 @@ export class UsersAndAdminsCheck {
43
43
  affectedItems: viewAllUsers.map(userItem),
44
44
  });
45
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 Assignee.Id NOT IN (SELECT UserId FROM UserLogin WHERE IsFrozen = true)');
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
47
  const customizeAppUsers = customizeAppResult.records;
48
48
  const customizeAppCount = customizeAppUsers.length;
49
49
  if (customizeAppCount > 5) {
@@ -58,7 +58,7 @@ export class UsersAndAdminsCheck {
58
58
  });
59
59
  }
60
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 Assignee.Id NOT IN (SELECT UserId FROM UserLogin WHERE IsFrozen = true)');
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
62
  const authorApexUsers = authorApexResult.records;
63
63
  const authorApexCount = authorApexUsers.length;
64
64
  if (authorApexCount > 3) {
@@ -22,5 +22,7 @@ export interface Finding {
22
22
  detail: string;
23
23
  remediation: string;
24
24
  affectedItems?: AffectedItem[];
25
+ /** True when the finding represents a passing check (everything is correctly configured). */
26
+ passed?: boolean;
25
27
  }
26
28
  //# sourceMappingURL=Finding.d.ts.map
@@ -12,6 +12,8 @@ const RISK_BG = {
12
12
  LOW: 'rgba(37,99,235,0.12)',
13
13
  INFO: 'rgba(100,116,139,0.12)',
14
14
  };
15
+ const PASS_COLOR = '#22c55e';
16
+ const PASS_BG = 'rgba(34,197,94,0.10)';
15
17
  function esc(str) {
16
18
  return str
17
19
  .replace(/&/g, '&')
@@ -37,10 +39,15 @@ export class HtmlRenderer {
37
39
  ].join('\n ');
38
40
  const findingsHtml = result.findings.length === 0
39
41
  ? '<p style="color:#64748b;text-align:center;padding:2rem 0">No findings.</p>'
40
- : result.findings.map((f) => `
41
- <details class="finding-card" data-risk="${esc(f.riskLevel)}" style="--card-accent:${RISK_COLORS[f.riskLevel]};--card-bg:${RISK_BG[f.riskLevel] ?? 'rgba(100,116,139,0.12)'}">
42
+ : result.findings.map((f) => {
43
+ const cardAccent = f.passed ? PASS_COLOR : (RISK_COLORS[f.riskLevel] ?? '#64748b');
44
+ const cardBg = f.passed ? PASS_BG : (RISK_BG[f.riskLevel] ?? 'rgba(100,116,139,0.12)');
45
+ const badgeStyle = f.passed ? PASS_COLOR : (RISK_COLORS[f.riskLevel] ?? '#64748b');
46
+ const badgeLabel = f.passed ? '✓ PASS' : esc(f.riskLevel);
47
+ return `
48
+ <details class="finding-card" data-risk="${esc(f.riskLevel)}" style="--card-accent:${cardAccent};--card-bg:${cardBg}">
42
49
  <summary class="finding-summary">
43
- <span class="risk-badge" style="background:${RISK_COLORS[f.riskLevel]}">${esc(f.riskLevel)}</span>
50
+ <span class="risk-badge" style="background:${badgeStyle}">${badgeLabel}</span>
44
51
  <span class="finding-title">${esc(f.title)}</span>
45
52
  <span class="finding-category">${esc(f.category)}</span>
46
53
  <span class="chevron">›</span>
@@ -52,22 +59,23 @@ export class HtmlRenderer {
52
59
  <p>${esc(f.remediation)}</p>
53
60
  </div>
54
61
  ${f.affectedItems?.length ? (() => {
55
- const hasUrls = f.affectedItems.some((i) => i.url);
56
- const hasNotes = f.affectedItems.some((i) => i.note);
57
- const headers = ['Item', ...(hasUrls ? ['Setup Link'] : []), ...(hasNotes ? ['Notes'] : [])];
58
- const thead = `<tr>${headers.map((h) => `<th>${esc(h)}</th>`).join('')}</tr>`;
59
- const tbody = f.affectedItems.map((item) => {
60
- const cells = [
61
- `<td>${esc(item.label)}</td>`,
62
- ...(hasUrls ? [`<td>${item.url ? `<a href="${esc(item.url)}" target="_blank" rel="noopener">Open ↗</a>` : '—'}</td>`] : []),
63
- ...(hasNotes ? [`<td>${esc(item.note ?? '')}</td>`] : []),
64
- ];
65
- return `<tr>${cells.join('')}</tr>`;
66
- }).join('');
67
- return `<div class="affected-items"><strong>Affected items (${f.affectedItems.length})</strong><table class="affected-table"><thead>${thead}</thead><tbody>${tbody}</tbody></table></div>`;
68
- })() : ''}
62
+ const hasUrls = f.affectedItems.some((i) => i.url);
63
+ const hasNotes = f.affectedItems.some((i) => i.note);
64
+ const headers = ['Item', ...(hasUrls ? ['Setup Link'] : []), ...(hasNotes ? ['Notes'] : [])];
65
+ const thead = `<tr>${headers.map((h) => `<th>${esc(h)}</th>`).join('')}</tr>`;
66
+ const tbody = f.affectedItems.map((item) => {
67
+ const cells = [
68
+ `<td>${esc(item.label)}</td>`,
69
+ ...(hasUrls ? [`<td>${item.url ? `<a href="${esc(item.url)}" target="_blank" rel="noopener">Open ↗</a>` : '—'}</td>`] : []),
70
+ ...(hasNotes ? [`<td>${esc(item.note ?? '')}</td>`] : []),
71
+ ];
72
+ return `<tr>${cells.join('')}</tr>`;
73
+ }).join('');
74
+ return `<div class="affected-items"><strong>Affected items (${f.affectedItems.length})</strong><table class="affected-table"><thead>${thead}</thead><tbody>${tbody}</tbody></table></div>`;
75
+ })() : ''}
69
76
  </div>
70
- </details>`).join('\n');
77
+ </details>`;
78
+ }).join('\n');
71
79
  return `<!DOCTYPE html>
72
80
  <html lang="en">
73
81
  <head>
@@ -1,5 +1,5 @@
1
1
  function escapeMdCell(s) {
2
- return s.replace(/\|/g, '\\|').replace(/\n/g, ' ');
2
+ return s.replace(/\\/g, '\\\\').replace(/\|/g, '\\|').replace(/\n/g, ' ');
3
3
  }
4
4
  export class MarkdownRenderer {
5
5
  format = 'md';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cclabsnz/sf-audit",
3
- "version": "0.2.4",
3
+ "version": "1.0.1",
4
4
  "description": "Salesforce Security Audit — native sf plugin",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",
@@ -45,6 +45,15 @@
45
45
  }
46
46
  }
47
47
  },
48
+ "overrides": {
49
+ "handlebars": "^4.7.9",
50
+ "minimatch@5": {
51
+ "brace-expansion": "^2.0.3"
52
+ },
53
+ "minimatch@10": {
54
+ "brace-expansion": "^5.0.5"
55
+ }
56
+ },
48
57
  "files": [
49
58
  "/lib",
50
59
  "/messages",