@critiq/rules 0.0.1 → 0.1.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 (204) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +256 -140
  3. package/catalog.yaml +985 -19
  4. package/package.json +7 -1
  5. package/rules/go/go.performance.no-regex-construction-in-loop.rule.yaml +33 -0
  6. package/rules/go/go.performance.no-sync-fs-in-request-path.rule.yaml +33 -0
  7. package/rules/go/go.performance.no-unbounded-concurrency.rule.yaml +33 -0
  8. package/rules/go/go.security.echo-sensitive-binding-without-validation.rule.yaml +46 -0
  9. package/rules/go/go.security.echo-unsafe-multipart-upload.rule.yaml +45 -0
  10. package/rules/go/go.security.fiber-sensitive-binding-without-validation.rule.yaml +45 -0
  11. package/rules/go/go.security.fiber-unsafe-multipart-upload.rule.yaml +45 -0
  12. package/rules/go/go.security.gin-sensitive-binding-without-validation.rule.yaml +45 -0
  13. package/rules/go/go.security.gin-trust-all-proxies.rule.yaml +45 -0
  14. package/rules/go/go.security.gin-wildcard-cors-with-credentials.rule.yaml +47 -0
  15. package/rules/go/go.security.net-http-missing-timeouts.rule.yaml +45 -0
  16. package/rules/go/go.security.sensitive-data-egress.rule.yaml +46 -0
  17. package/rules/go/go.security.tar-path-traversal.rule.yaml +45 -0
  18. package/rules/go/go.security.template-unescaped-request-value.rule.yaml +45 -0
  19. package/rules/go/go.testing.real-network-in-unit-test.rule.yaml +33 -0
  20. package/rules/go/go.testing.t-skip-without-ticket-reference.rule.yaml +33 -0
  21. package/rules/go/go.testing.time-sleep-in-unit-test.rule.yaml +33 -0
  22. package/rules/java/java.performance.no-regex-construction-in-loop.rule.yaml +33 -0
  23. package/rules/java/java.performance.no-sync-fs-in-request-path.rule.yaml +33 -0
  24. package/rules/java/java.performance.no-unbounded-concurrency.rule.yaml +33 -0
  25. package/rules/java/java.security.android-screenshot-exposure.rule.yaml +35 -0
  26. package/rules/java/java.security.android-world-readable-mode.rule.yaml +35 -0
  27. package/rules/java/java.security.jpa-concatenated-query.rule.yaml +47 -0
  28. package/rules/java/java.security.reflected-output-from-request.rule.yaml +35 -0
  29. package/rules/java/java.security.servlet-insecure-cookie.rule.yaml +35 -0
  30. package/rules/java/java.security.spring-actuator-health-details-always.rule.yaml +40 -0
  31. package/rules/java/java.security.spring-actuator-sensitive-exposure.rule.yaml +40 -0
  32. package/rules/java/java.security.spring-csrf-globally-disabled.rule.yaml +49 -0
  33. package/rules/java/java.security.spring-debug-exposure.rule.yaml +35 -0
  34. package/rules/java/java.security.spring-permit-all-default.rule.yaml +47 -0
  35. package/rules/java/java.security.spring-webmvc-unrestricted-data-binding.rule.yaml +47 -0
  36. package/rules/java/java.security.template-unescaped-user-output.rule.yaml +49 -0
  37. package/rules/java/java.testing.disabled-without-ticket-reference.rule.yaml +33 -0
  38. package/rules/java/java.testing.http-client-in-unit-test.rule.yaml +33 -0
  39. package/rules/java/java.testing.thread-sleep-in-unit-test.rule.yaml +33 -0
  40. package/rules/php/php.performance.no-regex-construction-in-loop.rule.yaml +33 -0
  41. package/rules/php/php.performance.no-sync-fs-in-request-path.rule.yaml +33 -0
  42. package/rules/php/php.performance.no-unbounded-concurrency.rule.yaml +33 -0
  43. package/rules/php/php.security.insecure-cors-wildcard-with-credentials.rule.yaml +41 -0
  44. package/rules/php/php.security.insecure-mail-or-file-transport.rule.yaml +41 -0
  45. package/rules/php/php.security.insecure-session-or-cookie-config.rule.yaml +42 -0
  46. package/rules/php/php.security.laravel-sensitive-csrf-exclusion.rule.yaml +42 -0
  47. package/rules/php/php.security.laravel-unsafe-blade-output.rule.yaml +42 -0
  48. package/rules/php/php.security.laravel-unsafe-mass-assignment.rule.yaml +45 -0
  49. package/rules/php/php.security.sensitive-data-egress.rule.yaml +42 -0
  50. package/rules/php/php.security.symfony-csrf-disabled.rule.yaml +42 -0
  51. package/rules/php/php.security.symfony-debug-exposure.rule.yaml +44 -0
  52. package/rules/php/php.security.unsafe-file-upload-handling.rule.yaml +41 -0
  53. package/rules/php/php.security.wordpress-missing-nonce-or-capability.rule.yaml +42 -0
  54. package/rules/php/php.security.wordpress-unprepared-sql.rule.yaml +42 -0
  55. package/rules/php/php.testing.curl-in-unit-test.rule.yaml +33 -0
  56. package/rules/php/php.testing.mark-test-skipped-without-ticket-reference.rule.yaml +33 -0
  57. package/rules/php/php.testing.sleep-in-unit-test.rule.yaml +33 -0
  58. package/rules/python/py.performance.no-regex-construction-in-loop.rule.yaml +33 -0
  59. package/rules/python/py.performance.no-sync-fs-in-request-path.rule.yaml +33 -0
  60. package/rules/python/py.performance.no-unbounded-concurrency.rule.yaml +33 -0
  61. package/rules/python/py.security.django-csrf-exempt-state-changing.rule.yaml +46 -0
  62. package/rules/python/py.security.django-missing-csrf-middleware.rule.yaml +47 -0
  63. package/rules/python/py.security.django-unsafe-production-settings.rule.yaml +47 -0
  64. package/rules/python/py.security.drf-allow-any-default.rule.yaml +46 -0
  65. package/rules/python/py.security.drf-allow-any-unsafe-method.rule.yaml +46 -0
  66. package/rules/python/py.security.fastapi-insecure-cors.rule.yaml +43 -0
  67. package/rules/python/py.security.flask-missing-upload-body-limit.rule.yaml +44 -0
  68. package/rules/python/py.security.flask-unsafe-html-output.rule.yaml +44 -0
  69. package/rules/python/py.security.flask-unsafe-upload-filename.rule.yaml +44 -0
  70. package/rules/python/py.testing.pytest-skip-without-ticket-reference.rule.yaml +33 -0
  71. package/rules/python/py.testing.real-network-in-unit-test.rule.yaml +33 -0
  72. package/rules/python/py.testing.time-sleep-in-unit-test.rule.yaml +33 -0
  73. package/rules/ruby/ruby.performance.no-regex-construction-in-loop.rule.yaml +33 -0
  74. package/rules/ruby/ruby.performance.no-sync-fs-in-request-path.rule.yaml +33 -0
  75. package/rules/ruby/ruby.performance.no-unbounded-concurrency.rule.yaml +33 -0
  76. package/rules/ruby/ruby.security.rails-csrf-disabled.rule.yaml +45 -0
  77. package/rules/ruby/ruby.security.rails-detailed-exceptions-enabled.rule.yaml +44 -0
  78. package/rules/ruby/ruby.security.rails-open-redirect.rule.yaml +45 -0
  79. package/rules/ruby/ruby.security.rails-unsafe-html-output.rule.yaml +46 -0
  80. package/rules/ruby/ruby.security.rails-unsafe-render.rule.yaml +45 -0
  81. package/rules/ruby/ruby.security.rails-unsafe-session-or-cookie-store.rule.yaml +45 -0
  82. package/rules/ruby/ruby.security.rails-unsafe-strong-parameters.rule.yaml +46 -0
  83. package/rules/ruby/ruby.security.sensitive-data-egress.rule.yaml +45 -0
  84. package/rules/ruby/ruby.security.sidekiq-web-unauthenticated-mount.rule.yaml +45 -0
  85. package/rules/ruby/ruby.testing.focused-example.rule.yaml +33 -0
  86. package/rules/ruby/ruby.testing.pending-without-ticket-reference.rule.yaml +33 -0
  87. package/rules/ruby/ruby.testing.real-network-in-unit-test.rule.yaml +33 -0
  88. package/rules/ruby/ruby.testing.skip-without-ticket-reference.rule.yaml +33 -0
  89. package/rules/ruby/ruby.testing.sleep-in-unit-test.rule.yaml +33 -0
  90. package/rules/rust/rust.performance.no-regex-construction-in-loop.rule.yaml +33 -0
  91. package/rules/rust/rust.performance.no-sync-fs-in-request-path.rule.yaml +33 -0
  92. package/rules/rust/rust.performance.no-unbounded-concurrency.rule.yaml +33 -0
  93. package/rules/rust/rust.security.actix-wildcard-cors-with-credentials.rule.yaml +47 -0
  94. package/rules/rust/rust.security.axum-body-limit-disabled.rule.yaml +45 -0
  95. package/rules/rust/rust.security.axum-insecure-cors-with-credentials.rule.yaml +47 -0
  96. package/rules/rust/rust.security.rocket-panic-prone-request-handler.rule.yaml +45 -0
  97. package/rules/rust/rust.security.rocket-unsafe-template-output.rule.yaml +47 -0
  98. package/rules/rust/rust.security.sqlx-diesel-raw-interpolated-query.rule.yaml +47 -0
  99. package/rules/rust/rust.security.template-unescaped-request-value.rule.yaml +47 -0
  100. package/rules/rust/rust.security.warp-blocking-or-panic-in-async-handler.rule.yaml +45 -0
  101. package/rules/rust/rust.testing.ignore-without-ticket-reference.rule.yaml +33 -0
  102. package/rules/rust/rust.testing.real-network-in-unit-test.rule.yaml +33 -0
  103. package/rules/rust/rust.testing.thread-sleep-in-unit-test.rule.yaml +33 -0
  104. package/rules/shared/security.archive-path-traversal.rule.yaml +41 -0
  105. package/rules/shared/security.external-file-upload.rule.yaml +40 -0
  106. package/rules/shared/security.permissive-file-permissions.rule.yaml +40 -0
  107. package/rules/shared/security.sensitive-data-egress.rule.yaml +36 -0
  108. package/rules/typescript/ts.correctness.assignment-in-condition.rule.yaml +36 -0
  109. package/rules/typescript/ts.correctness.assignment-to-import-binding.rule.yaml +36 -0
  110. package/rules/typescript/ts.correctness.async-promise-executor.rule.yaml +36 -0
  111. package/rules/typescript/ts.correctness.duplicate-function-parameter.rule.yaml +36 -0
  112. package/rules/typescript/ts.correctness.duplicate-import-source.rule.yaml +36 -0
  113. package/rules/typescript/ts.correctness.duplicate-object-key.rule.yaml +36 -0
  114. package/rules/typescript/ts.correctness.duplicate-switch-case.rule.yaml +36 -0
  115. package/rules/typescript/ts.correctness.empty-block-statement.rule.yaml +35 -0
  116. package/rules/typescript/ts.correctness.identical-comparison-operands.rule.yaml +36 -0
  117. package/rules/typescript/ts.correctness.reassign-catch-binding.rule.yaml +35 -0
  118. package/rules/typescript/ts.correctness.regexp-pattern-unusual-control-character.rule.yaml +35 -0
  119. package/rules/typescript/ts.correctness.self-assignment.rule.yaml +36 -0
  120. package/rules/typescript/ts.next.server-action-missing-local-auth.rule.yaml +35 -0
  121. package/rules/typescript/ts.performance.no-array-spread-in-hot-loop.rule.yaml +32 -0
  122. package/rules/typescript/ts.performance.no-cache-miss-from-unstable-key.rule.yaml +32 -0
  123. package/rules/typescript/ts.performance.no-expensive-sort-in-render-path.rule.yaml +32 -0
  124. package/rules/typescript/ts.performance.no-json-parse-stringify-clone.rule.yaml +32 -0
  125. package/rules/typescript/ts.performance.no-large-object-spread-in-loop.rule.yaml +32 -0
  126. package/rules/typescript/ts.performance.no-n-plus-one-await-in-map.rule.yaml +32 -0
  127. package/rules/typescript/ts.performance.no-redundant-network-fetch.rule.yaml +32 -0
  128. package/rules/typescript/ts.performance.no-regex-construction-in-loop.rule.yaml +32 -0
  129. package/rules/typescript/ts.performance.no-sync-fs-in-request-path.rule.yaml +32 -0
  130. package/rules/typescript/ts.performance.no-unbounded-concurrency.rule.yaml +32 -0
  131. package/rules/typescript/ts.quality.no-ambiguous-abbreviations.rule.yaml +27 -0
  132. package/rules/typescript/ts.quality.no-barrel-file-cycle.rule.yaml +27 -0
  133. package/rules/typescript/ts.quality.no-boolean-parameter-trap.rule.yaml +27 -0
  134. package/rules/typescript/ts.quality.no-dead-export.rule.yaml +27 -0
  135. package/rules/typescript/ts.quality.no-hidden-side-effect-import.rule.yaml +27 -0
  136. package/rules/typescript/ts.quality.no-inconsistent-error-shape.rule.yaml +27 -0
  137. package/rules/typescript/ts.quality.no-mixed-abstraction-level.rule.yaml +27 -0
  138. package/rules/typescript/ts.quality.no-primitive-obsession-in-domain-model.rule.yaml +27 -0
  139. package/rules/typescript/ts.quality.no-temporal-coupling.rule.yaml +27 -0
  140. package/rules/typescript/ts.quality.no-wide-public-surface.rule.yaml +27 -0
  141. package/rules/typescript/ts.react.no-accessibility-label-missing.rule.yaml +36 -0
  142. package/rules/typescript/ts.react.no-activedescendant-on-non-focusable-host.rule.yaml +36 -0
  143. package/rules/typescript/ts.react.no-click-without-keyboard-handler.rule.yaml +36 -0
  144. package/rules/typescript/ts.react.no-deprecated-create-factory.rule.yaml +34 -0
  145. package/rules/typescript/ts.react.no-deprecated-react-dom-root-api.rule.yaml +34 -0
  146. package/rules/typescript/ts.react.no-derived-state-from-props.rule.yaml +34 -0
  147. package/rules/typescript/ts.react.no-effect-fetch-without-cancellation.rule.yaml +35 -0
  148. package/rules/typescript/ts.react.no-find-dom-node.rule.yaml +34 -0
  149. package/rules/typescript/ts.react.no-img-missing-alt-text.rule.yaml +36 -0
  150. package/rules/typescript/ts.react.no-index-as-key-in-dynamic-list.rule.yaml +34 -0
  151. package/rules/typescript/ts.react.no-interactive-role-on-static-semantics.rule.yaml +36 -0
  152. package/rules/typescript/ts.react.no-invalid-anchor-href.rule.yaml +36 -0
  153. package/rules/typescript/ts.react.no-keyboard-interaction-without-widget-role.rule.yaml +36 -0
  154. package/rules/typescript/ts.react.no-legacy-lifecycle.rule.yaml +34 -0
  155. package/rules/typescript/ts.react.no-missing-error-boundary.rule.yaml +36 -0
  156. package/rules/typescript/ts.react.no-positive-tabindex.rule.yaml +36 -0
  157. package/rules/typescript/ts.react.no-static-element-with-synthetic-handlers.rule.yaml +36 -0
  158. package/rules/typescript/ts.react.no-string-ref.rule.yaml +34 -0
  159. package/rules/typescript/ts.react.no-uncontrolled-to-controlled-input.rule.yaml +34 -0
  160. package/rules/typescript/ts.react.no-widget-role-without-tabindex.rule.yaml +36 -0
  161. package/rules/typescript/ts.security.ajv-insecure-configuration.rule.yaml +34 -0
  162. package/rules/typescript/ts.security.angular-dom-sanitizer-bypass-untrusted-input.rule.yaml +35 -0
  163. package/rules/typescript/ts.security.apollo-server-csrf-disabled.rule.yaml +36 -0
  164. package/rules/typescript/ts.security.apollo-server-graphql-dev-tooling-exposure.rule.yaml +36 -0
  165. package/rules/typescript/ts.security.apollo-server-introspection-exposure.rule.yaml +35 -0
  166. package/rules/typescript/ts.security.apollo-server-missing-query-limits.rule.yaml +35 -0
  167. package/rules/typescript/ts.security.astro-vite-public-secret-define.rule.yaml +39 -0
  168. package/rules/typescript/ts.security.debug-statement-in-source.rule.yaml +36 -0
  169. package/rules/typescript/ts.security.electron-dangerous-webpreferences.rule.yaml +35 -0
  170. package/rules/typescript/ts.security.electron-insecure-local-state.rule.yaml +35 -0
  171. package/rules/typescript/ts.security.electron-missing-ipc-origin-check.rule.yaml +35 -0
  172. package/rules/typescript/ts.security.electron-shell-open-external-unvalidated.rule.yaml +35 -0
  173. package/rules/typescript/ts.security.express-error-handler-information-disclosure.rule.yaml +35 -0
  174. package/rules/typescript/ts.security.express-static-dotfiles-allow.rule.yaml +35 -0
  175. package/rules/typescript/ts.security.express-unbounded-body-parser.rule.yaml +34 -0
  176. package/rules/typescript/ts.security.express-user-controlled-static-mount.rule.yaml +35 -0
  177. package/rules/typescript/ts.security.fastify-excessive-body-limit.rule.yaml +34 -0
  178. package/rules/typescript/ts.security.fastify-public-bind-without-trust-proxy.rule.yaml +38 -0
  179. package/rules/typescript/ts.security.graphql-upload-without-csrf-guard.rule.yaml +36 -0
  180. package/rules/typescript/ts.security.iframe-missing-sandbox-attribute.rule.yaml +35 -0
  181. package/rules/typescript/ts.security.insecure-content-security-policy-literal.rule.yaml +35 -0
  182. package/rules/typescript/ts.security.insecure-helmet-hardening-options.rule.yaml +36 -0
  183. package/rules/typescript/ts.security.jwt-insecure-signing-algorithm.rule.yaml +35 -0
  184. package/rules/typescript/ts.security.legacy-buffer-constructor.rule.yaml +35 -0
  185. package/rules/typescript/ts.security.log-injection.rule.yaml +36 -0
  186. package/rules/typescript/ts.security.nestjs-helmet-after-route-mount.rule.yaml +34 -0
  187. package/rules/typescript/ts.security.nestjs-missing-global-validation-pipe.rule.yaml +35 -0
  188. package/rules/typescript/ts.security.nestjs-skip-throttle-sensitive-route.rule.yaml +35 -0
  189. package/rules/typescript/ts.security.nestjs-validation-pipe-without-whitelist.rule.yaml +36 -0
  190. package/rules/typescript/ts.security.nuxt-public-runtime-secret.rule.yaml +38 -0
  191. package/rules/typescript/ts.security.open-redirect.rule.yaml +2 -0
  192. package/rules/typescript/ts.security.request-driven-array-index-access.rule.yaml +33 -0
  193. package/rules/typescript/ts.security.sensitive-data-egress.rule.yaml +1 -0
  194. package/rules/typescript/ts.security.ssrf.rule.yaml +1 -0
  195. package/rules/typescript/ts.security.unsafe-dompurify-version.rule.yaml +36 -0
  196. package/rules/typescript/ts.security.unsafe-marked-version.rule.yaml +36 -0
  197. package/rules/typescript/ts.security.xml-parse-string-with-untrusted-input.rule.yaml +35 -0
  198. package/rules/typescript/ts.testing.no-flaky-timer-test.rule.yaml +38 -0
  199. package/rules/typescript/ts.testing.no-focused-test.rule.yaml +34 -0
  200. package/rules/typescript/ts.testing.no-missing-edge-case-tests.rule.yaml +35 -0
  201. package/rules/typescript/ts.testing.no-network-call-in-unit-test.rule.yaml +38 -0
  202. package/rules/typescript/ts.testing.no-skipped-test-without-ticket.rule.yaml +34 -0
  203. package/rules/typescript/ts.testing.no-snapshot-without-intent.rule.yaml +34 -0
  204. package/rules/typescript/ts.testing.no-test-only-code-in-production.rule.yaml +38 -0
