loadwise 0.5.1 → 0.6.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 (131) hide show
  1. package/README.md +542 -627
  2. package/bin/loadwise.js +4 -0
  3. package/lib/accessibility/frontend-detect.js +2 -1
  4. package/lib/accessibility/rule-ids.js +12 -9
  5. package/{editor/accessibility-examples.cjs → lib/editor/accessibility-examples.js} +20 -21
  6. package/lib/editor/actions.js +117 -0
  7. package/{editor/apply-fix.cjs → lib/editor/apply-fix.js} +1 -6
  8. package/{editor/control-flow-comparison.cjs → lib/editor/control-flow-comparison.js} +1 -3
  9. package/lib/editor/diagnostics.js +365 -0
  10. package/lib/editor/dismissals.js +111 -0
  11. package/lib/editor/editor-document.js +99 -0
  12. package/{editor/finding-comparison.cjs → lib/editor/finding-comparison.js} +4 -7
  13. package/lib/editor/fix-edits.js +200 -0
  14. package/lib/editor/language-server.js +437 -0
  15. package/{editor/maintainability-examples.cjs → lib/editor/maintainability-examples.js} +1 -3
  16. package/{editor/perf-site-comparison.cjs → lib/editor/perf-site-comparison.js} +1 -3
  17. package/lib/editor/perf-watch.js +78 -0
  18. package/{editor/performance-examples.cjs → lib/editor/performance-examples.js} +129 -128
  19. package/{editor/reliability-examples.cjs → lib/editor/reliability-examples.js} +100 -41
  20. package/lib/editor/scan-session.js +334 -0
  21. package/{editor/security-examples.cjs → lib/editor/security-examples.js} +28 -32
  22. package/lib/editor/server-commands.js +232 -0
  23. package/{editor/source-example.cjs → lib/editor/source-example.js} +3 -5
  24. package/{editor/standalone-performance-examples.cjs → lib/editor/standalone-performance-examples.js} +349 -333
  25. package/lib/editor/types/dismissal.js +1 -0
  26. package/lib/editor/types/fix-example.js +1 -0
  27. package/lib/editor/types/source-document.js +1 -0
  28. package/lib/editor/workspace-files.js +78 -0
  29. package/lib/editor/workspace-paths.js +22 -0
  30. package/lib/maintainability/analyze-source.js +2 -0
  31. package/lib/maintainability/apply-fix.js +1 -1
  32. package/lib/maintainability/cli.js +1 -1
  33. package/lib/maintainability/examples.js +58 -41
  34. package/lib/maintainability/rule-ids.js +29 -14
  35. package/lib/maintainability/scan-changed.js +3 -0
  36. package/lib/maintainability/scan.js +13 -9
  37. package/lib/maintainability/tsconfig-strict.js +69 -0
  38. package/lib/maintainability/type-safety-hygiene.js +204 -0
  39. package/lib/performance/analyze.js +2 -0
  40. package/lib/performance/cli-arguments.js +0 -2
  41. package/lib/performance/cli-policy.js +17 -9
  42. package/lib/performance/cli-scan.js +10 -8
  43. package/lib/performance/cli.js +4 -23
  44. package/lib/performance/editor-signal.js +1 -1
  45. package/lib/performance/finding-text.js +3 -3
  46. package/lib/performance/fix-cli.js +1 -1
  47. package/lib/performance/frontend-perf.js +7 -0
  48. package/lib/performance/frontend-render-perf.js +200 -0
  49. package/lib/performance/llm-max-tokens.js +56 -0
  50. package/lib/performance/native.js +46 -26
  51. package/lib/performance/polyglot.js +22 -1
  52. package/lib/performance/pooling.js +38 -23
  53. package/lib/performance/projects.js +42 -21
  54. package/lib/performance/rule-ids.js +236 -222
  55. package/lib/performance/site-fixes/database.js +3 -1
  56. package/lib/performance/site-fixes/integrity.js +15 -1
  57. package/lib/performance/source-inputs.js +18 -6
  58. package/lib/performance/unscanned-javascript.js +66 -19
  59. package/lib/reliability/analyze.js +12 -0
  60. package/lib/reliability/child-process.js +106 -0
  61. package/lib/reliability/error-values.js +177 -0
  62. package/lib/reliability/pool-timeout.js +79 -0
  63. package/lib/reliability/react-bugs.js +602 -0
  64. package/lib/reliability/resource-leaks.js +3 -6
  65. package/lib/reliability/rule-ids.js +169 -127
  66. package/lib/reliability/switch-exhaustive.js +284 -0
  67. package/lib/reliability/uncaught-exception.js +223 -0
  68. package/lib/security/auth-crypto/rule-ids.js +3 -2
  69. package/lib/security/cli.js +6 -5
  70. package/lib/security/deps/rule-ids.js +1 -0
  71. package/lib/security/examples/auth-crypto.cjs +5 -4
  72. package/lib/security/examples/deps.cjs +1 -0
  73. package/lib/security/examples/exposure.cjs +55 -42
  74. package/lib/security/examples/files.cjs +1 -0
  75. package/lib/security/examples/injection.cjs +1 -0
  76. package/lib/security/examples/moved.cjs +5 -4
  77. package/lib/security/examples/request-forgery.cjs +1 -0
  78. package/lib/security/exposure/client-env.js +113 -0
  79. package/lib/security/exposure/frontend-security.js +12 -10
  80. package/lib/security/exposure/index.js +14 -3
  81. package/lib/security/exposure/jsx-url.js +267 -0
  82. package/lib/security/exposure/next-image-config.js +34 -0
  83. package/lib/security/exposure/package-manifest.js +45 -0
  84. package/lib/security/exposure/react-version.js +45 -0
  85. package/lib/security/exposure/rule-ids.js +16 -12
  86. package/lib/security/files/index.js +1 -1
  87. package/lib/security/files/rule-ids.js +1 -0
  88. package/lib/security/injection/code.js +24 -10
  89. package/lib/security/injection/command.js +81 -28
  90. package/lib/security/injection/nosql.js +109 -22
  91. package/lib/security/injection/redos.js +152 -308
  92. package/lib/security/injection/regex-pattern.js +290 -0
  93. package/lib/security/injection/regex.js +30 -11
  94. package/lib/security/injection/rule-ids.js +2 -1
  95. package/lib/security/injection/shared.js +19 -1
  96. package/lib/security/injection/sql.js +83 -2
  97. package/lib/security/request-forgery/rule-ids.js +1 -0
  98. package/lib/security/rule-descriptions.js +36 -32
  99. package/lib/security/rule-ids.js +74 -67
  100. package/lib/security/taint/filename-guard.js +3 -1
  101. package/lib/security/taint/guards.js +84 -10
  102. package/lib/security/taint/index.js +124 -13
  103. package/lib/security/taint/propagate.js +10 -7
  104. package/lib/security/taint/sanitizers.js +7 -3
  105. package/lib/security/taint/sources.js +6 -3
  106. package/lib/security/taint/summaries.js +13 -1
  107. package/lib/security/taint/url-parts.js +14 -5
  108. package/lib/shared/agent-session.js +2 -2
  109. package/lib/shared/check.js +9 -6
  110. package/lib/shared/explain.js +5 -5
  111. package/lib/shared/fix-convergence.js +1 -1
  112. package/lib/shared/formats/finding-location.js +6 -2
  113. package/lib/shared/formats/sarif.js +3 -3
  114. package/lib/shared/heap-limit.js +6 -0
  115. package/lib/shared/pillars.js +7 -7
  116. package/lib/shared/rule-docs.js +12 -0
  117. package/lib/shared/scan-cache.js +0 -1
  118. package/lib/shared/workspaces.js +31 -9
  119. package/package.json +9 -16
  120. package/plugin/.claude-plugin/plugin.json +1 -1
  121. package/schema/loadwise.config.schema.json +44 -0
  122. package/editor/README.md +0 -47
  123. package/examples/redis-keys.otlp.json +0 -22
  124. package/lib/maintainability/notify-editor.js +0 -1
  125. package/lib/performance/editor-report.js +0 -191
  126. package/lib/performance/editor-setup.js +0 -189
  127. package/lib/performance/editor-watch-supervisor.js +0 -104
  128. package/lib/performance/editor-watch.js +0 -193
  129. package/lib/performance/notify-editor.js +0 -1
  130. package/lib/performance/recursive-watch.js +0 -181
  131. /package/lib/{performance/types/editor-report.js → editor/types/comparison.js} +0 -0
