@cclabsnz/sf-audit 1.18.1 → 1.19.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/CHANGELOG.md CHANGED
@@ -9,6 +9,39 @@ published note and carries the signed provenance attestation and CycloneDX SBOM
9
9
 
10
10
  ## [Unreleased]
11
11
 
12
+ ## [v1.19.0](https://github.com/cclabsnz/sf-audit-plugin/releases/tag/v1.19.0) — 2026-10-23
13
+
14
+ When the audit user cannot see who holds Modify All Data or View All Data, the report now says so
15
+ instead of reporting it as passed.
16
+
17
+ ### Fixed
18
+
19
+ - **"0 user(s) have View All / Modify All Data" is no longer reported as passed.** Every org with an active System Administrator has holders of both, so zero means the audit user could not see the assignments. The findings now read "Could not confirm who holds …" and are inconclusive, with advice on what to re-run as.
20
+ - `users-and-admins` reads every batch of permission set assignments, and checks the read against a `COUNT()` of the same query. When the client's row limit (default 10,000, or `org-max-query-limit`) cuts the read short:
21
+ - counts are reported as lower bounds ("At least 8 user(s) …") at that bound's severity, and are never reported as passed;
22
+ - a zero is inconclusive;
23
+ - a new inconclusive finding, `users-and-admins-read-incomplete`, says how much was read. Counts under a reporting threshold may not appear at all, and this finding is the signal.
24
+
25
+ A failed `COUNT()` is treated the same way and no longer fails the check.
26
+ - An unknown or lower-bound Modify All / View All count is shown as "unknown" on the HTML dashboard, not a number, and the history diff does not compare it, including an archived "0 user(s)" from earlier versions. JSON output still carries 0 for these metrics.
27
+
28
+ ### Changed
29
+
30
+ These follow from treating an unreadable count as unknown. They affect runs where the audit user cannot see permission set assignments, or where there are more assignments than the row limit:
31
+
32
+ - The health score drops. A passed finding counts towards the maximum score and an inconclusive one does not, so losing the two passes makes the open findings weigh more.
33
+ - `--fail-on-inconclusive` now exits 3.
34
+ - `users-and-admins` counts as not assessed in evidence coverage, which can cap the grade at B.
35
+ - In SARIF, `executionSuccessful` is false and the findings are listed under `toolExecutionNotifications`.
36
+ - `audit diff` shows the move from passed to inconclusive as a severity change.
37
+
38
+ ### Dependencies
39
+
40
+ - **@oclif/core** 4 → 5.1.8, **@salesforce/sf-plugins-core** 13.0.0 → 13.0.7,
41
+ **@salesforce/core** 9.3.0 → 9.4.0, **zod** 4.4.3 → 4.6.7. No change to commands or flags. (#170)
42
+ - Pinned actions: codeql-action v4.39.0, scorecard-action v2.5.0, upload-artifact v7.0.2.
43
+ (#168, #169, #171, #174)
44
+
12
45
  ## [v1.18.1](https://github.com/cclabsnz/sf-audit-plugin/releases/tag/v1.18.1) — 2026-10-22
13
46
 
14
47
  The HTML report's dashboard now agrees with the score and the executive report.
@@ -14,20 +14,37 @@ export class UsersAndAdminsCheck {
14
14
  // Total active, non-frozen users
15
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
- const broadPermResult = await ctx.soql.query(`SELECT Assignee.Id, Assignee.Username, Assignee.Name, Assignee.Profile.Name,
18
- PermissionSet.Name, PermissionSet.IsOwnedByProfile,
19
- PermissionSet.PermissionsModifyAllData, PermissionSet.PermissionsViewAllData,
20
- PermissionSet.PermissionsManageUsers, PermissionSet.PermissionsCustomizeApplication,
21
- PermissionSet.PermissionsAuthorApex
22
- FROM PermissionSetAssignment
17
+ const psaFrom = `FROM PermissionSetAssignment
23
18
  WHERE (PermissionSet.PermissionsModifyAllData = true
24
19
  OR PermissionSet.PermissionsViewAllData = true
25
20
  OR PermissionSet.PermissionsManageUsers = true
26
21
  OR PermissionSet.PermissionsCustomizeApplication = true
27
22
  OR PermissionSet.PermissionsAuthorApex = true)
28
23
  AND Assignee.IsActive = true
29
- AND AssigneeId NOT IN (SELECT UserId FROM UserLogin WHERE IsFrozen = true)`);
30
- const broadPerms = broadPermResult.records;
24
+ AND AssigneeId NOT IN (SELECT UserId FROM UserLogin WHERE IsFrozen = true)`;
25
+ // queryAll fetches every batch, but the client caps how many rows it will fetch and returns the
26
+ // rest silently. The COUNT() says how many rows there are, so a capped read is detected (INT-004).
27
+ const broadPerms = await ctx.soql.queryAll(`SELECT Assignee.Id, Assignee.Username, Assignee.Name, Assignee.Profile.Name,
28
+ PermissionSet.Name, PermissionSet.IsOwnedByProfile,
29
+ PermissionSet.PermissionsModifyAllData, PermissionSet.PermissionsViewAllData,
30
+ PermissionSet.PermissionsManageUsers, PermissionSet.PermissionsCustomizeApplication,
31
+ PermissionSet.PermissionsAuthorApex
32
+ ${psaFrom}`);
33
+ // `partial` means the rows may be incomplete: the COUNT reports more than came back, or the
34
+ // COUNT itself failed, so completeness cannot be confirmed. Counts are then lower bounds.
35
+ let psaTotal;
36
+ try {
37
+ psaTotal = (await ctx.soql.query(`SELECT COUNT() ${psaFrom}`)).totalSize;
38
+ }
39
+ catch {
40
+ psaTotal = undefined;
41
+ }
42
+ const partial = psaTotal === undefined || psaTotal > broadPerms.length;
43
+ const readNote = psaTotal === undefined
44
+ ? 'whether every assignment was read could not be confirmed'
45
+ : `read ${broadPerms.length} of ${psaTotal} assignments`;
46
+ // "At least N" when the read may be partial: the count is a lower bound, still definite.
47
+ const count = (n) => (partial ? `At least ${n}` : `${n}`);
31
48
  // Group by permission — a user may appear multiple times (once per permission set granting them)
32
49
  const modifyAllUsers = broadPerms.filter((r) => r.PermissionSet.PermissionsModifyAllData);
33
50
  const viewAllUsers = broadPerms.filter((r) => r.PermissionSet.PermissionsViewAllData);
@@ -61,13 +78,43 @@ export class UsersAndAdminsCheck {
61
78
  category: this.category,
62
79
  // Every org needs an administrator: grade on how many hold unrestricted control.
63
80
  riskLevel: sandboxCap(superAdminIds.length > 5 ? 'CRITICAL' : superAdminIds.length > 3 ? 'HIGH' : 'LOW'),
64
- title: `${superAdminIds.length} user(s) hold the super-admin permission combination (ViewAllData + ModifyAllData + ManageUsers)`,
81
+ title: `${count(superAdminIds.length)} user(s) hold the super-admin permission combination (ViewAllData + ModifyAllData + ManageUsers)`,
65
82
  detail: 'SBS-ACS-004 requires documented justification for any user holding all three of ViewAllData, ModifyAllData, and ManageUsers simultaneously. This combination is equivalent to unrestricted org control.' +
66
83
  (superAdminIds.length > 5 ? sandboxNote : ''),
67
84
  remediation: 'Reduce to the minimum necessary permissions. Document justification for each user in the system of record. Consider breaking this into role-specific permission sets.',
68
85
  affectedItems: superAdminItems,
69
86
  });
70
87
  }
88
+ // Every org with an active System Administrator has holders of both permissions, so zero means
89
+ // the assignments were not visible to the audit user, or not all were read. Zero is unknown:
90
+ // inconclusive, never a pass and never an active exposure (INT-004). A non-zero count from a
91
+ // partial read is a definite lower bound, so it stays active at that bound's severity.
92
+ const modifyUnknown = modifyAllCount === 0;
93
+ const viewUnknown = viewAllCount === 0;
94
+ const unknownTitle = (perm) => partial
95
+ ? `Could not confirm who holds ${perm}: ${readNote}`
96
+ : `Could not confirm who holds ${perm}`;
97
+ const unknownDetail = (perm) => partial
98
+ ? `No ${perm} holder was found, but ${readNote}, so holders may be in the rows not read.`
99
+ : `No active user was found holding ${perm}, yet every org with an active System Administrator has at least one. The audit user most likely cannot see PermissionSetAssignment rows, so this is unknown, not clean.`;
100
+ const RAISE_LIMIT = 'Raise the query row limit (sf config set org-max-query-limit, or SF_ORG_MAX_QUERY_LIMIT) above the assignment count and re-run.';
101
+ const SEE_ROWS = 'Re-run as a user with View Setup and Configuration (or View All Users) so permission set assignments are visible.';
102
+ // A capped read needs a higher limit; a failed COUNT says nothing about the limit, so the
103
+ // visibility advice applies too.
104
+ const unknownRemediation = !partial ? SEE_ROWS : psaTotal === undefined ? `${SEE_ROWS} ${RAISE_LIMIT}` : RAISE_LIMIT;
105
+ // On a partial read, a count can also fall under its reporting threshold and not appear at all.
106
+ // This finding is the machine-readable signal for every count from the read (INT-004).
107
+ if (partial) {
108
+ findings.push({
109
+ id: 'users-and-admins-read-incomplete',
110
+ category: this.category,
111
+ riskLevel: 'INFO',
112
+ inconclusive: true,
113
+ title: `Permission assignments were not fully read: ${readNote}`,
114
+ detail: 'Counts of Modify All Data, View All Data, super-admin, Customize Application and Author Apex holders are lower bounds. A count under its reporting threshold, or a super-admin whose permissions fell in the rows not read, may not be reported at all; such a super-admin is rated under Modify All Data instead.',
115
+ remediation: unknownRemediation,
116
+ });
117
+ }
71
118
  // Rate Modify All Data on the holders the super-admin finding does not already cover, so the
72
119
  // same users are not counted towards the grade twice. The finding still lists every holder.
73
120
  const superAdminSet = new Set(superAdminIds);
@@ -79,25 +126,41 @@ export class UsersAndAdminsCheck {
79
126
  findings.push({
80
127
  id: 'users-modify-all-data',
81
128
  category: this.category,
82
- riskLevel: modifyRisk,
83
- title: `${modifyAllCount} user(s) have Modify All Data permission`,
84
- // The population is always reported; at the lowest band it asks for no change.
85
- passed: modifyRisk === 'LOW' || undefined,
86
- detail: 'Modify All Data grants unrestricted write access across all objects. This is one of the most powerful permissions in Salesforce.' +
87
- coveredNote +
88
- (modifyRisk === 'HIGH' && otherModifyAll > 5 ? sandboxNote : ''),
89
- remediation: 'Limit Modify All Data to essential system administrators only. Review each user and remove the permission from any non-essential accounts.',
129
+ riskLevel: modifyUnknown ? 'INFO' : modifyRisk,
130
+ ...(modifyUnknown ? { inconclusive: true } : {}),
131
+ title: modifyUnknown
132
+ ? unknownTitle('Modify All Data')
133
+ : `${count(modifyAllCount)} user(s) have Modify All Data permission`,
134
+ // The population is always reported; at the lowest band it asks for no change. Zero holders
135
+ // is unknown and a partial read is a lower bound, so neither is a pass (INT-004).
136
+ passed: (!modifyUnknown && !partial && modifyRisk === 'LOW') || undefined,
137
+ detail: modifyUnknown
138
+ ? unknownDetail('Modify All Data')
139
+ : 'Modify All Data grants unrestricted write access across all objects. This is one of the most powerful permissions in Salesforce.' +
140
+ coveredNote +
141
+ (modifyRisk === 'HIGH' && otherModifyAll > 5 ? sandboxNote : '') +
142
+ (partial ? ` This is a lower bound: ${readNote}.` : ''),
143
+ remediation: modifyUnknown
144
+ ? unknownRemediation
145
+ : 'Limit Modify All Data to essential system administrators only. Review each user and remove the permission from any non-essential accounts.',
90
146
  affectedItems: modifyAllUsers.map((r) => userItem(r)),
91
147
  });
92
148
  const viewRisk = viewAllCount > 10 ? 'HIGH' : viewAllCount > 5 ? 'MEDIUM' : 'LOW';
93
149
  findings.push({
94
150
  id: 'users-view-all-data',
95
151
  category: this.category,
96
- riskLevel: viewRisk,
97
- title: `${viewAllCount} user(s) have View All Data permission`,
98
- passed: viewRisk === 'LOW' || undefined,
99
- detail: 'View All Data grants unrestricted read access across all objects, bypassing sharing rules and record-level security.',
100
- remediation: 'Limit View All Data to essential users. Consider using permission sets scoped to specific objects instead.',
152
+ riskLevel: viewUnknown ? 'INFO' : viewRisk,
153
+ ...(viewUnknown ? { inconclusive: true } : {}),
154
+ title: viewUnknown
155
+ ? unknownTitle('View All Data')
156
+ : `${count(viewAllCount)} user(s) have View All Data permission`,
157
+ passed: (!viewUnknown && !partial && viewRisk === 'LOW') || undefined,
158
+ detail: viewUnknown
159
+ ? unknownDetail('View All Data')
160
+ : 'View All Data grants unrestricted read access across all objects, bypassing sharing rules and record-level security.' + (partial ? ` This is a lower bound: ${readNote}.` : ''),
161
+ remediation: viewUnknown
162
+ ? unknownRemediation
163
+ : 'Limit View All Data to essential users. Consider using permission sets scoped to specific objects instead.',
101
164
  affectedItems: viewAllUsers.map((r) => userItem(r)),
102
165
  });
103
166
  if (customizeAppCount > 5) {
@@ -105,7 +168,7 @@ export class UsersAndAdminsCheck {
105
168
  id: 'users-customize-application',
106
169
  category: this.category,
107
170
  riskLevel: 'MEDIUM',
108
- title: `${customizeAppCount} user(s) have Customize Application permission`,
171
+ title: `${count(customizeAppCount)} user(s) have Customize Application permission`,
109
172
  detail: 'Customize Application allows users to make metadata changes, including modifying page layouts, custom fields, and application settings.',
110
173
  remediation: 'Customize Application allows metadata changes. Review and reduce to essential configuration administrators.',
111
174
  affectedItems: customizeAppUsers.map((r) => userItem(r)),
@@ -116,7 +179,7 @@ export class UsersAndAdminsCheck {
116
179
  id: 'users-author-apex',
117
180
  category: this.category,
118
181
  riskLevel: 'MEDIUM',
119
- title: `${authorApexCount} user(s) have Author Apex permission`,
182
+ title: `${count(authorApexCount)} user(s) have Author Apex permission`,
120
183
  detail: 'Author Apex allows users to write and deploy Apex code, which can execute server-side logic with elevated privileges.',
121
184
  remediation: 'Author Apex allows code deployment. Limit to developers with a genuine need.',
122
185
  affectedItems: authorApexUsers.map((r) => userItem(r)),
@@ -126,8 +189,10 @@ export class UsersAndAdminsCheck {
126
189
  findings,
127
190
  metrics: {
128
191
  totalActiveUsers,
129
- modifyAllDataUsersCount: modifyAllCount,
130
- viewAllDataUsersCount: viewAllCount,
192
+ // An unknown or lower-bound count is left out rather than reported as an exact number;
193
+ // see unknownMetrics.
194
+ ...(modifyUnknown || partial ? {} : { modifyAllDataUsersCount: modifyAllCount }),
195
+ ...(viewUnknown || partial ? {} : { viewAllDataUsersCount: viewAllCount }),
131
196
  },
132
197
  };
133
198
  }
@@ -0,0 +1,5 @@
1
+ import type { OrgMetrics } from '@cclabsnz/sf-core';
2
+ import type { Finding } from './Finding.js';
3
+ /** Metrics that are unknown in this result, so must not be shown or compared as numbers. */
4
+ export declare function unknownMetrics(findings: Finding[]): Set<keyof OrgMetrics>;
5
+ //# sourceMappingURL=unknownMetrics.d.ts.map
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Metrics whose value is only meaningful when the finding that reports the same count was
3
+ * definite. A result fills missing metrics with 0, so without this an unreadable count shows as a
4
+ * reassuring zero on the dashboard and as an "improvement" in a history diff (INT-004).
5
+ */
6
+ const METRIC_SOURCE = {
7
+ modifyAllDataUsersCount: 'users-modify-all-data',
8
+ viewAllDataUsersCount: 'users-view-all-data',
9
+ };
10
+ /**
11
+ * Whether a source finding gives its metric an exact value. Not when it is missing (the check did
12
+ * not run, or failed) or inconclusive; not when its title is a lower bound ("At least N", a capped
13
+ * read); and not for "0 user(s)", which is how v1.17 and earlier archived an unreadable count.
14
+ */
15
+ function exact(source) {
16
+ if (!source || source.inconclusive === true)
17
+ return false;
18
+ return !/^(At least |0 user\(s\))/.test(source.title);
19
+ }
20
+ /** Metrics that are unknown in this result, so must not be shown or compared as numbers. */
21
+ export function unknownMetrics(findings) {
22
+ const unknown = new Set();
23
+ for (const [key, id] of Object.entries(METRIC_SOURCE)) {
24
+ if (!exact(findings.find((f) => f.id === id)))
25
+ unknown.add(key);
26
+ }
27
+ return unknown;
28
+ }
29
+ //# sourceMappingURL=unknownMetrics.js.map
@@ -1,4 +1,5 @@
1
1
  import { METRIC_META, metricDirection } from './metricMeta.js';
2
+ import { unknownMetrics } from '../findings/unknownMetrics.js';
2
3
  function detailChanged(a, b) {
3
4
  return (a.detail !== b.detail ||
4
5
  a.remediation !== b.remediation ||
@@ -30,9 +31,13 @@ export function computeDiff(baseline, current) {
30
31
  findingChanges.push({ type: 'resolved', finding: prev });
31
32
  }
32
33
  }
33
- // Metric deltas — only emit when before !== after
34
+ // Metric deltas — only emit when before !== after, and only between two known values: an
35
+ // unreadable count is stored as 0, and a drop to it is not an improvement.
36
+ const unknown = new Set([...unknownMetrics(baseline.findings), ...unknownMetrics(current.findings)]);
34
37
  const metricDeltas = [];
35
38
  for (const key of Object.keys(METRIC_META)) {
39
+ if (unknown.has(key))
40
+ continue;
36
41
  const before = baseline.metrics[key];
37
42
  const after = current.metrics[key];
38
43
  if (before === after)
@@ -1,6 +1,7 @@
1
1
  import { esc, firaFontFaceCss, INTERACTIVE_CSP_META } from '@cclabsnz/sf-core';
2
2
  import { renderAttackChainDagSvg } from './AttackChainDagRenderer.js';
3
3
  import { coverageSummary, coverageAdvice } from '../findings/coverage.js';
4
+ import { unknownMetrics } from '../findings/unknownMetrics.js';
4
5
  const RISK_COLORS = {
5
6
  CRITICAL: '#dc2626',
6
7
  HIGH: '#ea580c',
@@ -21,6 +22,8 @@ const GRADE_COLOR = {
21
22
  A: '#22c55e', B: '#84cc16', C: '#eab308', D: '#f97316', F: '#ef4444',
22
23
  };
23
24
  // ── Dashboard helpers ────────────────────────────────────────────────────────
25
+ /** The grey used for inconclusive findings. */
26
+ const UNKNOWN_COLOR = '#8b949e';
24
27
  function statusColor(value, warnThreshold, dangerThreshold) {
25
28
  if (value <= warnThreshold)
26
29
  return '#22c55e';
@@ -94,14 +97,19 @@ function buildDashboard(result, counts) {
94
97
  <div class="kpi-value" style="color:${RISK_COLORS[l]}">${counts[l] ?? 0}</div>
95
98
  <div class="kpi-label">${l}</div>
96
99
  </div>`).join('');
97
- // Users & Access
98
- const modifyColor = statusColor(m.modifyAllDataUsersCount, 2, 5);
99
- const viewColor = statusColor(m.viewAllDataUsersCount, 5, 15);
100
+ // Users & Access. A count the audit could not read is shown as unknown, never as a green 0.
101
+ const unknown = unknownMetrics(result.findings);
102
+ const countRow = (label, key, warn, danger) => {
103
+ if (unknown.has(key))
104
+ return metricRow(label, 'unknown', UNKNOWN_COLOR);
105
+ const color = statusColor(m[key], warn, danger);
106
+ return metricRow(label, m[key], color, m.totalActiveUsers > 0 ? progressBar(m[key], m.totalActiveUsers, color) : '');
107
+ };
100
108
  const inactiveColor = statusColor(m.inactiveUsers90d, 0, 5);
101
109
  const usersCard = inventoryCard('Users & Access', [
102
110
  metricRow('Active Users', m.totalActiveUsers),
103
- metricRow('Modify All Data', m.modifyAllDataUsersCount, modifyColor, m.totalActiveUsers > 0 ? progressBar(m.modifyAllDataUsersCount, m.totalActiveUsers, modifyColor) : ''),
104
- metricRow('View All Data', m.viewAllDataUsersCount, viewColor, m.totalActiveUsers > 0 ? progressBar(m.viewAllDataUsersCount, m.totalActiveUsers, viewColor) : ''),
111
+ countRow('Modify All Data', 'modifyAllDataUsersCount', 2, 5),
112
+ countRow('View All Data', 'viewAllDataUsersCount', 5, 15),
105
113
  metricRow('Inactive 90d', m.inactiveUsers90d, inactiveColor),
106
114
  metricRow('Profiles', m.profileCount),
107
115
  metricRow('Permission Sets', m.permissionSetCount),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cclabsnz/sf-audit",
3
- "version": "1.18.1",
3
+ "version": "1.19.0",
4
4
  "description": "Read-only Salesforce security audit for the sf CLI: 109 checks, attack-chain correlation, A-F risk grading, compliance mapping, free EventLogFile capture, and Guest User Anomaly investigation.",
5
5
  "keywords": [
6
6
  "salesforce",
@@ -47,7 +47,7 @@
47
47
  },
48
48
  "dependencies": {
49
49
  "@cclabsnz/sf-core": "^0.11.0",
50
- "@oclif/core": "^4",
50
+ "@oclif/core": "^5",
51
51
  "@salesforce/core": "^9.3.0",
52
52
  "@salesforce/sf-plugins-core": "^13",
53
53
  "chart.js": "^4.5.1",