package/README.md CHANGED
@@ -1,169 +1,285 @@
1
- # @critiq/rules
1
+ <p align="center">
2
+ <img src="https://raw.githubusercontent.com/critiq-dev/critiq-rules/main/docs/assets/banner-rules-simple-transparent.png" alt="critiq.dev" style="max-height:400px" />
3
+ </p>
2
4
 
3
- `@critiq/rules` is the default public OSS catalog used by `critiq check`.
5
+ <h1 align="center">Critiq OSS Rules</h1>
6
+ <p align="center">
7
+ <strong>Open source static analysis rules for deterministic code review.<br/>High-signal rules for security, correctness, performance, and code quality.</strong>
8
+ </p>
9
+ <p align="center">
10
+ <a href="https://www.npmjs.com/package/@critiq/rules"><img src="https://img.shields.io/npm/v/%40critiq%2Frules" alt="npm version" /></a>
11
+ <a href="https://github.com/critiq-dev/critiq-rules/tree/main/libs/rules/catalog"><img src="https://img.shields.io/badge/source-GitHub-181717?logo=github" alt="Source" /></a>
12
+ <a href="https://github.com/critiq-dev/critiq-rules/blob/main/libs/rules/catalog/LICENSE"><img src="https://img.shields.io/badge/license-Apache%202.0-blue.svg" alt="License" /></a>
13
+ </p>
4
14
 