@@ -1,101 +1,107 @@
1
+ // Keep sorted by rule id; test/shared/registry-order.test.ts checks it.
1
2
  const sourceRules = [
2
- 'promise-combinator-serial-await',
3
- 'numeric-sort-for-extreme',
4
- 'known-reads-awaited-serially',
5
- 'array-repeated-membership',
3
+ 'angular-default-change-detection',
4
+ 'angular-ngfor-missing-trackby',
5
+ 'angular-subscribe-without-cleanup',
6
6
  'array-repeated-find',
7
- 'reduce-copy-accumulator',
8
- 'pg-query-in-loop',
9
- 'pg-count-materialization',
10
- 'prisma-query-in-loop',
11
- 'prisma-count-materialization',
12
- 'prisma-count-for-existence',
13
- 'node-sync-fs-in-async',
14
- 'rebuild-lookup-in-loop',
15
- 'loop-copy-accumulator',
7
+ 'array-repeated-membership',
8
+ 'await-before-early-exit',
9
+ 'count-then-page-serial',
10
+ 'dom-layout-thrashing',
11
+ 'dom-listener-without-cleanup',
12
+ 'dom-unthrottled-scroll-resize',
13
+ 'drizzle-last-insert-id',
14
+ 'drizzle-query-in-loop',
15
+ 'express-missing-compression',
16
+ 'external-call-in-transaction',
16
17
  'filter-for-existence',
17
- 'pg-first-materialization',
18
- 'prisma-first-materialization',
19
- 'pg-filter-materialization',
20
- 'prisma-filter-materialization',
21
- 'pg-top-k-materialization',
22
- 'prisma-top-k-materialization',
23
- 'pool-created-per-request-or-item',
24
- 'pg-unreleased-checkout',
18
+ 'frontend-barrel-heavy-import',
19
+ 'graphql-n-plus-one-resolver',
20
+ 'guard-query-per-request',
21
+ 'heavy-media-in-request-handler',
22
+ 'json-roundtrip-clone',
23
+ 'json-stringify-in-loop',
24
+ 'known-reads-awaited-serially',
25
+ 'list-count-per-request',
26
+ 'list-query-overfetch',
27
+ 'llm-call-without-max-tokens',
28
+ 'loop-copy-accumulator',
29
+ 'mongoose-hydrate-for-to-object',
30
+ 'mongoose-missing-lean',
31
+ 'node-event-listener-leak',
25
32
  'node-sync-compression-in-async',
26
33
  'node-sync-crypto-in-async',
34
+ 'node-sync-fs-in-async',
27
35
  'node-sync-process-in-async',
28
- 'drizzle-query-in-loop',
29
- 'orm-query-in-loop',
36
+ 'notification-send-in-loop',
37
+ 'numeric-sort-for-extreme',
38
+ 'orm-cartesian-include',
30
39
  'orm-count-materialization',
31
- 'typeorm-existence-materialization',
32
- 'typeorm-unused-count',
33
- 'typeorm-wide-projection',
34
- 'typeorm-transaction-in-loop',
35
- 'redis-command-in-loop',
40
+ 'orm-deep-offset',
41
+ 'orm-query-in-loop',
42
+ 'password-hash-pure-js',
36
43
  'password-hash-sync-in-async',
37
- 'serial-awaits-in-literal',
38
- 'typeorm-load-then-save',
39
- 'queue-add-in-loop',
44
+ 'pg-count-materialization',
45
+ 'pg-filter-materialization',
46
+ 'pg-first-materialization',
47
+ 'pg-query-in-loop',
48
+ 'pg-top-k-materialization',
49
+ 'pg-unreleased-checkout',
50
+ 'pool-created-per-request-or-item',
51
+ 'prisma-count-for-existence',
52
+ 'prisma-count-materialization',
40
53
  'prisma-distinct-in-memory',
54
+ 'prisma-filter-materialization',
55
+ 'prisma-first-materialization',
56
+ 'prisma-query-in-loop',
41
57
  'prisma-relation-count-in-list',
42
- 'guard-query-per-request',
43
- 'mongoose-hydrate-for-to-object',
44
- 'express-missing-compression',
45
- 'heavy-media-in-request-handler',
46
- 'password-hash-pure-js',
47
- 'external-call-in-transaction',
48
- 'service-query-in-loop',
58
+ 'prisma-top-k-materialization',
59
+ 'promise-combinator-serial-await',
60
+ 'queue-add-in-loop',
61
+ 'react-component-defined-in-component',
62
+ 'react-context-value-recreated',
63
+ 'react-fetch-in-effect-no-abort',
64
+ 'react-index-as-key',
65
+ 'react-inline-object-in-jsx-prop',
66
+ 'react-missing-cleanup',
67
+ 'rebuild-lookup-in-loop',
68
+ 'redis-command-in-loop',
49
69
  'redis-keys-command',
50
- 'count-then-page-serial',
51
- 'await-before-early-exit',
52
- 'drizzle-last-insert-id',
70
+ 'reduce-copy-accumulator',
53
71
  'repeated-workbook-decode',
72
+ 'sequential-http-in-loop',
73
+ 'serial-awaits-in-literal',
74
+ 'service-query-in-loop',
75
+ 'session-memory-store',
76
+ 'sql-select-star-in-query',
77
+ 'typeorm-existence-materialization',
78
+ 'typeorm-load-then-save',
79
+ 'typeorm-transaction-in-loop',
80
+ 'typeorm-unused-count',
81
+ 'typeorm-wide-projection',
54
82
  'unbounded-list-query',
55
83
  'unbounded-module-cache',
56
- 'whole-payload-in-memory',
57
- 'list-query-overfetch',
58
- 'orm-deep-offset',
59
- 'list-count-per-request',
60
- 'notification-send-in-loop',
61
- 'session-memory-store',
62
- 'orm-cartesian-include',
63
- 'json-roundtrip-clone',
64
- 'react-missing-cleanup',
65
- 'react-index-as-key',
66
- 'react-fetch-in-effect-no-abort',
67
- 'react-inline-object-in-jsx-prop',
68
- 'angular-subscribe-without-cleanup',
69
- 'angular-default-change-detection',
70
- 'vue-watch-missing-cleanup',
71
84
  'vue-v-for-missing-key',
72
- 'dom-layout-thrashing',
73
- 'dom-listener-without-cleanup',
74
- 'dom-unthrottled-scroll-resize',
75
- 'frontend-barrel-heavy-import',
76
- 'sql-select-star-in-query',
77
- 'sequential-http-in-loop',
78
- 'mongoose-missing-lean',
79
- 'graphql-n-plus-one-resolver',
80
- 'react-context-value-recreated',
81
- 'node-event-listener-leak',
82
- 'json-stringify-in-loop',
85
+ 'vue-watch-missing-cleanup',
86
+ 'whole-payload-in-memory',
83
87
  ];
