@cclabsnz/sf-audit 1.2.0 → 1.3.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 (88) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +38 -30
  3. package/lib/chains/namedChains.js +4 -4
  4. package/lib/checks/impl/AnonymousApexAuditCheck.js +5 -5
  5. package/lib/checks/impl/ApexCrudFLSCheck.d.ts +1 -1
  6. package/lib/checks/impl/ApexCrudFLSCheck.js +4 -4
  7. package/lib/checks/impl/ApexLoggingCheck.js +10 -10
  8. package/lib/checks/impl/ApexRestEndpointCheck.js +5 -5
  9. package/lib/checks/impl/ApexSharingCheck.js +3 -3
  10. package/lib/checks/impl/ApiClientPermissionCheck.js +2 -2
  11. package/lib/checks/impl/CertificateExpiryCheck.js +1 -1
  12. package/lib/checks/impl/ConnectedAppInactivityCheck.d.ts +1 -1
  13. package/lib/checks/impl/ConnectedAppInactivityCheck.js +5 -5
  14. package/lib/checks/impl/ConnectedAppScopeCheck.d.ts +1 -1
  15. package/lib/checks/impl/ConnectedAppScopeCheck.js +4 -4
  16. package/lib/checks/impl/ConnectedAppsCheck.js +2 -2
  17. package/lib/checks/impl/ContentLinksCheck.js +6 -6
  18. package/lib/checks/impl/CorsAllowlistCheck.js +3 -3
  19. package/lib/checks/impl/CustomLabelsCredentialCheck.d.ts +1 -1
  20. package/lib/checks/impl/CustomLabelsCredentialCheck.js +7 -7
  21. package/lib/checks/impl/DataClassificationCheck.js +6 -6
  22. package/lib/checks/impl/DebugLogAccessCheck.js +6 -6
  23. package/lib/checks/impl/DeploymentIdentityCheck.js +8 -8
  24. package/lib/checks/impl/EmailSecurityCheck.d.ts +10 -0
  25. package/lib/checks/impl/EmailSecurityCheck.js +117 -0
  26. package/lib/checks/impl/EnhancedDomainsCheck.d.ts +1 -1
  27. package/lib/checks/impl/EnhancedDomainsCheck.js +6 -6
  28. package/lib/checks/impl/EscalationPermsCheck.js +2 -2
  29. package/lib/checks/impl/EventMonitoringCheck.js +6 -6
  30. package/lib/checks/impl/ExperienceCloudSiteCheck.js +3 -3
  31. package/lib/checks/impl/FailedLoginCheck.js +5 -5
  32. package/lib/checks/impl/FieldHistoryTrackingCheck.js +3 -3
  33. package/lib/checks/impl/FieldLevelSecurityCheck.js +2 -2
  34. package/lib/checks/impl/GuestExecutableApexCheck.d.ts +1 -1
  35. package/lib/checks/impl/GuestExecutableApexCheck.js +5 -5
  36. package/lib/checks/impl/GuestUserAccessCheck.js +5 -5
  37. package/lib/checks/impl/HealthCheckCheck.js +2 -2
  38. package/lib/checks/impl/HighAssuranceSessionCheck.js +4 -4
  39. package/lib/checks/impl/InstalledPackagesCheck.js +5 -5
  40. package/lib/checks/impl/IntegrationUsersCheck.js +5 -5
  41. package/lib/checks/impl/InternalUserMfaCheck.js +2 -2
  42. package/lib/checks/impl/IpRestrictionsCheck.js +3 -3
  43. package/lib/checks/impl/LegacyApiVersionCheck.js +1 -1
  44. package/lib/checks/impl/MfaEnforcementCheck.js +3 -3
  45. package/lib/checks/impl/MfaMethodStrengthCheck.js +3 -3
  46. package/lib/checks/impl/MfaRegistrationCheck.js +2 -2
  47. package/lib/checks/impl/MyDomainLoginPolicyCheck.d.ts +1 -1
  48. package/lib/checks/impl/MyDomainLoginPolicyCheck.js +9 -9
  49. package/lib/checks/impl/NamedCredentialsCheck.js +3 -3
  50. package/lib/checks/impl/OutboundMessagesCheck.d.ts +10 -0
  51. package/lib/checks/impl/OutboundMessagesCheck.js +88 -0
  52. package/lib/checks/impl/PasswordSessionPolicyCheck.js +3 -3
  53. package/lib/checks/impl/PermissionsCheck.js +3 -3
  54. package/lib/checks/impl/PrivilegedAccessCheck.d.ts +11 -0
  55. package/lib/checks/impl/PrivilegedAccessCheck.js +111 -0
  56. package/lib/checks/impl/PublicContentExposureCheck.d.ts +10 -0
  57. package/lib/checks/impl/PublicContentExposureCheck.js +98 -0
  58. package/lib/checks/impl/PublicGroupSharingCheck.js +1 -1
  59. package/lib/checks/impl/ReleaseUpdatesCheck.js +2 -2
  60. package/lib/checks/impl/RemoteSitesCheck.js +1 -1
  61. package/lib/checks/impl/ReportFolderAccessCheck.d.ts +1 -1
  62. package/lib/checks/impl/ReportFolderAccessCheck.js +4 -4
  63. package/lib/checks/impl/ScheduledApexCheck.js +1 -1
  64. package/lib/checks/impl/SeparationOfDutiesCheck.d.ts +11 -0
  65. package/lib/checks/impl/SeparationOfDutiesCheck.js +114 -0
  66. package/lib/checks/impl/SharingModelCheck.d.ts +1 -1
  67. package/lib/checks/impl/SharingModelCheck.js +8 -8
  68. package/lib/checks/impl/SiemIntegrationCheck.js +4 -4
  69. package/lib/checks/impl/SsoEnforcementCheck.js +5 -5
  70. package/lib/checks/impl/StandardProfilesCheck.js +2 -2
  71. package/lib/checks/impl/TransactionSecurityPolicyCheck.js +2 -2
  72. package/lib/checks/impl/TrustedIPRangesCheck.js +5 -5
  73. package/lib/checks/impl/VisualforceXssCheck.js +6 -6
  74. package/lib/checks/permCatalog.d.ts +15 -0
  75. package/lib/checks/permCatalog.js +42 -0
  76. package/lib/checks/registry.js +12 -0
  77. package/lib/commands/audit/diff.js +1 -1
  78. package/lib/commands/audit/security.js +2 -2
  79. package/lib/compliance/mapping.js +9 -2
  80. package/lib/context/AuditCache.d.ts +9 -0
  81. package/lib/findings/CheckMeta.js +8 -3
  82. package/lib/renderers/ClientReportRenderer.js +4 -4
  83. package/lib/renderers/DiffHtmlRenderer.js +1 -1
  84. package/lib/renderers/HistoryRenderer.js +1 -1
  85. package/lib/renderers/HtmlRenderer.js +3 -3
  86. package/lib/renderers/MarkdownRenderer.js +2 -2
  87. package/messages/audit.security.md +30 -2
  88. package/package.json +2 -1