5
- It ships:
6
15
 
7
- - `catalog.yaml`
8
- - rule YAML files under `rules/`
9
- - preset membership for `recommended`, `strict`, `security`, and `experimental`
10
16
 
11
- The current catalog is still TypeScript-heavy, but the shared security baseline
12
- also runs across Go and Python. Some rules are pure AST matches, and others
13
- depend on adapter facts such as control-flow, async, structural, and data-flow
14
- observations. A smaller set now depends on check-runner project heuristics for
15
- cross-file auth, coupling, and testing checks.
17
+ Think of Critiq as an extra code reviewer that scans your project for bugs, security issues, performance problems, and risky changes before they turn into production incidents. Instead of only checking style, it focuses on the kinds of problems that usually slip through review and cause real trouble later. You run it locally or in CI, and it gives you deterministic findings you can act on before merging code.
16
18
 
17
- ## What Gets Checked
18
19
 
19
- Representative examples of patterns the catalog flags today:
20
+ It does this by parsing your code, matching it against a curated catalog of explicit rules, and reporting findings with concrete evidence tied to the code that triggered them. That means the output is based on repeatable checks for things like unsafe SQL, missing authorization, repeated IO in loops, and untested critical logic changes, not vague heuristics or style-only linting.
20
21
 
21
- ```ts
22
- console.log('hello');
23
- console.error(error);
24
- debugger;
25
- ```
22
+ <p align="center">
23
+ <img
24
+ src="https://raw.githubusercontent.com/critiq-dev/critiq-core/main/docs/assets/languages.png"
25
+ alt="TypeScript, JavaScript, Node.js, Go, Java, Python, PHP, Ruby, and Rust support"
26
+ />
27
+ </p>
28
+ `@critiq/rules` is the default open source rule catalog for Critiq. It ships `catalog.yaml`, preset membership, and rule YAML files for high-signal checks across TypeScript, JavaScript, Node.js, Go, Java, Python, PHP, Ruby and Rust.
26
29
 
