@openreachtech/hora-skills-ort-renchan 0.2.1 → 0.3.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.
@@ -9,7 +9,7 @@ These follow the **`hoc-jest` skill** — read it for the general rules; this fi
9
9
  applies them to the agent-loop classes. In short: one file per class; nest
10
10
  `describe(ClassName) > describe('#member()' / '.get:member') > describe('should …') > test.each(cases)`;
11
11
  write each test as **Arrange / Act / Assert** separated by blank lines, taking the Act result into a
12
- `received` variable; bind every `jest.fn()` to a `~Spy` variable; and keep `cases` data unique and
12
+ `received` variable; bind every spy to a `~Spy` variable; and keep `cases` data unique and
13
13
  index-readable (`fake-keyword-0001`, `100001`, …).
14
14
 
15
15
  ## Grand principle: swap `context` for a stub and touch no real I/O
@@ -91,19 +91,18 @@ describe('SearchAction', () => {
91
91
  ]
92
92
 
93
93
  test.each(cases)('keyword: $tally.keyword', async ({ tally }) => {
94
- const searchSpy = jest.fn()
95
- .mockResolvedValue({
96
- items: [], // neutral; not under test
97
- })
98
94
  const args = {
99
95
  argumentHash: tally,
100
96
  context: {
101
97
  searchClient: {
102
- search: searchSpy,
98
+ search: async () => ({
99
+ items: [], // neutral; not under test
100
+ }),
103
101
  },
104
102
  },
105
- onProgress: jest.fn(),
103
+ onProgress: () => {},
106
104
  }
105
+ const searchSpy = jest.spyOn(args.context.searchClient, 'search')
107
106
 
108
107
  await SearchAction.create()
109
108
  .run(args)
@@ -138,18 +137,16 @@ describe('SearchAction', () => {
138
137
  ]
139
138
 
140
139
  test.each(cases)('keyword: $input.keyword', async ({ input, expected }) => {
141
- const searchSpy = jest.fn()
142
- .mockResolvedValue(expected)
143
140
  const args = {
144
141
  argumentHash: {
145
142
  keyword: input.keyword,
146
143
  },
147
144
  context: {
148
145
  searchClient: {
149
- search: searchSpy,
146
+ search: async () => expected,
150
147
  },
151
148
  },
152
- onProgress: jest.fn(),
149
+ onProgress: () => {},
153
150
  }
154
151
 
155
152
  const received = await SearchAction.create()
@@ -281,7 +278,7 @@ describe('ResearchJobWorker', () => {
281
278
  const worker = new ResearchJobWorker({
282
279
  engine: {
283
280
  subscriptionBroker: {
284
- publish: jest.fn(),
281
+ publish: async () => null,
285
282
  },
286
283
  },
287
284
  config: {
@@ -295,7 +292,6 @@ describe('ResearchJobWorker', () => {
295
292
  errorHash: {},
296
293
  })
297
294
 
298
- const updateProgressSpy = jest.fn()
299
295
  const args = {
300
296
  body: {
301
297
  jobId: input.jobId,
@@ -304,11 +300,12 @@ describe('ResearchJobWorker', () => {
304
300
  parcel: {
305
301
  jobModel: {
306
302
  job: {
307
- updateProgress: updateProgressSpy,
303
+ updateProgress: async () => null,
308
304
  },
309
305
  },
310
306
  },
311
307
  }
308
+ const updateProgressSpy = jest.spyOn(args.parcel.jobModel.job, 'updateProgress')
312
309
 
313
310
  await worker.executeJob(args)
314
311
 
@@ -366,11 +363,6 @@ describe('RequestResearchMutationResolver', () => {
366
363
  errorHash: {},
367
364
  })
368
365
 
369
- const dispatchJobSpy = jest.fn()
370
- .mockResolvedValue({
371
- hasResponse: () => true,
372
- idKey: expected.jobId,
373
- })
374
366
  const args = {
375
367
  variables: {
376
368
  input: {
@@ -380,7 +372,10 @@ describe('RequestResearchMutationResolver', () => {
380
372
  context: {
381
373
  share: {
382
374
  jobDispatcherProvider: {
383
- dispatchJob: dispatchJobSpy,
375
+ dispatchJob: async () => ({
376
+ hasResponse: () => true,
377
+ idKey: expected.jobId,
378
+ }),
384
379
  },
385
380
  },
386
381
  },
@@ -195,7 +195,13 @@ by default: `NODE_ENV=<stack-env>` selects the E2E stack's own values everywhere
195
195
  on every command remembering to apply overrides.
196
196
 
197
197
  The stack reads its own committed **`.env.<stack-env>`**, at the repository root beside the other
198
- environments' files. Two rules govern that file:
198
+ environments' files. Three rules govern that file:
199
+
200
+ - **It holds only values that reach the local machine.** It is a local env file, which may be
201
+ committed only on that condition: endpoints on `127.0.0.1` or `localhost`, placeholder credentials,
202
+ the connection of the stack's own database. An external host, a real staging or production endpoint,
203
+ or a key-shaped value — an API key, a token — never goes in it. This is the line the security
204
+ audit's checks 12 to 14 hold, and it reads the file to confirm it.
199
205
 
200
206
  - **It is a complete, standalone description of the E2E stack.** Every key the application, the
201
207
  tooling and the background processes read has to be present, because a missing key reads as `null`
@@ -39,17 +39,19 @@ The unit-test conventions for an external API client. The files live under
39
39
  - That the base launcher extends `BaseLauncher`, and that `clientConfig` returns the expected
40
40
  connection settings.
41
41
  - That the derived launcher's `Payload` / `Capsule` return the right classes.
42
- - That `launchRequest()`, with **`fetch` stubbed** (by replacing `static get fetch ()`), is called with
43
- the correct `Request` (URL, method, headers, body) and returns a `Capsule`.
42
+ - That `launchRequest()`, with **`fetch` spied** (`static get fetch ()` returns the native one, so the
43
+ spy goes there), is called with the correct `Request` (URL, method, headers, body) and returns a
44
+ `Capsule`.
44
45
  - For an SDK wrapper ([sdk-wrapper.md](./sdk-wrapper.md)), inject a stub SDK through
45
46
  `create({ sdkClient })` and assert that `launchRequest()` calls the SDK method with the right
46
47
  arguments and returns the result carried in a `Capsule`.
47
48
 
48
- ## Replace `fetch` by overriding it in a sub-class
49
+ ## Spy the native `fetch` the getter returns
49
50
 
50
- Stub `fetch` by creating an anonymous class inside the test that extends `CreateDocumentLauncher` and
51
- overrides `static get fetch ()`. Have `jest.fn().mockResolvedValue(...)` return a `Response`, then assert
52
- that it was called and what the `Capsule` extracted.
51
+ `static get fetch ()` returns the native `fetch`, so leave the getter alone and spy the real function
52
+ it hands back — the shape `hoc-jest` gives for a getter that returns a function. Have
53
+ `jest.spyOn(globalThis, 'fetch').mockResolvedValue(...)` return a `Response`, then assert that it was
54
+ called and what the `Capsule` extracted. No sub-class is needed.
53
55
 
54
56
  ```js
55
57
  import CreateDocumentLauncher from '../../../../app/documentApiClient/CreateDocumentLauncher.js'
@@ -97,19 +99,12 @@ describe('CreateDocumentLauncher', () => {
97
99
  status: 200,
98
100
  }
99
101
  )
100
- const fetchSpy = jest.fn()
102
+ const fetchSpy = jest.spyOn(globalThis, 'fetch')
101
103
  .mockResolvedValue(responseTally)
102
104
 
103
- const SpyLauncher = class extends CreateDocumentLauncher {
104
- /** @override */
105
- static get fetch () {
106
- return fetchSpy
107
- }
108
- }
109
-
110
- const launcher = SpyLauncher.create()
105
+ const launcher = CreateDocumentLauncher.create()
111
106
 
112
- const payload = SpyLauncher.createPayload(params)
107
+ const payload = CreateDocumentLauncher.createPayload(params)
113
108
 
114
109
  const capsule = await launcher.launchRequest({
115
110
  payload,
@@ -146,12 +146,12 @@ The full template with every helper filled in is in
146
146
  ## 3. `errorCodeHash` and throwing errors
147
147
 
148
148
  Declare every error the resolver can raise in `static get errorCodeHash ()`, spreading
149
- `...super.errorCodeHash` first. Each entry maps an `ErrorName` to a **code string** whose leading
150
- segment encodes the category:
149
+ `...super.errorCodeHash` first. Each entry maps an `ErrorName` to a **code string**, whose shape
150
+ and categories `hoc-error-codes` settles. The ones a mutation resolver reaches for:
151
151
 
152
- - `203.*` — **invalid input** (`InvalidXxx`). These pair with the validator's predicates (§6).
153
- - `204.*` — **DB / state** errors (`XxxNotFound`, `NotAllowedToXxx`, `CurrentXxxIsSameAsTheNewOne`).
154
- - `205.*` — **auth** errors (`InvalidCredentials`).
152
+ - `203.*` — **validational** (`InvalidXxx`). These pair with the validator's predicates (§6).
153
+ - `204.*` — **database record** (`XxxNotFound`, `NotAllowedToXxx`, `CurrentXxxIsSameAsTheNewOne`).
154
+ - `202.*` — **access right** (`InvalidCredentials`).
155
155
 
156
156
  ```js
157
157
  /** @override */
@@ -173,7 +173,7 @@ static get errorCodeHash () {
173
173
  The base turns this hash into constructable error classes on `this.errorHash` (via
174
174
  `buildErrorHash()` in the factory). **Throw with `this.errorHash.<Name>.create()`** — validator
175
175
  errors bubble out of `resolve()`; state errors are thrown from inside the transaction callback so
176
- the transaction rolls back. Codes, numbering (`M###`), and the wiring are in
176
+ the transaction rolls back. Which category each error falls into, and the wiring, are in
177
177
  [errors.md](./references/errors.md).
178
178
 
179
179
  ## 4. `generateTransactionCallback()` — one transaction, all writes
@@ -352,7 +352,7 @@ project-wide jest rules unchanged. Full placement detail in [testing.md](./refer
352
352
  - [transaction.md](./references/transaction.md) — `generateTransactionCallback` in depth:
353
353
  one-transaction rule, `beginTransaction`, nested-create `include`, existence guards, `.set()`+
354
354
  `.save()` vs `.update()`, throwing state errors, post-commit side effects (§4)
355
- - [errors.md](./references/errors.md) — `errorCodeHash` categories (203/204/205), `M###` numbering,
355
+ - [errors.md](./references/errors.md) — which category each error falls into,
356
356
  `this.errorHash.<Name>.create()`, and how the base builds the error hash (§3)
357
357
  - [dependency-injection.md](./references/dependency-injection.md) — `constructor` + `static create()`
358
358
  + `static createXxx()` factory helpers, when to inject, `buildErrorHash` wiring (§7)
@@ -22,28 +22,25 @@ static get errorCodeHash () {
22
22
  // Database Errors
23
23
  UserNotFound: '204.M024.001',
24
24
 
25
- // Authentication Errors
26
- InvalidCredentials: '205.M024.001',
25
+ // Access Right Errors
26
+ InvalidCredentials: '202.M024.001',
27
27
  }
28
28
  }
29
29
  ```
30
30
 
31
- ## The code string: `<category>.<M###>.<seq>`
32
-
33
- Each value is a dotted string with three parts:
34
-
35
- - **`<category>`** — the leading segment classifies the failure:
36
- - `203` — **invalid input**. Names are `InvalidXxx` and correspond 1:1 to the validator's
37
- predicates (`InvalidTitle` ↔ `isValidTitle`), per the project's resolver-validator conventions.
38
- - `204` — **DB / state**. `XxxNotFound`, `NotAllowedToXxx`, `CurrentXxxIsSameAsTheNewOne`. Thrown
39
- from inside the transaction callback ([transaction.md](./transaction.md)).
40
- - `205` — **auth**. `InvalidCredentials` and the like.
41
- - **`<M###>`** — the resolver's own identifier (`M024`, `M027`, `M043`, …). All codes in one
42
- resolver share the same `M###`; it is unique per resolver so a code pins down which resolver
43
- raised it.
44
- - **`<seq>`** — a zero-padded running number within the resolver (`001`, `002`, …). Numbering is
45
- usually contiguous within a category; a gap from a removed code is fine — do not renumber existing
46
- codes (they may be referenced by clients).
31
+ ## Which category an error falls into
32
+
33
+ The code string itself is settled by `hoc-error-codes` — its three parts, the categories the
34
+ leading one sorts a failure into, and the rule that a code already in use is never renumbered.
35
+ What a mutation resolver decides is which category each of its own errors belongs to, and where
36
+ that error is thrown from.
37
+
38
+ - **`203`, validational.** Names are `InvalidXxx` and correspond 1:1 to the validator's predicates
39
+ (`InvalidTitle` ↔ `isValidTitle`), per the project's resolver-validator conventions.
40
+ - **`204`, database record.** `XxxNotFound`, `NotAllowedToXxx`, `CurrentXxxIsSameAsTheNewOne`.
41
+ Thrown from inside the transaction callback ([transaction.md](./transaction.md)).
42
+ - **`202`, access right.** A credential that does not match, a principal barred from what it asked
43
+ for — `InvalidCredentials` and the like.
47
44
 
48
45
  - **Name = the reason, not the field alone.** `InvalidPublishedAt`, `TagNotFound`,
49
46
  `NotAllowedToEditArticle` — read as a sentence at the throw site. No `info`/`data`/`error`
@@ -271,19 +271,20 @@ split files per class.
271
271
  - **On success** (`error: null`, `output` present) → **dispatch is called** with the expected
272
272
  `DispatcherCtor` and `body`.
273
273
  - **On failure** (`error` present) → **dispatch is not called** (early return).
274
- - Stub the dispatch entry point. Replace `context.share.jobDispatcherProvider.dispatchJob` with a
275
- `jest.fn()` and verify the arguments (`DispatcherCtor` / `body`). **Don't actually enqueue a job.**
274
+ - Stub the dispatch entry point. Give `context.share.jobDispatcherProvider.dispatchJob` a stub
275
+ function, spy that property with `jest.spyOn()`, and verify the arguments (`DispatcherCtor` /
276
+ `body`). **Don't actually enqueue a job.**
276
277
 
277
278
  ```js
278
279
  // Success case: verify only that dispatch is called with the correct Dispatcher and body
279
- const dispatchJobSpy = jest.fn()
280
280
  const context = {
281
281
  share: {
282
282
  jobDispatcherProvider: {
283
- dispatchJob: dispatchJobSpy,
283
+ dispatchJob: async () => null,
284
284
  },
285
285
  },
286
286
  }
287
+ const dispatchJobSpy = jest.spyOn(context.share.jobDispatcherProvider, 'dispatchJob')
287
288
 
288
289
  await SignUpPostWorker.create({ engine })
289
290
  .onResolved({
@@ -169,11 +169,10 @@ static get errorCodeHash () {
169
169
  }
170
170
  ```
171
171
 
172
- - **Leading number = error family.** `203` invalid input, `204` database / not-found, `205` business
173
- logic / external API. (Framework standards live above these: `102` unauthorized, `104` database —
174
- do not redefine them.)
175
- - **Middle segment (`Q002`) is a stable per-query identifier**; the trailing `001…` numbers the
176
- errors within this resolver. Keep a given resolver on one identifier and add sequentially.
172
+ - **The code's shape and its categories are settled by `hoc-error-codes`.** What a query resolver
173
+ decides is which category each of its own errors takes: `203` for what the validator rejects,
174
+ `204` for what the database does not hold. The framework's own codes are declared by the engine
175
+ below, and are never redeclared here.
177
176
  - **Input-shape errors** (`InvalidXxx`) are raised by the validator via the shared `errorHash`, so
178
177
  their names must exist here. **Domain errors** (`XxxNotFound`, `NoXxxFound`) are thrown from
179
178
  `resolve()` with `this.errorHash.Xxx.create()` (optionally through a `createXxxError()` helper).
@@ -1,13 +1,13 @@
1
1
  # Errors, context, and actual-vs-stub
2
2
 
3
- The errorCodeHash prefix families, the validator↔errorHash contract, domain-error creators, reading
4
- auth and injected providers off `context`, and the actual-vs-stub split. Referenced from §1 and §4 of
5
- [SKILL.md](../SKILL.md).
3
+ The categories a query resolver's codes take, the validator↔errorHash contract, domain-error
4
+ creators, reading auth and injected providers off `context`, and the actual-vs-stub split.
5
+ Referenced from §1 and §4 of [SKILL.md](../SKILL.md).
6
6
 
7
7
  > The `users` / `User` / `Department` names and the `Q001` / `Q002` identifiers are placeholders —
8
8
  > swap in your resource and this resolver's own identifier.
9
9
 
10
- ## errorCodeHash: families and identifiers
10
+ ## errorCodeHash: which category each error takes
11
11
 
12
12
  `errorCodeHash` maps each error **name** to a **string code**; the framework's `create()` turns those
13
13
  into the `this.errorHash.<Name>` constructors the resolver and its validator throw. Always spread
@@ -30,18 +30,14 @@ static get errorCodeHash () {
30
30
  }
31
31
  ```
32
32
 
33
- Code format is `<family>.<identifier>.<seq>`:
34
-
35
- - **`<family>`** — the leading number classifies the error:
36
- - `203` — invalid input (raised by the `*InputValidator`).
37
- - `204` — database / not-found (thrown from `resolve()`).
38
- - `205` — business logic / external API.
39
- - Framework standards sit above these and are already defined by the engine — do **not** redeclare
40
- them: `102` unauthenticated / unauthorized / denied-permission, `104` database, `100` unknown,
41
- `101` concrete-member-not-found.
42
- - **`<identifier>`** (`Q002`, …) is a **stable per-query id**. Keep one resolver on one identifier;
43
- the letter tracks the endpoint family (`Q` for the query endpoints).
44
- - **`<seq>`** (`001`, `002`, …) numbers the errors within this resolver, per family.
33
+ The code's shape, and the categories its leading digits sort a failure into, are settled by
34
+ `hoc-error-codes`. What a query resolver decides is which category each of its own errors takes:
35
+
36
+ - `203` — validational, raised by the `*InputValidator`.
37
+ - `204` — database record, thrown from `resolve()`.
38
+
39
+ The framework's own codes are already declared by the engine — `102` access right, `104` database
40
+ record, `100` unknown, `101` implementational — and a resolver never redeclares one.
45
41
 
46
42
  ## The validator ↔ errorHash contract
47
43
 
@@ -76,8 +76,8 @@ type). **LOW** = hardening gap. **INFO** = worth noting, not a vulnerability.
76
76
  | 9 | Introspection / playground / debug endpoints disabled in prod | [auth-and-transport.md](./references/auth-and-transport.md) |
77
77
  | 10 | CORS scoped (not wildcard in production) | [auth-and-transport.md](./references/auth-and-transport.md) |
78
78
  | 11 | Rate limiting on public endpoints (and not bypassable) | [auth-and-transport.md](./references/auth-and-transport.md) |
79
- | 12 | Env files covered by `.gitignore` (all variants) | [secrets.md](./references/secrets.md) |
80
- | 13 | No secrets in committed env files; secret-free template present | [secrets.md](./references/secrets.md) |
79
+ | 12 | Production-facing env files covered by `.gitignore` | [secrets.md](./references/secrets.md) |
80
+ | 13 | Committed env files hold only values that reach the local machine | [secrets.md](./references/secrets.md) |
81
81
  | 14 | No hardcoded secrets in code / config | [secrets.md](./references/secrets.md) |
82
82
  | 15 | No plaintext passwords / secrets in seed / fixture data | [secrets.md](./references/secrets.md) |
83
83
  | 16 | No vulnerable dependencies (advisory audit) | [dependencies.md](./references/dependencies.md) |
@@ -4,50 +4,65 @@
4
4
  plaintext passwords in seed / fixture data. Referenced from [SKILL.md](../SKILL.md). **Mask every
5
5
  secret value in the report.**
6
6
 
7
- ## 12. Env files covered by `.gitignore` (all variants)
7
+ ## 12. Production-facing env files covered by `.gitignore`
8
+
9
+ Env files fall on two sides of one line, and the check differs by side.
10
+
11
+ | Side | Files | May be tracked |
12
+ |---|---|---|
13
+ | **production-facing** | `.env`, `.env.production`, `.env.prod`, `.env.staging` | never. `.env.staging` is shared with a client at times, so it is held as production |
14
+ | **local** | every other per-environment file — `.env.development`, `.env.live`, `.env.live-local`, `.env.test` and their like | yes, holding only values that reach the local machine (check 13) |
8
15
 
9
16
  A `.gitignore` with a bare `.env` line matches **only** a file named exactly `.env` — it does **not**
10
- match `.env.development`, `.env.staging`, `.env.production`, `.env.local`, etc. Those variants stay
11
- trackable and are easily committed with real secrets.
17
+ match `.env.production`, `.env.staging` or `.env.prod`. Those stay trackable and are easily committed
18
+ with real secrets.
12
19
 
13
20
  ```bash
14
21
  ls -a | grep -E '^\.env' # which env files exist on disk
15
22
  git check-ignore -v .env .env.* 2>/dev/null # prints the matching rule for each IGNORED file
16
- git ls-files | grep -E '(^|/)\.env' # env files TRACKED in git (should usually be only a template)
23
+ git ls-files | grep -E '(^|/)\.env' # env files TRACKED in git — sort each onto its side
17
24
  ```
18
25
 
19
26
  - **Important:** adding a pattern to `.gitignore` does **not** untrack a file that is already
20
- committed — `.gitignore` only affects untracked files. If an env file is already tracked, it must be
21
- removed from the index with `git rm --cached <file>` (and the secret rotated). Verify with
22
- `git ls-files`, not just by reading `.gitignore`.
23
- - **FINDING (HIGH if the tracked file holds real secrets, else MEDIUM):** any `.env*` file with
24
- secrets is **tracked** or **not ignored**. Recommend a broad ignore (e.g. `.env*` with a
25
- `!.env.example` negation), `git rm --cached` for anything already tracked, and — if a secret was
26
- ever committed — rotating it and purging history.
27
- - **PASS:** every secret-bearing env file is ignored; only a secret-free template is tracked.
28
-
29
- ## 13. No secrets in committed env files; secret-free template present
30
-
31
- Committed env files (a template, or any per-env file that is tracked) must not carry real secret
32
- **values**. Inspect key names and whether their values are populated — **do not echo the values**;
33
- grep key names and mask.
27
+ committed — `.gitignore` only affects untracked files. If a production-facing env file is already
28
+ tracked, it must be removed from the index with `git rm --cached <file>` (and the secret rotated).
29
+ Verify with `git ls-files`, not just by reading `.gitignore`.
30
+ - **FINDING (HIGH if the tracked file holds real secrets, else MEDIUM):** a production-facing env file
31
+ is **tracked** or **not ignored**. Recommend ignoring each by name, `git rm --cached` for anything
32
+ already tracked, and — if a secret was ever committed — rotating it and purging history.
33
+ - **A local env file that is tracked is not a finding here.** Tracking it is allowed; what it holds
34
+ is judged in check 13.
35
+ - **PASS:** every production-facing env file is ignored and untracked.
36
+
37
+ ## 13. Committed env files hold only values that reach the local machine
38
+
39
+ A tracked local env file (check 12) is allowed on a condition, so **every one is read, every time** —
40
+ this check is never skipped, and never answered from the file's name. Read each file, and report
41
+ values **masked**: whether a value is local is judged on its shape, and the report never echoes it.
42
+
43
+ | Allowed in a local env file | A finding wherever it sits |
44
+ |---|---|
45
+ | an endpoint on `127.0.0.1` or `localhost` — `http://localhost:3000` included | an external host |
46
+ | a placeholder credential — `user` / `password` and their like | a real staging or production endpoint |
47
+ | the connection of a CI or test database (`live`) | a key-shaped value — an API key, a token, a private key |
34
48
 
35
49
  ```bash
36
- # For each TRACKED env file (from check 12), list secret-bearing key NAMES only:
50
+ # For each TRACKED local env file (from check 12), list every key, whether it holds a value MASKED:
37
51
  git ls-files | grep -E '(^|/)\.env' | while read f; do echo "== $f =="; \
38
- grep -oE '^[A-Za-z0-9_]+=' "$f" 2>/dev/null | grep -iE 'PASSWORD|SECRET|TOKEN|API_?KEY|PRIVATE|CREDENTIAL|_KEY|DSN|CONNECTION'; done
39
- # For each such key, check ONLY whether a value is present, and MASK it, e.g.:
40
- # grep -E '^SOME_API_KEY=' <file> | sed -E 's/=.{0,4}.*/=****(masked)/'
52
+ sed -E 's/=.+$/=****(masked)/' "$f"; done
53
+ # Hosts are the one value read in full, since locality is the point: any that is not local is a
54
+ # finding. Credentials inside a URL are masked first:
55
+ git ls-files | grep -E '(^|/)\.env' | xargs grep -nE '(HOST|URL|ENDPOINT|DSN)[A-Z_]*=' \
56
+ | sed -E 's#://[^@/]*@#://****@#' \
57
+ | grep -vE '=([a-z+]+://)?(\*\*\*\*@)?(127\.0\.0\.1|localhost)([:/]|$)'
41
58
  ```
42
59
 
43
- - **FINDING (HIGH):** a real secret value sits in a committed env file. Recommend replacing it with a
44
- placeholder, moving the real value to an untracked file / secret manager, and rotating.
45
- - **Best practice to recommend:** keep exactly one committed, **secret-free** template (e.g.
46
- `.env.example`) listing every required key with placeholder values, and source **all** real
47
- credentials for non-local environments from env / a secret manager — never commit them, and do
48
- not leave per-env files (`.env.staging`, `.env.production`) tracked.
49
- - **PASS:** values are empty / obvious placeholders (`your-key-here`, `changeme`, `xxxx`), and a
50
- secret-free template exists.
60
+ - **An auditor told not to read env files reports this check as BLOCKED, never as passed.** The
61
+ allowance in check 12 rests on this reading; without it, nothing says the file stayed local.
62
+ - **FINDING (HIGH):** a tracked local env file holds a value outside the allowed column — an external
63
+ host, a real staging or production endpoint, a key-shaped value. Recommend moving the value to a
64
+ production-facing file or a secret manager, and rotating it if it was real.
65
+ - **PASS:** every tracked local env file holds only allowed values.
51
66
 
52
67
  ## 14. No hardcoded secrets in code / config
53
68
 
@@ -62,12 +77,23 @@ git grep -nE "AIza[0-9A-Za-z_-]{20,}|sk-[A-Za-z0-9]{20,}|ghp_[A-Za-z0-9]{20,}|AK
62
77
  ```
63
78
 
64
79
  - **Pay special attention to connection / datastore config files** — per-environment blocks commonly
65
- carry hardcoded `username` / `password`. Hardcoded credentials in a committed config file are a
66
- finding **even if they look like placeholders**, because they normalize the pattern; production
67
- credentials should come from env / a secret manager.
68
- - **FINDING (HIGH real / MEDIUM placeholder):** a literal credential in tracked code / config.
69
- Recommend sourcing from env / a secret manager; rotate if real.
70
- - **PASS:** credentials only ever come from `process.env` / a config facade.
80
+ carry hardcoded `username` / `password`. **A production or staging block takes its credentials from
81
+ the environment**, and a literal there is a finding even if it looks like a placeholder, because
82
+ it normalizes the pattern where it does harm.
83
+ - **The same line as check 13 holds outside env files.** A placeholder credential is not a finding
84
+ where only the local machine is reached by it:
85
+
86
+ | Not a finding | Why |
87
+ |---|---|
88
+ | the compose of local middleware whose ports are published on `127.0.0.1` only | nothing off the machine reaches it |
89
+ | the config of a CI or test database | it holds test data, and is rebuilt from nothing |
90
+
91
+ A port published on every interface (`3306:3306`, `0.0.0.0:…`) takes the compose out of the first
92
+ row, and its credentials are a finding again.
93
+ - **FINDING (HIGH real / MEDIUM placeholder):** a literal credential in tracked code / config, outside
94
+ the two rows above. Recommend sourcing from env / a secret manager; rotate if real.
95
+ - **PASS:** credentials come from `process.env` / a config facade, or are placeholders where only the
96
+ local machine reaches them.
71
97
 
72
98
  ## 15. No plaintext passwords / secrets in seed / fixture data
73
99
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openreachtech/hora-skills-ort-renchan",
3
- "version": "0.2.1",
3
+ "version": "0.3.0",
4
4
  "description": "Distributes the renchan backend skills used to develop with Hora Kit.",
5
5
  "type": "module",
6
6
  "files": [
@@ -49,11 +49,15 @@
49
49
  "@openreachtech/renchan-env": "^1.0.6",
50
50
  "@types/jest": "^30.0.0",
51
51
  "eslint": "^9.39.5",
52
- "jest": "^30.5.1"
52
+ "jest": "^30.5.2"
53
53
  },
54
54
  "overrides": {
55
55
  "@humanfs/node": "^0.16.8",
56
- "brace-expansion@5": "^5.0.9",
56
+ "@istanbuljs/load-nyc-config": {
57
+ "js-yaml": "^4.3.2"
58
+ },
59
+ "brace-expansion@1": "^1.1.21",
60
+ "brace-expansion@5": "^5.0.12",
57
61
  "flatted": "^3.4.4"
58
62
  },
59
63
  "allowScripts": {