@@ -23,6 +23,14 @@ export interface MfaRegistration {
23
23
  profileName: string;
24
24
  methods: string[];
25
25
  }
26
+ export interface EffectivePermissionGrant {
27
+ userId: string;
28
+ username: string;
29
+ name: string;
30
+ profileName: string;
31
+ /** Stable permission keys from DANGEROUS_PERMS held by this user. */
32
+ perms: string[];
33
+ }
26
34
  export interface AuditCache {
27
35
  healthCheckRisks?: HealthCheckRisk[];
28
36
  apexBodies?: ApexClassBody[];
@@ -34,5 +42,6 @@ export interface AuditCache {
34
42
  eventLogSummary?: EventLogSummary;
35
43
  mfaRegistrations?: MfaRegistration[];
36
44
  vfPageBodies?: VfPageBody[];
45
+ effectivePermissions?: EffectivePermissionGrant[];
37
46
  }
38
47
  //# sourceMappingURL=AuditCache.d.ts.map
@@ -26,7 +26,7 @@ export const CHECK_META = {
26
26
  'sso-enforcement': { effort: 'project', impact: 'Without enforced SSO, username/password logins bypass your identity provider’s MFA and conditional access.' },
27
27
  'mfa-enforcement': { effort: 'quick', impact: 'Portal/external users without MFA let a stolen password reach customer or partner data directly.' },
28
28
  'api-client-permission': { effort: 'quick', impact: '“Use Any API Client” bypasses API Access Control, letting a user reach the org from any tool.' },
29
- 'integration-users': { effort: 'moderate', impact: 'Over-privileged service accounts are prime targets — one stolen key grants broad, unattended access.' },
29
+ 'integration-users': { effort: 'moderate', impact: 'Over-privileged service accounts are prime targets: one stolen key grants broad, unattended access.' },
30
30
  'content-links': { effort: 'quick', impact: 'Public file links without expiry or password leak documents to anyone who finds the URL.' },
31
31
  'field-history-tracking': { effort: 'quick', impact: 'Without field history, tampering with sensitive records can’t be reconstructed after an incident.' },
32
32
  'data-classification': { effort: 'moderate', impact: 'Unclassified sensitive data can’t be protected or encrypted consistently, increasing exposure.' },
@@ -56,10 +56,15 @@ export const CHECK_META = {
56
56
  'failed-login-detection': { effort: 'quick', impact: 'No brute-force detection means credential-stuffing campaigns run unnoticed until they succeed.' },
57
57
  'experience-cloud-site': { effort: 'moderate', impact: 'Self-registration on live sites lets attackers create their own accounts to probe guest-accessible data.' },
58
58
  'custom-labels-credential': { effort: 'quick', impact: 'Credentials in custom labels are globally readable by all authenticated users via merge fields.' },
59
- 'report-folder-access': { effort: 'quick', impact: 'Public report folders let any authenticated user view all reports and the data behind them — mass exfiltration.' },
59
+ 'report-folder-access': { effort: 'quick', impact: 'Public report folders let any authenticated user view all reports and the data behind them: mass exfiltration.' },
60
60
  'escalation-perms': { effort: 'moderate', impact: 'Lateral-movement permissions let a compromised account grant itself more access and persist.' },
61
61
  'cors-allowlist': { effort: 'quick', impact: 'Wildcard CORS origins let malicious sites make authenticated browser requests against the org.' },
62
- 'guest-executable-apex': { effort: 'project', impact: 'Unauthenticated web users can execute Apex that bypasses sharing — bulk record exfiltration without login.' },
62
+ 'guest-executable-apex': { effort: 'project', impact: 'Unauthenticated web users can execute Apex that bypasses sharing: bulk record exfiltration without login.' },
63
+ 'email-security': { effort: 'quick', impact: 'Unauthenticated inbound email services and all-profile send-as addresses let attackers trigger Apex or spoof internal senders.' },
64
+ 'outbound-messages': { effort: 'quick', impact: 'Outbound messages can ship a live session ID to external endpoints over cleartext: a direct session-hijack and exfiltration path.' },
65
+ 'public-content-exposure': { effort: 'quick', impact: 'Documents marked externally available and public static resources are retrievable without authentication by anyone with the URL.' },
66
+ 'privileged-access': { effort: 'moderate', impact: 'Shadow admins hold full org control outside the admin profile, so a single takeover bypasses admin-focused monitoring and owns everything.' },
67
+ 'separation-of-duties': { effort: 'moderate', impact: 'A single user holding a toxic permission combination can self-escalate, commit fraud, or tamper undetected with no second party to stop them.' },
63
68
  };
64
69
  export function getCheckMeta(id) {
65
70
  return CHECK_META[id];
@@ -46,7 +46,7 @@ export class ClientReportRenderer {
46
46
  this.findingsAppendix(result, num()),
47
47
  ].join('\n');
48
48
  return `<!DOCTYPE html>
49
- <html lang="en"><head><meta charset="utf-8"><title>Security Audit — ${esc(result.orgName)}</title>
49
+ <html lang="en"><head><meta charset="utf-8"><title>Security Audit: ${esc(result.orgName)}</title>
50
50
  <style>${fontFaceCss()}
51
51
  :root{--ink:${b.ink};--bg:${b.bg};--bgalt:${b.bgAlt};--muted:${b.muted};--border:${b.border};--primary:${b.primary};
52
52
  --display:'${b.fontDisplay}',Georgia,serif;--body:'${b.fontBody}',system-ui,sans-serif;--mono:ui-monospace,'SF Mono',Menlo,monospace;}
@@ -146,7 +146,7 @@ ${this.footer(b)}
146
146
  return `${head}<p class="muted">No active findings to prioritise.</p>`;
147
147
  const items = priorities.map((f, i) => {
148
148
  const meta = f.checkId ? getCheckMeta(f.checkId) : undefined;
149
- const chained = chainIds.has(f.id) ? '<p class="muted">Part of an attack chain — see Attack Scenarios.</p>' : '';
149
+ const chained = chainIds.has(f.id) ? '<p class="muted">Part of an attack chain. See Attack Scenarios.</p>' : '';
150
150
  const impact = meta ? `<p><strong>Impact:</strong> ${esc(meta.impact)}</p>` : '';
151
151
  return `<div class="card" style="--c:${SEV_COLOR[f.riskLevel]}">
152
152
  <div class="row"><h3><span class="pnum">${String(i + 1).padStart(2, '0')}</span>${esc(f.title)}</h3>${this.chip(f.riskLevel, f.riskLevel)}</div>
@@ -187,7 +187,7 @@ ${tier('Projects', 'weeks', roadmap.project)}`;
187
187
  return `<h3>${esc(FRAMEWORK_LABEL[fm.framework])} <span class="muted">· ${esc(fm.version)}</span></h3>
188
188
  <table class="matrix"><thead><tr><th>Control</th><th>Requirement area</th><th>Status</th></tr></thead><tbody>${rows}</tbody></table>`;
189
189
  }).join('');
190
- return `${this.sectionHead(numStr, 'Compliance Coverage')}<p class="muted">Findings mapped to framework controls. “No findings detected” is not an attestation of compliance — see Scope &amp; Liability.</p>${blocks}`;
190
+ return `${this.sectionHead(numStr, 'Compliance Coverage')}<p class="muted">Findings mapped to framework controls. “No findings detected” is not an attestation of compliance. See Scope &amp; Liability.</p>${blocks}`;
191
191
  }
192
192
  findingsAppendix(r, numStr) {
193
193
  const rows = r.findings.map((f) => {
@@ -199,7 +199,7 @@ ${tier('Projects', 'weeks', roadmap.project)}`;
199
199
  }
200
200
  footer(b) {
201
201
  return `<footer><span class="label">Scope &amp; Liability</span>
202
- Read-only, point-in-time configuration review — not a penetration test, not a code audit. The grade is a prioritisation aid, not a certification. Validate findings before remediation. © ${new Date().getFullYear()} ${esc(b.firmName)} · ${esc(b.contact)}</footer>`;
202
+ Read-only, point-in-time configuration review: not a penetration test, not a code audit. The grade is a prioritisation aid, not a certification. Validate findings before remediation. © ${new Date().getFullYear()} ${esc(b.firmName)} · ${esc(b.contact)}</footer>`;
203
203
  }
204
204
  }
205
205
  //# sourceMappingURL=ClientReportRenderer.js.map
@@ -84,7 +84,7 @@ export class DiffHtmlRenderer {
84
84
  <head>
85
85
  <meta charset="UTF-8">
86
86
  <meta name="viewport" content="width=device-width,initial-scale=1">
87
- <title>SF Audit Diff — ${esc(baseline.orgName)}</title>
87
+ <title>SF Audit Diff: ${esc(baseline.orgName)}</title>
88
88
  <style>
89
89
  *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
90
90
  body { font-family: system-ui, -apple-system, 'Segoe UI', sans-serif; background: #0d1117; color: #c9d1d9; max-width: 1000px; margin: 2rem auto; padding: 0 1.25rem 4rem; line-height: 1.6; }
@@ -64,7 +64,7 @@ export class HistoryRenderer {
64
64
  <head>
65
65
  <meta charset="UTF-8">
66
66
  <meta name="viewport" content="width=device-width,initial-scale=1">
67
- <title>SF Audit History — ${orgName}</title>
67
+ <title>SF Audit History: ${orgName}</title>
68
68
  <script src="https://cdn.jsdelivr.net/npm/chart.js@4/dist/chart.umd.min.js"></script>
69
69
  <style>
70
70
  *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
@@ -165,7 +165,7 @@ export class HtmlRenderer {
165
165
  .map((c) => {
166
166
  const conf = c.confidence === 'named' ? '' : ' (potential)';
167
167
  const steps = c.steps
168
- .map((s, i) => `<li><strong>${escStr(s.title ?? s.findingId)}</strong> (${escStr(s.severity ?? '—')}) — grants <code>${escStr(s.capability)}</code></li>`)
168
+ .map((s, i) => `<li><strong>${escStr(s.title ?? s.findingId)}</strong> (${escStr(s.severity ?? '—')}): grants <code>${escStr(s.capability)}</code></li>`)
169
169
  .join('');
170
170
  return `<div class="attack-chain severity-${c.severity.toLowerCase()}">
171
171
  <h3>[${escStr(c.severity)}] ${escStr(c.title)}${conf}</h3>
@@ -241,7 +241,7 @@ export class HtmlRenderer {
241
241
  <head>
242
242
  <meta charset="UTF-8">
243
243
  <meta name="viewport" content="width=device-width,initial-scale=1">
244
- <title>SF Security Audit — ${esc(result.orgName)}</title>
244
+ <title>SF Security Audit: ${esc(result.orgName)}</title>
245
245
  <link rel="preconnect" href="https://fonts.googleapis.com">
246
246
  <link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Fira+Code:wght@400;500;700&family=Fira+Sans:wght@300;400;500;600;700&display=swap">
247
247
  <style>
@@ -563,7 +563,7 @@ export class HtmlRenderer {
563
563
  });
564
564
  </script>
565
565
  <div class="offline-footer">
566
- <strong>Offline-first audit</strong> — all analysis performed locally; no data is transmitted outside your Salesforce org. Generated by CloudCounsel SF Audit.
566
+ <strong>Offline-first audit:</strong> all analysis performed locally; no data is transmitted outside your Salesforce org. Generated by CloudCounsel SF Audit.
567
567
  </div>
568
568
  </body>
569
569
  </html>`;
@@ -26,7 +26,7 @@ export class MarkdownRenderer {
26
26
  lines.push('**Steps:**');
27
27
  lines.push('');
28
28
  c.steps.forEach((s, i) => {
29
- lines.push(`${i + 1}. **${s.title ?? s.findingId}** (${s.severity ?? '—'}) — grants \`${s.capability}\``);
29
+ lines.push(`${i + 1}. **${s.title ?? s.findingId}** (${s.severity ?? '—'}): grants \`${s.capability}\``);
30
30
  });
