@cclabsnz/sf-audit 1.2.0 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (142) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +135 -31
  3. package/lib/api/MetadataClient.d.ts +4 -0
  4. package/lib/api/MetadataClient.js +2 -0
  5. package/lib/api/MetadataClientImpl.d.ts +8 -0
  6. package/lib/api/MetadataClientImpl.js +22 -0
  7. package/lib/api/RestClient.d.ts +1 -0
  8. package/lib/api/RestClientImpl.d.ts +1 -0
  9. package/lib/api/RestClientImpl.js +6 -0
  10. package/lib/chains/CapabilityRegistry.js +19 -0
  11. package/lib/chains/namedChains.js +26 -4
  12. package/lib/checks/eventLogAccess.d.ts +14 -0
  13. package/lib/checks/eventLogAccess.js +33 -0
  14. package/lib/checks/impl/AnonymousApexAuditCheck.js +5 -5
  15. package/lib/checks/impl/ApexCrudFLSCheck.d.ts +1 -1
  16. package/lib/checks/impl/ApexCrudFLSCheck.js +4 -4
  17. package/lib/checks/impl/ApexLoggingCheck.js +10 -10
  18. package/lib/checks/impl/ApexRestEndpointCheck.js +5 -5
  19. package/lib/checks/impl/ApexSharingCheck.js +3 -3
  20. package/lib/checks/impl/ApiClientPermissionCheck.js +2 -2
  21. package/lib/checks/impl/AuthProvidersCheck.d.ts +17 -0
  22. package/lib/checks/impl/AuthProvidersCheck.js +88 -0
  23. package/lib/checks/impl/CertificateExpiryCheck.js +1 -1
  24. package/lib/checks/impl/ClassicSitesCheck.d.ts +17 -0
  25. package/lib/checks/impl/ClassicSitesCheck.js +65 -0
  26. package/lib/checks/impl/ConnectedAppInactivityCheck.d.ts +1 -1
  27. package/lib/checks/impl/ConnectedAppInactivityCheck.js +5 -5
  28. package/lib/checks/impl/ConnectedAppScopeCheck.d.ts +1 -1
  29. package/lib/checks/impl/ConnectedAppScopeCheck.js +4 -4
  30. package/lib/checks/impl/ConnectedAppsCheck.js +2 -2
  31. package/lib/checks/impl/ContentLinksCheck.js +6 -6
  32. package/lib/checks/impl/CorsAllowlistCheck.js +3 -3
  33. package/lib/checks/impl/CustomLabelsCredentialCheck.d.ts +1 -1
  34. package/lib/checks/impl/CustomLabelsCredentialCheck.js +7 -7
  35. package/lib/checks/impl/DataClassificationCheck.js +6 -6
  36. package/lib/checks/impl/DataExportAccessCheck.d.ts +19 -0
  37. package/lib/checks/impl/DataExportAccessCheck.js +79 -0
  38. package/lib/checks/impl/DebugLogAccessCheck.js +6 -6
  39. package/lib/checks/impl/DeploymentIdentityCheck.js +8 -8
  40. package/lib/checks/impl/EmailSecurityCheck.d.ts +10 -0
  41. package/lib/checks/impl/EmailSecurityCheck.js +117 -0
  42. package/lib/checks/impl/EncryptionCoverageCheck.d.ts +19 -0
  43. package/lib/checks/impl/EncryptionCoverageCheck.js +108 -0
  44. package/lib/checks/impl/EnhancedDomainsCheck.d.ts +1 -1
  45. package/lib/checks/impl/EnhancedDomainsCheck.js +6 -6
  46. package/lib/checks/impl/EscalationPermsCheck.js +2 -2
  47. package/lib/checks/impl/EventMonitoringCheck.js +14 -11
  48. package/lib/checks/impl/ExperienceCloudSiteCheck.js +3 -3
  49. package/lib/checks/impl/ExperienceCspCheck.d.ts +18 -0
  50. package/lib/checks/impl/ExperienceCspCheck.js +57 -0
  51. package/lib/checks/impl/ExternalCredentialsCheck.d.ts +17 -0
  52. package/lib/checks/impl/ExternalCredentialsCheck.js +74 -0
  53. package/lib/checks/impl/FailedLoginCheck.js +5 -5
  54. package/lib/checks/impl/FieldHistoryTrackingCheck.js +3 -3
  55. package/lib/checks/impl/FieldLevelSecurityCheck.js +2 -2
  56. package/lib/checks/impl/GuestApiAccessCheck.d.ts +19 -0
  57. package/lib/checks/impl/GuestApiAccessCheck.js +113 -0
  58. package/lib/checks/impl/GuestExecutableApexCheck.d.ts +1 -1
  59. package/lib/checks/impl/GuestExecutableApexCheck.js +5 -5
  60. package/lib/checks/impl/GuestObjectExposureCheck.d.ts +44 -0
  61. package/lib/checks/impl/GuestObjectExposureCheck.js +241 -0
  62. package/lib/checks/impl/GuestRecordAccessPolicyCheck.d.ts +34 -0
  63. package/lib/checks/impl/GuestRecordAccessPolicyCheck.js +120 -0
  64. package/lib/checks/impl/GuestSiteOptionsCheck.d.ts +18 -0
  65. package/lib/checks/impl/GuestSiteOptionsCheck.js +92 -0
  66. package/lib/checks/impl/GuestTrafficAnomalyCheck.d.ts +23 -0
  67. package/lib/checks/impl/GuestTrafficAnomalyCheck.js +343 -0
  68. package/lib/checks/impl/GuestUserAccessCheck.js +5 -5
  69. package/lib/checks/impl/HealthCheckCheck.js +2 -2
  70. package/lib/checks/impl/HighAssuranceSessionCheck.js +4 -4
  71. package/lib/checks/impl/InstalledPackagesCheck.js +5 -5
  72. package/lib/checks/impl/IntegrationUsersCheck.js +5 -5
  73. package/lib/checks/impl/InternalUserMfaCheck.js +2 -2
  74. package/lib/checks/impl/IpRestrictionsCheck.js +3 -3
  75. package/lib/checks/impl/LegacyApiVersionCheck.js +1 -1
  76. package/lib/checks/impl/LoginAccessPolicyCheck.d.ts +26 -0
  77. package/lib/checks/impl/LoginAccessPolicyCheck.js +117 -0
  78. package/lib/checks/impl/LoginAnomalyCheck.d.ts +17 -0
  79. package/lib/checks/impl/LoginAnomalyCheck.js +98 -0
  80. package/lib/checks/impl/MfaEnforcementCheck.js +3 -3
  81. package/lib/checks/impl/MfaMethodStrengthCheck.js +3 -3
  82. package/lib/checks/impl/MfaRegistrationCheck.js +2 -2
  83. package/lib/checks/impl/MyDomainLoginPolicyCheck.d.ts +1 -1
  84. package/lib/checks/impl/MyDomainLoginPolicyCheck.js +9 -9
  85. package/lib/checks/impl/NamedCredentialsCheck.js +3 -3
  86. package/lib/checks/impl/OutboundMessagesCheck.d.ts +10 -0
  87. package/lib/checks/impl/OutboundMessagesCheck.js +88 -0
  88. package/lib/checks/impl/PasswordSessionPolicyCheck.js +3 -3
  89. package/lib/checks/impl/PermissionsCheck.js +3 -3
  90. package/lib/checks/impl/PrivilegedAccessCheck.d.ts +11 -0
  91. package/lib/checks/impl/PrivilegedAccessCheck.js +111 -0
  92. package/lib/checks/impl/PublicContentExposureCheck.d.ts +10 -0
  93. package/lib/checks/impl/PublicContentExposureCheck.js +98 -0
  94. package/lib/checks/impl/PublicGroupSharingCheck.js +1 -1
  95. package/lib/checks/impl/ReleaseUpdatesCheck.js +2 -2
  96. package/lib/checks/impl/RemoteSitesCheck.js +1 -1
  97. package/lib/checks/impl/ReportFolderAccessCheck.d.ts +1 -1
  98. package/lib/checks/impl/ReportFolderAccessCheck.js +4 -4
  99. package/lib/checks/impl/SandboxDataMaskingCheck.d.ts +17 -0
  100. package/lib/checks/impl/SandboxDataMaskingCheck.js +85 -0
  101. package/lib/checks/impl/ScheduledApexCheck.js +1 -1
  102. package/lib/checks/impl/SeparationOfDutiesCheck.d.ts +11 -0
  103. package/lib/checks/impl/SeparationOfDutiesCheck.js +114 -0
  104. package/lib/checks/impl/SessionHardeningCheck.d.ts +21 -0
  105. package/lib/checks/impl/SessionHardeningCheck.js +134 -0
  106. package/lib/checks/impl/SharingModelCheck.d.ts +1 -1
  107. package/lib/checks/impl/SharingModelCheck.js +8 -8
  108. package/lib/checks/impl/SiemIntegrationCheck.js +4 -4
  109. package/lib/checks/impl/SsoEnforcementCheck.js +5 -5
  110. package/lib/checks/impl/StandardProfilesCheck.js +2 -2
  111. package/lib/checks/impl/ThreatDetectionCheck.d.ts +17 -0
  112. package/lib/checks/impl/ThreatDetectionCheck.js +91 -0
  113. package/lib/checks/impl/TransactionSecurityPolicyCheck.js +2 -2
  114. package/lib/checks/impl/TrustedIPRangesCheck.js +5 -5
  115. package/lib/checks/impl/VisualforceXssCheck.js +6 -6
  116. package/lib/checks/permCatalog.d.ts +15 -0
  117. package/lib/checks/permCatalog.js +42 -0
  118. package/lib/checks/registry.js +45 -0
  119. package/lib/commands/audit/diff.js +9 -5
  120. package/lib/commands/audit/events/pull.d.ts +17 -0
  121. package/lib/commands/audit/events/pull.js +88 -0
  122. package/lib/commands/audit/security.d.ts +4 -0
  123. package/lib/commands/audit/security.js +41 -17
  124. package/lib/compliance/mapping.js +34 -7
  125. package/lib/context/AuditCache.d.ts +12 -0
  126. package/lib/context/AuditContext.d.ts +2 -0
  127. package/lib/events/EventBaselineStore.d.ts +16 -0
  128. package/lib/events/EventBaselineStore.js +55 -0
  129. package/lib/events/eventLogQuery.d.ts +21 -0
  130. package/lib/events/eventLogQuery.js +34 -0
  131. package/lib/events/pullEventLogs.d.ts +51 -0
  132. package/lib/events/pullEventLogs.js +79 -0
  133. package/lib/findings/CheckMeta.js +24 -3
  134. package/lib/lib/wire.d.ts +2 -0
  135. package/lib/lib/wire.js +3 -0
  136. package/lib/renderers/ClientReportRenderer.js +4 -4
  137. package/lib/renderers/DiffHtmlRenderer.js +1 -1
  138. package/lib/renderers/HistoryRenderer.js +1 -1
  139. package/lib/renderers/HtmlRenderer.js +3 -3
  140. package/lib/renderers/MarkdownRenderer.js +2 -2
  141. package/messages/audit.security.md +30 -2
  142. package/package.json +14 -2
