@cclabsnz/sf-audit 1.3.0 → 1.6.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/README.md +193 -12
- package/lib/api/MetadataClient.d.ts +4 -0
- package/lib/api/MetadataClient.js +2 -0
- package/lib/api/MetadataClientImpl.d.ts +8 -0
- package/lib/api/MetadataClientImpl.js +22 -0
- package/lib/api/RestClient.d.ts +2 -0
- package/lib/api/RestClientImpl.d.ts +2 -0
- package/lib/api/RestClientImpl.js +33 -0
- package/lib/apps/analyzeApps.d.ts +8 -0
- package/lib/apps/analyzeApps.js +19 -0
- package/lib/apps/appResolver.d.ts +4 -0
- package/lib/apps/appResolver.js +50 -0
- package/lib/apps/grantedAccess.d.ts +4 -0
- package/lib/apps/grantedAccess.js +36 -0
- package/lib/apps/leastPrivilege.d.ts +6 -0
- package/lib/apps/leastPrivilege.js +47 -0
- package/lib/apps/renderApps.d.ts +5 -0
- package/lib/apps/renderApps.js +23 -0
- package/lib/apps/standardAppCatalog.d.ts +11 -0
- package/lib/apps/standardAppCatalog.js +14 -0
- package/lib/apps/types.d.ts +64 -0
- package/lib/apps/types.js +2 -0
- package/lib/apps/usageCollector.d.ts +9 -0
- package/lib/apps/usageCollector.js +104 -0
- package/lib/chains/CapabilityRegistry.js +19 -0
- package/lib/chains/namedChains.js +67 -0
- package/lib/checks/eventLogAccess.d.ts +14 -0
- package/lib/checks/eventLogAccess.js +33 -0
- package/lib/checks/impl/AgentActionSurfaceCheck.d.ts +13 -0
- package/lib/checks/impl/AgentActionSurfaceCheck.js +125 -0
- package/lib/checks/impl/AgentChannelExposureCheck.d.ts +15 -0
- package/lib/checks/impl/AgentChannelExposureCheck.js +223 -0
- package/lib/checks/impl/AgentInventoryCheck.d.ts +15 -0
- package/lib/checks/impl/AgentInventoryCheck.js +228 -0
- package/lib/checks/impl/AgentMonitoringCoverageCheck.d.ts +12 -0
- package/lib/checks/impl/AgentMonitoringCoverageCheck.js +97 -0
- package/lib/checks/impl/AgentUserPrivilegeCheck.d.ts +13 -0
- package/lib/checks/impl/AgentUserPrivilegeCheck.js +204 -0
- package/lib/checks/impl/AuthProvidersCheck.d.ts +17 -0
- package/lib/checks/impl/AuthProvidersCheck.js +88 -0
- package/lib/checks/impl/ClassicSitesCheck.d.ts +17 -0
- package/lib/checks/impl/ClassicSitesCheck.js +65 -0
- package/lib/checks/impl/CspTrustedSitesCheck.d.ts +1 -0
- package/lib/checks/impl/CspTrustedSitesCheck.js +10 -1
- package/lib/checks/impl/DataExportAccessCheck.d.ts +19 -0
- package/lib/checks/impl/DataExportAccessCheck.js +79 -0
- package/lib/checks/impl/EncryptionCoverageCheck.d.ts +19 -0
- package/lib/checks/impl/EncryptionCoverageCheck.js +108 -0
- package/lib/checks/impl/EventMonitoringCheck.js +8 -5
- package/lib/checks/impl/ExperienceCspCheck.d.ts +18 -0
- package/lib/checks/impl/ExperienceCspCheck.js +57 -0
- package/lib/checks/impl/ExternalCredentialsCheck.d.ts +17 -0
- package/lib/checks/impl/ExternalCredentialsCheck.js +74 -0
- package/lib/checks/impl/GuestApiAccessCheck.d.ts +19 -0
- package/lib/checks/impl/GuestApiAccessCheck.js +113 -0
- package/lib/checks/impl/GuestObjectExposureCheck.d.ts +44 -0
- package/lib/checks/impl/GuestObjectExposureCheck.js +241 -0
- package/lib/checks/impl/GuestRecordAccessPolicyCheck.d.ts +34 -0
- package/lib/checks/impl/GuestRecordAccessPolicyCheck.js +120 -0
- package/lib/checks/impl/GuestSiteOptionsCheck.d.ts +18 -0
- package/lib/checks/impl/GuestSiteOptionsCheck.js +92 -0
- package/lib/checks/impl/GuestTrafficAnomalyCheck.d.ts +23 -0
- package/lib/checks/impl/GuestTrafficAnomalyCheck.js +343 -0
- package/lib/checks/impl/LoginAccessPolicyCheck.d.ts +26 -0
- package/lib/checks/impl/LoginAccessPolicyCheck.js +117 -0
- package/lib/checks/impl/LoginAnomalyCheck.d.ts +17 -0
- package/lib/checks/impl/LoginAnomalyCheck.js +98 -0
- package/lib/checks/impl/SandboxDataMaskingCheck.d.ts +17 -0
- package/lib/checks/impl/SandboxDataMaskingCheck.js +85 -0
- package/lib/checks/impl/SessionHardeningCheck.d.ts +21 -0
- package/lib/checks/impl/SessionHardeningCheck.js +134 -0
- package/lib/checks/impl/ThreatDetectionCheck.d.ts +17 -0
- package/lib/checks/impl/ThreatDetectionCheck.js +91 -0
- package/lib/checks/impl/TrustedUrlHygieneCheck.d.ts +16 -0
- package/lib/checks/impl/TrustedUrlHygieneCheck.js +198 -0
- package/lib/checks/registry.js +52 -0
- package/lib/commands/audit/apps.d.ts +16 -0
- package/lib/commands/audit/apps.js +64 -0
- package/lib/commands/audit/diff.js +9 -5
- package/lib/commands/audit/events/pull.d.ts +17 -0
- package/lib/commands/audit/events/pull.js +88 -0
- package/lib/commands/audit/security.d.ts +5 -0
- package/lib/commands/audit/security.js +47 -17
- package/lib/compliance/catalogs/index.js +2 -0
- package/lib/compliance/catalogs/owaspLlm.d.ts +3 -0
- package/lib/compliance/catalogs/owaspLlm.js +34 -0
- package/lib/compliance/mapping.js +46 -7
- package/lib/compliance/resolve.js +4 -3
- package/lib/compliance/types.d.ts +1 -1
- package/lib/context/AuditCache.d.ts +31 -0
- package/lib/context/AuditContext.d.ts +6 -0
- package/lib/events/EventBaselineStore.d.ts +16 -0
- package/lib/events/EventBaselineStore.js +55 -0
- package/lib/events/eventLogQuery.d.ts +21 -0
- package/lib/events/eventLogQuery.js +34 -0
- package/lib/events/pullEventLogs.d.ts +51 -0
- package/lib/events/pullEventLogs.js +79 -0
- package/lib/findings/CheckMeta.js +22 -0
- package/lib/lib/wire.d.ts +4 -2
- package/lib/lib/wire.js +5 -1
- package/lib/renderers/ClientReportRenderer.js +1 -1
- package/package.json +16 -2
package/README.md
CHANGED
|
@@ -2,12 +2,14 @@
|
|
|
2
2
|
|
|
3
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
4
|
|
|
5
|
-
- **
|
|
5
|
+
- **88 read-only checks** across identity, access, data, code, integrations, monitoring, and Agentforce / GenAI
|
|
6
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
|
+
- **Compliance mapping:** every finding mapped to **source-verified** controls across 8 frameworks (OWASP, OWASP LLM Top 10, SOC 2, ISO/IEC 27001:2022, Security Benchmark for Salesforce, NZ Privacy Act, HISO 10029, NZISM)
|
|
8
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
9
|
- **History & diff:** archives each run and shows security-posture drift over time
|
|
10
|
-
-
|
|
10
|
+
- **Free event baseline:** `sf audit events pull` captures the org's free daily `EventLogFile` logs to local disk before the 1-day retention window drops them — no Event Monitoring / Shield add-on needed
|
|
11
|
+
- **Connected-app least-privilege:** `sf audit apps` reads the `RestApi` EventLogFile to see which objects each connected app actually uses, compares that against what its run-as user is granted, and reports the over-grant per object and read/write bit — plus a suggested least-privilege permission set
|
|
12
|
+
- Strictly read-only (SOQL/Tooling/REST GETs + Metadata API reads); see [PERMISSIONS.md](PERMISSIONS.md) for the least-privilege access it needs
|
|
11
13
|
|
|
12
14
|
## Installation
|
|
13
15
|
|
|
@@ -31,7 +33,13 @@ sf plugins link .
|
|
|
31
33
|
sf audit security --target-org <orgAlias>
|
|
32
34
|
```
|
|
33
35
|
|
|
34
|
-
This runs all
|
|
36
|
+
This runs all 88 security checks against the target org and writes a report to the current directory.
|
|
37
|
+
|
|
38
|
+
List every available check id (the values you pass to `--checks`):
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
sf audit list
|
|
42
|
+
```
|
|
35
43
|
|
|
36
44
|
### Options
|
|
37
45
|
|
|
@@ -41,12 +49,13 @@ This runs all 66 security checks against the target org and writes a report to t
|
|
|
41
49
|
| `--format` / `-f` | `html` | Output format(s), comma-separated: `html`, `md`, `json`, `executive` |
|
|
42
50
|
| `--output` / `-o` | `.` | Directory to write the report file |
|
|
43
51
|
| `--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
|
|
52
|
+
| `--checks` | *(all)* | Comma-separated check IDs to run instead of all 88 (e.g. `hardcoded-credentials,apex-sharing`) |
|
|
45
53
|
| `--scoring-config` | (none) | Path to a custom scoring config JSON file to override weights and grade thresholds |
|
|
46
54
|
| `--prepared-for` | (none) | Client name for the executive report cover line |
|
|
47
55
|
| `--branding` | (none) | Path to a `report-branding.json` to override CloudCounsel defaults (executive format) |
|
|
48
56
|
| `--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`) |
|
|
57
|
+
| `--frameworks` | `universal` | Compliance matrix scope (executive format): `universal` (OWASP/OWASP LLM/SOC 2/ISO 27001), `nz` (ISO/HISO/Privacy Act/NZISM), `all`, or a comma list (e.g. `owasp,owasp-llm,iso,nzism`) |
|
|
58
|
+
| `--resolve-domains` | `false` | Makes **outbound DNS queries from this machine** to verify CSP trusted domains still resolve (flags unresolvable / parked domains as exfiltration channels). Off by default; a default run contacts **only the target org** and never reaches out to any other host. |
|
|
50
59
|
|
|
51
60
|
### Examples
|
|
52
61
|
|
|
@@ -66,6 +75,10 @@ sf audit security --target-org myOrg --fail-on HIGH
|
|
|
66
75
|
# Run only specific checks
|
|
67
76
|
sf audit security --target-org myOrg --checks hardcoded-credentials,apex-sharing,guest-user-access
|
|
68
77
|
|
|
78
|
+
# Guest / Experience Cloud exposure sweep — the unauthenticated data-leak surface
|
|
79
|
+
# (bulk-read via UI API, guest-owned records defeating Private OWD, file access, self-reg, threat detection)
|
|
80
|
+
sf audit security --target-org myOrg --checks guest-user-access,guest-object-exposure,guest-site-options,guest-executable-apex,experience-cloud-site,threat-detection
|
|
81
|
+
|
|
69
82
|
# Use a custom scoring config (e.g. stricter weights for your org)
|
|
70
83
|
sf audit security --target-org myOrg --scoring-config ./my-scoring.json
|
|
71
84
|
```
|
|
@@ -89,15 +102,15 @@ sf audit security --target-org myOrg --format executive --branding ./report-bran
|
|
|
89
102
|
```
|
|
90
103
|
|
|
91
104
|
Compliance controls are mapped from authoritative, version-pinned sources (OWASP Top 10:2021,
|
|
92
|
-
AICPA TSC, ISO/IEC 27001:2022, the Security Benchmark for
|
|
93
|
-
NZISM). Only source-verified controls render. "No findings detected" is **not** an attestation of
|
|
105
|
+
OWASP Top 10 for LLM Applications 2025, AICPA TSC, ISO/IEC 27001:2022, the Security Benchmark for
|
|
106
|
+
Salesforce, NZ Privacy Act, HISO 10029, NZISM). Only source-verified controls render. "No findings detected" is **not** an attestation of
|
|
94
107
|
compliance (see the report's Scope & Liability section).
|
|
95
108
|
|
|
96
109
|
The report file is written as `sf-audit-<orgId>-<timestamp>.<ext>` in the output directory (e.g. `sf-audit-00D000000000001-1711234567890.html`).
|
|
97
110
|
|
|
98
111
|
## What It Checks
|
|
99
112
|
|
|
100
|
-
The audit runs **
|
|
113
|
+
The audit runs **88 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 ten domains below.
|
|
101
114
|
|
|
102
115
|
### Org Health & Configuration
|
|
103
116
|
| Check | What it looks for |
|
|
@@ -122,6 +135,8 @@ The audit runs **66 read-only checks**. Every finding is risk-rated (CRITICAL
|
|
|
122
135
|
| Login IP Restrictions | Admin profiles missing IP ranges; connected apps with relaxed IP policy |
|
|
123
136
|
| Password & Session Policy | Password complexity, session timeout, and MFA gaps (from Health Check) |
|
|
124
137
|
| Certificate Expiry | Installed certificates nearing expiry (30 / 90 / 180-day thresholds) |
|
|
138
|
+
| Auth Providers & External IdPs | External Auth Providers and SAML SSO configs; flags social/JIT providers that can federate in or auto-provision users |
|
|
139
|
+
| Session & Clickjack Hardening | Clickjack, CSRF, XSS, and content-sniffing settings read authoritatively from SecuritySettings (Health Check cache fallback) with per-setting remediation |
|
|
125
140
|
|
|
126
141
|
### Users, Permissions & Privilege
|
|
127
142
|
| Check | What it looks for |
|
|
@@ -135,6 +150,8 @@ The audit runs **66 read-only checks**. Every finding is risk-rated (CRITICAL
|
|
|
135
150
|
| Separation of Duties | Toxic permission combinations a single user holds (e.g. Manage Users + Assign Permission Sets, Author Apex + Modify All Data) |
|
|
136
151
|
| Integration / Service Accounts | Non-human identity inventory and excess privilege |
|
|
137
152
|
| Inactive Users | Active licensed users with no login in 90+ days |
|
|
153
|
+
| Login-As & Delegated Administration | Delegated-admin groups (SOQL) and the "log in as any user" policy read from SecuritySettings — user-impersonation and scoped-escalation paths |
|
|
154
|
+
| Mass Data Export Access | Profiles/permission sets with Weekly Data Export, or API access combined with View/Modify All Data (bulk-exfil capability) |
|
|
138
155
|
|
|
139
156
|
### Data Access & Sharing
|
|
140
157
|
| Check | What it looks for |
|
|
@@ -145,6 +162,8 @@ The audit runs **66 read-only checks**. Every finding is risk-rated (CRITICAL
|
|
|
145
162
|
| Report Folder Public Access | Report folders any authenticated user can view |
|
|
146
163
|
| Field History Tracking | History tracking enabled on sensitive standard objects |
|
|
147
164
|
| Data Classification & Encryption | Field data classification usage and Shield Platform Encryption |
|
|
165
|
+
| Encryption Coverage for Sensitive Fields | Fields classified PII/PHI (ComplianceGroup) that are NOT encrypted at rest with Shield |
|
|
166
|
+
| Sandbox Data Masking | In sandboxes, populated PII fields (likely unmasked production data); advises running Data Mask |
|
|
148
167
|
| Flows Without Sharing | Active flows running in system context without sharing enforcement |
|
|
149
168
|
| Content Distribution Links | Public file links missing expiry or passwords, and stale records |
|
|
150
169
|
| Public Static Resources & Documents | Documents marked externally available (anonymous URL access) and static resources cached publicly |
|
|
@@ -153,8 +172,14 @@ The audit runs **66 read-only checks**. Every finding is risk-rated (CRITICAL
|
|
|
153
172
|
| Check | What it looks for |
|
|
154
173
|
|-------|------------------|
|
|
155
174
|
| Guest User Access | Object permissions and sharing rules granted to unauthenticated guests |
|
|
175
|
+
| Guest Object Exposure (Bulk Read via UI API) | Auto-discovers guest-readable objects (incl. records exposed by guest ownership despite a Private OWD), then grades them by actual UI-API reachability: objects the UI API models are CRITICAL (GraphQL-pullable), objects readable only in the sharing model but not UI-API-modelled (Calendar, AuthSession, etc.) are separated as MEDIUM, with UserRecordAccess as ground-truth read confirmation |
|
|
156
176
|
| Guest-Executable Apex | Apex that guest profiles can run, flagging `without sharing` classes |
|
|
157
177
|
| Experience Cloud Sites | Live sites with self-registration enabled and guest user presence |
|
|
178
|
+
| Experience Cloud Guest Site Options | Guest file access and guest member visibility on Experience Cloud sites |
|
|
179
|
+
| Secure Guest User Record Access | Verifies the "Secure guest user record access" enforcement is activated — the guardrail that stops guest-owned records defeating a Private OWD (complements Guest Object Exposure) |
|
|
180
|
+
| Guest API & Bulk Access | Guest users granted API Enabled or Bulk API Hard Delete — programmatic bulk read/delete for unauthenticated visitors |
|
|
181
|
+
| Classic Force.com Sites | Active classic (Visualforce) Sites and their guest users — an unauthenticated surface separate from Experience Cloud |
|
|
182
|
+
| Experience Cloud CSP & Lightning Web Security | Advises verifying Strict CSP and Lightning Web Security on live sites (not reliably API-readable) |
|
|
158
183
|
| CORS Allowlist | Wildcard or overly broad CORS allowlist origins |
|
|
159
184
|
| CSP Trusted Sites | Content Security Policy trusted sites with insecure HTTP (mixed-content) endpoints |
|
|
160
185
|
|
|
@@ -178,6 +203,7 @@ The audit runs **66 read-only checks**. Every finding is risk-rated (CRITICAL
|
|
|
178
203
|
| Connected App OAuth Scopes | Full OAuth-scope grants and infinite refresh-token policies |
|
|
179
204
|
| Inactive Connected Apps | Apps with no OAuth logins in the past 90 days |
|
|
180
205
|
| Named Credentials | Named credential inventory; credentials not referenced in Apex |
|
|
206
|
+
| External Credential Authentication | External Credentials using no authentication or a custom (non-standard) scheme |
|
|
181
207
|
| Remote Site Settings | Remote sites with protocol security disabled |
|
|
182
208
|
| Outbound Messages | Workflow outbound messages that include a session ID or post to cleartext (http://) endpoints |
|
|
183
209
|
| Email Security & Spoofing | Inbound email services accepting mail from any sender / running Apex unauthenticated, and org-wide send-as addresses open to all profiles |
|
|
@@ -199,15 +225,42 @@ The audit runs **66 read-only checks**. Every finding is risk-rated (CRITICAL
|
|
|
199
225
|
| Transaction Security Policies | Automated threat detection and response policies configured |
|
|
200
226
|
| Active Debug Log Traces | Active TraceFlag records capturing logs, including high-detail traces |
|
|
201
227
|
| Event Monitoring | Event Monitoring enabled with logs covering 30+ days |
|
|
228
|
+
| Threat Detection Event Storage | Guest User Anomaly / Threat Detection event storage enabled and retaining events |
|
|
229
|
+
| Guest Traffic Anomaly | Scans recent EventLogFile guest requests for anonymizer/hosting source IPs, single-IP bursts, and GraphQL `totalCount` reconnaissance sweeps |
|
|
230
|
+
| Anomalous Successful Logins | Accounts with successful logins from an unusually high number of distinct source IPs (credential-sharing / compromise signature) |
|
|
202
231
|
| SIEM Integration Signals | Evidence of SIEM or external monitoring integration |
|
|
203
232
|
|
|
233
|
+
### AI & Agents (Agentforce / GenAI)
|
|
234
|
+
| Check | What it looks for |
|
|
235
|
+
|-------|------------------|
|
|
236
|
+
| Agent Inventory | Every Agentforce agent, its active version, and its run-as user (inventory findings); flags an active agent whose run-as identity is inactive or frozen |
|
|
237
|
+
| Agent User Privilege | Agent / run-as users with Modify All Data or View All Data, broad object write access, or read access to objects classified as sensitive — the data a prompt injection inherits |
|
|
238
|
+
| Agent Action Surface | Write-capable agent actions (Apex/Flow that create, update, or delete) and agents with an unusually large action surface |
|
|
239
|
+
| Agentforce Channel Exposure | Correlates active agents with the channels that reach them (Experience Cloud sites, embedded deployments, messaging channels); flags guest-reachable exposure |
|
|
240
|
+
| Agentforce Monitoring Coverage | Active agents running with no Event Monitoring capture and no Transaction Security policy (the monitoring gap in the ForcedLeak pattern); points at `sf audit events pull` |
|
|
241
|
+
| Trusted URL Hygiene | Reviews the CSP trusted-sites allowlist for non-Salesforce domains that could be repurposed as exfiltration channels; with `--resolve-domains`, DNS-checks each for unresolvable or parked entries |
|
|
242
|
+
|
|
243
|
+
Two named attack chains correlate these findings: **Prompt injection blast radius** (guest-reachable channel + over-privileged agent user + write-capable actions) and **ForcedLeak pattern** (active agents + a stale/unresolvable trusted URL + no event capture).
|
|
244
|
+
|
|
245
|
+
The five agent-specific checks stay silent in orgs where Agentforce is not enabled (the GenAI objects do not exist, so the inventory records `not-enabled` and the dependent checks return nothing). Trusted URL Hygiene runs everywhere, since the CSP allowlist is an org-wide exfiltration surface regardless of Agentforce.
|
|
246
|
+
|
|
247
|
+
### Known limitations (advisory-only checks)
|
|
248
|
+
|
|
249
|
+
A small number of checks emit an **advisory** rather than a pass/fail verdict because the underlying setting is not exposed to the read APIs this plugin uses (SOQL/Tooling/REST/Metadata read):
|
|
250
|
+
|
|
251
|
+
- **Experience Cloud CSP & Lightning Web Security** — the per-site LWR Content Security Policy level and the Lightning Web Security toggle live inside the site's `ExperienceBundle`, not in a `metadata.read`-able type. The check lists live Experience sites and asks for manual verification. A true detection would require retrieving and parsing the `ExperienceBundle` (retrieve → unzip → read `config/*.json`), which is a larger capability than the current read clients; it is tracked as a future enhancement.
|
|
252
|
+
- **"Administrators Can Log In as Any User"** is a true detection when SecuritySettings is readable; if the Metadata client is unavailable it degrades to a manual-verification advisory.
|
|
253
|
+
|
|
254
|
+
Advisory findings are surfaced as `INFO` and never inflate the health score.
|
|
255
|
+
|
|
204
256
|
## Compliance frameworks
|
|
205
257
|
|
|
206
|
-
Findings are mapped to controls across
|
|
258
|
+
Findings are mapped to controls across eight 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
259
|
|
|
208
260
|
| Framework | Version | Notes |
|
|
209
261
|
|-----------|---------|-------|
|
|
210
262
|
| OWASP Top 10 | 2021 | Web application risk categories |
|
|
263
|
+
| OWASP LLM Top 10 | 2025 | LLM/GenAI application risks (LLM01 Prompt Injection, LLM02 Sensitive Information Disclosure, LLM05 Improper Output Handling, LLM06 Excessive Agency); mapped by the AI & Agents checks |
|
|
211
264
|
| SOC 2 | AICPA TSC 2017 | Common Criteria (CC6–CC9) |
|
|
212
265
|
| ISO/IEC 27001 | 2022 | Annex A controls |
|
|
213
266
|
| Security Benchmark for Salesforce (SBS) | current | Salesforce-native benchmark: [docs.securitybenchmark.org](https://docs.securitybenchmark.org) |
|
|
@@ -219,10 +272,10 @@ Findings are mapped to controls across seven security and privacy frameworks. Th
|
|
|
219
272
|
|
|
220
273
|
**Framework packs.** The executive report's compliance matrix is scoped with `--frameworks`:
|
|
221
274
|
|
|
222
|
-
- `universal` *(default)*: OWASP, SOC 2, ISO 27001
|
|
275
|
+
- `universal` *(default)*: OWASP, OWASP LLM Top 10, SOC 2, ISO 27001
|
|
223
276
|
- `nz`: ISO 27001, HISO 10029, NZ Privacy Act, NZISM (for NZ health/government engagements)
|
|
224
277
|
- `all`: every framework
|
|
225
|
-
- a comma list of aliases, e.g. `owasp,iso,nzism`
|
|
278
|
+
- a comma list of aliases, e.g. `owasp,owasp-llm,iso,nzism` (`owasp-llm` / `llm` selects the OWASP LLM Top 10)
|
|
226
279
|
|
|
227
280
|
> **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
281
|
|
|
@@ -387,6 +440,134 @@ Diff report written: ./sf-audit-diff-00D000000000001-...-vs-....json
|
|
|
387
440
|
─────────────────────────────
|
|
388
441
|
```
|
|
389
442
|
|
|
443
|
+
## Free event baseline
|
|
444
|
+
|
|
445
|
+
Salesforce's free tier exposes **Daily-interval `EventLogFile` logs** (login, API, and error
|
|
446
|
+
activity) on Enterprise/Unlimited/Performance editions and Developer Edition — *without* the paid
|
|
447
|
+
Event Monitoring / Shield add-on. The catch: on the free tier those logs are retained for only
|
|
448
|
+
**~1 day**. Miss a day and that day's activity is gone.
|
|
449
|
+
|
|
450
|
+
`sf audit events pull` captures them to local disk before they expire, so a daily run builds a
|
|
451
|
+
rolling local baseline you own:
|
|
452
|
+
|
|
453
|
+
```bash
|
|
454
|
+
sf audit events pull --target-org myOrg
|
|
455
|
+
```
|
|
456
|
+
|
|
457
|
+
It queries whatever daily event types the org actually exposes, downloads each log's CSV body, and
|
|
458
|
+
saves it to `~/.sf/event-baseline/{orgId}/{EventType}/{LogDate}-{Id}.csv`, plus a per-run manifest.
|
|
459
|
+
It is **read-only** (GET only) and **idempotent**: any log already on disk is skipped, so it is safe
|
|
460
|
+
to run repeatedly. Run it once a day from cron or a scheduled GitHub Action and you beat the 1-day
|
|
461
|
+
retention window with a growing archive — no add-on required.
|
|
462
|
+
|
|
463
|
+
```bash
|
|
464
|
+
# Daily cron entry (07:15) — capture yesterday's logs
|
|
465
|
+
15 7 * * * sf audit events pull --target-org myOrg >> ~/.sf/event-baseline/pull.log 2>&1
|
|
466
|
+
```
|
|
467
|
+
|
|
468
|
+
**Flags:**
|
|
469
|
+
|
|
470
|
+
| Flag | Description | Default |
|
|
471
|
+
|------|-------------|---------|
|
|
472
|
+
| `--target-org` | Org alias or username | required |
|
|
473
|
+
| `--since` | Days of `LogDate` to request (`LAST_N_DAYS` window) | `1` |
|
|
474
|
+
| `--types` | Restrict to specific EventTypes, comma-separated (e.g. `Login,ApiTotalUsage`) | *(all available)* |
|
|
475
|
+
| `--output` / `-o` | Base directory to store logs under | `~/.sf/event-baseline` |
|
|
476
|
+
|
|
477
|
+
```bash
|
|
478
|
+
# Backfill the last 3 days (each still subject to the org's retention)
|
|
479
|
+
sf audit events pull --target-org myOrg --since 3
|
|
480
|
+
|
|
481
|
+
# Only pull login and API-usage logs
|
|
482
|
+
sf audit events pull --target-org myOrg --types Login,ApiTotalUsage
|
|
483
|
+
|
|
484
|
+
# Store under a project-local directory instead of ~/.sf
|
|
485
|
+
sf audit events pull --target-org myOrg --output ./event-baseline
|
|
486
|
+
```
|
|
487
|
+
|
|
488
|
+
> Reading `EventLogFile` requires the **View Event Log Files** permission on the running user (this
|
|
489
|
+
> is in addition to the minimum read-only audit permission set). If it is missing, or the edition
|
|
490
|
+
> does not expose free daily logs, the command exits cleanly with an explanation rather than failing.
|
|
491
|
+
|
|
492
|
+
**Example output:**
|
|
493
|
+
|
|
494
|
+
```
|
|
495
|
+
Pulling free EventLogFile logs for org: My Org (00D000000000001)
|
|
496
|
+
|
|
497
|
+
─────────────────────────────
|
|
498
|
+
Event Baseline Pull
|
|
499
|
+
─────────────────────────────
|
|
500
|
+
Found 7
|
|
501
|
+
Downloaded 7
|
|
502
|
+
Skipped 0 (already saved)
|
|
503
|
+
Total bytes 48213
|
|
504
|
+
─────────────────────────────
|
|
505
|
+
Saved to: ~/.sf/event-baseline/00D000000000001
|
|
506
|
+
Manifest: ~/.sf/event-baseline/00D000000000001/_manifests/manifest-...-....json
|
|
507
|
+
```
|
|
508
|
+
|
|
509
|
+
### Analyzing the captured logs
|
|
510
|
+
|
|
511
|
+
`events pull` is the collection half. To triage those `EventLogFile` CSVs for exploit and
|
|
512
|
+
abuse patterns, use the companion CLI **[sfelf-triage](https://github.com/cclabsnz/sfelf-triage)**.
|
|
513
|
+
It reads downloaded EventLogFile CSVs and emits a per-IP verdict
|
|
514
|
+
(`BENIGN_SCANNER | SUSPICIOUS | LIKELY_ABUSE`), answering *"is this guest/community IP a
|
|
515
|
+
vulnerability scanner or a real threat?"* — with **zero network egress** and no org connection.
|
|
516
|
+
|
|
517
|
+
sfelf-triage reads this plugin's `~/.sf/event-baseline/<orgId>` layout directly, so the two
|
|
518
|
+
tools chain with no glue:
|
|
519
|
+
|
|
520
|
+
```bash
|
|
521
|
+
sf audit events pull --target-org myOrg # capture (this plugin)
|
|
522
|
+
sfelf-triage analyze ~/.sf/event-baseline/<orgId> # triage (companion)
|
|
523
|
+
```
|
|
524
|
+
|
|
525
|
+
See the [sfelf-triage README](https://github.com/cclabsnz/sfelf-triage#readme) for install and usage.
|
|
526
|
+
|
|
527
|
+
## Connected-app least-privilege
|
|
528
|
+
|
|
529
|
+
Connected-app over-privilege was at the centre of the 2025-2026 wave of Salesforce data-theft
|
|
530
|
+
via OAuth: apps authorized with more scope than they use, and integration users with far more
|
|
531
|
+
object access than the app ever touches. The static checks (`connected-apps`, `connected-app-scope`,
|
|
532
|
+
`connected-app-inactivity`) tell you what was *granted*. `sf audit apps` tells you what is actually
|
|
533
|
+
*used*, so it can point at the specific access to remove.
|
|
534
|
+
|
|
535
|
+
```bash
|
|
536
|
+
sf audit apps --target-org myOrg --since 7
|
|
537
|
+
```
|
|
538
|
+
|
|
539
|
+
It reads the `RestApi` `EventLogFile` to see which objects each connected app touched, compares that
|
|
540
|
+
against the objects its run-as user can reach, and reports the over-grant per object and read/write
|
|
541
|
+
bit — plus a generated least-privilege permission set granting exactly what was observed. App IDs are
|
|
542
|
+
resolved to human-readable names (`AppMenuItem` / `ConnectedApplication` / a bundled standard-app
|
|
543
|
+
catalog / `LoginHistory` correlation), and anything unresolved is flagged loudly rather than hidden.
|
|
544
|
+
|
|
545
|
+
It is **read-only**: the suggested permission set is emitted as data, never deployed.
|
|
546
|
+
|
|
547
|
+
**Honest bounds.** `RestApi` attributes roughly half of API traffic to a connected app (the rest is
|
|
548
|
+
UI-API / session traffic), so *used* is a lower bound. Findings carry the observation window and
|
|
549
|
+
attribution rate, and revoke recommendations are suppressed below a soak window and for apps used by
|
|
550
|
+
many interactive users. Reading `EventLogFile` needs the **View Event Log Files** permission (the same
|
|
551
|
+
one `events pull` uses).
|
|
552
|
+
|
|
553
|
+
**Flags:**
|
|
554
|
+
|
|
555
|
+
| Flag | Description | Default |
|
|
556
|
+
|------|-------------|---------|
|
|
557
|
+
| `--target-org` | Org alias or username | required |
|
|
558
|
+
| `--since` | Days of `RestApi` log to analyze | `7` |
|
|
559
|
+
| `--from` | Read `RestApi` CSVs from a local `events pull` baseline dir instead of downloading | *(download)* |
|
|
560
|
+
| `--soak` | Minimum window (days) before asserting revoke recommendations | `7` |
|
|
561
|
+
| `--format` | `table` / `json` / `md` | `table` |
|
|
562
|
+
|
|
563
|
+
```bash
|
|
564
|
+
# Reuse an events-pull baseline instead of downloading again
|
|
565
|
+
sf audit apps --target-org myOrg --from ~/.sf/event-baseline/00Dxxx
|
|
566
|
+
|
|
567
|
+
# Machine-readable output
|
|
568
|
+
sf audit apps --target-org myOrg --format json
|
|
569
|
+
```
|
|
570
|
+
|
|
390
571
|
## Requirements
|
|
391
572
|
|
|
392
573
|
- Node.js 18+
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Connection } from '@salesforce/core';
|
|
2
|
+
import type { MetadataClient } from './MetadataClient.js';
|
|
3
|
+
export declare class MetadataClientImpl implements MetadataClient {
|
|
4
|
+
private readonly conn;
|
|
5
|
+
constructor(conn: Connection);
|
|
6
|
+
read<T = Record<string, unknown>>(type: string, fullName: string): Promise<T | null>;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=MetadataClientImpl.d.ts.map
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export class MetadataClientImpl {
|
|
2
|
+
conn;
|
|
3
|
+
constructor(conn) {
|
|
4
|
+
this.conn = conn;
|
|
5
|
+
}
|
|
6
|
+
async read(type, fullName) {
|
|
7
|
+
// jsforce types `read` to a fixed MetadataType union; we pass through arbitrary
|
|
8
|
+
// type names (e.g. 'SecuritySettings'), so call via a loosened signature.
|
|
9
|
+
const read = this.conn.metadata.read.bind(this.conn.metadata);
|
|
10
|
+
const res = await read(type, fullName);
|
|
11
|
+
if (res == null)
|
|
12
|
+
return null;
|
|
13
|
+
const rec = Array.isArray(res) ? res[0] : res;
|
|
14
|
+
// Metadata.read returns an object with only `fullName`/empty fields when the
|
|
15
|
+
// component does not exist — treat that as "not present".
|
|
16
|
+
if (!rec || typeof rec !== 'object')
|
|
17
|
+
return null;
|
|
18
|
+
const keys = Object.keys(rec).filter((k) => k !== 'fullName');
|
|
19
|
+
return keys.length === 0 ? null : rec;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=MetadataClientImpl.js.map
|
package/lib/api/RestClient.d.ts
CHANGED
|
@@ -4,5 +4,7 @@ export declare class RestClientImpl implements RestClient {
|
|
|
4
4
|
private readonly conn;
|
|
5
5
|
constructor(conn: Connection);
|
|
6
6
|
get<T>(path: string): Promise<T>;
|
|
7
|
+
getRaw(path: string): Promise<string>;
|
|
8
|
+
getRawToFile(path: string, destPath: string): Promise<number>;
|
|
7
9
|
}
|
|
8
10
|
//# sourceMappingURL=RestClientImpl.d.ts.map
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
import { createWriteStream } from 'node:fs';
|
|
2
|
+
import { mkdir, rm, stat } from 'node:fs/promises';
|
|
3
|
+
import { dirname } from 'node:path';
|
|
4
|
+
import { Readable } from 'node:stream';
|
|
5
|
+
import { pipeline } from 'node:stream/promises';
|
|
1
6
|
export class RestClientImpl {
|
|
2
7
|
conn;
|
|
3
8
|
constructor(conn) {
|
|
@@ -8,5 +13,33 @@ export class RestClientImpl {
|
|
|
8
13
|
const normalised = path.startsWith('/') ? path : `/${path}`;
|
|
9
14
|
return this.conn.request(`/services/data/v${version}${normalised}`);
|
|
10
15
|
}
|
|
16
|
+
async getRaw(path) {
|
|
17
|
+
const version = this.conn.getApiVersion();
|
|
18
|
+
const normalised = path.startsWith('/') ? path : `/${path}`;
|
|
19
|
+
// jsforce returns the raw body string for non-JSON content types (text/csv here).
|
|
20
|
+
return this.conn.request(`/services/data/v${version}${normalised}`);
|
|
21
|
+
}
|
|
22
|
+
async getRawToFile(path, destPath) {
|
|
23
|
+
const version = this.conn.getApiVersion();
|
|
24
|
+
const normalised = path.startsWith('/') ? path : `/${path}`;
|
|
25
|
+
// Stream directly from the org to disk with the session bearer token, so the body is never
|
|
26
|
+
// materialised as a JS string (which would fail on logs larger than ~512 MB).
|
|
27
|
+
const url = `${this.conn.instanceUrl}/services/data/v${version}${normalised}`;
|
|
28
|
+
const res = await fetch(url, {
|
|
29
|
+
headers: { Authorization: `Bearer ${this.conn.accessToken ?? ''}` },
|
|
30
|
+
});
|
|
31
|
+
if (!res.ok || !res.body) {
|
|
32
|
+
throw new Error(`Download failed for ${normalised} (HTTP ${res.status})`);
|
|
33
|
+
}
|
|
34
|
+
await mkdir(dirname(destPath), { recursive: true });
|
|
35
|
+
try {
|
|
36
|
+
await pipeline(Readable.fromWeb(res.body), createWriteStream(destPath));
|
|
37
|
+
}
|
|
38
|
+
catch (err) {
|
|
39
|
+
await rm(destPath, { force: true }); // never leave a partial file behind
|
|
40
|
+
throw err;
|
|
41
|
+
}
|
|
42
|
+
return (await stat(destPath)).size;
|
|
43
|
+
}
|
|
11
44
|
}
|
|
12
45
|
//# sourceMappingURL=RestClientImpl.js.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { AppFinding } from './types.js';
|
|
2
|
+
import type { SoqlClient } from '../api/SoqlClient.js';
|
|
3
|
+
export declare function analyzeApps(restApiCsv: string, soql: SoqlClient, opts: {
|
|
4
|
+
since: number;
|
|
5
|
+
soakDays: number;
|
|
6
|
+
soapApiCsv?: string;
|
|
7
|
+
}): Promise<AppFinding[]>;
|
|
8
|
+
//# sourceMappingURL=analyzeApps.d.ts.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { collectUsage } from './usageCollector.js';
|
|
2
|
+
import { resolveApps } from './appResolver.js';
|
|
3
|
+
import { computeGranted } from './grantedAccess.js';
|
|
4
|
+
import { buildFinding } from './leastPrivilege.js';
|
|
5
|
+
export async function analyzeApps(restApiCsv, soql, opts) {
|
|
6
|
+
const usage = collectUsage(restApiCsv, opts.soapApiCsv);
|
|
7
|
+
const appIds = usage.usage.map((u) => u.appId);
|
|
8
|
+
const allUsers = [...new Set(usage.usage.flatMap((u) => u.userIds))];
|
|
9
|
+
const resolved = await resolveApps(appIds, soql, allUsers);
|
|
10
|
+
const resolvedById = new Map(resolved.map((r) => [r.appId, r]));
|
|
11
|
+
const findings = [];
|
|
12
|
+
for (const u of usage.usage) {
|
|
13
|
+
const app = resolvedById.get(u.appId);
|
|
14
|
+
const granted = await computeGranted(u.appId, u.userIds, soql, null);
|
|
15
|
+
findings.push(buildFinding(app, u, granted, { since: opts.since, attributionRatePct: usage.attributionRatePct }, opts.soakDays));
|
|
16
|
+
}
|
|
17
|
+
return findings;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=analyzeApps.js.map
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { lookupStandardApp } from './standardAppCatalog.js';
|
|
2
|
+
const SECURITY_VENDOR = /datadog|defender|appomni|crowdstrike|splunk|siem|sentinel/i;
|
|
3
|
+
const SALESFORCE_VENDOR = /salesforce|dataloader|workbench|force\.com|chatter|salesforcea/i;
|
|
4
|
+
function categorise(name, viaStandard) {
|
|
5
|
+
if (viaStandard)
|
|
6
|
+
return viaStandard;
|
|
7
|
+
if (SECURITY_VENDOR.test(name))
|
|
8
|
+
return 'Security-vendor';
|
|
9
|
+
if (SALESFORCE_VENDOR.test(name))
|
|
10
|
+
return 'Salesforce-standard';
|
|
11
|
+
return 'Org-custom';
|
|
12
|
+
}
|
|
13
|
+
export async function resolveApps(appIds, soql, userIds) {
|
|
14
|
+
const menu = await soql
|
|
15
|
+
.queryAll("SELECT ApplicationId, Label, Name FROM AppMenuItem WHERE Type = 'ConnectedApplication'")
|
|
16
|
+
.catch(() => []);
|
|
17
|
+
const connApps = await soql
|
|
18
|
+
.queryAll('SELECT Id, Name FROM ConnectedApplication')
|
|
19
|
+
.catch(() => []);
|
|
20
|
+
const menuByKey = new Map(menu.map((m) => [m.ApplicationId.slice(0, 15), m.Label ?? m.Name ?? '']));
|
|
21
|
+
const connByKey = new Map(connApps.map((c) => [c.Id.slice(0, 15), c.Name]));
|
|
22
|
+
// Only pay for LoginHistory if some ids are still unresolved after 1-3.
|
|
23
|
+
const stillUnknown = appIds.filter((id) => !menuByKey.has(id.slice(0, 15)) && !connByKey.has(id.slice(0, 15)) && !lookupStandardApp(id));
|
|
24
|
+
let logins = [];
|
|
25
|
+
if (stillUnknown.length > 0 && userIds.length > 0) {
|
|
26
|
+
logins = await soql
|
|
27
|
+
.queryAll(`SELECT Application, UserId FROM LoginHistory WHERE UserId IN (${userIds
|
|
28
|
+
.map((u) => `'${u}'`)
|
|
29
|
+
.join(',')}) AND LoginTime = LAST_N_DAYS:7`)
|
|
30
|
+
.catch(() => []);
|
|
31
|
+
}
|
|
32
|
+
const loginNames = [...new Set(logins.map((l) => l.Application).filter((a) => a && a !== 'Browser' && a !== 'N/A'))];
|
|
33
|
+
return appIds.map((appId) => {
|
|
34
|
+
const key = appId.slice(0, 15);
|
|
35
|
+
const menuName = menuByKey.get(key);
|
|
36
|
+
if (menuName)
|
|
37
|
+
return { appId, name: menuName, category: categorise(menuName, null), confidence: 'resolved' };
|
|
38
|
+
const connName = connByKey.get(key);
|
|
39
|
+
if (connName)
|
|
40
|
+
return { appId, name: connName, category: categorise(connName, null), confidence: 'resolved' };
|
|
41
|
+
const std = lookupStandardApp(appId);
|
|
42
|
+
if (std)
|
|
43
|
+
return { appId, name: std.name, category: std.category, vendor: std.vendor, purpose: std.purpose, confidence: 'resolved' };
|
|
44
|
+
if (loginNames.length === 1) {
|
|
45
|
+
return { appId, name: loginNames[0], category: categorise(loginNames[0], null), confidence: 'inferred' };
|
|
46
|
+
}
|
|
47
|
+
return { appId, name: `Unidentified connected app ${appId}`, category: 'Unidentified', confidence: 'unidentified' };
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=appResolver.js.map
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { GrantedAccess } from './types.js';
|
|
2
|
+
import type { SoqlClient } from '../api/SoqlClient.js';
|
|
3
|
+
export declare function computeGranted(appId: string, runAsUsers: string[], soql: SoqlClient, scope: string | null): Promise<GrantedAccess>;
|
|
4
|
+
//# sourceMappingURL=grantedAccess.d.ts.map
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
const inList = (ids) => ids.map((i) => `'${i}'`).join(',');
|
|
2
|
+
export async function computeGranted(appId, runAsUsers, soql, scope) {
|
|
3
|
+
const multiUserInteractive = runAsUsers.length > 3;
|
|
4
|
+
if (runAsUsers.length === 0 || multiUserInteractive) {
|
|
5
|
+
return { appId, scope, objects: [], runAsUsers, multiUserInteractive };
|
|
6
|
+
}
|
|
7
|
+
const psa = await soql
|
|
8
|
+
.queryAll(`SELECT AssigneeId, PermissionSetId FROM PermissionSetAssignment WHERE AssigneeId IN (${inList(runAsUsers)})`)
|
|
9
|
+
.catch(() => []);
|
|
10
|
+
const psIds = [...new Set(psa.map((p) => p.PermissionSetId))];
|
|
11
|
+
if (psIds.length === 0)
|
|
12
|
+
return { appId, scope, objects: [], runAsUsers, multiUserInteractive };
|
|
13
|
+
const perms = await soql
|
|
14
|
+
.queryAll(`SELECT ParentId, SobjectType, PermissionsRead, PermissionsCreate, PermissionsEdit, PermissionsDelete
|
|
15
|
+
FROM ObjectPermissions WHERE ParentId IN (${inList(psIds)}) AND PermissionsRead = true`)
|
|
16
|
+
.catch(() => []);
|
|
17
|
+
const byObject = new Map();
|
|
18
|
+
for (const p of perms) {
|
|
19
|
+
const verbs = byObject.get(p.SobjectType) ?? new Set();
|
|
20
|
+
if (p.PermissionsRead)
|
|
21
|
+
verbs.add('read');
|
|
22
|
+
if (p.PermissionsCreate || p.PermissionsEdit)
|
|
23
|
+
verbs.add('write');
|
|
24
|
+
if (p.PermissionsDelete)
|
|
25
|
+
verbs.add('delete');
|
|
26
|
+
byObject.set(p.SobjectType, verbs);
|
|
27
|
+
}
|
|
28
|
+
return {
|
|
29
|
+
appId,
|
|
30
|
+
scope,
|
|
31
|
+
objects: [...byObject.entries()].map(([object, verbs]) => ({ object, verbs: [...verbs].sort() })),
|
|
32
|
+
runAsUsers,
|
|
33
|
+
multiUserInteractive,
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=grantedAccess.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { AppFinding, AppUsage, GrantedAccess, ResolvedApp } from './types.js';
|
|
2
|
+
export declare function buildFinding(app: ResolvedApp, used: AppUsage, granted: GrantedAccess, window: {
|
|
3
|
+
since: number;
|
|
4
|
+
attributionRatePct: number;
|
|
5
|
+
}, soakDays: number): AppFinding;
|
|
6
|
+
//# sourceMappingURL=leastPrivilege.d.ts.map
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
export function buildFinding(app, used, granted, window, soakDays) {
|
|
2
|
+
const usedObjects = new Set(used.objects.map((o) => o.object));
|
|
3
|
+
const usedVerbs = new Map(used.objects.map((o) => [o.object, new Set(o.verbs)]));
|
|
4
|
+
const belowSoak = window.since < soakDays;
|
|
5
|
+
const notes = [];
|
|
6
|
+
notes.push(`Observed over ${window.since} day(s); RestApi attribution ${window.attributionRatePct}% — "used" is a lower bound.`);
|
|
7
|
+
if (belowSoak)
|
|
8
|
+
notes.push(`Window below the ${soakDays}-day soak threshold: revoke recommendations suppressed.`);
|
|
9
|
+
if (used.soapOnly)
|
|
10
|
+
notes.push('SOAP usage present but not app-attributable; not treated as dormant.');
|
|
11
|
+
if (granted.multiUserInteractive)
|
|
12
|
+
notes.push('Interactive app with many run-as users; object delta not asserted.');
|
|
13
|
+
const assertDelta = !belowSoak && !granted.multiUserInteractive;
|
|
14
|
+
const unusedObjects = assertDelta
|
|
15
|
+
? granted.objects.map((o) => o.object).filter((o) => !usedObjects.has(o)).sort()
|
|
16
|
+
: [];
|
|
17
|
+
const unusedVerbs = assertDelta
|
|
18
|
+
? granted.objects
|
|
19
|
+
.filter((o) => usedObjects.has(o.object))
|
|
20
|
+
.map((o) => {
|
|
21
|
+
const u = usedVerbs.get(o.object) ?? new Set();
|
|
22
|
+
const extra = o.verbs.filter((v) => !u.has(v)).sort();
|
|
23
|
+
return { object: o.object, verbs: extra };
|
|
24
|
+
})
|
|
25
|
+
.filter((x) => x.verbs.length > 0)
|
|
26
|
+
: [];
|
|
27
|
+
const anyWriteUsed = used.objects.some((o) => o.verbs.some((v) => v === 'write' || v === 'delete'));
|
|
28
|
+
const scopeDowngrade = assertDelta && granted.scope === 'full' && !anyWriteUsed ? 'full -> api' : null;
|
|
29
|
+
const dormant = assertDelta && used.objects.length === 0 && granted.objects.length > 0;
|
|
30
|
+
const objectPermissions = used.objects.map((o) => ({
|
|
31
|
+
object: o.object,
|
|
32
|
+
read: o.verbs.includes('read'),
|
|
33
|
+
create: o.verbs.includes('write'),
|
|
34
|
+
edit: o.verbs.includes('write'),
|
|
35
|
+
delete: o.verbs.includes('delete'),
|
|
36
|
+
}));
|
|
37
|
+
return {
|
|
38
|
+
app,
|
|
39
|
+
window,
|
|
40
|
+
used,
|
|
41
|
+
granted,
|
|
42
|
+
overGrant: { unusedObjects, unusedVerbs, scopeDowngrade, dormant },
|
|
43
|
+
recommendation: { permissionSet: { objectPermissions } },
|
|
44
|
+
notes,
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=leastPrivilege.js.map
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { AppFinding } from './types.js';
|
|
2
|
+
export declare function renderJson(findings: AppFinding[]): string;
|
|
3
|
+
export declare function renderMarkdown(findings: AppFinding[]): string;
|
|
4
|
+
export declare function renderTable(findings: AppFinding[]): string;
|
|
5
|
+
//# sourceMappingURL=renderApps.d.ts.map
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export function renderJson(findings) {
|
|
2
|
+
return JSON.stringify(findings, null, 2);
|
|
3
|
+
}
|
|
4
|
+
export function renderMarkdown(findings) {
|
|
5
|
+
const lines = ['| App | Category | Confidence | Used | Over-granted | Scope |', '|---|---|---|---|---|---|'];
|
|
6
|
+
for (const f of findings) {
|
|
7
|
+
lines.push(`| ${f.app.name} | ${f.app.category} | ${f.app.confidence} | ${f.used.objects.length} objs | ` +
|
|
8
|
+
`${f.overGrant.unusedObjects.length} objs | ${f.overGrant.scopeDowngrade ?? '-'} |`);
|
|
9
|
+
}
|
|
10
|
+
return lines.join('\n');
|
|
11
|
+
}
|
|
12
|
+
export function renderTable(findings) {
|
|
13
|
+
const rows = findings.map((f) => [
|
|
14
|
+
f.app.name,
|
|
15
|
+
f.app.category,
|
|
16
|
+
f.app.confidence,
|
|
17
|
+
`${f.used.objects.length}`,
|
|
18
|
+
`${f.overGrant.unusedObjects.length}`,
|
|
19
|
+
f.overGrant.scopeDowngrade ?? '-',
|
|
20
|
+
].join(' '));
|
|
21
|
+
return ['App Category Confidence Used OverGranted Scope', ...rows].join('\n');
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=renderApps.js.map
|