@cclabsnz/sf-core 0.2.0 → 0.4.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 +111 -0
- package/README.md +32 -8
- package/lib/events/EventBaselineStore.d.ts +16 -5
- package/lib/events/EventBaselineStore.js +72 -25
- package/lib/events/pullEventLogs.js +16 -1
- package/lib/events/pullRealtimeEvents.d.ts +14 -1
- package/lib/events/pullRealtimeEvents.js +35 -14
- package/lib/events/rteCatalog.d.ts +36 -2
- package/lib/events/rteCatalog.js +68 -21
- package/lib/index.d.ts +1 -1
- package/lib/index.js +1 -1
- package/lib/report/branding.js +1 -1
- package/package.json +9 -6
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to `@cclabsnz/sf-core` are recorded here. The format follows
|
|
4
|
+
[Keep a Changelog](https://keepachangelog.com/en/1.1.0/) loosely, and the project uses
|
|
5
|
+
[Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
6
|
+
|
|
7
|
+
Each released entry mirrors the [GitHub Release](https://github.com/cclabsnz/sf-core/releases)
|
|
8
|
+
for that tag, which is the canonical published note and carries the provenance attestation and
|
|
9
|
+
CycloneDX SBOM for the build.
|
|
10
|
+
|
|
11
|
+
## [Unreleased]
|
|
12
|
+
|
|
13
|
+
Merged to `main`, not yet released.
|
|
14
|
+
|
|
15
|
+
## [0.4.0] — 2026-09-09
|
|
16
|
+
|
|
17
|
+
**Four missing Real-Time Event objects, and triage that matches what ships.**
|
|
18
|
+
|
|
19
|
+
Minor rather than patch: a consumer that changes nothing now captures four event
|
|
20
|
+
types it did not capture before, so output moves under it. The exported surface is
|
|
21
|
+
unchanged.
|
|
22
|
+
|
|
23
|
+
### Security
|
|
24
|
+
|
|
25
|
+
- `js-yaml` override raised to the first patched version, closing GHSA-5p4m-2wfm-xmqj
|
|
26
|
+
(quadratic CPU consumption in `!!omap` resolution). The override already permitted the fix
|
|
27
|
+
without requiring it, so the lockfile stayed on the vulnerable version: a caret that allows a
|
|
28
|
+
patch is not a floor that forces one. Development-scope transitive dependency; nothing shipped
|
|
29
|
+
to consumers was affected. (#8)
|
|
30
|
+
- `SECURITY.md` rewritten. It was `sf-audit`'s, copied verbatim: it described this package as a
|
|
31
|
+
security audit plugin, named the wrong package throughout, and told reporters to run a CLI
|
|
32
|
+
command that does not apply to a library. Private vulnerability reporting has also been enabled
|
|
33
|
+
on the repository, which the policy had named as the preferred channel while it was switched
|
|
34
|
+
off. (#9)
|
|
35
|
+
- `/.superpowers/` added to `.gitignore`. Execution ledgers quote live-org detail as a matter of
|
|
36
|
+
course, and this repository is public. Nothing was ever tracked under that path. (#9)
|
|
37
|
+
|
|
38
|
+
### Fixed
|
|
39
|
+
|
|
40
|
+
- **Four Real-Time Event objects were missing from the catalog**, and had been since it was
|
|
41
|
+
written: `LoginAnomalyEvent`, `UniversalAnomalyEvent`, `IdentityVerificationEvent` and
|
|
42
|
+
`ApiPrtcPolicyChangeEvent`. All four were verified across eight orgs. `LoginAnomalyEvent` is
|
|
43
|
+
the one that mattered — login anomaly is precisely the signal this catalog exists to retain.
|
|
44
|
+
The 0.3.0 probe checked that every declared object behaved as declared and found nothing
|
|
45
|
+
wrong; it never asked the inverse question. A missing entry raises no error anywhere, so the
|
|
46
|
+
pull simply never asked for these objects and the manifest recorded no gap, leaving a
|
|
47
|
+
consumer to read the silence as "this org had no such events" rather than "we did not look".
|
|
48
|
+
Re-probing now runs in both directions. (#13)
|
|
49
|
+
- **A catalog invariant passed vacuously.** The test asserting that a directly-queryable object
|
|
50
|
+
declares no `*Store` read `find(...)?.store`, which is `undefined` both for an entry with no
|
|
51
|
+
Store and for an entry that is absent entirely — so it could not fail for a missing object,
|
|
52
|
+
which is how `IdentityVerificationEvent` stayed missing. It now asserts the entry exists
|
|
53
|
+
first. (#13)
|
|
54
|
+
- **The Socket triage claimed something untrue of this package.** `socket.yml` stated that it
|
|
55
|
+
"makes no outbound network call of its own". `src/api/RestClientImpl.ts` calls global
|
|
56
|
+
`fetch` to stream an EventLogFile download, which is why Socket reports network access and
|
|
57
|
+
records `net: true`. The surrounding sentences were right about the destination, so the
|
|
58
|
+
claim read as true while the sentence carrying it was false — the worst shape for a
|
|
59
|
+
statement a reviewer is invited to verify. It now says what the call is: one `fetch`, to
|
|
60
|
+
the instance URL of an org the caller already authenticated against, on the caller's own
|
|
61
|
+
session. The OFL-1.1 licence alert, previously unanswered, is answered in the same place:
|
|
62
|
+
it describes the bundled fonts, not the code, which stays Apache-2.0. Neither rule is
|
|
63
|
+
suppressed. (#15)
|
|
64
|
+
|
|
65
|
+
### Added
|
|
66
|
+
|
|
67
|
+
- `CONTRIBUTING.md` and this changelog.
|
|
68
|
+
- `docs/RELEASE_TRACKING.md`: what a Salesforce release does and does not require of this
|
|
69
|
+
package, the per-release checklist, and a record of each release assessed. Winter '27
|
|
70
|
+
(API v68.0) is assessed and changes nothing here — no API version is pinned anywhere in
|
|
71
|
+
`src/`, so the release is inert for this package. The catalog re-probe against a v68.0
|
|
72
|
+
preview org remains open, and is recorded there as outstanding rather than assumed. (#13)
|
|
73
|
+
- README: an **Event capture** row in the capability table, which had no entry for `src/events/`
|
|
74
|
+
despite it being the largest module and fully exported; the Real-Time Event base/`*Store`
|
|
75
|
+
split added to the list of platform behaviours; and a statement of where the contract-test
|
|
76
|
+
guarantee stops — a test can refuse a wrong read, but it cannot notice an object the catalog
|
|
77
|
+
never lists. (#13)
|
|
78
|
+
|
|
79
|
+
## [0.3.0] — 2026-08-04
|
|
80
|
+
|
|
81
|
+
**Capture integrity, verified RTE catalog.**
|
|
82
|
+
|
|
83
|
+
### Fixed
|
|
84
|
+
|
|
85
|
+
- **The Real-Time Event catalog was wrong in both directions**, because it rested on a naming
|
|
86
|
+
convention rather than on the platform. Probing five orgs settled it; one org would not have.
|
|
87
|
+
A store that could not be read was also reported as a store containing nothing, which
|
|
88
|
+
manufactured false coverage gaps on every quiet hour. (#3)
|
|
89
|
+
|
|
90
|
+
### Security
|
|
91
|
+
|
|
92
|
+
- **Presence on disk now means complete.** Captures are written atomically, so a partial file is
|
|
93
|
+
never mistaken for a finished one. (#4)
|
|
94
|
+
- **Paths built from org data are confined.** `EventType`, object names, org ids and file ids all
|
|
95
|
+
arrive from query results and were joined straight into a filesystem path. Each is now reduced
|
|
96
|
+
to a single safe segment, so a value like `../../..` cannot place captured evidence outside the
|
|
97
|
+
store. (#4)
|
|
98
|
+
|
|
99
|
+
## [0.2.0] — 2026-08-03
|
|
100
|
+
|
|
101
|
+
**Hourly EventLogFile and Real-Time Event capture.** Adds the event baseline store and the
|
|
102
|
+
hourly capture path that dependants build on.
|
|
103
|
+
|
|
104
|
+
## [0.1.x]
|
|
105
|
+
|
|
106
|
+
Initial internal releases: API clients, org context, findings model and report rendering.
|
|
107
|
+
|
|
108
|
+
[Unreleased]: https://github.com/cclabsnz/sf-core/compare/v0.4.0...HEAD
|
|
109
|
+
[0.4.0]: https://github.com/cclabsnz/sf-core/releases/tag/v0.4.0
|
|
110
|
+
[0.3.0]: https://github.com/cclabsnz/sf-core/releases/tag/v0.3.0
|
|
111
|
+
[0.2.0]: https://github.com/cclabsnz/sf-core/releases/tag/v0.2.0
|
package/README.md
CHANGED
|
@@ -1,7 +1,18 @@
|
|
|
1
1
|
# @cclabsnz/sf-core
|
|
2
2
|
|
|
3
|
+
[](https://github.com/cclabsnz/sf-core/actions/workflows/ci.yml)
|
|
4
|
+
[](https://github.com/cclabsnz/sf-core/actions/workflows/codeql.yml)
|
|
5
|
+
[](https://github.com/cclabsnz/sf-core/actions/workflows/semgrep.yml)
|
|
6
|
+
[](https://securityscorecards.dev/viewer/?uri=github.com/cclabsnz/sf-core)
|
|
7
|
+
[](https://www.bestpractices.dev/projects/14150)
|
|
8
|
+
[](https://www.npmjs.com/package/@cclabsnz/sf-core)
|
|
9
|
+
[](https://www.npmjs.com/package/@cclabsnz/sf-core#provenance)
|
|
10
|
+
[](LICENSE)
|
|
11
|
+
|
|
3
12
|
> Shared platform layer for the CloudCounsel Salesforce `sf` plugins.
|
|
4
13
|
|
|
14
|
+
[Architecture](docs/ARCHITECTURE.md) · [Assurance case](docs/ASSURANCE_CASE.md) · [Release tracking](docs/RELEASE_TRACKING.md) · [Governance](GOVERNANCE.md) · [Roadmap](ROADMAP.md) · [Contributing](CONTRIBUTING.md) · [Security](SECURITY.md) · [Changelog](CHANGELOG.md)
|
|
15
|
+
|
|
5
16
|
The read-only API surface, platform-behaviour knowledge, report shell and versioned IR
|
|
6
17
|
contracts behind [`@cclabsnz/sf-audit`](https://www.npmjs.com/package/@cclabsnz/sf-audit)
|
|
7
18
|
(security auditing) and `@cclabsnz/sf-orgintel` (org intelligence).
|
|
@@ -10,8 +21,9 @@ contracts behind [`@cclabsnz/sf-audit`](https://www.npmjs.com/package/@cclabsnz/
|
|
|
10
21
|
|
|
11
22
|
| Area | What it provides |
|
|
12
23
|
| --- | --- |
|
|
13
|
-
| **API clients** | `SoqlClient`, `ToolingClient`, `RestClient`, `MetadataClient
|
|
24
|
+
| **API clients** | `SoqlClient`, `ToolingClient`, `RestClient`, `MetadataClient`: read-only wrappers over a `@salesforce/core` `Connection` |
|
|
14
25
|
| **Platform behaviour** | `FlowRepository`, `ApexRepository`, `isSalesforceId`, `describeSalesforceError`, `mapWithConcurrency` |
|
|
26
|
+
| **Event capture** | `EventBaselineStore`, `RTE_CATALOG`, `pullEventLogs`, `pullRealtimeEvents`, `CaptureManifest`: bounded, resumable EventLogFile and Real-Time Event pulls |
|
|
15
27
|
| **IR contracts** | Typed interfaces plus JSON Schemas for `coupling-graph`, `landscape-manifest` and `process-graph` |
|
|
16
28
|
| **Report shell** | Branding resolution and embedded webfonts for self-contained HTML reports |
|
|
17
29
|
| **Test invariants** | Static guards that fail a build on org writes or network egress |
|
|
@@ -21,22 +33,34 @@ contracts behind [`@cclabsnz/sf-audit`](https://www.npmjs.com/package/@cclabsnz/
|
|
|
21
33
|
Salesforce has behaviours that are easy to get wrong and expensive to discover, and each one
|
|
22
34
|
here was learned by running against a real org:
|
|
23
35
|
|
|
24
|
-
- `FlowDefinitionView` is a **standard** object
|
|
36
|
+
- `FlowDefinitionView` is a **standard** object, so querying it through Tooling answers
|
|
25
37
|
*"sObject type 'FlowDefinitionView' is not supported."*
|
|
26
|
-
- `Flow.Metadata` **is** Tooling, and is strictly **one row per query
|
|
38
|
+
- `Flow.Metadata` **is** Tooling, and is strictly **one row per query**. An `Id IN (...)`
|
|
27
39
|
batch is rejected outright, so bulk reads need bounded concurrency.
|
|
28
|
-
- `ApexClass` has a `SymbolTable` column; **`ApexTrigger` does not
|
|
40
|
+
- `ApexClass` has a `SymbolTable` column; **`ApexTrigger` does not**, and selecting it fails the
|
|
29
41
|
entire query.
|
|
30
42
|
- Managed-package flows return a **durable name** (`ns__Flow-1`) where an Id is expected;
|
|
31
43
|
feeding that to a `WHERE` clause yields `invalid ID field`.
|
|
32
|
-
- `expr0` is Salesforce's own aggregate alias and **cannot be requested
|
|
44
|
+
- `expr0` is Salesforce's own aggregate alias and **cannot be requested**. An explicit
|
|
33
45
|
`COUNT(Id) expr0` is rejected with *"alias is reserved: expr0"*.
|
|
46
|
+
- Real-Time Event objects split unevenly between the streaming base and a retained-rows
|
|
47
|
+
`*Store`, and **the split cannot be derived from the name**. Roughly half the base objects
|
|
48
|
+
reject a `SELECT` outright while their `*Store` answers fine. `ListViewEvent` is queryable
|
|
49
|
+
and has no Store at all; `GuestUserAnomalyEvent` is the exact inverse.
|
|
34
50
|
|
|
35
51
|
Encoding these once means a consumer cannot rediscover them by shipping the bug first. The
|
|
36
52
|
contract tests are the point: their mocks refuse exactly as an org refuses, so a query sent to
|
|
37
53
|
the wrong API or asking for a non-existent column fails the build rather than degrading
|
|
38
54
|
silently in production.
|
|
39
55
|
|
|
56
|
+
That guarantee has one edge, and it is worth stating because this package has been caught by
|
|
57
|
+
it. A contract test can only refuse what the code asks for; it cannot notice an object the
|
|
58
|
+
catalog never lists. A missing entry raises no error anywhere — the read is simply never
|
|
59
|
+
attempted, and the resulting absence is indistinguishable from an org that had nothing to
|
|
60
|
+
report. So the catalogs are re-probed against live orgs in **both** directions, asking not
|
|
61
|
+
only whether every listed object still behaves as listed but what `describe` returns that is
|
|
62
|
+
not listed at all. See [docs/RELEASE_TRACKING.md](docs/RELEASE_TRACKING.md).
|
|
63
|
+
|
|
40
64
|
## Install
|
|
41
65
|
|
|
42
66
|
```bash
|
|
@@ -52,7 +76,7 @@ const flows = new FlowRepository(soqlClient, toolingClient);
|
|
|
52
76
|
const definitions = await flows.listDefinitions();
|
|
53
77
|
const { versions, managedSkipped } = FlowRepository.selectVersions(definitions);
|
|
54
78
|
|
|
55
|
-
// Flow.Metadata is one row per query
|
|
79
|
+
// Flow.Metadata is one row per query; concurrency is the only lever.
|
|
56
80
|
await mapWithConcurrency(versions, 8, async (v) => {
|
|
57
81
|
const metadata = await flows.fetchMetadata(v.id);
|
|
58
82
|
// ...
|
|
@@ -68,7 +92,7 @@ const couplingGraphSchema = loadSchema('coupling-graph');
|
|
|
68
92
|
|
|
69
93
|
## Guarantees
|
|
70
94
|
|
|
71
|
-
Both are enforced as tests, not asserted in prose
|
|
95
|
+
Both are enforced as tests, not asserted in prose. Run them yourself with `pnpm test`:
|
|
72
96
|
|
|
73
97
|
- **Read-only.** No jsforce mutation API, HTTP write verb, or bulk/composite write path may
|
|
74
98
|
appear in source. Every org request is a SOQL query, a REST **GET**, or a Metadata read.
|
|
@@ -84,5 +108,5 @@ version bump on the contract, not a silent edit.
|
|
|
84
108
|
|
|
85
109
|
## Licence
|
|
86
110
|
|
|
87
|
-
Apache-2.0
|
|
111
|
+
Apache-2.0, see [LICENSE](LICENSE). Bundled fonts are SIL OFL 1.1; see
|
|
88
112
|
[`src/assets/fonts/NOTICE.md`](src/assets/fonts/NOTICE.md).
|
|
@@ -12,18 +12,29 @@ export declare class EventBaselineStore {
|
|
|
12
12
|
* verified case had two AuraRequest rows for the same hour.
|
|
13
13
|
*/
|
|
14
14
|
pathFor(orgId: string, eventType: string, logDate: string, id: string, hour?: string): string;
|
|
15
|
-
/**
|
|
15
|
+
/**
|
|
16
|
+
* True when this EventLogFile is already captured — the dedup / idempotency check.
|
|
17
|
+
*
|
|
18
|
+
* Requires a non-empty file, not merely an existing one. A zero-byte file is what a run
|
|
19
|
+
* killed between create and write leaves behind, and treating that as captured would retire
|
|
20
|
+
* the row permanently: every later run skips it, and the gap never appears in any manifest.
|
|
21
|
+
*/
|
|
16
22
|
has(orgId: string, eventType: string, logDate: string, id: string, hour?: string): boolean;
|
|
17
23
|
/** Write a CSV body verbatim; returns the saved path. Best-effort. */
|
|
18
24
|
save(orgId: string, eventType: string, logDate: string, id: string, body: string, hour?: string): string;
|
|
19
25
|
/** Absolute path the NDJSON for one Real-Time Event object-hour is (or would be) stored at. */
|
|
20
26
|
realtimePathFor(orgId: string, objectName: string, logDate: string, hour: string): string;
|
|
21
|
-
/** True when this object-hour already holds a
|
|
27
|
+
/** True when this object-hour already holds a complete NDJSON file. */
|
|
22
28
|
hasRealtime(orgId: string, objectName: string, logDate: string, hour: string): boolean;
|
|
23
29
|
/**
|
|
24
|
-
* Write RTE rows as NDJSON — one JSON object per line, so
|
|
25
|
-
*
|
|
26
|
-
*
|
|
30
|
+
* Write RTE rows as NDJSON — one JSON object per line, so the file stays parseable line by
|
|
31
|
+
* line and a reader never has to hold the whole set in memory.
|
|
32
|
+
*
|
|
33
|
+
* Written to a temporary file and renamed into place. The earlier rationale — that a
|
|
34
|
+
* half-written NDJSON is still parseable up to the last complete line — is true but beside
|
|
35
|
+
* the point: `hasRealtime` cannot distinguish a truncated file from a complete one, so a
|
|
36
|
+
* partial write would be skipped by every later run and silently pass as full coverage.
|
|
37
|
+
* Rename is atomic within a filesystem, so the file is either absent or whole.
|
|
27
38
|
*/
|
|
28
39
|
saveRealtime(orgId: string, objectName: string, logDate: string, hour: string, rows: readonly unknown[]): string;
|
|
29
40
|
/**
|
|
@@ -27,7 +27,7 @@ export class EventBaselineStore {
|
|
|
27
27
|
}
|
|
28
28
|
/** The per-org base directory logs for this org are stored under. */
|
|
29
29
|
orgDir(orgId) {
|
|
30
|
-
return path.join(this.root, orgId);
|
|
30
|
+
return path.join(this.root, segment(orgId));
|
|
31
31
|
}
|
|
32
32
|
/**
|
|
33
33
|
* Absolute path a given log file is (or would be) stored at. Pass `hour` ('00'–'23', UTC)
|
|
@@ -37,20 +37,26 @@ export class EventBaselineStore {
|
|
|
37
37
|
* verified case had two AuraRequest rows for the same hour.
|
|
38
38
|
*/
|
|
39
39
|
pathFor(orgId, eventType, logDate, id, hour) {
|
|
40
|
+
const [o, t, d, i] = [orgId, eventType, logDate, id].map(segment);
|
|
40
41
|
return hour === undefined
|
|
41
|
-
? path.join(this.root,
|
|
42
|
-
: path.join(this.root,
|
|
42
|
+
? path.join(this.root, o, t, `${d}-${i}.csv`)
|
|
43
|
+
: path.join(this.root, o, t, d, `${padHour(hour)}-${i}.csv`);
|
|
43
44
|
}
|
|
44
|
-
/**
|
|
45
|
+
/**
|
|
46
|
+
* True when this EventLogFile is already captured — the dedup / idempotency check.
|
|
47
|
+
*
|
|
48
|
+
* Requires a non-empty file, not merely an existing one. A zero-byte file is what a run
|
|
49
|
+
* killed between create and write leaves behind, and treating that as captured would retire
|
|
50
|
+
* the row permanently: every later run skips it, and the gap never appears in any manifest.
|
|
51
|
+
*/
|
|
45
52
|
has(orgId, eventType, logDate, id, hour) {
|
|
46
|
-
return
|
|
53
|
+
return nonEmpty(this.pathFor(orgId, eventType, logDate, id, hour));
|
|
47
54
|
}
|
|
48
55
|
/** Write a CSV body verbatim; returns the saved path. Best-effort. */
|
|
49
56
|
save(orgId, eventType, logDate, id, body, hour) {
|
|
50
57
|
const filePath = this.pathFor(orgId, eventType, logDate, id, hour);
|
|
51
58
|
try {
|
|
52
|
-
|
|
53
|
-
fs.writeFileSync(filePath, body, 'utf-8');
|
|
59
|
+
writeAtomic(filePath, body);
|
|
54
60
|
}
|
|
55
61
|
catch (err) {
|
|
56
62
|
process.stderr.write(`[sf-audit] Warning: could not save event log ${id}: ${String(err)}\n`);
|
|
@@ -59,28 +65,27 @@ export class EventBaselineStore {
|
|
|
59
65
|
}
|
|
60
66
|
/** Absolute path the NDJSON for one Real-Time Event object-hour is (or would be) stored at. */
|
|
61
67
|
realtimePathFor(orgId, objectName, logDate, hour) {
|
|
62
|
-
|
|
68
|
+
const [o, n, d] = [orgId, objectName, logDate].map(segment);
|
|
69
|
+
return path.join(this.root, o, '_realtime', n, d, `${padHour(hour)}.ndjson`);
|
|
63
70
|
}
|
|
64
|
-
/** True when this object-hour already holds a
|
|
71
|
+
/** True when this object-hour already holds a complete NDJSON file. */
|
|
65
72
|
hasRealtime(orgId, objectName, logDate, hour) {
|
|
66
|
-
|
|
67
|
-
try {
|
|
68
|
-
return fs.statSync(filePath).size > 0;
|
|
69
|
-
}
|
|
70
|
-
catch {
|
|
71
|
-
return false;
|
|
72
|
-
}
|
|
73
|
+
return nonEmpty(this.realtimePathFor(orgId, objectName, logDate, hour));
|
|
73
74
|
}
|
|
74
75
|
/**
|
|
75
|
-
* Write RTE rows as NDJSON — one JSON object per line, so
|
|
76
|
-
*
|
|
77
|
-
*
|
|
76
|
+
* Write RTE rows as NDJSON — one JSON object per line, so the file stays parseable line by
|
|
77
|
+
* line and a reader never has to hold the whole set in memory.
|
|
78
|
+
*
|
|
79
|
+
* Written to a temporary file and renamed into place. The earlier rationale — that a
|
|
80
|
+
* half-written NDJSON is still parseable up to the last complete line — is true but beside
|
|
81
|
+
* the point: `hasRealtime` cannot distinguish a truncated file from a complete one, so a
|
|
82
|
+
* partial write would be skipped by every later run and silently pass as full coverage.
|
|
83
|
+
* Rename is atomic within a filesystem, so the file is either absent or whole.
|
|
78
84
|
*/
|
|
79
85
|
saveRealtime(orgId, objectName, logDate, hour, rows) {
|
|
80
86
|
const filePath = this.realtimePathFor(orgId, objectName, logDate, hour);
|
|
81
87
|
try {
|
|
82
|
-
|
|
83
|
-
fs.writeFileSync(filePath, rows.map((r) => JSON.stringify(r)).join('\n') + '\n', 'utf-8');
|
|
88
|
+
writeAtomic(filePath, rows.map((r) => JSON.stringify(r)).join('\n') + '\n');
|
|
84
89
|
}
|
|
85
90
|
catch (err) {
|
|
86
91
|
process.stderr.write(`[sf-audit] Warning: could not save realtime events ${objectName} ${logDate} ${hour}: ${String(err)}\n`);
|
|
@@ -103,12 +108,13 @@ export class EventBaselineStore {
|
|
|
103
108
|
return this.writeManifestAs(orgId, 'manifest', manifest);
|
|
104
109
|
}
|
|
105
110
|
writeManifestAs(orgId, prefix, manifest) {
|
|
106
|
-
const dir = path.join(this.root, orgId, '_manifests');
|
|
111
|
+
const dir = path.join(this.root, segment(orgId), '_manifests');
|
|
107
112
|
const suffix = Math.random().toString(36).slice(2, 8);
|
|
108
113
|
const filePath = path.join(dir, `${prefix}-${Date.now()}-${suffix}.json`);
|
|
109
114
|
try {
|
|
110
|
-
|
|
111
|
-
|
|
115
|
+
// Atomic for the same reason as the captures: a reader scanning _manifests must never
|
|
116
|
+
// parse a half-written coverage record and conclude the run captured less than it did.
|
|
117
|
+
writeAtomic(filePath, JSON.stringify(manifest, null, 2));
|
|
112
118
|
}
|
|
113
119
|
catch (err) {
|
|
114
120
|
process.stderr.write(`[sf-audit] Warning: could not write event manifest: ${String(err)}\n`);
|
|
@@ -118,6 +124,47 @@ export class EventBaselineStore {
|
|
|
118
124
|
}
|
|
119
125
|
/** Hours are stored zero-padded so lexical order matches chronological order. */
|
|
120
126
|
function padHour(hour) {
|
|
121
|
-
return String(hour).padStart(2, '0');
|
|
127
|
+
return String(segment(String(hour))).padStart(2, '0');
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Constrain one org-supplied value to a single safe path segment.
|
|
131
|
+
*
|
|
132
|
+
* EventType, RTE object names, org ids and file ids all arrive from query results and are
|
|
133
|
+
* joined straight into a filesystem path. They are Salesforce identifiers in practice, but
|
|
134
|
+
* "in practice" is not a boundary: a value of `../../..` would place captured evidence
|
|
135
|
+
* outside the store, and this package writes to a directory under the operator's home. So
|
|
136
|
+
* anything that is not an identifier character is folded to `_`, and a segment that reduces
|
|
137
|
+
* to nothing (or to dots) becomes `_` rather than silently resolving to a parent directory.
|
|
138
|
+
*/
|
|
139
|
+
function segment(raw) {
|
|
140
|
+
const cleaned = String(raw).replace(/[^A-Za-z0-9._-]/g, '_');
|
|
141
|
+
return cleaned.length === 0 || /^\.+$/.test(cleaned) ? '_' : cleaned;
|
|
142
|
+
}
|
|
143
|
+
/** True when the path holds a file with at least one byte. */
|
|
144
|
+
function nonEmpty(filePath) {
|
|
145
|
+
try {
|
|
146
|
+
return fs.statSync(filePath).size > 0;
|
|
147
|
+
}
|
|
148
|
+
catch {
|
|
149
|
+
return false;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Write via a temporary file and rename into place, so a reader never observes a partial
|
|
154
|
+
* file. The temp name carries the pid so two concurrent pulls of the same org — a cron run
|
|
155
|
+
* overlapping a manual one — cannot corrupt each other's staging file.
|
|
156
|
+
*/
|
|
157
|
+
function writeAtomic(filePath, body) {
|
|
158
|
+
const dir = path.dirname(filePath);
|
|
159
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
160
|
+
const tmp = path.join(dir, `.${path.basename(filePath)}.${process.pid}.tmp`);
|
|
161
|
+
try {
|
|
162
|
+
fs.writeFileSync(tmp, body, 'utf-8');
|
|
163
|
+
fs.renameSync(tmp, filePath);
|
|
164
|
+
}
|
|
165
|
+
catch (err) {
|
|
166
|
+
fs.rmSync(tmp, { force: true });
|
|
167
|
+
throw err;
|
|
168
|
+
}
|
|
122
169
|
}
|
|
123
170
|
//# sourceMappingURL=EventBaselineStore.js.map
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
// src/events/pullEventLogs.ts
|
|
2
|
+
// Orchestrates a single `audit events pull` run: discover the org's EventLogFile rows for the
|
|
3
|
+
// requested interval and window, download the CSV body of any not already on disk, optionally
|
|
4
|
+
// capture Real-Time Event rows alongside them, and record a per-run coverage manifest.
|
|
5
|
+
// All org I/O is behind the injected SoqlClient/RestClient, so this is unit-testable with
|
|
6
|
+
// mocked clients — it never touches a real org.
|
|
7
|
+
import * as fs from 'node:fs';
|
|
1
8
|
import { classifyEventLogAccessError } from './eventLogAccess.js';
|
|
2
9
|
import { HOURLY_FORENSIC_CORE, buildEventLogQuery, toLogDate, toLogHour, } from './eventLogQuery.js';
|
|
3
10
|
import { emptyCoverage } from './CaptureManifest.js';
|
|
@@ -158,7 +165,14 @@ async function captureRow(deps, opts, base, coverage, row, passInterval, maxFile
|
|
|
158
165
|
}
|
|
159
166
|
try {
|
|
160
167
|
// Stream straight to disk — never buffer the body — so large logs don't blow the heap.
|
|
161
|
-
|
|
168
|
+
//
|
|
169
|
+
// Staged through a temp file and renamed, so the final path only ever exists complete.
|
|
170
|
+
// The client already removes a partial file when the stream errors, but that cannot help
|
|
171
|
+
// if the process itself dies mid-download: the truncated CSV would satisfy `has()` and be
|
|
172
|
+
// skipped by every later run, leaving a silently incomplete log presented as a whole one.
|
|
173
|
+
const tmpPath = `${savedPath}.${process.pid}.part`;
|
|
174
|
+
const bytes = await rest.getRawToFile(`/sobjects/EventLogFile/${row.Id}/LogFile`, tmpPath);
|
|
175
|
+
fs.renameSync(tmpPath, savedPath);
|
|
162
176
|
base.downloaded += 1;
|
|
163
177
|
base.totalBytes += bytes;
|
|
164
178
|
record('downloaded', bytes);
|
|
@@ -172,6 +186,7 @@ async function captureRow(deps, opts, base, coverage, row, passInterval, maxFile
|
|
|
172
186
|
});
|
|
173
187
|
}
|
|
174
188
|
catch (err) {
|
|
189
|
+
fs.rmSync(`${savedPath}.${process.pid}.part`, { force: true });
|
|
175
190
|
base.failed += 1;
|
|
176
191
|
record('failed', 0);
|
|
177
192
|
coverage.elf.failed.push({
|
|
@@ -19,8 +19,21 @@ export interface RealtimePullOptions {
|
|
|
19
19
|
catalog?: readonly RteType[];
|
|
20
20
|
/** Re-capture object-hours already on disk. */
|
|
21
21
|
force?: boolean;
|
|
22
|
+
/** Cap on rows accepted from one object. Defaults to MAX_RTE_ROWS. */
|
|
23
|
+
maxRows?: number;
|
|
22
24
|
warn?: (msg: string) => void;
|
|
23
25
|
}
|
|
26
|
+
/**
|
|
27
|
+
* Ceiling on rows taken from a single RTE object in one pull.
|
|
28
|
+
*
|
|
29
|
+
* RTE payloads are small for a sensible window — a busy hour ran to a few hundred ApiEvent
|
|
30
|
+
* rows — but the window is caller-supplied and `queryAll` follows every page, so a month-wide
|
|
31
|
+
* window on a chatty object would page the lot into memory before a single byte reached disk.
|
|
32
|
+
* Overflow is reported as `too-large` rather than truncated: a short NDJSON file is
|
|
33
|
+
* indistinguishable from a quiet hour once written, and quietly answering "nothing else
|
|
34
|
+
* happened" is the one failure this package exists to prevent.
|
|
35
|
+
*/
|
|
36
|
+
export declare const MAX_RTE_ROWS = 200000;
|
|
24
37
|
export interface RealtimePullResult {
|
|
25
38
|
captured: CapturedRteObject[];
|
|
26
39
|
unavailable: UnavailableRteObject[];
|
|
@@ -39,7 +52,7 @@ export declare function describeFields(rest: RestClient, objectName: string, pre
|
|
|
39
52
|
export declare function buildRealtimeQuery(objectName: string, fields: readonly string[], window: {
|
|
40
53
|
from: string;
|
|
41
54
|
to: string;
|
|
42
|
-
}): string;
|
|
55
|
+
}, limit?: number): string;
|
|
43
56
|
/**
|
|
44
57
|
* Map an RTE failure to a manifest reason. The distinction that matters most is
|
|
45
58
|
* "does not support query" — meaning the base object is streaming-only and the Store should be
|
|
@@ -1,4 +1,15 @@
|
|
|
1
1
|
import { RTE_CATALOG } from './rteCatalog.js';
|
|
2
|
+
/**
|
|
3
|
+
* Ceiling on rows taken from a single RTE object in one pull.
|
|
4
|
+
*
|
|
5
|
+
* RTE payloads are small for a sensible window — a busy hour ran to a few hundred ApiEvent
|
|
6
|
+
* rows — but the window is caller-supplied and `queryAll` follows every page, so a month-wide
|
|
7
|
+
* window on a chatty object would page the lot into memory before a single byte reached disk.
|
|
8
|
+
* Overflow is reported as `too-large` rather than truncated: a short NDJSON file is
|
|
9
|
+
* indistinguishable from a quiet hour once written, and quietly answering "nothing else
|
|
10
|
+
* happened" is the one failure this package exists to prevent.
|
|
11
|
+
*/
|
|
12
|
+
export const MAX_RTE_ROWS = 200_000;
|
|
2
13
|
const SOQL_DATETIME = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{1,3})?(?:Z|[+-]\d{2}:\d{2})$/;
|
|
3
14
|
export async function pullRealtimeEvents(deps, opts) {
|
|
4
15
|
for (const bound of [opts.window.from, opts.window.to]) {
|
|
@@ -42,27 +53,36 @@ async function captureOne(deps, opts, entry) {
|
|
|
42
53
|
details.push(`${attempt.name}: describe returned none of the preferred fields`);
|
|
43
54
|
continue;
|
|
44
55
|
}
|
|
56
|
+
const maxRows = opts.maxRows ?? MAX_RTE_ROWS;
|
|
45
57
|
let rows;
|
|
46
58
|
try {
|
|
47
|
-
|
|
59
|
+
// One over the cap, so an exactly-full result is told apart from an overflowing one.
|
|
60
|
+
rows = await deps.soql.queryAll(buildRealtimeQuery(attempt.name, fields, opts.window, maxRows + 1));
|
|
48
61
|
}
|
|
49
62
|
catch (err) {
|
|
50
63
|
lastReason = classifyRteError(err);
|
|
51
64
|
details.push(`${attempt.name}: ${message(err)}`);
|
|
52
65
|
continue;
|
|
53
66
|
}
|
|
67
|
+
if (rows.length > maxRows) {
|
|
68
|
+
opts.warn?.(`${attempt.name}: more than ${maxRows} rows in this window; narrow the window and re-run.`);
|
|
69
|
+
return {
|
|
70
|
+
object: entry.base,
|
|
71
|
+
reason: 'too-large',
|
|
72
|
+
detail: `${attempt.name} returned more than ${maxRows} rows for the requested window; nothing written`,
|
|
73
|
+
};
|
|
74
|
+
}
|
|
54
75
|
if (rows.length === 0) {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
//
|
|
62
|
-
//
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
continue;
|
|
76
|
+
// A query that succeeded and returned nothing is a finding: nothing happened in this
|
|
77
|
+
// window. Recorded as a capture of zero rows, not as an unavailable object.
|
|
78
|
+
//
|
|
79
|
+
// This used to distinguish base from Store, on the reasoning that an empty Store could
|
|
80
|
+
// not be told apart from one that never retained anything — reported as
|
|
81
|
+
// `storage-disabled`. A live run showed why that is wrong: the eight threat-detection
|
|
82
|
+
// Stores are queryable and empty in a normal hour, so every quiet hour produced eight
|
|
83
|
+
// "unavailable" entries claiming coverage was missing when the org had in fact been
|
|
84
|
+
// asked and had answered. Overstating a gap corrupts the record as surely as hiding one.
|
|
85
|
+
return { object: entry.base, rows: 0, via: attempt.via, paths: [] };
|
|
66
86
|
}
|
|
67
87
|
return writeBuckets(deps, opts, entry.base, attempt.via, rows);
|
|
68
88
|
}
|
|
@@ -120,11 +140,12 @@ export async function describeFields(rest, objectName, preferred) {
|
|
|
120
140
|
* `ORDER BY EventDate ASC` with "Unsupported order direction on filter column". Sorting is a
|
|
121
141
|
* client-side concern here.
|
|
122
142
|
*/
|
|
123
|
-
export function buildRealtimeQuery(objectName, fields, window) {
|
|
143
|
+
export function buildRealtimeQuery(objectName, fields, window, limit) {
|
|
124
144
|
const safeObject = objectName.replace(/[^A-Za-z0-9_]/g, '');
|
|
125
145
|
const safeFields = fields.map((f) => f.replace(/[^A-Za-z0-9_]/g, '')).filter((f) => f.length > 0);
|
|
146
|
+
const limitClause = limit === undefined ? '' : ` LIMIT ${Math.max(1, Math.trunc(limit))}`;
|
|
126
147
|
return (`SELECT ${safeFields.join(', ')} FROM ${safeObject} ` +
|
|
127
|
-
`WHERE EventDate >= ${window.from} AND EventDate <= ${window.to}`);
|
|
148
|
+
`WHERE EventDate >= ${window.from} AND EventDate <= ${window.to}${limitClause}`);
|
|
128
149
|
}
|
|
129
150
|
/**
|
|
130
151
|
* Map an RTE failure to a manifest reason. The distinction that matters most is
|
|
@@ -7,8 +7,42 @@ export interface RteType {
|
|
|
7
7
|
preferredFields: string[];
|
|
8
8
|
}
|
|
9
9
|
/**
|
|
10
|
-
* The
|
|
11
|
-
*
|
|
10
|
+
* The 23 known RTE types, split by how the org actually serves them.
|
|
11
|
+
*
|
|
12
|
+
* Probed against a live sandbox on 2026-08-03, which replaced the naming convention this
|
|
13
|
+
* table was first built on. The convention was wrong in both directions, and the real rule
|
|
14
|
+
* turns out to be about what kind of event it is:
|
|
15
|
+
*
|
|
16
|
+
* - **Audit events** (someone did a thing) are queried directly and have NO `*Store`.
|
|
17
|
+
* `ApiEventStore`, `LoginEventStore`, `LogoutEventStore`, `ReportEventStore`,
|
|
18
|
+
* `UriEventStore`, `LightningUriEventStore` and `LoginAsEventStore` were all declared
|
|
19
|
+
* here and none of them exist — every one 404s on describe.
|
|
20
|
+
* - **Threat-detection events** (something looked wrong) are streaming-only: the base
|
|
21
|
+
* rejects a query outright and the retained rows live in a `*Store`.
|
|
22
|
+
*
|
|
23
|
+
* A `store` on a directly-queryable base is never reached, so the phantom entries were
|
|
24
|
+
* harmless — but a catalog that documents objects which do not exist is worse than no
|
|
25
|
+
* documentation, so they are gone.
|
|
26
|
+
*
|
|
27
|
+
* Re-probed across five orgs — two sandboxes and three production — on 2026-08-03. Every
|
|
28
|
+
* verdict was identical in all five, including the absences, so the negatives are no longer
|
|
29
|
+
* a single-org observation that a different licence might overturn.
|
|
30
|
+
*
|
|
31
|
+
* Re-probed again across eight orgs on 2026-09-02, on API v67.0. Every existing verdict held
|
|
32
|
+
* unchanged. The probe was widened to ask the inverse question — what does describe return
|
|
33
|
+
* that this table does not list — and found four objects that had been invisible since the
|
|
34
|
+
* table was written, each unanimous across all eight orgs:
|
|
35
|
+
*
|
|
36
|
+
* - `LoginAnomalyEvent` and `UniversalAnomalyEvent` are ordinary threat-detection pairs
|
|
37
|
+
* that simply were never enumerated. `LoginAnomalyEvent` is the costly omission: login
|
|
38
|
+
* anomaly is exactly the signal this catalog exists to retain.
|
|
39
|
+
* - `IdentityVerificationEvent` is an audit event, directly queryable with no Store.
|
|
40
|
+
* - `ApiPrtcPolicyChangeEvent` is streaming-only with no Store, so it joins the bucket
|
|
41
|
+
* that can never be captured retroactively.
|
|
42
|
+
*
|
|
43
|
+
* The lesson is the same one the naming convention taught: this table's failure mode is
|
|
44
|
+
* silent omission, not a wrong entry. A missing object produces no error anywhere — the pull
|
|
45
|
+
* simply never asks for it — so only an inverse probe against describe can find one.
|
|
12
46
|
*/
|
|
13
47
|
export declare const RTE_CATALOG: readonly RteType[];
|
|
14
48
|
//# sourceMappingURL=rteCatalog.d.ts.map
|
package/lib/events/rteCatalog.js
CHANGED
|
@@ -46,45 +46,92 @@ const CONTEXT_FIELDS = [
|
|
|
46
46
|
];
|
|
47
47
|
const ALL_PREFERRED = [...COMMON_FIELDS, ...EXFIL_FIELDS, ...CONTEXT_FIELDS];
|
|
48
48
|
/**
|
|
49
|
-
* The
|
|
50
|
-
*
|
|
49
|
+
* The 23 known RTE types, split by how the org actually serves them.
|
|
50
|
+
*
|
|
51
|
+
* Probed against a live sandbox on 2026-08-03, which replaced the naming convention this
|
|
52
|
+
* table was first built on. The convention was wrong in both directions, and the real rule
|
|
53
|
+
* turns out to be about what kind of event it is:
|
|
54
|
+
*
|
|
55
|
+
* - **Audit events** (someone did a thing) are queried directly and have NO `*Store`.
|
|
56
|
+
* `ApiEventStore`, `LoginEventStore`, `LogoutEventStore`, `ReportEventStore`,
|
|
57
|
+
* `UriEventStore`, `LightningUriEventStore` and `LoginAsEventStore` were all declared
|
|
58
|
+
* here and none of them exist — every one 404s on describe.
|
|
59
|
+
* - **Threat-detection events** (something looked wrong) are streaming-only: the base
|
|
60
|
+
* rejects a query outright and the retained rows live in a `*Store`.
|
|
61
|
+
*
|
|
62
|
+
* A `store` on a directly-queryable base is never reached, so the phantom entries were
|
|
63
|
+
* harmless — but a catalog that documents objects which do not exist is worse than no
|
|
64
|
+
* documentation, so they are gone.
|
|
65
|
+
*
|
|
66
|
+
* Re-probed across five orgs — two sandboxes and three production — on 2026-08-03. Every
|
|
67
|
+
* verdict was identical in all five, including the absences, so the negatives are no longer
|
|
68
|
+
* a single-org observation that a different licence might overturn.
|
|
69
|
+
*
|
|
70
|
+
* Re-probed again across eight orgs on 2026-09-02, on API v67.0. Every existing verdict held
|
|
71
|
+
* unchanged. The probe was widened to ask the inverse question — what does describe return
|
|
72
|
+
* that this table does not list — and found four objects that had been invisible since the
|
|
73
|
+
* table was written, each unanimous across all eight orgs:
|
|
74
|
+
*
|
|
75
|
+
* - `LoginAnomalyEvent` and `UniversalAnomalyEvent` are ordinary threat-detection pairs
|
|
76
|
+
* that simply were never enumerated. `LoginAnomalyEvent` is the costly omission: login
|
|
77
|
+
* anomaly is exactly the signal this catalog exists to retain.
|
|
78
|
+
* - `IdentityVerificationEvent` is an audit event, directly queryable with no Store.
|
|
79
|
+
* - `ApiPrtcPolicyChangeEvent` is streaming-only with no Store, so it joins the bucket
|
|
80
|
+
* that can never be captured retroactively.
|
|
81
|
+
*
|
|
82
|
+
* The lesson is the same one the naming convention taught: this table's failure mode is
|
|
83
|
+
* silent omission, not a wrong entry. A missing object produces no error anywhere — the pull
|
|
84
|
+
* simply never asks for it — so only an inverse probe against describe can find one.
|
|
51
85
|
*/
|
|
52
86
|
export const RTE_CATALOG = [
|
|
87
|
+
// Directly queryable; no Store counterpart exists. Verified queryable in the probe org.
|
|
53
88
|
{ base: 'ListViewEvent', preferredFields: ALL_PREFERRED },
|
|
54
|
-
{ base: 'ApiEvent',
|
|
55
|
-
{ base: 'LoginEvent',
|
|
56
|
-
{ base: 'LogoutEvent',
|
|
57
|
-
{ base: 'ReportEvent',
|
|
58
|
-
{ base: 'UriEvent',
|
|
59
|
-
{ base: 'LightningUriEvent',
|
|
60
|
-
{ base: '
|
|
89
|
+
{ base: 'ApiEvent', preferredFields: ALL_PREFERRED },
|
|
90
|
+
{ base: 'LoginEvent', preferredFields: ALL_PREFERRED },
|
|
91
|
+
{ base: 'LogoutEvent', preferredFields: ALL_PREFERRED },
|
|
92
|
+
{ base: 'ReportEvent', preferredFields: ALL_PREFERRED },
|
|
93
|
+
{ base: 'UriEvent', preferredFields: ALL_PREFERRED },
|
|
94
|
+
{ base: 'LightningUriEvent', preferredFields: ALL_PREFERRED },
|
|
95
|
+
{ base: 'LoginAsEvent', preferredFields: ALL_PREFERRED },
|
|
96
|
+
{ base: 'IdentityProviderEventStore', preferredFields: ALL_PREFERRED },
|
|
97
|
+
{ base: 'IdentityVerificationEvent', preferredFields: ALL_PREFERRED },
|
|
98
|
+
// Streaming-only base, retained rows in the Store. All ten Stores verified queryable, and
|
|
99
|
+
// all ten bases verified to reject a query with "does not support query".
|
|
100
|
+
{ base: 'ApiAnomalyEvent', store: 'ApiAnomalyEventStore', preferredFields: ALL_PREFERRED },
|
|
61
101
|
{ base: 'BulkApiResultEvent', store: 'BulkApiResultEventStore', preferredFields: ALL_PREFERRED },
|
|
102
|
+
{
|
|
103
|
+
base: 'CredentialStuffingEvent',
|
|
104
|
+
store: 'CredentialStuffingEventStore',
|
|
105
|
+
preferredFields: ALL_PREFERRED,
|
|
106
|
+
},
|
|
62
107
|
{ base: 'FileEvent', store: 'FileEventStore', preferredFields: ALL_PREFERRED },
|
|
63
|
-
{ base: 'ApiAnomalyEvent', store: 'ApiAnomalyEventStore', preferredFields: ALL_PREFERRED },
|
|
64
108
|
{
|
|
65
109
|
base: 'GuestUserAnomalyEvent',
|
|
66
110
|
store: 'GuestUserAnomalyEventStore',
|
|
67
111
|
preferredFields: ALL_PREFERRED,
|
|
68
112
|
},
|
|
113
|
+
{ base: 'PermissionSetEvent', store: 'PermissionSetEventStore', preferredFields: ALL_PREFERRED },
|
|
114
|
+
{ base: 'ReportAnomalyEvent', store: 'ReportAnomalyEventStore', preferredFields: ALL_PREFERRED },
|
|
69
115
|
{
|
|
70
116
|
base: 'SessionHijackingEvent',
|
|
71
117
|
store: 'SessionHijackingEventStore',
|
|
72
118
|
preferredFields: ALL_PREFERRED,
|
|
73
119
|
},
|
|
120
|
+
{ base: 'LoginAnomalyEvent', store: 'LoginAnomalyEventStore', preferredFields: ALL_PREFERRED },
|
|
74
121
|
{
|
|
75
|
-
base: '
|
|
76
|
-
store: '
|
|
77
|
-
preferredFields: ALL_PREFERRED,
|
|
78
|
-
},
|
|
79
|
-
{ base: 'ReportAnomalyEvent', store: 'ReportAnomalyEventStore', preferredFields: ALL_PREFERRED },
|
|
80
|
-
{ base: 'PermissionSetEvent', store: 'PermissionSetEventStore', preferredFields: ALL_PREFERRED },
|
|
81
|
-
{
|
|
82
|
-
base: 'ConcurLongRunApexErrEvent',
|
|
83
|
-
store: 'ConcurLongRunApexErrEventStore',
|
|
122
|
+
base: 'UniversalAnomalyEvent',
|
|
123
|
+
store: 'UniversalAnomalyEventStore',
|
|
84
124
|
preferredFields: ALL_PREFERRED,
|
|
85
125
|
},
|
|
126
|
+
// Exist, but are streaming-only with no Store in any org probed — so they can never be
|
|
127
|
+
// captured retroactively. Kept deliberately: the manifest recording them as `not-queryable`
|
|
128
|
+
// is real coverage information. "This event type exists and cannot be read after the fact"
|
|
129
|
+
// is a different answer from "we did not look", and a forensic consumer needs to tell them
|
|
130
|
+
// apart before it reports an absence.
|
|
131
|
+
{ base: 'ConcurLongRunApexErrEvent', preferredFields: ALL_PREFERRED },
|
|
86
132
|
{ base: 'OrgLifecycleNotification', preferredFields: ALL_PREFERRED },
|
|
87
|
-
{ base: '
|
|
88
|
-
|
|
133
|
+
{ base: 'ApiPrtcPolicyChangeEvent', preferredFields: ALL_PREFERRED },
|
|
134
|
+
// `ApexExecutionEvent` was here and is gone: absent from describe in all eight orgs, so the
|
|
135
|
+
// name appears not to exist rather than to be unlicensed. It cost a 404 per pull.
|
|
89
136
|
];
|
|
90
137
|
//# sourceMappingURL=rteCatalog.js.map
|
package/lib/index.d.ts
CHANGED
|
@@ -15,7 +15,7 @@ export { classifyEventLogAccessError } from './events/eventLogAccess.js';
|
|
|
15
15
|
export type { RteType } from './events/rteCatalog.js';
|
|
16
16
|
export { RTE_CATALOG } from './events/rteCatalog.js';
|
|
17
17
|
export type { RealtimePullDeps, RealtimePullOptions, RealtimePullResult, } from './events/pullRealtimeEvents.js';
|
|
18
|
-
export { pullRealtimeEvents, buildRealtimeQuery, describeFields, classifyRteError, } from './events/pullRealtimeEvents.js';
|
|
18
|
+
export { pullRealtimeEvents, MAX_RTE_ROWS, buildRealtimeQuery, describeFields, classifyRteError, } from './events/pullRealtimeEvents.js';
|
|
19
19
|
export type { SkipReason, CaptureCoverage, CapturedElfFile, SkippedElfFile, CapturedRteObject, UnavailableRteObject, } from './events/CaptureManifest.js';
|
|
20
20
|
export { SKIP_REASONS, isSkipReason, emptyCoverage, readCoverageManifest, } from './events/CaptureManifest.js';
|
|
21
21
|
export type { Branding, BrandingOverrides } from './report/branding.js';
|
package/lib/index.js
CHANGED
|
@@ -9,7 +9,7 @@ export { sanitizeTypes, toLogDate, toLogHour, buildEventLogQuery, HOURLY_FORENSI
|
|
|
9
9
|
export { pullEventLogs, MAX_FILE_BYTES } from './events/pullEventLogs.js';
|
|
10
10
|
export { classifyEventLogAccessError } from './events/eventLogAccess.js';
|
|
11
11
|
export { RTE_CATALOG } from './events/rteCatalog.js';
|
|
12
|
-
export { pullRealtimeEvents, buildRealtimeQuery, describeFields, classifyRteError, } from './events/pullRealtimeEvents.js';
|
|
12
|
+
export { pullRealtimeEvents, MAX_RTE_ROWS, buildRealtimeQuery, describeFields, classifyRteError, } from './events/pullRealtimeEvents.js';
|
|
13
13
|
export { SKIP_REASONS, isSkipReason, emptyCoverage, readCoverageManifest, } from './events/CaptureManifest.js';
|
|
14
14
|
export { DEFAULT_BRANDING, resolveBranding } from './report/branding.js';
|
|
15
15
|
export { fontFaceCss, firaFontFaceCss } from './report/fonts.js';
|
package/lib/report/branding.js
CHANGED
|
@@ -12,7 +12,7 @@ export const DEFAULT_BRANDING = {
|
|
|
12
12
|
website: 'cloudcounsel.co.nz',
|
|
13
13
|
};
|
|
14
14
|
export function resolveBranding(overrides, preparedFor) {
|
|
15
|
-
const merged = { ...DEFAULT_BRANDING, ...
|
|
15
|
+
const merged = { ...DEFAULT_BRANDING, ...overrides };
|
|
16
16
|
if (preparedFor)
|
|
17
17
|
merged.preparedFor = preparedFor;
|
|
18
18
|
return merged;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cclabsnz/sf-core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Shared platform layer for CloudCounsel Salesforce sf plugins — API clients, org context, event log pull, report shell, and versioned IR schemas.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
"./schemas/*": "./schemas/*"
|
|
19
19
|
},
|
|
20
20
|
"scripts": {
|
|
21
|
+
"lint": "oxlint src test",
|
|
21
22
|
"build": "tsc -p tsconfig.json",
|
|
22
23
|
"test": "node --experimental-vm-modules node_modules/jest/bin/jest.js --passWithNoTests",
|
|
23
24
|
"test:unit": "node --experimental-vm-modules node_modules/jest/bin/jest.js test/unit --passWithNoTests",
|
|
@@ -27,14 +28,15 @@
|
|
|
27
28
|
},
|
|
28
29
|
"devDependencies": {
|
|
29
30
|
"@jest/globals": "^29.7.0",
|
|
31
|
+
"@salesforce/core": "^9",
|
|
30
32
|
"@types/jest": "^29",
|
|
31
33
|
"@types/node": "^22",
|
|
32
34
|
"ajv": "^8",
|
|
33
35
|
"jest": "^29",
|
|
36
|
+
"oxlint": "^1.79.0",
|
|
34
37
|
"ts-jest": "^29",
|
|
35
38
|
"ts-node": "^10.9.2",
|
|
36
|
-
"typescript": "^5"
|
|
37
|
-
"@salesforce/core": "^9"
|
|
39
|
+
"typescript": "^5"
|
|
38
40
|
},
|
|
39
41
|
"engines": {
|
|
40
42
|
"node": ">=18.0.0"
|
|
@@ -45,6 +47,7 @@
|
|
|
45
47
|
"/src/assets",
|
|
46
48
|
"LICENSE",
|
|
47
49
|
"README.md",
|
|
50
|
+
"CHANGELOG.md",
|
|
48
51
|
"!/lib/**/*.map"
|
|
49
52
|
],
|
|
50
53
|
"repository": {
|
|
@@ -71,10 +74,10 @@
|
|
|
71
74
|
"pnpm": {
|
|
72
75
|
"overrides": {
|
|
73
76
|
"form-data": "^4.0.6",
|
|
74
|
-
"js-yaml@3": "^3.15.
|
|
77
|
+
"js-yaml@3": "^3.15.1",
|
|
75
78
|
"handlebars": "^4.7.9",
|
|
76
|
-
"brace-expansion": "^5.0.
|
|
77
|
-
"fast-uri@3": "^3.1.
|
|
79
|
+
"brace-expansion": "^5.0.9",
|
|
80
|
+
"fast-uri@3": "^3.1.6"
|
|
78
81
|
}
|
|
79
82
|
},
|
|
80
83
|
"peerDependencies": {
|