88
+ // Keep sorted by rule id; test/shared/registry-order.test.ts checks it.
84
89
  const indexRules = [
85
- 'index-missing-foreign-key',
86
90
  'index-missing-filter',
91
+ 'index-missing-foreign-key',
87
92
  'index-missing-order',
88
- 'index-unusable-pattern',
89
- 'index-unusable-expression',
90
93
  'index-redundant-prefix',
94
+ 'index-unusable-expression',
95
+ 'index-unusable-pattern',
91
96
  ];
97
+ // Keep sorted by rule id; test/shared/registry-order.test.ts checks it.
92
98
  const databaseRules = [
93
- 'db-unindexed-foreign-key',
94
- 'db-unused-index',
95
99
  'db-duplicate-index',
100
+ 'db-missing-index',
96
101
  'db-seq-scan-heavy-table',
97
102
  'db-slow-query-plan',
98
- 'db-missing-index',
103
+ 'db-unindexed-foreign-key',
104
+ 'db-unused-index',
99
105
  'mongo-collection-scan-observed',
100
106
  ];
101
107
  // One --ignore list is shared by every command, so a CI script can pass the same flags to each of
@@ -105,175 +111,201 @@ const knownRules = new Set([...sourceRules, ...indexRules, ...databaseRules]);
105
111
  // carry, including the trace, plan and polyglot rules that are not --ignore targets. README
106
112
  // criteria: critical is data loss, an outage or a lock risk in production; high a per-request
107
113
  // scaling problem; medium a measurable local cost; low a micro-optimization.