@@ -0,0 +1,79 @@
1
+ import { classifyEventLogAccessError } from '../checks/eventLogAccess.js';
2
+ import { buildEventLogQuery, toLogDate } from './eventLogQuery.js';
3
+ export async function pullEventLogs(deps, opts) {
4
+ const { soql, rest, store, orgId } = deps;
5
+ const since = opts.since;
6
+ const storagePath = store.orgDir(orgId);
7
+ const base = {
8
+ orgId,
9
+ since,
10
+ storagePath,
11
+ found: 0,
12
+ downloaded: 0,
13
+ skipped: 0,
14
+ failed: 0,
15
+ totalBytes: 0,
16
+ logs: [],
17
+ };
18
+ let rows;
19
+ try {
20
+ rows = await soql.queryAll(buildEventLogQuery({ since, types: opts.types }));
21
+ }
22
+ catch (err) {
23
+ // Inaccessible EventLogFile (unlicensed / no permission) must not crash the command.
24
+ return { ...base, accessError: classifyEventLogAccessError(err) };
25
+ }
26
+ base.found = rows.length;
27
+ for (const row of rows) {
28
+ const logDate = toLogDate(row.LogDate);
29
+ if (store.has(orgId, row.EventType, logDate, row.Id)) {
30
+ base.skipped += 1;
31
+ base.logs.push({
32
+ id: row.Id,
33
+ eventType: row.EventType,
34
+ logDate,
35
+ bytes: 0,
36
+ savedPath: store.pathFor(orgId, row.EventType, logDate, row.Id),
37
+ status: 'skipped',
38
+ });
39
+ continue;
40
+ }
41
+ try {
42
+ const body = await rest.getRaw(`/sobjects/EventLogFile/${row.Id}/LogFile`);
43
+ const savedPath = store.save(orgId, row.EventType, logDate, row.Id, body);
44
+ const bytes = Buffer.byteLength(body, 'utf-8');
45
+ base.downloaded += 1;
46
+ base.totalBytes += bytes;
47
+ base.logs.push({ id: row.Id, eventType: row.EventType, logDate, bytes, savedPath, status: 'downloaded' });
48
+ }
49
+ catch (err) {
50
+ base.failed += 1;
51
+ base.logs.push({
52
+ id: row.Id,
53
+ eventType: row.EventType,
54
+ logDate,
55
+ bytes: 0,
56
+ savedPath: store.pathFor(orgId, row.EventType, logDate, row.Id),
57
+ status: 'failed',
58
+ });
59
+ opts.warn?.(`Failed to download EventLogFile ${row.Id} (${row.EventType} ${logDate}): ${String(err)}`);
60
+ }
61
+ }
62
+ // Only write a manifest when something was actually captured — a pure all-skipped or
63
+ // empty run leaves no new record to make.
64
+ if (base.downloaded > 0) {
65
+ base.manifestPath = store.writeManifest(orgId, {
66
+ orgId,
67
+ since,
68
+ pulledAt: new Date().toISOString(),
69
+ found: base.found,
70
+ downloaded: base.downloaded,
71
+ skipped: base.skipped,
72
+ failed: base.failed,
73
+ totalBytes: base.totalBytes,
74
+ logs: base.logs,
75
+ });
76
+ }
77
+ return base;
78
+ }
79
+ //# sourceMappingURL=pullEventLogs.js.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,31 @@ 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.' },
68
+ 'guest-object-exposure': { effort: 'moderate', impact: 'Grades guest-readable objects by ACTUAL UI-API reachability: objects the UI API models are bulk-readable unauthenticated via GraphQL (CRITICAL, incl. guest-owned records under a Private OWD, enabling mass PII exfiltration without login); objects readable only in the sharing model but not UI-API-modelled (Calendar, AuthSession, etc.) are separated as MEDIUM defense-in-depth, with UserRecordAccess as ground-truth read confirmation.' },
69
+ 'guest-site-options': { effort: 'quick', impact: 'Guest file access and member visibility let unauthenticated visitors download public files and enumerate site members.' },
70
+ 'threat-detection': { effort: 'moderate', impact: 'Without Guest User Anomaly storage, malicious guest bulk-reads are never flagged and cannot be reconstructed after the fact.' },
71
+ 'guest-record-access-policy': { effort: 'quick', impact: 'Without "Secure guest user record access" enforced, guests own the records they submit and can read them under a Private OWD, turning a public form into an unauthenticated bulk-read surface.' },
72
+ 'guest-traffic-anomaly': { effort: 'moderate', impact: 'Guest requests from anonymizer/hosting IPs, single-IP bursts, and GraphQL totalCount sweeps are the live signatures of scraping and pre-exfiltration recon — unmonitored, they only surface after data is gone.' },
73
+ 'login-access-policy': { effort: 'moderate', impact: 'Delegated admins and "log in as any user" let accounts impersonate others and self-escalate, bypassing normal credentials and admin-focused monitoring.' },
74
+ 'data-export-access': { effort: 'quick', impact: 'Weekly Data Export or API access with View/Modify All is a one-step, org-wide exfiltration capability in the wrong hands.' },
75
+ 'classic-sites': { effort: 'moderate', impact: 'Active classic Visualforce sites expose a second unauthenticated guest surface that the Experience Cloud checks never inspect.' },
76
+ 'auth-providers': { effort: 'moderate', impact: 'Unvetted social/SAML identity providers with just-in-time provisioning can let attackers federate in or auto-create over-privileged users.' },
77
+ 'guest-api-access': { effort: 'quick', impact: 'A guest user with API access can drive the raw REST/Bulk API, turning readable objects into scriptable mass extraction (and Hard Delete into irreversible destruction) without login.' },
78
+ 'external-credentials': { effort: 'moderate', impact: 'Callouts with no or custom authentication can be spoofed or leak a static secret, exposing the integrated system and the data crossing it.' },
79
+ 'login-anomaly': { effort: 'quick', impact: 'An account logging in from many distinct IPs signals credential sharing or compromise; caught late, it means an attacker already has a working session.' },
80
+ 'session-hardening': { effort: 'quick', impact: 'Weak clickjack/CSRF/session-lock/XSS settings let attackers hijack authenticated sessions via framing, forged requests, or injected script.' },
81
+ 'encryption-coverage': { effort: 'moderate', impact: 'Fields labelled PII/PHI but stored in plaintext are unprotected at rest and on export — the sensitivity is known, the protection is missing.' },
82
+ 'experience-csp': { effort: 'moderate', impact: 'Relaxed CSP or disabled Lightning Web Security on a public site lets injected/third-party scripts run against unauthenticated visitors.' },
83
+ 'sandbox-data-masking': { effort: 'moderate', impact: 'Unmasked production PII/PHI copied into a sandbox spreads sensitive data into a lower-trust environment with broader access and weaker monitoring.' },
63
84
  };
