cfsolve 0.1.2 → 0.1.4

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 (395) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +22 -0
  3. data/README.md +8 -3
  4. data/THIRD_PARTY_LICENSES/README.md +71 -254
  5. data/THIRD_PARTY_LICENSES/{derive_builder_macro-0.20.2/LICENSE-APACHE → bytecount-0.6.9/LICENSE.Apache2} +0 -1
  6. data/THIRD_PARTY_LICENSES/{darling-0.20.11/LICENSE → bytecount-0.6.9/LICENSE.MIT} +1 -3
  7. data/THIRD_PARTY_LICENSES/{ident_case-1.0.1/LICENSE → cobs-0.3.0/LICENSE-MIT} +1 -1
  8. data/THIRD_PARTY_LICENSES/cow-utils-0.1.3/LICENSE +21 -0
  9. data/THIRD_PARTY_LICENSES/{hashbrown-0.14.5 → embedded-io-0.4.0}/LICENSE-MIT +1 -1
  10. data/THIRD_PARTY_LICENSES/{ahash-0.8.12 → embedded-io-0.6.1}/LICENSE-MIT +1 -1
  11. data/THIRD_PARTY_LICENSES/{browserslist-data-0.1.4 → escape-simd-0.1.1}/LICENSE +1 -1
  12. data/THIRD_PARTY_LICENSES/escape-simd-0.1.1/NOTICE +62 -0
  13. data/THIRD_PARTY_LICENSES/json-escape-simd-3.1.3/LICENSE +21 -0
  14. data/THIRD_PARTY_LICENSES/{miette-7.6.0/LICENSE → json-escape-simd-3.1.3/LICENSE-APACHE} +0 -1
  15. data/THIRD_PARTY_LICENSES/json-escape-simd-3.1.3/NOTICE +62 -0
  16. data/THIRD_PARTY_LICENSES/memchr-2.8.3/UNLICENSE +24 -0
  17. data/THIRD_PARTY_LICENSES/{derive_builder_core-0.20.2 → nonmax-0.5.5}/LICENSE-APACHE +1 -2
  18. data/THIRD_PARTY_LICENSES/{dashmap-5.5.3/LICENSE → nonmax-0.5.5/LICENSE-MIT} +2 -4
  19. data/THIRD_PARTY_LICENSES/{rand-0.8.5 → num-bigint-0.5.1}/LICENSE-MIT +0 -1
  20. data/THIRD_PARTY_LICENSES/oxc-0.157.0/LICENSE +22 -0
  21. data/THIRD_PARTY_LICENSES/oxc-0.157.0/THIRD-PARTY-LICENSE +763 -0
  22. data/THIRD_PARTY_LICENSES/{browserslist-rs-0.19.0 → oxc-browserslist-5.0.1}/LICENSE +1 -0
  23. data/THIRD_PARTY_LICENSES/oxc_allocator-0.157.0/LICENSE +22 -0
  24. data/THIRD_PARTY_LICENSES/oxc_allocator-0.157.0/THIRD-PARTY-LICENSE +763 -0
  25. data/THIRD_PARTY_LICENSES/oxc_ast-0.157.0/LICENSE +22 -0
  26. data/THIRD_PARTY_LICENSES/oxc_ast-0.157.0/THIRD-PARTY-LICENSE +763 -0
  27. data/THIRD_PARTY_LICENSES/oxc_ast_macros-0.157.0/LICENSE +22 -0
  28. data/THIRD_PARTY_LICENSES/oxc_ast_macros-0.157.0/THIRD-PARTY-LICENSE +763 -0
  29. data/THIRD_PARTY_LICENSES/oxc_ast_visit-0.157.0/LICENSE +22 -0
  30. data/THIRD_PARTY_LICENSES/oxc_ast_visit-0.157.0/THIRD-PARTY-LICENSE +763 -0
  31. data/THIRD_PARTY_LICENSES/oxc_codegen-0.157.0/LICENSE +22 -0
  32. data/THIRD_PARTY_LICENSES/oxc_codegen-0.157.0/THIRD-PARTY-LICENSE +763 -0
  33. data/THIRD_PARTY_LICENSES/oxc_compat-0.157.0/LICENSE +22 -0
  34. data/THIRD_PARTY_LICENSES/oxc_compat-0.157.0/THIRD-PARTY-LICENSE +763 -0
  35. data/THIRD_PARTY_LICENSES/oxc_data_structures-0.157.0/LICENSE +22 -0
  36. data/THIRD_PARTY_LICENSES/oxc_data_structures-0.157.0/THIRD-PARTY-LICENSE +763 -0
  37. data/THIRD_PARTY_LICENSES/oxc_diagnostics-0.157.0/LICENSE +22 -0
  38. data/THIRD_PARTY_LICENSES/oxc_diagnostics-0.157.0/THIRD-PARTY-LICENSE +763 -0
  39. data/THIRD_PARTY_LICENSES/oxc_ecmascript-0.157.0/LICENSE +22 -0
  40. data/THIRD_PARTY_LICENSES/oxc_ecmascript-0.157.0/THIRD-PARTY-LICENSE +763 -0
  41. data/THIRD_PARTY_LICENSES/oxc_estree-0.157.0/LICENSE +22 -0
  42. data/THIRD_PARTY_LICENSES/oxc_estree-0.157.0/THIRD-PARTY-LICENSE +763 -0
  43. data/THIRD_PARTY_LICENSES/oxc_index-5.0.0/LICENSE +22 -0
  44. data/THIRD_PARTY_LICENSES/oxc_parser-0.157.0/LICENSE +22 -0
  45. data/THIRD_PARTY_LICENSES/oxc_parser-0.157.0/THIRD-PARTY-LICENSE +763 -0
  46. data/THIRD_PARTY_LICENSES/oxc_regular_expression-0.157.0/LICENSE +22 -0
  47. data/THIRD_PARTY_LICENSES/oxc_regular_expression-0.157.0/THIRD-PARTY-LICENSE +763 -0
  48. data/THIRD_PARTY_LICENSES/oxc_semantic-0.157.0/LICENSE +22 -0
  49. data/THIRD_PARTY_LICENSES/oxc_semantic-0.157.0/THIRD-PARTY-LICENSE +763 -0
  50. data/THIRD_PARTY_LICENSES/oxc_span-0.157.0/LICENSE +22 -0
  51. data/THIRD_PARTY_LICENSES/oxc_span-0.157.0/THIRD-PARTY-LICENSE +763 -0
  52. data/THIRD_PARTY_LICENSES/oxc_str-0.157.0/LICENSE +22 -0
  53. data/THIRD_PARTY_LICENSES/oxc_str-0.157.0/THIRD-PARTY-LICENSE +763 -0
  54. data/THIRD_PARTY_LICENSES/oxc_syntax-0.157.0/LICENSE +22 -0
  55. data/THIRD_PARTY_LICENSES/oxc_syntax-0.157.0/THIRD-PARTY-LICENSE +763 -0
  56. data/THIRD_PARTY_LICENSES/{fixedbitset-0.5.7 → postcard-1.1.3}/LICENSE-MIT +1 -1
  57. data/THIRD_PARTY_LICENSES/{bytes-str-0.2.7/LICENSE → self_cell-1.3.0/LICENSE-APACHE} +1 -2
  58. data/THIRD_PARTY_LICENSES/self_cell-1.3.0/LICENSE-GPLv2 +339 -0
  59. data/THIRD_PARTY_LICENSES/{darling_core-0.20.11 → smawk-0.3.3}/LICENSE +1 -1
  60. data/UPSTREAM.md +14 -6
  61. data/ext/cfsolve/Cargo.lock +534 -1727
  62. data/ext/cfsolve/Cargo.toml +4 -0
  63. data/ext/cfsolve/src/main.rs +1 -1
  64. data/lib/cfsolve/profiles/chrome-157-macos/answers.json +4777 -0
  65. data/lib/cfsolve/profiles/chrome-157-macos.json +613 -0
  66. data/lib/cfsolve/profiles/safari-26-ios/answers.json +266 -265
  67. data/lib/cfsolve/profiles/safari-26-ios/challenge-page-answers.json +312 -312
  68. data/lib/cfsolve/profiles/safari-26-ios.json +106 -152
  69. data/lib/cfsolve/version.rb +2 -2
  70. data/lib/cfsolve.rb +1 -1
  71. data/vendor/cfsolve/Cargo.lock +561 -1729
  72. data/vendor/cfsolve/Cargo.toml +26 -8
  73. data/vendor/cfsolve/README.md +57 -5
  74. data/vendor/cfsolve/examples/check_answers.rs +2 -2
  75. data/vendor/cfsolve/examples/compare_session.rs +1 -2
  76. data/vendor/cfsolve/examples/solver_profile.rs +84 -0
  77. data/vendor/cfsolve/examples/solver_smoke.rs +9 -8
  78. data/vendor/cfsolve/examples/stage2_snapshot.rs +2 -2
  79. data/vendor/cfsolve/examples/tls_echo.rs +3 -3
  80. data/vendor/cfsolve/examples/turnstile_smoke.rs +58 -0
  81. data/vendor/cfsolve/examples/vm_snapshot.rs +32 -33
  82. data/vendor/cfsolve/profiles/chrome-157-macos/answers.json +4777 -0
  83. data/vendor/cfsolve/profiles/chrome-157-macos.json +613 -0
  84. data/vendor/cfsolve/profiles/safari-26-ios/answers.json +266 -265
  85. data/vendor/cfsolve/profiles/safari-26-ios/challenge-page-answers.json +312 -312
  86. data/vendor/cfsolve/profiles/safari-26-ios.json +106 -152
  87. data/vendor/cfsolve/src/bin/capture-proxy/main.rs +3 -2
  88. data/vendor/cfsolve/src/bin/challenge/cli.rs +8 -2
  89. data/vendor/cfsolve/src/bin/challenge/main.rs +7 -2
  90. data/vendor/cfsolve/src/capture/proxy/tests.rs +1 -1
  91. data/vendor/cfsolve/src/capture/proxy.rs +44 -13
  92. data/vendor/cfsolve/src/capture/sessions.rs +4 -3
  93. data/vendor/cfsolve/src/capture/upstream.rs +1 -1
  94. data/vendor/cfsolve/src/challenge/codec.rs +4 -2
  95. data/vendor/cfsolve/src/challenge/expression.rs +161 -117
  96. data/vendor/cfsolve/src/challenge/installed/audit.rs +11 -10
  97. data/vendor/cfsolve/src/challenge/installed.rs +13 -6
  98. data/vendor/cfsolve/src/challenge/merge.rs +120 -80
  99. data/vendor/cfsolve/src/challenge/orchestrator.rs +57 -44
  100. data/vendor/cfsolve/src/challenge/payload.rs +69 -31
  101. data/vendor/cfsolve/src/challenge/program.rs +197 -178
  102. data/vendor/cfsolve/src/challenge/reduced_timing.rs +55 -40
  103. data/vendor/cfsolve/src/challenge/source.rs +151 -96
  104. data/vendor/cfsolve/src/challenge/state.rs +180 -148
  105. data/vendor/cfsolve/src/challenge/tally.rs +64 -50
  106. data/vendor/cfsolve/src/challenge.rs +1 -0
  107. data/vendor/cfsolve/src/deobfuscate/analysis/bindings.rs +187 -185
  108. data/vendor/cfsolve/src/deobfuscate/analysis/effects.rs +42 -51
  109. data/vendor/cfsolve/src/deobfuscate/analysis/hoisting.rs +147 -228
  110. data/vendor/cfsolve/src/deobfuscate/analysis/properties.rs +250 -425
  111. data/vendor/cfsolve/src/deobfuscate/analysis/unconditional.rs +79 -0
  112. data/vendor/cfsolve/src/deobfuscate/analysis.rs +259 -41
  113. data/vendor/cfsolve/src/deobfuscate/argument_arrays.rs +70 -73
  114. data/vendor/cfsolve/src/deobfuscate/arrow_blocks.rs +91 -104
  115. data/vendor/cfsolve/src/deobfuscate/ast.rs +383 -0
  116. data/vendor/cfsolve/src/deobfuscate/bitwise.rs +44 -54
  117. data/vendor/cfsolve/src/deobfuscate/blocks.rs +36 -29
  118. data/vendor/cfsolve/src/deobfuscate/call_helpers.rs +80 -131
  119. data/vendor/cfsolve/src/deobfuscate/control_flow.rs +239 -297
  120. data/vendor/cfsolve/src/deobfuscate/copy_propagation.rs +114 -135
  121. data/vendor/cfsolve/src/deobfuscate/dead_branches.rs +62 -61
  122. data/vendor/cfsolve/src/deobfuscate/dead_properties.rs +197 -214
  123. data/vendor/cfsolve/src/deobfuscate/dispatch.rs +238 -298
  124. data/vendor/cfsolve/src/deobfuscate/encoded_strings.rs +198 -203
  125. data/vendor/cfsolve/src/deobfuscate/function_lengths.rs +32 -38
  126. data/vendor/cfsolve/src/deobfuscate/helper_objects.rs +338 -513
  127. data/vendor/cfsolve/src/deobfuscate/hygiene.rs +197 -0
  128. data/vendor/cfsolve/src/deobfuscate/int32_helpers.rs +121 -155
  129. data/vendor/cfsolve/src/deobfuscate/literals.rs +116 -67
  130. data/vendor/cfsolve/src/deobfuscate/loops.rs +43 -43
  131. data/vendor/cfsolve/src/deobfuscate/memoized_strings.rs +127 -131
  132. data/vendor/cfsolve/src/deobfuscate/merged_functions.rs +262 -220
  133. data/vendor/cfsolve/src/deobfuscate/pipeline.rs +199 -244
  134. data/vendor/cfsolve/src/deobfuscate/register_arrays.rs +353 -327
  135. data/vendor/cfsolve/src/deobfuscate/removal.rs +83 -52
  136. data/vendor/cfsolve/src/deobfuscate/simplify.rs +147 -0
  137. data/vendor/cfsolve/src/deobfuscate/state_machines.rs +88 -110
  138. data/vendor/cfsolve/src/deobfuscate/statements.rs +228 -228
  139. data/vendor/cfsolve/src/deobfuscate/static_members.rs +46 -31
  140. data/vendor/cfsolve/src/deobfuscate/testing.rs +49 -59
  141. data/vendor/cfsolve/src/deobfuscate/unused_bindings.rs +92 -102
  142. data/vendor/cfsolve/src/deobfuscate.rs +15 -11
  143. data/vendor/cfsolve/src/embedding_page/extra_params.rs +132 -24
  144. data/vendor/cfsolve/src/embedding_page/page.rs +41 -1
  145. data/vendor/cfsolve/src/embedding_page/render_sample.rs +184 -147
  146. data/vendor/cfsolve/src/error.rs +40 -5
  147. data/vendor/cfsolve/src/fingerprint.rs +8 -2
  148. data/vendor/cfsolve/src/http/client.rs +7 -10
  149. data/vendor/cfsolve/src/http/requests.rs +2 -2
  150. data/vendor/cfsolve/src/js/ast.rs +479 -263
  151. data/vendor/cfsolve/src/lib.rs +1 -0
  152. data/vendor/cfsolve/src/listing/fold.rs +19 -9
  153. data/vendor/cfsolve/src/listing/query.rs +1 -47
  154. data/vendor/cfsolve/src/performance_clock.rs +20 -1
  155. data/vendor/cfsolve/src/profiling.rs +49 -0
  156. data/vendor/cfsolve/src/script.rs +35 -24
  157. data/vendor/cfsolve/src/session/challenge_page.rs +41 -21
  158. data/vendor/cfsolve/src/session/channel.rs +2 -2
  159. data/vendor/cfsolve/src/session/initial.rs +12 -11
  160. data/vendor/cfsolve/src/session/probes.rs +1 -0
  161. data/vendor/cfsolve/src/session/sink.rs +26 -1
  162. data/vendor/cfsolve/src/session/tests/challenge_page.rs +36 -1
  163. data/vendor/cfsolve/src/session.rs +1 -1
  164. data/vendor/cfsolve/src/solver.rs +3 -1
  165. data/vendor/cfsolve/src/stage2/analysis/analyze.rs +33 -4
  166. data/vendor/cfsolve/src/stage2/analysis/audit.rs +4 -2
  167. data/vendor/cfsolve/src/stage2/analysis/discovery.rs +13 -2
  168. data/vendor/cfsolve/src/stage2/analysis/envelope.rs +2 -1
  169. data/vendor/cfsolve/src/stage2/audit_globals.rs +142 -74
  170. data/vendor/cfsolve/src/stage2/benchmark.rs +113 -41
  171. data/vendor/cfsolve/src/stage2/call_stack.rs +1564 -1041
  172. data/vendor/cfsolve/src/stage2/challenge_page.rs +3 -2
  173. data/vendor/cfsolve/src/stage2/fixtures/encoded_benchmark_worker.js +1 -0
  174. data/vendor/cfsolve/src/stage2/interaction/checkbox.rs +202 -150
  175. data/vendor/cfsolve/src/stage2/interaction/click.rs +2 -2
  176. data/vendor/cfsolve/src/stage2/interaction/plan.rs +5 -4
  177. data/vendor/cfsolve/src/stage2/payload/recover.rs +2 -2
  178. data/vendor/cfsolve/src/stage2/probes/clock.rs +1 -3
  179. data/vendor/cfsolve/src/stage2/probes/dates.rs +44 -0
  180. data/vendor/cfsolve/src/stage2/probes/parent_info_array.rs +326 -0
  181. data/vendor/cfsolve/src/stage2/probes/performance.rs +12 -8
  182. data/vendor/cfsolve/src/stage2/probes/stack.rs +117 -4
  183. data/vendor/cfsolve/src/stage2/probes/websocket_echo.rs +80 -2
  184. data/vendor/cfsolve/src/stage2/probes.rs +1 -0
  185. data/vendor/cfsolve/src/stage2/queries.rs +50 -0
  186. data/vendor/cfsolve/src/stage2/reference.rs +5 -0
  187. data/vendor/cfsolve/src/stage2/registry.rs +8 -2
  188. data/vendor/cfsolve/src/stage2/replay.rs +34 -3
  189. data/vendor/cfsolve/src/stage2/stylesheets.rs +35 -0
  190. data/vendor/cfsolve/src/stage2/syntax.rs +88 -0
  191. data/vendor/cfsolve/src/stage2/trace.rs +134 -108
  192. data/vendor/cfsolve/src/stage2/value_labels.rs +185 -0
  193. data/vendor/cfsolve/src/stage2/vocabulary.rs +112 -17
  194. data/vendor/cfsolve/src/stage2.rs +3 -0
  195. data/vendor/cfsolve/src/vm/disassemble.rs +75 -7
  196. data/vendor/cfsolve/src/vm/dispatch.rs +93 -65
  197. data/vendor/cfsolve/src/vm/encoded_names.rs +635 -0
  198. data/vendor/cfsolve/src/vm/extract.rs +550 -250
  199. data/vendor/cfsolve/src/vm/fixtures/free_functions/README.md +9 -0
  200. data/vendor/cfsolve/src/vm/fixtures/free_functions/machine.js +7438 -0
  201. data/vendor/cfsolve/src/vm/fixtures/free_functions/program.base64 +1 -0
  202. data/vendor/cfsolve/src/vm/interpret/access.rs +71 -50
  203. data/vendor/cfsolve/src/vm/interpret/builtin.rs +10 -10
  204. data/vendor/cfsolve/src/vm/interpret/call.rs +116 -52
  205. data/vendor/cfsolve/src/vm/interpret/compile.rs +79 -62
  206. data/vendor/cfsolve/src/vm/interpret/copies.rs +2 -2
  207. data/vendor/cfsolve/src/vm/interpret/evaluate/tests.rs +63 -42
  208. data/vendor/cfsolve/src/vm/interpret/evaluate.rs +65 -575
  209. data/vendor/cfsolve/src/vm/interpret/explore.rs +7 -10
  210. data/vendor/cfsolve/src/vm/interpret/formula.rs +131 -0
  211. data/vendor/cfsolve/src/vm/interpret/frozen.rs +3 -5
  212. data/vendor/cfsolve/src/vm/interpret/intrinsic.rs +160 -58
  213. data/vendor/cfsolve/src/vm/interpret/mix32.rs +189 -0
  214. data/vendor/cfsolve/src/vm/interpret/native_dispatch.rs +220 -0
  215. data/vendor/cfsolve/src/vm/interpret/pattern.rs +1765 -0
  216. data/vendor/cfsolve/src/vm/interpret/plan.rs +586 -338
  217. data/vendor/cfsolve/src/vm/interpret/register_helpers.rs +392 -0
  218. data/vendor/cfsolve/src/vm/interpret/run.rs +120 -45
  219. data/vendor/cfsolve/src/vm/interpret/semantics.rs +71 -46
  220. data/vendor/cfsolve/src/vm/interpret/setup.rs +80 -45
  221. data/vendor/cfsolve/src/vm/interpret/string_decoder.rs +482 -0
  222. data/vendor/cfsolve/src/vm/interpret.rs +9 -1
  223. data/vendor/cfsolve/src/vm/machine.rs +116 -51
  224. data/vendor/cfsolve/src/vm/output.rs +19 -6
  225. data/vendor/cfsolve/src/vm/packed_names.rs +11 -7
  226. data/vendor/cfsolve/src/vm/registers.rs +35 -21
  227. data/vendor/cfsolve/src/vm/session.rs +189 -121
  228. data/vendor/cfsolve/src/vm/value.rs +22 -19
  229. data/vendor/cfsolve/src/vm.rs +3 -1
  230. data/vendor/cfsolve/vendor/btls-sys/Cargo.toml +3 -0
  231. data/vendor/cfsolve/vendor/btls-sys/build/main.rs +20 -0
  232. metadata +106 -178
  233. data/THIRD_PARTY_LICENSES/Inflector-0.11.4/LICENSE.md +0 -22
  234. data/THIRD_PARTY_LICENSES/arrayvec-0.7.6/LICENSE-MIT +0 -25
  235. data/THIRD_PARTY_LICENSES/ascii-1.1.0/LICENSE-APACHE +0 -201
  236. data/THIRD_PARTY_LICENSES/ascii-1.1.0/LICENSE-MIT +0 -22
  237. data/THIRD_PARTY_LICENSES/ast_node-5.0.0/LICENSE +0 -201
  238. data/THIRD_PARTY_LICENSES/better_scoped_tls-1.0.1/LICENSE +0 -201
  239. data/THIRD_PARTY_LICENSES/bitvec-1.0.1/LICENSE.txt +0 -21
  240. data/THIRD_PARTY_LICENSES/bstr-1.12.1/COPYING +0 -8
  241. data/THIRD_PARTY_LICENSES/bstr-1.12.1/LICENSE-MIT +0 -21
  242. data/THIRD_PARTY_LICENSES/cargo-platform-0.1.9/LICENSE-APACHE +0 -201
  243. data/THIRD_PARTY_LICENSES/cargo_metadata-0.19.2/LICENSE-MIT +0 -23
  244. data/THIRD_PARTY_LICENSES/darling_macro-0.20.11/LICENSE +0 -21
  245. data/THIRD_PARTY_LICENSES/debugid-0.8.0/LICENSE +0 -201
  246. data/THIRD_PARTY_LICENSES/derive_builder-0.20.2/LICENSE-MIT +0 -21
  247. data/THIRD_PARTY_LICENSES/derive_builder_core-0.20.2/LICENSE-MIT +0 -21
  248. data/THIRD_PARTY_LICENSES/derive_builder_macro-0.20.2/LICENSE-MIT +0 -21
  249. data/THIRD_PARTY_LICENSES/foldhash-0.1.5/LICENSE +0 -19
  250. data/THIRD_PARTY_LICENSES/from_variant-3.0.0/LICENSE +0 -201
  251. data/THIRD_PARTY_LICENSES/funty-2.0.0/LICENSE.txt +0 -21
  252. data/THIRD_PARTY_LICENSES/hashbrown-0.16.1/LICENSE-MIT +0 -25
  253. data/THIRD_PARTY_LICENSES/heck-0.5.0/LICENSE-APACHE +0 -201
  254. data/THIRD_PARTY_LICENSES/hermit-abi-0.5.2/LICENSE-APACHE +0 -201
  255. data/THIRD_PARTY_LICENSES/hermit-abi-0.5.2/LICENSE-MIT +0 -23
  256. data/THIRD_PARTY_LICENSES/hstr-3.0.3/LICENSE +0 -202
  257. data/THIRD_PARTY_LICENSES/if_chain-1.0.3/LICENSE-APACHE +0 -201
  258. data/THIRD_PARTY_LICENSES/if_chain-1.0.3/LICENSE-MIT +0 -25
  259. data/THIRD_PARTY_LICENSES/is-macro-0.3.7/LICENSE +0 -202
  260. data/THIRD_PARTY_LICENSES/itoa-1.0.17/LICENSE-MIT +0 -23
  261. data/THIRD_PARTY_LICENSES/jsonc-parser-0.26.3/LICENSE +0 -21
  262. data/THIRD_PARTY_LICENSES/lazy_static-1.5.0/LICENSE-APACHE +0 -201
  263. data/THIRD_PARTY_LICENSES/lazy_static-1.5.0/LICENSE-MIT +0 -25
  264. data/THIRD_PARTY_LICENSES/lru-0.16.2/LICENSE +0 -21
  265. data/THIRD_PARTY_LICENSES/memchr-2.7.6/COPYING +0 -3
  266. data/THIRD_PARTY_LICENSES/memchr-2.7.6/LICENSE-MIT +0 -21
  267. data/THIRD_PARTY_LICENSES/miette-derive-7.6.0/LICENSE +0 -229
  268. data/THIRD_PARTY_LICENSES/normpath-0.2.0/COPYRIGHT +0 -7
  269. data/THIRD_PARTY_LICENSES/normpath-0.2.0/LICENSE-MIT +0 -21
  270. data/THIRD_PARTY_LICENSES/normpath-0.2.0/LICENSE-THIRD-PARTY +0 -210
  271. data/THIRD_PARTY_LICENSES/num_cpus-1.17.0/LICENSE-APACHE +0 -201
  272. data/THIRD_PARTY_LICENSES/num_cpus-1.17.0/LICENSE-MIT +0 -20
  273. data/THIRD_PARTY_LICENSES/owo-colors-4.2.3/LICENSE +0 -21
  274. data/THIRD_PARTY_LICENSES/par-core-2.0.0/LICENSE +0 -202
  275. data/THIRD_PARTY_LICENSES/par-iter-2.0.0/LICENSE +0 -202
  276. data/THIRD_PARTY_LICENSES/path-clean-0.1.0/LICENSE-APACHE +0 -13
  277. data/THIRD_PARTY_LICENSES/path-clean-0.1.0/LICENSE-MIT +0 -18
  278. data/THIRD_PARTY_LICENSES/path-clean-1.0.1/LICENSE-APACHE +0 -13
  279. data/THIRD_PARTY_LICENSES/path-clean-1.0.1/LICENSE-MIT +0 -18
  280. data/THIRD_PARTY_LICENSES/pathdiff-0.2.3/LICENSE-APACHE +0 -201
  281. data/THIRD_PARTY_LICENSES/pathdiff-0.2.3/LICENSE-MIT +0 -23
  282. data/THIRD_PARTY_LICENSES/petgraph-0.7.1/LICENSE-APACHE +0 -201
  283. data/THIRD_PARTY_LICENSES/precomputed-map-0.2.0/LICENSE +0 -21
  284. data/THIRD_PARTY_LICENSES/preset_env_base-6.0.0/LICENSE +0 -201
  285. data/THIRD_PARTY_LICENSES/radium-0.7.0/LICENSE.txt +0 -21
  286. data/THIRD_PARTY_LICENSES/radix_fmt-1.0.0/LICENSE +0 -201
  287. data/THIRD_PARTY_LICENSES/rand-0.8.5/COPYRIGHT +0 -12
  288. data/THIRD_PARTY_LICENSES/rand-0.8.5/LICENSE-APACHE +0 -176
  289. data/THIRD_PARTY_LICENSES/rand_core-0.6.4/COPYRIGHT +0 -12
  290. data/THIRD_PARTY_LICENSES/rand_core-0.6.4/LICENSE-APACHE +0 -187
  291. data/THIRD_PARTY_LICENSES/rand_core-0.6.4/LICENSE-MIT +0 -26
  292. data/THIRD_PARTY_LICENSES/regress-0.10.5/LICENSE-APACHE +0 -201
  293. data/THIRD_PARTY_LICENSES/regress-0.10.5/LICENSE-MIT +0 -21
  294. data/THIRD_PARTY_LICENSES/ryu-1.0.22/LICENSE-APACHE +0 -176
  295. data/THIRD_PARTY_LICENSES/ryu-1.0.22/LICENSE-BOOST +0 -23
  296. data/THIRD_PARTY_LICENSES/scoped-tls-1.0.1/LICENSE-APACHE +0 -201
  297. data/THIRD_PARTY_LICENSES/scoped-tls-1.0.1/LICENSE-MIT +0 -25
  298. data/THIRD_PARTY_LICENSES/siphasher-0.3.11/COPYING +0 -7
  299. data/THIRD_PARTY_LICENSES/smallvec-1.15.1/LICENSE-APACHE +0 -201
  300. data/THIRD_PARTY_LICENSES/smartstring-1.0.1/LICENCE.md +0 -355
  301. data/THIRD_PARTY_LICENSES/st-map-0.2.4/LICENSE +0 -202
  302. data/THIRD_PARTY_LICENSES/static-map-macro-0.3.4/LICENSE +0 -202
  303. data/THIRD_PARTY_LICENSES/string_enum-1.0.2/LICENSE +0 -201
  304. data/THIRD_PARTY_LICENSES/strsim-0.11.1/LICENSE +0 -23
  305. data/THIRD_PARTY_LICENSES/swc-52.0.0/LICENSE +0 -201
  306. data/THIRD_PARTY_LICENSES/swc_allocator-4.0.1/LICENSE +0 -201
  307. data/THIRD_PARTY_LICENSES/swc_atoms-9.0.0/LICENSE +0 -201
  308. data/THIRD_PARTY_LICENSES/swc_common-18.0.1/LICENSE +0 -201
  309. data/THIRD_PARTY_LICENSES/swc_compiler_base-45.0.0/LICENSE +0 -201
  310. data/THIRD_PARTY_LICENSES/swc_config-3.1.2/LICENSE +0 -201
  311. data/THIRD_PARTY_LICENSES/swc_config_macro-1.0.1/LICENSE +0 -201
  312. data/THIRD_PARTY_LICENSES/swc_core-54.0.0/LICENSE +0 -201
  313. data/THIRD_PARTY_LICENSES/swc_ecma_ast-19.0.0/LICENSE +0 -201
  314. data/THIRD_PARTY_LICENSES/swc_ecma_codegen-21.0.0/LICENSE +0 -201
  315. data/THIRD_PARTY_LICENSES/swc_ecma_codegen_macros-2.0.2/LICENSE +0 -201
  316. data/THIRD_PARTY_LICENSES/swc_ecma_compat_bugfixes-39.0.0/LICENSE +0 -201
  317. data/THIRD_PARTY_LICENSES/swc_ecma_compat_common-30.0.0/LICENSE +0 -201
  318. data/THIRD_PARTY_LICENSES/swc_ecma_compat_es2015-39.0.0/LICENSE +0 -201
  319. data/THIRD_PARTY_LICENSES/swc_ecma_compat_es2016-35.0.0/LICENSE +0 -201
  320. data/THIRD_PARTY_LICENSES/swc_ecma_compat_es2017-35.0.0/LICENSE +0 -201
  321. data/THIRD_PARTY_LICENSES/swc_ecma_compat_es2018-36.0.0/LICENSE +0 -201
  322. data/THIRD_PARTY_LICENSES/swc_ecma_compat_es2019-35.0.0/LICENSE +0 -201
  323. data/THIRD_PARTY_LICENSES/swc_ecma_compat_es2020-37.0.0/LICENSE +0 -201
  324. data/THIRD_PARTY_LICENSES/swc_ecma_compat_es2021-35.0.0/LICENSE +0 -201
  325. data/THIRD_PARTY_LICENSES/swc_ecma_compat_es2022-37.0.0/LICENSE +0 -201
  326. data/THIRD_PARTY_LICENSES/swc_ecma_compat_es3-26.0.0/LICENSE +0 -201
  327. data/THIRD_PARTY_LICENSES/swc_ecma_ext_transforms-25.0.0/LICENSE +0 -201
  328. data/THIRD_PARTY_LICENSES/swc_ecma_hooks-0.3.0/LICENSE +0 -201
  329. data/THIRD_PARTY_LICENSES/swc_ecma_loader-18.0.0/LICENSE +0 -201
  330. data/THIRD_PARTY_LICENSES/swc_ecma_minifier-42.0.0/LICENSE +0 -201
  331. data/THIRD_PARTY_LICENSES/swc_ecma_parser-32.0.0/LICENSE +0 -201
  332. data/THIRD_PARTY_LICENSES/swc_ecma_preset_env-45.0.0/LICENSE +0 -201
  333. data/THIRD_PARTY_LICENSES/swc_ecma_transformer-6.0.0/LICENSE +0 -201
  334. data/THIRD_PARTY_LICENSES/swc_ecma_transforms-44.0.0/LICENSE +0 -201
  335. data/THIRD_PARTY_LICENSES/swc_ecma_transforms_base-35.0.0/LICENSE +0 -201
  336. data/THIRD_PARTY_LICENSES/swc_ecma_transforms_classes-35.0.0/LICENSE +0 -201
  337. data/THIRD_PARTY_LICENSES/swc_ecma_transforms_compat-40.0.0/LICENSE +0 -201
  338. data/THIRD_PARTY_LICENSES/swc_ecma_transforms_macros-1.0.1/LICENSE +0 -201
  339. data/THIRD_PARTY_LICENSES/swc_ecma_transforms_module-38.0.0/LICENSE +0 -201
  340. data/THIRD_PARTY_LICENSES/swc_ecma_transforms_optimization-37.0.0/LICENSE +0 -201
  341. data/THIRD_PARTY_LICENSES/swc_ecma_transforms_proposal-35.0.0/LICENSE +0 -201
  342. data/THIRD_PARTY_LICENSES/swc_ecma_transforms_react-38.0.0/LICENSE +0 -201
  343. data/THIRD_PARTY_LICENSES/swc_ecma_transforms_typescript-38.0.0/LICENSE +0 -201
  344. data/THIRD_PARTY_LICENSES/swc_ecma_usage_analyzer-27.0.0/LICENSE +0 -201
  345. data/THIRD_PARTY_LICENSES/swc_ecma_utils-25.0.0/LICENSE +0 -201
  346. data/THIRD_PARTY_LICENSES/swc_ecma_visit-19.0.0/LICENSE +0 -201
  347. data/THIRD_PARTY_LICENSES/swc_eq_ignore_macros-1.0.1/LICENSE +0 -201
  348. data/THIRD_PARTY_LICENSES/swc_error_reporters-20.0.0/LICENSE +0 -201
  349. data/THIRD_PARTY_LICENSES/swc_macros_common-1.0.1/LICENSE +0 -201
  350. data/THIRD_PARTY_LICENSES/swc_node_comments-18.0.0/LICENSE +0 -201
  351. data/THIRD_PARTY_LICENSES/swc_timer-1.0.0/LICENSE +0 -201
  352. data/THIRD_PARTY_LICENSES/swc_trace_macro-2.0.2/LICENSE +0 -201
  353. data/THIRD_PARTY_LICENSES/swc_transform_common-12.0.0/LICENSE +0 -201
  354. data/THIRD_PARTY_LICENSES/swc_visit-2.0.1/LICENSE +0 -201
  355. data/THIRD_PARTY_LICENSES/tap-1.0.1/LICENSE.txt +0 -21
  356. data/THIRD_PARTY_LICENSES/tracing-0.1.44/LICENSE +0 -25
  357. data/THIRD_PARTY_LICENSES/tracing-attributes-0.1.31/LICENSE +0 -25
  358. data/THIRD_PARTY_LICENSES/tracing-core-0.1.36/LICENSE +0 -25
  359. data/THIRD_PARTY_LICENSES/triomphe-0.1.15/LICENSE-APACHE +0 -201
  360. data/THIRD_PARTY_LICENSES/triomphe-0.1.15/LICENSE-MIT +0 -27
  361. data/THIRD_PARTY_LICENSES/unicode-width-0.1.14/LICENSE-APACHE +0 -201
  362. data/THIRD_PARTY_LICENSES/unicode-width-0.1.14/LICENSE-MIT +0 -25
  363. data/THIRD_PARTY_LICENSES/uuid-1.19.0/LICENSE-APACHE +0 -201
  364. data/THIRD_PARTY_LICENSES/uuid-1.19.0/LICENSE-MIT +0 -26
  365. data/THIRD_PARTY_LICENSES/vergen-9.0.6/LICENSE-APACHE +0 -201
  366. data/THIRD_PARTY_LICENSES/vergen-9.0.6/LICENSE-MIT +0 -25
  367. data/THIRD_PARTY_LICENSES/vergen-lib-0.1.6/LICENSE-APACHE +0 -201
  368. data/THIRD_PARTY_LICENSES/vergen-lib-0.1.6/LICENSE-MIT +0 -25
  369. data/THIRD_PARTY_LICENSES/wyz-0.5.1/LICENSE.txt +0 -21
  370. data/vendor/cfsolve/src/deobfuscate/analysis/globals.rs +0 -33
  371. data/vendor/cfsolve/src/deobfuscate/analysis/names.rs +0 -52
  372. /data/THIRD_PARTY_LICENSES/{derive_builder-0.20.2 → cobs-0.3.0}/LICENSE-APACHE +0 -0
  373. /data/THIRD_PARTY_LICENSES/{compact_str-0.7.1 → compact_str-0.10.0}/LICENSE +0 -0
  374. /data/THIRD_PARTY_LICENSES/{ahash-0.8.12 → embedded-io-0.4.0}/LICENSE-APACHE +0 -0
  375. /data/THIRD_PARTY_LICENSES/{arrayvec-0.7.6 → embedded-io-0.6.1}/LICENSE-APACHE +0 -0
  376. /data/THIRD_PARTY_LICENSES/{normpath-0.2.0 → escape-simd-0.1.1}/LICENSE-APACHE +0 -0
  377. /data/THIRD_PARTY_LICENSES/{bstr-1.12.1 → itertools-0.15.0}/LICENSE-APACHE +0 -0
  378. /data/THIRD_PARTY_LICENSES/{petgraph-0.7.1 → itertools-0.15.0}/LICENSE-MIT +0 -0
  379. /data/THIRD_PARTY_LICENSES/{itoa-1.0.17 → itoa-1.0.19}/LICENSE-APACHE +0 -0
  380. /data/THIRD_PARTY_LICENSES/{camino-1.2.2 → itoa-1.0.19}/LICENSE-MIT +0 -0
  381. /data/THIRD_PARTY_LICENSES/{globset-0.4.18 → memchr-2.8.3}/COPYING +0 -0
  382. /data/THIRD_PARTY_LICENSES/{globset-0.4.18 → memchr-2.8.3}/LICENSE-MIT +0 -0
  383. /data/THIRD_PARTY_LICENSES/{camino-1.2.2 → num-bigint-0.5.1}/LICENSE-APACHE +0 -0
  384. /data/THIRD_PARTY_LICENSES/{swc_sourcemap-9.3.4 → oxc_sourcemap-9.0.0}/LICENSE +0 -0
  385. /data/THIRD_PARTY_LICENSES/{phf-0.11.3 → phf-0.14.0}/LICENSE +0 -0
  386. /data/THIRD_PARTY_LICENSES/{phf_generator-0.11.3 → phf_generator-0.14.0}/LICENSE +0 -0
  387. /data/THIRD_PARTY_LICENSES/{phf_macros-0.11.3 → phf_macros-0.14.0}/LICENSE +0 -0
  388. /data/THIRD_PARTY_LICENSES/{phf_shared-0.11.3 → phf_shared-0.14.0}/LICENSE +0 -0
  389. /data/THIRD_PARTY_LICENSES/{fixedbitset-0.5.7 → postcard-1.1.3}/LICENSE-APACHE +0 -0
  390. /data/THIRD_PARTY_LICENSES/{hashbrown-0.14.5 → smallvec-1.16.5}/LICENSE-APACHE +0 -0
  391. /data/THIRD_PARTY_LICENSES/{smallvec-1.15.1 → smallvec-1.16.5}/LICENSE-MIT +0 -0
  392. /data/THIRD_PARTY_LICENSES/{unicode-width-0.1.14 → unicode-segmentation-1.13.3}/COPYRIGHT +0 -0
  393. /data/THIRD_PARTY_LICENSES/{hashbrown-0.16.1 → unicode-segmentation-1.13.3}/LICENSE-APACHE +0 -0
  394. /data/THIRD_PARTY_LICENSES/{heck-0.5.0 → unicode-segmentation-1.13.3}/LICENSE-MIT +0 -0
  395. /data/THIRD_PARTY_LICENSES/{cargo-platform-0.1.9 → zmij_ecma-1.0.23}/LICENSE-MIT +0 -0
