@openreachtech/hora-skills-ort-renchan 0.0.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.
Files changed (126) hide show
  1. package/LICENSE +201 -0
  2. package/README.ja.md +135 -0
  3. package/README.md +135 -0
  4. package/dist/skills/hor-agent-loop/SKILL.md +123 -0
  5. package/dist/skills/hor-agent-loop/references/core.md +485 -0
  6. package/dist/skills/hor-agent-loop/references/graphql-integration.md +178 -0
  7. package/dist/skills/hor-agent-loop/references/renchan-job-integration.md +368 -0
  8. package/dist/skills/hor-agent-loop/references/testing.md +492 -0
  9. package/dist/skills/hor-ai-agent-structure/SKILL.md +403 -0
  10. package/dist/skills/hor-ai-agent-structure/references/loop-and-actions.md +100 -0
  11. package/dist/skills/hor-ai-prompt-document-store/SKILL.md +220 -0
  12. package/dist/skills/hor-ai-prompt-document-store/references/models-and-composition.md +156 -0
  13. package/dist/skills/hor-backend-testing/SKILL.md +118 -0
  14. package/dist/skills/hor-backend-testing/references/placement-and-ordering.md +89 -0
  15. package/dist/skills/hor-backend-testing/references/purity-and-mocks.md +82 -0
  16. package/dist/skills/hor-backend-testing/references/running-tests.md +186 -0
  17. package/dist/skills/hor-bank-id/SKILL.md +91 -0
  18. package/dist/skills/hor-build-e2e-test-environment/SKILL.md +609 -0
  19. package/dist/skills/hor-build-e2e-test-environment/references/compose-definition.md +368 -0
  20. package/dist/skills/hor-build-e2e-test-environment/references/edge-and-proxy.md +287 -0
  21. package/dist/skills/hor-build-e2e-test-environment/references/environment-and-ports.md +201 -0
  22. package/dist/skills/hor-build-e2e-test-environment/references/runner-and-lifecycle.md +330 -0
  23. package/dist/skills/hor-build-e2e-test-environment/references/seed-data.md +145 -0
  24. package/dist/skills/hor-build-e2e-test-environment/references/windows-runner.md +146 -0
  25. package/dist/skills/hor-constant-definition/SKILL.md +139 -0
  26. package/dist/skills/hor-cookie-authentication/SKILL.md +33 -0
  27. package/dist/skills/hor-cookie-authentication/references/auth-filter.md +55 -0
  28. package/dist/skills/hor-cookie-authentication/references/cookie-context.md +53 -0
  29. package/dist/skills/hor-cookie-authentication/references/dev-login-seeder.md +22 -0
  30. package/dist/skills/hor-cookie-authentication/references/environment.md +64 -0
  31. package/dist/skills/hor-cookie-authentication/references/error-codes.md +24 -0
  32. package/dist/skills/hor-cookie-authentication/references/migrations.md +18 -0
  33. package/dist/skills/hor-cookie-authentication/references/resolvers.md +97 -0
  34. package/dist/skills/hor-cookie-authentication/references/session-clerk.md +41 -0
  35. package/dist/skills/hor-cookie-authentication/references/token-models.md +125 -0
  36. package/dist/skills/hor-database-design/SKILL.md +54 -0
  37. package/dist/skills/hor-database-design/references/column-types.md +92 -0
  38. package/dist/skills/hor-database-design/references/datetimes.md +88 -0
  39. package/dist/skills/hor-database-design/references/master-tables.md +117 -0
  40. package/dist/skills/hor-database-design/references/normalization.md +40 -0
  41. package/dist/skills/hor-database-design/references/update-history.md +35 -0
  42. package/dist/skills/hor-execution-placement-pattern/SKILL.md +216 -0
  43. package/dist/skills/hor-external-api-client/SKILL.md +99 -0
  44. package/dist/skills/hor-external-api-client/references/architecture.md +127 -0
  45. package/dist/skills/hor-external-api-client/references/authorization.md +105 -0
  46. package/dist/skills/hor-external-api-client/references/capsule.md +130 -0
  47. package/dist/skills/hor-external-api-client/references/conventions.md +68 -0
  48. package/dist/skills/hor-external-api-client/references/launcher.md +138 -0
  49. package/dist/skills/hor-external-api-client/references/payload.md +176 -0
  50. package/dist/skills/hor-external-api-client/references/sdk-wrapper.md +291 -0
  51. package/dist/skills/hor-external-api-client/references/testing.md +130 -0
  52. package/dist/skills/hor-external-api-client/references/usage.md +152 -0
  53. package/dist/skills/hor-graphql-schema/SKILL.md +360 -0
  54. package/dist/skills/hor-graphql-server-engine/SKILL.md +356 -0
  55. package/dist/skills/hor-light-rag/SKILL.md +242 -0
  56. package/dist/skills/hor-light-rag/references/retrieval-internals.md +143 -0
  57. package/dist/skills/hor-multi-llm-provider/SKILL.md +288 -0
  58. package/dist/skills/hor-multi-llm-provider/references/provider-internals.md +153 -0
  59. package/dist/skills/hor-mutation-resolver/SKILL.md +360 -0
  60. package/dist/skills/hor-mutation-resolver/references/dependency-injection.md +148 -0
  61. package/dist/skills/hor-mutation-resolver/references/errors.md +120 -0
  62. package/dist/skills/hor-mutation-resolver/references/resolve-flow.md +275 -0
  63. package/dist/skills/hor-mutation-resolver/references/testing.md +125 -0
  64. package/dist/skills/hor-mutation-resolver/references/transaction.md +197 -0
  65. package/dist/skills/hor-post-worker/SKILL.md +320 -0
  66. package/dist/skills/hor-query-resolver/SKILL.md +246 -0
  67. package/dist/skills/hor-query-resolver/references/anatomy.md +384 -0
  68. package/dist/skills/hor-query-resolver/references/data-access.md +248 -0
  69. package/dist/skills/hor-query-resolver/references/errors-and-context.md +172 -0
  70. package/dist/skills/hor-query-resolver/references/testing.md +241 -0
  71. package/dist/skills/hor-renchan-job-bullmq/SKILL.md +178 -0
  72. package/dist/skills/hor-renchan-job-bullmq/references/daemon-and-scheduler.md +182 -0
  73. package/dist/skills/hor-renchan-job-bullmq/references/engine-and-infra.md +106 -0
  74. package/dist/skills/hor-renchan-job-bullmq/references/job-triple.md +189 -0
  75. package/dist/skills/hor-renchan-job-bullmq/references/queues.md +74 -0
  76. package/dist/skills/hor-renchan-job-bullmq/references/subscriptions.md +113 -0
  77. package/dist/skills/hor-resolver-share/SKILL.md +262 -0
  78. package/dist/skills/hor-resolver-validator/SKILL.md +194 -0
  79. package/dist/skills/hor-resolver-validator/references/inspector-api.md +115 -0
  80. package/dist/skills/hor-resolver-validator/references/validator-pattern.md +281 -0
  81. package/dist/skills/hor-restfulapi-architecture/SKILL.md +275 -0
  82. package/dist/skills/hor-restfulapi-architecture/references/engine-and-context.md +192 -0
  83. package/dist/skills/hor-restfulapi-architecture/references/renderers.md +204 -0
  84. package/dist/skills/hor-restfulapi-architecture/references/response-and-flusher.md +118 -0
  85. package/dist/skills/hor-restfulapi-architecture/references/validation.md +229 -0
  86. package/dist/skills/hor-security-audit/SKILL.md +110 -0
  87. package/dist/skills/hor-security-audit/references/application-surface.md +90 -0
  88. package/dist/skills/hor-security-audit/references/auth-and-transport.md +147 -0
  89. package/dist/skills/hor-security-audit/references/code-safety.md +74 -0
  90. package/dist/skills/hor-security-audit/references/dependencies.md +72 -0
  91. package/dist/skills/hor-security-audit/references/network-and-logging.md +56 -0
  92. package/dist/skills/hor-security-audit/references/secrets.md +95 -0
  93. package/dist/skills/hor-sequelize-migration/SKILL.md +336 -0
  94. package/dist/skills/hor-sequelize-migration/references/alter-table.md +147 -0
  95. package/dist/skills/hor-sequelize-migration/references/foreign-keys.md +107 -0
  96. package/dist/skills/hor-sequelize-migration/references/indexes.md +149 -0
  97. package/dist/skills/hor-sequelize-migration/references/notation.md +215 -0
  98. package/dist/skills/hor-sequelize-model/SKILL.md +69 -0
  99. package/dist/skills/hor-sequelize-model/references/associations.md +218 -0
  100. package/dist/skills/hor-sequelize-model/references/default-methods.md +244 -0
  101. package/dist/skills/hor-sequelize-model/references/mixins.md +247 -0
  102. package/dist/skills/hor-sequelize-model/references/notation.md +225 -0
  103. package/dist/skills/hor-sequelize-model/references/timestamps.md +74 -0
  104. package/dist/skills/hor-sequelize-seeder/SKILL.md +275 -0
  105. package/dist/skills/hor-sequelize-seeder/references/development-coverage.md +74 -0
  106. package/dist/skills/hor-sequelize-seeder/references/directory-structure.md +113 -0
  107. package/dist/skills/hor-sequelize-seeder/references/id-numbering.md +133 -0
  108. package/dist/skills/hor-sequelize-seeder/references/naming.md +59 -0
  109. package/dist/skills/hor-sequelize-seeder/references/notation.md +170 -0
  110. package/dist/skills/hor-sequelize-subquery/SKILL.md +369 -0
  111. package/dist/skills/hor-strategy-pattern/SKILL.md +371 -0
  112. package/dist/skills/hor-stub-api/SKILL.md +330 -0
  113. package/dist/skills/hor-subscription-resolver/SKILL.md +105 -0
  114. package/dist/skills/hor-subscription-resolver/references/authentication.md +99 -0
  115. package/dist/skills/hor-subscription-resolver/references/basic-notation.md +116 -0
  116. package/dist/skills/hor-subscription-resolver/references/design-philosophy.md +68 -0
  117. package/dist/skills/hor-type-interface/SKILL.md +200 -0
  118. package/docs/skills.ja.md +40 -0
  119. package/docs/skills.md +40 -0
  120. package/lib/equip/CommandLineArguments.js +178 -0
  121. package/lib/equip/HoraSkillsCli.js +590 -0
  122. package/lib/equip/SkillsInstaller.js +443 -0
  123. package/lib/equip/SkillsManifestFile.js +260 -0
  124. package/lib/equip/constants/CLI_COMMAND.js +8 -0
  125. package/lib/equip/hora-skills-ort-renchan.js +8 -0
  126. package/package.json +51 -0
