circle-ir 4.21.1 → 4.22.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 (57) hide show
  1. package/dist/analysis/config-loader.d.ts.map +1 -1
  2. package/dist/analysis/config-loader.js +6 -0
  3. package/dist/analysis/config-loader.js.map +1 -1
  4. package/dist/analysis/findings.d.ts.map +1 -1
  5. package/dist/analysis/findings.js +14 -6
  6. package/dist/analysis/findings.js.map +1 -1
  7. package/dist/analysis/passes/_js-crypto-binding.d.ts +53 -0
  8. package/dist/analysis/passes/_js-crypto-binding.d.ts.map +1 -0
  9. package/dist/analysis/passes/_js-crypto-binding.js +123 -0
  10. package/dist/analysis/passes/_js-crypto-binding.js.map +1 -0
  11. package/dist/analysis/passes/hardcoded-secret-argument-pass.d.ts +85 -0
  12. package/dist/analysis/passes/hardcoded-secret-argument-pass.d.ts.map +1 -0
  13. package/dist/analysis/passes/hardcoded-secret-argument-pass.js +351 -0
  14. package/dist/analysis/passes/hardcoded-secret-argument-pass.js.map +1 -0
  15. package/dist/analysis/passes/language-sources-pass.d.ts.map +1 -1
  16. package/dist/analysis/passes/language-sources-pass.js +2 -2
  17. package/dist/analysis/passes/language-sources-pass.js.map +1 -1
  18. package/dist/analysis/passes/missing-auth-middleware-pass.d.ts +56 -0
  19. package/dist/analysis/passes/missing-auth-middleware-pass.d.ts.map +1 -0
  20. package/dist/analysis/passes/missing-auth-middleware-pass.js +255 -0
  21. package/dist/analysis/passes/missing-auth-middleware-pass.js.map +1 -0
  22. package/dist/analysis/passes/prototype-pollution-pass.d.ts +78 -0
  23. package/dist/analysis/passes/prototype-pollution-pass.d.ts.map +1 -0
  24. package/dist/analysis/passes/prototype-pollution-pass.js +736 -0
  25. package/dist/analysis/passes/prototype-pollution-pass.js.map +1 -0
  26. package/dist/analysis/passes/redos-regex-literal-pass.d.ts +106 -0
  27. package/dist/analysis/passes/redos-regex-literal-pass.d.ts.map +1 -0
  28. package/dist/analysis/passes/redos-regex-literal-pass.js +637 -0
  29. package/dist/analysis/passes/redos-regex-literal-pass.js.map +1 -0
  30. package/dist/analysis/passes/scan-secrets-pass.d.ts +3 -0
  31. package/dist/analysis/passes/scan-secrets-pass.d.ts.map +1 -1
  32. package/dist/analysis/passes/scan-secrets-pass.js +3 -3
  33. package/dist/analysis/passes/scan-secrets-pass.js.map +1 -1
  34. package/dist/analysis/passes/taint-propagation-pass.js +24 -0
  35. package/dist/analysis/passes/taint-propagation-pass.js.map +1 -1
  36. package/dist/analysis/passes/weak-crypto-pass.d.ts.map +1 -1
  37. package/dist/analysis/passes/weak-crypto-pass.js +7 -1
  38. package/dist/analysis/passes/weak-crypto-pass.js.map +1 -1
  39. package/dist/analysis/passes/weak-hash-pass.d.ts.map +1 -1
  40. package/dist/analysis/passes/weak-hash-pass.js +7 -1
  41. package/dist/analysis/passes/weak-hash-pass.js.map +1 -1
  42. package/dist/analysis/passes/weak-password-hash-pass.d.ts.map +1 -1
  43. package/dist/analysis/passes/weak-password-hash-pass.js +7 -1
  44. package/dist/analysis/passes/weak-password-hash-pass.js.map +1 -1
  45. package/dist/analyzer.d.ts.map +1 -1
  46. package/dist/analyzer.js +12 -0
  47. package/dist/analyzer.js.map +1 -1
  48. package/dist/browser/circle-ir.js +1729 -146
  49. package/dist/core/circle-ir-core.cjs +70 -79
  50. package/dist/core/circle-ir-core.js +70 -79
  51. package/dist/core/extractors/imports.js +18 -1
  52. package/dist/core/extractors/imports.js.map +1 -1
  53. package/dist/types/index.d.ts +5 -0
  54. package/dist/types/index.d.ts.map +1 -1
  55. package/dist/wasm/web-tree-sitter.wasm +0 -0
  56. package/docs/SPEC.md +1 -0
  57. package/package.json +2 -2