@@ -1,531 +1,356 @@
1
1
  //! Tracks static property reads, calls, definitions, escapes, and dynamic accesses, so rewrites
2
- //! can decide whether properties retain their defined values.
2
+ //! can decide whether properties keep their defined values.
3
3
 
4
- use swc_core::atoms::Atom;
5
- use swc_core::ecma::ast::{
6
- AssignExpr, AssignOp, AssignTarget, BindingIdent, CallExpr, Callee, Expr, Id, Ident,
7
- MemberExpr, MemberProp, OptCall, OptChainBase, Pat, Program, Prop, PropName,
8
- SimpleAssignTarget, TaggedTpl, ThisExpr, UnaryExpr, UnaryOp, UpdateExpr, VarDeclarator,
4
+ use oxc::ast::ast::{
5
+ AssignmentExpression, AssignmentTarget, CallExpression, Expression, IdentifierReference,
6
+ MemberExpression, ObjectExpression, ObjectPropertyKind, Program, PropertyKind, ThisExpression,
7
+ UnaryExpression, UpdateExpression, VariableDeclarator,
9
8
  };
10
- use swc_core::ecma::visit::{Visit, VisitWith};
11
-
12
- use super::Bindings;
13
- use crate::deobfuscate::{HashMap, HashSet};
14
- use crate::js::ast;
15
-
16
- /// Tracks property uses by binding and by object. Merges uses through single-assignment copies
17
- /// such as `alias = object`; the copies themselves do not count as uses. See
18
- /// [`Bindings::root`].
19
- pub(crate) struct Properties {
20
- uses: HashMap<Id, Uses>,
21
- /// The uses of each root, merged over every binding with that root.
22
- objects: HashMap<Id, Uses>,
23
- /// See [`Bindings::roots`].
24
- roots: HashMap<Id, Id>,
25
- none: Uses,
26
- }
27
-
28
- /// Uses of a binding or of all aliases sharing an object.
29
- #[derive(Default, PartialEq)]
30
- pub(crate) struct Uses {
31
- /// Passed, returned, stored, coerced, or copied to a multiply assigned binding. Such uses
32
- /// expose the object to code this summary cannot track.
33
- whole: bool,
34
- /// Accessed or defined with an unknown key, including `__proto__`, except for reads at
35
- /// constant indices.
36
- computed: bool,
37
- /// Read through a constant non-negative integer index, `binding[0]`.
38
- indexed: bool,
39
- deleted: bool,
40
- /// A property value mentions `this`, so calling it as a method may observe or mutate the
41
- /// object.
42
- this: bool,
43
- /// Assigned through a property with `=`: `binding.key = value` or `binding[key] = value`.
44
- pub(crate) written_through: bool,
45
- /// Static keys accessed through reads, calls, updates, deletions, destructuring writes, or
46
- /// loop targets. Excludes plain `binding.key = value` assignments.
47
- pub(crate) accessed: HashSet<Atom>,
48
- /// The static keys called as methods, `binding.key(...)`.
49
- called: HashSet<Atom>,
50
- /// Definition counts for static keys, including object literals, assignments, updates,
51
- /// destructuring patterns, and loop targets.
52
- defined: HashMap<Atom, usize>,
9
+ use oxc::ast_visit::{Visit, walk};
10
+ use oxc::syntax::operator::{AssignmentOperator, UnaryOperator};
11
+
12
+ use super::{Analysis, Id};
13
+ use crate::deobfuscate::{HashMap, HashSet, ast};
14
+
15
+ /// Observations and definitions of an object, merged over its single-assignment aliases.
16
+ #[derive(Default)]
17
+ pub(in crate::deobfuscate) struct Uses<'a> {
18
+ /// The object escapes: it is passed, returned, stored, coerced, or copied into a binding
19
+ /// with several writes.
20
+ pub whole: bool,
21
+ /// An unknown or special key, unsupported property definition, or indexed method call.
22
+ pub dynamic: bool,
23
+ /// Accessed through a constant non-negative integer index.
24
+ pub indexed: bool,
25
+ /// Deleting a property can expose inherited values.
26
+ pub deleted: bool,
27
+ /// A property value mentions `this` and may observe or mutate the object when called.
28
+ pub this: bool,
29
+ /// A property is assigned or updated through some alias.
30
+ pub written: bool,
31
+ /// Static keys read, called, updated, or written by destructuring and loop targets.
32
+ pub read: HashSet<&'a str>,
33
+ /// Static keys called with the object as receiver, including inherited methods.
34
+ pub called: HashSet<&'a str>,
35
+ /// Definition counts from literal entries, assignments, updates, and pattern targets.
36
+ pub defined: HashMap<&'a str, usize>,
53
37
  }
54
38
 
55
- impl Uses {
56
- fn merge(&mut self, other: &Self) {
57
- self.whole |= other.whole;
58
- self.computed |= other.computed;
59
- self.indexed |= other.indexed;
60
- self.deleted |= other.deleted;
61
- self.this |= other.this;
62
- self.written_through |= other.written_through;
63
- self.accessed.extend(other.accessed.iter().cloned());
64
- self.called.extend(other.called.iter().cloned());
65
- for (key, count) in &other.defined {
66
- *self.defined.entry(key.clone()).or_default() += count;
67
- }
68
- }
69
-
70
- /// Checks for uses of the whole object or access through a key that could name any
71
- /// property.
72
- #[must_use]
73
- pub(crate) fn is_used_dynamically(&self) -> bool {
74
- self.whole || self.computed || self.indexed
39
+ impl Uses<'_> {
40
+ /// Checks that no untracked observation can change the object's properties. Rejects escapes,
41
+ /// dynamic or indexed keys, deletion, `this` in property values, and calls to inherited
42
+ /// methods such as `hasOwnProperty`.
43
+ pub(in crate::deobfuscate) fn is_tracked(&self) -> bool {
44
+ !self.whole
45
+ && !self.dynamic
46
+ && !self.indexed
47
+ && !self.deleted
48
+ && !self.this
49
+ && self.called.iter().all(|key| self.defined.contains_key(key))
75
50
  }
51
+ }
76
52
 
77
- /// Checks that every use is a read at a constant index.
78
- #[must_use]
79
- pub(crate) fn is_only_indexed(&self) -> bool {
80
- let indexed_reads = Self {
81
- indexed: self.indexed,
82
- ..Self::default()
83
- };
84
- *self == indexed_reads
85
- }
53
+ /// Property uses by object identity. Single-write copies such as `alias = object` share a root;
54
+ /// the copy itself is not an escape.
55
+ #[derive(Default)]
56
+ pub(in crate::deobfuscate) struct Properties<'a> {
57
+ uses: HashMap<Id, Uses<'a>>,
86
58
  }
87
59
 
88
- impl Properties {
89
- #[must_use]
90
- pub(crate) fn collect(program: &Program, bindings: &Bindings) -> Self {
60
+ impl<'a> Properties<'a> {
61
+ pub(crate) fn collect(program: &Program<'a>, analysis: &Analysis<'a>) -> Self {
91
62
  let mut collect = Collect {
92
- bindings,
93
- uses: HashMap::default(),
63
+ analysis,
64
+ properties: Self::default(),
94
65
  };
95
- program.visit_with(&mut collect);
96
- let uses = collect.uses;
97
- let mut objects: HashMap<Id, Uses> = HashMap::default();
98
- for (id, uses) in &uses {
99
- objects.entry(bindings.root(id)).or_default().merge(uses);
100
- }
101
- Self {
102
- uses,
103
- objects,
104
- roots: bindings.roots(),
105
- none: Uses::default(),
106
- }
107
- }
108
-
109
- /// The uses through `id` itself.
110
- #[must_use]
111
- pub(crate) fn binding(&self, id: &Id) -> &Uses {
112
- self.uses.get(id).unwrap_or(&self.none)
66
+ collect.visit_program(program);
67
+ collect.properties
113
68
  }
114
69
 
115
- /// Returns uses through all bindings that share `id`'s object.
116
- #[must_use]
117
- pub(crate) fn object(&self, id: &Id) -> &Uses {
118
- let root = self.roots.get(id).unwrap_or(id);
119
- self.objects.get(root).unwrap_or(&self.none)
70
+ /// Returns the uses merged over every binding with the same copy-chain root as `id`.
71
+ pub(crate) fn get(&self, id: Id, analysis: &Analysis<'_>) -> Option<&Uses<'a>> {
72
+ self.uses.get(&analysis.bindings.root(&id))
120
73
  }
121
74
 
122
- /// Checks for untracked object observations or mutations: escapes, dynamic keys, deletion,
123
- /// or methods that may use `this`. Includes inherited methods such as `hasOwnProperty` and
124
- /// defined methods mentioning `this`.
125
- #[must_use]
126
- pub(crate) fn is_opaque(&self, id: &Id) -> bool {
127
- let object = self.object(id);
128
- object.is_used_dynamically()
129
- || object.deleted
130
- || object.this
131
- || object
132
- .called
133
- .iter()
134
- .any(|name| !object.defined.contains_key(name))
75
+ /// Checks that `id.key` has exactly one definition and no untracked observation can change
76
+ /// it (see [`Uses::is_tracked`]). Inlining also needs a separate proof that the definition
77
+ /// runs first.
78
+ pub(crate) fn stable(&self, id: Id, key: &str, analysis: &Analysis<'_>) -> bool {
79
+ self.get(id, analysis)
80
+ .is_some_and(|uses| uses.is_tracked() && uses.defined.get(key) == Some(&1))
135
81
  }
136
82
 
137
- /// Checks that `id.key` has one definition. Reads must see that value, or an absent
138
- /// property if they precede the definition.
139
- #[must_use]
140
- pub(crate) fn is_stable(&self, id: &Id, key: &Atom) -> bool {
141
- !self.is_opaque(id) && self.object(id).defined.get(key) == Some(&1)
83
+ /// Checks that every observation is a constant-index read, with no calls, writes, or escapes.
84
+ pub(crate) fn only_indexed(&self, id: Id, analysis: &Analysis<'_>) -> bool {
85
+ self.get(id, analysis).is_some_and(|uses| {
86
+ !uses.whole
87
+ && !uses.dynamic
88
+ && !uses.deleted
89
+ && !uses.this
90
+ && !uses.written
91
+ && uses.called.is_empty()
92
+ && uses.read.is_empty()
93
+ })
142
94
  }
143
95
  }
144
96
 
145
- /// How a member expression is used.
146
- #[derive(Clone, Copy, PartialEq)]
97
+ #[derive(Clone, Copy, PartialEq, Eq)]
147
98
  enum Access {
148
99
  Read,
149
100
  Call,
150
- /// `binding.key = value`.
151
- Assign,
152
- /// Read and written: a compound assignment or an update.
153
- Update,
154
- /// Written by a destructuring pattern or a loop head.
155
- Pattern,
156
101
  Delete,
102
+ Write,
103
+ ReadWrite,
157
104
  }
158
105
 
159
- struct Collect<'bindings> {
160
- bindings: &'bindings Bindings,
161
- uses: HashMap<Id, Uses>,
106
+ struct Collect<'b, 'a> {
107
+ analysis: &'b Analysis<'a>,
108
+ properties: Properties<'a>,
162
109
  }
163
110
 
164
- impl Collect<'_> {
165
- fn uses(&mut self, id: &Ident) -> &mut Uses {
166
- self.uses.entry(id.to_id()).or_default()
111
+ impl<'a> Collect<'_, 'a> {
112
+ fn uses(&mut self, id: Id) -> &mut Uses<'a> {
113
+ let root = self.analysis.bindings.root(&id);
114
+ self.properties.uses.entry(root).or_default()
167
115
  }
168
116
 
169
- /// Records an `access` to `member` when its object is a binding, then visits the remaining
170
- /// evaluated expressions.
171
- fn member(&mut self, member: &MemberExpr, access: Access) {
172
- let Some(object) = member.obj.as_ident() else {
173
- member.visit_children_with(self);
174
- return;
175
- };
176
- let uses = self.uses(object);
177
- match member_key(&member.prop) {
178
- Some(key) => {
179
- if matches!(access, Access::Assign | Access::Update | Access::Pattern) {
180
- *uses.defined.entry(key.clone()).or_default() += 1;
181
- }
182
- if access == Access::Call {
183
- uses.called.insert(key.clone());
184
- }
185
- if access != Access::Assign {
186
- uses.accessed.insert(key);
187
- }
188
- }
189
- None if access == Access::Read && constant_index(&member.prop).is_some() => {
190
- uses.indexed = true;
191
- }
192
- None => uses.computed = true,
117
+ /// Records an object literal assigned to `id`, and returns whether `value` is the tracked
118
+ /// copy that makes `id` an alias.
119
+ fn define(&mut self, id: Id, value: &Expression<'a>) -> bool {
120
+ if let Expression::ObjectExpression(object) = value.get_inner_expression() {
121
+ self.object(id, object)
193
122
  }
194
- uses.written_through |= access == Access::Assign;
195
- uses.deleted |= access == Access::Delete;
196
- member.prop.visit_with(self);
123
+ self.analysis
124
+ .expression_id(value)
125
+ .is_some_and(|source| self.analysis.bindings.copy_source(&id) == Some(&source))
197
126
  }
198
127
 
199
- /// Records `binding = value`. Returns whether it only copies an alias of the same object;
200
- /// such copies do not count as object uses.
201
- fn assignment(&mut self, binding: &Ident, value: &Expr) -> bool {
202
- let Expr::Object(literal) = value else {
203
- let copy_source = self.bindings.copy_source(&binding.to_id());
204
- return value
205
- .as_ident()
206
- .is_some_and(|value| copy_source == Some(&value.to_id()));
207
- };
208
- let this = mentions_this(literal);
209
- let uses = self.uses(binding);
210
- uses.this |= this;
211
- for property in &literal.props {
212
- let key = match property.as_prop().map(|property| &**property) {
213
- Some(Prop::KeyValue(property)) => prop_key(&property.key),
214
- Some(Prop::Getter(property)) => prop_key(&property.key),
215
- Some(Prop::Setter(property)) => prop_key(&property.key),
216
- Some(Prop::Method(property)) => prop_key(&property.key),
217
- Some(Prop::Shorthand(property)) => Some(property.sym.clone()),
218
- Some(Prop::Assign(_)) | None => None,
128
+ fn object(&mut self, id: Id, object: &ObjectExpression<'a>) {
129
+ let uses = self.uses(id);
130
+ for property in &object.properties {
131
+ let ObjectPropertyKind::ObjectProperty(property) = property else {
132
+ uses.dynamic = true;
133
+ continue;
219
134
  };
220
- match key {
221
- Some(key) => *uses.defined.entry(key).or_default() += 1,
222
- None => uses.computed = true,
223
- }
135
+ let Some(key) = ast::key(&property.key, property.computed) else {
136
+ uses.dynamic = true;
137
+ continue;
138
+ };
139
+ uses.dynamic |= property.method || property.kind != PropertyKind::Init;
140
+ uses.dynamic |= key == "__proto__";
141
+ *uses.defined.entry(key).or_default() += 1;
142
+ uses.this |= mentions_this(&property.value);
224
143
  }
225
- false
226
144
  }
227
145
 
228
- /// Records a call, including the receiver passed as `this` for member callees.
229
- fn callee(&mut self, callee: &Expr) {
230
- match callee {
231
- Expr::Paren(paren) => self.callee(&paren.expr),
232
- Expr::Member(member) => self.member(member, Access::Call),
233
- Expr::OptChain(chain) => match &*chain.base {
234
- OptChainBase::Member(member) => self.member(member, Access::Call),
235
- OptChainBase::Call(_) => chain.visit_with(self),
236
- },
237
- callee => callee.visit_with(self),
146
+ /// Records how a member is used, then visits its evaluated object and computed key operands.
147
+ fn member(&mut self, member: &MemberExpression<'a>, access: Access) {
148
+ if let Some(id) = self.analysis.expression_id(member.object()) {
149
+ let key = member.static_property_name().and_then(|name| name.as_str());
150
+ let indexed = matches!(member, MemberExpression::ComputedMemberExpression(computed)
151
+ if ast::number(&computed.expression)
152
+ .is_some_and(|index| index >= 0.0 && index.fract() == 0.0));
153
+ let uses = self.uses(id);
154
+ let write = matches!(access, Access::Write | Access::ReadWrite);
155
+ uses.dynamic |= access == Access::Call && key.is_none();
156
+ uses.written |= write;
157
+ uses.deleted |= access == Access::Delete;
158
+ if let Some(key) = key {
159
+ if write {
160
+ *uses.defined.entry(key).or_default() += 1;
161
+ }
162
+ if access != Access::Write {
163
+ uses.read.insert(key);
164
+ }
165
+ if access == Access::Call {
166
+ uses.called.insert(key);
167
+ }
168
+ uses.dynamic |= key == "__proto__";
169
+ } else if indexed {
170
+ uses.indexed = true
171
+ } else {
172
+ uses.dynamic = true
173
+ }
174
+ } else {
175
+ self.visit_expression(member.object())
176
+ }
177
+ if let MemberExpression::ComputedMemberExpression(computed) = member {
178
+ self.visit_expression(&computed.expression)
238
179
  }
239
180
  }
240
181
  }
241
182
 
242
- impl Visit for Collect<'_> {
243
- /// Any mention of a binding that the cases below do not account for.
244
- fn visit_ident(&mut self, identifier: &Ident) {
245
- self.uses(identifier).whole = true;
246
- }
247
-
248
- /// Declaring or assigning a binding does not access the object's contents.
249
- fn visit_binding_ident(&mut self, _: &BindingIdent) {}
250
-
251
- fn visit_member_expr(&mut self, member: &MemberExpr) {
252
- self.member(member, Access::Read);
253
- }
254
-
255
- fn visit_call_expr(&mut self, call: &CallExpr) {
256
- match &call.callee {
257
- Callee::Expr(callee) => self.callee(callee),
258
- callee => callee.visit_with(self),
183
+ impl<'a> Visit<'a> for Collect<'_, 'a> {
184
+ fn visit_identifier_reference(&mut self, reference: &IdentifierReference<'a>) {
185
+ if let Some(id) = self.analysis.id(reference) {
186
+ self.uses(id).whole = true
259
187
  }
260
- call.args.visit_with(self);
261
188
  }
262
189
 
263
- fn visit_opt_call(&mut self, call: &OptCall) {
264
- self.callee(&call.callee);
265
- call.args.visit_with(self);
266
- }
267
-
268
- fn visit_tagged_tpl(&mut self, template: &TaggedTpl) {
269
- self.callee(&template.tag);
270
- template.tpl.visit_with(self);
190
+ fn visit_expression(&mut self, expression: &Expression<'a>) {
191
+ match expression.as_member_expression() {
192
+ Some(member) => self.member(member, Access::Read),
193
+ None => walk::walk_expression(self, expression),
194
+ }
271
195
  }
272
196
 
273
- fn visit_assign_expr(&mut self, assignment: &AssignExpr) {
274
- let target = match &assignment.left {
275
- AssignTarget::Simple(SimpleAssignTarget::Paren(paren)) => paren.expr.as_member(),
276
- AssignTarget::Simple(SimpleAssignTarget::Member(member)) => Some(member),
277
- _ => None,
278
- };
279
- if let Some(member) = target {
280
- let access = if assignment.op == AssignOp::Assign {
281
- Access::Assign
197
+ fn visit_assignment_expression(&mut self, assignment: &AssignmentExpression<'a>) {
198
+ if let Some(id) = self.analysis.target_id(&assignment.left) {
199
+ if !self.define(id, &assignment.right) {
200
+ self.visit_expression(&assignment.right)
201
+ }
202
+ } else if let Some(member) = assignment.left.as_member_expression() {
203
+ if let Some(id) = self.analysis.expression_id(member.object()) {
204
+ self.uses(id).this |= mentions_this(&assignment.right)
205
+ }
206
+ let access = if assignment.operator == AssignmentOperator::Assign {
207
+ Access::Write
282
208
  } else {
283
- Access::Update
209
+ Access::ReadWrite
284
210
  };
285
- if let Some(object) = member.obj.as_ident()
286
- && mentions_this(&assignment.right)
287
- {
288
- self.uses(object).this = true;
289
- }
290
211
  self.member(member, access);
291
- } else if assignment.op == AssignOp::Assign
292
- && let Some(target) = assignment.left.as_ident()
293
- {
294
- if self.assignment(&target.id, &assignment.right) {
295
- return;
296
- }
212
+ self.visit_expression(&assignment.right)
297
213
  } else {
298
- assignment.left.visit_with(self);
214
+ walk::walk_assignment_expression(self, assignment)
299
215
  }
300
- assignment.right.visit_with(self);
301
216
  }
302
217
 
303
- fn visit_var_declarator(&mut self, declarator: &VarDeclarator) {
304
- if let Pat::Ident(name) = &declarator.name
305
- && let Some(init) = &declarator.init
306
- && self.assignment(&name.id, init)
218
+ fn visit_variable_declarator(&mut self, declarator: &VariableDeclarator<'a>) {
219
+ if let Some(id) = ast::pattern_id(&declarator.id)
220
+ && let Some(value) = &declarator.init
221
+ && self.define(id, value)
307
222
  {
308
223
  return;
309
224
  }
310
- declarator.visit_children_with(self);
225
+ walk::walk_variable_declarator(self, declarator)
311
226
  }
312
227
 
313
- fn visit_update_expr(&mut self, update: &UpdateExpr) {
314
- match &*update.arg {
315
- Expr::Member(member) => self.member(member, Access::Update),
316
- argument => argument.visit_with(self),
228
+ fn visit_assignment_target(&mut self, target: &AssignmentTarget<'a>) {
229
+ match target.as_member_expression() {
230
+ Some(member) => self.member(member, Access::ReadWrite),
231
+ None => walk::walk_assignment_target(self, target),
317
232
  }
318
233
  }
319
234
 
320
- fn visit_unary_expr(&mut self, unary: &UnaryExpr) {
321
- match &*unary.arg {
322
- Expr::Member(member) if unary.op == UnaryOp::Delete => {
323
- self.member(member, Access::Delete);
324
- }
325
- argument => argument.visit_with(self),
235
+ fn visit_call_expression(&mut self, call: &CallExpression<'a>) {
236
+ match call.callee.get_inner_expression().as_member_expression() {
237
+ Some(member) => self.member(member, Access::Call),
238
+ None => self.visit_expression(&call.callee),
239
+ }
240
+ for argument in &call.arguments {
241
+ self.visit_argument(argument)
326
242
  }
327
243
  }
328
244
 
329
- /// A member a destructuring pattern or a loop head writes.
330
- fn visit_pat(&mut self, pattern: &Pat) {
331
- match pattern {
332
- Pat::Expr(target) if let Expr::Member(member) = &**target => {
333
- self.member(member, Access::Pattern);
334
- }
335
- pattern => pattern.visit_children_with(self),
245
+ fn visit_unary_expression(&mut self, unary: &UnaryExpression<'a>) {
246
+ if unary.operator == UnaryOperator::Delete
247
+ && let Some(member) = unary.argument.get_inner_expression().as_member_expression()
248
+ {
249
+ self.member(member, Access::Delete)
250
+ } else {
251
+ walk::walk_unary_expression(self, unary)
336
252
  }
337
253
  }
338
- }
339
254
 
340
- /// The index `[i]` reads, for a non-negative integer `i`.
341
- #[must_use]
342
- pub(crate) fn constant_index(property: &MemberProp) -> Option<usize> {
343
- ast::index_literal(&property.as_computed()?.expr)
255
+ fn visit_update_expression(&mut self, update: &UpdateExpression<'a>) {
256
+ match update.argument.as_member_expression() {
257
+ Some(member) => self.member(member, Access::ReadWrite),
258
+ None => walk::walk_update_expression(self, update),
259
+ }
260
+ }
344
261
  }
345
262
 
346
- /// Identifies `__proto__`, which has special behavior: reads can invoke an inherited accessor,
347
- /// assignments can change the prototype, and object-literal entries set the prototype.
348
- const PROTO: &str = "__proto__";
349
-
350
- /// Returns the own-property name in `object.name`, `object["name"]`, or ``object[`name`]``.
351
- /// Rejects keys containing lone surrogates, since converting them to Rust strings would replace
352
- /// them with U+FFFD and could match a different key.
353
- #[must_use]
354
- pub(crate) fn member_key(property: &MemberProp) -> Option<Atom> {
355
- ast::member_str(property)
356
- .filter(|name| *name != PROTO)
357
- .map(Atom::from)
358
- }
263
+ /// Checks for `this`, including in nested functions, since a method may pass its receiver on.
264
+ fn mentions_this(value: &Expression<'_>) -> bool {
265
+ struct This(bool);
359
266
 
360
- /// The own property an object-literal key defines (see [`member_key`]).
361
- #[must_use]
362
- pub(crate) fn prop_key(key: &PropName) -> Option<Atom> {
363
- ast::key_str(key)
364
- .filter(|name| *name != PROTO)
365
- .map(Atom::from)
366
- }
267
+ impl<'a> Visit<'a> for This {
268
+ fn visit_this_expression(&mut self, _: &ThisExpression) {
269
+ self.0 = true
270
+ }
271
+ }
367
272
 
368
- /// Checks for `this` anywhere in `node`, including nested functions. A method mentioning it may
369
- /// observe or change its receiver.
370
- fn mentions_this<N: VisitWith<This>>(node: &N) -> bool {
371
273
  let mut this = This(false);
372
- node.visit_with(&mut this);
274
+ this.visit_expression(value);
373
275
  this.0
374
276
  }
375
277
 
376
- struct This(bool);
377
-
378
- impl Visit for This {
379
- fn visit_this_expr(&mut self, _: &ThisExpr) {
380
- self.0 = true;
381
- }
382
- }
383
-
384
278
  #[cfg(test)]
385
279
  mod tests {
386
- use swc_core::atoms::Atom;
387
- use swc_core::ecma::ast::{Expr, MemberProp, Program, PropName};
388
-
389
- use super::{Properties, member_key, prop_key};
390
- use crate::deobfuscate::analysis::Bindings;
280
+ use super::Properties;
391
281
  use crate::deobfuscate::testing;
392
- use crate::js::ast;
393
-
394
- fn properties(program: &Program) -> Properties {
395
- Properties::collect(program, &Bindings::collect(program))
396
- }
397
-
398
- fn member(source: &str) -> MemberProp {
399
- match ast::parse_expression("member", source).unwrap() {
400
- Expr::Member(member) => member.prop,
401
- other => panic!("{source} is {other:?}"),
402
- }
403
- }
404
-
405
- fn key(source: &str) -> PropName {
406
- let Expr::Object(object) = ast::parse_expression("object", source).unwrap() else {
407
- panic!("{source} is not an object");
408
- };
409
- let property = object.props[0].as_prop().unwrap();
410
- property.as_key_value().unwrap().key.clone()
411
- }
412
-
413
- #[test]
414
- fn resolves_static_keys() {
415
- for source in ["o.name", "o['name']", "o[`name`]", r#"o["n\x61me"]"#] {
416
- assert_eq!(
417
- member_key(&member(source)).as_deref(),
418
- Some("name"),
419
- "{source}"
420
- );
421
- }
422
- assert_eq!(prop_key(&key("{ 'name': 1 }")).as_deref(), Some("name"));
423
- assert_eq!(prop_key(&key("{ name: 1 }")).as_deref(), Some("name"));
424
- // Dynamic, prototype, and lone-surrogate names have no key.
425
- for source in [
426
- "o[k]",
427
- "o[0]",
428
- "o[`${k}`]",
429
- "o.__proto__",
430
- "o['__proto__']",
431
- r#"o["\uD800"]"#,
432
- r#"o["\uDC00"]"#,
433
- ] {
434
- assert_eq!(member_key(&member(source)), None, "{source}");
435
- }
436
- for source in [
437
- "{ __proto__: 1 }",
438
- "{ '__proto__': 1 }",
439
- "{ 0: 1 }",
440
- "{ [k]: 1 }",
441
- ] {
442
- assert_eq!(prop_key(&key(source)), None, "{source}");
443
- }
444
- assert_eq!(
445
- prop_key(&key(r#"{ "\uD800": 1 }"#)),
446
- None,
447
- "two different lone surrogates must not become the same key"
448
- );
449
- }
450
282
 
451
283
  #[test]
452
284
  fn counts_definitions_through_aliases() {
453
285
  testing::check(
454
- "function f(h, p, q, o) {
455
- h = { a: 1, b: function () {} }; p = h; var q = p;
456
- q.c = 2; p.a += 1; h.b(); o = { d: 1 }; o.d++;
457
- return [q.a, p.c];
458
- }",
459
- |program, id| {
460
- let properties = properties(program);
461
- assert!(!properties.is_opaque(&id("q")));
462
- assert!(!properties.is_stable(&id("h"), &"a".into()));
463
- assert!(properties.is_stable(&id("q"), &"b".into()));
464
- assert!(properties.is_stable(&id("h"), &"c".into()));
465
- assert!(!properties.is_stable(&id("o"), &"d".into()));
466
- let object = properties.object(&id("p"));
286
+ "function f(h,p,q,o){h={a:1,b:function(){}};p=h;var q=p;q.c=2;p.a+=1;h.b();o={d:1};o.d++;return [q.a,p.c];}",
287
+ |program, analysis, id| {
288
+ let properties = Properties::collect(program, analysis);
289
+ assert!(!properties.stable(id("h"), "a", analysis));
290
+ assert!(properties.stable(id("q"), "b", analysis));
291
+ assert!(properties.stable(id("h"), "c", analysis));
292
+ assert!(!properties.stable(id("o"), "d", analysis));
293
+ let object = properties.get(id("p"), analysis).unwrap();
467
294
  for key in ["a", "b", "c"] {
468
- assert!(object.accessed.contains(&Atom::from(key)), "{key}");
295
+ assert!(object.read.contains(key), "{key}")
469
296
  }
470
- assert!(properties.binding(&id("q")).written_through);
471
- assert!(!properties.binding(&id("h")).written_through);
472
297
  },
473
298
  );
474
299
  }
475
300
 
476
301
  #[test]
477
- fn makes_objects_opaque() {
478
- for (source, opaque) in [
479
- ("h = {}; use(h);", true),
480
- ("h = {}; use({ h });", true),
481
- ("h = {}; h[k] = 1;", true),
482
- ("h = {}; h[0];", true),
483
- ("h = {}; h.__proto__;", true),
484
- ("h = { __proto__: p };", true),
485
- ("h = { [k]: 1 };", true),
486
- ("h = {}; delete h.a;", true),
487
- ("h = {}; h.hasOwnProperty('a');", true),
488
- ("h = {}; (h.hasOwnProperty)('a');", true),
489
- ("h = {}; h?.hasOwnProperty('a');", true),
490
- ("h = { m: function () { return this; } };", true),
491
- ("h = {}; h.m = function () { return this; };", true),
492
- ("h = {}; p = h; p = 2; h.a;", true),
493
- (
494
- "h = { m: function () {} }; h.m(); h.a = 1; [h.b] = [1]; h.c;",
495
- false,
496
- ),
302
+ fn rejects_escapes_dynamic_keys_and_observable_mutations() {
303
+ for source in [
304
+ "use(h);",
305
+ "use({h});",
306
+ "h[k]=1;",
307
+ "h[0];",
308
+ "h.__proto__;",
309
+ "delete h.a;",
310
+ "h.hasOwnProperty('a');",
311
+ "(h.hasOwnProperty)('a');",
312
+ "h?.hasOwnProperty('a');",
313
+ "h.m=function(){return this};h.m();",
314
+ "p=h;p=2;h.a;",
315
+ "[h.a]=[1];",
316
+ "for(h.a of list);",
317
+ "h.a++;",
318
+ "h.a+=1;",
497
319
  ] {
498
320
  testing::check(
499
- &format!("function f(h, p, k) {{ {source} }}"),
500
- |program, id| {
501
- assert_eq!(properties(program).is_opaque(&id("h")), opaque, "{source}");
321
+ &format!("function f(h,p,k){{h={{a:1}};{source}}}"),
322
+ |program, analysis, id| {
323
+ assert!(
324
+ !Properties::collect(program, analysis).stable(id("h"), "a", analysis),
325
+ "{source}"
326
+ )
502
327
  },
503
328
  );
504
329
  }
505
330
  }
506
331
 
507
332
  #[test]
508
- fn tells_constant_index_reads_from_other_uses() {
333
+ fn distinguishes_constant_index_reads_from_writes() {
509
334
  for (source, only_indexed) in [
510
- ("f = [a]; f[0] + f[3];", true),
511
- ("f = [a]; f[0]();", false),
512
- ("f = [a]; f[0] = 1;", false),
513
- ("f = [a]; f[0]++;", false),
514
- ("f = [a]; delete f[0];", false),
515
- ("f = [a]; [f[0]] = [1];", false),
516
- ("f = [a]; for (f[0] of [1]);", false),
517
- ("f = [a]; f.length;", false),
518
- ("f = [a]; f[i];", false),
519
- ("f = [a]; use({ f });", false),
335
+ ("f[0]+f[3];", true),
336
+ ("f[0]();", false),
337
+ ("f[0]=1;", false),
338
+ ("f[0]++;", false),
339
+ ("delete f[0];", false),
340
+ ("[f[0]]=[1];", false),
341
+ ("for(f[0] of [1]);", false),
342
+ ("f.length;", false),
343
+ ("f[i];", false),
344
+ ("use({f});", false),
520
345
  ] {
521
346
  testing::check(
522
- &format!("function g(a, f, i) {{ {source} }}"),
523
- |program, id| {
347
+ &format!("function g(a,f,i){{f=[a];{source}}}"),
348
+ |program, analysis, id| {
524
349
  assert_eq!(
525
- properties(program).binding(&id("f")).is_only_indexed(),
350
+ Properties::collect(program, analysis).only_indexed(id("f"), analysis),
526
351
  only_indexed,
527
352
  "{source}"
528
- );
353
+ )
529
354
  },
530
355
  );
531
356
  }