27
- ```ts
28
- async function load() {
29
- fetch('/users');
30
- }
30
+ Use it with [`@critiq/cli`](https://www.npmjs.com/package/@critiq/cli):
31
31
 
32
- async function callApi() {
33
- return fetch('/users');
34
- }
32
+ ```bash
33
+ npm install -D @critiq/cli @critiq/rules
34
+ npx critiq check .
35
35
  ```
36
36
 
37
- ```ts
38
- function read(req: { body: any }) {
39
- const payload = req.body;
40
- return payload.user.profile.city;
41
- }
37
+ Run against a diff:
42
38
 
43
- function maybe(flag: boolean) {
44
- const user = flag ? { name: 'Ada' } : null;
45
- return user.name;
46
- }
39
+ ```bash
40
+ npx critiq check . --base origin/main --head HEAD
47
41
  ```
48
42
 
49
- ```ts
50
- function lookup(cacheMap: Map<string, string>, key: string) {
51
- return cacheMap.get(key);
52
- }
43
+ ## GitHub Actions
53
44
 
54
- function parseIdentity(req: { headers: Record<string, string | undefined> }) {
55
- const token = req.headers.authorization;
56
- return decode(token ?? '');
57
- }
58
- ```
45
+ For pull request workflows that run `critiq check` in CI and want to post **inline review comments** on the pr, use the Github Action **[critiq-dev/critiq-action](https://github.com/critiq-dev/critiq-action)** ([README](https://github.com/critiq-dev/critiq-action/blob/main/README.md)). It installs `@critiq/cli` (and `@critiq/rules` when needed), respects `.critiq/config.yaml`, and does not require Critiq Cloud or a separate account.
46
+
47
+ Example `.github/workflows/critiq.yml`:
48
+
49
+ ```yaml
50
+ name: Critiq Review
59
51
 
60
- ```ts
61
- const query = `SELECT * FROM users WHERE email = '${email}'`;
62
- element.innerHTML = req.body.html;
63
- document.write(userMarkup);
64
- execFile(req.query.command, []);
65
- JSON.parse(req.body.payload);
52
+ on:
53
+ pull_request:
54
+
55
+ permissions:
56
+ contents: read
57
+ pull-requests: write
58
+
59
+ jobs:
60
+ critiq:
61
+ runs-on: ubuntu-latest
62
+ steps:
63
+ - name: Checkout
64
+ uses: actions/checkout@v6
65
+ with:
66
+ fetch-depth: 0
67
+
68
+ - name: Run Critiq
69
+ uses: critiq-dev/critiq-action@v1
70
+ with:
71
+ fail-on-severity: off
66
72
  ```
67
73
 
68
- ## Rule Register
74
+ Use a **major tag** (`@v1`) or pin a **commit SHA** for supply-chain control. More options (inputs, outputs, monorepos, reusable workflow) are in the [action README](https://github.com/critiq-dev/critiq-action/blob/main/README.md).
75
+
76
+ ## Catalog At A Glance
77
+
78
+ Today the catalog includes `309` rules across `17` categories, with `recommended`, `strict`, `security`, and `experimental` presets.
79
+
80
+ | Category | Rules | What it looks after |
81
+ | --- | ---: | --- |
82
+ | Security | 93 | Injection, auth and session gaps, unsafe transport, sensitive data exposure, dependency policy, unsafe file and HTML handling |
83
+ | Python | 9 | Django, DRF, Flask, and FastAPI deployment and framework safety |
84
+ | Correctness | 18 | Async bugs, null access, control-flow mistakes, missing fallbacks, race conditions |
85
+ | Performance | 10 | Repeated IO, wasted async sequencing, hot-path loops, large retained objects, render churn |
86
+ | Quality | 10 | Error handling gaps, oversized functions, coupling, duplicated logic, and weak test coverage |
87
+ | Logging | 2 | Console usage and unsafe logging patterns |
88
+ | Config | 1 | Configuration access boundaries |
89
+ | Next | 1 | Server and client boundary leaks |
90
+ | Random | 1 | Unsafe randomness in core logic |
91
+ | React | 1 | Cascaded effect fetch patterns |
92
+ | Runtime | 1 | Debug-only statements left in shipped code |
93
+
94
+ ## High-Value Rules In This Catalog
95
+
96
+ | Rule title | Description |
97
+ | --- | --- |
98
+ | `Hardcoded API keys or credentials` | Source files should not embed credential-like string literals. |
99
+ | `Avoid raw or interpolated SQL` | Database query sinks must not receive request-driven or dynamically interpolated SQL text. |
100
+ | `Path traversal via user input` | File access calls must not use request-controlled paths directly. |
101
+ | `Protect deserialization trust boundaries` | Deserializers should not consume untrusted payloads directly across a trust boundary. |
102
+ | `Server-side request forgery` | Outbound requests should not use attacker-controlled targets or private hosts. |
103
+ | `Open redirect via request-controlled target` | Redirect and navigation sinks should not use request-controlled destinations without validation. |
104
+ | `Missing authorization before sensitive action` | Sensitive backend actions should be guarded by an authorization or permission check. |
105
+ | `Use authenticated encryption for secrets and tokens` | Session, cookie, and token encryption should provide integrity protection in the same helper. |
106
+ | `Missing await on async call` | Async functions should not drop direct async calls without awaiting them. |
107
+ | `Repeated IO call inside loop` | Database or network calls inside loops can multiply latency and load. |
108
+ | `Logic change without corresponding test updates` | Diffs that change critical logic should usually update the matching tests in the same change. |
109
+ | `Avoid server/client boundary leaks in Next.js` | Server components should not use browser-only APIs or client-only hooks without an explicit client boundary. |
110
+
111
+ ## Rule Methodology
112
+
113
+ Critiq keeps the OSS catalog intentionally high-signal.
114
+
115
+ - We add rules that change code review outcomes: security flaws, correctness bugs, performance regressions, and maintainability issues with real operational cost.
116
+ - We prefer rules that are deterministic, explainable, and backed by fixtures instead of vague heuristics.
117
+ - We avoid generic style rules that compilers and standard linters already handle well.
118
+ - Every rule should produce an actionable finding with evidence, not restate general guidance.
69
119
 
70
- Each entry lists the shipped rule id, its preset membership, and the main
71
- pattern it checks.
120
+ ## More Rules In This Catalog
72
121
 
73
- ### Logging And Runtime
122
+ The catalog also includes these `165` additional rules beyond the highlights above.
74
123
 
75
- - `ts.logging.no-console-log` (`recommended`, `strict`): direct `console.log(...)` calls.
76
- - `ts.logging.no-console-error` (`recommended`, `strict`): direct `console.error(...)` calls.
77
- - `ts.runtime.no-debugger-statement` (`recommended`, `strict`): `debugger;` statements in committed code.
124
+ ### Security
125
+
126
+ | Rule title | Description |
127
+ | --- | --- |
128
+ | `Eval or dynamic code execution` | Eval-like helpers, `vm` execution APIs, and string-evaluated timers should not execute dynamic code. |
129
+ | `Command execution using untrusted input` | Process execution helpers must not receive request-controlled executables or shell-interpreted arguments. |
130
+ | `Avoid unsafe DOM HTML insertion sinks` | `outerHTML`, `document.write*`, and `insertAdjacentHTML` should only receive fixed or explicitly sanitized HTML. |
131
+ | `` Avoid unsafe `dangerouslySetInnerHTML` `` | React `dangerouslySetInnerHTML` should only render fixed or explicitly sanitized HTML. |
132
+ | `` Avoid unsafe `innerHTML` assignment `` | `innerHTML` assignments should only use fixed or explicitly sanitized HTML. |
133
+ | `Missing ownership validation` | Resource identifiers from request input should be checked against the caller before sensitive actions run. |
134
+ | `Authorization enforced only on frontend` | Backend routes should enforce authorization directly instead of relying on frontend gating alone. |
135
+ | `Token or session not validated` | Session and token values from external input should be verified before authentication or identity use. |
136
+ | `Harden auth-bearing cookies` | Auth and session cookies should set HttpOnly, Secure, and SameSite. |
137
+ | `Remove sensitive claims from JWT payloads` | JWT payloads should avoid embedding PII or secrets unless absolutely required. |
138
+ | `Avoid browser token storage` | Access and session tokens should not be stored in long-lived browser storage. |
139
+ | `TLS verification disabled` | Transport clients should not disable certificate verification. |
140
+ | `Insecure HTTP transport` | Outbound transport should not use plain HTTP for sensitive requests. |
141
+ | `Require modern TLS minimum versions` | Transport clients should not explicitly allow SSLv3, TLS 1.0, or TLS 1.1. |
142
+ | `Sensitive data egress to third-party processors` | Sensitive values should not be sent to external processors or outbound SDKs without minimization or redaction. |
143
+ | `Avoid sensitive data in logs and telemetry` | Sensitive fields should not be sent to logging, tracing, or analytics sinks. |
144
+ | `Avoid binding to all interfaces` | Network-facing services should not explicitly bind to every interface unless public exposure is intentional and protected. |
145
+ | `Avoid weak hash algorithms` | Cryptographic hashing should use modern, collision-resistant algorithms. |
146
+ | `Avoid weak cipher algorithms and modes` | Cryptographic ciphers should use modern authenticated modes and approved algorithms. |
147
+ | `Avoid predictable token generation` | Tokens, reset links, and session secrets should be generated from cryptographically strong randomness. |
148
+ | `Use enough entropy for secrets and tokens` | Secret-bearing tokens and secrets should use at least 16 bytes of cryptographic entropy. |
149
+ | `Avoid weak key-generation strength` | Key-generation helpers should use current minimum strengths for RSA, AES, and HMAC keys. |
150
+ | `Validate untrusted input before parser construction` | Untrusted input should be validated before it is used to construct sensitive parsers or runtime objects. |
151
+ | `Missing request timeout or retry protection` | External calls should define timeout, cancellation, or retry behavior before they enter security-sensitive flows. |
152
+ | `Review Datadog RUM user interaction capture` | Datadog Browser RUM should not enable broad user interaction capture without a privacy review. |
153
+ | `Avoid request-driven DynamoDB queries` | DynamoDB query and scan inputs should not be built directly from request input. |
154
+ | `Avoid hardcoded auth secrets` | JWT, session, and strategy secrets should not be embedded directly in source code. |
155
+ | `Constrain module-loading trust boundaries` | `require()` and dynamic `import()` should not resolve modules from untrusted input. |
156
+ | `Do not reflect request origin into CORS policy` | `Access-Control-Allow-Origin` should not be set from request-controlled input. |
157
+ | `Do not allow every origin in CORS policy` | CORS should not fall back to wildcard or implicit allow-all origin settings. |
158
+ | `` Set `Secure` on Express session cookies `` | Express session and cookie-session configs should not disable the `Secure` flag. |
159
+ | `` Set `HttpOnly` on Express session cookies `` | Express session and cookie-session configs should not disable the `HttpOnly` flag. |
160
+ | `Avoid legacy Argon2 password hash modes` | Password hashing should not use `argon2i` or `argon2d` when safer modern modes are available. |
161
+ | `Use secure WebSocket transport` | WebSocket clients should not connect over cleartext `ws://` when sensitive application data is involved. |
162
+ | `Add a JWT revocation hook` | Express JWT middleware should check revocation state when bearer tokens can be invalidated early. |
163
+ | `Keep Handlebars escaping enabled at template trust boundaries` | Server-side Handlebars compilation should not disable HTML escaping with `noEscape: true`. |
164
+ | `Avoid ad hoc HTML sanitization` | Hand-rolled HTML escaping and sanitization should be replaced with vetted sanitizers or safe rendering paths. |
165
+ | `` Verify `message` event origins `` | `message` handlers should validate `event.origin` before trusting cross-window data. |
166
+ | `Avoid request-driven model queries` | Express handlers should not pass raw request objects into NoSQL filters, query helpers, or aggregation pipelines. |
167
+ | `Use constant-time secret comparison` | Secrets and tokens should not be compared with ordinary equality operators. |
168
+ | `Do not persist upload filenames directly` | Upload handlers should not store attacker-controlled filenames without generating or validating a safe local name. |
169
+ | `Constrain local file generation paths` | Local file writes should not derive their destination path from request or upload input. |
170
+ | `Avoid attacker-controlled filesystem read paths` | Direct filesystem read APIs should not consume request- or upload-controlled filenames. |
171
+ | `Avoid permissive file modes` | Files that can carry user or security data should not be created with world-accessible modes. |
172
+ | `` Avoid wildcard `postMessage` targets `` | `postMessage` calls should not use `*` as the target origin when they carry application data. |
173
+ | `Avoid raw HTML with request input` | Request-derived values should not be interpolated into raw HTML strings. |
174
+ | `Avoid sensitive data in thrown errors` | Exceptions and rejection payloads should not include raw secrets or personal data. |
175
+ | `Avoid writing sensitive data to files` | Data exports and local file writes should not persist raw secrets or personal fields. |
176
+ | `Avoid leaking sensitive or diagnostic state` | Logs, stdout or stderr, and direct response sinks should not expose sensitive fields or internal diagnostic detail. |
177
+ | `Do not derive anti-framing headers from request input` | Framing and CSP headers should not be set from request-controlled values. |
178
+ | `Avoid request-controlled format strings` | Logging and formatting helpers should not take request input as the format string itself. |
179
+ | `Sanitize user-controlled values before they reach log messages` | Logger calls in pino, winston, bunyan, and consola should not interpolate or concatenate request input directly into the message text. |
180
+ | `Remove leftover console.trace calls from production paths` | `console.trace()` calls should not ship in production code outside an explicit dev-only branch. |
181
+ | `` Constrain `res.sendFile` to a trusted root `` | `res.sendFile()` should not resolve filenames or options from request input without a trusted root. |
182
+ | `` Constrain `res.render()` trust boundaries `` | Express view names should not cross into server-side rendering from untrusted input. |
183
+ | `Avoid exposed directory listings` | Directory listing middleware should not be enabled on public paths without a deliberate review. |
184
+ | `Override Express session defaults` | Express session middleware should not rely on default session naming and configuration. |
185
+ | `Override Express cookie defaults` | Express session cookie settings should not omit explicit lifetime, scope, and transport attributes. |
186
+ | `Avoid permissive Express session cookie scope` | Express session cookies should not explicitly opt into cross-site or wildcard-style scope. |
187
+ | `Serve static assets before session middleware` | Static assets should be mounted before session middleware when they do not need session state. |
188
+ | `Limit Express request parser body size` | Express and body-parser middleware should set explicit parser limits, including upload middleware caps. |
189
+ | `Constrain Fastify body limits` | Fastify bootstrap and route-level body limits should not be disabled or set unusually high without compensating controls. |
190
+ | `Protect Fastify public bind posture` | Fastify public binds should pair with trust-proxy or gateway controls before exposing upstream network metadata. |
191
+ | `Harden Apollo GraphQL CSRF posture` | Apollo server configs should not disable CSRF protection in public bootstraps. |
192
+ | `Constrain Apollo introspection exposure` | Apollo production bootstraps should not unconditionally enable introspection. |
193
+ | `Require GraphQL query limiting controls` | Public GraphQL servers should define depth, complexity, persisted operation, or equivalent query limiting controls. |
194
+ | `Avoid Apollo dev tooling exposure in production` | Apollo dev landing pages and playground plugins should not ship without explicit production guards. |
195
+ | `Avoid GraphQL upload middleware without CSRF guard` | GraphQL multipart upload middleware should not run when CSRF prevention is explicitly disabled. |
196
+ | `Apply Helmet before NestJS route mounts` | NestJS apps should register helmet before route middleware mounts. |
197
+ | `Enable NestJS global validation pipe` | NestJS bootstraps should configure a global ValidationPipe to harden DTO trust boundaries. |
198
+ | `Whitelist NestJS ValidationPipe payload fields` | ValidationPipe should enable whitelist-style filtering for request payload hardening. |
199
+ | `Avoid SkipThrottle on sensitive NestJS auth routes` | Sensitive NestJS auth routes should not bypass throttle controls without compensating protection. |
200
+ | `Apply Helmet to Express apps` | Express apps should use Helmet or equivalent header hardening middleware. |
201
+ | `Reduce Express fingerprinting` | Express apps should disable `x-powered-by` or equivalent fingerprinting headers. |
202
+ | `Do not expose debug routes or middleware in production` | Debug handlers, stack-showing middleware, and diagnostic endpoints should stay behind explicit development-only guards. |
203
+ | `Avoid unsafe raw HTTP response output` | Raw response writers should not echo request data into HTML-capable responses without trusted escaping or sanitization. |
78
204
 
79
205
  ### Correctness
80
206
 
81
- - `ts.correctness.constant-condition` (`recommended`, `strict`): flow-control tests that resolve to a constant boolean.
82
- - `ts.correctness.missing-await-on-async-call` (`recommended`, `strict`): direct async work dropped inside async functions without `await`.
83
- - `ts.correctness.implicit-undefined-return` (`recommended`, `strict`): functions that return a value on some paths but fall through on others.
84
- - `ts.correctness.unhandled-async-error` (`recommended`, `strict`, `security`): promise chains without a terminal rejection handler.
85
- - `ts.correctness.incorrect-boolean-logic` (`recommended`, `strict`): same-discriminant comparison chains using the wrong boolean operator.
86
- - `ts.correctness.blocking-call-in-async-flow` (`recommended`, `strict`): blocking synchronous APIs inside async code paths.
87
- - `ts.correctness.missing-default-dispatch` (`recommended`, `strict`): `switch` or `if` dispatch chains without a default or final `else`.
88
- - `ts.correctness.missing-timeout-on-external-call` (`recommended`, `strict`, `security`): `fetch` or axios-style calls without timeout or cancellation configuration.
89
- - `ts.correctness.possible-null-dereference` (`recommended`, `strict`): nullable local aliases dereferenced or invoked without a guard.
90
- - `ts.correctness.nested-property-access-without-check` (`recommended`, `strict`): deep request-derived property chains without existence checks.
91
- - `ts.correctness.unchecked-map-key-access` (`recommended`, `strict`): dictionary-like `Map#get(...)` or keyed-object reads without a presence check.
92
- - `ts.correctness.optional-value-without-fallback` (`recommended`, `strict`): optional aliases used directly in expressions without `??`, `||`, or a guard.
93
- - `ts.correctness.off-by-one-loop-boundary` (`recommended`, `strict`): index-based loops that skip the first element or iterate past `.length`.
94
- - `ts.correctness.shared-state-race` (`experimental`): shared or outer-scope state mutated after an `await` boundary.
95
- - `ts.correctness.unreachable-statement` (`recommended`, `strict`): statements after `return` or `throw`.
96
-
97
- ### Quality, Config, And Determinism
98
-
99
- - `ts.quality.swallowed-error` (`recommended`, `strict`): `catch` blocks that drop errors silently.
100
- - `ts.quality.function-too-large-or-complex` (`strict`): oversized or high-complexity functions.
101
- - `ts.quality.duplicate-code-block` (`strict`): large near-identical function bodies duplicated across files.
102
- - `ts.quality.deep-nesting` (`strict`): deeply nested control flow.
103
- - `ts.quality.missing-error-context` (`strict`): `catch` paths that log or rethrow without preserving the original error.
104
- - `ts.quality.tight-module-coupling` (`strict`): direct local import cycles between modules.
105
- - `ts.quality.hardcoded-configuration-values` (`recommended`, `strict`): top-level config-like identifiers or properties bound to literals.
106
- - `ts.quality.magic-numbers-or-strings` (`strict`): non-trivial literals embedded directly in logic.
107
- - `ts.quality.missing-tests-for-critical-logic` (`strict`): critical auth or payment-like logic without a matching test file.
108
- - `ts.quality.logic-change-without-test-updates` (`strict`): changed critical logic in a diff without a changed matching test file.
109
- - `ts.config.no-process-env-outside-config` (`strict`): `process.env.*` access outside config modules.
110
- - `ts.random.no-math-random-in-core` (`strict`): `Math.random()` under `**/core/**`.
207
+ | Rule title | Description |
208
+ | --- | --- |
209
+ | `Always-true or always-false condition` | Flow-control conditions should not resolve to a constant boolean value. |
210
+ | `Implicit undefined return in function` | Functions that return a value on some paths must not fall through implicitly. |
211
+ | `Unhandled promise rejection or async error` | Promise chains started in a function should terminate with explicit rejection handling. |
212
+ | `Incorrect boolean logic (AND/OR misuse)` | Comparison chains on the same value must use the boolean operator that matches the intended logic. |
213
+ | `Blocking call inside async flow` | Async functions should not call synchronous blocking APIs on the hot path. |
214
+ | `Missing default case in switch or conditional dispatch` | Dispatch constructs should include an explicit default or final else path. |
215
+ | `Missing timeout on external call` | External HTTP calls should declare timeout or cancellation behavior. |
216
+ | `Possible null or undefined dereference` | Nullable values should be guarded before property access or invocation. |
217
+ | `Nested property access without existence check` | Deep property chains derived from external input should verify intermediate values before access. |
218
+ | `Unchecked map or dictionary key access` | Lookups should verify key presence before reading from maps or keyed objects. |
219
+ | `Optional value used without fallback` | Optional values should be normalized before arithmetic, concatenation, or other direct use. |
220
+ | `Off-by-one error in loop boundaries` | Index-based loops should not skip the first element or iterate one step past the collection boundary. |
221
+ | `Race condition on shared state` | Async functions that mutate shared state after an await boundary should be reviewed for races. |
222
+ | `Unreachable code after return or throw` | Statements after terminal exits should be removed or moved before the exit. |
111
223
 
112
224
  ### Performance
113
225
 
114
- - `ts.performance.sequential-async-calls` (`recommended`, `strict`): independent awaited calls serialized in one block.
115
- - `ts.performance.repeated-io-in-loop` (`recommended`, `strict`): direct or one-hop local IO helpers invoked inside loops.
116
- - `ts.performance.repeated-expensive-computation` (`recommended`, `strict`): the same expensive computation repeated in a local block.
117
- - `ts.performance.inefficient-data-structure-usage` (`recommended`, `strict`): linear membership scans or key-projection checks where a better lookup structure fits.
118
- - `ts.performance.nested-loops-hot-path` (`strict`): loop nesting that creates quadratic hot paths.
119
- - `ts.performance.missing-batch-operations` (`strict`): looped one-by-one helper calls when a batch or bulk variant is available locally.
120
- - `ts.performance.large-payload-without-streaming` (`strict`): likely large file or response payloads loaded eagerly instead of streamed.
121
- - `ts.performance.unbounded-growth-memory-leak` (`strict`): shared collections that only grow and never evict.
122
- - `ts.performance.retained-large-object` (`experimental`): large payloads assigned into shared state and retained longer than needed.
123
- - `ts.performance.unnecessary-rerenders-from-state-misuse` (`experimental`): React state setters called directly during render.
226
+ | Rule title | Description |
227
+ | --- | --- |
228
+ | `Sequential async calls that could run in parallel` | Independent awaited calls in the same block should not serialize unnecessarily. |
229
+ | `Repeated expensive computation` | Repeating the same expensive computation in one block should usually be cached. |
230
+ | `Inefficient data structure usage` | Linear membership checks or key projections should be reviewed for more suitable lookup structures. |
231
+ | `Nested loops in hot path (O(n²) risk)` | Nested loops in the same function should be reviewed for quadratic work on larger inputs. |
232
+ | `Missing batching of operations` | Repeated one-by-one operations inside loops should prefer available batch-style helpers. |
233
+ | `Large payload processing without streaming` | Whole-payload reads of likely large content should be reviewed for streaming alternatives. |
234
+ | `Potential memory leak from unbounded growth` | Shared collections that only grow should be reviewed for eviction or lifecycle boundaries. |
235
+ | `Unnecessarily retained large object` | Large payloads assigned into shared state should be reviewed for shorter lifetimes. |
236
+ | `Unnecessary re-renders from state misuse` | React state setters invoked directly during render should be reviewed for rerender loops. |
124
237
 
125
- ### Security
238
+ ### Quality
239
+
240
+ | Rule title | Description |
241
+ | --- | --- |
242
+ | `Errors swallowed silently` | Catch blocks must log, reject, or rethrow failures instead of dropping them silently. |
243
+ | `Function too large or too complex` | Oversized or overly complex functions should be split into smaller units. |
244
+ | `Duplicate code block` | Large duplicated function bodies across files make behavior harder to maintain safely. |
245
+ | `Deep nesting reducing readability` | Deeply nested control flow should be flattened where practical. |
246
+ | `Missing error context or logging` | Catch blocks should include the caught error when they log or rethrow. |
247
+ | `Tight coupling between modules` | Direct import cycles between modules increase coupling and make change boundaries harder to maintain. |
248
+ | `Hardcoded configuration values` | Config-like values should usually come from configuration sources rather than source literals. |
249
+ | `Magic numbers or magic strings` | Non-trivial literals in logic should be named to explain their meaning. |
250
+ | `Missing tests for critical logic` | Critical auth, payment, or similar business logic should have a matching test file. |
251
+
252
+ ### Logging
253
+
254
+ | Rule title | Description |
255
+ | --- | --- |
256
+ | `Avoid console.log` | Use the project logger instead of console.log. |
257
+ | `Avoid console.error` | Route error logs through the project logger. |
258
+
259
+ ### Config
260
+
261
+ | Rule title | Description |
262
+ | --- | --- |
263
+ | `` Avoid direct `process.env` access outside config `` | Keep environment variable access inside config modules. |
264
+
265
+ ### Random
266
+
267
+ | Rule title | Description |
268
+ | --- | --- |
269
+ | `` Avoid `Math.random()` in core code `` | Core code should not depend on nondeterministic random generation. |
270
+
271
+ ### React
272
+
273
+ | Rule title | Description |
274
+ | --- | --- |
275
+ | `Avoid cascaded fetches inside React effects` | React effects should not serialize independent fetches that can run in parallel or move server-side. |
276
+
277
+ ### Runtime
278
+
279
+ | Rule title | Description |
280
+ | --- | --- |
281
+ | `` Remove `debugger;` `` | Remove debugger statements before committing source files. |
282
+
283
+ ## License
126
284
 
127
- - `security.no-sql-interpolation` (`recommended`, `strict`, `security`): raw or interpolated SQL text passed into query sinks.
128
- - `ts.security.no-dynamic-execution` (`recommended`, `strict`, `security`): `eval`, `Function`, `vm`, or string-evaluated timer execution.
129
- - `security.no-request-path-file-read` (`recommended`, `strict`, `security`): file reads using request-controlled paths.
130
- - `ts.security.non-literal-fs-filename` (`recommended`, `strict`, `security`): direct filesystem reads using request- or upload-controlled filenames.
131
- - `ts.security.file-generation` (`recommended`, `strict`, `security`): local file writes whose destination path is derived from external input.
132
- - `ts.security.external-file-upload` (`recommended`, `strict`, `security`): upload handlers that persist attacker-controlled filenames directly.
133
- - `security.no-command-execution-with-request-input` (`recommended`, `strict`, `security`): process execution helpers given request-controlled executables or shell-interpreted arguments.
134
- - `ts.security.dangerous-insert-html` (`recommended`, `strict`, `security`): unsafe `outerHTML`, `document.write*`, or `insertAdjacentHTML` use with non-literal, non-sanitized HTML.
135
- - `ts.security.dangerously-set-inner-html` (`recommended`, `strict`, `security`): React `dangerouslySetInnerHTML` given non-literal, non-sanitized HTML.
136
- - `ts.security.no-innerhtml-assignment` (`recommended`, `strict`, `security`): `innerHTML` assignment without fixed or explicitly sanitized HTML.
137
- - `security.no-hardcoded-credentials` (`recommended`, `strict`, `security`): credential-like literals embedded in source.
138
- - `ts.security.handlebars-no-escape` (`recommended`, `strict`, `security`): `Handlebars.compile(..., { noEscape: true })`.
139
- - `ts.security.missing-authorization-before-sensitive-action` (`strict`, `security`): backend-like sensitive handlers without a local authorization guard.
140
- - `ts.security.missing-ownership-validation` (`strict`, `security`): auth-gated handlers acting on caller-supplied resource ids without an ownership check.
141
- - `ts.security.frontend-only-authorization` (`experimental`): frontend-auth-gated literal route calls whose matching backend route lacks authorization.
142
- - `ts.security.token-or-session-not-validated` (`recommended`, `strict`, `security`): token or session values from external input used without same-function validation.
143
- - `security.tls-verification-disabled` (`recommended`, `strict`, `security`): transport clients configured to skip certificate verification.
144
- - `security.insecure-http-transport` (`recommended`, `strict`, `security`): outbound requests sent over plain HTTP to non-local endpoints.
145
- - `security.weak-hash-algorithm` (`recommended`, `strict`, `security`): MD5, SHA-1, or similar weak hashing primitives used in security-sensitive flows.
146
- - `ts.security.weak-cipher-or-mode` (`recommended`, `strict`, `security`): weak or obsolete cipher selections such as ECB mode, DES-family ciphers, RC4, Blowfish, or RSA no-padding.
147
- - `ts.security.predictable-token-generation` (`recommended`, `strict`, `security`): auth-like tokens, invite codes, or reset helpers derived from `Math.random`, timestamps, or other predictable sources.
148
- - `ts.security.insufficiently-random-values` (`recommended`, `strict`, `security`): secret-like values generated from cryptographic APIs with less than 16 bytes of entropy.
149
- - `ts.security.weak-key-strength` (`recommended`, `strict`, `security`): explicit RSA, AES, or HMAC key-generation settings below modern minimum sizes.
150
- - `ts.security.missing-integrity-check` (`recommended`, `strict`, `security`): token or secret encryption helpers using non-AEAD modes or predictable IVs without same-function integrity protection.
151
- - `ts.security.insecure-password-hash-configuration` (`recommended`, `strict`, `security`): legacy or obsolete password-hash configuration such as insecure Argon2 mode selections.
152
- - `ts.security.unvalidated-external-input` (`strict`, `security`): request-derived values used to construct `RegExp` or `URL` without validation.
153
- - `security.unsafe-deserialization` (`recommended`, `strict`, `security`): `JSON.parse`, `yaml.load`, `qs.parse`, or similar deserializers fed external input.
154
- - `ts.security.missing-request-timeout-or-retry` (`strict`, `security`): external calls with neither timeout or cancellation nor retry protection.
155
- - `ts.security.unsanitized-http-response` (`recommended`, `strict`, `security`): raw `res.send`, `res.write`, or `res.end` output of request-derived HTML without trusted escaping or sanitization.
156
- - `ts.security.permissive-file-permissions` (`recommended`, `strict`, `security`): world-accessible file or directory modes on creation helpers or `chmod`.
157
- - `ts.security.user-controlled-sendfile` (`recommended`, `strict`, `security`): `res.sendFile()` paths or options driven by external input without a trusted root.
158
- - `ts.security.exposed-directory-listing` (`recommended`, `strict`, `security`): explicit directory-listing middleware such as `serveIndex`.
159
-
160
- ## Notes
161
-
162
- - `recommended` is the baseline OSS preset.
163
- - `strict` adds higher-noise or more opinionated rules.
164
- - `security` is the security-focused slice of the catalog.
165
- - `experimental` holds narrower heuristics that are shipped but not enabled by
166
- default.
167
-
168
- For executable examples, see the sandbox scenarios under
169
- [`critiq-sandbox/scenarios`](</Users/aavanzyl/Documents/personal/critiq/critiq-sandbox/scenarios>).
285
+ `@critiq/rules` is licensed under [Apache 2.0](https://www.apache.org/licenses/LICENSE-2.0). See the package [LICENSE](https://github.com/critiq-dev/critiq-rules/blob/main/libs/rules/catalog/LICENSE).