31
31
  lines.push('');
32
32
  lines.push(`**Remediation:** ${c.remediation}`);
@@ -79,7 +79,7 @@ export class MarkdownRenderer {
79
79
  lines.push('');
80
80
  lines.push('---');
81
81
  lines.push('');
82
- lines.push('> **Offline-first audit** — all analysis is performed locally; no data is transmitted outside your Salesforce org. Generated by CloudCounsel SF Audit.');
82
+ lines.push('> **Offline-first audit:** all analysis is performed locally; no data is transmitted outside your Salesforce org. Generated by CloudCounsel SF Audit.');
83
83
  lines.push('');
84
84
  return lines.join('\n');
85
85
  }
@@ -1,6 +1,6 @@
1
1
  # Summary
2
2
 
3
- Run a comprehensive security audit against a Salesforce org.
3
+ Run a complete, read-only security audit against a Salesforce org.
4
4
 
5
5
  # Flags
6
6
 
@@ -10,7 +10,8 @@ The org to audit. Must be authenticated via `sf org login`.
10
10
 
11
11
  ## format
12
12
 
13
- Output format: html (default), md, or json.
13
+ Output format(s), comma-separated: `html` (default), `md`, `json`, or `executive`.
14
+ The `executive` format produces a branded, print-to-PDF client report.
14
15
 
