cognium-dev 4.9.19 → 4.9.21
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.
- package/dist/cli.js +96 -72
- package/package.json +10 -7
package/dist/cli.js
CHANGED
|
@@ -113,44 +113,65 @@ function setModule(module2) {
|
|
|
113
113
|
}
|
|
114
114
|
__name(setModule, "setModule");
|
|
115
115
|
var C;
|
|
116
|
+
function newFinalizer(handler) {
|
|
117
|
+
try {
|
|
118
|
+
return new FinalizationRegistry(handler);
|
|
119
|
+
} catch (e) {
|
|
120
|
+
console.error("Unsupported FinalizationRegistry:", e);
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
__name(newFinalizer, "newFinalizer");
|
|
125
|
+
var finalizer = newFinalizer((address) => {
|
|
126
|
+
C._ts_lookahead_iterator_delete(address);
|
|
127
|
+
});
|
|
116
128
|
var LookaheadIterator = class {
|
|
117
129
|
static {
|
|
118
130
|
__name(this, "LookaheadIterator");
|
|
119
131
|
}
|
|
120
132
|
[0] = 0;
|
|
121
133
|
language;
|
|
134
|
+
positioned = false;
|
|
122
135
|
constructor(internal, address, language) {
|
|
123
136
|
assertInternal(internal);
|
|
124
137
|
this[0] = address;
|
|
125
138
|
this.language = language;
|
|
139
|
+
finalizer?.register(this, address, this);
|
|
126
140
|
}
|
|
127
141
|
get currentTypeId() {
|
|
128
|
-
return C._ts_lookahead_iterator_current_symbol(this[0]);
|
|
142
|
+
return this.positioned ? C._ts_lookahead_iterator_current_symbol(this[0]) : null;
|
|
129
143
|
}
|
|
130
144
|
get currentType() {
|
|
131
|
-
|
|
145
|
+
const id = this.currentTypeId;
|
|
146
|
+
if (id === null)
|
|
147
|
+
return null;
|
|
148
|
+
return this.language.types[id] ?? C.UTF8ToString(C._ts_language_symbol_name(this.language[0], id));
|
|
132
149
|
}
|
|
133
150
|
delete() {
|
|
151
|
+
finalizer?.unregister(this);
|
|
134
152
|
C._ts_lookahead_iterator_delete(this[0]);
|
|
135
153
|
this[0] = 0;
|
|
136
154
|
}
|
|
137
155
|
reset(language, stateId) {
|
|
138
156
|
if (C._ts_lookahead_iterator_reset(this[0], language[0], stateId)) {
|
|
139
157
|
this.language = language;
|
|
158
|
+
this.positioned = false;
|
|
140
159
|
return true;
|
|
141
160
|
}
|
|
142
161
|
return false;
|
|
143
162
|
}
|
|
144
163
|
resetState(stateId) {
|
|
145
|
-
|
|
164
|
+
if (!C._ts_lookahead_iterator_reset_state(this[0], stateId))
|
|
165
|
+
return false;
|
|
166
|
+
this.positioned = false;
|
|
167
|
+
return true;
|
|
146
168
|
}
|
|
147
169
|
[Symbol.iterator]() {
|
|
148
170
|
return {
|
|
149
171
|
next: /* @__PURE__ */ __name(() => {
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
}
|
|
153
|
-
return { done: true, value: "" };
|
|
172
|
+
this.positioned = Boolean(C._ts_lookahead_iterator_next(this[0]));
|
|
173
|
+
const value = this.currentType;
|
|
174
|
+
return value === null ? { done: true, value: "" } : { done: false, value };
|
|
154
175
|
}, "next")
|
|
155
176
|
};
|
|
156
177
|
}
|
|
@@ -176,6 +197,9 @@ function getText(tree, startIndex, endIndex, startPosition) {
|
|
|
176
197
|
return result ?? "";
|
|
177
198
|
}
|
|
178
199
|
__name(getText, "getText");
|
|
200
|
+
var finalizer2 = newFinalizer((address) => {
|
|
201
|
+
C._ts_tree_delete(address);
|
|
202
|
+
});
|
|
179
203
|
var Tree = class _Tree {
|
|
180
204
|
static {
|
|
181
205
|
__name(this, "Tree");
|
|
@@ -188,12 +212,14 @@ var Tree = class _Tree {
|
|
|
188
212
|
this[0] = address;
|
|
189
213
|
this.language = language;
|
|
190
214
|
this.textCallback = textCallback;
|
|
215
|
+
finalizer2?.register(this, address, this);
|
|
191
216
|
}
|
|
192
217
|
copy() {
|
|
193
218
|
const address = C._ts_tree_copy(this[0]);
|
|
194
219
|
return new _Tree(INTERNAL, address, this.language, this.textCallback);
|
|
195
220
|
}
|
|
196
221
|
delete() {
|
|
222
|
+
finalizer2?.unregister(this);
|
|
197
223
|
C._ts_tree_delete(this[0]);
|
|
198
224
|
this[0] = 0;
|
|
199
225
|
}
|
|
@@ -249,6 +275,9 @@ var Tree = class _Tree {
|
|
|
249
275
|
return result;
|
|
250
276
|
}
|
|
251
277
|
};
|
|
278
|
+
var finalizer3 = newFinalizer((address) => {
|
|
279
|
+
C._ts_tree_cursor_delete_wasm(address);
|
|
280
|
+
});
|
|
252
281
|
var TreeCursor = class _TreeCursor {
|
|
253
282
|
static {
|
|
254
283
|
__name(this, "TreeCursor");
|
|
@@ -262,6 +291,7 @@ var TreeCursor = class _TreeCursor {
|
|
|
262
291
|
assertInternal(internal);
|
|
263
292
|
this.tree = tree;
|
|
264
293
|
unmarshalTreeCursor(this);
|
|
294
|
+
finalizer3?.register(this, this.tree[0], this);
|
|
265
295
|
}
|
|
266
296
|
copy() {
|
|
267
297
|
const copy = new _TreeCursor(INTERNAL, this.tree);
|
|
@@ -270,6 +300,7 @@ var TreeCursor = class _TreeCursor {
|
|
|
270
300
|
return copy;
|
|
271
301
|
}
|
|
272
302
|
delete() {
|
|
303
|
+
finalizer3?.unregister(this);
|
|
273
304
|
marshalTreeCursor(this);
|
|
274
305
|
C._ts_tree_cursor_delete_wasm(this.tree[0]);
|
|
275
306
|
this[0] = this[1] = this[2] = 0;
|
|
@@ -1029,16 +1060,23 @@ ${body2}`);
|
|
|
1029
1060
|
}
|
|
1030
1061
|
}
|
|
1031
1062
|
const mod = await C.loadWebAssemblyModule(binary2, { loadAsync: true });
|
|
1063
|
+
return _Language.loadFromWasmExports(mod, { sync: false });
|
|
1064
|
+
}
|
|
1065
|
+
static loadFromWasmExports(mod, { sync }) {
|
|
1032
1066
|
const symbolNames = Object.keys(mod);
|
|
1033
1067
|
const functionName = symbolNames.find((key) => LANGUAGE_FUNCTION_REGEX.test(key) && !key.includes("external_scanner_"));
|
|
1034
1068
|
if (!functionName) {
|
|
1035
1069
|
console.log(`Couldn't find language function in Wasm file. Symbols:
|
|
1036
1070
|
${JSON.stringify(symbolNames, null, 2)}`);
|
|
1037
|
-
throw new Error("
|
|
1071
|
+
throw new Error(`Language.${sync ? "loadSync" : "load"} failed: no language function found in Wasm file`);
|
|
1038
1072
|
}
|
|
1039
1073
|
const languageAddress = mod[functionName]();
|
|
1040
1074
|
return new _Language(INTERNAL, languageAddress);
|
|
1041
1075
|
}
|
|
1076
|
+
static loadSync(wasmModule) {
|
|
1077
|
+
const mod = C.loadWebAssemblyModule(wasmModule, { loadAsync: false });
|
|
1078
|
+
return _Language.loadFromWasmExports(mod, { sync: true });
|
|
1079
|
+
}
|
|
1042
1080
|
};
|
|
1043
1081
|
async function Module2(moduleArg = {}) {
|
|
1044
1082
|
var moduleRtn;
|
|
@@ -1558,7 +1596,7 @@ async function Module2(moduleArg = {}) {
|
|
|
1558
1596
|
newDSO("__main__", 0, wasmImports);
|
|
1559
1597
|
}
|
|
1560
1598
|
};
|
|
1561
|
-
var ___heap_base =
|
|
1599
|
+
var ___heap_base = 82240;
|
|
1562
1600
|
var alignMemory = /* @__PURE__ */ __name((size, alignment) => Math.ceil(size / alignment) * alignment, "alignMemory");
|
|
1563
1601
|
var getMemory = /* @__PURE__ */ __name((size) => {
|
|
1564
1602
|
if (runtimeInitialized) {
|
|
@@ -2084,12 +2122,12 @@ async function Module2(moduleArg = {}) {
|
|
|
2084
2122
|
value: "i32",
|
|
2085
2123
|
mutable: false
|
|
2086
2124
|
}, 1024);
|
|
2087
|
-
var ___stack_high =
|
|
2088
|
-
var ___stack_low =
|
|
2125
|
+
var ___stack_high = 82240;
|
|
2126
|
+
var ___stack_low = 16704;
|
|
2089
2127
|
var ___stack_pointer = new WebAssembly.Global({
|
|
2090
2128
|
value: "i32",
|
|
2091
2129
|
mutable: true
|
|
2092
|
-
},
|
|
2130
|
+
}, 82240);
|
|
2093
2131
|
var ___table_base = new WebAssembly.Global({
|
|
2094
2132
|
value: "i32",
|
|
2095
2133
|
mutable: false
|
|
@@ -2356,7 +2394,7 @@ async function Module2(moduleArg = {}) {
|
|
|
2356
2394
|
Module["loadWebAssemblyModule"] = loadWebAssemblyModule;
|
|
2357
2395
|
Module["LE_HEAP_STORE_I64"] = LE_HEAP_STORE_I64;
|
|
2358
2396
|
var ASM_CONSTS = {};
|
|
2359
|
-
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_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, _iswupper, _iswxdigit, _memchr, _strlen, _strcmp, _strncat, _strncpy, _towlower, _towupper, _setThrew, __emscripten_stack_restore, __emscripten_stack_alloc, _emscripten_stack_get_current, ___wasm_apply_data_relocs;
|
|
2397
|
+
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;
|
|
2360
2398
|
function assignWasmExports(wasmExports2) {
|
|
2361
2399
|
Module["_malloc"] = _malloc = wasmExports2["malloc"];
|
|
2362
2400
|
Module["_calloc"] = _calloc = wasmExports2["calloc"];
|
|
@@ -2390,6 +2428,7 @@ async function Module2(moduleArg = {}) {
|
|
|
2390
2428
|
Module["_ts_query_delete"] = _ts_query_delete = wasmExports2["ts_query_delete"];
|
|
2391
2429
|
Module["_iswspace"] = _iswspace = wasmExports2["iswspace"];
|
|
2392
2430
|
Module["_iswalnum"] = _iswalnum = wasmExports2["iswalnum"];
|
|
2431
|
+
Module["_ts_query_copy"] = _ts_query_copy = wasmExports2["ts_query_copy"];
|
|
2393
2432
|
Module["_ts_query_pattern_count"] = _ts_query_pattern_count = wasmExports2["ts_query_pattern_count"];
|
|
2394
2433
|
Module["_ts_query_capture_count"] = _ts_query_capture_count = wasmExports2["ts_query_capture_count"];
|
|
2395
2434
|
Module["_ts_query_string_count"] = _ts_query_string_count = wasmExports2["ts_query_string_count"];
|
|
@@ -2495,6 +2534,7 @@ async function Module2(moduleArg = {}) {
|
|
|
2495
2534
|
Module["_iswblank"] = _iswblank = wasmExports2["iswblank"];
|
|
2496
2535
|
Module["_iswdigit"] = _iswdigit = wasmExports2["iswdigit"];
|
|
2497
2536
|
Module["_iswlower"] = _iswlower = wasmExports2["iswlower"];
|
|
2537
|
+
Module["_iswpunct"] = _iswpunct = wasmExports2["iswpunct"];
|
|
2498
2538
|
Module["_iswupper"] = _iswupper = wasmExports2["iswupper"];
|
|
2499
2539
|
Module["_iswxdigit"] = _iswxdigit = wasmExports2["iswxdigit"];
|
|
2500
2540
|
Module["_memchr"] = _memchr = wasmExports2["memchr"];
|
|
@@ -2614,6 +2654,10 @@ __name(checkModule, "checkModule");
|
|
|
2614
2654
|
var TRANSFER_BUFFER;
|
|
2615
2655
|
var LANGUAGE_VERSION;
|
|
2616
2656
|
var MIN_COMPATIBLE_VERSION;
|
|
2657
|
+
var finalizer4 = newFinalizer((addresses) => {
|
|
2658
|
+
C._ts_parser_delete(addresses[0]);
|
|
2659
|
+
C._free(addresses[1]);
|
|
2660
|
+
});
|
|
2617
2661
|
var Parser = class {
|
|
2618
2662
|
static {
|
|
2619
2663
|
__name(this, "Parser");
|
|
@@ -2630,6 +2674,7 @@ var Parser = class {
|
|
|
2630
2674
|
}
|
|
2631
2675
|
constructor() {
|
|
2632
2676
|
this.initialize();
|
|
2677
|
+
finalizer4?.register(this, [this[0], this[1]], this);
|
|
2633
2678
|
}
|
|
2634
2679
|
initialize() {
|
|
2635
2680
|
if (!checkModule()) {
|
|
@@ -2640,6 +2685,7 @@ var Parser = class {
|
|
|
2640
2685
|
this[1] = C.getValue(TRANSFER_BUFFER + SIZE_OF_INT, "i32");
|
|
2641
2686
|
}
|
|
2642
2687
|
delete() {
|
|
2688
|
+
finalizer4?.unregister(this);
|
|
2643
2689
|
C._ts_parser_delete(this[0]);
|
|
2644
2690
|
C._free(this[1]);
|
|
2645
2691
|
this[0] = 0;
|
|
@@ -2770,6 +2816,10 @@ var QueryError = class _QueryError extends Error {
|
|
|
2770
2816
|
this.length = length;
|
|
2771
2817
|
this.name = "QueryError";
|
|
2772
2818
|
}
|
|
2819
|
+
kind;
|
|
2820
|
+
info;
|
|
2821
|
+
index;
|
|
2822
|
+
length;
|
|
2773
2823
|
static {
|
|
2774
2824
|
__name(this, "QueryError");
|
|
2775
2825
|
}
|
|
@@ -2953,6 +3003,9 @@ function parsePattern(index, stepType, stepValueId, captureNames, stringValues,
|
|
|
2953
3003
|
}
|
|
2954
3004
|
}
|
|
2955
3005
|
__name(parsePattern, "parsePattern");
|
|
3006
|
+
var finalizer5 = newFinalizer((address) => {
|
|
3007
|
+
C._ts_query_delete(address);
|
|
3008
|
+
});
|
|
2956
3009
|
var Query = class {
|
|
2957
3010
|
static {
|
|
2958
3011
|
__name(this, "Query");
|
|
@@ -3052,8 +3105,10 @@ var Query = class {
|
|
|
3052
3105
|
this.assertedProperties = assertedProperties;
|
|
3053
3106
|
this.refutedProperties = refutedProperties;
|
|
3054
3107
|
this.exceededMatchLimit = false;
|
|
3108
|
+
finalizer5?.register(this, address, this);
|
|
3055
3109
|
}
|
|
3056
3110
|
delete() {
|
|
3111
|
+
finalizer5?.unregister(this);
|
|
3057
3112
|
C._ts_query_delete(this[0]);
|
|
3058
3113
|
this[0] = 0;
|
|
3059
3114
|
}
|
|
@@ -8583,7 +8638,7 @@ function buildBashCFG(tree, startId, cache) {
|
|
|
8583
8638
|
allEdges.push({ from: entryBlock.id, to: firstBlockId, type: "sequential" });
|
|
8584
8639
|
}
|
|
8585
8640
|
const exitBlock = {
|
|
8586
|
-
id: blockIdCounter
|
|
8641
|
+
id: blockIdCounter,
|
|
8587
8642
|
type: "exit",
|
|
8588
8643
|
start_line: topLevelStatements[topLevelStatements.length - 1].endPosition.row + 1,
|
|
8589
8644
|
end_line: topLevelStatements[topLevelStatements.length - 1].endPosition.row + 1
|
|
@@ -8701,7 +8756,7 @@ function buildGoCFG(tree, blockIdCounter, cache) {
|
|
|
8701
8756
|
const hasTopLevelDecls = tree.rootNode.children.some((c) => c !== null && isGoStatement(c));
|
|
8702
8757
|
if (hasTopLevelDecls) {
|
|
8703
8758
|
const block = {
|
|
8704
|
-
id: blockIdCounter
|
|
8759
|
+
id: blockIdCounter,
|
|
8705
8760
|
type: "normal",
|
|
8706
8761
|
start_line: 1,
|
|
8707
8762
|
end_line: tree.rootNode.endPosition.row + 1
|
|
@@ -9746,7 +9801,7 @@ function buildRustDFG(tree, cache) {
|
|
|
9746
9801
|
const defs = [];
|
|
9747
9802
|
const uses = [];
|
|
9748
9803
|
let defIdCounter = 1;
|
|
9749
|
-
|
|
9804
|
+
const useIdCounter = 1;
|
|
9750
9805
|
const scopeStack = [new Map];
|
|
9751
9806
|
const functions = findNodes(tree.rootNode, "function_item");
|
|
9752
9807
|
for (const func2 of functions) {
|
|
@@ -10663,7 +10718,7 @@ function parsePythonDecorator(dec) {
|
|
|
10663
10718
|
if (!fnNode)
|
|
10664
10719
|
return null;
|
|
10665
10720
|
let receiver = "";
|
|
10666
|
-
let method
|
|
10721
|
+
let method;
|
|
10667
10722
|
if (fnNode.type === "identifier") {
|
|
10668
10723
|
method = getNodeText(fnNode);
|
|
10669
10724
|
} else if (fnNode.type === "attribute") {
|
|
@@ -10733,7 +10788,7 @@ function classifyPythonDecorator(receiver, method, imp) {
|
|
|
10733
10788
|
if (receiver && PY_HTTP_ROUTE_METHODS.has(method)) {
|
|
10734
10789
|
const isRoutey = isPyRouterReceiver(receiver);
|
|
10735
10790
|
if (isRoutey) {
|
|
10736
|
-
let framework
|
|
10791
|
+
let framework;
|
|
10737
10792
|
if (imp.hasFlask)
|
|
10738
10793
|
framework = "flask";
|
|
10739
10794
|
else if (imp.hasFastApi)
|
|
@@ -11128,12 +11183,6 @@ var DEFAULT_SOURCES = [
|
|
|
11128
11183
|
{ method: "getBody", class: "Exchange", type: "http_body", severity: "high", return_tainted: true },
|
|
11129
11184
|
{ method: "getIn", class: "Exchange", type: "http_body", severity: "high", return_tainted: true },
|
|
11130
11185
|
{ method: "getHeader", class: "Message", type: "http_header", severity: "high", return_tainted: true },
|
|
11131
|
-
{ method: "getFileName", type: "file_input", severity: "high", return_tainted: true },
|
|
11132
|
-
{ method: "getName", class: "File", type: "file_input", severity: "high", return_tainted: true },
|
|
11133
|
-
{ method: "getPath", class: "File", type: "file_input", severity: "high", return_tainted: true },
|
|
11134
|
-
{ method: "getAbsolutePath", class: "File", type: "file_input", severity: "high", return_tainted: true },
|
|
11135
|
-
{ method: "toString", class: "Path", type: "file_input", severity: "medium", return_tainted: true },
|
|
11136
|
-
{ method: "getFileName", class: "Path", type: "file_input", severity: "high", return_tainted: true },
|
|
11137
11186
|
{ method: "getOriginalFilename", class: "MultipartFile", type: "file_input", severity: "high", return_tainted: true },
|
|
11138
11187
|
{ method: "getName", class: "MultipartFile", type: "file_input", severity: "high", return_tainted: true },
|
|
11139
11188
|
{ method: "getSubmittedFileName", class: "Part", type: "file_input", severity: "high", return_tainted: true },
|
|
@@ -11204,7 +11253,6 @@ var DEFAULT_SOURCES = [
|
|
|
11204
11253
|
{ method: "refreshUsersAndGroups", type: "io_input", severity: "high", return_tainted: true },
|
|
11205
11254
|
{ method: "getScriptPath", type: "io_input", severity: "critical", return_tainted: true },
|
|
11206
11255
|
{ method: "getFilePathSuffix", type: "io_input", severity: "high", return_tainted: true },
|
|
11207
|
-
{ method: "getPath", type: "file_input", severity: "high", return_tainted: true },
|
|
11208
11256
|
{ method: "contentAsString", type: "file_input", severity: "critical", return_tainted: true },
|
|
11209
11257
|
{ method: "readAsString", type: "file_input", severity: "critical", return_tainted: true },
|
|
11210
11258
|
{ method: "content", type: "file_input", severity: "high", return_tainted: true },
|
|
@@ -19866,7 +19914,7 @@ class ConstantPropagator {
|
|
|
19866
19914
|
}
|
|
19867
19915
|
}
|
|
19868
19916
|
const startIdx = matchingIdx >= 0 ? matchingIdx : defaultIdx;
|
|
19869
|
-
for (let i2 = 0;i2 < startIdx
|
|
19917
|
+
for (let i2 = 0;i2 < startIdx; i2++) {
|
|
19870
19918
|
this.markUnreachable(caseGroups[i2]);
|
|
19871
19919
|
}
|
|
19872
19920
|
if (startIdx >= 0) {
|
|
@@ -24579,7 +24627,7 @@ class CrossFilePass {
|
|
|
24579
24627
|
const phase1Start = Date.now();
|
|
24580
24628
|
logger.debug("cross-file: phase 1/4 starting (findCrossFileTaintFlows)");
|
|
24581
24629
|
const flows = resolver.findCrossFileTaintFlows(budgetExceeded);
|
|
24582
|
-
|
|
24630
|
+
const phase1Truncated = budgetExceeded();
|
|
24583
24631
|
logger.info("cross-file: phase 1/4 done", {
|
|
24584
24632
|
flows: flows.length,
|
|
24585
24633
|
elapsedMs: Date.now() - phase1Start
|
|
@@ -28187,17 +28235,14 @@ function findPythonRegexAllowlistWrapperSanitizers(code) {
|
|
|
28187
28235
|
const argName = m[3];
|
|
28188
28236
|
let foundGuard = false;
|
|
28189
28237
|
let returnsArg = false;
|
|
28190
|
-
let blockEnd = -1;
|
|
28191
28238
|
const maxScan = Math.min(lines.length, i2 + 40);
|
|
28192
28239
|
for (let j = i2 + 1;j < maxScan; j++) {
|
|
28193
28240
|
const line = lines[j];
|
|
28194
28241
|
if (line.trim() === "")
|
|
28195
28242
|
continue;
|
|
28196
28243
|
const indent = line.length - line.trimStart().length;
|
|
28197
|
-
if (indent <= defIndent)
|
|
28198
|
-
blockEnd = j - 1;
|
|
28244
|
+
if (indent <= defIndent)
|
|
28199
28245
|
break;
|
|
28200
|
-
}
|
|
28201
28246
|
if (!foundGuard) {
|
|
28202
28247
|
const guard = new RegExp(`if\\s+not\\s+re\\.(?:fullmatch|match)\\s*\\(\\s*(${tightRegex.source})\\s*,\\s*${argName}\\s*\\)\\s*:`);
|
|
28203
28248
|
if (guard.test(line)) {
|
|
@@ -28218,8 +28263,6 @@ function findPythonRegexAllowlistWrapperSanitizers(code) {
|
|
|
28218
28263
|
returnsArg = true;
|
|
28219
28264
|
}
|
|
28220
28265
|
}
|
|
28221
|
-
if (blockEnd === -1)
|
|
28222
|
-
blockEnd = Math.min(lines.length - 1, i2 + 39);
|
|
28223
28266
|
if (!foundGuard || !returnsArg)
|
|
28224
28267
|
continue;
|
|
28225
28268
|
wrappers.push({ name: wrapperName, defLine: i2, defIndent });
|
|
@@ -31268,7 +31311,7 @@ function findRustEvalCrateCodeInjectionFindings(code, file) {
|
|
|
31268
31311
|
continue;
|
|
31269
31312
|
if (arg.length === 0)
|
|
31270
31313
|
continue;
|
|
31271
|
-
|
|
31314
|
+
const unwrapped = arg.replace(/^&\s*/, "").trim();
|
|
31272
31315
|
if (/^"[^"]*"$/.test(unwrapped))
|
|
31273
31316
|
continue;
|
|
31274
31317
|
let tainted = false;
|
|
@@ -31955,7 +31998,7 @@ function findJsLdapInjectionFindings(code, file) {
|
|
|
31955
31998
|
for (let i2 = 0;i2 < lines.length; i2++) {
|
|
31956
31999
|
const line = lines[i2];
|
|
31957
32000
|
const fm = line.match(filterPropRe);
|
|
31958
|
-
let expr
|
|
32001
|
+
let expr;
|
|
31959
32002
|
if (fm) {
|
|
31960
32003
|
expr = fm[1].trim();
|
|
31961
32004
|
} else if (filterShorthandRe.test(line)) {
|
|
@@ -34721,7 +34764,7 @@ class SinkFilterPass {
|
|
|
34721
34764
|
if (/^-?\d+$/.test(t) || /^"(?:[^"\\]|\\.)*"$/.test(t) || /^'(?:[^'\\]|\\.)*'$/.test(t)) {
|
|
34722
34765
|
continue;
|
|
34723
34766
|
}
|
|
34724
|
-
let helperName
|
|
34767
|
+
let helperName;
|
|
34725
34768
|
const directCall = t.match(/^([A-Za-z_]\w*)\s*\(/);
|
|
34726
34769
|
if (directCall) {
|
|
34727
34770
|
helperName = directCall[1] ?? null;
|
|
@@ -40854,7 +40897,7 @@ function buildSourceCoveredRanges(codeLines, language) {
|
|
|
40854
40897
|
function buildJsCoveredRanges(codeLines) {
|
|
40855
40898
|
const ranges = [];
|
|
40856
40899
|
const tryStack = [];
|
|
40857
|
-
|
|
40900
|
+
const braceDepthAtTry = [];
|
|
40858
40901
|
let braceDepth = 0;
|
|
40859
40902
|
for (let i2 = 0;i2 < codeLines.length; i2++) {
|
|
40860
40903
|
const line = codeLines[i2];
|
|
@@ -40928,10 +40971,6 @@ class UnhandledExceptionPass {
|
|
|
40928
40971
|
coveredRanges.push(range);
|
|
40929
40972
|
}
|
|
40930
40973
|
}
|
|
40931
|
-
const catchStarts = new Set(exGraph.pairs.map((p) => p.catchBlock.start_line));
|
|
40932
|
-
for (const range of coveredRanges) {
|
|
40933
|
-
catchStarts.add(range.end + 1);
|
|
40934
|
-
}
|
|
40935
40974
|
const throwRe = language === "python" ? PYTHON_RAISE_RE : JS_THROW_RE;
|
|
40936
40975
|
const unhandled = [];
|
|
40937
40976
|
const reportedMethods = new Set;
|
|
@@ -40940,13 +40979,6 @@ class UnhandledExceptionPass {
|
|
|
40940
40979
|
if (!throwRe.test(lineText))
|
|
40941
40980
|
continue;
|
|
40942
40981
|
let inCatch = false;
|
|
40943
|
-
for (const cs of catchStarts) {
|
|
40944
|
-
if (ln >= cs) {
|
|
40945
|
-
inCatch = true;
|
|
40946
|
-
break;
|
|
40947
|
-
}
|
|
40948
|
-
}
|
|
40949
|
-
inCatch = false;
|
|
40950
40982
|
for (const pair of exGraph.pairs) {
|
|
40951
40983
|
if (ln >= pair.catchBlock.start_line) {
|
|
40952
40984
|
const mThrow = graph.methodAtLine(ln);
|
|
@@ -49745,7 +49777,7 @@ var colors = {
|
|
|
49745
49777
|
};
|
|
49746
49778
|
|
|
49747
49779
|
// src/version.ts
|
|
49748
|
-
var version = "4.9.
|
|
49780
|
+
var version = "4.9.21";
|
|
49749
49781
|
|
|
49750
49782
|
// src/formatters.ts
|
|
49751
49783
|
var LIBRARY_API_SURFACE_TAG2 = "library-api-surface:caller-responsibility";
|
|
@@ -50175,9 +50207,18 @@ function formatJSON(results, crossFileData, profileSummary) {
|
|
|
50175
50207
|
};
|
|
50176
50208
|
return JSON.stringify(output, null, 2);
|
|
50177
50209
|
}
|
|
50210
|
+
function physicalLocation(file, line) {
|
|
50211
|
+
const hasLine = Number.isInteger(line) && line >= 1;
|
|
50212
|
+
return {
|
|
50213
|
+
physicalLocation: {
|
|
50214
|
+
artifactLocation: { uri: file },
|
|
50215
|
+
...hasLine ? { region: { startLine: line } } : {}
|
|
50216
|
+
}
|
|
50217
|
+
};
|
|
50218
|
+
}
|
|
50178
50219
|
function formatSARIF(results, crossFileData, profileSummary) {
|
|
50179
50220
|
const sarif = {
|
|
50180
|
-
$schema: "https://raw.githubusercontent.com/oasis-tcs/sarif-spec/
|
|
50221
|
+
$schema: "https://raw.githubusercontent.com/oasis-tcs/sarif-spec/main/sarif-2.1/schema/sarif-schema-2.1.0.json",
|
|
50181
50222
|
version: "2.1.0",
|
|
50182
50223
|
runs: [
|
|
50183
50224
|
{
|
|
@@ -50242,14 +50283,7 @@ function generateSarifResults(results, crossFileData) {
|
|
|
50242
50283
|
ruleId: vuln.type.replace(/\s+/g, "-").toLowerCase(),
|
|
50243
50284
|
level: vuln.severity === "critical" || vuln.severity === "high" ? "error" : "warning",
|
|
50244
50285
|
message: { text: vuln.message },
|
|
50245
|
-
locations: [
|
|
50246
|
-
{
|
|
50247
|
-
physicalLocation: {
|
|
50248
|
-
artifactLocation: { uri: result.file },
|
|
50249
|
-
region: { startLine: vuln.line }
|
|
50250
|
-
}
|
|
50251
|
-
}
|
|
50252
|
-
],
|
|
50286
|
+
locations: [physicalLocation(result.file, vuln.line)],
|
|
50253
50287
|
properties: {
|
|
50254
50288
|
cwe: vuln.cwe,
|
|
50255
50289
|
severity: vuln.severity,
|
|
@@ -50268,22 +50302,12 @@ function generateSarifResults(results, crossFileData) {
|
|
|
50268
50302
|
message: {
|
|
50269
50303
|
text: `Cross-file taint flow from ${p.source.file}:${p.source.line} to ${p.sink.file}:${p.sink.line}`
|
|
50270
50304
|
},
|
|
50271
|
-
locations: [
|
|
50272
|
-
{
|
|
50273
|
-
physicalLocation: {
|
|
50274
|
-
artifactLocation: { uri: p.sink.file },
|
|
50275
|
-
region: { startLine: p.sink.line }
|
|
50276
|
-
}
|
|
50277
|
-
}
|
|
50278
|
-
],
|
|
50305
|
+
locations: [physicalLocation(p.sink.file, p.sink.line)],
|
|
50279
50306
|
relatedLocations: [
|
|
50280
50307
|
{
|
|
50281
50308
|
id: 0,
|
|
50282
50309
|
message: { text: "taint source" },
|
|
50283
|
-
physicalLocation
|
|
50284
|
-
artifactLocation: { uri: p.source.file },
|
|
50285
|
-
region: { startLine: p.source.line }
|
|
50286
|
-
}
|
|
50310
|
+
...physicalLocation(p.source.file, p.source.line)
|
|
50287
50311
|
}
|
|
50288
50312
|
],
|
|
50289
50313
|
properties: {
|
|
@@ -50298,8 +50322,8 @@ function generateSarifResults(results, crossFileData) {
|
|
|
50298
50322
|
|
|
50299
50323
|
// src/build-info.ts
|
|
50300
50324
|
var buildInfo = {
|
|
50301
|
-
gitSha: "
|
|
50302
|
-
builtAt: "2026-09-
|
|
50325
|
+
gitSha: "1ac1389",
|
|
50326
|
+
builtAt: "2026-09-21T17:09:28.224Z"
|
|
50303
50327
|
};
|
|
50304
50328
|
|
|
50305
50329
|
// src/utils/args.ts
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cognium-dev",
|
|
3
|
-
"version": "4.9.
|
|
3
|
+
"version": "4.9.21",
|
|
4
4
|
"description": "Static Application Security Testing CLI for detecting security vulnerabilities via taint tracking",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -14,9 +14,10 @@
|
|
|
14
14
|
"test": "bun test",
|
|
15
15
|
"clean": "rm -rf dist cognium-dev cognium-dev-* *.bun-build wasm",
|
|
16
16
|
"typecheck": "tsc --noEmit",
|
|
17
|
-
"version": "node -e \"const v = require('./package.json').version; require('fs').writeFileSync('src/version.ts', '/**\\n * Version information\\n *\\n * Kept in sync with package.json via the \\`version\\` npm lifecycle script.\\n * Do not edit manually
|
|
17
|
+
"version": "node -e \"const v = require('./package.json').version; require('fs').writeFileSync('src/version.ts', '/**\\n * Version information\\n *\\n * Kept in sync with package.json via the \\`version\\` npm lifecycle script.\\n * Do not edit manually — use \\`npm version patch|minor|major\\` instead.\\n */\\nexport const version = \\x27' + v + '\\x27;\\n')\" && git add src/version.ts",
|
|
18
18
|
"dogfood": "bun run src/cli.ts scan src/ -q",
|
|
19
|
-
"prepublishOnly": "bun run build"
|
|
19
|
+
"prepublishOnly": "bun run build",
|
|
20
|
+
"test:coverage": "bun test --coverage"
|
|
20
21
|
},
|
|
21
22
|
"keywords": [
|
|
22
23
|
"security",
|
|
@@ -66,11 +67,13 @@
|
|
|
66
67
|
},
|
|
67
68
|
"dependencies": {
|
|
68
69
|
"@cognium/project-profile-detect": "1.1.1",
|
|
69
|
-
"circle-ir": "4.9.
|
|
70
|
+
"circle-ir": "4.9.21"
|
|
70
71
|
},
|
|
71
72
|
"devDependencies": {
|
|
72
|
-
"@types/node": "^
|
|
73
|
-
"
|
|
74
|
-
"
|
|
73
|
+
"@types/node": "^26.6.1",
|
|
74
|
+
"ajv": "^8.17.1",
|
|
75
|
+
"ajv-draft-04": "^1.0.0",
|
|
76
|
+
"bun-types": "^1.4.2",
|
|
77
|
+
"typescript": "^7.0.2"
|
|
75
78
|
}
|
|
76
79
|
}
|