@lunora/advisor 1.0.0-alpha.4 → 1.0.0-alpha.40

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 (141) hide show
  1. package/LICENSE.md +6 -0
  2. package/README.md +1 -1
  3. package/dist/index.d.mts +3459 -941
  4. package/dist/index.d.ts +3459 -941
  5. package/dist/index.mjs +1 -79
  6. package/dist/packem_shared/AE_METRIC_EVENTS-LP_0D7Uw.mjs +1 -0
  7. package/dist/packem_shared/actionFetchSsrf-BbWxy1Yf.mjs +1 -0
  8. package/dist/packem_shared/adminRouteWithoutGuard-DSo4t9j4.mjs +1 -0
  9. package/dist/packem_shared/aiRawRunEscapeHatch-DfhjYm43.mjs +1 -0
  10. package/dist/packem_shared/aiToolSideEffectPromptInjection-DnWQOoKi.mjs +1 -0
  11. package/dist/packem_shared/aiUnboundedGenerationPublic-D3HZrh5_.mjs +1 -0
  12. package/dist/packem_shared/allowUnauthenticatedShardAccessEnabled-D4aMNBb0.mjs +1 -0
  13. package/dist/packem_shared/argument-derived-sink-BpO3NPPM.mjs +1 -0
  14. package/dist/packem_shared/authApiCallWithoutHeaders-BItMMdZP.mjs +1 -0
  15. package/dist/packem_shared/authCsrfCheckDisabled-De9ammtV.mjs +1 -0
  16. package/dist/packem_shared/authEmailVerificationDisabled-BFKdJcx4.mjs +1 -0
  17. package/dist/packem_shared/authSecureCookiesDisabled-B4WIzvMm.mjs +1 -0
  18. package/dist/packem_shared/authSessionFreshageZero-Bpcaf_Pe.mjs +1 -0
  19. package/dist/packem_shared/authTrustedOriginsWildcard-DjU9NXEm.mjs +1 -0
  20. package/dist/packem_shared/browserAllowPrivateTargets-Dxyeh6lg.mjs +1 -0
  21. package/dist/packem_shared/browserUserUrlWithoutAllowlist-BHBS6b0N.mjs +1 -0
  22. package/dist/packem_shared/circularFk-BMuJKmuZ.mjs +1 -0
  23. package/dist/packem_shared/constraintValidator-N339mfyx.mjs +1 -0
  24. package/dist/packem_shared/containerInstanceKeyFromUserInput-C8S4T3ty.mjs +1 -0
  25. package/dist/packem_shared/containerOversizedInstance-B9wW_sU5.mjs +1 -0
  26. package/dist/packem_shared/containerPublicInternet-Bx2J7tha.mjs +1 -0
  27. package/dist/packem_shared/containerRuntimeEgressRelaxation-BQ2ZD1aV.mjs +1 -0
  28. package/dist/packem_shared/containerStartEnableInternetOverride-B62WUura.mjs +1 -0
  29. package/dist/packem_shared/dedupeCacheKeys-7JgxaQWV.mjs +1 -0
  30. package/dist/packem_shared/duplicateIndex-DFT7qLQD.mjs +1 -0
  31. package/dist/packem_shared/emptyIndex-BiXEfyfN.mjs +1 -0
  32. package/dist/packem_shared/exportSinkMisconfigured-DvpAaa6j.mjs +1 -0
  33. package/dist/packem_shared/externalSourceIncrementalNoDeletePath-DnoL64YY.mjs +1 -0
  34. package/dist/packem_shared/externalSourceOnGlobal-DNPLoNUg.mjs +1 -0
  35. package/dist/packem_shared/externalSourceUnscoped-DqBp5jYr.mjs +1 -0
  36. package/dist/packem_shared/filterWithoutIndex-ht2GZQWV.mjs +1 -0
  37. package/dist/packem_shared/finding-BAVgqnCF.mjs +1 -0
  38. package/dist/packem_shared/fk-index-Bmk19RvQ.mjs +1 -0
  39. package/dist/packem_shared/flagGatesSecurityWithUnsafeDefault-DPGFEHTt.mjs +1 -0
  40. package/dist/packem_shared/fromServerSchema-CJ-AQ2kw.mjs +1 -0
  41. package/dist/packem_shared/geoIndexFieldNotGeopoint-DAGLZtaH.mjs +1 -0
  42. package/dist/packem_shared/geoIndexUnused-BgDE6_AR.mjs +1 -0
  43. package/dist/packem_shared/hardcodedSecret-rIRc3aNk.mjs +1 -0
  44. package/dist/packem_shared/helpers-DwlvEUCh.mjs +1 -0
  45. package/dist/packem_shared/hotShard-DVs_U17R.mjs +1 -0
  46. package/dist/packem_shared/httpActionMissingAuthGuard-BZDdeW_D.mjs +1 -0
  47. package/dist/packem_shared/httpActionResponseHeaderInjection-D063rB7U.mjs +1 -0
  48. package/dist/packem_shared/hyperdriveOutsideAction-CRmOQz67.mjs +1 -0
  49. package/dist/packem_shared/identityUndeclaredClaimTrusted-BYRYGQ74.mjs +1 -0
  50. package/dist/packem_shared/imagesUrlSourceFromUserInput-Cy5pc_dA.mjs +1 -0
  51. package/dist/packem_shared/indexReferencesUnknownField-r3QHlaz6.mjs +1 -0
  52. package/dist/packem_shared/indexUtilization-QfbIH_w4.mjs +1 -0
  53. package/dist/packem_shared/insertManyUnsafeUserData-DrH7PdRs.mjs +1 -0
  54. package/dist/packem_shared/kvUnscopedUserKeyIdor-B4lGxRxh.mjs +1 -0
  55. package/dist/packem_shared/mailInboundDispatchWithoutVerify-BivYJ5F9.mjs +1 -0
  56. package/dist/packem_shared/mailRecipientFromRequestInput-BR_oSh65.mjs +1 -0
  57. package/dist/packem_shared/maskUncoveredPiiColumn-DqPfZM2O.mjs +1 -0
  58. package/dist/packem_shared/maskWeakHashStrategyOnPii-CEiiGgT7.mjs +1 -0
  59. package/dist/packem_shared/maskedRelationLeakViaWith-CxYk0MDW.mjs +1 -0
  60. package/dist/packem_shared/mutatorFullRowReplace-CEgecSGm.mjs +1 -0
  61. package/dist/packem_shared/nondeterministicQueryMutation-BaMfbAk_.mjs +1 -0
  62. package/dist/packem_shared/normalizeIdUsedAsAuthorization-FjISSXJm.mjs +1 -0
  63. package/dist/packem_shared/notifyMissingPushConfig-C_GbVw3S.mjs +1 -0
  64. package/dist/packem_shared/notifySendOutsideAction-B0jZuUP3.mjs +1 -0
  65. package/dist/packem_shared/outputProjectionMissingOnPublicRead-9Pm9766s.mjs +1 -0
  66. package/dist/packem_shared/ownerFieldFromArgsNotAuth-BoR9vvst.mjs +1 -0
  67. package/dist/packem_shared/paymentCreateWithoutAuthorize-CurtqN8K.mjs +1 -0
  68. package/dist/packem_shared/paymentWebhookWideTolerance-I7ingfR8.mjs +1 -0
  69. package/dist/packem_shared/plaintextSecretInWranglerVariables-DXjKIm8H.mjs +1 -0
  70. package/dist/packem_shared/policyReferencesUnknownTable-D3WelAQa.mjs +1 -0
  71. package/dist/packem_shared/privilegedDispatchUnvalidatedPayload-74GuGye1.mjs +1 -0
  72. package/dist/packem_shared/privilegedFanoutFromPublicProcedure-C2j2GSUN.mjs +1 -0
  73. package/dist/packem_shared/publicArgumentUsesAny-BJb4cTqL.mjs +1 -0
  74. package/dist/packem_shared/publicMutationWithoutRatelimit-D9phluHW.mjs +1 -0
  75. package/dist/packem_shared/publicTableRlsOptoutConfusion-CaWtPGAn.mjs +1 -0
  76. package/dist/packem_shared/queueWithoutDlq-BLY3iy9Q.mjs +1 -0
  77. package/dist/packem_shared/r2sqlOutsideAction-CKK_I1Ms.mjs +1 -0
  78. package/dist/packem_shared/ratelimitDefaultMemoryStore-mOdI3Jmb.mjs +1 -0
  79. package/dist/packem_shared/ratelimitKeySpoofableOrGlobal-DaGId_Fh.mjs +1 -0
  80. package/dist/packem_shared/ratelimitMiddlewareFailOpen-CTWVosEc.mjs +1 -0
  81. package/dist/packem_shared/relationReferencesUnknownField-clqyB69Y.mjs +1 -0
  82. package/dist/packem_shared/relationReferencesUnknownTable-CLdrhkmS.mjs +1 -0
  83. package/dist/packem_shared/rlsUncoveredTable-DYHgnoos.mjs +1 -0
  84. package/dist/packem_shared/shapeTargetsGlobalTable-Blz-aSkg.mjs +1 -0
  85. package/dist/packem_shared/shapeUnknownTable-DFxtyFio.mjs +1 -0
  86. package/dist/packem_shared/signupMutationWithoutDisposableGating-3ir808Vz.mjs +1 -0
  87. package/dist/packem_shared/softDeleteIncludeDeletedFromArgs-DgxpQHRA.mjs +1 -0
  88. package/dist/packem_shared/sqlInjectionRisk-D2NaT-5c.mjs +1 -0
  89. package/dist/packem_shared/storageGenerateUploadUrlNoContentTypePin-C9cjl6Jh.mjs +1 -0
  90. package/dist/packem_shared/storageKeyFromUserArgs-BeS5cp56.mjs +1 -0
  91. package/dist/packem_shared/storagePresignedUrlForPrivateContent-j7VhwIdu.mjs +1 -0
  92. package/dist/packem_shared/storageUploadWithoutContentTypeAllowlist-oxKLecuf.mjs +1 -0
  93. package/dist/packem_shared/storageUploadWithoutMaxSize-DUDxPutk.mjs +1 -0
  94. package/dist/packem_shared/tableWithoutInsert-D3AhaNzR.mjs +1 -0
  95. package/dist/packem_shared/ttlFieldNotTimestamp-BFiRkSZD.mjs +1 -0
  96. package/dist/packem_shared/unboundedStringArgument-AkkIcr-S.mjs +1 -0
  97. package/dist/packem_shared/unindexedForeignKey-DK4eWXkb.mjs +1 -0
  98. package/dist/packem_shared/unindexedRelationTarget-B5fFq1E8.mjs +1 -0
  99. package/dist/packem_shared/unrestrictedWhereBranch-YKiydie4.mjs +1 -0
  100. package/dist/packem_shared/userCreatingMutationWithoutCaptcha-iDjRkUFO.mjs +1 -0
  101. package/dist/packem_shared/vectorsNamespaceFromUserInput-Cyq5B2kF.mjs +1 -0
  102. package/dist/packem_shared/workflowDuplicateStepName-cXF6Rpvg.mjs +1 -0
  103. package/dist/packem_shared/workflowUnknownTarget-JF8rITLP.mjs +1 -0
  104. package/dist/packem_shared/workflowUnused-Dx_FQwGE.mjs +1 -0
  105. package/package.json +4 -3
  106. package/dist/packem_shared/AE_METRIC_EVENTS-DexctYv6.mjs +0 -85
  107. package/dist/packem_shared/adminRouteWithoutGuard-UUGBkAjU.mjs +0 -33
  108. package/dist/packem_shared/authApiCallWithoutHeaders-BeJhCZaf.mjs +0 -38
  109. package/dist/packem_shared/circularFk-B2freHrP.mjs +0 -84
  110. package/dist/packem_shared/constraintValidator-Dr9Py3FD.mjs +0 -186
  111. package/dist/packem_shared/containerOversizedInstance-5U1VKPRM.mjs +0 -36
  112. package/dist/packem_shared/containerPublicInternet-CuNerJE5.mjs +0 -30
  113. package/dist/packem_shared/duplicateIndex-BOublMSt.mjs +0 -57
  114. package/dist/packem_shared/emptyIndex-BX8EuEY7.mjs +0 -32
  115. package/dist/packem_shared/filterWithoutIndex-BYVeJaSs.mjs +0 -31
  116. package/dist/packem_shared/finding-Dm_zvzS1.mjs +0 -16
  117. package/dist/packem_shared/fk-index-IUK1ukgs.mjs +0 -7
  118. package/dist/packem_shared/fromServerSchema-DinF1nph.mjs +0 -50
  119. package/dist/packem_shared/hardcodedSecret-W2pz1UZB.mjs +0 -35
  120. package/dist/packem_shared/helpers-DNCkMWZQ.mjs +0 -4
  121. package/dist/packem_shared/hotShard-Ir5D0B6J.mjs +0 -48
  122. package/dist/packem_shared/hyperdriveOutsideAction-BgZqX7Xg.mjs +0 -30
  123. package/dist/packem_shared/indexReferencesUnknownField-DH0_dbUY.mjs +0 -36
  124. package/dist/packem_shared/indexUtilization-B5DMQ3bI.mjs +0 -45
  125. package/dist/packem_shared/maskUncoveredPiiColumn-DjGIPG6M.mjs +0 -61
  126. package/dist/packem_shared/nondeterministicQueryMutation-GXES1fLp.mjs +0 -35
  127. package/dist/packem_shared/policyReferencesUnknownTable-DtaIEovd.mjs +0 -38
  128. package/dist/packem_shared/publicArgumentUsesAny-C71b2NCf.mjs +0 -32
  129. package/dist/packem_shared/publicMutationWithoutRatelimit-xBpJ6GWK.mjs +0 -36
  130. package/dist/packem_shared/r2sqlOutsideAction-CtqxvMuV.mjs +0 -30
  131. package/dist/packem_shared/relationReferencesUnknownField-YznyXt_7.mjs +0 -54
  132. package/dist/packem_shared/relationReferencesUnknownTable-DrorpKYe.mjs +0 -33
  133. package/dist/packem_shared/rlsUncoveredTable-CxEfZ5eZ.mjs +0 -56
  134. package/dist/packem_shared/sqlInjectionRisk-zwytYGLt.mjs +0 -26
  135. package/dist/packem_shared/tableWithoutInsert-CbbaYIP4.mjs +0 -34
  136. package/dist/packem_shared/unboundedStringArgument-DThg2-wt.mjs +0 -32
  137. package/dist/packem_shared/unindexedForeignKey-BgJbKyqK.mjs +0 -45
  138. package/dist/packem_shared/unindexedRelationTarget-D6eyj6Xx.mjs +0 -53
  139. package/dist/packem_shared/userCreatingMutationWithoutCaptcha-CH31YsUZ.mjs +0 -42
  140. package/dist/packem_shared/workflowUnknownTarget-Cdd7WhKQ.mjs +0 -34
  141. package/dist/packem_shared/workflowUnused-D0jHxdz9.mjs +0 -38
