@cclabsnz/sf-audit 1.1.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.
- package/LICENSE +201 -0
- package/README.md +168 -38
- package/lib/chains/namedChains.js +4 -4
- package/lib/checks/CheckEngine.js +1 -1
- package/lib/checks/impl/AnonymousApexAuditCheck.js +5 -5
- package/lib/checks/impl/ApexCrudFLSCheck.d.ts +1 -1
- package/lib/checks/impl/ApexCrudFLSCheck.js +4 -4
- package/lib/checks/impl/ApexLoggingCheck.js +10 -10
- package/lib/checks/impl/ApexRestEndpointCheck.js +5 -5
- package/lib/checks/impl/ApexSharingCheck.js +3 -3
- package/lib/checks/impl/ApiClientPermissionCheck.js +2 -2
- package/lib/checks/impl/CertificateExpiryCheck.js +1 -1
- package/lib/checks/impl/ConnectedAppInactivityCheck.d.ts +1 -1
- package/lib/checks/impl/ConnectedAppInactivityCheck.js +5 -5
- package/lib/checks/impl/ConnectedAppScopeCheck.d.ts +1 -1
- package/lib/checks/impl/ConnectedAppScopeCheck.js +4 -4
- package/lib/checks/impl/ConnectedAppsCheck.js +2 -2
- package/lib/checks/impl/ContentLinksCheck.js +6 -6
- package/lib/checks/impl/CorsAllowlistCheck.js +3 -3
- package/lib/checks/impl/CustomLabelsCredentialCheck.d.ts +1 -1
- package/lib/checks/impl/CustomLabelsCredentialCheck.js +7 -7
- package/lib/checks/impl/DataClassificationCheck.js +6 -6
- package/lib/checks/impl/DebugLogAccessCheck.js +6 -6
- package/lib/checks/impl/DeploymentIdentityCheck.js +8 -8
- package/lib/checks/impl/EmailSecurityCheck.d.ts +10 -0
- package/lib/checks/impl/EmailSecurityCheck.js +117 -0
- package/lib/checks/impl/EnhancedDomainsCheck.d.ts +1 -1
- package/lib/checks/impl/EnhancedDomainsCheck.js +6 -6
- package/lib/checks/impl/EscalationPermsCheck.js +2 -2
- package/lib/checks/impl/EventMonitoringCheck.js +6 -6
- package/lib/checks/impl/ExperienceCloudSiteCheck.js +3 -3
- package/lib/checks/impl/FailedLoginCheck.js +5 -5
- package/lib/checks/impl/FieldHistoryTrackingCheck.js +3 -3
- package/lib/checks/impl/FieldLevelSecurityCheck.js +2 -2
- package/lib/checks/impl/GuestExecutableApexCheck.d.ts +1 -1
- package/lib/checks/impl/GuestExecutableApexCheck.js +5 -5
- package/lib/checks/impl/GuestUserAccessCheck.js +5 -5
- package/lib/checks/impl/HealthCheckCheck.js +2 -2
- package/lib/checks/impl/HighAssuranceSessionCheck.js +4 -4
- package/lib/checks/impl/InstalledPackagesCheck.js +5 -5
- package/lib/checks/impl/IntegrationUsersCheck.js +5 -5
- package/lib/checks/impl/InternalUserMfaCheck.js +2 -2
- package/lib/checks/impl/IpRestrictionsCheck.js +3 -3
- package/lib/checks/impl/LegacyApiVersionCheck.js +1 -1
- package/lib/checks/impl/MfaEnforcementCheck.js +3 -3
- package/lib/checks/impl/MfaMethodStrengthCheck.js +3 -3
- package/lib/checks/impl/MfaRegistrationCheck.js +2 -2
- package/lib/checks/impl/MyDomainLoginPolicyCheck.d.ts +1 -1
- package/lib/checks/impl/MyDomainLoginPolicyCheck.js +9 -9
- package/lib/checks/impl/NamedCredentialsCheck.js +3 -3
- package/lib/checks/impl/OutboundMessagesCheck.d.ts +10 -0
- package/lib/checks/impl/OutboundMessagesCheck.js +88 -0
- package/lib/checks/impl/PasswordSessionPolicyCheck.js +3 -3
- package/lib/checks/impl/PermissionsCheck.js +3 -3
- package/lib/checks/impl/PrivilegedAccessCheck.d.ts +11 -0
- package/lib/checks/impl/PrivilegedAccessCheck.js +111 -0
- package/lib/checks/impl/PublicContentExposureCheck.d.ts +10 -0
- package/lib/checks/impl/PublicContentExposureCheck.js +98 -0
- package/lib/checks/impl/PublicGroupSharingCheck.js +1 -1
- package/lib/checks/impl/ReleaseUpdatesCheck.js +2 -2
- package/lib/checks/impl/RemoteSitesCheck.js +1 -1
- package/lib/checks/impl/ReportFolderAccessCheck.d.ts +1 -1
- package/lib/checks/impl/ReportFolderAccessCheck.js +4 -4
- package/lib/checks/impl/ScheduledApexCheck.js +1 -1
- package/lib/checks/impl/SeparationOfDutiesCheck.d.ts +11 -0
- package/lib/checks/impl/SeparationOfDutiesCheck.js +114 -0
- package/lib/checks/impl/SharingModelCheck.d.ts +1 -1
- package/lib/checks/impl/SharingModelCheck.js +8 -8
- package/lib/checks/impl/SiemIntegrationCheck.js +4 -4
- package/lib/checks/impl/SsoEnforcementCheck.js +5 -5
- package/lib/checks/impl/StandardProfilesCheck.js +2 -2
- package/lib/checks/impl/TransactionSecurityPolicyCheck.js +2 -2
- package/lib/checks/impl/TrustedIPRangesCheck.js +5 -5
- package/lib/checks/impl/VisualforceXssCheck.js +6 -6
- package/lib/checks/permCatalog.d.ts +15 -0
- package/lib/checks/permCatalog.js +42 -0
- package/lib/checks/registry.js +12 -0
- package/lib/commands/audit/diff.js +1 -1
- package/lib/commands/audit/security.d.ts +5 -0
- package/lib/commands/audit/security.js +33 -4
- package/lib/compliance/catalogs/hiso10029.d.ts +3 -0
- package/lib/compliance/catalogs/hiso10029.js +35 -0
- package/lib/compliance/catalogs/index.d.ts +4 -0
- package/lib/compliance/catalogs/index.js +21 -0
- package/lib/compliance/catalogs/iso27001.d.ts +3 -0
- package/lib/compliance/catalogs/iso27001.js +39 -0
- package/lib/compliance/catalogs/nzism.d.ts +3 -0
- package/lib/compliance/catalogs/nzism.js +31 -0
- package/lib/compliance/catalogs/owasp.d.ts +3 -0
- package/lib/compliance/catalogs/owasp.js +37 -0
- package/lib/compliance/catalogs/privacyAct.d.ts +3 -0
- package/lib/compliance/catalogs/privacyAct.js +17 -0
- package/lib/compliance/catalogs/sbs.d.ts +3 -0
- package/lib/compliance/catalogs/sbs.js +61 -0
- package/lib/compliance/catalogs/soc2.d.ts +3 -0
- package/lib/compliance/catalogs/soc2.js +42 -0
- package/lib/compliance/mapping.d.ts +2 -0
- package/lib/compliance/mapping.js +118 -0
- package/lib/compliance/resolve.d.ts +12 -0
- package/lib/compliance/resolve.js +49 -0
- package/lib/compliance/types.d.ts +13 -0
- package/lib/compliance/types.js +2 -0
- package/lib/context/AuditCache.d.ts +9 -0
- package/lib/findings/CheckMeta.d.ts +9 -0
- package/lib/findings/CheckMeta.js +72 -0
- package/lib/renderers/AuditRenderer.d.ts +2 -0
- package/lib/renderers/ClientReportRenderer.d.ts +29 -0
- package/lib/renderers/ClientReportRenderer.js +205 -0
- package/lib/renderers/DiffHtmlRenderer.js +1 -1
- package/lib/renderers/HistoryRenderer.js +1 -1
- package/lib/renderers/HtmlRenderer.js +4 -10
- package/lib/renderers/MarkdownRenderer.js +2 -2
- package/lib/renderers/html-utils.d.ts +2 -0
- package/lib/renderers/html-utils.js +8 -0
- package/lib/report/ComplianceMatrix.d.ts +19 -0
- package/lib/report/ComplianceMatrix.js +47 -0
- package/lib/report/ExecutivePriorities.d.ts +8 -0
- package/lib/report/ExecutivePriorities.js +22 -0
- package/lib/report/RemediationRoadmap.d.ts +9 -0
- package/lib/report/RemediationRoadmap.js +18 -0
- package/lib/report/branding.d.ts +18 -0
- package/lib/report/branding.js +19 -0
- package/lib/report/fonts.d.ts +2 -0
- package/lib/report/fonts.js +22 -0
- package/messages/audit.security.md +30 -2
- package/package.json +3 -1
- package/src/assets/fonts/dm-sans-italic-latin.woff2 +0 -0
- package/src/assets/fonts/dm-sans-normal-latin.woff2 +0 -0
- package/src/assets/fonts/dm-serif-display-italic-latin.woff2 +0 -0
- package/src/assets/fonts/dm-serif-display-normal-latin.woff2 +0 -0
- package/config/queries/soql.json +0 -24
- package/config/queries/tooling.json +0 -28
- package/config/scoring.json +0 -17
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2026 CloudCounsel Limited
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
# @cclabsnz/sf-audit
|
|
2
2
|
|
|
3
|
-
A Salesforce CLI (`sf`) plugin that runs a
|
|
3
|
+
A Salesforce CLI (`sf`) plugin that runs a complete, **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
|
+
- **66 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
|
|
34
|
+
This runs all 66 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
|
-
| `--fail-on` |
|
|
37
|
-
| `--checks` | *(all)* | Comma-separated check IDs to run instead of all
|
|
38
|
-
| `--scoring-config` |
|
|
43
|
+
| `--fail-on` | (none) | Exit with code 1 if any finding is at or above this severity: `CRITICAL`, `HIGH`, `MEDIUM`, `LOW` |
|
|
44
|
+
| `--checks` | *(all)* | Comma-separated check IDs to run instead of all 66 (e.g. `hardcoded-credentials,apex-sharing`) |
|
|
45
|
+
| `--scoring-config` | (none) | Path to a custom scoring config JSON file to override weights and grade thresholds |
|
|
46
|
+
| `--prepared-for` | (none) | Client name for the executive report cover line |
|
|
47
|
+
| `--branding` | (none) | 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,176 @@ 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
|
|
100
|
+
The audit runs **66 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
|
|
72
|
-
|
|
|
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 &
|
|
111
|
+
### Identity & Authentication
|
|
75
112
|
| Check | What it looks for |
|
|
76
113
|
|-------|------------------|
|
|
77
|
-
|
|
|
78
|
-
|
|
|
79
|
-
|
|
|
80
|
-
|
|
|
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
|
|
127
|
+
| Check | What it looks for |
|
|
128
|
+
|-------|------------------|
|
|
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
|
+
| Privileged Access & Shadow Admins | Effective high-risk permissions per user (profile + permission sets + groups); admin-equivalent users not on the System Administrator profile |
|
|
135
|
+
| Separation of Duties | Toxic permission combinations a single user holds (e.g. Manage Users + Assign Permission Sets, Author Apex + Modify All Data) |
|
|
136
|
+
| Integration / Service Accounts | Non-human identity inventory and excess privilege |
|
|
81
137
|
| Inactive Users | Active licensed users with no login in 90+ days |
|
|
82
138
|
|
|
83
|
-
### Data
|
|
139
|
+
### Data Access & Sharing
|
|
84
140
|
| Check | What it looks for |
|
|
85
141
|
|-------|------------------|
|
|
86
|
-
| Sharing Model |
|
|
87
|
-
| Field
|
|
88
|
-
| Guest User Access | Object permissions and sharing rules granted to unauthenticated guest users |
|
|
142
|
+
| OWD Sharing Model | Org-wide defaults for Account, Contact, Opportunity, Case, Lead (internal + external) |
|
|
143
|
+
| Field-Level Security | Sensitive fields (SSN, credit card, tax ID) exposed to broad permission sets |
|
|
89
144
|
| Public Group Sharing | Sharing rules that grant access to All Internal Users |
|
|
145
|
+
| Report Folder Public Access | Report folders any authenticated user can view |
|
|
146
|
+
| Field History Tracking | History tracking enabled on sensitive standard objects |
|
|
147
|
+
| Data Classification & Encryption | Field data classification usage and Shield Platform Encryption |
|
|
148
|
+
| Flows Without Sharing | Active flows running in system context without sharing enforcement |
|
|
149
|
+
| Content Distribution Links | Public file links missing expiry or passwords, and stale records |
|
|
150
|
+
| Public Static Resources & Documents | Documents marked externally available (anonymous URL access) and static resources cached publicly |
|
|
90
151
|
|
|
91
|
-
###
|
|
152
|
+
### Guest & External-Facing Access
|
|
92
153
|
| Check | What it looks for |
|
|
93
154
|
|-------|------------------|
|
|
94
|
-
|
|
|
95
|
-
|
|
|
96
|
-
|
|
|
97
|
-
|
|
|
155
|
+
| Guest User Access | Object permissions and sharing rules granted to unauthenticated guests |
|
|
156
|
+
| Guest-Executable Apex | Apex that guest profiles can run, flagging `without sharing` classes |
|
|
157
|
+
| Experience Cloud Sites | Live sites with self-registration enabled and guest user presence |
|
|
158
|
+
| CORS Allowlist | Wildcard or overly broad CORS allowlist origins |
|
|
159
|
+
| CSP Trusted Sites | Content Security Policy trusted sites with insecure HTTP (mixed-content) endpoints |
|
|
98
160
|
|
|
99
|
-
###
|
|
161
|
+
### Apex & Code Security
|
|
100
162
|
| Check | What it looks for |
|
|
101
163
|
|-------|------------------|
|
|
102
|
-
| Apex Sharing |
|
|
103
|
-
|
|
|
104
|
-
|
|
|
105
|
-
|
|
|
164
|
+
| Apex Sharing Declarations | Classes classified by sharing declaration (with / without / inherited / omitted) |
|
|
165
|
+
| Apex CRUD/FLS Enforcement | DML or SOQL performed without CRUD/FLS permission checks |
|
|
166
|
+
| Apex REST Endpoints | `@RestResource` classes running `without sharing` |
|
|
167
|
+
| Visualforce XSS | `escape="false"` and unencoded merge fields in Visualforce markup |
|
|
168
|
+
| Hardcoded Credentials | Bearer tokens, Basic auth, API keys, and raw callout URLs in Apex |
|
|
169
|
+
| Code Security & Coverage | Org-wide Apex test coverage, class/trigger counts, and SOQL injection patterns |
|
|
170
|
+
| Scheduled & Batch Apex | Active scheduled and batch Apex jobs |
|
|
171
|
+
| Anonymous Apex Audit | Anonymous Apex executed in the last 90 days (via SetupAuditTrail) |
|
|
172
|
+
| Apex Logging Framework | Persistent logging usage and sensitive data exposed in Apex logs |
|
|
173
|
+
|
|
174
|
+
### Integrations, Connected Apps & Deployments
|
|
175
|
+
| Check | What it looks for |
|
|
176
|
+
|-------|------------------|
|
|
177
|
+
| Connected Apps | Apps not restricted to admin-approved users |
|
|
178
|
+
| Connected App OAuth Scopes | Full OAuth-scope grants and infinite refresh-token policies |
|
|
179
|
+
| Inactive Connected Apps | Apps with no OAuth logins in the past 90 days |
|
|
180
|
+
| Named Credentials | Named credential inventory; credentials not referenced in Apex |
|
|
181
|
+
| Remote Site Settings | Remote sites with protocol security disabled |
|
|
182
|
+
| Outbound Messages | Workflow outbound messages that include a session ID or post to cleartext (http://) endpoints |
|
|
183
|
+
| Email Security & Spoofing | Inbound email services accepting mail from any sender / running Apex unauthenticated, and org-wide send-as addresses open to all profiles |
|
|
184
|
+
| Installed Packages | Managed/unmanaged package inventory; unmanaged or beta packages in production |
|
|
185
|
+
| Deployment Identity | Designated deployment identity and uncontrolled deployment activity |
|
|
186
|
+
|
|
187
|
+
### Secrets & Credential Storage
|
|
188
|
+
| Check | What it looks for |
|
|
189
|
+
|-------|------------------|
|
|
190
|
+
| Custom Settings & Credentials | Custom settings with credential-like names that may store secrets |
|
|
191
|
+
| Custom Labels Credential Exposure | API keys and tokens in globally-readable Custom Labels |
|
|
106
192
|
|
|
107
|
-
###
|
|
193
|
+
### Monitoring & Threat Detection
|
|
108
194
|
| Check | What it looks for |
|
|
109
195
|
|-------|------------------|
|
|
110
|
-
| API Limits | API request consumption vs. daily/concurrent limits |
|
|
111
196
|
| Audit Trail | Permission changes and Login-As events in the setup audit trail |
|
|
112
|
-
|
|
|
197
|
+
| Login Session | Failed login trends, Login-As events, and access from diverse IPs |
|
|
198
|
+
| Failed Login Detection | Brute-force and credential-stuffing patterns (last 7 days) |
|
|
199
|
+
| Transaction Security Policies | Automated threat detection and response policies configured |
|
|
200
|
+
| Active Debug Log Traces | Active TraceFlag records capturing logs, including high-detail traces |
|
|
201
|
+
| Event Monitoring | Event Monitoring enabled with logs covering 30+ days |
|
|
202
|
+
| SIEM Integration Signals | Evidence of SIEM or external monitoring integration |
|
|
203
|
+
|
|
204
|
+
## Compliance frameworks
|
|
205
|
+
|
|
206
|
+
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.
|
|
207
|
+
|
|
208
|
+
| Framework | Version | Notes |
|
|
209
|
+
|-----------|---------|-------|
|
|
210
|
+
| OWASP Top 10 | 2021 | Web application risk categories |
|
|
211
|
+
| SOC 2 | AICPA TSC 2017 | Common Criteria (CC6–CC9) |
|
|
212
|
+
| ISO/IEC 27001 | 2022 | Annex A controls |
|
|
213
|
+
| Security Benchmark for Salesforce (SBS) | current | Salesforce-native benchmark: [docs.securitybenchmark.org](https://docs.securitybenchmark.org) |
|
|
214
|
+
| NZ Privacy Act | 2020 | Information Privacy Principles (IPP 5/9/12) |
|
|
215
|
+
| HISO 10029 | 2022 | NZ Health Information Security Framework |
|
|
216
|
+
| NZISM | v3.8 | NZ Information Security Manual |
|
|
217
|
+
|
|
218
|
+
**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).
|
|
219
|
+
|
|
220
|
+
**Framework packs.** The executive report's compliance matrix is scoped with `--frameworks`:
|
|
221
|
+
|
|
222
|
+
- `universal` *(default)*: OWASP, SOC 2, ISO 27001
|
|
223
|
+
- `nz`: ISO 27001, HISO 10029, NZ Privacy Act, NZISM (for NZ health/government engagements)
|
|
224
|
+
- `all`: every framework
|
|
225
|
+
- a comma list of aliases, e.g. `owasp,iso,nzism`
|
|
226
|
+
|
|
227
|
+
> **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).
|
|
228
|
+
|
|
229
|
+
**Further reading:** [Mapping Salesforce security to NZISM, the NZ Privacy Act and ISO 27001](https://www.softwareinsights.dev/posts/salesforce-security-nzism-nz-privacy-act) and [Why Salesforce Health Cloud needs its own security review](https://www.softwareinsights.dev/posts/salesforce-health-cloud-security-review).
|
|
230
|
+
|
|
231
|
+
## Scope & Liability
|
|
232
|
+
|
|
233
|
+
**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.
|
|
234
|
+
|
|
235
|
+
**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.
|
|
236
|
+
|
|
237
|
+
|
|
238
|
+
**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)).
|
|
239
|
+
|
|
240
|
+
**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.
|
|
241
|
+
|
|
242
|
+
**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
243
|
|
|
114
244
|
## Scoring
|
|
115
245
|
|
|
@@ -137,15 +267,15 @@ The audit produces a **Health Score** (0–100) and a **Grade** (A–F):
|
|
|
137
267
|
|
|
138
268
|
### Custom Scoring Config
|
|
139
269
|
|
|
140
|
-
All weights and grade thresholds are configurable
|
|
270
|
+
All weights and grade thresholds are configurable: no recompile needed. This is useful when your org has a different risk appetite (e.g. you want to penalise hardcoded credentials more heavily, or set stricter grade thresholds).
|
|
141
271
|
|
|
142
|
-
**Step 1
|
|
272
|
+
**Step 1:** Copy the sample config as your starting point:
|
|
143
273
|
|
|
144
274
|
```bash
|
|
145
275
|
cp config/scoring.sample.json my-scoring.json
|
|
146
276
|
```
|
|
147
277
|
|
|
148
|
-
**Step 2
|
|
278
|
+
**Step 2:** Edit the values. All three sections (`riskScores`, `checkWeights`, `gradeThresholds`) are optional: omit any section to keep the defaults.
|
|
149
279
|
|
|
150
280
|
```json
|
|
151
281
|
{
|
|
@@ -174,7 +304,7 @@ cp config/scoring.sample.json my-scoring.json
|
|
|
174
304
|
|
|
175
305
|
The full list of valid `checkWeights` keys (one per check) is in [`config/scoring.sample.json`](config/scoring.sample.json).
|
|
176
306
|
|
|
177
|
-
**Step 3
|
|
307
|
+
**Step 3:** Pass it when running the audit:
|
|
178
308
|
|
|
179
309
|
```bash
|
|
180
310
|
sf audit security --target-org myOrg --scoring-config ./my-scoring.json
|
|
@@ -190,7 +320,7 @@ Every `sf audit security` run automatically archives a JSON copy of the report t
|
|
|
190
320
|
~/.sf/audit-history/{orgId}/sf-audit-{orgId}-{timestamp}.json
|
|
191
321
|
```
|
|
192
322
|
|
|
193
|
-
No configuration needed
|
|
323
|
+
No configuration needed: archiving happens silently after each run.
|
|
194
324
|
|
|
195
325
|
### View Audit History
|
|
196
326
|
|
|
@@ -261,7 +391,7 @@ Diff report written: ./sf-audit-diff-00D000000000001-...-vs-....json
|
|
|
261
391
|
|
|
262
392
|
- Node.js 18+
|
|
263
393
|
- Salesforce CLI (`sf`) v2+
|
|
264
|
-
-
|
|
394
|
+
- 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)).
|
|
265
395
|
|
|
266
396
|
## Development
|
|
267
397
|
|
|
@@ -26,7 +26,7 @@ export const NAMED_CHAINS = [
|
|
|
26
26
|
},
|
|
27
27
|
{
|
|
28
28
|
id: 'standard-to-takeover',
|
|
29
|
-
title: 'Standard user
|
|
29
|
+
title: 'Standard user to org takeover',
|
|
30
30
|
severity: 'CRITICAL',
|
|
31
31
|
narrative: 'A low-trust authenticated user combines with a privilege-escalation permission ' +
|
|
32
32
|
'(assign permission sets, manage users, author apex, modify metadata) to reach full org control.',
|
|
@@ -45,7 +45,7 @@ export const NAMED_CHAINS = [
|
|
|
45
45
|
},
|
|
46
46
|
{
|
|
47
47
|
id: 'cred-theft-pivot',
|
|
48
|
-
title: 'Credential theft
|
|
48
|
+
title: 'Credential theft to external pivot',
|
|
49
49
|
severity: 'CRITICAL',
|
|
50
50
|
narrative: 'Exposed secrets (hardcoded credentials, credentials in custom labels, debug logs, or broad CORS) ' +
|
|
51
51
|
'combine with an external egress path (named credential or remote site) to exfiltrate data to attacker infrastructure.',
|
|
@@ -63,7 +63,7 @@ export const NAMED_CHAINS = [
|
|
|
63
63
|
},
|
|
64
64
|
{
|
|
65
65
|
id: 'soql-injection-read',
|
|
66
|
-
title: 'SOQL injection
|
|
66
|
+
title: 'SOQL injection to mass read',
|
|
67
67
|
severity: 'HIGH',
|
|
68
68
|
narrative: 'Injectable dynamic SOQL combines with bulk data readability to let an attacker extract large datasets.',
|
|
69
69
|
remediation: 'Use bind variables in all dynamic SOQL and enforce CRUD/FLS; restrict bulk read access.',
|
|
@@ -82,7 +82,7 @@ export const NAMED_CHAINS = [
|
|
|
82
82
|
},
|
|
83
83
|
{
|
|
84
84
|
id: 'mfa-bypass-admin',
|
|
85
|
-
title: 'MFA bypass
|
|
85
|
+
title: 'MFA bypass to privileged compromise',
|
|
86
86
|
severity: 'HIGH',
|
|
87
87
|
narrative: 'Weak MFA enforcement or trusted-IP MFA bypass combines with the presence of highly-privileged ' +
|
|
88
88
|
'accounts, so a credential-stuffing or phishing attacker can take over an admin without a second factor.',
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { buildAuditResult } from '../findings/scoring.js';
|
|
2
|
-
import { getComplianceTags } from '../
|
|
2
|
+
import { getComplianceTags } from '../compliance/resolve.js';
|
|
3
3
|
import { ChainEngine } from '../chains/ChainEngine.js';
|
|
4
4
|
const PERMISSION_ERROR_CODES = new Set([
|
|
5
5
|
'INSUFFICIENT_ACCESS_RIGHTS',
|
|
@@ -30,7 +30,7 @@ export class AnonymousApexAuditCheck {
|
|
|
30
30
|
category: this.category,
|
|
31
31
|
riskLevel: 'INFO',
|
|
32
32
|
inconclusive: true,
|
|
33
|
-
title: 'SetupAuditTrail could not be queried
|
|
33
|
+
title: 'SetupAuditTrail could not be queried: anonymous Apex execution cannot be verified',
|
|
34
34
|
detail: 'The SetupAuditTrail object was not accessible. This may indicate insufficient permissions to view the org audit trail.',
|
|
35
35
|
remediation: 'Grant "View Setup and Configuration" permission to the audit user. Review anonymous Apex execution manually in Setup → Audit Trail.',
|
|
36
36
|
affectedItems: [{ label: 'Setup Audit Trail', url: auditTrailUrl }],
|
|
@@ -76,12 +76,12 @@ export class AnonymousApexAuditCheck {
|
|
|
76
76
|
category: this.category,
|
|
77
77
|
riskLevel: 'HIGH',
|
|
78
78
|
title: `${nonAdminUsers.length} non-admin user(s) executed anonymous Apex in the last 90 days`,
|
|
79
|
-
detail: 'Anonymous Apex execution in production is a privileged, hard-to-audit operation. Anon Apex runs as the executing user but leaves no code artifact
|
|
79
|
+
detail: 'Anonymous Apex execution in production is a privileged, hard-to-audit operation. Anon Apex runs as the executing user but leaves no code artifact. It cannot be reviewed, versioned, or rolled back. Non-admin users executing anonymous Apex indicates a significant control gap: these users have Developer Console access in production and can manipulate data or bypass sharing rules without leaving a traceable code change.',
|
|
80
80
|
remediation: 'Remove Developer Console access from non-admin users. Revoke the "Author Apex" permission from all profiles and permission sets that do not require it. All code changes in production must go through a formal deployment process (change sets, Salesforce DX). Review each execution instance to determine what code was run and what data was affected.',
|
|
81
81
|
affectedItems: nonAdminUsers.map((u) => ({
|
|
82
82
|
label: u.username,
|
|
83
83
|
url: auditTrailUrl,
|
|
84
|
-
note: `${u.count} execution(s)
|
|
84
|
+
note: `${u.count} execution(s). Latest: ${new Date(u.latest).toISOString().split('T')[0]}. Profile: ${u.profile}`,
|
|
85
85
|
})),
|
|
86
86
|
});
|
|
87
87
|
}
|
|
@@ -90,13 +90,13 @@ export class AnonymousApexAuditCheck {
|
|
|
90
90
|
id: 'anonymous-apex-admin-only',
|
|
91
91
|
category: this.category,
|
|
92
92
|
riskLevel: 'MEDIUM',
|
|
93
|
-
title: `Anonymous Apex executed by ${adminOnlyUsers.length} admin-profile user(s) in the last 90 days
|
|
93
|
+
title: `Anonymous Apex executed by ${adminOnlyUsers.length} admin-profile user(s) in the last 90 days: monitoring recommended`,
|
|
94
94
|
detail: 'Anonymous Apex execution by administrator-profile users still represents a risk in production: it bypasses change management, leaves no deployable artifact, and cannot be peer-reviewed. Even legitimate use by admins should be tracked, approved, and documented as part of a change management process.',
|
|
95
95
|
remediation: 'Establish a policy requiring pre-approval for any anonymous Apex execution in production. Log approvals in your change management system. Prefer metadata deployments over anonymous Apex for all production data or configuration changes. Consider restricting Developer Console to a dedicated integration user only.',
|
|
96
96
|
affectedItems: adminOnlyUsers.map((u) => ({
|
|
97
97
|
label: u.username,
|
|
98
98
|
url: auditTrailUrl,
|
|
99
|
-
note: `${u.count} execution(s)
|
|
99
|
+
note: `${u.count} execution(s). Latest: ${new Date(u.latest).toISOString().split('T')[0]}. Profile: ${u.profile}`,
|
|
100
100
|
})),
|
|
101
101
|
});
|
|
102
102
|
}
|
|
@@ -4,7 +4,7 @@ export declare class ApexCrudFLSCheck implements SecurityCheck {
|
|
|
4
4
|
readonly id = "apex-crud-fls";
|
|
5
5
|
readonly name = "Apex CRUD/FLS Enforcement";
|
|
6
6
|
readonly category = "Code Security";
|
|
7
|
-
readonly description = "Flags Apex classes that perform DML or SOQL without checking CRUD/FLS permissions
|
|
7
|
+
readonly description = "Flags Apex classes that perform DML or SOQL without checking CRUD/FLS permissions: OWASP Top 10 for Salesforce";
|
|
8
8
|
readonly dependsOnCache: readonly ["apexBodies"];
|
|
9
9
|
run(ctx: AuditContext): Promise<CheckResult>;
|
|
10
10
|
}
|
|
@@ -12,7 +12,7 @@ export class ApexCrudFLSCheck {
|
|
|
12
12
|
id = 'apex-crud-fls';
|
|
13
13
|
name = 'Apex CRUD/FLS Enforcement';
|
|
14
14
|
category = 'Code Security';
|
|
15
|
-
description = 'Flags Apex classes that perform DML or SOQL without checking CRUD/FLS permissions
|
|
15
|
+
description = 'Flags Apex classes that perform DML or SOQL without checking CRUD/FLS permissions: OWASP Top 10 for Salesforce';
|
|
16
16
|
dependsOnCache = ['apexBodies'];
|
|
17
17
|
async run(ctx) {
|
|
18
18
|
const findings = [];
|
|
@@ -24,7 +24,7 @@ export class ApexCrudFLSCheck {
|
|
|
24
24
|
category: this.category,
|
|
25
25
|
riskLevel: 'INFO',
|
|
26
26
|
inconclusive: true,
|
|
27
|
-
title: 'Apex class bodies not available
|
|
27
|
+
title: 'Apex class bodies not available: CRUD/FLS check skipped',
|
|
28
28
|
detail: 'Apex class bodies were not cached. Ensure HardcodedCredentialsCheck runs before this check.',
|
|
29
29
|
remediation: 'Verify registry ordering so HardcodedCredentialsCheck (which populates apexBodies) precedes ApexCrudFLSCheck.',
|
|
30
30
|
});
|
|
@@ -62,7 +62,7 @@ export class ApexCrudFLSCheck {
|
|
|
62
62
|
affectedItems: withoutSharingNoFls.slice(0, 30).map((n) => ({
|
|
63
63
|
label: n,
|
|
64
64
|
url: apexClassesUrl,
|
|
65
|
-
note: '"without sharing" + DML/SOQL + no FLS check
|
|
65
|
+
note: '"without sharing" + DML/SOQL + no FLS check: highest risk',
|
|
66
66
|
})),
|
|
67
67
|
});
|
|
68
68
|
}
|
|
@@ -77,7 +77,7 @@ export class ApexCrudFLSCheck {
|
|
|
77
77
|
affectedItems: withDmlNoFls.slice(0, 30).map((n) => ({
|
|
78
78
|
label: n,
|
|
79
79
|
url: apexClassesUrl,
|
|
80
|
-
note: 'DML/SOQL without FLS check
|
|
80
|
+
note: 'DML/SOQL without FLS check: add Security.stripInaccessible() or isAccessible() guards',
|
|
81
81
|
})),
|
|
82
82
|
});
|
|
83
83
|
}
|