114
+ // Keep sorted by rule id; test/shared/registry-order.test.ts checks it.
108
115
  const impactByRule = {
109
- 'pg-unreleased-checkout': 'critical',
110
- 'pool-created-per-request-or-item': 'critical',
111
- 'pg-query-in-loop': 'high',
112
- 'prisma-query-in-loop': 'high',
113
- 'drizzle-query-in-loop': 'high',
114
- 'orm-query-in-loop': 'high',
115
- 'service-query-in-loop': 'high',
116
- 'redis-command-in-loop': 'high',
117
- 'queue-add-in-loop': 'high',
118
- 'typeorm-transaction-in-loop': 'high',
119
- 'external-call-in-transaction': 'high',
120
- 'typeorm-load-then-save': 'high',
121
- 'unbounded-list-query': 'high',
122
- 'unbounded-module-cache': 'medium',
123
- 'whole-payload-in-memory': 'medium',
124
- 'list-query-overfetch': 'medium',
125
- 'drizzle-last-insert-id': 'medium',
126
- 'repeated-workbook-decode': 'medium',
127
- 'mongoose-hydrate-for-to-object': 'medium',
128
- 'express-missing-compression': 'low',
129
- 'heavy-media-in-request-handler': 'medium',
130
- 'react-missing-cleanup': 'medium',
131
- 'react-index-as-key': 'low',
132
- 'react-fetch-in-effect-no-abort': 'low',
133
- 'react-inline-object-in-jsx-prop': 'low',
134
- 'angular-subscribe-without-cleanup': 'medium',
135
116
  'angular-default-change-detection': 'low',
136
- 'vue-watch-missing-cleanup': 'medium',
137
- 'vue-v-for-missing-key': 'low',
117
+ 'angular-ngfor-missing-trackby': 'low',
118
+ 'angular-subscribe-without-cleanup': 'medium',
119
+ 'array-repeated-find': 'medium',
120
+ 'array-repeated-membership': 'medium',
121
+ 'await-before-early-exit': 'medium',
122
+ 'count-then-page-serial': 'low',
123
+ 'csharp-fixed-regex-in-loop': 'medium',
124
+ 'csharp-string-concat-in-loop': 'medium',
125
+ 'db-duplicate-index': 'low',
126
+ 'db-missing-index': 'high',
127
+ 'db-seq-scan-heavy-table': 'high',
128
+ 'db-slow-query-plan': 'high',
129
+ 'db-unindexed-foreign-key': 'high',
130
+ 'db-unused-index': 'low',
138
131
  'dom-layout-thrashing': 'medium',
139
132
  'dom-listener-without-cleanup': 'low',
140
133
  'dom-unthrottled-scroll-resize': 'low',
134
+ 'drizzle-last-insert-id': 'medium',
135
+ 'drizzle-query-in-loop': 'high',
136
+ 'duplicate-key-read': 'medium',
137
+ 'express-missing-compression': 'low',
138
+ 'external-call-in-transaction': 'high',
139
+ 'filter-for-existence': 'low',
141
140
  'frontend-barrel-heavy-import': 'low',
142
- 'sql-select-star-in-query': 'low',
143
- 'sequential-http-in-loop': 'high',
144
- 'redis-keys-command': 'high',
145
- 'orm-deep-offset': 'high',
146
- 'list-count-per-request': 'medium',
147
- 'notification-send-in-loop': 'high',
148
- 'session-memory-store': 'high',
149
- 'orm-cartesian-include': 'high',
150
- 'json-roundtrip-clone': 'low',
151
- 'rebuild-lookup-in-loop': 'high',
152
- 'node-sync-crypto-in-async': 'high',
153
- 'node-sync-process-in-async': 'high',
154
- 'password-hash-sync-in-async': 'high',
155
- 'index-missing-foreign-key': 'high',
141
+ 'go-fixed-regexp-in-loop': 'medium',
142
+ 'go-sql-query-in-loop': 'high',
143
+ 'go-string-concat-in-loop': 'medium',
144
+ 'graphql-n-plus-one-resolver': 'high',
145
+ 'guard-query-per-request': 'medium',
146
+ 'heavy-media-in-request-handler': 'medium',
156
147
  'index-missing-filter': 'high',
157
- 'index-unusable-pattern': 'high',
158
- 'index-unusable-expression': 'high',
148
+ 'index-missing-foreign-key': 'high',
149
+ 'index-missing-order': 'medium',
159
150
  'index-redundant-prefix': 'low',
160
- 'db-unindexed-foreign-key': 'high',
161
- 'db-seq-scan-heavy-table': 'high',
162
- 'db-slow-query-plan': 'high',
163
- 'db-missing-index': 'high',
164
- 'mongo-collection-scan-observed': 'high',
165
- 'pg-sequential-scan': 'high',
166
- 'mongo-collection-scan': 'high',
167
- 'pg-deep-offset': 'high',
168
- 'mongo-deep-skip': 'high',
169
- 'repeated-db-span': 'high',
170
- 'redis-keys-scan': 'high',
171
- 'promise-combinator-serial-await': 'medium',
151
+ 'index-unusable-expression': 'high',
152
+ 'index-unusable-pattern': 'high',
153
+ 'java-fixed-regex-in-loop': 'medium',
154
+ 'java-jdbc-query-in-loop': 'high',
155
+ 'java-string-concat-in-loop': 'medium',
156
+ 'json-roundtrip-clone': 'low',
157
+ 'json-stringify-in-loop': 'medium',
172
158
  'known-reads-awaited-serially': 'medium',
173
- 'await-before-early-exit': 'medium',
174
- 'array-repeated-membership': 'medium',
175
- 'array-repeated-find': 'medium',
176
- 'reduce-copy-accumulator': 'medium',
159
+ 'list-count-per-request': 'medium',
160
+ 'list-query-overfetch': 'medium',
161
+ 'llm-call-without-max-tokens': 'medium',
177
162
  'loop-copy-accumulator': 'medium',
178
- 'pg-count-materialization': 'medium',
179
- 'prisma-count-materialization': 'medium',
180
- 'prisma-count-for-existence': 'medium',
163
+ 'mongo-collection-scan': 'high',
164
+ 'mongo-collection-scan-observed': 'high',
165
+ 'mongo-deep-skip': 'high',
166
+ 'mongo-disk-sort': 'medium',
167
+ 'mongoose-hydrate-for-to-object': 'medium',
168
+ 'mongoose-missing-lean': 'medium',
169
+ 'node-event-listener-leak': 'high',
170
+ 'node-sync-compression-in-async': 'medium',
171
+ 'node-sync-crypto-in-async': 'high',
172
+ 'node-sync-fs-in-async': 'medium',
173
+ 'node-sync-process-in-async': 'high',
174
+ 'notification-send-in-loop': 'high',
175
+ 'numeric-sort-for-extreme': 'low',
176
+ 'orm-cartesian-include': 'high',
181
177
  'orm-count-materialization': 'medium',
182
- 'typeorm-unused-count': 'medium',
183
- 'pg-first-materialization': 'medium',
184
- 'prisma-first-materialization': 'medium',
178
+ 'orm-deep-offset': 'high',
179
+ 'orm-query-in-loop': 'high',
180
+ 'password-hash-pure-js': 'medium',
181
+ 'password-hash-sync-in-async': 'high',
182
+ 'pg-count-materialization': 'medium',
183
+ 'pg-deep-offset': 'high',
184
+ 'pg-disk-sort': 'medium',
185
185
  'pg-filter-materialization': 'medium',
186
- 'prisma-filter-materialization': 'medium',
186
+ 'pg-first-materialization': 'medium',
187
+ 'pg-query-in-loop': 'high',
188
+ 'pg-sequential-scan': 'high',
187
189
  'pg-top-k-materialization': 'medium',
188
- 'prisma-top-k-materialization': 'medium',
189
- 'typeorm-existence-materialization': 'medium',
190
- 'node-sync-fs-in-async': 'medium',
191
- 'node-sync-compression-in-async': 'medium',
190
+ 'pg-unreleased-checkout': 'critical',
191
+ 'pool-created-per-request-or-item': 'critical',
192
+ 'prisma-count-for-existence': 'medium',
193
+ 'prisma-count-materialization': 'medium',
192
194
  'prisma-distinct-in-memory': 'medium',
195
+ 'prisma-filter-materialization': 'medium',
196
+ 'prisma-first-materialization': 'medium',
197
+ 'prisma-query-in-loop': 'high',
193
198
  'prisma-relation-count-in-list': 'medium',
194
- 'guard-query-per-request': 'medium',
195
- 'password-hash-pure-js': 'medium',
196
- 'serial-awaits-in-literal': 'medium',
197
- 'duplicate-key-read': 'medium',
198
- 'index-missing-order': 'medium',
199
- 'pg-disk-sort': 'medium',
200
- 'mongo-disk-sort': 'medium',
201
- 'redis-repeated-read': 'medium',
202
- 'csharp-fixed-regex-in-loop': 'medium',
203
- 'go-fixed-regexp-in-loop': 'medium',
204
- 'java-fixed-regex-in-loop': 'medium',
205
- 'rust-fixed-regex-in-loop': 'medium',
206
- 'python-copy-growing-list': 'medium',
207
- 'python-sync-requests-in-async': 'high',
199
+ 'prisma-top-k-materialization': 'medium',
200
+ 'promise-combinator-serial-await': 'medium',
208
201
  'python-blocking-sleep-in-async': 'high',
202
+ 'python-copy-growing-list': 'medium',
209
203
  'python-fixed-regex-in-loop': 'low',
210
- 'numeric-sort-for-extreme': 'low',
211
- 'filter-for-existence': 'low',
212
- 'typeorm-wide-projection': 'low',
213
- 'count-then-page-serial': 'low',
214
- 'db-unused-index': 'low',
215
- 'db-duplicate-index': 'low',
216
- 'mongoose-missing-lean': 'medium',
217
- 'graphql-n-plus-one-resolver': 'high',
218
- 'react-context-value-recreated': 'low',
219
- 'node-event-listener-leak': 'high',
220
- 'json-stringify-in-loop': 'medium',
221
204
  'python-n-plus-one-orm-loop': 'high',
205
+ 'python-sync-requests-in-async': 'high',
222
206
  'python-unbounded-comprehension': 'medium',
223
- 'go-sql-query-in-loop': 'high',
224
- 'go-string-concat-in-loop': 'medium',
225
- 'java-string-concat-in-loop': 'medium',
226
- 'java-jdbc-query-in-loop': 'high',
227
- 'csharp-string-concat-in-loop': 'medium',
207
+ 'queue-add-in-loop': 'high',
208
+ 'react-component-defined-in-component': 'medium',
209
+ 'react-context-value-recreated': 'low',
210
+ 'react-fetch-in-effect-no-abort': 'low',
211
+ 'react-index-as-key': 'low',
212
+ 'react-inline-object-in-jsx-prop': 'low',
213
+ 'react-missing-cleanup': 'medium',
214
+ 'rebuild-lookup-in-loop': 'high',
215
+ 'redis-command-in-loop': 'high',
216
+ 'redis-keys-command': 'high',
217
+ 'redis-keys-scan': 'high',
218
+ 'redis-repeated-read': 'medium',
219
+ 'reduce-copy-accumulator': 'medium',
220
+ 'repeated-db-span': 'high',
221
+ 'repeated-workbook-decode': 'medium',
228
222
  'rust-clone-in-loop': 'low',
223
+ 'rust-fixed-regex-in-loop': 'medium',
229
224
  'rust-format-in-loop': 'low',
225
+ 'sequential-http-in-loop': 'high',
226
+ 'serial-awaits-in-literal': 'medium',
227
+ 'service-query-in-loop': 'high',
228
+ 'session-memory-store': 'high',
229
+ 'sql-select-star-in-query': 'low',
230
+ 'typeorm-existence-materialization': 'medium',
231
+ 'typeorm-load-then-save': 'high',
232
+ 'typeorm-transaction-in-loop': 'high',
233
+ 'typeorm-unused-count': 'medium',
234
+ 'typeorm-wide-projection': 'low',
235
+ 'unbounded-list-query': 'high',
236
+ 'unbounded-module-cache': 'medium',
237
+ 'vue-v-for-missing-key': 'low',
238
+ 'vue-watch-missing-cleanup': 'medium',
239
+ 'whole-payload-in-memory': 'medium',
230
240
  };