15
16
  ## output
16
17
 
@@ -20,3 +21,30 @@ Directory to write the report file. Defaults to the current directory.
20
21
 
21
22
  Exit with code 1 if any finding is at or above this severity level.
22
23
  Options: CRITICAL, HIGH, MEDIUM, LOW
24
+
25
+ ## checks
26
+
27
+ Comma-separated check IDs to run instead of all checks (e.g. `hardcoded-credentials,apex-sharing`).
28
+ Run `sf audit list` to see available check IDs.
29
+
30
+ ## scoring-config
31
+
32
+ Path to a custom scoring config JSON file to override severity weights, per-check
33
+ weights, and grade thresholds. Merges with the built-in defaults.
34
+
35
+ ## prepared-for
36
+
37
+ Client name for the executive report cover line (executive format).
38
+
39
+ ## branding
40
+
41
+ Path to a `report-branding.json` to override the default branding (executive format).
42
+
43
+ ## top
44
+
45
+ Number of executive priorities to highlight (executive format). Defaults to 5.
46
+
47
+ ## frameworks
48
+
49
+ Compliance matrix scope for the executive report: `universal` (default), `nz`, `all`,
50
+ or a comma list of framework aliases (e.g. `owasp,iso,nzism`).
package/package.json CHANGED
@@ -1,7 +1,8 @@
1
1
  {
2
2
  "name": "@cclabsnz/sf-audit",
3
- "version": "1.2.0",
3
+ "version": "1.3.0",
4
4
  "description": "Salesforce Security Audit — native sf plugin",
5
+ "license": "Apache-2.0",
5
6
  "type": "module",
6
7
  "main": "lib/index.js",
7
8
  "scripts": {