@neralabs/rerail-pack-python 0.1.1

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 (147) hide show
  1. package/LICENSE +202 -0
  2. package/NOTICE +7 -0
  3. package/README.md +36 -0
  4. package/licenses/bandit/LICENSE +175 -0
  5. package/licenses/bandit/UPSTREAM.md +100 -0
  6. package/licenses/ruff/LICENSE +430 -0
  7. package/licenses/ruff/UPSTREAM.md +338 -0
  8. package/pack.json +912 -0
  9. package/package.json +30 -0
  10. package/rules/bandit-b101-assert-used.json +38 -0
  11. package/rules/bandit-b102-exec-used.json +125 -0
  12. package/rules/bandit-b110-try-except-pass.json +109 -0
  13. package/rules/bandit-b112-try-except-continue.json +109 -0
  14. package/rules/bandit-b113-request-without-timeout.json +138 -0
  15. package/rules/bandit-b301-pickle.json +58 -0
  16. package/rules/bandit-b302-marshal.json +48 -0
  17. package/rules/bandit-b303-md5.json +79 -0
  18. package/rules/bandit-b305-cipher-modes.json +47 -0
  19. package/rules/bandit-b306-mktemp-q.json +54 -0
  20. package/rules/bandit-b307-eval.json +125 -0
  21. package/rules/bandit-b308-mark-safe.json +47 -0
  22. package/rules/bandit-b310-urllib-urlopen.json +54 -0
  23. package/rules/bandit-b311-random.json +57 -0
  24. package/rules/bandit-b312-telnetlib.json +47 -0
  25. package/rules/bandit-b313-xml-bad-celementtree.json +50 -0
  26. package/rules/bandit-b314-xml-bad-elementtree.json +50 -0
  27. package/rules/bandit-b315-xml-bad-expatreader.json +47 -0
  28. package/rules/bandit-b316-xml-bad-expatbuilder.json +48 -0
  29. package/rules/bandit-b317-xml-bad-sax.json +58 -0
  30. package/rules/bandit-b318-xml-bad-minidom.json +48 -0
  31. package/rules/bandit-b319-xml-bad-pulldom.json +48 -0
  32. package/rules/bandit-b321-ftplib.json +47 -0
  33. package/rules/bandit-b323-unverified-context.json +47 -0
  34. package/rules/bandit-b401-import-telnetlib.json +48 -0
  35. package/rules/bandit-b402-import-ftplib.json +48 -0
  36. package/rules/bandit-b405-import-xml-etree.json +69 -0
  37. package/rules/bandit-b406-import-xml-sax.json +73 -0
  38. package/rules/bandit-b407-import-xml-expat.json +54 -0
  39. package/rules/bandit-b408-import-xml-minidom.json +54 -0
  40. package/rules/bandit-b409-import-xml-pulldom.json +54 -0
  41. package/rules/bandit-b411-import-xmlrpclib.json +48 -0
  42. package/rules/bandit-b413-import-pycrypto.json +159 -0
  43. package/rules/bandit-b415-import-pyghmi.json +48 -0
  44. package/rules/bandit-b502-ssl-with-bad-version.json +90 -0
  45. package/rules/bandit-b505-weak-cryptographic-key.json +166 -0
  46. package/rules/bandit-b507-ssh-no-host-key-verification.json +210 -0
  47. package/rules/bandit-b606-start-process-with-no-shell.json +63 -0
  48. package/rules/bandit-b610-django-extra-used.json +268 -0
  49. package/rules/bandit-b615-huggingface-unsafe-download.json +1152 -0
  50. package/rules/ruff-async100-cancel-scope-no-checkpoint.json +357 -0
  51. package/rules/ruff-async105-trio-sync-call.json +199 -0
  52. package/rules/ruff-async115-async-zero-sleep.json +264 -0
  53. package/rules/ruff-async116-long-sleep-not-forever.json +267 -0
  54. package/rules/ruff-async210-blocking-http-call-in-async-function.json +161 -0
  55. package/rules/ruff-async221-run-process-in-async-function.json +342 -0
  56. package/rules/ruff-async222-wait-for-process-in-async-function.json +144 -0
  57. package/rules/ruff-async230-blocking-open-call-in-async-function.json +339 -0
  58. package/rules/ruff-async250-blocking-input-in-async-function.json +143 -0
  59. package/rules/ruff-async251-blocking-sleep-in-async-function.json +140 -0
  60. package/rules/ruff-b002-unary-prefix-increment-decrement.json +54 -0
  61. package/rules/ruff-b003-assignment-to-os-environ.json +54 -0
  62. package/rules/ruff-b004-unreliable-callable-check.json +171 -0
  63. package/rules/ruff-b005-strip-with-multi-characters.json +131 -0
  64. package/rules/ruff-b007-unused-loop-control-variable.json +368 -0
  65. package/rules/ruff-b009-get-attr-with-constant.json +190 -0
  66. package/rules/ruff-b010-set-attr-with-constant.json +219 -0
  67. package/rules/ruff-b011-assert-false.json +62 -0
  68. package/rules/ruff-b013-redundant-tuple-in-exception-handler.json +94 -0
  69. package/rules/ruff-b014-duplicate-handler-exception.json +126 -0
  70. package/rules/ruff-b016-raise-literal.json +47 -0
  71. package/rules/ruff-b020-loop-variable-overrides-iterator.json +341 -0
  72. package/rules/ruff-b021-f-string-docstring.json +48 -0
  73. package/rules/ruff-b022-useless-contextlib-suppress.json +95 -0
  74. package/rules/ruff-b023-function-uses-loop-variable.json +560 -0
  75. package/rules/ruff-b025-duplicate-try-block-exception.json +182 -0
  76. package/rules/ruff-b026-star-arg-unpacking-after-keyword-arg.json +57 -0
  77. package/rules/ruff-b028-no-explicit-stacklevel.json +177 -0
  78. package/rules/ruff-b029-except-with-empty-tuple.json +102 -0
  79. package/rules/ruff-b032-unintentional-type-annotation.json +157 -0
  80. package/rules/ruff-b033-duplicate-value.json +129 -0
  81. package/rules/ruff-b034-re-sub-positional-args.json +159 -0
  82. package/rules/ruff-b039-mutable-contextvar-default.json +281 -0
  83. package/rules/ruff-b904-raise-without-from-inside-except.json +194 -0
  84. package/rules/ruff-b905-zip-without-explicit-strict.json +429 -0
  85. package/rules/ruff-e711-none-comparison.json +199 -0
  86. package/rules/ruff-e721-type-comparison.json +293 -0
  87. package/rules/ruff-e722-bare-except.json +57 -0
  88. package/rules/ruff-e742-ambiguous-class-name.json +47 -0
  89. package/rules/ruff-e743-ambiguous-function-name.json +47 -0
  90. package/rules/ruff-f403-undefined-local-with-import-star.json +73 -0
  91. package/rules/ruff-f405-undefined-local-with-import-star-usage.json +87 -0
  92. package/rules/ruff-f406-undefined-local-with-nested-import-star-usage.json +39 -0
  93. package/rules/ruff-f407-future-feature-not-defined.json +56 -0
  94. package/rules/ruff-f501-percent-format-invalid-format.json +88 -0
  95. package/rules/ruff-f502-percent-format-expected-mapping.json +127 -0
  96. package/rules/ruff-f503-percent-format-expected-sequence.json +127 -0
  97. package/rules/ruff-f504-percent-format-extra-named-arguments.json +46 -0
  98. package/rules/ruff-f505-percent-format-missing-argument.json +49 -0
  99. package/rules/ruff-f506-percent-format-mixed-positional-and-named.json +114 -0
  100. package/rules/ruff-f507-percent-format-positional-count-mismatch.json +78 -0
  101. package/rules/ruff-f508-percent-format-star-requires-sequence.json +112 -0
  102. package/rules/ruff-f509-percent-format-unsupported-format-character.json +86 -0
  103. package/rules/ruff-f521-string-dot-format-invalid-format.json +83 -0
  104. package/rules/ruff-f522-string-dot-format-extra-named-arguments.json +46 -0
  105. package/rules/ruff-f523-string-dot-format-extra-positional-arguments.json +48 -0
  106. package/rules/ruff-f524-string-dot-format-missing-arguments.json +46 -0
  107. package/rules/ruff-f525-string-dot-format-mixing-automatic.json +99 -0
  108. package/rules/ruff-f541-f-string-missing-placeholders.json +52 -0
  109. package/rules/ruff-f601-multi-value-repeated-key-literal.json +215 -0
  110. package/rules/ruff-f602-multi-value-repeated-key-variable.json +123 -0
  111. package/rules/ruff-f622-multiple-starred-expressions.json +57 -0
  112. package/rules/ruff-f632-is-literal.json +232 -0
  113. package/rules/ruff-f633-invalid-print-syntax.json +299 -0
  114. package/rules/ruff-f701-break-outside-loop.json +64 -0
  115. package/rules/ruff-f702-continue-outside-loop.json +64 -0
  116. package/rules/ruff-f706-return-outside-function.json +61 -0
  117. package/rules/ruff-f707-default-except-not-last.json +50 -0
  118. package/rules/ruff-f722-forward-annotation-syntax-error.json +654 -0
  119. package/rules/ruff-f822-undefined-export.json +55 -0
  120. package/rules/ruff-f823-undefined-local.json +42 -0
  121. package/rules/ruff-f842-unused-annotation.json +51 -0
  122. package/rules/ruff-f901-raise-not-implemented.json +97 -0
  123. package/rules/ruff-pie794-duplicate-class-field-definition.json +157 -0
  124. package/rules/ruff-pie796-non-unique-enums.json +460 -0
  125. package/rules/ruff-pie800-unnecessary-spread.json +62 -0
  126. package/rules/ruff-pie804-unnecessary-dict-kwargs.json +179 -0
  127. package/rules/ruff-pie807-reimplemented-container-builtin.json +100 -0
  128. package/rules/ruff-pie810-multiple-starts-ends-with.json +585 -0
  129. package/rules/ruff-ret501-unnecessary-return-none.json +256 -0
  130. package/rules/ruff-ret502-implicit-return-value.json +163 -0
  131. package/rules/ruff-ret505-superfluous-else-return.json +211 -0
  132. package/rules/ruff-ret506-superfluous-else-raise.json +211 -0
  133. package/rules/ruff-ret507-superfluous-else-continue.json +211 -0
  134. package/rules/ruff-ret508-superfluous-else-break.json +211 -0
  135. package/rules/ruff-sim101-duplicate-isinstance-call.json +384 -0
  136. package/rules/ruff-sim107-return-in-try-except-finally.json +82 -0
  137. package/rules/ruff-sim109-compare-with-tuple.json +205 -0
  138. package/rules/ruff-sim112-uncapitalized-environment-variables.json +168 -0
  139. package/rules/ruff-sim113-enumerate-for-loop.json +562 -0
  140. package/rules/ruff-sim208-double-negation.json +58 -0
  141. package/rules/ruff-sim210-if-expr-with-true-false.json +90 -0
  142. package/rules/ruff-sim211-if-expr-with-false-true.json +90 -0
  143. package/rules/ruff-sim212-if-expr-with-twisted-arms.json +95 -0
  144. package/rules/ruff-sim300-yoda-conditions.json +487 -0
  145. package/rules/ruff-sim905-split-static-string.json +579 -0
  146. package/rules/ruff-sim910-dict-get-with-none-default.json +518 -0
  147. package/rules/ruff-t100-debugger.json +197 -0