64
85
  export function getCheckMeta(id) {
65
86
  return CHECK_META[id];
package/lib/lib/wire.d.ts CHANGED
@@ -2,12 +2,14 @@ import type { Connection } from '@salesforce/core';
2
2
  import { SoqlClientImpl } from '../api/SoqlClientImpl.js';
3
3
  import { ToolingClientImpl } from '../api/ToolingClientImpl.js';
4
4
  import { RestClientImpl } from '../api/RestClientImpl.js';
5
+ import { MetadataClientImpl } from '../api/MetadataClientImpl.js';
5
6
  import type { AuditContext } from '../context/AuditContext.js';
6
7
  import type { OrgInfo } from '../context/OrgInfo.js';
7
8
  export declare function buildApiClients(conn: Connection): {
8
9
  soql: SoqlClientImpl;
9
10
  tooling: ToolingClientImpl;
10
11
  rest: RestClientImpl;
12
+ metadata: MetadataClientImpl;
11
13
  };
12
14
  export declare function resolveOrgInfo(conn: Connection): Promise<OrgInfo>;
13
15
  export declare function buildAuditContext(conn: Connection, orgInfo: OrgInfo): AuditContext;
package/lib/lib/wire.js CHANGED
@@ -1,11 +1,13 @@
1
1
  import { SoqlClientImpl } from '../api/SoqlClientImpl.js';
2
2
  import { ToolingClientImpl } from '../api/ToolingClientImpl.js';
3
3
  import { RestClientImpl } from '../api/RestClientImpl.js';
4
+ import { MetadataClientImpl } from '../api/MetadataClientImpl.js';
4
5
  export function buildApiClients(conn) {
5
6
  return {
6
7
  soql: new SoqlClientImpl(conn),
7
8
  tooling: new ToolingClientImpl(conn),
8
9
  rest: new RestClientImpl(conn),
10
+ metadata: new MetadataClientImpl(conn),
9
11
  };
10
12
  }
11
13
  export async function resolveOrgInfo(conn) {
@@ -28,6 +30,7 @@ export function buildAuditContext(conn, orgInfo) {
28
30
  soql: clients.soql,
29
31
  tooling: clients.tooling,
30
32
  rest: clients.rest,
33
+ metadata: clients.metadata,
31
34
  orgInfo,
32
35
  cache: {},
33
36
  };
@@ -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.4.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": {
@@ -41,10 +42,21 @@
41
42
  "devPlugins": [],
42
43
  "topics": {
43
44
  "audit": {
44
- "description": "Salesforce security audit commands"
45
+ "description": "Salesforce security audit commands",
46
+ "subtopics": {
47
+ "events": {
48
+ "description": "Capture free EventLogFile logs to local disk"
49
+ }
50
+ }
45
51
  }
46
52
  }
47
53
  },
54
+ "pnpm": {
55
+ "overrides": {
56
+ "form-data": "^4.0.6",
57
+ "js-yaml@3": "^3.15.0"
58
+ }
59
+ },
48
60
  "overrides": {
49
61
  "handlebars": "^4.7.9",
50
62
  "minimatch@5": {