@cclabsnz/sf-core 0.3.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 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
+ [![CI](https://github.com/cclabsnz/sf-core/actions/workflows/ci.yml/badge.svg)](https://github.com/cclabsnz/sf-core/actions/workflows/ci.yml)
4
+ [![CodeQL](https://github.com/cclabsnz/sf-core/actions/workflows/codeql.yml/badge.svg)](https://github.com/cclabsnz/sf-core/actions/workflows/codeql.yml)
5
+ [![Semgrep](https://github.com/cclabsnz/sf-core/actions/workflows/semgrep.yml/badge.svg)](https://github.com/cclabsnz/sf-core/actions/workflows/semgrep.yml)
6
+ [![OpenSSF Scorecard](https://api.securityscorecards.dev/projects/github.com/cclabsnz/sf-core/badge)](https://securityscorecards.dev/viewer/?uri=github.com/cclabsnz/sf-core)
7
+ [![OpenSSF Best Practices](https://www.bestpractices.dev/projects/14150/badge)](https://www.bestpractices.dev/projects/14150)
8
+ [![npm version](https://img.shields.io/npm/v/@cclabsnz/sf-core)](https://www.npmjs.com/package/@cclabsnz/sf-core)
9
+ [![npm provenance](https://img.shields.io/badge/npm-signed%20provenance-brightgreen)](https://www.npmjs.com/package/@cclabsnz/sf-core#provenance)
10
+ [![License: Apache-2.0](https://img.shields.io/badge/license-Apache--2.0-blue.svg)](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` — read-only wrappers over a `@salesforce/core` `Connection` |
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 — querying it through Tooling answers
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** — an `Id IN (...)`
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** — selecting it fails the
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** — an explicit
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 — concurrency is the only lever.
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 — run them yourself with `pnpm test`:
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 — see [LICENSE](LICENSE). Bundled fonts are SIL OFL 1.1; see
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).
@@ -7,7 +7,7 @@ export interface RteType {
7
7
  preferredFields: string[];
8
8
  }
9
9
  /**
10
- * The 20 known RTE types, split by how the org actually serves them.
10
+ * The 23 known RTE types, split by how the org actually serves them.
11
11
  *
12
12
  * Probed against a live sandbox on 2026-08-03, which replaced the naming convention this
13
13
  * table was first built on. The convention was wrong in both directions, and the real rule
@@ -27,6 +27,22 @@ export interface RteType {
27
27
  * Re-probed across five orgs — two sandboxes and three production — on 2026-08-03. Every
28
28
  * verdict was identical in all five, including the absences, so the negatives are no longer
29
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.
30
46
  */
31
47
  export declare const RTE_CATALOG: readonly RteType[];
32
48
  //# sourceMappingURL=rteCatalog.d.ts.map
@@ -46,7 +46,7 @@ const CONTEXT_FIELDS = [
46
46
  ];
47
47
  const ALL_PREFERRED = [...COMMON_FIELDS, ...EXFIL_FIELDS, ...CONTEXT_FIELDS];
48
48
  /**
49
- * The 20 known RTE types, split by how the org actually serves them.
49
+ * The 23 known RTE types, split by how the org actually serves them.
50
50
  *
51
51
  * Probed against a live sandbox on 2026-08-03, which replaced the naming convention this
52
52
  * table was first built on. The convention was wrong in both directions, and the real rule
@@ -66,6 +66,22 @@ const ALL_PREFERRED = [...COMMON_FIELDS, ...EXFIL_FIELDS, ...CONTEXT_FIELDS];
66
66
  * Re-probed across five orgs — two sandboxes and three production — on 2026-08-03. Every
67
67
  * verdict was identical in all five, including the absences, so the negatives are no longer
68
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.
69
85
  */
70
86
  export const RTE_CATALOG = [
71
87
  // Directly queryable; no Store counterpart exists. Verified queryable in the probe org.
@@ -78,8 +94,9 @@ export const RTE_CATALOG = [
78
94
  { base: 'LightningUriEvent', preferredFields: ALL_PREFERRED },
79
95
  { base: 'LoginAsEvent', preferredFields: ALL_PREFERRED },
80
96
  { base: 'IdentityProviderEventStore', preferredFields: ALL_PREFERRED },
81
- // Streaming-only base, retained rows in the Store. All eight Stores verified queryable,
82
- // and all eight bases verified to reject a query with "does not support query".
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".
83
100
  { base: 'ApiAnomalyEvent', store: 'ApiAnomalyEventStore', preferredFields: ALL_PREFERRED },
84
101
  { base: 'BulkApiResultEvent', store: 'BulkApiResultEventStore', preferredFields: ALL_PREFERRED },
85
102
  {
@@ -100,6 +117,12 @@ export const RTE_CATALOG = [
100
117
  store: 'SessionHijackingEventStore',
101
118
  preferredFields: ALL_PREFERRED,
102
119
  },
120
+ { base: 'LoginAnomalyEvent', store: 'LoginAnomalyEventStore', preferredFields: ALL_PREFERRED },
121
+ {
122
+ base: 'UniversalAnomalyEvent',
123
+ store: 'UniversalAnomalyEventStore',
124
+ preferredFields: ALL_PREFERRED,
125
+ },
103
126
  // Exist, but are streaming-only with no Store in any org probed — so they can never be
104
127
  // captured retroactively. Kept deliberately: the manifest recording them as `not-queryable`
105
128
  // is real coverage information. "This event type exists and cannot be read after the fact"
@@ -107,7 +130,8 @@ export const RTE_CATALOG = [
107
130
  // apart before it reports an absence.
108
131
  { base: 'ConcurLongRunApexErrEvent', preferredFields: ALL_PREFERRED },
109
132
  { base: 'OrgLifecycleNotification', preferredFields: ALL_PREFERRED },
110
- // `ApexExecutionEvent` was here and is gone: absent from describe in all five orgs, so the
133
+ { base: 'ApiPrtcPolicyChangeEvent', preferredFields: ALL_PREFERRED },
134
+ // `ApexExecutionEvent` was here and is gone: absent from describe in all eight orgs, so the
111
135
  // name appears not to exist rather than to be unlicensed. It cost a 404 per pull.
112
136
  ];
113
137
  //# sourceMappingURL=rteCatalog.js.map
@@ -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, ...(overrides ?? {}) };
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.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.0",
77
+ "js-yaml@3": "^3.15.1",
75
78
  "handlebars": "^4.7.9",
76
- "brace-expansion": "^5.0.8",
77
- "fast-uri@3": "^3.1.4"
79
+ "brace-expansion": "^5.0.9",
80
+ "fast-uri@3": "^3.1.6"
78
81
  }
79
82
  },
80
83
  "peerDependencies": {