@@ -0,0 +1,264 @@
1
+ {
2
+ "format": "rerail.policy/v1",
3
+ "id": "ruff-async115-async-zero-sleep",
4
+ "revision": 1,
5
+ "mode": "steer",
6
+ "description": "Port of Ruff's ASYNC115 (async-zero-sleep): a call to `trio.sleep` or `anyio.sleep` with exactly one argument, an int literal whose value is zero (any radix; parentheses allowed) as `seconds=` (trio), `delay=` (anyio) or the first positional argument, in any context, reported on the call. Names resolve as in Ruff's resolve_qualified_name, through the engine's `resolves` (M7).",
7
+ "scope": {
8
+ "include": [
9
+ "**/*"
10
+ ],
11
+ "exclude": []
12
+ },
13
+ "clauses": [
14
+ {
15
+ "id": "shared",
16
+ "define": {
17
+ "language": "python",
18
+ "utils": {
19
+ "number": {
20
+ "any": [
21
+ {
22
+ "any": [
23
+ {
24
+ "kind": "integer"
25
+ },
26
+ {
27
+ "kind": "float"
28
+ }
29
+ ],
30
+ "value": {
31
+ "type": "int",
32
+ "eq": 0
33
+ }
34
+ },
35
+ {
36
+ "kind": "parenthesized_expression",
37
+ "has": {
38
+ "stopBy": "neighbor",
39
+ "matches": "number"
40
+ }
41
+ }
42
+ ]
43
+ }
44
+ }
45
+ }
46
+ },
47
+ {
48
+ "id": "trio-sleep",
49
+ "forbid": {
50
+ "ast": {
51
+ "language": "python",
52
+ "utils": {
53
+ "target": {
54
+ "any": [
55
+ {
56
+ "kind": "identifier"
57
+ },
58
+ {
59
+ "kind": "attribute"
60
+ }
61
+ ],
62
+ "resolves": {
63
+ "import": [
64
+ "trio.sleep"
65
+ ]
66
+ }
67
+ },
68
+ "callee-of-target": {
69
+ "any": [
70
+ {
71
+ "matches": "target"
72
+ },
73
+ {
74
+ "kind": "parenthesized_expression",
75
+ "has": {
76
+ "stopBy": "neighbor",
77
+ "matches": "callee-of-target"
78
+ }
79
+ }
80
+ ]
81
+ }
82
+ },
83
+ "rule": {
84
+ "kind": "call",
85
+ "has": {
86
+ "stopBy": "neighbor",
87
+ "matches": "callee-of-target",
88
+ "precedes": {
89
+ "stopBy": "neighbor",
90
+ "any": [
91
+ {
92
+ "kind": "argument_list"
93
+ },
94
+ {
95
+ "kind": "generator_expression"
96
+ }
97
+ ]
98
+ }
99
+ },
100
+ "arguments": {
101
+ "signature": [
102
+ "seconds"
103
+ ],
104
+ "bind": {
105
+ "S": "seconds"
106
+ },
107
+ "mode": "syntactic"
108
+ },
109
+ "all": [
110
+ {
111
+ "has": {
112
+ "stopBy": "neighbor",
113
+ "kind": "argument_list",
114
+ "count": {
115
+ "has": {
116
+ "stopBy": "neighbor",
117
+ "not": {
118
+ "any": [
119
+ {
120
+ "regex": "^[(),\\[\\]{}]$"
121
+ },
122
+ {
123
+ "kind": "comment"
124
+ }
125
+ ]
126
+ }
127
+ },
128
+ "min": 1,
129
+ "max": 1
130
+ }
131
+ }
132
+ }
133
+ ]
134
+ },
135
+ "constraints": {
136
+ "S": {
137
+ "matches": "number"
138
+ }
139
+ }
140
+ }
141
+ },
142
+ "violation": {
143
+ "anchor": "witness.span",
144
+ "code": "ASYNC115",
145
+ "message": "Use `trio.lowlevel.checkpoint()` instead of `trio.sleep(0)`",
146
+ "suppress": {
147
+ "noqa": {
148
+ "codes": [
149
+ "ASYNC115"
150
+ ]
151
+ }
152
+ }
153
+ }
154
+ },
155
+ {
156
+ "id": "anyio-sleep",
157
+ "forbid": {
158
+ "ast": {
159
+ "language": "python",
160
+ "utils": {
161
+ "target": {
162
+ "any": [
163
+ {
164
+ "kind": "identifier"
165
+ },
166
+ {
167
+ "kind": "attribute"
168
+ }
169
+ ],
170
+ "resolves": {
171
+ "import": [
172
+ "anyio.sleep"
173
+ ]
174
+ }
175
+ },
176
+ "callee-of-target": {
177
+ "any": [
178
+ {
179
+ "matches": "target"
180
+ },
181
+ {
182
+ "kind": "parenthesized_expression",
183
+ "has": {
184
+ "stopBy": "neighbor",
185
+ "matches": "callee-of-target"
186
+ }
187
+ }
188
+ ]
189
+ }
190
+ },
191
+ "rule": {
192
+ "kind": "call",
193
+ "has": {
194
+ "stopBy": "neighbor",
195
+ "matches": "callee-of-target",
196
+ "precedes": {
197
+ "stopBy": "neighbor",
198
+ "any": [
199
+ {
200
+ "kind": "argument_list"
201
+ },
202
+ {
203
+ "kind": "generator_expression"
204
+ }
205
+ ]
206
+ }
207
+ },
208
+ "arguments": {
209
+ "signature": [
210
+ "delay"
211
+ ],
212
+ "bind": {
213
+ "S": "delay"
214
+ },
215
+ "mode": "syntactic"
216
+ },
217
+ "all": [
218
+ {
219
+ "has": {
220
+ "stopBy": "neighbor",
221
+ "kind": "argument_list",
222
+ "count": {
223
+ "has": {
224
+ "stopBy": "neighbor",
225
+ "not": {
226
+ "any": [
227
+ {
228
+ "regex": "^[(),\\[\\]{}]$"
229
+ },
230
+ {
231
+ "kind": "comment"
232
+ }
233
+ ]
234
+ }
235
+ },
236
+ "min": 1,
237
+ "max": 1
238
+ }
239
+ }
240
+ }
241
+ ]
242
+ },
243
+ "constraints": {
244
+ "S": {
245
+ "matches": "number"
246
+ }
247
+ }
248
+ }
249
+ },
250
+ "violation": {
251
+ "anchor": "witness.span",
252
+ "code": "ASYNC115",
253
+ "message": "Use `anyio.lowlevel.checkpoint()` instead of `anyio.sleep(0)`",
254
+ "suppress": {
255
+ "noqa": {
256
+ "codes": [
257
+ "ASYNC115"
258
+ ]
259
+ }
260
+ }
261
+ }
262
+ }
263
+ ]
264
+ }
@@ -0,0 +1,267 @@
1
+ {
2
+ "format": "rerail.policy/v1",
3
+ "id": "ruff-async116-long-sleep-not-forever",
4
+ "revision": 1,
5
+ "mode": "steer",
6
+ "description": "Port of Ruff's ASYNC116 (long-sleep-not-forever): a call to `trio.sleep` or `anyio.sleep` with exactly one argument, an int or float literal (any spelling; not complex, not signed; parentheses allowed) whose value is greater than 86400 as `seconds=` (trio), `delay=` (anyio) or the first positional argument, in any context, reported on the call. Names resolve as in Ruff's resolve_qualified_name, through the engine's `resolves` (M7).",
7
+ "scope": {
8
+ "include": [
9
+ "**/*"
10
+ ],
11
+ "exclude": []
12
+ },
13
+ "clauses": [
14
+ {
15
+ "id": "shared",
16
+ "define": {
17
+ "language": "python",
18
+ "utils": {
19
+ "number": {
20
+ "any": [
21
+ {
22
+ "any": [
23
+ {
24
+ "kind": "integer"
25
+ },
26
+ {
27
+ "kind": "float"
28
+ }
29
+ ],
30
+ "value": {
31
+ "type": [
32
+ "int",
33
+ "float"
34
+ ],
35
+ "gt": 86400
36
+ }
37
+ },
38
+ {
39
+ "kind": "parenthesized_expression",
40
+ "has": {
41
+ "stopBy": "neighbor",
42
+ "matches": "number"
43
+ }
44
+ }
45
+ ]
46
+ }
47
+ }
48
+ }
49
+ },
50
+ {
51
+ "id": "trio-sleep",
52
+ "forbid": {
53
+ "ast": {
54
+ "language": "python",
55
+ "utils": {
56
+ "target": {
57
+ "any": [
58
+ {
59
+ "kind": "identifier"
60
+ },
61
+ {
62
+ "kind": "attribute"
63
+ }
64
+ ],
65
+ "resolves": {
66
+ "import": [
67
+ "trio.sleep"
68
+ ]
69
+ }
70
+ },
71
+ "callee-of-target": {
72
+ "any": [
73
+ {
74
+ "matches": "target"
75
+ },
76
+ {
77
+ "kind": "parenthesized_expression",
78
+ "has": {
79
+ "stopBy": "neighbor",
80
+ "matches": "callee-of-target"
81
+ }
82
+ }
83
+ ]
84
+ }
85
+ },
86
+ "rule": {
87
+ "kind": "call",
88
+ "has": {
89
+ "stopBy": "neighbor",
90
+ "matches": "callee-of-target",
91
+ "precedes": {
92
+ "stopBy": "neighbor",
93
+ "any": [
94
+ {
95
+ "kind": "argument_list"
96
+ },
97
+ {
98
+ "kind": "generator_expression"
99
+ }
100
+ ]
101
+ }
102
+ },
103
+ "arguments": {
104
+ "signature": [
105
+ "seconds"
106
+ ],
107
+ "bind": {
108
+ "S": "seconds"
109
+ },
110
+ "mode": "syntactic"
111
+ },
112
+ "all": [
113
+ {
114
+ "has": {
115
+ "stopBy": "neighbor",
116
+ "kind": "argument_list",
117
+ "count": {
118
+ "has": {
119
+ "stopBy": "neighbor",
120
+ "not": {
121
+ "any": [
122
+ {
123
+ "regex": "^[(),\\[\\]{}]$"
124
+ },
125
+ {
126
+ "kind": "comment"
127
+ }
128
+ ]
129
+ }
130
+ },
131
+ "min": 1,
132
+ "max": 1
133
+ }
134
+ }
135
+ }
136
+ ]
137
+ },
138
+ "constraints": {
139
+ "S": {
140
+ "matches": "number"
141
+ }
142
+ }
143
+ }
144
+ },
145
+ "violation": {
146
+ "anchor": "witness.span",
147
+ "code": "ASYNC116",
148
+ "message": "`trio.sleep()` with >24 hour interval should usually be `trio.sleep_forever()`",
149
+ "suppress": {
150
+ "noqa": {
151
+ "codes": [
152
+ "ASYNC116"
153
+ ]
154
+ }
155
+ }
156
+ }
157
+ },
158
+ {
159
+ "id": "anyio-sleep",
160
+ "forbid": {
161
+ "ast": {
162
+ "language": "python",
163
+ "utils": {
164
+ "target": {
165
+ "any": [
166
+ {
167
+ "kind": "identifier"
168
+ },
169
+ {
170
+ "kind": "attribute"
171
+ }
172
+ ],
173
+ "resolves": {
174
+ "import": [
175
+ "anyio.sleep"
176
+ ]
177
+ }
178
+ },
179
+ "callee-of-target": {
180
+ "any": [
181
+ {
182
+ "matches": "target"
183
+ },
184
+ {
185
+ "kind": "parenthesized_expression",
186
+ "has": {
187
+ "stopBy": "neighbor",
188
+ "matches": "callee-of-target"
189
+ }
190
+ }
191
+ ]
192
+ }
193
+ },
194
+ "rule": {
195
+ "kind": "call",
196
+ "has": {
197
+ "stopBy": "neighbor",
198
+ "matches": "callee-of-target",
199
+ "precedes": {
200
+ "stopBy": "neighbor",
201
+ "any": [
202
+ {
203
+ "kind": "argument_list"
204
+ },
205
+ {
206
+ "kind": "generator_expression"
207
+ }
208
+ ]
209
+ }
210
+ },
211
+ "arguments": {
212
+ "signature": [
213
+ "delay"
214
+ ],
215
+ "bind": {
216
+ "S": "delay"
217
+ },
218
+ "mode": "syntactic"
219
+ },
220
+ "all": [
221
+ {
222
+ "has": {
223
+ "stopBy": "neighbor",
224
+ "kind": "argument_list",
225
+ "count": {
226
+ "has": {
227
+ "stopBy": "neighbor",
228
+ "not": {
229
+ "any": [
230
+ {
231
+ "regex": "^[(),\\[\\]{}]$"
232
+ },
233
+ {
234
+ "kind": "comment"
235
+ }
236
+ ]
237
+ }
238
+ },
239
+ "min": 1,
240
+ "max": 1
241
+ }
242
+ }
243
+ }
244
+ ]
245
+ },
246
+ "constraints": {
247
+ "S": {
248
+ "matches": "number"
249
+ }
250
+ }
251
+ }
252
+ },
253
+ "violation": {
254
+ "anchor": "witness.span",
255
+ "code": "ASYNC116",
256
+ "message": "`anyio.sleep()` with >24 hour interval should usually be `anyio.sleep_forever()`",
257
+ "suppress": {
258
+ "noqa": {
259
+ "codes": [
260
+ "ASYNC116"
261
+ ]
262
+ }
263
+ }
264
+ }
265
+ }
266
+ ]
267
+ }
@@ -0,0 +1,161 @@
1
+ {
2
+ "format": "rerail.policy/v1",
3
+ "id": "ruff-async210-blocking-http-call-in-async-function",
4
+ "revision": 1,
5
+ "mode": "steer",
6
+ "description": "Port of Ruff's ASYNC210 (blocking-http-call-in-async-function): a call to `urllib.request.urlopen`, `urllib3.request` or an `httpx`/`requests` module-level HTTP method inside an `async def` body whose function is the nearest enclosing function, lambda body or class, reported on the callee. Names resolve as in Ruff's resolve_qualified_name, through the engine's `resolves` (M7).",
7
+ "scope": {
8
+ "include": [
9
+ "**/*"
10
+ ],
11
+ "exclude": []
12
+ },
13
+ "clauses": [
14
+ {
15
+ "id": "blocking-http-call",
16
+ "forbid": {
17
+ "ast": {
18
+ "language": "python",
19
+ "utils": {
20
+ "scope-body": {
21
+ "kind": "block",
22
+ "inside": {
23
+ "stopBy": "neighbor",
24
+ "any": [
25
+ {
26
+ "kind": "function_definition"
27
+ },
28
+ {
29
+ "kind": "class_definition"
30
+ }
31
+ ]
32
+ }
33
+ },
34
+ "lambda-body": {
35
+ "inside": {
36
+ "stopBy": "neighbor",
37
+ "kind": "lambda"
38
+ },
39
+ "follows": {
40
+ "stopBy": "end",
41
+ "regex": "^:$"
42
+ }
43
+ },
44
+ "callee-position": {
45
+ "any": [
46
+ {
47
+ "inside": {
48
+ "stopBy": "neighbor",
49
+ "kind": "call"
50
+ },
51
+ "precedes": {
52
+ "stopBy": "neighbor",
53
+ "any": [
54
+ {
55
+ "kind": "argument_list"
56
+ },
57
+ {
58
+ "kind": "generator_expression"
59
+ }
60
+ ]
61
+ }
62
+ },
63
+ {
64
+ "inside": {
65
+ "stopBy": "neighbor",
66
+ "kind": "parenthesized_expression",
67
+ "matches": "callee-position"
68
+ }
69
+ }
70
+ ]
71
+ },
72
+ "async-context": {
73
+ "inside": {
74
+ "stopBy": {
75
+ "any": [
76
+ {
77
+ "matches": "scope-body"
78
+ },
79
+ {
80
+ "matches": "lambda-body"
81
+ }
82
+ ]
83
+ },
84
+ "kind": "block",
85
+ "inside": {
86
+ "stopBy": "neighbor",
87
+ "kind": "function_definition",
88
+ "has": {
89
+ "stopBy": "neighbor",
90
+ "regex": "^async$"
91
+ }
92
+ }
93
+ }
94
+ },
95
+ "target": {
96
+ "any": [
97
+ {
98
+ "kind": "identifier"
99
+ },
100
+ {
101
+ "kind": "attribute"
102
+ }
103
+ ],
104
+ "resolves": {
105
+ "import": [
106
+ "urllib.request.urlopen",
107
+ "urllib3.request",
108
+ "httpx.request",
109
+ "httpx.get",
110
+ "httpx.post",
111
+ "httpx.delete",
112
+ "httpx.patch",
113
+ "httpx.put",
114
+ "httpx.head",
115
+ "httpx.connect",
116
+ "httpx.options",
117
+ "httpx.trace",
118
+ "requests.request",
119
+ "requests.get",
120
+ "requests.post",
121
+ "requests.delete",
122
+ "requests.patch",
123
+ "requests.put",
124
+ "requests.head",
125
+ "requests.connect",
126
+ "requests.options",
127
+ "requests.trace"
128
+ ]
129
+ }
130
+ }
131
+ },
132
+ "rule": {
133
+ "all": [
134
+ {
135
+ "matches": "callee-position"
136
+ },
137
+ {
138
+ "matches": "async-context"
139
+ },
140
+ {
141
+ "matches": "target"
142
+ }
143
+ ]
144
+ }
145
+ }
146
+ },
147
+ "violation": {
148
+ "anchor": "witness.span",
149
+ "code": "ASYNC210",
150
+ "message": "Async functions should not call blocking HTTP methods",
151
+ "suppress": {
152
+ "noqa": {
153
+ "codes": [
154
+ "ASYNC210"
155
+ ]
156
+ }
157
+ }
158
+ }
159
+ }
160
+ ]
161
+ }