@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
package/README.md CHANGED
@@ -1,6 +1,13 @@
1
1
  # @cclabsnz/sf-audit
2
2
 
3
- A Salesforce CLI (`sf`) plugin that runs a comprehensive security audit against any Salesforce org and produces an HTML, Markdown, or JSON report.
3
+ A Salesforce CLI (`sf`) plugin that runs a comprehensive, **read-only** security audit against any Salesforce org, risk-scores it with an A–F grade, and turns the result into a report your security team — or your client's — can act on.
4
+
5
+ - **61 read-only checks** across identity, access, data, code, integrations, and monitoring
6
+ - **Attack-chain correlation** — links individual findings into named, multi-step attack scenarios
7
+ - **Compliance mapping** — every finding mapped to **source-verified** controls across 7 frameworks (OWASP, SOC 2, ISO/IEC 27001:2022, Security Benchmark for Salesforce, NZ Privacy Act, HISO 10029, NZISM)
8
+ - **Outputs:** a technical `html` / `md` / `json` report, or a branded, client-ready **executive report** (print-to-PDF) with priorities, remediation roadmap, and a compliance coverage matrix
9
+ - **History & diff** — archives each run and shows security-posture drift over time
10
+ - Strictly read-only (SOQL/Tooling/REST GETs); see [PERMISSIONS.md](PERMISSIONS.md) for the least-privilege access it needs
4
11
 
5
12
  ## Installation
6
13
 
@@ -24,18 +31,22 @@ sf plugins link .
24
31
  sf audit security --target-org <orgAlias>
25
32
  ```
26
33
 
27
- This runs all 22 security checks against the target org and writes a report to the current directory.
34
+ This runs all 61 security checks against the target org and writes a report to the current directory.
28
35
 
29
36
  ### Options
30
37
 
31
38
  | Flag | Default | Description |
32
39
  |------|---------|-------------|
33
40
  | `--target-org` | *(required)* | Org alias or username to audit |
34
- | `--format` / `-f` | `html` | Output format(s), comma-separated: `html`, `md`, `json` |
41
+ | `--format` / `-f` | `html` | Output format(s), comma-separated: `html`, `md`, `json`, `executive` |
35
42
  | `--output` / `-o` | `.` | Directory to write the report file |
36
43
  | `--fail-on` | — | Exit with code 1 if any finding is at or above this severity: `CRITICAL`, `HIGH`, `MEDIUM`, `LOW` |
37
- | `--checks` | *(all)* | Comma-separated check IDs to run instead of all 22 (e.g. `hardcoded-credentials,apex-sharing`) |
44
+ | `--checks` | *(all)* | Comma-separated check IDs to run instead of all 61 (e.g. `hardcoded-credentials,apex-sharing`) |
38
45
  | `--scoring-config` | — | Path to a custom scoring config JSON file to override weights and grade thresholds |
46
+ | `--prepared-for` | — | Client name for the executive report cover line |
47
+ | `--branding` | — | Path to a `report-branding.json` to override CloudCounsel defaults (executive format) |
48
+ | `--top` | `5` | Number of executive priorities to highlight (executive format) |
49
+ | `--frameworks` | `universal` | Compliance matrix scope (executive format): `universal` (OWASP/SOC 2/ISO 27001), `nz` (ISO/HISO/Privacy Act/NZISM), `all`, or a comma list (e.g. `owasp,iso,nzism`) |
39
50
 
40
51
  ### Examples
41
52
 
@@ -59,57 +70,168 @@ sf audit security --target-org myOrg --checks hardcoded-credentials,apex-sharing
59
70
  sf audit security --target-org myOrg --scoring-config ./my-scoring.json
60
71
  ```
61
72
 