@@ -0,0 +1,229 @@
1
+ # Input validation (the target shape)
2
+
3
+ The current repo validates REST input **ad hoc** inside `render()` — a hand-rolled
4
+ `isValidRequestBody()` per renderer. The **target** is to validate with the **same validator
5
+ structure the GraphQL layer uses**, so the two surfaces share one validation approach. Reaching
6
+ that needs two collaborators: an **adapter** that normalizes REST input, and a **validator** that
7
+ runs the rules.
8
+
9
+ > This page is a target design, not the current repo. Examples use a generic `Article` resource.
10
+
11
+ ## Why validation needs an adapter here
12
+
13
+ A GraphQL validator receives a single, already-typed `input` object. REST input does not arrive that
14
+ way — it is **split across `body` / `query` / path params**, and it is all **string-like** (query
15
+ and path values are strings; body values are whatever the client sent). Before any rule can run, the
16
+ input has to be **collected and coerced** into the one `input` object the validator expects. That
17
+ collect-and-coerce step is the **adapter**.
18
+
19
+ So the boundary has two responsibilities, kept in two classes:
20
+
21
+ - **Adapter** — read `{ body, query, request }`, produce a normalized `input` object (coerce types,
22
+ default missing values to `null`, merge the sources).
23
+ - **Validator** — take that `input` and decide whether each value is acceptable.
24
+
25
+ ## The validator (same structure as GraphQL)
26
+
27
+ A validator extends the shared **`BaseInputValidator`** and overrides one method:
28
+ `generateValidationEntries()`, which returns an array of **`[predicate, ErrorIdentity]`** pairs. The
29
+ base's `validateInput()` runs the predicates in order and returns the **first failing** entry's error
30
+ (or `null` when all pass). Predicates are small `isValidX()` methods that read `this.input` and
31
+ return a boolean — they never throw.
32
+
33
+ ```js
34
+ import BaseInputValidator from '../../BaseInputValidator.js'
35
+
36
+ export default class CreateArticleInputValidator extends BaseInputValidator {
37
+ /**
38
+ * @override
39
+ * @returns {Array<[() => boolean, *]>}
40
+ */
41
+ generateValidationEntries () {
42
+ return [
43
+ [
44
+ () => this.isValidTitle(),
45
+ this.errorHash.InvalidTitle,
46
+ ],
47
+ [
48
+ () => this.isValidTagIds(),
49
+ this.errorHash.InvalidTagIds,
50
+ ],
51
+ ]
52
+ }
53
+
54
+ /**
55
+ * @returns {boolean}
56
+ */
57
+ isValidTitle () {
58
+ const {
59
+ title,
60
+ } = this.input
61
+
62
+ return typeof title === 'string'
63
+ && title.length > 0
64
+ }
65
+
66
+ /**
67
+ * @returns {boolean}
68
+ */
69
+ isValidTagIds () {
70
+ const {
71
+ tagIds,
72
+ } = this.input
73
+
74
+ return Array.isArray(tagIds)
75
+ && tagIds.every(id => Number.isInteger(id))
76
+ }
77
+ }
78
+ ```
79
+
80
+ This is the **same shape** the GraphQL side uses — `generateValidationEntries()` returning
81
+ `[predicate, error]` pairs, `validateInput()` provided by the base. Only the input it validates
82
+ differs, and that difference is absorbed by the adapter.
83
+
84
+ ## The adapter
85
+
86
+ One adapter per operation. It reads the three REST sources and returns the normalized `input`.
87
+
88
+ ```js
89
+ export default class CreateArticleInputAdapter {
90
+ /**
91
+ * @param {{
92
+ * body: RestfulApiType.RenderRequestBody
93
+ * query: RestfulApiType.RenderRequestQuery
94
+ * request: RestfulApiType.Request
95
+ * }} params
96
+ * @returns {CreateArticleInputAdapter}
97
+ */
98
+ static create ({
99
+ body,
100
+ query,
101
+ request,
102
+ }) {
103
+ return new this({
104
+ body,
105
+ query,
106
+ request,
107
+ })
108
+ }
109
+
110
+ /**
111
+ * @param {{
112
+ * body: RestfulApiType.RenderRequestBody
113
+ * query: RestfulApiType.RenderRequestQuery
114
+ * request: RestfulApiType.Request
115
+ * }} params
116
+ */
117
+ constructor ({
118
+ body,
119
+ query,
120
+ request,
121
+ }) {
122
+ this.body = body
123
+ this.query = query
124
+ this.request = request
125
+ }
126
+
127
+ /**
128
+ * Normalize REST input into the validator's `input` shape.
129
+ *
130
+ * @returns {{
131
+ * title: string | null
132
+ * tagIds: Array<number>
133
+ * articleId: number | null
134
+ * }}
135
+ */
136
+ buildInput () {
137
+ return {
138
+ title: this.body.title ?? null,
139
+ tagIds: this.extractTagIds(),
140
+ articleId: this.extractArticleId(),
141
+ }
142
+ }
143
+
144
+ /**
145
+ * Coerce a comma-joined query string into a number array.
146
+ *
147
+ * @returns {Array<number>}
148
+ */
149
+ extractTagIds () {
150
+ const raw = this.query.tagIds ?? ''
151
+
152
+ return raw
153
+ .split(',')
154
+ .filter(Boolean)
155
+ .map(Number)
156
+ }
157
+
158
+ /**
159
+ * Coerce the path parameter into a number.
160
+ *
161
+ * @returns {number | null}
162
+ */
163
+ extractArticleId () {
164
+ const raw = this.request.pathParameterHashProxy.articleId
165
+
166
+ return raw === null
167
+ ? null
168
+ : Number(raw)
169
+ }
170
+ }
171
+ ```
172
+
173
+ - The adapter is the **only** place that knows input was split across sources and arrived as strings.
174
+ Everything downstream sees a clean, typed `input`.
175
+
176
+ ## Wiring in the renderer (and the error-type bridge)
177
+
178
+ The renderer runs **adapter → validator → (on failure) a status-bearing response**:
179
+
180
+ ```js
181
+ async render ({
182
+ body,
183
+ query,
184
+ request,
185
+ }) {
186
+ const input = CreateArticleInputAdapter.create({
187
+ body,
188
+ query,
189
+ request,
190
+ })
191
+ .buildInput()
192
+
193
+ const validationResult = this.validateInput({
194
+ input,
195
+ })
196
+
197
+ if (validationResult) {
198
+ return validationResult
199
+ }
200
+
201
+ // ... input is now trusted; touch the DB, return RestfulApiResponse ...
202
+ }
203
+ ```
204
+
205
+ There is one bridge to get right. A GraphQL-style validator yields a **code-only** error, but REST
206
+ must return a **status-bearing `RestfulApiResponse`** (§4). Resolve it one of two ways:
207
+
208
+ - **Map in the renderer (recommended).** Keep `BaseInputValidator` transport-neutral: its
209
+ `errorHash` entries are error **identities** (names/keys), `validateInput()` returns the failing
210
+ identity or `null`, and the renderer maps that identity to its own
211
+ `this.errorResponseHash.Xxx.createAsError()`. The validator stays byte-for-byte the same as the
212
+ GraphQL one; only the renderer knows about HTTP status.
213
+ - **A REST base validator.** Alternatively, a thin `BaseRestfulApiInputValidator` overrides how the
214
+ failing entry is instantiated so it returns a `RestfulApiResponse` (via `createAsError()`) directly,
215
+ and you feed it the renderer's `errorResponseHash`. Use this if you would rather the validator emit
216
+ the final response.
217
+
218
+ Either way, keep `createInputValidator()` / `validateInput()` as thin named methods on the renderer,
219
+ mirroring the GraphQL side, so the two surfaces read the same.
220
+
221
+ ## Split of duty
222
+
223
+ - **Adapter** — shape and type only: collect `body` / `query` / path, coerce strings, default to
224
+ `null`. No value judgements.
225
+ - **Validator** — value rules on the normalized `input`: presence, format, ranges, enums. Pure
226
+ booleans; no DB.
227
+ - **Renderer / DB layer** — existence, ownership, and state checks that require the database (a
228
+ missing row → return a `404`-class response). These stay out of the validator, exactly as on the
229
+ GraphQL side.
@@ -0,0 +1,110 @@
1
+ ---
2
+ name: hor-security-audit
3
+ description: >
4
+ Run a READ-ONLY, repo-wide security audit of a JavaScript/TypeScript (Node) project and produce
5
+ a findings list — do not fix anything. Covers injection, missing or over-broad auth on HTTP
6
+ routes and GraphQL operations, port and datastore exposure, secrets and env hygiene, dependency
7
+ risk, CORS, rate limiting, logging/PII, uploads, and error leakage. Use when the user asks for a
8
+ security check or audit of the codebase. For a diff-only review of pending changes, use
9
+ /security-review.
10
+ ---
11
+
12
+ # Security Audit
13
+
14
+ A **read-only checklist audit** of a Node (JS/TS) repository. The goal is to **check and list
15
+ places that could become vulnerabilities** — not to fix them. Work through every check, run its
16
+ detection commands, judge each against its finding criteria, and produce a single **findings
17
+ report**.
18
+
19
+ This skill is **stack-agnostic within the Node ecosystem**: it names common frameworks / ORMs /
20
+ loggers only as *examples*. Discover what the target project uses (read `package.json`, the entry
21
+ point, the config files) and adapt each check's patterns to it. Do not assume any specific file
22
+ layout — detect it.
23
+
24
+ ## Rules (read first)
25
+
26
+ 1. **Read-only. Never edit, never fix.** Only inspect, run non-mutating commands, and report.
27
+ Suggest a remediation per finding as text, but do not apply it.
28
+ 2. **Never print secret values.** When a check surfaces a credential, show the **key name and a
29
+ masked value** (e.g. `API_KEY=abcd…(masked)`, or `****`). Never paste full tokens / passwords into
30
+ the report or transcript.
31
+ 3. **Do not exfiltrate.** No network calls that send repo contents anywhere. A dependency-advisory
32
+ check against the registry (e.g. `npm audit`, which sends only package metadata) is fine; sending
33
+ files is not.
34
+ 4. **Every check must appear in the report** — as one or more findings, `PASS`, or `N/A` (with a
35
+ one-line reason). A gap must never look like "not applicable".
36
+ 5. **Detect, don't assume.** Before running a check, confirm which tools the project uses and where
37
+ the relevant code lives. If a check's subject does not exist in this project, mark it `N/A`.
38
+
39
+ ## How to run
40
+
41
+ First, **profile the project** (about a minute): read `package.json` (scripts, deps, `engines`,
42
+ `type`), find the server entry point and the config / env files, and identify the HTTP framework, the
43
+ ORM / DB driver, the GraphQL server (if any), and the logger. Then go category by category through
44
+ the [detail files](#checklist--detail-files). For each check: run the detection commands (adapted to
45
+ this project), decide PASS / FINDING / N/A, and record findings in the format below. Prefer
46
+ `git grep` so the search covers tracked source only (no `node_modules`, no build output). Finally,
47
+ print the **summary table** (every check → verdict) followed by the detailed findings, most severe
48
+ first.
49
+
50
+ ## Finding format
51
+
52
+ ```
53
+ ### [HIGH|MEDIUM|LOW|INFO] <short title> (check: <category>/<id>)
54
+ - Location: <file:line, or scope e.g. "the ORM connection config, non-local environments">
55
+ - Evidence: <masked snippet or command output>
56
+ - Risk: <why this is exploitable / what it exposes>
57
+ - Recommendation: <what to change — DO NOT apply it>
58
+ ```
59
+
60
+ Severity guide: **HIGH** = exploitable now / secret exposed / unauthenticated sensitive access.
61
+ **MEDIUM** = weakens the security posture (no transport encryption, weak config, unrestricted upload
62
+ type). **LOW** = hardening gap. **INFO** = worth noting, not a vulnerability.
63
+
64
+ ## Checklist & detail files
65
+
66
+ | # | Check | Detail file |
67
+ | --- | --- | --- |
68
+ | 1 | Injection (SQL / NoSQL / command) via raw/interpolated input | [code-safety.md](./references/code-safety.md) |
69
+ | 2 | `eval` / dynamic-exec code | [code-safety.md](./references/code-safety.md) |
70
+ | 3 | Malicious / obfuscated code or install hooks | [code-safety.md](./references/code-safety.md) |
71
+ | 4 | Exposed ports / bind address / datastore exposure | [network-and-logging.md](./references/network-and-logging.md) |
72
+ | 5 | Production logging via a redacting logger; no PII | [network-and-logging.md](./references/network-and-logging.md) |
73
+ | 6 | Auth enforced on every endpoint (routes + GraphQL queries/mutations/**subscriptions**) | [auth-and-transport.md](./references/auth-and-transport.md) |
74
+ | 7 | Public / guest allow-list is minimal & intentional (classified) | [auth-and-transport.md](./references/auth-and-transport.md) |
75
+ | 8 | Datastore transport encryption (TLS / SSL) | [auth-and-transport.md](./references/auth-and-transport.md) |
76
+ | 9 | Introspection / playground / debug endpoints disabled in prod | [auth-and-transport.md](./references/auth-and-transport.md) |
77
+ | 10 | CORS scoped (not wildcard in production) | [auth-and-transport.md](./references/auth-and-transport.md) |
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) |
81
+ | 14 | No hardcoded secrets in code / config | [secrets.md](./references/secrets.md) |
82
+ | 15 | No plaintext passwords / secrets in seed / fixture data | [secrets.md](./references/secrets.md) |
83
+ | 16 | No vulnerable dependencies (advisory audit) | [dependencies.md](./references/dependencies.md) |
84
+ | 17 | Lockfile committed + version-pinning delay + no committed registry tokens | [dependencies.md](./references/dependencies.md) |
85
+ | 18 | Reproducible installs (clean / locked install, not mutating) | [dependencies.md](./references/dependencies.md) |
86
+ | 19 | File-upload validation (type + content + size) | [application-surface.md](./references/application-surface.md) |
87
+ | 20 | No unused / scaffold / boilerplate operations exposed | [application-surface.md](./references/application-surface.md) |
88
+ | 21 | GraphQL query depth / complexity limits | [application-surface.md](./references/application-surface.md) |
89
+ | 22 | Error responses don't leak internals in production | [application-surface.md](./references/application-surface.md) |
90
+
91
+ ## Additional checks worth proposing
92
+
93
+ Offer these when relevant (report as findings / PASS / N/A like the rest):
94
+
95
+ - **Secrets in git history** (not just the current tree) — scan `git log -p` for secret patterns and
96
+ known key shapes; a secret that was ever committed must be rotated even if later removed.
97
+ - **Datastore auth in production** — DB / cache / queue require a password and are not on a public
98
+ interface.
99
+ - **Cookie / session flags** (`httpOnly` / `secure` / `sameSite`) if cookies are used.
100
+ - **Runtime pinning** (`engines` set; no end-of-life Node version).
101
+ - **Mass-assignment** — endpoints spreading raw request input straight into a DB write.
102
+
103
+ ## Output
104
+
105
+ End with: (1) the summary table (every check → verdict), (2) findings most-severe-first, (3) the
106
+ count by severity, and (4) a one-line reminder that nothing was changed. If asked, offer to hand
107
+ specific findings to a fix workflow — but this skill itself never modifies code.
108
+
109
+ Write the report in the language the reader is using, as the documentation convention requires of
110
+ any document generated for a reader.
@@ -0,0 +1,90 @@
1
+ # Application surface (checks 19–22)
2
+
3
+ File-upload validation, exposed unused / scaffold operations, GraphQL query depth / complexity, and
4
+ error-response leakage. Referenced from [SKILL.md](../SKILL.md).
5
+
6
+ ## 19. File-upload validation (type + content + size)
7
+
8
+ Any endpoint that accepts an uploaded file must validate it in **three** ways. Checking only one
9
+ (commonly just size, or just the client-declared MIME type) is insufficient.
10
+
11
+ 1. **Declared type allow-list** — accept only the MIME type(s) / extension(s) the feature needs.
12
+ 2. **Content / magic-byte check** — verify the bytes actually match the claimed type. The client-sent
13
+ MIME type and filename extension are attacker-controlled and trivially spoofed; a real check reads
14
+ the file's magic number (e.g. `%PDF-` for PDF, `\x89PNG` for PNG, `PK\x03\x04` for zip/office).
15
+ 3. **Size limit** — cap the accepted size to bound memory / disk / downstream cost.
16
+
17
+ ```bash
18
+ # Find upload handling (adapt to the stack: multer, busboy, formidable, GraphQL Upload, framework multipart):
19
+ git grep -nE "multer|busboy|formidable|multipart|createReadStream|GraphQLUpload|Upload\b|fileFields|\.file\b|\.files\b" -- '*.js' '*.ts' '*.cjs' | head
20
+ # Evidence of type/content/size validation near uploads:
21
+ git grep -nE "mimetype|mime-type|content-type|fileFilter|magic|%PDF|signature|limits?\s*:|maxFileSize|fileSize|allowed.*[Tt]ype" -- '*.js' '*.ts' '*.cjs' | head
22
+ ```
23
+
24
+ - **FINDING (MEDIUM):** an upload endpoint that validates size only, or trusts the client-declared
25
+ MIME type without a magic-byte / content check (spoofable). Recommend a type allow-list **plus** a
26
+ content check **plus** a size cap.
27
+ - **FINDING (MEDIUM/HIGH):** no validation at all on an upload that is stored, parsed, or forwarded
28
+ (parsing an unexpected type can be an exploitation or DoS vector).
29
+ - A robust content check reads the leading bytes and compares against the expected magic number for
30
+ the allow-listed type(s), and rejects anything that does not match even if the declared MIME type
31
+ looks correct.
32
+ - **PASS:** uploads enforce type allow-list + content/magic check + size limit. **N/A:** no uploads.
33
+
34
+ ## 20. No unused / scaffold / boilerplate operations exposed
35
+
36
+ Generated scaffolding, boilerplate CRUD, and leftover example endpoints are **attack surface** even
37
+ when the product does not use them — they are often less reviewed, may be unauthenticated, and can
38
+ mutate data. Every reachable route / resolver / subscription should correspond to a real product
39
+ feature.
40
+
41
+ ```bash
42
+ # Enumerate all operations, then reconcile against features actually in use:
43
+ git grep -nE "\.(get|post|put|patch|delete)\(\s*['\"]/|type (Query|Mutation|Subscription)|@(Query|Mutation|Subscription|Get|Post|Put|Patch|Delete)\(|static get schema|routePath" -- '*.js' '*.ts' '*.cjs' '*.graphql'
44
+ # Names that smell like scaffolding / examples / unused features:
45
+ git grep -niE "example|sample|scaffold|boilerplate|todo|foobar|test-?only|demo|playground" -- '*.js' '*.ts' '*.cjs' '*.graphql' | head
46
+ ```
47
+
48
+ - Cross-reference each operation with whether the frontend / product actually calls it. Operations
49
+ with no caller, or clearly generated example CRUD, are candidates for removal.
50
+ - **FINDING (MEDIUM):** an exposed operation that is unused / scaffold and **state-changing or
51
+ sensitive** — especially if unauthenticated (ties into checks 6–7). Recommend removing it to shrink
52
+ the attack surface.
53
+ - **FINDING (LOW):** an unused read-only operation left exposed.
54
+ - **PASS:** every exposed operation maps to a real, intended feature.
55
+ - Report the operation inventory so a human can confirm the mapping — do not delete anything (this
56
+ skill is read-only).
57
+
58
+ ## 21. GraphQL query depth / complexity limits
59
+
60
+ Without a depth / complexity / cost limit, a client can send a deeply nested or highly branching
61
+ query (e.g. cyclic relations) that forces enormous resolution work — a denial-of-service vector.
62
+
63
+ ```bash
64
+ git grep -nE "depthLimit|graphql-depth-limit|complexity|costAnalysis|createComplexityRule|maxDepth|queryComplexity|validationRules" -- '*.js' '*.ts' '*.cjs' | head
65
+ ```
66
+
67
+ - **FINDING (MEDIUM):** a GraphQL server with **no** depth or complexity limit and a schema that
68
+ contains nested / cyclic relations. Recommend a depth limit and/or a query-cost / complexity rule
69
+ as a validation rule.
70
+ - **PASS:** a depth and/or complexity limit is configured. **N/A:** no GraphQL server, or a trivial
71
+ flat schema with no nesting (note the reasoning).
72
+
73
+ ## 22. Error responses don't leak internals in production
74
+
75
+ Error responses returned to clients must not include stack traces, raw DB / driver errors, internal
76
+ file paths, or SQL — these leak implementation detail useful to an attacker. Detail belongs in server
77
+ logs (via the redacting logger, check 5), not the HTTP / GraphQL response.
78
+
79
+ ```bash
80
+ git grep -nE "stack|err\.stack|error\.stack|formatError|maskError|debug\s*:\s*true|NODE_ENV|sendError|res\.(json|send)\(\s*err" -- '*.js' '*.ts' '*.cjs' | head
81
+ ```
82
+
83
+ - **Make it actionable:** determine what the client actually receives in **production**. A GraphQL
84
+ server exposing `error.extensions.exception.stacktrace`, or an HTTP handler returning `err.stack` /
85
+ the raw error message, is a leak. A production error formatter that maps to a safe message / code
86
+ while logging detail server-side is correct.
87
+ - **FINDING (MEDIUM):** stack traces / raw internal errors returned to clients in production.
88
+ Recommend a production error formatter that returns a generic message + a correlation id, and logs
89
+ the detail server-side.
90
+ - **PASS:** production responses carry only safe, sanitized errors; detail is logged, not returned.
@@ -0,0 +1,147 @@
1
+ # Auth & transport (checks 6–11)
2
+
3
+ Authentication / authorization on every endpoint, the public allow-list, datastore transport
4
+ encryption, introspection / debug endpoints, CORS scope, and rate limiting. Referenced from
5
+ [SKILL.md](../SKILL.md).
6
+
7
+ The right patterns depend on the stack. First identify: the HTTP framework (Express / Fastify / Koa /
8
+ Nest / Hapi …), whether there is a GraphQL server (Apollo / Yoga / Mercurius / a framework
9
+ integration), and how the project expresses "this endpoint is authenticated" (middleware, guard,
10
+ decorator, a per-operation filter, an allow-list of public operations). Then adapt the checks below.
11
+
12
+ ## 6. Auth enforced on every endpoint
13
+
14
+ The goal: **every route and every GraphQL operation is authenticated by default**, and the set of
15
+ operations reachable **without** auth is small, explicit, and intentional. Two enforcement models are
16
+ common — identify which the project uses:
17
+
18
+ - **Default-deny** (a global guard / filter authenticates everything; a named allow-list enumerates
19
+ the public operations). Verify the guard is actually wired, and audit the allow-list (check 7).
20
+ - **Per-endpoint opt-in** (each route/resolver attaches its own auth middleware / guard). Verify none
21
+ are missing it — the failure mode here is a forgotten guard.
22
+
23
+ ### HTTP routes
24
+
25
+ ```bash
26
+ # How auth is expressed (adapt keyword to the project): middleware, guard, decorator, visa, policy:
27
+ git grep -nE "authenticate|requireAuth|isAuthenticated|ensureAuth|@UseGuards|AuthGuard|passport|verifyToken|visa" -- '*.js' '*.ts' '*.cjs' | head
28
+ # Enumerate routes so you can cross-check each has auth (adapt to the router style):
29
+ git grep -nE "\.(get|post|put|patch|delete)\(\s*['\"]/|route\(|@(Get|Post|Put|Patch|Delete)\(|routePath" -- '*.js' '*.ts' '*.cjs'
30
+ ```
31
+
32
+ - **FINDING (HIGH):** a route exposing sensitive data / actions with no auth middleware / guard.
33
+ - **FINDING (MEDIUM):** a route whose auth status is ambiguous (no clear guard, not an intentional
34
+ public route).
35
+ - Public routes (health check, an integration webhook, a public form submit) must be **intentional**
36
+ and otherwise protected (signature verification, IP allow-list, token, captcha).
37
+
38
+ ### GraphQL — queries, mutations, **and subscriptions**
39
+
40
+ Subscriptions are frequently forgotten: a project may authenticate queries/mutations over HTTP yet
41
+ leave the WebSocket subscription transport (`onConnect` / connection init) unauthenticated. Check all
42
+ three operation types.
43
+
44
+ ```bash
45
+ # The enforcement point (adapt to the server): a context builder, a global validation rule, a filter:
46
+ git grep -nE "authorize|isAuthorized|isAllowed|checkPermission|hasPermission|Unauthenticated|Unauthorized|requireAuth|context\s*:.*auth" -- '*.js' '*.ts' '*.cjs' | head
47
+ # Subscription transport auth (the commonly-missed one):
48
+ git grep -nE "onConnect|connectionParams|context.*subscription|subscriptions\s*:|useServer|SubscriptionServer" -- '*.js' '*.ts' '*.cjs'
49
+ # Enumerate operations to cross-check coverage (adapt to how schemas/resolvers are declared):
50
+ git grep -nE "type (Query|Mutation|Subscription)|@(Query|Mutation|Subscription)\(|static get schema" -- '*.js' '*.ts' '*.cjs' '*.graphql'
51
+ ```
52
+
53
+ - **FINDING (HIGH):** the auth check is missing entirely (everything becomes public), or the
54
+ subscription transport authenticates on connect differently from (or weaker than) queries/mutations.
55
+ - **FINDING (HIGH):** a **state-changing mutation** reachable unauthenticated that is not an
56
+ intentional public operation.
57
+ - **FINDING (MEDIUM):** an operation whose coverage is ambiguous (neither clearly guarded nor an
58
+ intentional public entry).
59
+
60
+ ## 7. Public / guest allow-list is minimal & intentional (classified)
61
+
62
+ If the project has an explicit list of unauthenticated operations / routes, enumerate it and
63
+ **classify every entry**, because severity depends on what the operation does:
64
+
65
+ - **Read-only, non-sensitive** public entry (health check, public content query, public form submit)
66
+ → likely intentional; confirm and mark INFO/PASS.
67
+ - **State-changing** public entry (any mutation that writes data) → **HIGH** unless there is a
68
+ compensating control (signature, captcha, strict rate limit, idempotency). A public write is an
69
+ abuse / spam / resource-exhaustion vector.
70
+ - **Sensitive read** (PII, internal data) exposed publicly → **HIGH**.
71
+
72
+ Report the **full allow-list** so a human can confirm each entry matches product intent. Flag any
73
+ entry that looks like leftover scaffolding rather than a deliberate public endpoint (see check 20).
74
+
75
+ ## 8. Datastore transport encryption (TLS / SSL)
76
+
77
+ Connections to a managed / remote datastore should be encrypted in transit. For SQL via most ORMs /
78
+ drivers this is a TLS/SSL option on the connection config; for Mongo it is `tls=true` /
79
+ `mongodb+srv`; for Redis it is a `rediss://` URL / `tls` options.
80
+
81
+ ```bash
82
+ # Find the connection config the project uses (adapt filename):
83
+ git grep -lniE "dialect|connection|datasource|createConnection|new Sequelize|new Pool|MongoClient|createClient" -- '*.js' '*.ts' '*.cjs' | head
84
+ # TLS/SSL settings within it:
85
+ git grep -nE "ssl|tls|rejectUnauthorized|sslmode|rediss:|mongodb\+srv" -- '*.js' '*.ts' '*.cjs' '*.json' | head
86
+ ```
87
+
88
+ - **FINDING (MEDIUM):** a **remote / non-local** environment (staging / production) connecting to a
89
+ datastore with **no TLS/SSL** → traffic is unencrypted. Recommend enabling TLS and, where the
90
+ driver supports it, verifying the server certificate (e.g. `rejectUnauthorized: true` rather than
91
+ `false`, which accepts any cert — a weaker MEDIUM).
92
+ - **Severity nuance:** a **local test / dev DB** on loopback (e.g. a sqlite file or a localhost
93
+ container) does not need TLS — mark **N/A** for that environment, but do not let a local exception
94
+ hide a missing setting on the production connection.
95
+ - **PASS:** all non-local datastore connections use TLS with certificate verification.
96
+
97
+ ## 9. Introspection / playground / debug endpoints disabled in prod
98
+
99
+ ```bash
100
+ git grep -nE "introspection|playground|graphiql|ApolloServerPluginLandingPage|debug\s*:\s*true|NODE_ENV" -- '*.js' '*.ts' '*.cjs' | head
101
+ ```
102
+
103
+ - **Make it actionable:** determine the **actual production value**, not just that the flag is
104
+ mentioned. `introspection: true` unconditionally → MEDIUM. Gated on `NODE_ENV !== 'production'` (or
105
+ a config flag that is off in prod) → PASS; note how it is gated. A landing page / GraphiQL served
106
+ in production → MEDIUM.
107
+ - **FINDING (MEDIUM):** introspection or an interactive playground / debug console enabled in
108
+ production. Recommend disabling in prod (keep it in development only).
109
+ - **N/A:** no GraphQL server.
110
+
111
+ ## 10. CORS scoped (not wildcard in production)
112
+
113
+ ```bash
114
+ git grep -nE "cors\(|Access-Control-Allow-Origin|origin\s*:|credentials\s*:\s*true" -- '*.js' '*.ts' '*.cjs' | head
115
+ ```
116
+
117
+ - **FINDING (HIGH):** `origin: '*'` (or reflecting any `Origin`) **together with**
118
+ `credentials: true` — this is an invalid-but-dangerous combination that browsers partly block yet
119
+ often leaks in practice; at minimum it signals no origin control.
120
+ - **FINDING (MEDIUM):** wildcard origin in production for anything beyond truly public, credential-less
121
+ content.
122
+ - **Concrete secure pattern to recommend** (adapt to the app's real domains): allow only the app's
123
+ own base domain **and its subdomains**, plus localhost for the test / dev environment, driven from
124
+ an env var rather than hard-coded — e.g. an `origin` function that accepts a request origin when it
125
+ equals or is a subdomain of the configured base domain, or is a localhost origin, and rejects
126
+ everything else. Requests with no `Origin` header (server-to-server, curl) can be allowed since CORS
127
+ is a browser control. Do not reflect arbitrary origins.
128
+ - **PASS:** origins are an explicit allow-list / env-driven and not `*` in production.
129
+
130
+ ## 11. Rate limiting on public endpoints (and not bypassable)
131
+
132
+ ```bash
133
+ git grep -nE "rateLimit|rate-limit|express-rate-limit|RateLimiter|throttle|slow-down|limiter" -- '*.js' '*.ts' '*.cjs' | head
134
+ # Client-IP resolution — the common bypass:
135
+ git grep -nE "x-forwarded-for|X-Forwarded-For|req\.ip|trust proxy|trustProxy|remoteAddress" -- '*.js' '*.ts' '*.cjs' | head
136
+ ```
137
+
138
+ - **Make it actionable:** confirm a limiter is (a) actually **applied** to the public / expensive
139
+ endpoints (unauthenticated forms, login, upload, AI/LLM calls), not merely imported; and (b) keyed
140
+ on a **trustworthy client identifier**. If the limiter keys on a **spoofable header**
141
+ (`X-Forwarded-For`) without a correctly configured `trust proxy` setting, an attacker rotates the
142
+ header to bypass it.
143
+ - **FINDING (MEDIUM):** no rate limiting on a public, abusable, or expensive endpoint.
144
+ - **FINDING (MEDIUM):** rate limiting keyed on a client-controlled header without a trusted-proxy
145
+ configuration (bypassable). Recommend keying on the real peer address / a correctly trusted proxy
146
+ chain.
147
+ - **PASS:** limiter applied to the relevant endpoints and keyed on a trustworthy identifier.
@@ -0,0 +1,74 @@
1
+ # Code safety (checks 1–3)
2
+
3
+ Injection (SQL / NoSQL / command), dynamic code execution (`eval`), and malicious / obfuscated code
4
+ or install hooks. Referenced from [SKILL.md](../SKILL.md).
5
+
6
+ Commands below use `git grep` so the search stays on tracked source (no `node_modules`, no build
7
+ output). Adjust the patterns to the ORM / driver / framework the project uses.
8
+
9
+ ## 1. Injection (SQL / NoSQL / command)
10
+
11
+ Most ORMs and query builders parameterize by default and are safe. Risk appears where a **raw query
12
+ is built with string interpolation / concatenation from untrusted input** (request body, query
13
+ params, headers, path params, GraphQL variables, message payloads).
14
+
15
+ ```bash
16
+ # Raw SQL entry points (varies by library — include the ones the project uses):
17
+ # node-postgres/mysql2: .query( | Sequelize: sequelize.query / literal( / QueryTypes
18
+ # Knex: .raw( | Prisma: $queryRawUnsafe / $executeRawUnsafe | TypeORM: createQueryBuilder / .query(
19
+ git grep -nE "\.query\(|\.raw\(|\\\$queryRawUnsafe|\\\$executeRawUnsafe|literal\(|QueryTypes|createQueryBuilder" -- '*.js' '*.ts' '*.cjs' '*.mjs'
20
+ # The dangerous shape — interpolation/concatenation inside a raw query:
21
+ git grep -nE "\.(query|raw)\(\s*\`[^\`]*\\\$\{" -- '*.js' '*.ts' '*.cjs' '*.mjs'
22
+ git grep -nE "(WHERE|SELECT|INSERT|UPDATE|DELETE)[^\"'\`]*(\+|\\\$\{)" -- '*.js' '*.ts' '*.cjs' '*.mjs'
23
+ # NoSQL (Mongo) operator injection — raw request objects flowing into a filter:
24
+ git grep -nE "\.(find|findOne|updateOne|deleteOne|aggregate)\(\s*(req\.|request\.|input|variables|body|params|query)" -- '*.js' '*.ts'
25
+ ```
26
+
27
+ - **Distinguish the source of interpolated values.** Interpolating a **constant** (e.g. a table name
28
+ from a file-local constant in a migration) is not injection. Interpolating anything that traces
29
+ back to **request input** (`variables`, `input`, `req`, `args`, `body`, `params`, `headers`) is.
30
+ - **NoSQL note:** passing a raw request object straight into a Mongo filter allows operator injection
31
+ (`{ "$gt": "" }`), even without string building. Flag request objects used as query filters
32
+ without validation / casting.
33
+ - **FINDING (HIGH):** a raw query whose interpolated / concatenated value comes from user input, or a
34
+ request object used directly as a NoSQL filter. Recommend parameterized queries (placeholders /
35
+ bind params), the ORM's safe builder, or validating + casting the input first.
36
+ - **FINDING (LOW/INFO):** raw query with only constant interpolation — note it, confirm the value
37
+ cannot become input-derived.
38
+ - **PASS:** no raw queries, or raw queries use bind params / only constants; NoSQL filters are
39
+ validated.
40
+
41
+ ## 2. `eval` / dynamic-exec code
42
+
43
+ ```bash
44
+ git grep -nE "\beval\s*\(|new Function\s*\(|vm\.(run|compile|Script)|require\(['\"]vm['\"]\)|from ['\"]vm['\"]" -- '*.js' '*.ts' '*.cjs' '*.mjs'
45
+ git grep -nE "child_process|execSync|spawnSync|\bexec\(|\bspawn\(|\bexecFile\(" -- '*.js' '*.ts' '*.cjs' '*.mjs'
46
+ ```
47
+
48
+ - **FINDING (HIGH):** `eval(` / `new Function(` / `vm` run on any value that could be
49
+ attacker-influenced; `child_process` exec/spawn with interpolated input (command injection — a
50
+ shell string built from input is worse than an args array).
51
+ - **FINDING (LOW):** `child_process` with fully-static args (still worth noting).
52
+ - **PASS:** none found, or all uses are on static values.
53
+
54
+ ## 3. Malicious / obfuscated code & install hooks
55
+
56
+ Look for code that decodes-then-executes, phones home, or runs during install.
57
+
58
+ ```bash
59
+ # Install-time hooks (a common supply-chain foothold) — check root and any workspace package.json:
60
+ git grep -nE "\"(pre|post)?install\"\s*:|\"prepare\"\s*:|\"prepublish(Only)?\"\s*:" -- 'package.json' '**/package.json'
61
+ # Obfuscation / decode-then-run:
62
+ git grep -nE "Buffer\.from\([^)]*base64|atob\(|\\\\x[0-9a-f]{2}|fromCharCode|eval\(.*(atob|Buffer)" -- '*.js' '*.ts' '*.cjs' '*.mjs'
63
+ # Unexpected outbound network / curl|bash in scripts:
64
+ git grep -nE "curl .*\| *(ba)?sh|wget .*\| *(ba)?sh|https?://[^ '\"]+" -- 'package.json' '*.js' '*.ts' '*.cjs' '*.sh' | head
65
+ ```
66
+
67
+ - **FINDING (HIGH):** an `install` / `postinstall` / `prepare` script that downloads or executes
68
+ remote code; base64 / hex-decoded strings passed to `eval` / `Function`; outbound calls sending
69
+ repo / secret data to an unknown host.
70
+ - **FINDING (INFO):** hard-coded external URLs — list them so a human can confirm each is expected
71
+ (API endpoints, docs) and not exfiltration.
72
+ - **PASS:** no install hooks that fetch / execute; no decode-then-run; outbound hosts all expected.
73
+ - Also sanity-check recent history (`git log -p -n 50 -- package.json`) for unexpected additions to
74
+ build / install scripts.