231
241
  // One-line summaries of every rule above, used where a rule needs a fixed name (SARIF
232
242
  // shortDescription) rather than the per-site finding message. The README row for each rule has the
233
243
  // full evidence.
244
+ // Keep sorted by rule id; test/shared/registry-order.test.ts checks it.
234
245
  const descriptionByRule = {
235
- 'unbounded-list-query': 'A request handler returns query results without an apparent row limit.',
236
- 'unbounded-module-cache': 'A long-lived cache accepts dynamic keys without an apparent bound or eviction.',
237
- 'whole-payload-in-memory': 'An operation loads an entire file, stream, or response into memory.',
238
- 'list-query-overfetch': 'A list query loads large columns or nested relations without a narrow projection.',
246
+ 'angular-default-change-detection': 'An Angular component uses default change detection instead of OnPush, so its subtree is re-checked on every event.',
247
+ 'angular-ngfor-missing-trackby': 'An *ngFor has no trackBy, so a list replaced with new objects recreates the DOM of every item.',
248
+ 'angular-subscribe-without-cleanup': 'An RxJS subscription in a component has no completing operator or ngOnDestroy unsubscribe and keeps running after destruction.',
239
249
  'array-repeated-find': 'An array is searched with find or findIndex repeatedly where a Map lookup would do.',
240
250
  'array-repeated-membership': 'An array is tested with includes or indexOf repeatedly where a Set would do.',
241
251
  'await-before-early-exit': 'An awaited read runs before a guard that returns or throws without using its result.',
242
252
  'count-then-page-serial': 'A count and a page query with the same filter run one after the other.',
243
253
  'csharp-fixed-regex-in-loop': 'A C# Regex with a fixed pattern is constructed inside a loop.',
254
+ 'csharp-string-concat-in-loop': 'String concatenation in a C# loop allocates repeatedly; use StringBuilder.',
244
255
  'db-duplicate-index': 'A database index is covered by another index on the same table.',
245
256
  'db-missing-index': 'A query plan scans a table that a suggested index would let it seek.',
246
257
  'db-seq-scan-heavy-table': 'A large table is read by many sequential scans on the live database.',
247
258
  'db-slow-query-plan': 'One of the slowest statements reads a table with a full table scan.',
248
259
  'db-unindexed-foreign-key': 'A foreign key on the live database has no index that leads with its columns.',
249
260
  'db-unused-index': 'A database index has not been scanned since statistics were last reset.',
261
+ 'dom-layout-thrashing': 'A loop reads layout metrics and mutates DOM styles or classes, forcing a reflow on each iteration.',
262
+ 'dom-listener-without-cleanup': 'A window or document listener uses an inline function with no AbortSignal or once, so it can never be removed.',
263
+ 'dom-unthrottled-scroll-resize': 'A scroll, resize, mousemove, wheel or touch listener runs unthrottled work (or is non-passive) on the main thread.',
264
+ 'drizzle-last-insert-id': 'A MySQL insert is followed by an extra query for its generated ID.',
250
265
  'drizzle-query-in-loop': 'A Drizzle statement executes once per loop iteration.',
251
266
  'duplicate-key-read': 'A trace repeats the same key or row read under one parent span.',
267
+ 'express-missing-compression': 'An Express server registers no response compression middleware.',
252
268
  'external-call-in-transaction': 'An external call is awaited inside a database transaction, holding its connection and locks.',
253
269
  'filter-for-existence': 'filter(...).length is used only to test whether any element matches.',
254
- 'drizzle-last-insert-id': 'A MySQL insert is followed by an extra query for its generated ID.',
255
- 'repeated-workbook-decode': 'A workflow decodes the same input with ExcelJS more than once.',
270
+ 'frontend-barrel-heavy-import': 'A client module imports the whole of lodash or moment instead of subpaths or a lighter library.',
256
271
  'go-fixed-regexp-in-loop': 'A Go regexp with a fixed pattern is compiled inside a loop.',
272
+ 'go-sql-query-in-loop': 'A Go database query executes inside a loop instead of batching.',
273
+ 'go-string-concat-in-loop': 'String concatenation in a Go loop allocates repeatedly; use strings.Builder.',
274
+ 'graphql-n-plus-one-resolver': 'A GraphQL field resolver executes a database or HTTP query per parent item without DataLoader batching.',
257
275
  'guard-query-per-request': 'A guard or per-request hook runs a database query before every handler.',
276
+ 'heavy-media-in-request-handler': 'Heavy image (sharp) or PDF rendering runs directly inside an HTTP request handler.',
258
277
  'index-missing-filter': 'A query filters on a column that no index leads with.',
259
278
  'index-missing-foreign-key': 'A foreign key column in the schema has no index.',
260
279
  'index-missing-order': 'A query orders by columns that no index serves in that order.',
280
+ 'index-redundant-prefix': 'An index repeats the leading columns of a longer index on the same table, adding write cost for no read benefit.',
261
281
  'index-unusable-expression': 'A function or expression on an indexed column keeps the index from being used.',
262
282
  'index-unusable-pattern': 'A predicate such as a leading-wildcard LIKE cannot use an ordinary index.',
263
- 'index-redundant-prefix': 'An index repeats the leading columns of a longer index on the same table, adding write cost for no read benefit.',
264
283
  'java-fixed-regex-in-loop': 'A Java Pattern with a fixed pattern is compiled inside a loop.',
284
+ 'java-jdbc-query-in-loop': 'A JDBC query executes inside a Java loop instead of batching.',
285
+ 'java-string-concat-in-loop': 'String concatenation in a Java loop allocates repeatedly; use StringBuilder.',
286
+ 'json-roundtrip-clone': 'A value is deep-cloned with JSON.parse(JSON.stringify(...)) on a request path.',
287
+ 'json-stringify-in-loop': 'JSON.stringify runs inside a loop instead of serializing once or streaming.',
265
288
  'known-reads-awaited-serially': 'Two independent reads from a configured parallelReads group are awaited one after the other.',
289
+ 'list-count-per-request': 'A list endpoint runs a full count query on every request.',
290
+ 'list-query-overfetch': 'A list query loads large columns or nested relations without a narrow projection.',
291
+ 'llm-call-without-max-tokens': 'An OpenAI chat or responses call sets no output token limit.',
266
292
  'loop-copy-accumulator': 'A loop copies its growing result on every iteration.',
267
293
  'mongo-collection-scan': 'A MongoDB plan scans many documents for each one it returns.',
268
294
  'mongo-collection-scan-observed': 'Profiled MongoDB operations scanned a whole collection.',
269
295
  'mongo-deep-skip': 'A MongoDB query skips past many documents to return a page.',
270
296
  'mongo-disk-sort': 'A MongoDB sort spilled to disk.',
297
+ 'mongoose-hydrate-for-to-object': 'A Mongoose query hydrates full Documents only to convert them immediately via .toObject() or .toJSON().',
298
+ 'mongoose-missing-lean': 'A Mongoose read query is returned or serialized without .lean(), paying full Document hydration overhead.',
299
+ 'node-event-listener-leak': 'An event listener is registered inside a repeated or per-request context without matching cleanup.',
271
300
  'node-sync-compression-in-async': 'A synchronous zlib call blocks the event loop inside an async function.',
272
301
  'node-sync-crypto-in-async': 'A synchronous crypto call blocks the event loop inside an async function.',
273
302
  'node-sync-fs-in-async': 'A synchronous fs call blocks the event loop inside an async function.',
274
303
  'node-sync-process-in-async': 'A synchronous child_process call blocks the event loop inside an async function.',
304
+ 'notification-send-in-loop': 'A push, email or Firebase message is sent once per loop iteration instead of in one batch.',
275
305
  'numeric-sort-for-extreme': 'A numeric sort is used only to read the smallest or largest value.',
306
+ 'orm-cartesian-include': 'One query joins two or more one-to-many relations, so the returned rows multiply.',
276
307
  'orm-count-materialization': 'A TypeORM, Sequelize, Mongoose, Knex or Kysely query loads rows only to count them.',
308
+ 'orm-deep-offset': 'A list query pages with a large or unbounded offset, so the database reads and discards every skipped row.',
277
309
  'orm-query-in-loop': 'A TypeORM, Sequelize, Mongoose, Knex or Kysely operation runs once per loop iteration.',
278
310
  'password-hash-pure-js': 'bcryptjs hashes passwords in pure JavaScript on the main thread.',
279
311
  'password-hash-sync-in-async': 'A synchronous bcrypt call blocks the event loop inside an async function.',
@@ -286,9 +318,9 @@ const descriptionByRule = {
286
318
  'pg-sequential-scan': 'A PostgreSQL plan scans many rows for each one it returns.',
287
319
  'pg-top-k-materialization': 'A pg query loads an unbounded result that JavaScript sorts to keep the top rows.',
288
320
  'pg-unreleased-checkout': 'A chained pool checkout loses the client, so it is never released.',
289
- 'pool-created-per-request-or-item': 'A database or Redis client or pool is created on a per-request or per-item path.',
290
- 'prisma-count-materialization': 'A Prisma query loads rows only to count them.',
321
+ 'pool-created-per-request-or-item': 'A database, Redis, S3, OpenAI, Anthropic or Stripe client or pool is created on a per-request or per-item path.',
291
322
  'prisma-count-for-existence': 'A Prisma query counts all matches only to check whether any row exists.',
323
+ 'prisma-count-materialization': 'A Prisma query loads rows only to count them.',
292
324
  'prisma-distinct-in-memory': 'Prisma findMany with distinct reads every matching row and de-duplicates in memory.',
293
325
  'prisma-filter-materialization': 'A Prisma query loads an unbounded result that JavaScript then filters by equality.',
294
326
  'prisma-first-materialization': 'A Prisma query loads an unbounded result to read only its first row.',
@@ -296,62 +328,44 @@ const descriptionByRule = {
296
328
  'prisma-relation-count-in-list': 'A paged Prisma findMany selects a relation _count computed over the whole related table.',
297
329
  'prisma-top-k-materialization': 'A Prisma query loads an unbounded result that JavaScript sorts to keep the top rows.',
298
330
  'promise-combinator-serial-await': 'Promise.all receives calls that were already awaited one by one.',
299
- 'python-copy-growing-list': 'A Python loop rebuilds a growing list with items = items + [value].',
300
- 'python-sync-requests-in-async': 'A blocking requests HTTP call runs inside a Python async def function.',
301
331
  'python-blocking-sleep-in-async': 'A blocking time.sleep call runs inside a Python async def function.',
332
+ 'python-copy-growing-list': 'A Python loop rebuilds a growing list with items = items + [value].',
302
333
  'python-fixed-regex-in-loop': 'A Python loop compiles a fixed pattern with re.compile on every iteration.',
334
+ 'python-n-plus-one-orm-loop': 'An ORM query executes inside a Python loop instead of using eager loading or batching.',
335
+ 'python-sync-requests-in-async': 'A blocking requests HTTP call runs inside a Python async def function.',
336
+ 'python-unbounded-comprehension': 'A Python list comprehension materializes an unbounded collection in memory.',
303
337
  'queue-add-in-loop': 'A job queue add runs once per item instead of one addBulk.',
338
+ 'react-component-defined-in-component': 'A component is declared inside another component and rendered as an element, so it remounts on every render and loses its state and DOM.',
339
+ 'react-context-value-recreated': 'An inline object or array literal in Context.Provider value creates a new reference on every render.',
340
+ 'react-fetch-in-effect-no-abort': 'A fetch in an effect has no AbortController or cleanup, so dependency changes can race and apply stale results.',
341
+ 'react-index-as-key': 'A list item uses the map index as its React key, which breaks reconciliation when items are inserted or reordered.',
342
+ 'react-inline-object-in-jsx-prop': 'An inline object literal is passed to a memo() component, creating a new reference each render and defeating the memo.',
343
+ 'react-missing-cleanup': 'An effect starts a global listener, interval, socket or endless subscription and returns no cleanup, so it leaks on every remount.',
304
344
  'rebuild-lookup-in-loop': 'A Set or Map is rebuilt from the same data on every loop iteration.',
305
345
  'redis-command-in-loop': 'A per-key Redis command runs once per loop iteration.',
306
346
  'redis-keys-command': 'A Redis KEYS call blocks the server while it scans the keyspace.',
307
- 'orm-deep-offset': 'A list query pages with a large or unbounded offset, so the database reads and discards every skipped row.',
308
- 'list-count-per-request': 'A list endpoint runs a full count query on every request.',
309
- 'notification-send-in-loop': 'A push, email or Firebase message is sent once per loop iteration instead of in one batch.',
310
- 'session-memory-store': 'An express-session middleware has no store, so sessions live in process memory.',
311
- 'orm-cartesian-include': 'One query joins two or more one-to-many relations, so the returned rows multiply.',
312
- 'json-roundtrip-clone': 'A value is deep-cloned with JSON.parse(JSON.stringify(...)) on a request path.',
313
347
  'redis-keys-scan': 'A trace shows a Redis KEYS command scanning the keyspace.',
314
348
  'redis-repeated-read': 'A trace shows repeated sibling Redis GET or HGET calls.',
315
349
  'reduce-copy-accumulator': 'A reduce callback copies its growing accumulator on every step.',
316
350
  'repeated-db-span': 'A trace shows many similar sibling database calls under one parent.',
351
+ 'repeated-workbook-decode': 'A workflow decodes the same input with ExcelJS more than once.',
352
+ 'rust-clone-in-loop': 'Cloning values inside a Rust loop adds avoidable heap allocations.',
317
353
  'rust-fixed-regex-in-loop': 'A Rust Regex with a fixed pattern is compiled inside a loop.',
354
+ 'rust-format-in-loop': 'Calling format! inside a Rust loop allocates a new String on every iteration.',
355
+ 'sequential-http-in-loop': 'Independent HTTP requests are awaited one at a time inside a loop.',
318
356
  'serial-awaits-in-literal': 'An array or object literal awaits two or more independent values one after another.',
319
357
  'service-query-in-loop': 'A loop calls a project function that runs several database operations per item.',
358
+ 'session-memory-store': 'An express-session middleware has no store, so sessions live in process memory.',
359
+ 'sql-select-star-in-query': 'A raw SQL query selects every column with SELECT * instead of the columns it needs.',
320
360
  'typeorm-existence-materialization': 'A TypeORM entity is loaded only to check whether it exists.',
321
361
  'typeorm-load-then-save': 'A TypeORM entity is loaded only to change a few fields and save it back.',
322
- 'typeorm-unused-count': 'A TypeORM count-and-list query discards its total in immediate tuple destructuring.',
323
362
  'typeorm-transaction-in-loop': 'A loop calls a helper that starts one TypeORM transaction per item.',
363
+ 'typeorm-unused-count': 'A TypeORM count-and-list query discards its total in immediate tuple destructuring.',
324
364
  'typeorm-wide-projection': 'A TypeORM DTO projection loads wide columns it never uses.',
325
- 'mongoose-hydrate-for-to-object': 'A Mongoose query hydrates full Documents only to convert them immediately via .toObject() or .toJSON().',
326
- 'express-missing-compression': 'An Express server registers no response compression middleware.',
327
- 'heavy-media-in-request-handler': 'Heavy image (sharp) or PDF rendering runs directly inside an HTTP request handler.',
328
- 'react-missing-cleanup': 'An effect starts a global listener, interval, socket or endless subscription and returns no cleanup, so it leaks on every remount.',
329
- 'react-index-as-key': 'A list item uses the map index as its React key, which breaks reconciliation when items are inserted or reordered.',
330
- 'react-fetch-in-effect-no-abort': 'A fetch in an effect has no AbortController or cleanup, so dependency changes can race and apply stale results.',
331
- 'react-inline-object-in-jsx-prop': 'An inline object literal is passed to a memo() component, creating a new reference each render and defeating the memo.',
332
- 'angular-subscribe-without-cleanup': 'An RxJS subscription in a component has no completing operator or ngOnDestroy unsubscribe and keeps running after destruction.',
333
- 'angular-default-change-detection': 'An Angular component uses default change detection instead of OnPush, so its subtree is re-checked on every event.',
334
- 'vue-watch-missing-cleanup': 'onMounted registers a global listener, timer or observer with no unmount cleanup.',
365
+ 'unbounded-list-query': 'A request handler returns query results without an apparent row limit.',
366
+ 'unbounded-module-cache': 'A long-lived cache accepts dynamic keys without an apparent bound or eviction.',
335
367
  'vue-v-for-missing-key': 'A list rendered with h() has no key prop, forcing inefficient patching.',
336
- 'dom-layout-thrashing': 'A loop reads layout metrics and mutates DOM styles or classes, forcing a reflow on each iteration.',
337
- 'dom-listener-without-cleanup': 'A window or document listener uses an inline function with no AbortSignal or once, so it can never be removed.',
338
- 'dom-unthrottled-scroll-resize': 'A scroll, resize, mousemove, wheel or touch listener runs unthrottled work (or is non-passive) on the main thread.',
339
- 'frontend-barrel-heavy-import': 'A client module imports the whole of lodash or moment instead of subpaths or a lighter library.',
340
- 'sql-select-star-in-query': 'A raw SQL query selects every column with SELECT * instead of the columns it needs.',
341
- 'sequential-http-in-loop': 'Independent HTTP requests are awaited one at a time inside a loop.',
342
- 'mongoose-missing-lean': 'A Mongoose read query is returned or serialized without .lean(), paying full Document hydration overhead.',
343
- 'graphql-n-plus-one-resolver': 'A GraphQL field resolver executes a database or HTTP query per parent item without DataLoader batching.',
344
- 'react-context-value-recreated': 'An inline object or array literal in Context.Provider value creates a new reference on every render.',
345
- 'node-event-listener-leak': 'An event listener is registered inside a repeated or per-request context without matching cleanup.',
346
- 'json-stringify-in-loop': 'JSON.stringify runs inside a loop instead of serializing once or streaming.',
347
- 'python-n-plus-one-orm-loop': 'An ORM query executes inside a Python loop instead of using eager loading or batching.',
348
- 'python-unbounded-comprehension': 'A Python list comprehension materializes an unbounded collection in memory.',
349
- 'go-sql-query-in-loop': 'A Go database query executes inside a loop instead of batching.',
350
- 'go-string-concat-in-loop': 'String concatenation in a Go loop allocates repeatedly; use strings.Builder.',
351
- 'java-string-concat-in-loop': 'String concatenation in a Java loop allocates repeatedly; use StringBuilder.',
352
- 'java-jdbc-query-in-loop': 'A JDBC query executes inside a Java loop instead of batching.',
353
- 'csharp-string-concat-in-loop': 'String concatenation in a C# loop allocates repeatedly; use StringBuilder.',
354
- 'rust-clone-in-loop': 'Cloning values inside a Rust loop adds avoidable heap allocations.',
355
- 'rust-format-in-loop': 'Calling format! inside a Rust loop allocates a new String on every iteration.',
368
+ 'vue-watch-missing-cleanup': 'onMounted registers a global listener, timer or observer with no unmount cleanup.',
369
+ 'whole-payload-in-memory': 'An operation loads an entire file, stream, or response into memory.',
356
370
  };
357
371
  export { sourceRules, indexRules, databaseRules, knownRules, impactByRule, descriptionByRule };
@@ -445,11 +445,13 @@ function mongooseLeanFix({ node, sourceFile }) {
445
445
  note: 'Appends `.lean()` so Mongoose skips hydrating full Document instances.',
446
446
  };
447
447
  }
448
+ // A lean result skips schema defaults, getters and virtuals, so a field the caller reads can disappear.
449
+ const reviewedLeanFix = requireReview('A lean result skips schema defaults, getters and virtuals; check that callers do not read them.', mongooseLeanFix);
448
450
  export default {
449
451
  'db-unindexed-foreign-key': reviewedMigration,
450
452
  'db-missing-index': reviewedMigration,
451
453
  'db-slow-query-plan': reviewedMigration,
452
454
  'db-unused-index': reviewedMigration,
453
455
  'db-duplicate-index': reviewedMigration,
454
- 'mongoose-hydrate-for-to-object': mongooseLeanFix,
456
+ 'mongoose-hydrate-for-to-object': reviewedLeanFix,
455
457
  };