73
+ ### Executive report
74
+
75
+ `--format executive` produces a CloudCounsel-branded, print-to-PDF HTML report for clients —
76
+ grade and executive summary, top priorities with abuse/impact narratives, attack scenarios, a
77
+ risk×effort remediation roadmap, and a **compliance coverage matrix** mapping findings to framework
78
+ controls. It is fully self-contained (fonts embedded); open it and **Save as PDF**.
79
+
80
+ ```bash
81
+ # Branded executive report for a client (universal compliance matrix)
82
+ sf audit security --target-org myOrg --format executive --prepared-for "Acme Health" --top 5
83
+
84
+ # NZ health/government engagement — NZ framework matrix
85
+ sf audit security --target-org myOrg --format executive --frameworks nz
86
+
87
+ # White-label / co-brand via overrides
88
+ sf audit security --target-org myOrg --format executive --branding ./report-branding.json
89
+ ```
90
+
91
+ Compliance controls are mapped from authoritative, version-pinned sources (OWASP Top 10:2021,
92
+ AICPA TSC, ISO/IEC 27001:2022, the Security Benchmark for Salesforce, NZ Privacy Act, HISO 10029,
93
+ NZISM). Only source-verified controls render; "No findings detected" is **not** an attestation of
94
+ compliance (see the report's Scope & Liability section).
95
+
62
96
  The report file is written as `sf-audit-<orgId>-<timestamp>.<ext>` in the output directory (e.g. `sf-audit-00D000000000001-1711234567890.html`).
63
97
 
64
98
  ## What It Checks
65
99
 
66
- The audit runs 22 checks across 6 categories:
100
+ The audit runs **61 read-only checks**. Every finding is risk-rated (CRITICAL → INFO) and mapped to controls across the compliance frameworks (see [Compliance frameworks](#compliance-frameworks)). The checks are grouped into nine domains below.
67
101
 
68
- ### Org Health
102
+ ### Org Health & Configuration
69
103
  | Check | What it looks for |
70
104
  |-------|------------------|
71
- | Health Check | Salesforce Health Check score and individual risk items |
72
- | Password & Session Policy | Weak password requirements, session timeout, MFA gaps |
105
+ | Security Health Check | Salesforce Health Check score and individual high-risk settings |
106
+ | Enhanced Domains | Enhanced Domains enabled — prevents cross-org cookie leakage and enforces URL isolation |
107
+ | Pending Release Updates | Salesforce release updates pending activation, especially those past auto-activation |
108
+ | Legacy API Versions | Apex compiled on old API versions and SOAP-based remote site integrations |
109
+ | API & Resource Limits | API request consumption against daily and concurrent limits |
73
110
 
74
- ### Identity & Access
111
+ ### Identity & Authentication
112
+ | Check | What it looks for |
113
+ |-------|------------------|
114
+ | SSO Enforcement | Username-password logins indicating SSO is not org-wide enforced |
115
+ | My Domain Login Policy | My Domain configured and login from login.salesforce.com blocked (stops SSO bypass) |
116
+ | Internal User MFA | MFA enforcement for active internal standard users |
117
+ | MFA for External Users | MFA enforced for external/portal users with data access |
118
+ | MFA Method Registration | Active standard users with no registered MFA method |
119
+ | MFA Method Strength | Registered MFA methods classified by strength (phishing-resistant / TOTP / weak) |
120
+ | High Assurance Sessions | Admin-capable connected apps requiring short timeouts or high-assurance MFA sessions |
121
+ | Trusted IP Ranges | Trusted IP ranges that bypass MFA, including overly broad ranges |
122
+ | Login IP Restrictions | Admin profiles missing IP ranges; connected apps with relaxed IP policy |
123
+ | Password & Session Policy | Password complexity, session timeout, and MFA gaps (from Health Check) |
124
+ | Certificate Expiry | Installed certificates nearing expiry (30 / 90 / 180-day thresholds) |
125
+
126
+ ### Users, Permissions & Privilege
75
127
  | Check | What it looks for |
76
128
  |-------|------------------|
77
- | Users & Admins | Users with system-wide permissions (ModifyAllData, ViewAllData, AuthorApex) |
78
- | Permissions | Unassigned permission sets, excessive profile count |
79
- | IP Restrictions | Admins without IP range restrictions, connected apps with relaxed IP policies |
80
- | Login Sessions | Failed login trends, logins from diverse IPs, recent login activity |
129
+ | Users & Admins | Users with system-wide permissions (ModifyAllData, ViewAllData, AuthorApex, CustomizeApplication) |
130
+ | Permissions | Unassigned permission sets and high profile counts that widen the attack surface |
131
+ | Standard Profile Usage | Active users assigned to out-of-the-box standard profiles |
132
+ | Use Any API Client | Users with the permission that bypasses API Access Control |
133
+ | Privilege Escalation Permissions | Users holding lateral-movement / persistence permission clusters |
134
+ | Integration / Service Accounts | Non-human identity inventory and excess privilege |
81
135
  | Inactive Users | Active licensed users with no login in 90+ days |
82
136
 
83
- ### Data Security
137
+ ### Data Access & Sharing
84
138
  | Check | What it looks for |
85
139
  |-------|------------------|
86
- | Sharing Model | Object-level OWD settings for Account, Contact, Opportunity, Case, Lead |
87
- | Field Level Security | Sensitive fields (SSN, credit card, tax ID) exposed to broad permission sets |
88
- | Guest User Access | Object permissions and sharing rules granted to unauthenticated guest users |
140
+ | OWD Sharing Model | Org-wide defaults for Account, Contact, Opportunity, Case, Lead (internal + external) |
141
+ | Field-Level Security | Sensitive fields (SSN, credit card, tax ID) exposed to broad permission sets |
89
142
  | Public Group Sharing | Sharing rules that grant access to All Internal Users |
143
+ | Report Folder Public Access | Report folders any authenticated user can view |
144
+ | Field History Tracking | History tracking enabled on sensitive standard objects |
145
+ | Data Classification & Encryption | Field data classification usage and Shield Platform Encryption |
146
+ | Flows Without Sharing | Active flows running in system context without sharing enforcement |
147
+ | Content Distribution Links | Public file links missing expiry or passwords, and stale records |
90
148
 
91
- ### Integration Security
149
+ ### Guest & External-Facing Access
92
150
  | Check | What it looks for |
93
151
  |-------|------------------|
94
- | Connected Apps | Apps not restricted to admin-approved users |
95
- | Remote Sites | Raw remote site registrations without Named Credential coverage |
96
- | Named Credentials | Named credential inventory |
97
- | Hardcoded Credentials | Bearer tokens, Basic auth, API keys, and raw callout URLs in Apex code |
152
+ | Guest User Access | Object permissions and sharing rules granted to unauthenticated guests |
153
+ | Guest-Executable Apex | Apex that guest profiles can run, flagging `without sharing` classes |
154
+ | Experience Cloud Sites | Live sites with self-registration enabled and guest user presence |
155
+ | CORS Allowlist | Wildcard or overly broad CORS allowlist origins |
156
+ | CSP Trusted Sites | Content Security Policy trusted sites with insecure HTTP (mixed-content) endpoints |
98
157
 
99
- ### Code & Automation
158
+ ### Apex & Code Security
100
159
  | Check | What it looks for |
101
160
  |-------|------------------|
102
- | Apex Sharing | Apex classes using `without sharing` or missing sharing declaration |
103
- | Flows Without Sharing | Active flows running in system context without sharing enforcement |
104
- | Scheduled Apex | Active scheduled and batch Apex jobs |
105
- | Code Security | Org-wide Apex test coverage percentage |
161
+ | Apex Sharing Declarations | Classes classified by sharing declaration (with / without / inherited / omitted) |
162
+ | Apex CRUD/FLS Enforcement | DML or SOQL performed without CRUD/FLS permission checks |
163
+ | Apex REST Endpoints | `@RestResource` classes running `without sharing` |
164
+ | Visualforce XSS | `escape="false"` and unencoded merge fields in Visualforce markup |
165
+ | Hardcoded Credentials | Bearer tokens, Basic auth, API keys, and raw callout URLs in Apex |
166
+ | Code Security & Coverage | Org-wide Apex test coverage, class/trigger counts, and SOQL injection patterns |
167
+ | Scheduled & Batch Apex | Active scheduled and batch Apex jobs |
168
+ | Anonymous Apex Audit | Anonymous Apex executed in the last 90 days (via SetupAuditTrail) |
169
+ | Apex Logging Framework | Persistent logging usage and sensitive data exposed in Apex logs |
170
+
171
+ ### Integrations, Connected Apps & Deployments
172
+ | Check | What it looks for |
173
+ |-------|------------------|
174
+ | Connected Apps | Apps not restricted to admin-approved users |
175
+ | Connected App OAuth Scopes | Full OAuth-scope grants and infinite refresh-token policies |
176
+ | Inactive Connected Apps | Apps with no OAuth logins in the past 90 days |
177
+ | Named Credentials | Named credential inventory; credentials not referenced in Apex |
178
+ | Remote Site Settings | Remote sites with protocol security disabled |
179
+ | Installed Packages | Managed/unmanaged package inventory; unmanaged or beta packages in production |
180
+ | Deployment Identity | Designated deployment identity and uncontrolled deployment activity |
181
+
182
+ ### Secrets & Credential Storage
183
+ | Check | What it looks for |
184
+ |-------|------------------|
185
+ | Custom Settings & Credentials | Custom settings with credential-like names that may store secrets |
186
+ | Custom Labels Credential Exposure | API keys and tokens in globally-readable Custom Labels |
106
187
 
107
- ### Platform
188
+ ### Monitoring & Threat Detection
108
189
  | Check | What it looks for |
109
190
  |-------|------------------|
110
- | API Limits | API request consumption vs. daily/concurrent limits |
111
191
  | Audit Trail | Permission changes and Login-As events in the setup audit trail |
112
- | Custom Settings | Custom settings with credential-like names that may store secrets |
192
+ | Login Session | Failed login trends, Login-As events, and access from diverse IPs |
193
+ | Failed Login Detection | Brute-force and credential-stuffing patterns (last 7 days) |
194
+ | Transaction Security Policies | Automated threat detection and response policies configured |
195
+ | Active Debug Log Traces | Active TraceFlag records capturing logs, including high-detail traces |
196
+ | Event Monitoring | Event Monitoring enabled with logs covering 30+ days |
197
+ | SIEM Integration Signals | Evidence of SIEM or external monitoring integration |
198
+
199
+ ## Compliance frameworks
200
+
201
+ Findings are mapped to controls across seven security and privacy frameworks. The mapping is built on a **sourced control catalog** — each control carries its framework, **pinned version**, official title, and a citation — so a finding's compliance reference ties to an exact, defensible requirement rather than a bare tag.
202
+
203
+ | Framework | Version | Notes |
204
+ |-----------|---------|-------|
205
+ | OWASP Top 10 | 2021 | Web application risk categories |
206
+ | SOC 2 | AICPA TSC 2017 | Common Criteria (CC6–CC9) |
207
+ | ISO/IEC 27001 | 2022 | Annex A controls |
208
+ | Security Benchmark for Salesforce (SBS) | current | Salesforce-native benchmark — [docs.securitybenchmark.org](https://docs.securitybenchmark.org) |
209
+ | NZ Privacy Act | 2020 | Information Privacy Principles (IPP 5/9/12) |
210
+ | HISO 10029 | 2022 | NZ Health Information Security Framework |
211
+ | NZISM | v3.8 | NZ Information Security Manual |
212
+
213
+ **Provenance gate.** Each catalogued control is marked `verified` only after its title/reference is confirmed against the authoritative source. **Controls that are not verified do not render** in the compliance matrix — nothing ships as "compliant-to-clause" on unconfirmed data. The current verification status is tracked in [`docs/compliance/verification-worksheet.md`](docs/compliance/verification-worksheet.md).
214
+
215
+ **Framework packs.** The executive report's compliance matrix is scoped with `--frameworks`:
216
+
217
+ - `universal` *(default)* — OWASP, SOC 2, ISO 27001
218
+ - `nz` — ISO 27001, HISO 10029, NZ Privacy Act, NZISM (for NZ health/government engagements)
219
+ - `all` — every framework
220
+ - a comma list of aliases, e.g. `owasp,iso,nzism`
221
+
222
+ > **Not an attestation.** A control rendering "No findings detected" means this audit's checks surfaced no issues mapped to it — it is **not** a statement of compliance or certification. See [Scope & Liability](#scope--liability).
223
+
224
+ ## Scope & Liability
225
+
226
+ **What this tool is.** A read-only, point-in-time configuration review. Every check uses standard Salesforce SOQL, Tooling, and REST **GET** queries only — the tool performs no DML, no metadata deployments, and never modifies the target org or its data. It runs under the permissions of the authenticated `sf` user; checks that the user cannot access are reported as *inconclusive* rather than passing silently.
227
+
228
+ **What this tool is not.** It is **not** a penetration test, a dynamic/runtime security test, or a source-code audit of managed-package internals. It does not exploit vulnerabilities, attempt privilege escalation, or guarantee detection of every misconfiguration. The Health Score and A–F grade are **prioritisation aids**, not certifications, and do not represent compliance with, or accreditation under, any standard (OWASP, SOC 2, ISO 27001, HIPAA, GDPR, or otherwise). Compliance-framework tags indicate *relevance* to a control area only.
229
+
230
+ **Point-in-time.** Results reflect org configuration **at the moment the audit ran**. Configuration drift, new customisations, and platform changes can invalidate findings at any time. Re-run regularly (see [History & Diff](#history--diff)).
231
+
232
+ **Authorisation.** Run this tool only against orgs you own or are **explicitly authorised in writing** to assess. You are responsible for obtaining the necessary permissions and for handling generated reports — which may contain sensitive security configuration — in accordance with your organisation's data-handling and confidentiality obligations.
233
+
234
+ **No warranty.** This software is provided "as is", without warranty of any kind, express or implied. To the maximum extent permitted by law, the authors and CloudCounsel Limited accept no liability for any loss, damage, or claim arising from use of this tool or reliance on its output. Findings are informational and should be validated by a qualified Salesforce security practitioner before any remediation action is taken.
113
235
 
114
236
  ## Scoring
115
237
 
@@ -182,11 +304,86 @@ sf audit security --target-org myOrg --scoring-config ./my-scoring.json
182
304
 
183
305
  Your config is deep-merged with the defaults, so you only need to include the values you want to change.
184
306
 
307
+ ## History & Diff
308
+
309
+ Every `sf audit security` run automatically archives a JSON copy of the report to:
310
+
311
+ ```
312
+ ~/.sf/audit-history/{orgId}/sf-audit-{orgId}-{timestamp}.json
313
+ ```
314
+
315
+ No configuration needed — archiving happens silently after each run.
316
+
317
+ ### View Audit History
318
+
319
+ Show how your org's security posture has changed across multiple runs:
320
+
321
+ ```bash
322
+ sf audit history --target-org myOrg
323
+ ```
324
+
325
+ Prints a terminal table with score trends and writes an HTML timeline to the current directory.
326
+
327
+ **Flags:**
328
+
329
+ | Flag | Description | Default |
330
+ |------|-------------|---------|
331
+ | `--target-org` | Org alias or username | required |
332
+ | `--reports-dir` | Custom directory containing archived reports | `~/.sf/audit-history/{orgId}` |
333
+ | `--output` | Directory to write the HTML timeline | `.` (cwd) |
334
+ | `--limit` | Maximum number of most-recent runs to show | all |
335
+
336
+ **Example output:**
337
+
338
+ ```
339
+ Audit History: My Org (00D000000000001)
340
+ ────────────────────────────────────────────────────────────────────────────────
341
+ # Date Score Grade CRIT HIGH MED LOW Δ Score
342
+ ────────────────────────────────────────────────────────────────────────────────
343
+ 1 2026-03-23 15:10 64 D 1 5 8 3 —
344
+ 2 2026-04-09 11:22 81 B 0 2 5 3 +17
345
+ ────────────────────────────────────────────────────────────────────────────────
346
+ Trend: ▲ +17 over 2 audits Best: 81 (2026-04-09 11:22) Worst: 64 (2026-03-23 15:10)
347
+ ```
348
+
349
+ ### Diff Two Reports
350
+
351
+ Compare any two audit JSON files to see exactly what changed:
352
+
353
+ ```bash
354
+ sf audit diff baseline.json current.json
355
+ ```
356
+
357
+ Writes an HTML and JSON diff report to the current directory.
358
+
359
+ **Flags:**
360
+
361
+ | Flag | Description | Default |
362
+ |------|-------------|---------|
363
+ | `--output` | Directory to write diff reports | `.` (cwd) |
364
+ | `--format` | Comma-separated formats: `html`, `json` | `html,json` |
365
+
366
+ **Example output:**
367
+
368
+ ```
369
+ Diff report written: ./sf-audit-diff-00D000000000001-...-vs-....html
370
+ Diff report written: ./sf-audit-diff-00D000000000001-...-vs-....json
371
+
372
+ ─────────────────────────────
373
+ Diff Summary
374
+ ─────────────────────────────
375
+ Score delta +17
376
+ Grade D → B
377
+ New 0
378
+ Resolved 1
379
+ ─────────────────────────────
380
+ ```
381
+
185
382
  ## Requirements
186
383
 
187
384
  - Node.js 18+
188
385
  - Salesforce CLI (`sf`) v2+
189
- - The authenticated org user needs at least: Read access to setup objects (User, PermissionSet, ApexClass, Flow, etc.) and access to the Tooling API.
386
+ - A least-privilege, **read-only** org user. The audit performs no writes and does **not** require `View All Data`. See **[PERMISSIONS.md](PERMISSIONS.md)** for the exact minimum permission set, what each is for, what the tool does *not* need, and a ready-to-deploy `SF Audit (Read-Only)` permission set ([`docs/permissionset/`](docs/permissionset/SF_Audit_ReadOnly.permissionset-meta.xml)).
190
387
 
191
388
  ## Development
192
389
 
@@ -10,8 +10,11 @@ export class ToolingClientImpl {
10
10
  let records = (result.records ?? []);
11
11
  let nextUrl = result.nextRecordsUrl;
12
12
  // Using conn.request() directly avoids the complex Query<> overload typings
13
- // on tooling.queryMore — the nextRecordsUrl is a plain string handled cleanly here
14
- while (nextUrl) {
13
+ // on tooling.queryMore — the nextRecordsUrl is a plain string handled cleanly here.
14
+ // Circuit breaker: 200 pages × 2000 rows = 400 000 records max before we abort.
15
+ let page = 0;
16
+ while (nextUrl && page < 200) {
17
+ page++;
15
18
  const next = await this.conn.request(nextUrl);
16
19
  records = records.concat(next.records ?? []);
17
20
  nextUrl = next.nextRecordsUrl;
@@ -0,0 +1,20 @@
1
+ import type { RiskLevel } from '../findings/RiskLevel.js';
2
+ import type { Capability } from './Capability.js';
3
+ export interface AttackChainStep {
4
+ findingId: string;
5
+ checkId?: string;
6
+ /** The capability this step contributes to the chain. */
7
+ capability: Capability;
8
+ title?: string;
9
+ severity?: RiskLevel;
10
+ }
11
+ export interface AttackChain {
12
+ id: string;
13
+ title: string;
14
+ severity: RiskLevel;
15
+ confidence: 'named' | 'potential';
16
+ narrative: string;
17
+ remediation: string;
18
+ steps: AttackChainStep[];
19
+ }
20
+ //# sourceMappingURL=AttackChain.d.ts.map
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=AttackChain.js.map
@@ -0,0 +1,7 @@
1
+ export type Capability = 'unauth-foothold' | 'low-trust-authenticated' | 'data-read' | 'data-read-bulk' | 'data-write' | 'code-exec' | 'credential-theft' | 'priv-esc' | 'org-takeover' | 'external-egress';
2
+ export declare const ALL_CAPABILITIES: readonly Capability[];
3
+ /** Capabilities that represent an attacker entry point. */
4
+ export declare const SOURCE_CAPS: readonly Capability[];
5
+ /** Capabilities that represent a high-impact outcome (a chain "sink"). */
6
+ export declare const HIGH_IMPACT_SINKS: readonly Capability[];
7
+ //# sourceMappingURL=Capability.d.ts.map
@@ -0,0 +1,11 @@
1
+ export const ALL_CAPABILITIES = [
2
+ 'unauth-foothold', 'low-trust-authenticated', 'data-read', 'data-read-bulk',
3
+ 'data-write', 'code-exec', 'credential-theft', 'priv-esc', 'org-takeover', 'external-egress',
4
+ ];
5
+ /** Capabilities that represent an attacker entry point. */
6
+ export const SOURCE_CAPS = ['unauth-foothold', 'low-trust-authenticated'];
7
+ /** Capabilities that represent a high-impact outcome (a chain "sink"). */
8
+ export const HIGH_IMPACT_SINKS = [
9
+ 'org-takeover', 'data-write', 'data-read-bulk', 'credential-theft',
10
+ ];
11
+ //# sourceMappingURL=Capability.js.map
@@ -0,0 +1,18 @@
1
+ import type { Capability } from './Capability.js';
2
+ import type { Finding } from '../findings/Finding.js';
3
+ export interface CapabilityEntry {
4
+ grants?: Capability[];
5
+ requires?: Capability[];
6
+ }
7
+ /**
8
+ * The full attack model lives here: finding id → attacker capabilities it grants.
9
+ * Keep this the single source of truth so the ~75 checks stay untouched.
10
+ * Every key MUST correspond to a finding id some check can emit (see registry-integrity test).
11
+ */
12
+ export declare const CAPABILITY_REGISTRY: Record<string, CapabilityEntry>;
13
+ /** Resolve the effective capabilities for a finding (inline overrides registry; passed/inconclusive yield nothing). */
14
+ export declare function capabilitiesFor(finding: Finding): {
15
+ grants: Capability[];
16
+ requires: Capability[];
17
+ };
18
+ //# sourceMappingURL=CapabilityRegistry.d.ts.map
@@ -0,0 +1,53 @@
1
+ /**
2
+ * The full attack model lives here: finding id → attacker capabilities it grants.
3
+ * Keep this the single source of truth so the ~75 checks stay untouched.
4
+ * Every key MUST correspond to a finding id some check can emit (see registry-integrity test).
5
+ */
6
+ export const CAPABILITY_REGISTRY = {
7
+ // Guest / unauthenticated foothold
8
+ 'guest-user-write-access': { grants: ['unauth-foothold', 'data-write', 'data-read'] },
9
+ 'guest-user-read-access': { grants: ['unauth-foothold', 'data-read'] },
10
+ 'guest-user-sharing-exposure': { grants: ['unauth-foothold', 'data-read'] },
11
+ 'guest-user-baseline': { grants: ['unauth-foothold'] },
12
+ // External / portal sharing
13
+ 'sharing-model-external-write': { grants: ['low-trust-authenticated', 'data-write', 'data-read-bulk'] },
14
+ 'sharing-model-external-read': { grants: ['low-trust-authenticated', 'data-read-bulk'] },
15
+ // Apex / code execution surfaces
16
+ 'portal-exposed-apex-without-sharing': { grants: ['code-exec', 'data-read', 'data-write'] },
17
+ 'soql-injection-risk': { grants: ['code-exec', 'data-read-bulk'] },
18
+ // Sensitive data presence
19
+ 'field-level-security-high': { grants: ['data-read'] },
20
+ 'field-level-security-medium': { grants: ['data-read'] },
21
+ // Credential / secret exposure
22
+ 'hardcoded-credentials-found': { grants: ['credential-theft'] },
23
+ 'custom-labels-credential-value-match': { grants: ['credential-theft'] },
24
+ 'custom-labels-credential-name-match': { grants: ['credential-theft'] },
25
+ 'debug-log-active-traces': { grants: ['credential-theft'] },
26
+ // Egress
27
+ 'named-credentials-inventory': { grants: ['external-egress'] },
28
+ 'named-credentials-http-endpoint': { grants: ['external-egress'] },
29
+ 'remote-sites-inventory': { grants: ['external-egress'] },
30
+ // Privileged users
31
+ 'users-modify-all-data': { grants: ['data-read-bulk', 'data-write'] },
32
+ 'users-view-all-data': { grants: ['data-read-bulk'] },
33
+ 'users-super-admin-combo': { grants: ['org-takeover'] },
34
+ 'users-author-apex': { grants: ['code-exec', 'priv-esc'] },
35
+ // New checks (Tasks 8–10)
36
+ 'guest-executable-apex-unprotected': { grants: ['code-exec', 'data-read-bulk', 'data-write'] },
37
+ 'guest-executable-apex-exposed': { grants: ['code-exec'] },
38
+ 'cors-wildcard-origin': { grants: ['credential-theft'] },
39
+ 'cors-broad-origin': { grants: ['credential-theft'] },
40
+ 'escalation-perms-found': { grants: ['priv-esc'] },
41
+ };
42
+ /** Resolve the effective capabilities for a finding (inline overrides registry; passed/inconclusive yield nothing). */
43
+ export function capabilitiesFor(finding) {
44
+ if (finding.passed || finding.inconclusive)
45
+ return { grants: [], requires: [] };
46
+ const inline = finding.capabilities;
47
+ if (inline && (inline.grants || inline.requires)) {
48
+ return { grants: inline.grants ?? [], requires: inline.requires ?? [] };
49
+ }
50
+ const entry = CAPABILITY_REGISTRY[finding.id];
51
+ return { grants: entry?.grants ?? [], requires: entry?.requires ?? [] };
52
+ }
53
+ //# sourceMappingURL=CapabilityRegistry.js.map
@@ -0,0 +1,13 @@
1
+ import type { Finding } from '../findings/Finding.js';
2
+ import type { AttackChain } from './AttackChain.js';
3
+ export declare class ChainEngine {
4
+ correlate(findings: Finding[]): AttackChain[];
5
+ private rank;
6
+ private stepFor;
7
+ private runNamedPass;
8
+ /** Record which (source, sink) capability pairs are already explained by a named chain. */
9
+ private coveredSourceSinkPairs;
10
+ private runEmergentPass;
11
+ private label;
12
+ }
13
+ //# sourceMappingURL=ChainEngine.d.ts.map
@@ -0,0 +1,137 @@
1
+ import { SOURCE_CAPS, HIGH_IMPACT_SINKS } from './Capability.js';
2
+ import { capabilitiesFor } from './CapabilityRegistry.js';
3
+ import { NAMED_CHAINS } from './namedChains.js';
4
+ const SEVERITY_ORDER = {
5
+ CRITICAL: 0, HIGH: 1, MEDIUM: 2, LOW: 3, INFO: 4,
6
+ };
7
+ /** Potential-chain severity by terminal sink (capped at HIGH — named chains own CRITICAL). */
8
+ const SINK_SEVERITY = {
9
+ 'org-takeover': 'HIGH',
10
+ 'data-write': 'HIGH',
11
+ 'data-read-bulk': 'HIGH',
12
+ 'credential-theft': 'MEDIUM',
13
+ };
14
+ const MAX_STEPS = 4;
15
+ export class ChainEngine {
16
+ correlate(findings) {
17
+ const active = findings.filter((f) => !f.passed && !f.inconclusive);
18
+ // Build present capability set + per-finding grants.
19
+ const present = new Set();
20
+ const grantsByFinding = new Map();
21
+ for (const f of active) {
22
+ const grants = capabilitiesFor(f).grants;
23
+ grantsByFinding.set(f, grants);
24
+ for (const c of grants)
25
+ present.add(c);
26
+ }
27
+ const namedChains = this.runNamedPass(present, active, grantsByFinding);
28
+ const covered = this.coveredSourceSinkPairs(namedChains, grantsByFinding);
29
+ const potentialChains = this.runEmergentPass(present, active, grantsByFinding, covered);
30
+ return [...namedChains, ...potentialChains].sort((a, b) => this.rank(a) - this.rank(b));
31
+ }
32
+ rank(c) {
33
+ // named before potential, then by severity
34
+ return (c.confidence === 'named' ? 0 : 100) + SEVERITY_ORDER[c.severity];
35
+ }
36
+ stepFor(f, grants) {
37
+ return {
38
+ findingId: f.id,
39
+ checkId: f.checkId,
40
+ capability: grants[0] ?? 'data-read',
41
+ title: f.title,
42
+ severity: f.riskLevel,
43
+ };
44
+ }
45
+ runNamedPass(present, active, grantsByFinding) {
46
+ const out = [];
47
+ for (const def of NAMED_CHAINS) {
48
+ const members = def.match(present, active);
49
+ if (!members || members.length === 0)
50
+ continue;
51
+ out.push({
52
+ id: def.id,
53
+ title: def.title,
54
+ severity: def.severity,
55
+ confidence: 'named',
56
+ narrative: def.narrative,
57
+ remediation: def.remediation,
58
+ steps: members.map((f) => this.stepFor(f, grantsByFinding.get(f) ?? [])),
59
+ });
60
+ }
61
+ return out;
62
+ }
63
+ /** Record which (source, sink) capability pairs are already explained by a named chain. */
64
+ coveredSourceSinkPairs(named, grantsByFinding) {
65
+ const covered = new Set();
66
+ for (const chain of named) {
67
+ const caps = new Set();
68
+ for (const s of chain.steps)
69
+ caps.add(s.capability);
70
+ for (const src of SOURCE_CAPS) {
71
+ for (const sink of HIGH_IMPACT_SINKS) {
72
+ if (caps.has(src) && caps.has(sink))
73
+ covered.add(`${src}->${sink}`);
74
+ }
75
+ }
76
+ }
77
+ // Also use the raw grants of member findings (capability per step is only the first grant).
78
+ for (const chain of named) {
79
+ const memberCaps = new Set();
80
+ for (const s of chain.steps) {
81
+ const f = [...grantsByFinding.keys()].find((k) => k.id === s.findingId);
82
+ if (f)
83
+ for (const c of grantsByFinding.get(f) ?? [])
84
+ memberCaps.add(c);
85
+ }
86
+ for (const src of SOURCE_CAPS) {
87
+ for (const sink of HIGH_IMPACT_SINKS) {
88
+ if (memberCaps.has(src) && memberCaps.has(sink))
89
+ covered.add(`${src}->${sink}`);
90
+ }
91
+ }
92
+ }
93
+ return covered;
94
+ }
95
+ runEmergentPass(present, active, grantsByFinding, covered) {
96
+ const out = [];
97
+ const seen = new Set();
98
+ for (const src of SOURCE_CAPS) {
99
+ if (!present.has(src))
100
+ continue;
101
+ for (const sink of HIGH_IMPACT_SINKS) {
102
+ if (!present.has(sink))
103
+ continue;
104
+ const key = `${src}->${sink}`;
105
+ if (covered.has(key) || seen.has(key))
106
+ continue;
107
+ seen.add(key);
108
+ // Gather the findings that grant the source and the sink (+ any code-exec bridge).
109
+ const members = [];
110
+ for (const f of active) {
111
+ const g = grantsByFinding.get(f) ?? [];
112
+ if (g.includes(src) || g.includes(sink) || g.includes('code-exec'))
113
+ members.push(f);
114
+ if (members.length >= MAX_STEPS)
115
+ break;
116
+ }
117
+ if (members.length === 0)
118
+ continue;
119
+ out.push({
120
+ id: `potential-${src}-${sink}`,
121
+ title: `Potential attack path: ${this.label(src)} → ${this.label(sink)}`,
122
+ severity: SINK_SEVERITY[sink] ?? 'MEDIUM',
123
+ confidence: 'potential',
124
+ narrative: `The org presents a ${this.label(src)} entry point and findings that grant ` +
125
+ `${this.label(sink)}. Review whether these can be combined into an exploit path.`,
126
+ remediation: 'Treat the contributing findings as a single risk: remediating any one of them breaks the path.',
127
+ steps: members.map((f) => this.stepFor(f, grantsByFinding.get(f) ?? [])),
128
+ });
129
+ }
130
+ }
131
+ return out;
132
+ }
133
+ label(c) {
134
+ return c.replace(/-/g, ' ');
135
+ }
136
+ }
137
+ //# sourceMappingURL=ChainEngine.js.map
@@ -0,0 +1,14 @@
1
+ import type { RiskLevel } from '../findings/RiskLevel.js';
2
+ import type { Finding } from '../findings/Finding.js';
3
+ import type { Capability } from './Capability.js';
4
+ export interface NamedChainDef {
5
+ id: string;
6
+ title: string;
7
+ severity: RiskLevel;
8
+ narrative: string;
9
+ remediation: string;
10
+ /** Returns the member findings (chain steps) if present in this org, else null. */
11
+ match(present: Set<Capability>, active: Finding[]): Finding[] | null;
12
+ }
13
+ export declare const NAMED_CHAINS: NamedChainDef[];
14
+ //# sourceMappingURL=namedChains.d.ts.map