@@ -115,17 +115,17 @@ function unmarshalNode(tree, address = TRANSFER_BUFFER) {
115
115
  });
116
116
  return result;
117
117
  }
118
- function marshalTreeCursor(cursor, address = TRANSFER_BUFFER) {
119
- C.setValue(address + 0 * SIZE_OF_INT, cursor[0], "i32");
120
- C.setValue(address + 1 * SIZE_OF_INT, cursor[1], "i32");
121
- C.setValue(address + 2 * SIZE_OF_INT, cursor[2], "i32");
122
- C.setValue(address + 3 * SIZE_OF_INT, cursor[3], "i32");
123
- }
124
- function unmarshalTreeCursor(cursor) {
125
- cursor[0] = C.getValue(TRANSFER_BUFFER + 0 * SIZE_OF_INT, "i32");
126
- cursor[1] = C.getValue(TRANSFER_BUFFER + 1 * SIZE_OF_INT, "i32");
127
- cursor[2] = C.getValue(TRANSFER_BUFFER + 2 * SIZE_OF_INT, "i32");
128
- cursor[3] = C.getValue(TRANSFER_BUFFER + 3 * SIZE_OF_INT, "i32");
118
+ function marshalTreeCursor({ handles }, address = TRANSFER_BUFFER) {
119
+ C.setValue(address + 0 * SIZE_OF_INT, handles[0], "i32");
120
+ C.setValue(address + 1 * SIZE_OF_INT, handles[1], "i32");
121
+ C.setValue(address + 2 * SIZE_OF_INT, handles[2], "i32");
122
+ C.setValue(address + 3 * SIZE_OF_INT, handles[3], "i32");
123
+ }
124
+ function unmarshalTreeCursor({ handles }) {
125
+ handles[0] = C.getValue(TRANSFER_BUFFER + 0 * SIZE_OF_INT, "i32");
126
+ handles[1] = C.getValue(TRANSFER_BUFFER + 1 * SIZE_OF_INT, "i32");
127
+ handles[2] = C.getValue(TRANSFER_BUFFER + 2 * SIZE_OF_INT, "i32");
128
+ handles[3] = C.getValue(TRANSFER_BUFFER + 3 * SIZE_OF_INT, "i32");
129
129
  }
130
130
  function marshalPoint(address, point) {
131
131
  C.setValue(address, point.row, "i32");
@@ -1531,7 +1531,7 @@ async function Module2(moduleArg = {}) {
1531
1531
  Module["loadWebAssemblyModule"] = loadWebAssemblyModule;
1532
1532
  Module["LE_HEAP_STORE_I64"] = LE_HEAP_STORE_I64;
1533
1533
  var ASM_CONSTS = {};
1534
- var _malloc, _calloc, _realloc, _free, _ts_range_edit, _memcmp, _ts_language_symbol_count, _ts_language_state_count, _ts_language_abi_version, _ts_language_name, _ts_language_field_count, _ts_language_next_state, _ts_language_symbol_name, _ts_language_symbol_for_name, _strncmp, _ts_language_symbol_type, _ts_language_field_name_for_id, _ts_lookahead_iterator_new, _ts_lookahead_iterator_delete, _ts_lookahead_iterator_reset_state, _ts_lookahead_iterator_reset, _ts_lookahead_iterator_next, _ts_lookahead_iterator_current_symbol, _ts_point_edit, _ts_parser_delete, _ts_parser_reset, _ts_parser_set_language, _ts_parser_set_included_ranges, _ts_query_new, _ts_query_delete, _iswspace, _iswalnum, _ts_query_copy, _ts_query_pattern_count, _ts_query_capture_count, _ts_query_string_count, _ts_query_capture_name_for_id, _ts_query_capture_quantifier_for_id, _ts_query_string_value_for_id, _ts_query_predicates_for_pattern, _ts_query_start_byte_for_pattern, _ts_query_end_byte_for_pattern, _ts_query_is_pattern_rooted, _ts_query_is_pattern_non_local, _ts_query_is_pattern_guaranteed_at_step, _ts_query_disable_capture, _ts_query_disable_pattern, _ts_tree_copy, _ts_tree_delete, _ts_init, _ts_parser_new_wasm, _ts_parser_enable_logger_wasm, _ts_parser_parse_wasm, _ts_parser_included_ranges_wasm, _ts_language_type_is_named_wasm, _ts_language_type_is_visible_wasm, _ts_language_metadata_wasm, _ts_language_supertypes_wasm, _ts_language_subtypes_wasm, _ts_tree_root_node_wasm, _ts_tree_root_node_with_offset_wasm, _ts_tree_edit_wasm, _ts_tree_included_ranges_wasm, _ts_tree_get_changed_ranges_wasm, _ts_tree_cursor_new_wasm, _ts_tree_cursor_copy_wasm, _ts_tree_cursor_delete_wasm, _ts_tree_cursor_reset_wasm, _ts_tree_cursor_reset_to_wasm, _ts_tree_cursor_goto_first_child_wasm, _ts_tree_cursor_goto_last_child_wasm, _ts_tree_cursor_goto_first_child_for_index_wasm, _ts_tree_cursor_goto_first_child_for_position_wasm, _ts_tree_cursor_goto_next_sibling_wasm, _ts_tree_cursor_goto_previous_sibling_wasm, _ts_tree_cursor_goto_descendant_wasm, _ts_tree_cursor_goto_parent_wasm, _ts_tree_cursor_current_node_type_id_wasm, _ts_tree_cursor_current_node_state_id_wasm, _ts_tree_cursor_current_node_is_named_wasm, _ts_tree_cursor_current_node_is_missing_wasm, _ts_tree_cursor_current_node_id_wasm, _ts_tree_cursor_start_position_wasm, _ts_tree_cursor_end_position_wasm, _ts_tree_cursor_start_index_wasm, _ts_tree_cursor_end_index_wasm, _ts_tree_cursor_current_field_id_wasm, _ts_tree_cursor_current_depth_wasm, _ts_tree_cursor_current_descendant_index_wasm, _ts_tree_cursor_current_node_wasm, _ts_node_symbol_wasm, _ts_node_field_name_for_child_wasm, _ts_node_field_name_for_named_child_wasm, _ts_node_children_by_field_id_wasm, _ts_node_first_child_for_byte_wasm, _ts_node_first_named_child_for_byte_wasm, _ts_node_grammar_symbol_wasm, _ts_node_child_count_wasm, _ts_node_named_child_count_wasm, _ts_node_child_wasm, _ts_node_named_child_wasm, _ts_node_child_by_field_id_wasm, _ts_node_next_sibling_wasm, _ts_node_prev_sibling_wasm, _ts_node_next_named_sibling_wasm, _ts_node_prev_named_sibling_wasm, _ts_node_descendant_count_wasm, _ts_node_parent_wasm, _ts_node_child_with_descendant_wasm, _ts_node_descendant_for_index_wasm, _ts_node_named_descendant_for_index_wasm, _ts_node_descendant_for_position_wasm, _ts_node_named_descendant_for_position_wasm, _ts_node_start_point_wasm, _ts_node_end_point_wasm, _ts_node_start_index_wasm, _ts_node_end_index_wasm, _ts_node_to_string_wasm, _ts_node_children_wasm, _ts_node_named_children_wasm, _ts_node_descendants_of_type_wasm, _ts_node_is_named_wasm, _ts_node_has_changes_wasm, _ts_node_has_error_wasm, _ts_node_is_error_wasm, _ts_node_is_missing_wasm, _ts_node_is_extra_wasm, _ts_node_parse_state_wasm, _ts_node_next_parse_state_wasm, _ts_query_matches_wasm, _ts_query_captures_wasm, _memset, _memcpy, _memmove, _iswalpha, _iswblank, _iswdigit, _iswlower, _iswpunct, _iswupper, _iswxdigit, _memchr, _strlen, _strcmp, _strncat, _strncpy, _towlower, _towupper, _setThrew, __emscripten_stack_restore, __emscripten_stack_alloc, _emscripten_stack_get_current, ___wasm_apply_data_relocs;
1534
+ var _malloc, _calloc, _realloc, _free, _ts_range_edit, _memcmp, _ts_language_symbol_count, _ts_language_state_count, _ts_language_abi_version, _ts_language_name, _ts_language_field_count, _ts_language_next_state, _ts_language_symbol_name, _ts_language_symbol_for_name, _strncmp, _strlen, _ts_language_symbol_type, _ts_language_field_name_for_id, _ts_lookahead_iterator_new, _ts_lookahead_iterator_delete, _ts_lookahead_iterator_reset_state, _ts_lookahead_iterator_reset, _ts_lookahead_iterator_next, _ts_lookahead_iterator_current_symbol, _ts_point_edit, _ts_parser_delete, _ts_parser_reset, _ts_parser_set_language, _ts_parser_set_included_ranges, _ts_query_new, _ts_query_delete, _iswspace, _iswalnum, _ts_query_copy, _ts_query_pattern_count, _ts_query_capture_count, _ts_query_string_count, _ts_query_capture_name_for_id, _ts_query_capture_quantifier_for_id, _ts_query_string_value_for_id, _ts_query_predicates_for_pattern, _ts_query_start_byte_for_pattern, _ts_query_end_byte_for_pattern, _ts_query_is_pattern_rooted, _ts_query_is_pattern_non_local, _ts_query_is_pattern_guaranteed_at_step, _ts_query_disable_capture, _ts_query_disable_pattern, _ts_tree_copy, _ts_tree_delete, _ts_init, _ts_parser_new_wasm, _ts_parser_enable_logger_wasm, _ts_parser_parse_wasm, _ts_parser_included_ranges_wasm, _ts_language_type_is_named_wasm, _ts_language_type_is_visible_wasm, _ts_language_metadata_wasm, _ts_language_supertypes_wasm, _ts_language_subtypes_wasm, _ts_tree_root_node_wasm, _ts_tree_root_node_with_offset_wasm, _ts_tree_edit_wasm, _ts_tree_included_ranges_wasm, _ts_tree_get_changed_ranges_wasm, _ts_tree_cursor_new_wasm, _ts_tree_cursor_copy_wasm, _ts_tree_cursor_delete_wasm, _ts_tree_cursor_reset_wasm, _ts_tree_cursor_reset_to_wasm, _ts_tree_cursor_goto_first_child_wasm, _ts_tree_cursor_goto_last_child_wasm, _ts_tree_cursor_goto_first_child_for_index_wasm, _ts_tree_cursor_goto_first_child_for_position_wasm, _ts_tree_cursor_goto_next_sibling_wasm, _ts_tree_cursor_goto_previous_sibling_wasm, _ts_tree_cursor_goto_descendant_wasm, _ts_tree_cursor_goto_parent_wasm, _ts_tree_cursor_current_node_type_id_wasm, _ts_tree_cursor_current_node_state_id_wasm, _ts_tree_cursor_current_node_is_named_wasm, _ts_tree_cursor_current_node_is_missing_wasm, _ts_tree_cursor_current_node_id_wasm, _ts_tree_cursor_start_position_wasm, _ts_tree_cursor_end_position_wasm, _ts_tree_cursor_start_index_wasm, _ts_tree_cursor_end_index_wasm, _ts_tree_cursor_current_field_id_wasm, _ts_tree_cursor_current_depth_wasm, _ts_tree_cursor_current_descendant_index_wasm, _ts_tree_cursor_current_node_wasm, _ts_node_symbol_wasm, _ts_node_field_name_for_child_wasm, _ts_node_field_name_for_named_child_wasm, _ts_node_children_by_field_id_wasm, _ts_node_first_child_for_byte_wasm, _ts_node_first_named_child_for_byte_wasm, _ts_node_grammar_symbol_wasm, _ts_node_child_count_wasm, _ts_node_named_child_count_wasm, _ts_node_child_wasm, _ts_node_named_child_wasm, _ts_node_child_by_field_id_wasm, _ts_node_next_sibling_wasm, _ts_node_prev_sibling_wasm, _ts_node_next_named_sibling_wasm, _ts_node_prev_named_sibling_wasm, _ts_node_descendant_count_wasm, _ts_node_parent_wasm, _ts_node_child_with_descendant_wasm, _ts_node_descendant_for_index_wasm, _ts_node_named_descendant_for_index_wasm, _ts_node_descendant_for_position_wasm, _ts_node_named_descendant_for_position_wasm, _ts_node_start_point_wasm, _ts_node_end_point_wasm, _ts_node_start_index_wasm, _ts_node_end_index_wasm, _ts_node_to_string_wasm, _ts_node_children_wasm, _ts_node_named_children_wasm, _ts_node_descendants_of_type_wasm, _ts_node_is_named_wasm, _ts_node_has_changes_wasm, _ts_node_has_error_wasm, _ts_node_is_error_wasm, _ts_node_is_missing_wasm, _ts_node_is_extra_wasm, _ts_node_parse_state_wasm, _ts_node_next_parse_state_wasm, _ts_query_matches_wasm, _ts_query_captures_wasm, _memset, _memcpy, _memmove, _iswalpha, _iswblank, _iswdigit, _iswlower, _iswpunct, _iswupper, _iswxdigit, _memchr, _strcmp, _strncat, _strncpy, _towlower, _towupper, _setThrew, __emscripten_stack_restore, __emscripten_stack_alloc, _emscripten_stack_get_current, ___wasm_apply_data_relocs;
1535
1535
  function assignWasmExports(wasmExports2) {
1536
1536
  Module["_malloc"] = _malloc = wasmExports2["malloc"];
1537
1537
  Module["_calloc"] = _calloc = wasmExports2["calloc"];
@@ -1548,6 +1548,7 @@ async function Module2(moduleArg = {}) {
1548
1548
  Module["_ts_language_symbol_name"] = _ts_language_symbol_name = wasmExports2["ts_language_symbol_name"];
1549
1549
  Module["_ts_language_symbol_for_name"] = _ts_language_symbol_for_name = wasmExports2["ts_language_symbol_for_name"];
1550
1550
  Module["_strncmp"] = _strncmp = wasmExports2["strncmp"];
1551
+ Module["_strlen"] = _strlen = wasmExports2["strlen"];
1551
1552
  Module["_ts_language_symbol_type"] = _ts_language_symbol_type = wasmExports2["ts_language_symbol_type"];
1552
1553
  Module["_ts_language_field_name_for_id"] = _ts_language_field_name_for_id = wasmExports2["ts_language_field_name_for_id"];
1553
1554
  Module["_ts_lookahead_iterator_new"] = _ts_lookahead_iterator_new = wasmExports2["ts_lookahead_iterator_new"];
@@ -1675,7 +1676,6 @@ async function Module2(moduleArg = {}) {
1675
1676
  Module["_iswupper"] = _iswupper = wasmExports2["iswupper"];
1676
1677
  Module["_iswxdigit"] = _iswxdigit = wasmExports2["iswxdigit"];
1677
1678
  Module["_memchr"] = _memchr = wasmExports2["memchr"];
1678
- Module["_strlen"] = _strlen = wasmExports2["strlen"];
1679
1679
  Module["_strcmp"] = _strcmp = wasmExports2["strcmp"];
1680
1680
  Module["_strncat"] = _strncat = wasmExports2["strncat"];
1681
1681
  Module["_strncpy"] = _strncpy = wasmExports2["strncpy"];
@@ -1971,6 +1971,9 @@ function parsePattern(index, stepType, stepValueId, captureNames, stringValues,
1971
1971
  steps.length = 0;
1972
1972
  }
1973
1973
  }
1974
+ function indexForByteOffset(source, byteOffset) {
1975
+ return new TextEncoder().encodeInto(source, new Uint8Array(byteOffset)).read;
1976
+ }
1974
1977
  var import_meta, __defProp2, __name, Edit, SIZE_OF_SHORT, SIZE_OF_INT, SIZE_OF_CURSOR, SIZE_OF_NODE, SIZE_OF_POINT, SIZE_OF_RANGE, ZERO_POINT, INTERNAL, C, finalizer, LookaheadIterator, finalizer2, Tree, finalizer3, TreeCursor, Node, LANGUAGE_FUNCTION_REGEX, Language, web_tree_sitter_default, Module3, TRANSFER_BUFFER, LANGUAGE_VERSION, MIN_COMPATIBLE_VERSION, finalizer4, Parser, PREDICATE_STEP_TYPE_CAPTURE, PREDICATE_STEP_TYPE_STRING, QUERY_WORD_REGEX, CaptureQuantifier, isCaptureStep, isStringStep, QueryErrorKind, QueryError, finalizer5, Query;
1975
1978
  var init_web_tree_sitter = __esm({
1976
1979
  "../../node_modules/web-tree-sitter/web-tree-sitter.js"() {
@@ -2290,29 +2293,17 @@ var init_web_tree_sitter = __esm({
2290
2293
  return result;
2291
2294
  }
2292
2295
  };
2293
- finalizer3 = newFinalizer((address) => {
2294
- C._ts_tree_cursor_delete_wasm(address);
2296
+ finalizer3 = newFinalizer((handles) => {
2297
+ marshalTreeCursor({ handles });
2298
+ C._ts_tree_cursor_delete_wasm(0);
2295
2299
  });
2296
2300
  TreeCursor = class _TreeCursor {
2297
2301
  static {
2298
2302
  __name(this, "TreeCursor");
2299
2303
  }
2300
2304
  /** @internal */
2301
- // @ts-expect-error: never read
2302
- [0] = 0;
2303
- // Internal handle for Wasm
2304
- /** @internal */
2305
- // @ts-expect-error: never read
2306
- [1] = 0;
2307
- // Internal handle for Wasm
2308
- /** @internal */
2309
- // @ts-expect-error: never read
2310
- [2] = 0;
2311
- // Internal handle for Wasm
2312
- /** @internal */
2313
- // @ts-expect-error: never read
2314
- [3] = 0;
2315
- // Internal handle for Wasm
2305
+ handles = [0, 0, 0, 0];
2306
+ // Internal handles for Wasm, shared with the finalizer.
2316
2307
  /** @internal */
2317
2308
  tree;
2318
2309
  /** @internal */
@@ -2320,21 +2311,20 @@ var init_web_tree_sitter = __esm({
2320
2311
  assertInternal(internal);
2321
2312
  this.tree = tree;
2322
2313
  unmarshalTreeCursor(this);
2323
- finalizer3?.register(this, this.tree[0], this);
2314
+ finalizer3?.register(this, this.handles, this);
2324
2315
  }
2325
2316
  /** Creates a deep copy of the tree cursor. This allocates new memory. */
2326
2317
  copy() {
2327
- const copy = new _TreeCursor(INTERNAL, this.tree);
2318
+ marshalTreeCursor(this);
2328
2319
  C._ts_tree_cursor_copy_wasm(this.tree[0]);
2329
- unmarshalTreeCursor(copy);
2330
- return copy;
2320
+ return new _TreeCursor(INTERNAL, this.tree);
2331
2321
  }
2332
2322
  /** Delete the tree cursor, freeing its resources. */
2333
2323
  delete() {
2334
2324
  finalizer3?.unregister(this);
2335
2325
  marshalTreeCursor(this);
2336
2326
  C._ts_tree_cursor_delete_wasm(this.tree[0]);
2337
- this[0] = this[1] = this[2] = 0;
2327
+ this.handles.fill(0);
2338
2328
  }
2339
2329
  /** Get the tree cursor's current {@link Node}. */
2340
2330
  get currentNode() {
@@ -2545,10 +2535,10 @@ var init_web_tree_sitter = __esm({
2545
2535
  }
2546
2536
  /**
2547
2537
  * Move this cursor to the first child of its current node that contains or
2548
- * starts after the given byte offset.
2538
+ * starts after the given position.
2549
2539
  *
2550
- * This returns the index of the child node if one was found, and returns
2551
- * `null` if no such child was found.
2540
+ * This returns `true` if the cursor successfully moved to a child node, and returns
2541
+ * `false` if no such child was found.
2552
2542
  */
2553
2543
  gotoFirstChildForPosition(goalPosition) {
2554
2544
  marshalTreeCursor(this);
@@ -2564,8 +2554,9 @@ var init_web_tree_sitter = __esm({
2564
2554
  reset(node) {
2565
2555
  marshalNode(node);
2566
2556
  marshalTreeCursor(this, TRANSFER_BUFFER + SIZE_OF_NODE);
2567
- C._ts_tree_cursor_reset_wasm(this.tree[0]);
2557
+ C._ts_tree_cursor_reset_wasm(node.tree[0]);
2568
2558
  unmarshalTreeCursor(this);
2559
+ this.tree = node.tree;
2569
2560
  }
2570
2561
  /**
2571
2562
  * Re-initialize a tree cursor to the same position as another cursor.
@@ -2578,6 +2569,7 @@ var init_web_tree_sitter = __esm({
2578
2569
  marshalTreeCursor(cursor, TRANSFER_BUFFER + SIZE_OF_CURSOR);
2579
2570
  C._ts_tree_cursor_reset_to_wasm(this.tree[0], cursor.tree[0]);
2580
2571
  unmarshalTreeCursor(this);
2572
+ this.tree = cursor.tree;
2581
2573
  }
2582
2574
  };
2583
2575
  Node = class {
@@ -2936,16 +2928,14 @@ var init_web_tree_sitter = __esm({
2936
2928
  if (!Array.isArray(types)) types = [types];
2937
2929
  const symbols = [];
2938
2930
  const typesBySymbol = this.tree.language.types;
2939
- for (const node_type of types) {
2940
- if (node_type == "ERROR") {
2941
- symbols.push(65535);
2942
- }
2943
- }
2944
2931
  for (let i2 = 0, n = typesBySymbol.length; i2 < n; i2++) {
2945
2932
  if (types.includes(typesBySymbol[i2])) {
2946
2933
  symbols.push(i2);
2947
2934
  }
2948
2935
  }
2936
+ if (types.includes("ERROR")) {
2937
+ symbols.push(65535);
2938
+ }
2949
2939
  const symbolsAddress = C._malloc(SIZE_OF_INT * symbols.length);
2950
2940
  for (let i2 = 0, n = symbols.length; i2 < n; i2++) {
2951
2941
  C.setValue(symbolsAddress + i2 * SIZE_OF_INT, symbols[i2], "i32");
@@ -3100,31 +3090,9 @@ var init_web_tree_sitter = __esm({
3100
3090
  * you want to keep and continue to use after an edit.
3101
3091
  */
3102
3092
  edit(edit) {
3103
- if (this.startIndex >= edit.oldEndIndex) {
3104
- this.startIndex = edit.newEndIndex + (this.startIndex - edit.oldEndIndex);
3105
- let subbedPointRow;
3106
- let subbedPointColumn;
3107
- if (this.startPosition.row > edit.oldEndPosition.row) {
3108
- subbedPointRow = this.startPosition.row - edit.oldEndPosition.row;
3109
- subbedPointColumn = this.startPosition.column;
3110
- } else {
3111
- subbedPointRow = 0;
3112
- subbedPointColumn = this.startPosition.column;
3113
- if (this.startPosition.column >= edit.oldEndPosition.column) {
3114
- subbedPointColumn = this.startPosition.column - edit.oldEndPosition.column;
3115
- }
3116
- }
3117
- if (subbedPointRow > 0) {
3118
- this.startPosition.row += subbedPointRow;
3119
- this.startPosition.column = subbedPointColumn;
3120
- } else {
3121
- this.startPosition.column += subbedPointColumn;
3122
- }
3123
- } else if (this.startIndex > edit.startIndex) {
3124
- this.startIndex = edit.newEndIndex;
3125
- this.startPosition.row = edit.newEndPosition.row;
3126
- this.startPosition.column = edit.newEndPosition.column;
3127
- }
3093
+ const { point, index } = edit.editPoint(this.startPosition, this.startIndex);
3094
+ this.startPosition = point;
3095
+ this.startIndex = index;
3128
3096
  }
3129
3097
  /** Get the S-expression representation of this node. */
3130
3098
  toString() {
@@ -3645,6 +3613,7 @@ ${JSON.stringify(symbolNames, null, 2)}`);
3645
3613
  __name(parseIsPredicate, "parseIsPredicate");
3646
3614
  __name(parseSetDirective, "parseSetDirective");
3647
3615
  __name(parsePattern, "parsePattern");
3616
+ __name(indexForByteOffset, "indexForByteOffset");
3648
3617
  finalizer5 = newFinalizer((address) => {
3649
3618
  C._ts_query_delete(address);
3650
3619
  });
@@ -3659,6 +3628,8 @@ ${JSON.stringify(symbolNames, null, 2)}`);
3659
3628
  exceededMatchLimit;
3660
3629
  /** @internal */
3661
3630
  textPredicates;
3631
+ /** @internal */
3632
+ source;
3662
3633
  /** The names of the captures used in the query. */
3663
3634
  captureNames;
3664
3635
  /** The quantifiers of the captures used in the query. */
@@ -3797,6 +3768,7 @@ ${JSON.stringify(symbolNames, null, 2)}`);
3797
3768
  this.captureNames = captureNames;
3798
3769
  this.captureQuantifiers = captureQuantifiers;
3799
3770
  this.textPredicates = textPredicates;
3771
+ this.source = source;
3800
3772
  this.predicates = predicates;
3801
3773
  this.setProperties = setProperties;
3802
3774
  this.assertedProperties = assertedProperties;
@@ -4033,23 +4005,25 @@ ${JSON.stringify(symbolNames, null, 2)}`);
4033
4005
  didExceedMatchLimit() {
4034
4006
  return this.exceededMatchLimit;
4035
4007
  }
4036
- /** Get the byte offset where the given pattern starts in the query's source. */
4008
+ /** Get the index where the given pattern starts in the query's source. */
4037
4009
  startIndexForPattern(patternIndex) {
4038
4010
  if (patternIndex >= this.predicates.length) {
4039
4011
  throw new Error(
4040
4012
  `Pattern index is ${patternIndex} but the pattern count is ${this.predicates.length}`
4041
4013
  );
4042
4014
  }
4043
- return C._ts_query_start_byte_for_pattern(this[0], patternIndex);
4015
+ const byteOffset = C._ts_query_start_byte_for_pattern(this[0], patternIndex);
4016
+ return indexForByteOffset(this.source, byteOffset);
4044
4017
  }
4045
- /** Get the byte offset where the given pattern ends in the query's source. */
4018
+ /** Get the index where the given pattern ends in the query's source. */
4046
4019
  endIndexForPattern(patternIndex) {
4047
4020
  if (patternIndex >= this.predicates.length) {
4048
4021
  throw new Error(
4049
4022
  `Pattern index is ${patternIndex} but the pattern count is ${this.predicates.length}`
4050
4023
  );
4051
4024
  }
4052
- return C._ts_query_end_byte_for_pattern(this[0], patternIndex);
4025
+ const byteOffset = C._ts_query_end_byte_for_pattern(this[0], patternIndex);
4026
+ return indexForByteOffset(this.source, byteOffset);
4053
4027
  }
4054
4028
  /** Get the number of patterns in the query. */
4055
4029
  patternCount() {
@@ -4068,13 +4042,14 @@ ${JSON.stringify(symbolNames, null, 2)}`);
4068
4042
  return C._ts_query_is_pattern_non_local(this[0], patternIndex) === 1;
4069
4043
  }
4070
4044
  /**
4071
- * Check if a given step in a query is 'definite'.
4045
+ * Check if the step at the given index in the query's source is 'definite'.
4072
4046
  *
4073
4047
  * A query step is 'definite' if its parent pattern will be guaranteed to
4074
4048
  * match successfully once it reaches the step.
4075
4049
  */
4076
- isPatternGuaranteedAtStep(byteIndex) {
4077
- return C._ts_query_is_pattern_guaranteed_at_step(this[0], byteIndex) === 1;
4050
+ isPatternGuaranteedAtStep(index) {
4051
+ const byteOffset = C.lengthBytesUTF8(this.source.slice(0, index));
4052
+ return C._ts_query_is_pattern_guaranteed_at_step(this[0], byteOffset) === 1;
4078
4053
  }
4079
4054
  };
4080
4055
  }
@@ -8885,6 +8860,7 @@ function extractJavaImports(tree, cache) {
8885
8860
  function extractJSImportInfo(node) {
8886
8861
  const imports = [];
8887
8862
  const lineNumber = node.startPosition.row + 1;
8863
+ const statementTypeOnly = hasTypeKeyword(node);
8888
8864
  const sourceNode = node.childForFieldName("source");
8889
8865
  const fromPackage = sourceNode ? getNodeText(sourceNode).replace(/['"]/g, "") : null;
8890
8866
  if (!node.childForFieldName("import_clause") && !node.childForFieldName("namespace_import")) {
@@ -8957,7 +8933,8 @@ function extractJSImportInfo(node) {
8957
8933
  from_package: fromPackage,
8958
8934
  alias,
8959
8935
  is_wildcard: false,
8960
- line_number: lineNumber
8936
+ line_number: lineNumber,
8937
+ ...hasTypeKeyword(specifier) ? { is_type_only: true } : {}
8961
8938
  });
8962
8939
  }
8963
8940
  }
@@ -9011,7 +8988,8 @@ function extractJSImportInfo(node) {
9011
8988
  from_package: fromPackage,
9012
8989
  alias,
9013
8990
  is_wildcard: false,
9014
- line_number: lineNumber
8991
+ line_number: lineNumber,
8992
+ ...hasTypeKeyword(specifier) ? { is_type_only: true } : {}
9015
8993
  });
9016
8994
  }
9017
8995
  }
@@ -9019,7 +8997,14 @@ function extractJSImportInfo(node) {
9019
8997
  }
9020
8998
  }
9021
8999
  }
9022
- return imports;
9000
+ return statementTypeOnly ? imports.map((imp) => ({ ...imp, is_type_only: true })) : imports;
9001
+ }
9002
+ function hasTypeKeyword(node) {
9003
+ for (let i2 = 0; i2 < node.childCount; i2++) {
9004
+ const child = node.child(i2);
9005
+ if (child && !child.isNamed && child.type === "type") return true;
9006
+ }
9007
+ return false;
9023
9008
  }
9024
9009
  function findRequireCalls(tree, cache) {
9025
9010
  const imports = [];
@@ -16252,6 +16237,12 @@ var DEFAULT_SANITIZERS = [
16252
16237
  // `code_injection` categorization that `re.compile` currently emits
16253
16238
  // (a re.escape-wrapped pattern cannot execute anything, so both are safe).
16254
16239
  { method: "escape", class: "re", removes: ["redos", "code_injection"] },
16240
+ // JS/TS ReDoS — escaping a request value before `new RegExp(...)` makes it a
16241
+ // literal: lodash `_.escapeRegExp`, the `escape-string-regexp` package, and
16242
+ // the common local helper names.
16243
+ { method: "escapeRegExp", removes: ["redos"] },
16244
+ { method: "escapeStringRegexp", removes: ["redos"] },
16245
+ { method: "escapeRegex", removes: ["redos"] },
16255
16246
  // Python SQLAlchemy — `text(...).bindparams(...)` binds params safely.
16256
16247
  // The `bindparams` call is the sanitizer; the parent `text` wraps the
16257
16248
  // template. Also add `expression.literal` for explicit SQL literals.