@@ -1,36 +0,0 @@
1
- import { e as emit } from './finding-Dm_zvzS1.mjs';
2
-
3
- const SENSITIVE_NAME_RE = /contact|forgot|login|magic|otp|register|reset|signin|signup|subscribe|verify/iu;
4
- const publicMutationWithoutRatelimit = {
5
- categories: ["SECURITY"],
6
- description: "A public `mutation`/`action` has no `rateLimit` middleware. Publicly-callable writes are flood and brute-force targets — an attacker can exhaust writes, mail quota, or credits, or guess credentials on auth-shaped endpoints.",
7
- facing: "EXTERNAL",
8
- level: "WARN",
9
- name: "public_mutation_without_ratelimit",
10
- remediation: 'Attach a rate limit: `.use(rateLimit(limiter, "<bucket>"))` from `@lunora/ratelimit`, or wrap the recommended public-procedure guards with `.use(protectPublic({ rateLimit, captcha }))` from `@lunora/server`. Genuinely-open writes can be acknowledged by adding a permissive limiter.',
11
- run: (context) => {
12
- if (context.procedureProtections === void 0) {
13
- return [];
14
- }
15
- const findings = [];
16
- for (const procedure of context.procedureProtections) {
17
- const isPublicWrite = procedure.visibility === "public" && (procedure.kind === "mutation" || procedure.kind === "action");
18
- if (!isPublicWrite || procedure.usesRateLimit) {
19
- continue;
20
- }
21
- const sensitive = SENSITIVE_NAME_RE.test(procedure.exportName);
22
- findings.push(
23
- emit(publicMutationWithoutRatelimit, {
24
- cacheKey: `public_mutation_without_ratelimit:${procedure.file}:${procedure.exportName}`,
25
- detail: `Public ${procedure.kind} \`${procedure.exportName}\` (${procedure.file}) has no rate limit${sensitive ? " — its name suggests an auth/abuse-sensitive endpoint, so this is high-risk" : ""}. Add \`.use(rateLimit(...))\` or \`.use(protectPublic({ rateLimit }))\`.`,
26
- metadata: { exportName: procedure.exportName, file: procedure.file, kind: procedure.kind, sensitive }
27
- })
28
- );
29
- }
30
- return findings;
31
- },
32
- source: "static",
33
- title: "Public write without a rate limit"
34
- };
35
-
36
- export { publicMutationWithoutRatelimit as default };
@@ -1,30 +0,0 @@
1
- import { e as emit } from './finding-Dm_zvzS1.mjs';
2
-
3
- const r2sqlOutsideAction = {
4
- categories: ["SCHEMA"],
5
- description: "A `query`/`mutation` handler accesses R2 SQL via `ctx.r2sql`. R2 SQL queries external Apache Iceberg tables over REST (no Workers binding): queries are non-deterministic (like `fetch`) and the reads are invisible to live queries. `ctx.r2sql` is available on `ActionCtx` only and must be confined to `action` handlers.",
6
- facing: "EXTERNAL",
7
- level: "WARN",
8
- name: "r2sql_outside_action",
9
- remediation: "Move the `ctx.r2sql` access into an `action(...)` (the only context where it is typed), where external I/O is allowed. If a query/mutation needs the data, have the action read it via `ctx.r2sql` and write a projection into a `defineSchema` DO/D1 table — that write is tracked by live queries, whereas R2 SQL is not.",
10
- run: (context) => {
11
- if (context.r2sqlCalls === void 0) {
12
- return [];
13
- }
14
- const findings = [];
15
- for (const call of context.r2sqlCalls) {
16
- findings.push(
17
- emit(r2sqlOutsideAction, {
18
- cacheKey: `r2sql_outside_action:${call.file}:${call.line.toString()}:${call.callee}`,
19
- detail: `\`${call.callee}(…)\` in ${call.exportName} (${call.file}:${call.line.toString()}) runs inside a ${call.kind} handler — R2 SQL's \`ctx.r2sql\` is non-deterministic and non-reactive, so it is available only in actions. Move the external query into an \`action\` and project the result into a Lunora table if a query/mutation needs it.`,
20
- metadata: { callee: call.callee, exportName: call.exportName, file: call.file, kind: call.kind, line: call.line }
21
- })
22
- );
23
- }
24
- return findings;
25
- },
26
- source: "static",
27
- title: "R2 SQL `ctx.r2sql` used outside an action"
28
- };
29
-
30
- export { r2sqlOutsideAction as default };
@@ -1,54 +0,0 @@
1
- import { e as emit } from './finding-Dm_zvzS1.mjs';
2
- import { t as tableColumnSet } from './helpers-DNCkMWZQ.mjs';
3
-
4
- const missingColumns = (byName, columnsOf, holder, relation) => {
5
- const target = byName.get(relation.table);
6
- if (!target) {
7
- return [];
8
- }
9
- const fkTable = relation.kind === "one" ? holder : target;
10
- const referencedTable = relation.kind === "one" ? target : holder;
11
- const problems = [];
12
- if (!columnsOf(fkTable).has(relation.field)) {
13
- problems.push({ column: relation.field, owner: fkTable.name, side: "field" });
14
- }
15
- if (!columnsOf(referencedTable).has(relation.references)) {
16
- problems.push({ column: relation.references, owner: referencedTable.name, side: "references" });
17
- }
18
- return problems;
19
- };
20
- const relationReferencesUnknownField = {
21
- categories: ["SCHEMA"],
22
- description: "A relation references a foreign-key or referenced column that is not declared on its table, so the join can never resolve.",
23
- facing: "INTERNAL",
24
- level: "ERROR",
25
- name: "relation_references_unknown_field",
26
- remediation: "Fix the `field` / `references` column name in the relation, or add the missing column.",
27
- run: (context) => {
28
- const byName = new Map(context.schema.tables.map((table) => [table.name, table]));
29
- const columnsCache = /* @__PURE__ */ new Map();
30
- const columnsOf = (table) => {
31
- let columns = columnsCache.get(table);
32
- if (!columns) {
33
- columns = tableColumnSet(table);
34
- columnsCache.set(table, columns);
35
- }
36
- return columns;
37
- };
38
- return context.schema.tables.flatMap(
39
- (table) => table.relations.flatMap(
40
- (relation) => missingColumns(byName, columnsOf, table, relation).map(
41
- (problem) => emit(relationReferencesUnknownField, {
42
- cacheKey: `relation_references_unknown_field:${table.name}:${relation.name}:${problem.side}`,
43
- detail: `Relation "${relation.name}" on table "${table.name}" uses ${problem.side} "${problem.column}", which is not declared on table "${problem.owner}".`,
44
- metadata: { column: problem.column, owner: problem.owner, relation: relation.name, side: problem.side, table: table.name }
45
- })
46
- )
47
- )
48
- );
49
- },
50
- source: "static",
51
- title: "Relation references unknown field"
52
- };
53
-
54
- export { relationReferencesUnknownField as default };
@@ -1,33 +0,0 @@
1
- import { e as emit } from './finding-Dm_zvzS1.mjs';
2
-
3
- const relationReferencesUnknownTable = {
4
- categories: ["SCHEMA"],
5
- description: "A relation targets a table that does not exist in the schema. The relation can never load — the target is a typo or a removed/renamed table.",
6
- facing: "INTERNAL",
7
- level: "ERROR",
8
- name: "relation_references_unknown_table",
9
- remediation: "Fix the target table name in the relation, or add the missing table to the schema.",
10
- run: (context) => {
11
- const findings = [];
12
- const tableNames = new Set(context.schema.tables.map((table) => table.name));
13
- for (const table of context.schema.tables) {
14
- for (const relation of table.relations) {
15
- if (tableNames.has(relation.table)) {
16
- continue;
17
- }
18
- findings.push(
19
- emit(relationReferencesUnknownTable, {
20
- cacheKey: `relation_references_unknown_table:${table.name}:${relation.name}`,
21
- detail: `Relation "${relation.name}" on table "${table.name}" targets table "${relation.table}", which does not exist in the schema.`,
22
- metadata: { relation: relation.name, table: table.name, target: relation.table }
23
- })
24
- );
25
- }
26
- }
27
- return findings;
28
- },
29
- source: "static",
30
- title: "Relation references unknown table"
31
- };
32
-
33
- export { relationReferencesUnknownTable as default };
@@ -1,56 +0,0 @@
1
- import { e as emit } from './finding-Dm_zvzS1.mjs';
2
-
3
- const rlsUncoveredTable = {
4
- categories: ["SECURITY"],
5
- description: "A public procedure reads or writes a table that is covered by an RLS policy elsewhere in the app, but this procedure's builder chain does not include `.use(rls(...))`. The raw, unwrapped `ctx.db` silently bypasses every policy in the list.",
6
- facing: "EXTERNAL",
7
- level: "WARN",
8
- name: "rls_uncovered_table",
9
- remediation: "Add `.use(rls(policies))` to the procedure's builder chain — e.g. `c.use(rls(myPolicies)).query(...)` — so its `ctx.db` is wrapped by the same policy evaluator as the rest of the app. If this procedure is intentionally privileged (e.g. a background job), declare it with `internalQuery` / `internalMutation` / `internalAction` instead of the public builder so the intent is explicit.",
10
- // eslint-disable-next-line sonarjs/cognitive-complexity -- the policy/table cross-reference is clearest as one linear pass; splitting it would obscure the flow.
11
- run: (context) => {
12
- if (context.rlsProcedures === void 0) {
13
- return [];
14
- }
15
- const policyCoveredTables = /* @__PURE__ */ new Set();
16
- for (const procedure of context.rlsProcedures) {
17
- for (const table of procedure.rlsTables) {
18
- if (table !== "") {
19
- policyCoveredTables.add(table);
20
- }
21
- }
22
- }
23
- if (policyCoveredTables.size === 0) {
24
- return [];
25
- }
26
- const findings = [];
27
- for (const procedure of context.rlsProcedures) {
28
- if (procedure.usesRls) {
29
- continue;
30
- }
31
- if (procedure.visibility === "internal") {
32
- continue;
33
- }
34
- const touched = /* @__PURE__ */ new Set();
35
- for (const table of [...procedure.tablesRead, ...procedure.tablesWritten]) {
36
- if (table !== "" && policyCoveredTables.has(table)) {
37
- touched.add(table);
38
- }
39
- }
40
- for (const table of touched) {
41
- findings.push(
42
- emit(rlsUncoveredTable, {
43
- cacheKey: `rls_uncovered_table:${procedure.file}:${procedure.exportName}:${table}`,
44
- detail: `\`${procedure.exportName}\` in ${procedure.file} accesses table \`${table}\` without \`.use(rls(...))\` — the table is policy-gated elsewhere in the app but this procedure bypasses those policies entirely.`,
45
- metadata: { exportName: procedure.exportName, file: procedure.file, table }
46
- })
47
- );
48
- }
49
- }
50
- return findings;
51
- },
52
- source: "static",
53
- title: "RLS-gated table accessed without rls() middleware"
54
- };
55
-
56
- export { rlsUncoveredTable as default };
@@ -1,26 +0,0 @@
1
- import { e as emit } from './finding-Dm_zvzS1.mjs';
2
-
3
- const sqlInjectionRisk = {
4
- categories: ["SECURITY"],
5
- description: "A `ctx.sql` tagged-template interpolates an unparameterized string-building expression (concatenation or nested template) instead of a bound value — splicing raw text into the query and reopening SQL injection.",
6
- facing: "EXTERNAL",
7
- level: "ERROR",
8
- name: "sql_injection_risk",
9
- remediation: "Pass the value through a bound placeholder so the driver parameterizes it — keep request input inside a `ctx.sql` placeholder instead of concatenating it into the query string. Never build SQL text from request input by hand.",
10
- run: (context) => {
11
- if (context.sqlInterpolations === void 0) {
12
- return [];
13
- }
14
- return context.sqlInterpolations.map(
15
- (interpolation) => emit(sqlInjectionRisk, {
16
- cacheKey: `sql_injection_risk:${interpolation.file}:${interpolation.line.toString()}`,
17
- detail: `\`ctx.sql\` in \`${interpolation.exportName}\` (${interpolation.file}:${interpolation.line.toString()}) interpolates a string-building expression instead of a bound value — a SQL-injection vector. Pass the value through a bound placeholder so the driver parameterizes it.`,
18
- metadata: { exportName: interpolation.exportName, file: interpolation.file, line: interpolation.line }
19
- })
20
- );
21
- },
22
- source: "static",
23
- title: "Possible SQL injection in ctx.sql interpolation"
24
- };
25
-
26
- export { sqlInjectionRisk as default };
@@ -1,34 +0,0 @@
1
- import { e as emit } from './finding-Dm_zvzS1.mjs';
2
-
3
- const tableWithoutInsert = {
4
- categories: ["SCHEMA"],
5
- description: 'No function inserts into this table via `ctx.db.insert("<table>", …)`. It may be read-only by design (seeded by a migration, replicated, or written through a path the advisor can\'t see) — or it may be dead schema.',
6
- facing: "INTERNAL",
7
- level: "INFO",
8
- name: "table_without_insert",
9
- remediation: 'If the table should be writable, add a mutation that calls `ctx.db.insert("<table>", …)`. If it is read-only or seeded elsewhere, this advisory can be ignored.',
10
- run: (context) => {
11
- if (context.inserts === void 0) {
12
- return [];
13
- }
14
- const insertedTables = new Set(context.inserts.filter((write) => write.table !== "").map((write) => write.table));
15
- const findings = [];
16
- for (const table of context.schema.tables) {
17
- if (insertedTables.has(table.name) || table.externallyManaged === true) {
18
- continue;
19
- }
20
- findings.push(
21
- emit(tableWithoutInsert, {
22
- cacheKey: `table_without_insert:${table.name}`,
23
- detail: `No function calls \`ctx.db.insert("${table.name}", …)\` — table "${table.name}" has no discovered insert path.`,
24
- metadata: { table: table.name }
25
- })
26
- );
27
- }
28
- return findings;
29
- },
30
- source: "static",
31
- title: "Table has no insert path"
32
- };
33
-
34
- export { tableWithoutInsert as default };
@@ -1,32 +0,0 @@
1
- import { e as emit } from './finding-Dm_zvzS1.mjs';
2
-
3
- const unboundedStringArgument = {
4
- categories: ["SECURITY"],
5
- description: "A public `v.string()` argument has no maximum-length bound. An unbounded string lets a client submit arbitrarily large input — abusing storage and CPU on every request that processes it.",
6
- facing: "EXTERNAL",
7
- level: "INFO",
8
- name: "unbounded_string_arg",
9
- remediation: "Add a max-length bound via `.check(...)` / `.meta({ maxLength })` on the string validator (e.g. cap a name at 256, a body at a few KB). Size the cap to the field's real-world maximum.",
10
- run: (context) => {
11
- if (context.argValidators === void 0) {
12
- return [];
13
- }
14
- const findings = [];
15
- for (const procedure of context.argValidators) {
16
- for (const argument of procedure.unboundedStringArgs) {
17
- findings.push(
18
- emit(unboundedStringArgument, {
19
- cacheKey: `unbounded_string_arg:${procedure.file}:${procedure.exportName}:${argument}`,
20
- detail: `Arg \`${argument}\` of public procedure \`${procedure.exportName}\` (${procedure.file}:${procedure.line.toString()}) is an unbounded \`v.string()\`. Add a max-length bound to cap payload size.`,
21
- metadata: { argument, exportName: procedure.exportName, file: procedure.file, line: procedure.line }
22
- })
23
- );
24
- }
25
- }
26
- return findings;
27
- },
28
- source: "static",
29
- title: "Public string argument has no length bound"
30
- };
31
-
32
- export { unboundedStringArgument as default };
@@ -1,45 +0,0 @@
1
- import { e as emit } from './finding-Dm_zvzS1.mjs';
2
- import { l as leadingIndexedColumns, P as PRIMARY_KEY, s as suggestIndexName } from './fk-index-IUK1ukgs.mjs';
3
-
4
- const unindexedForeignKey = {
5
- categories: ["PERFORMANCE"],
6
- description: "A foreign-key column declared by a `one` relation has no index leading with it. Reads that filter or join on the column full-scan the table, which gets linearly slower as rows accumulate.",
7
- facing: "EXTERNAL",
8
- level: "INFO",
9
- name: "unindexed_foreign_key",
10
- remediation: 'Add a secondary index leading with the FK column, e.g. `.index("byAuthorId", ["authorId"])`.',
11
- run: (context) => {
12
- const findings = [];
13
- for (const table of context.schema.tables) {
14
- const indexed = leadingIndexedColumns(table);
15
- for (const relation of table.relations) {
16
- if (relation.kind !== "one") {
17
- continue;
18
- }
19
- const fkColumn = relation.field;
20
- if (fkColumn === PRIMARY_KEY || indexed.has(fkColumn)) {
21
- continue;
22
- }
23
- const suggestedIndex = suggestIndexName(fkColumn);
24
- findings.push(
25
- emit(unindexedForeignKey, {
26
- cacheKey: `unindexed_foreign_key:${table.name}:${fkColumn}`,
27
- detail: `Relation "${relation.name}" on table "${table.name}" references "${relation.table}" via column "${fkColumn}", which is not the leading column of any index. Reads filtering or joining on "${fkColumn}" full-scan "${table.name}".`,
28
- metadata: {
29
- fkColumn,
30
- references: { column: relation.references, table: relation.table },
31
- relation: relation.name,
32
- suggestedIndex: { fields: [fkColumn], name: suggestedIndex },
33
- table: table.name
34
- }
35
- })
36
- );
37
- }
38
- }
39
- return findings;
40
- },
41
- source: "static",
42
- title: "Unindexed foreign key"
43
- };
44
-
45
- export { unindexedForeignKey as default };
@@ -1,53 +0,0 @@
1
- import { e as emit } from './finding-Dm_zvzS1.mjs';
2
- import { P as PRIMARY_KEY, l as leadingIndexedColumns, s as suggestIndexName } from './fk-index-IUK1ukgs.mjs';
3
-
4
- const unindexedRelationTarget = {
5
- categories: ["PERFORMANCE"],
6
- description: "A `many` relation's foreign-key column on the target table has no index leading with it. Relation predicates (`some`/`none`/`every`) and `with:` child reads filter the target on that column, full-scanning it as rows accumulate.",
7
- facing: "EXTERNAL",
8
- level: "INFO",
9
- name: "unindexed_relation_target",
10
- remediation: 'Add a secondary index on the target table leading with the FK column, e.g. `.index("byAuthorId", ["authorId"])`.',
11
- run: (context) => {
12
- const findings = [];
13
- const tablesByName = new Map(context.schema.tables.map((table) => [table.name, table]));
14
- for (const table of context.schema.tables) {
15
- for (const relation of table.relations) {
16
- if (relation.kind !== "many") {
17
- continue;
18
- }
19
- const target = tablesByName.get(relation.table);
20
- if (target === void 0) {
21
- continue;
22
- }
23
- const fkColumn = relation.field;
24
- if (fkColumn === PRIMARY_KEY) {
25
- continue;
26
- }
27
- const coveredByForeignKeyLint = target.relations.some((targetRelation) => targetRelation.kind === "one" && targetRelation.field === fkColumn);
28
- if (coveredByForeignKeyLint || leadingIndexedColumns(target).has(fkColumn)) {
29
- continue;
30
- }
31
- const suggestedIndex = suggestIndexName(fkColumn);
32
- findings.push(
33
- emit(unindexedRelationTarget, {
34
- cacheKey: `unindexed_relation_target:${relation.table}:${fkColumn}`,
35
- detail: `Relation "${relation.name}" on table "${table.name}" is a to-many over "${relation.table}" via its column "${fkColumn}", which is not the leading column of any index on "${relation.table}". Relation predicates (\`some\`/\`none\`/\`every\`) and \`with:\` reads of "${relation.name}" full-scan "${relation.table}".`,
36
- metadata: {
37
- fkColumn,
38
- references: { column: relation.references, table: table.name },
39
- relation: relation.name,
40
- suggestedIndex: { fields: [fkColumn], name: suggestedIndex },
41
- table: relation.table
42
- }
43
- })
44
- );
45
- }
46
- }
47
- return findings;
48
- },
49
- source: "static",
50
- title: "Unindexed relation target"
51
- };
52
-
53
- export { unindexedRelationTarget as default };
@@ -1,42 +0,0 @@
1
- import { e as emit } from './finding-Dm_zvzS1.mjs';
2
-
3
- const userCreatingMutationWithoutCaptcha = {
4
- categories: ["SECURITY"],
5
- description: "A public `mutation`/`action` that creates a user/session or sends mail has no CAPTCHA / bot check. Account-creating and mail-sending endpoints are prime automated-abuse targets (credential stuffing, mailbox flooding, disposable-account farming).",
6
- facing: "EXTERNAL",
7
- level: "WARN",
8
- name: "user_creating_mutation_without_captcha",
9
- remediation: "Add a server-verified human check: `.use(verifyTurnstile({ secret, token }))` from `@lunora/auth`, or wrap it with `.use(protectPublic({ rateLimit, captcha }))` from `@lunora/server`. Pair with a rate limit for defense in depth.",
10
- run: (context) => {
11
- if (context.procedureProtections === void 0) {
12
- return [];
13
- }
14
- const findings = [];
15
- for (const procedure of context.procedureProtections) {
16
- const isPublicWrite = procedure.visibility === "public" && (procedure.kind === "mutation" || procedure.kind === "action");
17
- const sensitive = procedure.writesUserTable || procedure.callsMail;
18
- if (!isPublicWrite || !sensitive || procedure.usesCaptcha) {
19
- continue;
20
- }
21
- const reason = procedure.writesUserTable ? "writes a user/session table" : "sends mail";
22
- findings.push(
23
- emit(userCreatingMutationWithoutCaptcha, {
24
- cacheKey: `user_creating_mutation_without_captcha:${procedure.file}:${procedure.exportName}`,
25
- detail: `Public ${procedure.kind} \`${procedure.exportName}\` (${procedure.file}) ${reason} but has no CAPTCHA check. Add \`.use(verifyTurnstile(...))\` or \`.use(protectPublic({ captcha }))\`.`,
26
- metadata: {
27
- callsMail: procedure.callsMail,
28
- exportName: procedure.exportName,
29
- file: procedure.file,
30
- kind: procedure.kind,
31
- writesUserTable: procedure.writesUserTable
32
- }
33
- })
34
- );
35
- }
36
- return findings;
37
- },
38
- source: "static",
39
- title: "Account-creating / mail-sending write without a CAPTCHA"
40
- };
41
-
42
- export { userCreatingMutationWithoutCaptcha as default };
@@ -1,34 +0,0 @@
1
- import { e as emit } from './finding-Dm_zvzS1.mjs';
2
-
3
- const workflowUnknownTarget = {
4
- categories: ["SCHEMA"],
5
- description: 'A `ctx.workflows.get("<name>")` call references a workflow that is not declared by any `defineWorkflow` export in `lunora/workflows.ts`. The name is a typo or points at a removed/renamed workflow — the call throws at runtime.',
6
- facing: "INTERNAL",
7
- level: "ERROR",
8
- name: "workflow_unknown_target",
9
- remediation: 'Fix the workflow name in the `ctx.workflows.get("…")` call, or add the missing `defineWorkflow` export to `lunora/workflows.ts`.',
10
- run: (context) => {
11
- if (context.workflows === void 0 || context.workflowCalls === void 0) {
12
- return [];
13
- }
14
- const declared = new Set(context.workflows.map((workflow) => workflow.exportName));
15
- const findings = [];
16
- for (const call of context.workflowCalls) {
17
- if (call.workflow === "" || declared.has(call.workflow)) {
18
- continue;
19
- }
20
- findings.push(
21
- emit(workflowUnknownTarget, {
22
- cacheKey: `workflow_unknown_target:${call.file}:${call.exportName}:${call.workflow}`,
23
- detail: `\`ctx.workflows.get("${call.workflow}")\` in "${call.exportName}" (${call.file}) references workflow "${call.workflow}", which is not declared in lunora/workflows.ts.`,
24
- metadata: { exportName: call.exportName, file: call.file, line: call.line, workflow: call.workflow }
25
- })
26
- );
27
- }
28
- return findings;
29
- },
30
- source: "static",
31
- title: "Workflow call references unknown workflow"
32
- };
33
-
34
- export { workflowUnknownTarget as default };
@@ -1,38 +0,0 @@
1
- import { e as emit } from './finding-Dm_zvzS1.mjs';
2
-
3
- const workflowUnused = {
4
- categories: ["SCHEMA"],
5
- description: 'No function starts this workflow via `ctx.workflows.get("<name>")`. It may be triggered through a path the advisor can\'t see (the Cloudflare API, a wrangler invocation, a cross-service binding) — or it may be dead code that still deploys as a billable WorkflowEntrypoint.',
6
- facing: "INTERNAL",
7
- level: "INFO",
8
- name: "workflow_unused",
9
- remediation: 'If the workflow should be triggered in-app, start it from a mutation/action with `ctx.workflows.get("<name>").create({ params })`. If it is started externally or is no longer needed, this advisory can be ignored (or remove the `defineWorkflow` export).',
10
- run: (context) => {
11
- if (context.workflows === void 0) {
12
- return [];
13
- }
14
- const calls = context.workflowCalls ?? [];
15
- if (calls.some((call) => call.workflow === "")) {
16
- return [];
17
- }
18
- const started = new Set(calls.map((call) => call.workflow));
19
- const findings = [];
20
- for (const workflow of context.workflows) {
21
- if (started.has(workflow.exportName)) {
22
- continue;
23
- }
24
- findings.push(
25
- emit(workflowUnused, {
26
- cacheKey: `workflow_unused:${workflow.exportName}`,
27
- detail: `No function calls \`ctx.workflows.get("${workflow.exportName}")\` — workflow "${workflow.exportName}" is declared but never started in app code.`,
28
- metadata: { workflow: workflow.exportName }
29
- })
30
- );
31
- }
32
- return findings;
33
- },
34
- source: "static",
35
- title: "Workflow is never started"
36
- };
37
-
38
- export { workflowUnused as default };