@cclabsnz/sf-audit 0.2.3 → 0.2.4
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/README.md
CHANGED
|
@@ -34,6 +34,8 @@ This runs all 22 security checks against the target org and writes a report to t
|
|
|
34
34
|
| `--format` / `-f` | `html` | Output format(s), comma-separated: `html`, `md`, `json` |
|
|
35
35
|
| `--output` / `-o` | `.` | Directory to write the report file |
|
|
36
36
|
| `--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`) |
|
|
38
|
+
| `--scoring-config` | — | Path to a custom scoring config JSON file to override weights and grade thresholds |
|
|
37
39
|
|
|
38
40
|
### Examples
|
|
39
41
|
|
|
@@ -49,6 +51,12 @@ sf audit security --target-org myOrg --output ./reports
|
|
|
49
51
|
|
|
50
52
|
# Fail CI pipeline on HIGH or CRITICAL findings
|
|
51
53
|
sf audit security --target-org myOrg --fail-on HIGH
|
|
54
|
+
|
|
55
|
+
# Run only specific checks
|
|
56
|
+
sf audit security --target-org myOrg --checks hardcoded-credentials,apex-sharing,guest-user-access
|
|
57
|
+
|
|
58
|
+
# Use a custom scoring config (e.g. stricter weights for your org)
|
|
59
|
+
sf audit security --target-org myOrg --scoring-config ./my-scoring.json
|
|
52
60
|
```
|
|
53
61
|
|
|
54
62
|
The report file is written as `sf-audit-<orgId>-<timestamp>.<ext>` in the output directory (e.g. `sf-audit-00D000000000001-1711234567890.html`).
|
|
@@ -107,8 +115,8 @@ The audit runs 22 checks across 6 categories:
|
|
|
107
115
|
|
|
108
116
|
Each finding is assigned a risk level with a corresponding weight:
|
|
109
117
|
|
|
110
|
-
| Risk Level | Weight |
|
|
111
|
-
|
|
118
|
+
| Risk Level | Default Weight |
|
|
119
|
+
|------------|---------------|
|
|
112
120
|
| CRITICAL | 10 |
|
|
113
121
|
| HIGH | 7 |
|
|
114
122
|
| MEDIUM | 4 |
|
|
@@ -117,8 +125,6 @@ Each finding is assigned a risk level with a corresponding weight:
|
|
|
117
125
|
|
|
118
126
|
The health score is calculated as `100 - (total weight / max possible weight) * 100`, capped at 0.
|
|
119
127
|
|
|
120
|
-
Weights are configurable in [`config/scoring.json`](config/scoring.json) — no recompile needed.
|
|
121
|
-
|
|
122
128
|
The audit produces a **Health Score** (0–100) and a **Grade** (A–F):
|
|
123
129
|
|
|
124
130
|
| Grade | Criteria |
|
|
@@ -129,6 +135,53 @@ The audit produces a **Health Score** (0–100) and a **Grade** (A–F):
|
|
|
129
135
|
| D | Score ≥ 40, no CRITICAL findings |
|
|
130
136
|
| F | Score < 40 or any CRITICAL finding |
|
|
131
137
|
|
|
138
|
+
### Custom Scoring Config
|
|
139
|
+
|
|
140
|
+
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
|
+
|
|
142
|
+
**Step 1** — Copy the sample config as your starting point:
|
|
143
|
+
|
|
144
|
+
```bash
|
|
145
|
+
cp config/scoring.sample.json my-scoring.json
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
**Step 2** — Edit the values. All three sections (`riskScores`, `checkWeights`, `gradeThresholds`) are optional — omit any section to keep the defaults.
|
|
149
|
+
|
|
150
|
+
```json
|
|
151
|
+
{
|
|
152
|
+
"riskScores": {
|
|
153
|
+
"CRITICAL": 10,
|
|
154
|
+
"HIGH": 7,
|
|
155
|
+
"MEDIUM": 4,
|
|
156
|
+
"LOW": 1,
|
|
157
|
+
"INFO": 0
|
|
158
|
+
},
|
|
159
|
+
"checkWeights": {
|
|
160
|
+
"hardcoded-credentials": 10,
|
|
161
|
+
"guest-user-access": 10,
|
|
162
|
+
"users-and-admins": 10,
|
|
163
|
+
"apex-sharing": 7
|
|
164
|
+
},
|
|
165
|
+
"gradeThresholds": {
|
|
166
|
+
"A": { "minScore": 90, "maxHigh": 0 },
|
|
167
|
+
"B": { "minScore": 75, "maxHigh": 1 },
|
|
168
|
+
"C": { "minScore": 60, "maxHigh": 3 },
|
|
169
|
+
"D": { "minScore": 40, "maxCritical": 0 },
|
|
170
|
+
"F": {}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
The full list of valid `checkWeights` keys (one per check) is in [`config/scoring.sample.json`](config/scoring.sample.json).
|
|
176
|
+
|
|
177
|
+
**Step 3** — Pass it when running the audit:
|
|
178
|
+
|
|
179
|
+
```bash
|
|
180
|
+
sf audit security --target-org myOrg --scoring-config ./my-scoring.json
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
Your config is deep-merged with the defaults, so you only need to include the values you want to change.
|
|
184
|
+
|
|
132
185
|
## Requirements
|
|
133
186
|
|
|
134
187
|
- Node.js 18+
|
|
@@ -10,6 +10,7 @@ export class InactiveUsersCheck {
|
|
|
10
10
|
SELECT Id, Username, Name, Profile.Name, LastLoginDate, UserType
|
|
11
11
|
FROM User
|
|
12
12
|
WHERE IsActive = true
|
|
13
|
+
AND Id NOT IN (SELECT UserId FROM UserLogin WHERE IsFrozen = true)
|
|
13
14
|
AND (LastLoginDate < LAST_N_DAYS:90 OR LastLoginDate = null)
|
|
14
15
|
AND UserType = 'Standard'
|
|
15
16
|
ORDER BY LastLoginDate ASC
|
|
@@ -11,11 +11,11 @@ export class UsersAndAdminsCheck {
|
|
|
11
11
|
url: `${baseUrl}/${r.Assignee.Id}`,
|
|
12
12
|
note: `via: ${r.PermissionSet.IsOwnedByProfile ? 'Profile' : r.PermissionSet.Name}`,
|
|
13
13
|
});
|
|
14
|
-
// Total active users
|
|
15
|
-
const activeUsersResult = await ctx.soql.query('SELECT COUNT() FROM User WHERE IsActive = true');
|
|
14
|
+
// Total active, non-frozen users
|
|
15
|
+
const activeUsersResult = await ctx.soql.query('SELECT COUNT() FROM User WHERE IsActive = true AND Id NOT IN (SELECT UserId FROM UserLogin WHERE IsFrozen = true)');
|
|
16
16
|
const totalActiveUsers = activeUsersResult.totalSize;
|
|
17
17
|
// Modify All Data
|
|
18
|
-
const modifyAllResult = await ctx.soql.query('SELECT Assignee.Id, Assignee.Username, Assignee.Name, Assignee.Profile.Name, PermissionSet.Name, PermissionSet.IsOwnedByProfile FROM PermissionSetAssignment WHERE PermissionSet.PermissionsModifyAllData = true AND Assignee.IsActive = true');
|
|
18
|
+
const modifyAllResult = await ctx.soql.query('SELECT Assignee.Id, Assignee.Username, Assignee.Name, Assignee.Profile.Name, PermissionSet.Name, PermissionSet.IsOwnedByProfile FROM PermissionSetAssignment WHERE PermissionSet.PermissionsModifyAllData = true AND Assignee.IsActive = true AND Assignee.Id NOT IN (SELECT UserId FROM UserLogin WHERE IsFrozen = true)');
|
|
19
19
|
const modifyAllUsers = modifyAllResult.records;
|
|
20
20
|
const modifyAllCount = modifyAllUsers.length;
|
|
21
21
|
const modifyRisk = modifyAllCount > 5 ? 'CRITICAL' : modifyAllCount > 3 ? 'HIGH' : 'LOW';
|
|
@@ -29,7 +29,7 @@ export class UsersAndAdminsCheck {
|
|
|
29
29
|
affectedItems: modifyAllUsers.map(userItem),
|
|
30
30
|
});
|
|
31
31
|
// View All Data
|
|
32
|
-
const viewAllResult = await ctx.soql.query('SELECT Assignee.Id, Assignee.Username, Assignee.Name, Assignee.Profile.Name, PermissionSet.Name, PermissionSet.IsOwnedByProfile FROM PermissionSetAssignment WHERE PermissionSet.PermissionsViewAllData = true AND Assignee.IsActive = true');
|
|
32
|
+
const viewAllResult = await ctx.soql.query('SELECT Assignee.Id, Assignee.Username, Assignee.Name, Assignee.Profile.Name, PermissionSet.Name, PermissionSet.IsOwnedByProfile FROM PermissionSetAssignment WHERE PermissionSet.PermissionsViewAllData = true AND Assignee.IsActive = true AND Assignee.Id NOT IN (SELECT UserId FROM UserLogin WHERE IsFrozen = true)');
|
|
33
33
|
const viewAllUsers = viewAllResult.records;
|
|
34
34
|
const viewAllCount = viewAllUsers.length;
|
|
35
35
|
const viewRisk = viewAllCount > 10 ? 'HIGH' : viewAllCount > 5 ? 'MEDIUM' : 'LOW';
|
|
@@ -43,7 +43,7 @@ export class UsersAndAdminsCheck {
|
|
|
43
43
|
affectedItems: viewAllUsers.map(userItem),
|
|
44
44
|
});
|
|
45
45
|
// Customize Application
|
|
46
|
-
const customizeAppResult = await ctx.soql.query('SELECT Assignee.Id, Assignee.Username, Assignee.Profile.Name, PermissionSet.Name, PermissionSet.IsOwnedByProfile FROM PermissionSetAssignment WHERE PermissionSet.PermissionsCustomizeApplication = true AND Assignee.IsActive = true');
|
|
46
|
+
const customizeAppResult = await ctx.soql.query('SELECT Assignee.Id, Assignee.Username, Assignee.Profile.Name, PermissionSet.Name, PermissionSet.IsOwnedByProfile FROM PermissionSetAssignment WHERE PermissionSet.PermissionsCustomizeApplication = true AND Assignee.IsActive = true AND Assignee.Id NOT IN (SELECT UserId FROM UserLogin WHERE IsFrozen = true)');
|
|
47
47
|
const customizeAppUsers = customizeAppResult.records;
|
|
48
48
|
const customizeAppCount = customizeAppUsers.length;
|
|
49
49
|
if (customizeAppCount > 5) {
|
|
@@ -58,7 +58,7 @@ export class UsersAndAdminsCheck {
|
|
|
58
58
|
});
|
|
59
59
|
}
|
|
60
60
|
// Author Apex
|
|
61
|
-
const authorApexResult = await ctx.soql.query('SELECT Assignee.Id, Assignee.Username, Assignee.Profile.Name, PermissionSet.Name, PermissionSet.IsOwnedByProfile FROM PermissionSetAssignment WHERE PermissionSet.PermissionsAuthorApex = true AND Assignee.IsActive = true');
|
|
61
|
+
const authorApexResult = await ctx.soql.query('SELECT Assignee.Id, Assignee.Username, Assignee.Profile.Name, PermissionSet.Name, PermissionSet.IsOwnedByProfile FROM PermissionSetAssignment WHERE PermissionSet.PermissionsAuthorApex = true AND Assignee.IsActive = true AND Assignee.Id NOT IN (SELECT UserId FROM UserLogin WHERE IsFrozen = true)');
|
|
62
62
|
const authorApexUsers = authorApexResult.records;
|
|
63
63
|
const authorApexCount = authorApexUsers.length;
|
|
64
64
|
if (authorApexCount > 3) {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cclabsnz/sf-audit",
|
|
3
|
-
"version": "0.2.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.2.4",
|
|
4
|
+
"description": "Salesforce Security Audit — native sf plugin",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|
|
7
7
|
"scripts": {
|