circle-ir 4.21.1 → 4.23.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.
- package/dist/analysis/config-loader.d.ts.map +1 -1
- package/dist/analysis/config-loader.js +12 -0
- package/dist/analysis/config-loader.js.map +1 -1
- package/dist/analysis/constant-propagation/patterns.d.ts +16 -8
- package/dist/analysis/constant-propagation/patterns.d.ts.map +1 -1
- package/dist/analysis/constant-propagation/patterns.js +18 -9
- package/dist/analysis/constant-propagation/patterns.js.map +1 -1
- package/dist/analysis/findings.d.ts.map +1 -1
- package/dist/analysis/findings.js +14 -6
- package/dist/analysis/findings.js.map +1 -1
- package/dist/analysis/passes/_js-crypto-binding.d.ts +53 -0
- package/dist/analysis/passes/_js-crypto-binding.d.ts.map +1 -0
- package/dist/analysis/passes/_js-crypto-binding.js +123 -0
- package/dist/analysis/passes/_js-crypto-binding.js.map +1 -0
- package/dist/analysis/passes/hardcoded-secret-argument-pass.d.ts +85 -0
- package/dist/analysis/passes/hardcoded-secret-argument-pass.d.ts.map +1 -0
- package/dist/analysis/passes/hardcoded-secret-argument-pass.js +351 -0
- package/dist/analysis/passes/hardcoded-secret-argument-pass.js.map +1 -0
- package/dist/analysis/passes/language-sources-pass.d.ts.map +1 -1
- package/dist/analysis/passes/language-sources-pass.js +53 -2
- package/dist/analysis/passes/language-sources-pass.js.map +1 -1
- package/dist/analysis/passes/missing-auth-middleware-pass.d.ts +56 -0
- package/dist/analysis/passes/missing-auth-middleware-pass.d.ts.map +1 -0
- package/dist/analysis/passes/missing-auth-middleware-pass.js +255 -0
- package/dist/analysis/passes/missing-auth-middleware-pass.js.map +1 -0
- package/dist/analysis/passes/prototype-pollution-pass.d.ts +78 -0
- package/dist/analysis/passes/prototype-pollution-pass.d.ts.map +1 -0
- package/dist/analysis/passes/prototype-pollution-pass.js +736 -0
- package/dist/analysis/passes/prototype-pollution-pass.js.map +1 -0
- package/dist/analysis/passes/redos-regex-literal-pass.d.ts +106 -0
- package/dist/analysis/passes/redos-regex-literal-pass.d.ts.map +1 -0
- package/dist/analysis/passes/redos-regex-literal-pass.js +637 -0
- package/dist/analysis/passes/redos-regex-literal-pass.js.map +1 -0
- package/dist/analysis/passes/scan-secrets-pass.d.ts +3 -0
- package/dist/analysis/passes/scan-secrets-pass.d.ts.map +1 -1
- package/dist/analysis/passes/scan-secrets-pass.js +3 -3
- package/dist/analysis/passes/scan-secrets-pass.js.map +1 -1
- package/dist/analysis/passes/sink-filter-pass.d.ts.map +1 -1
- package/dist/analysis/passes/sink-filter-pass.js +4 -3
- package/dist/analysis/passes/sink-filter-pass.js.map +1 -1
- package/dist/analysis/passes/taint-propagation-pass.d.ts.map +1 -1
- package/dist/analysis/passes/taint-propagation-pass.js +100 -11
- package/dist/analysis/passes/taint-propagation-pass.js.map +1 -1
- package/dist/analysis/passes/weak-crypto-pass.d.ts.map +1 -1
- package/dist/analysis/passes/weak-crypto-pass.js +7 -1
- package/dist/analysis/passes/weak-crypto-pass.js.map +1 -1
- package/dist/analysis/passes/weak-hash-pass.d.ts.map +1 -1
- package/dist/analysis/passes/weak-hash-pass.js +7 -1
- package/dist/analysis/passes/weak-hash-pass.js.map +1 -1
- package/dist/analysis/passes/weak-password-hash-pass.d.ts.map +1 -1
- package/dist/analysis/passes/weak-password-hash-pass.js +7 -1
- package/dist/analysis/passes/weak-password-hash-pass.js.map +1 -1
- package/dist/analyzer.d.ts.map +1 -1
- package/dist/analyzer.js +12 -0
- package/dist/analyzer.js.map +1 -1
- package/dist/browser/circle-ir.js +1834 -154
- package/dist/core/circle-ir-core.cjs +114 -80
- package/dist/core/circle-ir-core.js +114 -80
- package/dist/core/extractors/imports.js +18 -1
- package/dist/core/extractors/imports.js.map +1 -1
- package/dist/types/index.d.ts +5 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/wasm/web-tree-sitter.wasm +0 -0
- package/docs/SPEC.md +1 -0
- package/package.json +2 -2
|
@@ -93,17 +93,17 @@ function unmarshalNode(tree, address = TRANSFER_BUFFER) {
|
|
|
93
93
|
});
|
|
94
94
|
return result;
|
|
95
95
|
}
|
|
96
|
-
function marshalTreeCursor(
|
|
97
|
-
C.setValue(address + 0 * SIZE_OF_INT,
|
|
98
|
-
C.setValue(address + 1 * SIZE_OF_INT,
|
|
99
|
-
C.setValue(address + 2 * SIZE_OF_INT,
|
|
100
|
-
C.setValue(address + 3 * SIZE_OF_INT,
|
|
101
|
-
}
|
|
102
|
-
function unmarshalTreeCursor(
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
96
|
+
function marshalTreeCursor({ handles }, address = TRANSFER_BUFFER) {
|
|
97
|
+
C.setValue(address + 0 * SIZE_OF_INT, handles[0], "i32");
|
|
98
|
+
C.setValue(address + 1 * SIZE_OF_INT, handles[1], "i32");
|
|
99
|
+
C.setValue(address + 2 * SIZE_OF_INT, handles[2], "i32");
|
|
100
|
+
C.setValue(address + 3 * SIZE_OF_INT, handles[3], "i32");
|
|
101
|
+
}
|
|
102
|
+
function unmarshalTreeCursor({ handles }) {
|
|
103
|
+
handles[0] = C.getValue(TRANSFER_BUFFER + 0 * SIZE_OF_INT, "i32");
|
|
104
|
+
handles[1] = C.getValue(TRANSFER_BUFFER + 1 * SIZE_OF_INT, "i32");
|
|
105
|
+
handles[2] = C.getValue(TRANSFER_BUFFER + 2 * SIZE_OF_INT, "i32");
|
|
106
|
+
handles[3] = C.getValue(TRANSFER_BUFFER + 3 * SIZE_OF_INT, "i32");
|
|
107
107
|
}
|
|
108
108
|
function marshalPoint(address, point) {
|
|
109
109
|
C.setValue(address, point.row, "i32");
|
|
@@ -1509,7 +1509,7 @@ async function Module2(moduleArg = {}) {
|
|
|
1509
1509
|
Module["loadWebAssemblyModule"] = loadWebAssemblyModule;
|
|
1510
1510
|
Module["LE_HEAP_STORE_I64"] = LE_HEAP_STORE_I64;
|
|
1511
1511
|
var ASM_CONSTS = {};
|
|
1512
|
-
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,
|
|
1512
|
+
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;
|
|
1513
1513
|
function assignWasmExports(wasmExports2) {
|
|
1514
1514
|
Module["_malloc"] = _malloc = wasmExports2["malloc"];
|
|
1515
1515
|
Module["_calloc"] = _calloc = wasmExports2["calloc"];
|
|
@@ -1526,6 +1526,7 @@ async function Module2(moduleArg = {}) {
|
|
|
1526
1526
|
Module["_ts_language_symbol_name"] = _ts_language_symbol_name = wasmExports2["ts_language_symbol_name"];
|
|
1527
1527
|
Module["_ts_language_symbol_for_name"] = _ts_language_symbol_for_name = wasmExports2["ts_language_symbol_for_name"];
|
|
1528
1528
|
Module["_strncmp"] = _strncmp = wasmExports2["strncmp"];
|
|
1529
|
+
Module["_strlen"] = _strlen = wasmExports2["strlen"];
|
|
1529
1530
|
Module["_ts_language_symbol_type"] = _ts_language_symbol_type = wasmExports2["ts_language_symbol_type"];
|
|
1530
1531
|
Module["_ts_language_field_name_for_id"] = _ts_language_field_name_for_id = wasmExports2["ts_language_field_name_for_id"];
|
|
1531
1532
|
Module["_ts_lookahead_iterator_new"] = _ts_lookahead_iterator_new = wasmExports2["ts_lookahead_iterator_new"];
|
|
@@ -1653,7 +1654,6 @@ async function Module2(moduleArg = {}) {
|
|
|
1653
1654
|
Module["_iswupper"] = _iswupper = wasmExports2["iswupper"];
|
|
1654
1655
|
Module["_iswxdigit"] = _iswxdigit = wasmExports2["iswxdigit"];
|
|
1655
1656
|
Module["_memchr"] = _memchr = wasmExports2["memchr"];
|
|
1656
|
-
Module["_strlen"] = _strlen = wasmExports2["strlen"];
|
|
1657
1657
|
Module["_strcmp"] = _strcmp = wasmExports2["strcmp"];
|
|
1658
1658
|
Module["_strncat"] = _strncat = wasmExports2["strncat"];
|
|
1659
1659
|
Module["_strncpy"] = _strncpy = wasmExports2["strncpy"];
|
|
@@ -1949,6 +1949,9 @@ function parsePattern(index, stepType, stepValueId, captureNames, stringValues,
|
|
|
1949
1949
|
steps.length = 0;
|
|
1950
1950
|
}
|
|
1951
1951
|
}
|
|
1952
|
+
function indexForByteOffset(source, byteOffset) {
|
|
1953
|
+
return new TextEncoder().encodeInto(source, new Uint8Array(byteOffset)).read;
|
|
1954
|
+
}
|
|
1952
1955
|
var __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;
|
|
1953
1956
|
var init_web_tree_sitter = __esm({
|
|
1954
1957
|
"../../node_modules/web-tree-sitter/web-tree-sitter.js"() {
|
|
@@ -2267,29 +2270,17 @@ var init_web_tree_sitter = __esm({
|
|
|
2267
2270
|
return result;
|
|
2268
2271
|
}
|
|
2269
2272
|
};
|
|
2270
|
-
finalizer3 = newFinalizer((
|
|
2271
|
-
|
|
2273
|
+
finalizer3 = newFinalizer((handles) => {
|
|
2274
|
+
marshalTreeCursor({ handles });
|
|
2275
|
+
C._ts_tree_cursor_delete_wasm(0);
|
|
2272
2276
|
});
|
|
2273
2277
|
TreeCursor = class _TreeCursor {
|
|
2274
2278
|
static {
|
|
2275
2279
|
__name(this, "TreeCursor");
|
|
2276
2280
|
}
|
|
2277
2281
|
/** @internal */
|
|
2278
|
-
|
|
2279
|
-
|
|
2280
|
-
// Internal handle for Wasm
|
|
2281
|
-
/** @internal */
|
|
2282
|
-
// @ts-expect-error: never read
|
|
2283
|
-
[1] = 0;
|
|
2284
|
-
// Internal handle for Wasm
|
|
2285
|
-
/** @internal */
|
|
2286
|
-
// @ts-expect-error: never read
|
|
2287
|
-
[2] = 0;
|
|
2288
|
-
// Internal handle for Wasm
|
|
2289
|
-
/** @internal */
|
|
2290
|
-
// @ts-expect-error: never read
|
|
2291
|
-
[3] = 0;
|
|
2292
|
-
// Internal handle for Wasm
|
|
2282
|
+
handles = [0, 0, 0, 0];
|
|
2283
|
+
// Internal handles for Wasm, shared with the finalizer.
|
|
2293
2284
|
/** @internal */
|
|
2294
2285
|
tree;
|
|
2295
2286
|
/** @internal */
|
|
@@ -2297,21 +2288,20 @@ var init_web_tree_sitter = __esm({
|
|
|
2297
2288
|
assertInternal(internal);
|
|
2298
2289
|
this.tree = tree;
|
|
2299
2290
|
unmarshalTreeCursor(this);
|
|
2300
|
-
finalizer3?.register(this, this.
|
|
2291
|
+
finalizer3?.register(this, this.handles, this);
|
|
2301
2292
|
}
|
|
2302
2293
|
/** Creates a deep copy of the tree cursor. This allocates new memory. */
|
|
2303
2294
|
copy() {
|
|
2304
|
-
|
|
2295
|
+
marshalTreeCursor(this);
|
|
2305
2296
|
C._ts_tree_cursor_copy_wasm(this.tree[0]);
|
|
2306
|
-
|
|
2307
|
-
return copy;
|
|
2297
|
+
return new _TreeCursor(INTERNAL, this.tree);
|
|
2308
2298
|
}
|
|
2309
2299
|
/** Delete the tree cursor, freeing its resources. */
|
|
2310
2300
|
delete() {
|
|
2311
2301
|
finalizer3?.unregister(this);
|
|
2312
2302
|
marshalTreeCursor(this);
|
|
2313
2303
|
C._ts_tree_cursor_delete_wasm(this.tree[0]);
|
|
2314
|
-
this
|
|
2304
|
+
this.handles.fill(0);
|
|
2315
2305
|
}
|
|
2316
2306
|
/** Get the tree cursor's current {@link Node}. */
|
|
2317
2307
|
get currentNode() {
|
|
@@ -2522,10 +2512,10 @@ var init_web_tree_sitter = __esm({
|
|
|
2522
2512
|
}
|
|
2523
2513
|
/**
|
|
2524
2514
|
* Move this cursor to the first child of its current node that contains or
|
|
2525
|
-
* starts after the given
|
|
2515
|
+
* starts after the given position.
|
|
2526
2516
|
*
|
|
2527
|
-
* This returns
|
|
2528
|
-
* `
|
|
2517
|
+
* This returns `true` if the cursor successfully moved to a child node, and returns
|
|
2518
|
+
* `false` if no such child was found.
|
|
2529
2519
|
*/
|
|
2530
2520
|
gotoFirstChildForPosition(goalPosition) {
|
|
2531
2521
|
marshalTreeCursor(this);
|
|
@@ -2541,8 +2531,9 @@ var init_web_tree_sitter = __esm({
|
|
|
2541
2531
|
reset(node) {
|
|
2542
2532
|
marshalNode(node);
|
|
2543
2533
|
marshalTreeCursor(this, TRANSFER_BUFFER + SIZE_OF_NODE);
|
|
2544
|
-
C._ts_tree_cursor_reset_wasm(
|
|
2534
|
+
C._ts_tree_cursor_reset_wasm(node.tree[0]);
|
|
2545
2535
|
unmarshalTreeCursor(this);
|
|
2536
|
+
this.tree = node.tree;
|
|
2546
2537
|
}
|
|
2547
2538
|
/**
|
|
2548
2539
|
* Re-initialize a tree cursor to the same position as another cursor.
|
|
@@ -2555,6 +2546,7 @@ var init_web_tree_sitter = __esm({
|
|
|
2555
2546
|
marshalTreeCursor(cursor, TRANSFER_BUFFER + SIZE_OF_CURSOR);
|
|
2556
2547
|
C._ts_tree_cursor_reset_to_wasm(this.tree[0], cursor.tree[0]);
|
|
2557
2548
|
unmarshalTreeCursor(this);
|
|
2549
|
+
this.tree = cursor.tree;
|
|
2558
2550
|
}
|
|
2559
2551
|
};
|
|
2560
2552
|
Node = class {
|
|
@@ -2913,16 +2905,14 @@ var init_web_tree_sitter = __esm({
|
|
|
2913
2905
|
if (!Array.isArray(types)) types = [types];
|
|
2914
2906
|
const symbols = [];
|
|
2915
2907
|
const typesBySymbol = this.tree.language.types;
|
|
2916
|
-
for (const node_type of types) {
|
|
2917
|
-
if (node_type == "ERROR") {
|
|
2918
|
-
symbols.push(65535);
|
|
2919
|
-
}
|
|
2920
|
-
}
|
|
2921
2908
|
for (let i2 = 0, n = typesBySymbol.length; i2 < n; i2++) {
|
|
2922
2909
|
if (types.includes(typesBySymbol[i2])) {
|
|
2923
2910
|
symbols.push(i2);
|
|
2924
2911
|
}
|
|
2925
2912
|
}
|
|
2913
|
+
if (types.includes("ERROR")) {
|
|
2914
|
+
symbols.push(65535);
|
|
2915
|
+
}
|
|
2926
2916
|
const symbolsAddress = C._malloc(SIZE_OF_INT * symbols.length);
|
|
2927
2917
|
for (let i2 = 0, n = symbols.length; i2 < n; i2++) {
|
|
2928
2918
|
C.setValue(symbolsAddress + i2 * SIZE_OF_INT, symbols[i2], "i32");
|
|
@@ -3077,31 +3067,9 @@ var init_web_tree_sitter = __esm({
|
|
|
3077
3067
|
* you want to keep and continue to use after an edit.
|
|
3078
3068
|
*/
|
|
3079
3069
|
edit(edit) {
|
|
3080
|
-
|
|
3081
|
-
|
|
3082
|
-
|
|
3083
|
-
let subbedPointColumn;
|
|
3084
|
-
if (this.startPosition.row > edit.oldEndPosition.row) {
|
|
3085
|
-
subbedPointRow = this.startPosition.row - edit.oldEndPosition.row;
|
|
3086
|
-
subbedPointColumn = this.startPosition.column;
|
|
3087
|
-
} else {
|
|
3088
|
-
subbedPointRow = 0;
|
|
3089
|
-
subbedPointColumn = this.startPosition.column;
|
|
3090
|
-
if (this.startPosition.column >= edit.oldEndPosition.column) {
|
|
3091
|
-
subbedPointColumn = this.startPosition.column - edit.oldEndPosition.column;
|
|
3092
|
-
}
|
|
3093
|
-
}
|
|
3094
|
-
if (subbedPointRow > 0) {
|
|
3095
|
-
this.startPosition.row += subbedPointRow;
|
|
3096
|
-
this.startPosition.column = subbedPointColumn;
|
|
3097
|
-
} else {
|
|
3098
|
-
this.startPosition.column += subbedPointColumn;
|
|
3099
|
-
}
|
|
3100
|
-
} else if (this.startIndex > edit.startIndex) {
|
|
3101
|
-
this.startIndex = edit.newEndIndex;
|
|
3102
|
-
this.startPosition.row = edit.newEndPosition.row;
|
|
3103
|
-
this.startPosition.column = edit.newEndPosition.column;
|
|
3104
|
-
}
|
|
3070
|
+
const { point, index } = edit.editPoint(this.startPosition, this.startIndex);
|
|
3071
|
+
this.startPosition = point;
|
|
3072
|
+
this.startIndex = index;
|
|
3105
3073
|
}
|
|
3106
3074
|
/** Get the S-expression representation of this node. */
|
|
3107
3075
|
toString() {
|
|
@@ -3622,6 +3590,7 @@ ${JSON.stringify(symbolNames, null, 2)}`);
|
|
|
3622
3590
|
__name(parseIsPredicate, "parseIsPredicate");
|
|
3623
3591
|
__name(parseSetDirective, "parseSetDirective");
|
|
3624
3592
|
__name(parsePattern, "parsePattern");
|
|
3593
|
+
__name(indexForByteOffset, "indexForByteOffset");
|
|
3625
3594
|
finalizer5 = newFinalizer((address) => {
|
|
3626
3595
|
C._ts_query_delete(address);
|
|
3627
3596
|
});
|
|
@@ -3636,6 +3605,8 @@ ${JSON.stringify(symbolNames, null, 2)}`);
|
|
|
3636
3605
|
exceededMatchLimit;
|
|
3637
3606
|
/** @internal */
|
|
3638
3607
|
textPredicates;
|
|
3608
|
+
/** @internal */
|
|
3609
|
+
source;
|
|
3639
3610
|
/** The names of the captures used in the query. */
|
|
3640
3611
|
captureNames;
|
|
3641
3612
|
/** The quantifiers of the captures used in the query. */
|
|
@@ -3774,6 +3745,7 @@ ${JSON.stringify(symbolNames, null, 2)}`);
|
|
|
3774
3745
|
this.captureNames = captureNames;
|
|
3775
3746
|
this.captureQuantifiers = captureQuantifiers;
|
|
3776
3747
|
this.textPredicates = textPredicates;
|
|
3748
|
+
this.source = source;
|
|
3777
3749
|
this.predicates = predicates;
|
|
3778
3750
|
this.setProperties = setProperties;
|
|
3779
3751
|
this.assertedProperties = assertedProperties;
|
|
@@ -4010,23 +3982,25 @@ ${JSON.stringify(symbolNames, null, 2)}`);
|
|
|
4010
3982
|
didExceedMatchLimit() {
|
|
4011
3983
|
return this.exceededMatchLimit;
|
|
4012
3984
|
}
|
|
4013
|
-
/** Get the
|
|
3985
|
+
/** Get the index where the given pattern starts in the query's source. */
|
|
4014
3986
|
startIndexForPattern(patternIndex) {
|
|
4015
3987
|
if (patternIndex >= this.predicates.length) {
|
|
4016
3988
|
throw new Error(
|
|
4017
3989
|
`Pattern index is ${patternIndex} but the pattern count is ${this.predicates.length}`
|
|
4018
3990
|
);
|
|
4019
3991
|
}
|
|
4020
|
-
|
|
3992
|
+
const byteOffset = C._ts_query_start_byte_for_pattern(this[0], patternIndex);
|
|
3993
|
+
return indexForByteOffset(this.source, byteOffset);
|
|
4021
3994
|
}
|
|
4022
|
-
/** Get the
|
|
3995
|
+
/** Get the index where the given pattern ends in the query's source. */
|
|
4023
3996
|
endIndexForPattern(patternIndex) {
|
|
4024
3997
|
if (patternIndex >= this.predicates.length) {
|
|
4025
3998
|
throw new Error(
|
|
4026
3999
|
`Pattern index is ${patternIndex} but the pattern count is ${this.predicates.length}`
|
|
4027
4000
|
);
|
|
4028
4001
|
}
|
|
4029
|
-
|
|
4002
|
+
const byteOffset = C._ts_query_end_byte_for_pattern(this[0], patternIndex);
|
|
4003
|
+
return indexForByteOffset(this.source, byteOffset);
|
|
4030
4004
|
}
|
|
4031
4005
|
/** Get the number of patterns in the query. */
|
|
4032
4006
|
patternCount() {
|
|
@@ -4045,13 +4019,14 @@ ${JSON.stringify(symbolNames, null, 2)}`);
|
|
|
4045
4019
|
return C._ts_query_is_pattern_non_local(this[0], patternIndex) === 1;
|
|
4046
4020
|
}
|
|
4047
4021
|
/**
|
|
4048
|
-
* Check if
|
|
4022
|
+
* Check if the step at the given index in the query's source is 'definite'.
|
|
4049
4023
|
*
|
|
4050
4024
|
* A query step is 'definite' if its parent pattern will be guaranteed to
|
|
4051
4025
|
* match successfully once it reaches the step.
|
|
4052
4026
|
*/
|
|
4053
|
-
isPatternGuaranteedAtStep(
|
|
4054
|
-
|
|
4027
|
+
isPatternGuaranteedAtStep(index) {
|
|
4028
|
+
const byteOffset = C.lengthBytesUTF8(this.source.slice(0, index));
|
|
4029
|
+
return C._ts_query_is_pattern_guaranteed_at_step(this[0], byteOffset) === 1;
|
|
4055
4030
|
}
|
|
4056
4031
|
};
|
|
4057
4032
|
}
|
|
@@ -8987,6 +8962,7 @@ function extractJavaImports(tree, cache) {
|
|
|
8987
8962
|
function extractJSImportInfo(node) {
|
|
8988
8963
|
const imports = [];
|
|
8989
8964
|
const lineNumber = node.startPosition.row + 1;
|
|
8965
|
+
const statementTypeOnly = hasTypeKeyword(node);
|
|
8990
8966
|
const sourceNode = node.childForFieldName("source");
|
|
8991
8967
|
const fromPackage = sourceNode ? getNodeText(sourceNode).replace(/['"]/g, "") : null;
|
|
8992
8968
|
if (!node.childForFieldName("import_clause") && !node.childForFieldName("namespace_import")) {
|
|
@@ -9059,7 +9035,8 @@ function extractJSImportInfo(node) {
|
|
|
9059
9035
|
from_package: fromPackage,
|
|
9060
9036
|
alias,
|
|
9061
9037
|
is_wildcard: false,
|
|
9062
|
-
line_number: lineNumber
|
|
9038
|
+
line_number: lineNumber,
|
|
9039
|
+
...hasTypeKeyword(specifier) ? { is_type_only: true } : {}
|
|
9063
9040
|
});
|
|
9064
9041
|
}
|
|
9065
9042
|
}
|
|
@@ -9113,7 +9090,8 @@ function extractJSImportInfo(node) {
|
|
|
9113
9090
|
from_package: fromPackage,
|
|
9114
9091
|
alias,
|
|
9115
9092
|
is_wildcard: false,
|
|
9116
|
-
line_number: lineNumber
|
|
9093
|
+
line_number: lineNumber,
|
|
9094
|
+
...hasTypeKeyword(specifier) ? { is_type_only: true } : {}
|
|
9117
9095
|
});
|
|
9118
9096
|
}
|
|
9119
9097
|
}
|
|
@@ -9121,7 +9099,14 @@ function extractJSImportInfo(node) {
|
|
|
9121
9099
|
}
|
|
9122
9100
|
}
|
|
9123
9101
|
}
|
|
9124
|
-
return imports;
|
|
9102
|
+
return statementTypeOnly ? imports.map((imp) => ({ ...imp, is_type_only: true })) : imports;
|
|
9103
|
+
}
|
|
9104
|
+
function hasTypeKeyword(node) {
|
|
9105
|
+
for (let i2 = 0; i2 < node.childCount; i2++) {
|
|
9106
|
+
const child = node.child(i2);
|
|
9107
|
+
if (child && !child.isNamed && child.type === "type") return true;
|
|
9108
|
+
}
|
|
9109
|
+
return false;
|
|
9125
9110
|
}
|
|
9126
9111
|
function findRequireCalls(tree, cache) {
|
|
9127
9112
|
const imports = [];
|
|
@@ -10978,13 +10963,13 @@ function processExpression(expr, startDefId, startUseId, scopeStack, isJavaScrip
|
|
|
10978
10963
|
const operand = expr.childForFieldName("operand") ?? expr.child(0) ?? expr.child(1);
|
|
10979
10964
|
if (operand && operand.type === "identifier") {
|
|
10980
10965
|
const name2 = getNodeText(operand);
|
|
10981
|
-
const
|
|
10966
|
+
const reachingDef2 = findReachingDef(name2, scopeStack);
|
|
10982
10967
|
const use = {
|
|
10983
10968
|
id: useId++,
|
|
10984
10969
|
variable: name2,
|
|
10985
10970
|
line: operand.startPosition.row + 1,
|
|
10986
10971
|
...jsColumn(operand, isJavaScript),
|
|
10987
|
-
def_id:
|
|
10972
|
+
def_id: reachingDef2
|
|
10988
10973
|
};
|
|
10989
10974
|
uses.push(use);
|
|
10990
10975
|
const def = {
|
|
@@ -11092,16 +11077,16 @@ function extractUses(node, startId, scopeStack, isJavaScript) {
|
|
|
11092
11077
|
if (parent.type === "inferred_parameters") return;
|
|
11093
11078
|
}
|
|
11094
11079
|
const name2 = getNodeText(n);
|
|
11095
|
-
const
|
|
11080
|
+
const reachingDef2 = findReachingDef(name2, scopeStack);
|
|
11096
11081
|
uses.push({
|
|
11097
11082
|
id: id++,
|
|
11098
11083
|
variable: name2,
|
|
11099
11084
|
line: n.startPosition.row + 1,
|
|
11100
11085
|
...jsColumn(n, isJavaScript),
|
|
11101
|
-
def_id:
|
|
11086
|
+
def_id: reachingDef2
|
|
11102
11087
|
});
|
|
11103
11088
|
for (const alt of findAlternateDefs(name2, scopeStack)) {
|
|
11104
|
-
if (alt ===
|
|
11089
|
+
if (alt === reachingDef2) continue;
|
|
11105
11090
|
uses.push({ id: id++, variable: name2, line: n.startPosition.row + 1, ...jsColumn(n, isJavaScript), def_id: alt });
|
|
11106
11091
|
}
|
|
11107
11092
|
}
|
|
@@ -11704,8 +11689,8 @@ function buildBashDFG(tree) {
|
|
|
11704
11689
|
if (varNameNode) {
|
|
11705
11690
|
const varName = getNodeText(varNameNode);
|
|
11706
11691
|
if (varName && !varName.startsWith("?") && !varName.startsWith("#")) {
|
|
11707
|
-
let
|
|
11708
|
-
if (
|
|
11692
|
+
let reachingDef2 = positionalDef(varName, node, findReachingDef(varName, scopeStack));
|
|
11693
|
+
if (reachingDef2 === null && !positionalParams.includes(varName)) {
|
|
11709
11694
|
const def = {
|
|
11710
11695
|
id: defIdCounter++,
|
|
11711
11696
|
variable: varName,
|
|
@@ -11714,13 +11699,13 @@ function buildBashDFG(tree) {
|
|
|
11714
11699
|
};
|
|
11715
11700
|
defs.push(def);
|
|
11716
11701
|
scopeStack[0].set(varName, def.id);
|
|
11717
|
-
|
|
11702
|
+
reachingDef2 = def.id;
|
|
11718
11703
|
}
|
|
11719
11704
|
uses.push({
|
|
11720
11705
|
id: useIdCounter++,
|
|
11721
11706
|
variable: varName,
|
|
11722
11707
|
line: node.startPosition.row + 1,
|
|
11723
|
-
def_id:
|
|
11708
|
+
def_id: reachingDef2
|
|
11724
11709
|
});
|
|
11725
11710
|
}
|
|
11726
11711
|
}
|
|
@@ -11728,8 +11713,8 @@ function buildBashDFG(tree) {
|
|
|
11728
11713
|
const varNameNode = node.namedChildCount > 0 ? node.namedChild(0) : null;
|
|
11729
11714
|
if (varNameNode && varNameNode.type === "variable_name") {
|
|
11730
11715
|
const varName = getNodeText(varNameNode);
|
|
11731
|
-
let
|
|
11732
|
-
if (
|
|
11716
|
+
let reachingDef2 = positionalDef(varName, node, findReachingDef(varName, scopeStack));
|
|
11717
|
+
if (reachingDef2 === null && !positionalParams.includes(varName)) {
|
|
11733
11718
|
const def = {
|
|
11734
11719
|
id: defIdCounter++,
|
|
11735
11720
|
variable: varName,
|
|
@@ -11738,13 +11723,13 @@ function buildBashDFG(tree) {
|
|
|
11738
11723
|
};
|
|
11739
11724
|
defs.push(def);
|
|
11740
11725
|
scopeStack[0].set(varName, def.id);
|
|
11741
|
-
|
|
11726
|
+
reachingDef2 = def.id;
|
|
11742
11727
|
}
|
|
11743
11728
|
uses.push({
|
|
11744
11729
|
id: useIdCounter++,
|
|
11745
11730
|
variable: varName,
|
|
11746
11731
|
line: node.startPosition.row + 1,
|
|
11747
|
-
def_id:
|
|
11732
|
+
def_id: reachingDef2
|
|
11748
11733
|
});
|
|
11749
11734
|
}
|
|
11750
11735
|
}
|
|
@@ -14729,6 +14714,8 @@ var DEFAULT_SINKS = [
|
|
|
14729
14714
|
{ method: "eval", class: "ScriptContext", type: "code_injection", cwe: "CWE-94", severity: "critical", arg_positions: [0] },
|
|
14730
14715
|
// Dynamic class loading (can lead to RCE)
|
|
14731
14716
|
{ method: "forName", class: "Class", type: "code_injection", cwe: "CWE-94", severity: "high", arg_positions: [0] },
|
|
14717
|
+
// Attacker-chosen class names used for reflective instantiation (yamlbeans CVE-2023-24621, cognium-dev#1290)
|
|
14718
|
+
{ method: "forName", class: "Class", type: "deserialization", cwe: "CWE-502", severity: "critical", arg_positions: [0], languages: ["java"] },
|
|
14732
14719
|
{ method: "loadClass", class: "ClassLoader", type: "code_injection", cwe: "CWE-94", severity: "high", arg_positions: [0] },
|
|
14733
14720
|
{ method: "defineClass", class: "ClassLoader", type: "code_injection", cwe: "CWE-94", severity: "critical", arg_positions: [0, 1] },
|
|
14734
14721
|
{ method: "newInstance", class: "Class", type: "code_injection", cwe: "CWE-94", severity: "high", arg_positions: [] },
|
|
@@ -16464,6 +16451,10 @@ var DEFAULT_SANITIZERS = [
|
|
|
16464
16451
|
// Log Injection sanitizers
|
|
16465
16452
|
{ method: "replace", removes: ["log_injection"] },
|
|
16466
16453
|
// Used to remove newlines/control chars
|
|
16454
|
+
// JSON.stringify escapes CR/LF (and every other control character) inside a
|
|
16455
|
+
// string, so a log entry cannot be split. Log injection only: the output still
|
|
16456
|
+
// carries `<`, quotes and shell/SQL metacharacters.
|
|
16457
|
+
{ method: "stringify", class: "JSON", removes: ["log_injection"] },
|
|
16467
16458
|
// LDAP Injection
|
|
16468
16459
|
{ method: "encodeForLDAP", removes: ["ldap_injection"] },
|
|
16469
16460
|
{ method: "encodeForDN", removes: ["ldap_injection"] },
|
|
@@ -16725,6 +16716,12 @@ var DEFAULT_SANITIZERS = [
|
|
|
16725
16716
|
// `code_injection` categorization that `re.compile` currently emits
|
|
16726
16717
|
// (a re.escape-wrapped pattern cannot execute anything, so both are safe).
|
|
16727
16718
|
{ method: "escape", class: "re", removes: ["redos", "code_injection"] },
|
|
16719
|
+
// JS/TS ReDoS — escaping a request value before `new RegExp(...)` makes it a
|
|
16720
|
+
// literal: lodash `_.escapeRegExp`, the `escape-string-regexp` package, and
|
|
16721
|
+
// the common local helper names.
|
|
16722
|
+
{ method: "escapeRegExp", removes: ["redos"] },
|
|
16723
|
+
{ method: "escapeStringRegexp", removes: ["redos"] },
|
|
16724
|
+
{ method: "escapeRegex", removes: ["redos"] },
|
|
16728
16725
|
// Python SQLAlchemy — `text(...).bindparams(...)` binds params safely.
|
|
16729
16726
|
// The `bindparams` call is the sanitizer; the parent `text` wraps the
|
|
16730
16727
|
// template. Also add `expression.literal` for explicit SQL literals.
|
|
@@ -17864,7 +17861,7 @@ function findRustLiteralEqualityGuardSanitizers(code) {
|
|
|
17864
17861
|
lineStarts.push(off);
|
|
17865
17862
|
off += origLines[i2].length + 1;
|
|
17866
17863
|
}
|
|
17867
|
-
const
|
|
17864
|
+
const lineOf2 = (idx) => {
|
|
17868
17865
|
let lo = 0, hi = lineStarts.length - 1;
|
|
17869
17866
|
while (lo < hi) {
|
|
17870
17867
|
const mid = lo + hi + 1 >> 1;
|
|
@@ -17937,12 +17934,12 @@ function findRustLiteralEqualityGuardSanitizers(code) {
|
|
|
17937
17934
|
}
|
|
17938
17935
|
}
|
|
17939
17936
|
const mutBinding = mutParam || new RegExp(String.raw`\bmut\s+${name2}\b|\b${name2}\s*:\s*&(?:\s*'\w+)?\s*mut\b`).test(masked.slice(0, at));
|
|
17940
|
-
const firstLine =
|
|
17941
|
-
const lastLine = end === masked.length ? origLines.length - 1 :
|
|
17937
|
+
const firstLine = lineOf2(close) + 1;
|
|
17938
|
+
const lastLine = end === masked.length ? origLines.length - 1 : lineOf2(end) - 1;
|
|
17942
17939
|
let stop2 = lastLine + 1;
|
|
17943
17940
|
let rebindLine = lastLine + 1;
|
|
17944
17941
|
const rb = firstRebind(masked, close + 1, end, name2, { mutBinding });
|
|
17945
|
-
if (rb >= 0) rebindLine =
|
|
17942
|
+
if (rb >= 0) rebindLine = lineOf2(rb);
|
|
17946
17943
|
if (mutParam) {
|
|
17947
17944
|
for (let l = firstLine; l < rebindLine && l <= lastLine; l++) {
|
|
17948
17945
|
if (passesMutParam(maskedLines[l], name2)) {
|
|
@@ -17957,8 +17954,8 @@ function findRustLiteralEqualityGuardSanitizers(code) {
|
|
|
17957
17954
|
for (const lp of masked.slice(close + 1, end).matchAll(/\b(?:for|while|loop)\b[^{;]*\{/g)) {
|
|
17958
17955
|
const lpOpen = close + 1 + lp.index + lp[0].length - 1;
|
|
17959
17956
|
const lpClose = matchBrace(masked, lpOpen);
|
|
17960
|
-
const lpLine =
|
|
17961
|
-
if (lpClose >= 0 &&
|
|
17957
|
+
const lpLine = lineOf2(lpOpen);
|
|
17958
|
+
if (lpClose >= 0 && lineOf2(lpClose) >= l && lpLine <= l) stop2 = Math.min(stop2, lpLine);
|
|
17962
17959
|
}
|
|
17963
17960
|
}
|
|
17964
17961
|
const mention = new RegExp(String.raw`(?<![\w.])${name2}\b`);
|
|
@@ -18748,6 +18745,7 @@ var LanguageSourcesPass = class {
|
|
|
18748
18745
|
additionalSanitizers.push(...findJsCsvFormulaPrefixSanitizers(code));
|
|
18749
18746
|
additionalSanitizers.push(...findJsWrapperFunctionSanitizers(code));
|
|
18750
18747
|
additionalSanitizers.push(...findJsSsrfAllowlistGuardSanitizers(code));
|
|
18748
|
+
additionalSanitizers.push(...findJsSsrfAllowlistWrapperSanitizers(code));
|
|
18751
18749
|
additionalSanitizers.push(...findJsArgvFormExecSanitizers(code));
|
|
18752
18750
|
additionalSanitizers.push(...findJsParameterizedSqlSanitizers(code));
|
|
18753
18751
|
additionalSanitizers.push(
|
|
@@ -18972,10 +18970,10 @@ function findOopFieldReadSources(types, sourceCode, language) {
|
|
|
18972
18970
|
}
|
|
18973
18971
|
}
|
|
18974
18972
|
if (!ctor) continue;
|
|
18975
|
-
const
|
|
18973
|
+
const paramNames2 = /* @__PURE__ */ new Set();
|
|
18976
18974
|
for (const p of ctor.parameters) {
|
|
18977
18975
|
if (p.name === "self" || p.name === "this") continue;
|
|
18978
|
-
|
|
18976
|
+
paramNames2.add(p.name);
|
|
18979
18977
|
}
|
|
18980
18978
|
const fieldTaint = /* @__PURE__ */ new Map();
|
|
18981
18979
|
const ctorStart = ctor.start_line;
|
|
@@ -18996,7 +18994,7 @@ function findOopFieldReadSources(types, sourceCode, language) {
|
|
|
18996
18994
|
if (pairs.length === 0) continue;
|
|
18997
18995
|
for (const { field: fieldName, rhs } of pairs) {
|
|
18998
18996
|
let sourceType = null;
|
|
18999
|
-
if (
|
|
18997
|
+
if (paramNames2.has(rhs)) {
|
|
19000
18998
|
sourceType = "interprocedural_param";
|
|
19001
18999
|
} else if (isJava && javaHttpPattern.test(rhs)) {
|
|
19002
19000
|
sourceType = "http_param";
|
|
@@ -23649,6 +23647,42 @@ function findJsSsrfAllowlistGuardSanitizers(code) {
|
|
|
23649
23647
|
}
|
|
23650
23648
|
return sanitizers;
|
|
23651
23649
|
}
|
|
23650
|
+
function findJsSsrfAllowlistWrapperSanitizers(code) {
|
|
23651
|
+
const sanitizers = [];
|
|
23652
|
+
const lines = code.split("\n");
|
|
23653
|
+
const fnDeclRe = /\bfunction\s+([A-Za-z_]\w*)\s*\(\s*([A-Za-z_]\w*)\s*\)/;
|
|
23654
|
+
const arrowDeclRe = /\b(?:const|let|var)\s+([A-Za-z_]\w*)\s*=\s*\(\s*([A-Za-z_]\w*)\s*\)\s*=>/;
|
|
23655
|
+
const allowlistName = /^(?:[A-Z][A-Z0-9_]+|.*?(allowed|accepted|whitelist|permitted|valid|approved).*)$/i;
|
|
23656
|
+
const allowGuard = /!\s*([A-Za-z_]\w*)\s*\.\s*(?:has|includes)\s*\(/;
|
|
23657
|
+
const wrappers = /* @__PURE__ */ new Set();
|
|
23658
|
+
for (let i2 = 0; i2 < lines.length; i2++) {
|
|
23659
|
+
const m = fnDeclRe.exec(lines[i2]) ?? arrowDeclRe.exec(lines[i2]);
|
|
23660
|
+
if (!m) continue;
|
|
23661
|
+
const name2 = m[1];
|
|
23662
|
+
const param = m[2];
|
|
23663
|
+
const body2 = lines.slice(i2, Math.min(lines.length, i2 + 12)).join("\n");
|
|
23664
|
+
if (!new RegExp(`new\\s+URL\\s*\\(\\s*${param}\\b`).test(body2)) continue;
|
|
23665
|
+
const gm = allowGuard.exec(body2);
|
|
23666
|
+
if (!gm || !allowlistName.test(gm[1])) continue;
|
|
23667
|
+
if (!/\b(?:throw|return)\b/.test(body2)) continue;
|
|
23668
|
+
if (!new RegExp(`\\breturn\\s+${param}\\b`).test(body2)) continue;
|
|
23669
|
+
wrappers.add(name2);
|
|
23670
|
+
}
|
|
23671
|
+
for (const name2 of wrappers) {
|
|
23672
|
+
for (let i2 = 0; i2 < lines.length; i2++) {
|
|
23673
|
+
const declSelf = new RegExp(`\\b(?:function|const|let|var)\\s+${name2}\\b`);
|
|
23674
|
+
if (declSelf.test(lines[i2])) continue;
|
|
23675
|
+
if (!new RegExp(`\\b${name2}\\s*\\(`).test(lines[i2])) continue;
|
|
23676
|
+
sanitizers.push({
|
|
23677
|
+
type: "js_ssrf_allowlist_wrapper",
|
|
23678
|
+
method: name2,
|
|
23679
|
+
line: i2 + 1,
|
|
23680
|
+
sanitizes: ["ssrf", "external_taint_escape"]
|
|
23681
|
+
});
|
|
23682
|
+
}
|
|
23683
|
+
}
|
|
23684
|
+
return sanitizers;
|
|
23685
|
+
}
|
|
23652
23686
|
function findJsArgvFormExecSanitizers(code) {
|
|
23653
23687
|
const sanitizers = [];
|
|
23654
23688
|
const lines = code.split("\n");
|
|
@@ -23805,7 +23839,9 @@ function findJsRelativeRedirectGuardSanitizers(code) {
|
|
|
23805
23839
|
}
|
|
23806
23840
|
function jsGuardCreditLines(lines, from, v) {
|
|
23807
23841
|
const esc = v.replace(/[.$]/g, "\\$&");
|
|
23808
|
-
const reassign = new RegExp(
|
|
23842
|
+
const reassign = new RegExp(
|
|
23843
|
+
`(?:^|[^\\w$.])(?:(?:let|const|var)\\s+)?${esc}\\s*(?:[+\\-*/%|&^]?=)(?!=)`
|
|
23844
|
+
);
|
|
23809
23845
|
const out2 = [];
|
|
23810
23846
|
let depth = 0;
|
|
23811
23847
|
for (let l = from; l < lines.length; l++) {
|
|
@@ -28149,6 +28185,40 @@ function findJavaSpringReturnXSSSinks(code, types, sources, xssSanitizerLines) {
|
|
|
28149
28185
|
return out2;
|
|
28150
28186
|
}
|
|
28151
28187
|
|
|
28188
|
+
// src/types/index.ts
|
|
28189
|
+
var SINK_TYPES = [
|
|
28190
|
+
"sql_injection",
|
|
28191
|
+
"nosql_injection",
|
|
28192
|
+
"command_injection",
|
|
28193
|
+
"path_traversal",
|
|
28194
|
+
"xss",
|
|
28195
|
+
"xxe",
|
|
28196
|
+
"deserialization",
|
|
28197
|
+
"ldap_injection",
|
|
28198
|
+
"xpath_injection",
|
|
28199
|
+
"ssrf",
|
|
28200
|
+
"open_redirect",
|
|
28201
|
+
"code_injection",
|
|
28202
|
+
"log_injection",
|
|
28203
|
+
"redos",
|
|
28204
|
+
"format_string",
|
|
28205
|
+
"crlf",
|
|
28206
|
+
"mass_assignment",
|
|
28207
|
+
"mybatis_mapper_call",
|
|
28208
|
+
"weak_random",
|
|
28209
|
+
"weak_hash",
|
|
28210
|
+
"weak_crypto",
|
|
28211
|
+
"insecure_cookie",
|
|
28212
|
+
"trust_boundary",
|
|
28213
|
+
"cache_poisoning",
|
|
28214
|
+
"prompt_injection",
|
|
28215
|
+
"insecure_storage",
|
|
28216
|
+
"prototype_pollution",
|
|
28217
|
+
"regex_dos",
|
|
28218
|
+
"unsafe_memory",
|
|
28219
|
+
"external_taint_escape"
|
|
28220
|
+
];
|
|
28221
|
+
|
|
28152
28222
|
// src/analysis/constant-propagation/patterns.ts
|
|
28153
28223
|
var TAINT_PATTERNS = [
|
|
28154
28224
|
// HTTP Sources (Servlet API)
|
|
@@ -28378,7 +28448,10 @@ var HTML_CONTEXT_ENCODER_METHODS = /* @__PURE__ */ new Set([
|
|
|
28378
28448
|
"htmlEscapeDecimal",
|
|
28379
28449
|
"htmlEscapeHex"
|
|
28380
28450
|
]);
|
|
28381
|
-
var
|
|
28451
|
+
var HTML_CONTEXT_ENCODER_COVERED_SINKS = /* @__PURE__ */ new Set(["xss", "external_taint_escape"]);
|
|
28452
|
+
var HTML_CONTEXT_ENCODER_UNCOVERED_SINKS = new Set(
|
|
28453
|
+
SINK_TYPES.filter((t) => !HTML_CONTEXT_ENCODER_COVERED_SINKS.has(t))
|
|
28454
|
+
);
|
|
28382
28455
|
var ANTI_SANITIZER_METHODS = /* @__PURE__ */ new Set([
|
|
28383
28456
|
// URL decoding (reverses URL encoding)
|
|
28384
28457
|
"decode",
|
|
@@ -30795,8 +30868,8 @@ function findSanitizers(calls, types, patterns, sourceLines, language) {
|
|
|
30795
30868
|
for (const method of type.methods) {
|
|
30796
30869
|
const bodySize = method.end_line - method.start_line;
|
|
30797
30870
|
if (bodySize < 0 || bodySize > 2) continue;
|
|
30798
|
-
const
|
|
30799
|
-
if (
|
|
30871
|
+
const paramNames2 = new Set(method.parameters.map((p) => p.name));
|
|
30872
|
+
if (paramNames2.size === 0) continue;
|
|
30800
30873
|
const inside = [];
|
|
30801
30874
|
for (const c of calls) {
|
|
30802
30875
|
if (c.location.line < method.start_line || c.location.line > method.end_line) continue;
|
|
@@ -30833,7 +30906,7 @@ function findSanitizers(calls, types, patterns, sourceLines, language) {
|
|
|
30833
30906
|
let argOk = false;
|
|
30834
30907
|
if (replaceChainHelper) {
|
|
30835
30908
|
const recv = innerCall.receiver?.trim() ?? "";
|
|
30836
|
-
for (const p of
|
|
30909
|
+
for (const p of paramNames2) {
|
|
30837
30910
|
if (recv === p || recv.startsWith(`${p}.`)) {
|
|
30838
30911
|
argOk = true;
|
|
30839
30912
|
break;
|
|
@@ -30841,7 +30914,7 @@ function findSanitizers(calls, types, patterns, sourceLines, language) {
|
|
|
30841
30914
|
}
|
|
30842
30915
|
} else {
|
|
30843
30916
|
for (const arg of innerCall.arguments) {
|
|
30844
|
-
if (arg.variable &&
|
|
30917
|
+
if (arg.variable && paramNames2.has(arg.variable)) {
|
|
30845
30918
|
argOk = true;
|
|
30846
30919
|
break;
|
|
30847
30920
|
}
|
|
@@ -30855,7 +30928,7 @@ function findSanitizers(calls, types, patterns, sourceLines, language) {
|
|
|
30855
30928
|
if (!returnMatch) continue;
|
|
30856
30929
|
const after = returnMatch[1].replace(/;\s*$/, "").trimEnd();
|
|
30857
30930
|
if (replaceChainHelper) {
|
|
30858
|
-
const startsWithParam = [...
|
|
30931
|
+
const startsWithParam = [...paramNames2].some(
|
|
30859
30932
|
(p) => after === p || after.startsWith(`${p}.`)
|
|
30860
30933
|
);
|
|
30861
30934
|
if (!startsWithParam) continue;
|
|
@@ -30884,8 +30957,8 @@ function findSanitizers(calls, types, patterns, sourceLines, language) {
|
|
|
30884
30957
|
if (wrapperSanitizers.has(method.name)) continue;
|
|
30885
30958
|
const bodySize = method.end_line - method.start_line;
|
|
30886
30959
|
if (bodySize < 0 || bodySize > 2) continue;
|
|
30887
|
-
const
|
|
30888
|
-
if (
|
|
30960
|
+
const paramNames2 = new Set(method.parameters.map((p) => p.name));
|
|
30961
|
+
if (paramNames2.size === 0) continue;
|
|
30889
30962
|
const inside = [];
|
|
30890
30963
|
for (const c of calls) {
|
|
30891
30964
|
if (c.location.line < method.start_line || c.location.line > method.end_line) continue;
|
|
@@ -30898,7 +30971,7 @@ function findSanitizers(calls, types, patterns, sourceLines, language) {
|
|
|
30898
30971
|
if (!delegateRemoves || delegateRemoves.length === 0) continue;
|
|
30899
30972
|
let argOk = false;
|
|
30900
30973
|
for (const arg of innerCall.arguments) {
|
|
30901
|
-
if (arg.variable &&
|
|
30974
|
+
if (arg.variable && paramNames2.has(arg.variable)) {
|
|
30902
30975
|
argOk = true;
|
|
30903
30976
|
break;
|
|
30904
30977
|
}
|
|
@@ -31516,6 +31589,10 @@ function walkBackwardDefs(startDefId, chainsByToDef, defById, options = {}) {
|
|
|
31516
31589
|
// src/analysis/findings.ts
|
|
31517
31590
|
function canSourceReachSink(sourceType, sinkType) {
|
|
31518
31591
|
const sourceToSinkMapping = {
|
|
31592
|
+
// redos added to http_*: a request value used as
|
|
31593
|
+
// the pattern of `new RegExp(req.query.p)` on one line never produced the
|
|
31594
|
+
// inline flow. The colocation detector only emits it when the value sits
|
|
31595
|
+
// in the sink's pattern argument (`redosColocatedInPatternArg`).
|
|
31519
31596
|
// code_injection added to http_param/http_query/http_header/http_cookie:
|
|
31520
31597
|
// `eval(req.query.x)`, `Function(req.header('x'))`, `vm.runInThisContext(req.cookies.c)`
|
|
31521
31598
|
// are all real RCE patterns in JS web apps (cognium-dev #83).
|
|
@@ -31566,20 +31643,24 @@ function canSourceReachSink(sourceType, sinkType) {
|
|
|
31566
31643
|
// pairing was gated out and generateFindings dropped it — same class as the
|
|
31567
31644
|
// #129 log_injection/format_string/nosql_injection drop. Mirrors how
|
|
31568
31645
|
// deserialization already sits on both http_param and http_query.
|
|
31646
|
+
// deserialization added to http_cookie: a cookie value reaching node-serialize's
|
|
31647
|
+
// unserialize (or any deserialization sink) is the classic JS RCE (CVE-2017-5941 came in
|
|
31648
|
+
// through a cookie). The reach map had it on http_param/http_query/http_body only, so
|
|
31649
|
+
// `serialize.unserialize(req.cookies.profile)` was dropped while the req.body form fired.
|
|
31569
31650
|
// cache_poisoning added (cognium-dev #900): request-derived strings written
|
|
31570
31651
|
// into a shared in-memory cache (Map.set value arg, OIDC/mr-title-frag shapes).
|
|
31571
|
-
http_param: ["sql_injection", "command_injection", "path_traversal", "xss", "xpath_injection", "ldap_injection", "ssrf", "mybatis_mapper_call", "code_injection", "crlf", "mass_assignment", "open_redirect", "trust_boundary", "deserialization", "xxe", "log_injection", "format_string", "nosql_injection", "prompt_injection", "cache_poisoning"],
|
|
31572
|
-
http_body: ["sql_injection", "command_injection", "deserialization", "xxe", "xss", "code_injection", "mybatis_mapper_call", "crlf", "mass_assignment", "open_redirect", "trust_boundary", "log_injection", "format_string", "nosql_injection", "prompt_injection", "cache_poisoning"],
|
|
31573
|
-
http_header: ["sql_injection", "xss", "ssrf", "mybatis_mapper_call", "code_injection", "crlf", "open_redirect", "trust_boundary", "log_injection", "format_string", "nosql_injection", "prompt_injection", "cache_poisoning"],
|
|
31574
|
-
http_cookie: ["sql_injection", "xss", "mybatis_mapper_call", "code_injection", "crlf", "open_redirect", "trust_boundary", "log_injection", "format_string", "nosql_injection", "prompt_injection"],
|
|
31652
|
+
http_param: ["sql_injection", "command_injection", "path_traversal", "xss", "xpath_injection", "ldap_injection", "ssrf", "mybatis_mapper_call", "code_injection", "crlf", "mass_assignment", "open_redirect", "trust_boundary", "deserialization", "xxe", "log_injection", "format_string", "nosql_injection", "prompt_injection", "cache_poisoning", "redos"],
|
|
31653
|
+
http_body: ["sql_injection", "command_injection", "deserialization", "xxe", "xss", "code_injection", "mybatis_mapper_call", "crlf", "mass_assignment", "open_redirect", "trust_boundary", "log_injection", "format_string", "nosql_injection", "prompt_injection", "cache_poisoning", "redos"],
|
|
31654
|
+
http_header: ["sql_injection", "xss", "ssrf", "mybatis_mapper_call", "code_injection", "crlf", "open_redirect", "trust_boundary", "log_injection", "format_string", "nosql_injection", "prompt_injection", "cache_poisoning", "redos"],
|
|
31655
|
+
http_cookie: ["sql_injection", "xss", "mybatis_mapper_call", "code_injection", "crlf", "open_redirect", "trust_boundary", "deserialization", "log_injection", "format_string", "nosql_injection", "prompt_injection", "redos"],
|
|
31575
31656
|
// xss added cognium-dev 3.163.0: URL path components (getRequestURI,
|
|
31576
31657
|
// getRequestURL, getPathInfo, getServletPath) reflected back into HTML
|
|
31577
31658
|
// output are a classic reflected-XSS vector — cf. Basic35 in
|
|
31578
31659
|
// SecuriBench Micro where `writer.println(req.getRequestURL())` is
|
|
31579
31660
|
// annotated `/* BAD */`. Prior to 3.163.0 the reach map omitted xss
|
|
31580
31661
|
// so http_path → xss inline-colocation flows were silently dropped.
|
|
31581
|
-
http_path: ["path_traversal", "sql_injection", "ssrf", "mybatis_mapper_call", "open_redirect", "trust_boundary", "xss", "log_injection", "format_string", "prompt_injection"],
|
|
31582
|
-
http_query: ["sql_injection", "command_injection", "xss", "ssrf", "mybatis_mapper_call", "code_injection", "crlf", "mass_assignment", "open_redirect", "trust_boundary", "deserialization", "xxe", "log_injection", "format_string", "nosql_injection", "prompt_injection", "cache_poisoning"],
|
|
31662
|
+
http_path: ["path_traversal", "sql_injection", "ssrf", "mybatis_mapper_call", "open_redirect", "trust_boundary", "xss", "log_injection", "format_string", "prompt_injection", "redos"],
|
|
31663
|
+
http_query: ["sql_injection", "command_injection", "xss", "ssrf", "mybatis_mapper_call", "code_injection", "crlf", "mass_assignment", "open_redirect", "trust_boundary", "deserialization", "xxe", "log_injection", "format_string", "nosql_injection", "prompt_injection", "cache_poisoning", "redos"],
|
|
31583
31664
|
// ssrf added Sprint 57 #200: bash CGI/webhook handlers and scripts that
|
|
31584
31665
|
// take a URL on stdin or as a positional CLI arg (`curl "$1"`,
|
|
31585
31666
|
// `wget "$(read line)"`) and curl/wget it server-side are textbook SSRF
|
|
@@ -39927,16 +40008,16 @@ var ConstantPropagator = class _ConstantPropagator {
|
|
|
39927
40008
|
}
|
|
39928
40009
|
if (node.type === "identifier") {
|
|
39929
40010
|
let isTainted = false;
|
|
39930
|
-
let
|
|
40011
|
+
let boundName2 = null;
|
|
39931
40012
|
for (const candidate of this.getScopedNameCandidates(text)) {
|
|
39932
40013
|
if (this.tainted.has(candidate)) {
|
|
39933
40014
|
isTainted = true;
|
|
39934
|
-
|
|
40015
|
+
boundName2 = candidate;
|
|
39935
40016
|
break;
|
|
39936
40017
|
}
|
|
39937
40018
|
}
|
|
39938
|
-
if (isTainted &&
|
|
39939
|
-
if (this.isExcludedByCondition(
|
|
40019
|
+
if (isTainted && boundName2) {
|
|
40020
|
+
if (this.isExcludedByCondition(boundName2) || this.isExcludedByCondition(text)) {
|
|
39940
40021
|
return false;
|
|
39941
40022
|
}
|
|
39942
40023
|
}
|
|
@@ -45902,12 +45983,12 @@ var HELPER_RETURN_GATED_SINKS = /* @__PURE__ */ new Set([
|
|
|
45902
45983
|
]);
|
|
45903
45984
|
function calleeReturnMayCarryParam(code, startLine, endLine, sourceVars) {
|
|
45904
45985
|
const raw = code.split("\n").slice(startLine - 1, endLine);
|
|
45905
|
-
const
|
|
45986
|
+
const paramNames2 = [...sourceVars, ...javaMethodParamNames(raw)];
|
|
45906
45987
|
const dead = computeDeadJavaBranchLines(raw);
|
|
45907
45988
|
const inlined = /* @__PURE__ */ new Set();
|
|
45908
45989
|
const slice = joinWrappedStatements(raw, inlined);
|
|
45909
45990
|
const text = slice.join("\n");
|
|
45910
|
-
const seeds = new Set(
|
|
45991
|
+
const seeds = new Set(paramNames2);
|
|
45911
45992
|
const mutated = /* @__PURE__ */ new Set();
|
|
45912
45993
|
let live = new Set(seeds);
|
|
45913
45994
|
for (let round = 0; round < 8; round++) {
|
|
@@ -46125,12 +46206,12 @@ function javaHelperCallHasInstanceReceiver(graph, edge) {
|
|
|
46125
46206
|
}
|
|
46126
46207
|
function skipPassThroughTrustBoundaryWithoutHttpArg(graph, fileCode, edge, calleeStart, calleeEnd, fileSources, paramVars) {
|
|
46127
46208
|
const lines = fileCode.split("\n");
|
|
46128
|
-
const
|
|
46209
|
+
const paramNames2 = javaMethodParamNames(lines.slice(calleeStart - 1, calleeEnd));
|
|
46129
46210
|
const callSite = graph.ir.calls?.find(
|
|
46130
46211
|
(c) => c.location.line === edge.callLine && (c.in_method ?? null) === edge.callerMethod
|
|
46131
46212
|
);
|
|
46132
46213
|
for (const paramVar of paramVars) {
|
|
46133
|
-
const idx =
|
|
46214
|
+
const idx = paramNames2.indexOf(paramVar);
|
|
46134
46215
|
if (idx < 0) continue;
|
|
46135
46216
|
const fromCall = callSite?.arguments?.find((a) => a.position === idx);
|
|
46136
46217
|
const argVar = fromCall?.variable ?? (fromCall?.expression && /^[A-Za-z_]\w*$/.test(fromCall.expression.trim()) ? fromCall.expression.trim() : void 0);
|
|
@@ -47950,7 +48031,7 @@ function jsLibxmljsNoentDisablesXxe(code, sinkLine) {
|
|
|
47950
48031
|
if (closeIdx < 0) return false;
|
|
47951
48032
|
const inner = afterCall.slice(openParen + 1, closeIdx);
|
|
47952
48033
|
const commaIdx = inner.indexOf(",");
|
|
47953
|
-
if (commaIdx < 0) return
|
|
48034
|
+
if (commaIdx < 0) return false;
|
|
47954
48035
|
const secondArg = inner.slice(commaIdx + 1).trim();
|
|
47955
48036
|
if (/^[A-Za-z_$][\w$]*$/.test(secondArg)) return false;
|
|
47956
48037
|
return secondArg.startsWith("{");
|
|
@@ -51657,6 +51738,13 @@ function goConstantHelperCalleeFromLines(lines, lineNumber) {
|
|
|
51657
51738
|
}
|
|
51658
51739
|
return null;
|
|
51659
51740
|
}
|
|
51741
|
+
function encoderLeavesSinkUncovered(constProp, graph, step, sinkType) {
|
|
51742
|
+
const unc = constProp.sanitizedVarUncovered;
|
|
51743
|
+
if (!unc || unc.size === 0) return false;
|
|
51744
|
+
if (step.variable.includes(":")) return !!unc.get(step.variable)?.has(sinkType);
|
|
51745
|
+
const method = methodAtLine(graph, step.line);
|
|
51746
|
+
return !!unc.get(method ? `${method}:${step.variable}` : step.variable)?.has(sinkType);
|
|
51747
|
+
}
|
|
51660
51748
|
function makeConstPropVeto(constProp, graph, sources, code, language, sanitizers) {
|
|
51661
51749
|
const lines = typeof code === "string" ? code.split("\n") : [];
|
|
51662
51750
|
const selfReassign = /* @__PURE__ */ new Map();
|
|
@@ -51683,7 +51771,7 @@ function makeConstPropVeto(constProp, graph, sources, code, language, sanitizers
|
|
|
51683
51771
|
const use = (graph.usesByLine.get(line) ?? []).find((u) => u.variable === v && u.def_id != null);
|
|
51684
51772
|
return use ? graph.defById.get(use.def_id) : void 0;
|
|
51685
51773
|
};
|
|
51686
|
-
return (step, sourceLine, sinkLine, sinkType) => {
|
|
51774
|
+
return (step, sourceLine, sinkLine, sinkType, encodedUpstream) => {
|
|
51687
51775
|
if (step.variable.includes(".") && sources.some(
|
|
51688
51776
|
(s) => s.variable === step.variable && s.line >= sourceLine && s.line <= sinkLine && typeof s.location === "string" && s.location.includes("heap field read")
|
|
51689
51777
|
)) {
|
|
@@ -51701,6 +51789,7 @@ function makeConstPropVeto(constProp, graph, sources, code, language, sanitizers
|
|
|
51701
51789
|
const r = isFalsePositive(constProp, step.line, fpLookup);
|
|
51702
51790
|
if (!r.isFalsePositive) return false;
|
|
51703
51791
|
if (r.reason !== "variable_not_tainted") return true;
|
|
51792
|
+
if (encodedUpstream) return false;
|
|
51704
51793
|
if (r.reason === "variable_not_tainted" && language === "java" && method && fpLookup === step.variable && !step.variable.includes(".")) {
|
|
51705
51794
|
const v = step.variable;
|
|
51706
51795
|
if (constProp.tainted.has(`${method}:${v}`)) return false;
|
|
@@ -51804,8 +51893,10 @@ var TaintPropagationPass = class {
|
|
|
51804
51893
|
const isVetoed = makeConstPropVeto(constProp, graph, sources, ctx.code, ctx.language, sanitizers);
|
|
51805
51894
|
const verifiedFlows = propagationResult.flows.filter((flow) => {
|
|
51806
51895
|
if (constProp.unreachableLines.has(flow.sink.line)) return false;
|
|
51896
|
+
let encodedUpstream = false;
|
|
51807
51897
|
for (const step of flow.path) {
|
|
51808
|
-
if (isVetoed(step, flow.source.line, flow.sink.line, flow.sink.type)) return false;
|
|
51898
|
+
if (isVetoed(step, flow.source.line, flow.sink.line, flow.sink.type, encodedUpstream)) return false;
|
|
51899
|
+
if (!encodedUpstream) encodedUpstream = encoderLeavesSinkUncovered(constProp, graph, step, flow.sink.type);
|
|
51809
51900
|
}
|
|
51810
51901
|
if (isCorrelatedPredicateFP(constProp, flow)) return false;
|
|
51811
51902
|
return true;
|
|
@@ -52370,13 +52461,20 @@ function isInJavaSanitizedMethod(code, types, sinkLine, sinkType) {
|
|
|
52370
52461
|
return true;
|
|
52371
52462
|
}
|
|
52372
52463
|
if (sinkType === "xxe") {
|
|
52373
|
-
|
|
52374
|
-
if (setFeatureRe.test(body2)) return true;
|
|
52375
|
-
if (/\.setProperty\s*\([^,]*SUPPORT_DTD[^,]*,\s*false\s*\)/.test(body2)) return true;
|
|
52376
|
-
return false;
|
|
52464
|
+
return isHardenedXmlFactory(body2);
|
|
52377
52465
|
}
|
|
52378
52466
|
return false;
|
|
52379
52467
|
}
|
|
52468
|
+
function isHardenedXmlFactory(body2) {
|
|
52469
|
+
const setFeatureRe = /\.setFeature\s*\(\s*"(?:[^"]*disallow-doctype-decl|[^"]*external-general-entities|[^"]*external-parameter-entities|[^"]*load-external-dtd)"/;
|
|
52470
|
+
if (setFeatureRe.test(body2)) return true;
|
|
52471
|
+
if (/\.setProperty\s*\([^,]*SUPPORT_DTD[^,]*,\s*false\s*\)/.test(body2)) return true;
|
|
52472
|
+
const accessName = '(?:ACCESS_EXTERNAL_(?:DTD|STYLESHEET|SCHEMA)\\b|"https?:\\/\\/javax\\.xml\\.XMLConstants\\/property\\/accessExternal(?:DTD|Stylesheet|Schema)")';
|
|
52473
|
+
const emptyExternalAccessRe = new RegExp(`${accessName}\\s*,\\s*""`);
|
|
52474
|
+
const permissiveExternalAccessRe = new RegExp(`${accessName}\\s*,\\s*"[^"]+"`);
|
|
52475
|
+
if (emptyExternalAccessRe.test(body2) && !permissiveExternalAccessRe.test(body2)) return true;
|
|
52476
|
+
return false;
|
|
52477
|
+
}
|
|
52380
52478
|
function detectGoPackageGlobalFlows(code, _calls, sources, sinks, unreachableLines) {
|
|
52381
52479
|
const flows = [];
|
|
52382
52480
|
if (!code || sinks.length === 0) return flows;
|
|
@@ -52903,10 +53001,10 @@ function shouldGateCSharpPatPermsLibraryParamFlow(flow, sources, sinks, types, c
|
|
|
52903
53001
|
ctx
|
|
52904
53002
|
);
|
|
52905
53003
|
}
|
|
52906
|
-
function compoundArgParamNames(expression,
|
|
53004
|
+
function compoundArgParamNames(expression, paramNames2) {
|
|
52907
53005
|
const stripped = expression.replace(/(['"`])(?:\\.|(?!\1)[^\\\n\r\u2028\u2029])*\1/g, (m) => " ".repeat(m.length));
|
|
52908
53006
|
const matched = [];
|
|
52909
|
-
for (const raw of
|
|
53007
|
+
for (const raw of paramNames2) {
|
|
52910
53008
|
const name2 = raw.startsWith("*") ? raw.slice(1) : raw;
|
|
52911
53009
|
if (!/^[\w$]+$/.test(name2)) continue;
|
|
52912
53010
|
const re = new RegExp(
|
|
@@ -53013,7 +53111,7 @@ function csharpMethodScopedAliases(code, seeds, methods, fieldNames) {
|
|
|
53013
53111
|
const declRe = /^\s*(?:public|private|protected|internal|static|readonly|const|\s)*\s*(?:[A-Za-z_][\w.]*(?:\s*<[^>]*>)?(?:\s*\[\s*\])*\??)\s+([A-Za-z_]\w*)\s*=\s*(.+?);\s*$/;
|
|
53014
53112
|
const assignRe = /^\s*(?:this\s*\.\s*)?([A-Za-z_]\w*)\s*=\s*(.+?);\s*$/;
|
|
53015
53113
|
const returnRe = /^\s*return\s+(.+?);\s*$/;
|
|
53016
|
-
const
|
|
53114
|
+
const KEYWORDS4 = /* @__PURE__ */ new Set(["return", "throw", "new", "await", "yield", "else", "case", "using", "var"]);
|
|
53017
53115
|
const codeOf = (rhs) => rhs.replace(/\$@?"(?:[^"\\]|\\.)*"/g, (lit) => " " + [...lit.matchAll(/\{([^}]*)\}/g)].map((x) => x[1]).join(" ") + " ").replace(/@?"(?:[^"\\]|\\.)*"/g, " ").replace(/'(?:[^'\\]|\\.)'/g, " ");
|
|
53018
53116
|
const local = /* @__PURE__ */ new Map();
|
|
53019
53117
|
const taintedFields = /* @__PURE__ */ new Set();
|
|
@@ -53068,7 +53166,7 @@ function csharpMethodScopedAliases(code, seeds, methods, fieldNames) {
|
|
|
53068
53166
|
}
|
|
53069
53167
|
if (!d) continue;
|
|
53070
53168
|
const [, lhs, rhs] = d;
|
|
53071
|
-
if (
|
|
53169
|
+
if (KEYWORDS4.has(lhs)) continue;
|
|
53072
53170
|
const isField = fieldNames.has(lhs) && !declRe.test(text);
|
|
53073
53171
|
if (isField ? taintedFields.has(lhs) : here.has(lhs)) continue;
|
|
53074
53172
|
const rhsCode = codeOf(rhs);
|
|
@@ -53700,6 +53798,15 @@ function sinkNestedInJsTsParseArgs(lineText, sinkMethod) {
|
|
|
53700
53798
|
}
|
|
53701
53799
|
return false;
|
|
53702
53800
|
}
|
|
53801
|
+
function redosColocatedInPatternArg(source, sink, calls) {
|
|
53802
|
+
if (source.variable) return false;
|
|
53803
|
+
const loc = source.location ?? "";
|
|
53804
|
+
const at = loc.indexOf(" in ");
|
|
53805
|
+
const expr = (at >= 0 ? loc.slice(0, at) : loc).trim();
|
|
53806
|
+
if (expr.length < 3) return false;
|
|
53807
|
+
const positions = sink.argPositions && sink.argPositions.length > 0 ? sink.argPositions : [0];
|
|
53808
|
+
return calls.some((c) => c.location.line === sink.line && c.method_name === sink.method && c.arguments.some((a) => positions.includes(a.position) && (a.expression ?? "").includes(expr)));
|
|
53809
|
+
}
|
|
53703
53810
|
function detectExpressionScanFlows(calls, sources, sinks, sanitizers, unreachableLines, tainted, code, language, types) {
|
|
53704
53811
|
const flows = [];
|
|
53705
53812
|
const methodRanges = (langs) => language && langs.includes(language) && types ? types.flatMap((t) => t.methods.map((m) => [m.start_line, m.end_line])) : [];
|
|
@@ -54220,7 +54327,7 @@ function detectExpressionScanFlows(calls, sources, sinks, sanitizers, unreachabl
|
|
|
54220
54327
|
};
|
|
54221
54328
|
const argListRe = /(?<![\w.])(\w+)\s*\.\s*(StartInfo\s*\.\s*)?ArgumentList\s*\.\s*Add\s*\(\s*(.+?)\s*\)\s*;?\s*(?:\/\/.*)?$/;
|
|
54222
54329
|
const shellFlagRe = /^(?:[-/](?:c|k|command|encodedcommand|ec))$/i;
|
|
54223
|
-
const
|
|
54330
|
+
const splitTopLevel3 = (text) => {
|
|
54224
54331
|
const parts2 = [];
|
|
54225
54332
|
let depth = 0;
|
|
54226
54333
|
let quote = "";
|
|
@@ -54268,10 +54375,10 @@ function detectExpressionScanFlows(calls, sources, sinks, sanitizers, unreachabl
|
|
|
54268
54375
|
const m = /new\s+ProcessStartInfo\s*(?:\(([^()]*)\))?\s*(?:\{([\s\S]*)\})?\s*;/.exec(text);
|
|
54269
54376
|
if (!m) return { program: null };
|
|
54270
54377
|
let program;
|
|
54271
|
-
const ctorArgs =
|
|
54378
|
+
const ctorArgs = splitTopLevel3(m[1] ?? "");
|
|
54272
54379
|
if (ctorArgs.length > 1) return { program: null };
|
|
54273
54380
|
if (ctorArgs.length === 1) program = constLiteral(ctorArgs[0]);
|
|
54274
|
-
for (const member of
|
|
54381
|
+
for (const member of splitTopLevel3(m[2] ?? "")) {
|
|
54275
54382
|
const em = /^(\w+)\s*=(?!=)\s*([\s\S]*)$/.exec(member);
|
|
54276
54383
|
if (!em) return { program: null };
|
|
54277
54384
|
if (em[1] === "FileName") {
|
|
@@ -54618,6 +54725,7 @@ function detectExpressionScanFlows(calls, sources, sinks, sanitizers, unreachabl
|
|
|
54618
54725
|
for (const source of colocSources) {
|
|
54619
54726
|
if (!canSourceReachSink(source.type, sink.type)) continue;
|
|
54620
54727
|
if (!sourceSemanticsAllowed(source, sink.type)) continue;
|
|
54728
|
+
if (sink.type === "redos" && !redosColocatedInPatternArg(source, sink, calls)) continue;
|
|
54621
54729
|
const colocLineText = sink.code ?? "";
|
|
54622
54730
|
if (colocLineText && (language === "javascript" || language === "typescript") && source.type === "io_input" && typeof source.location === "string" && source.location.includes(".parse()") && sinkNestedInJsTsParseArgs(colocLineText, sink.method)) {
|
|
54623
54731
|
continue;
|
|
@@ -57774,8 +57882,8 @@ var BlockingMainThreadPass = class {
|
|
|
57774
57882
|
isRequestHandler(method) {
|
|
57775
57883
|
if (method.annotations.some((a) => HTTP_DECORATORS.has(a))) return true;
|
|
57776
57884
|
if (HANDLER_METHOD_NAMES.has(method.name)) return true;
|
|
57777
|
-
const
|
|
57778
|
-
return
|
|
57885
|
+
const paramNames2 = method.parameters.map((p) => p.name.toLowerCase());
|
|
57886
|
+
return paramNames2.some((n) => HANDLER_PARAM_NAMES.has(n));
|
|
57779
57887
|
}
|
|
57780
57888
|
};
|
|
57781
57889
|
|
|
@@ -59712,6 +59820,76 @@ var InsecureCookiePass = class {
|
|
|
59712
59820
|
}
|
|
59713
59821
|
};
|
|
59714
59822
|
|
|
59823
|
+
// src/analysis/passes/_js-crypto-binding.ts
|
|
59824
|
+
var CRYPTO_MODULES = /* @__PURE__ */ new Set(["crypto", "node:crypto"]);
|
|
59825
|
+
var IMPORT_DECL_SPAN = 3;
|
|
59826
|
+
var REQUIRE_CRYPTO_RE = /^require\(\s*(['"])(?:node:)?crypto\1\s*\)$/;
|
|
59827
|
+
function jsCryptoBindings(imports, declarations) {
|
|
59828
|
+
const modules = /* @__PURE__ */ new Set();
|
|
59829
|
+
const named2 = /* @__PURE__ */ new Map();
|
|
59830
|
+
const importLine = /* @__PURE__ */ new Map();
|
|
59831
|
+
for (const imp of imports ?? []) {
|
|
59832
|
+
if (!imp.from_package || !CRYPTO_MODULES.has(imp.from_package)) continue;
|
|
59833
|
+
if (imp.is_type_only) continue;
|
|
59834
|
+
if (imp.is_wildcard || imp.imported_name === "*" || imp.imported_name === "default") {
|
|
59835
|
+
if (imp.alias) {
|
|
59836
|
+
modules.add(imp.alias);
|
|
59837
|
+
importLine.set(imp.alias, imp.line_number);
|
|
59838
|
+
}
|
|
59839
|
+
continue;
|
|
59840
|
+
}
|
|
59841
|
+
const local = imp.alias ?? imp.imported_name;
|
|
59842
|
+
named2.set(local, imp.imported_name);
|
|
59843
|
+
importLine.set(local, imp.line_number);
|
|
59844
|
+
}
|
|
59845
|
+
if (declarations && importLine.size > 0) {
|
|
59846
|
+
for (const name2 of redeclaredNames(importLine, declarations)) {
|
|
59847
|
+
modules.delete(name2);
|
|
59848
|
+
named2.delete(name2);
|
|
59849
|
+
}
|
|
59850
|
+
}
|
|
59851
|
+
return { modules, named: named2 };
|
|
59852
|
+
}
|
|
59853
|
+
function redeclaredNames(importLine, decl) {
|
|
59854
|
+
const out2 = /* @__PURE__ */ new Set();
|
|
59855
|
+
const defs = decl.dfg?.defs ?? [];
|
|
59856
|
+
const ownDef = /* @__PURE__ */ new Map();
|
|
59857
|
+
for (const def of defs) {
|
|
59858
|
+
const line = importLine.get(def.variable);
|
|
59859
|
+
if (line == null || def.kind !== "local") continue;
|
|
59860
|
+
const gap = line - def.line;
|
|
59861
|
+
if (gap < 0 || gap > IMPORT_DECL_SPAN) continue;
|
|
59862
|
+
const prev = ownDef.get(def.variable);
|
|
59863
|
+
if (!prev || def.line > prev.line) ownDef.set(def.variable, def);
|
|
59864
|
+
}
|
|
59865
|
+
for (const def of defs) {
|
|
59866
|
+
if (!importLine.has(def.variable)) continue;
|
|
59867
|
+
if (ownDef.get(def.variable) === def) continue;
|
|
59868
|
+
out2.add(def.variable);
|
|
59869
|
+
}
|
|
59870
|
+
for (const type of decl.types ?? []) {
|
|
59871
|
+
for (const method of type.methods) {
|
|
59872
|
+
if (type.name === "<module>" && importLine.has(method.name)) out2.add(method.name);
|
|
59873
|
+
for (const param of method.parameters) {
|
|
59874
|
+
if (importLine.has(param.name)) out2.add(param.name);
|
|
59875
|
+
}
|
|
59876
|
+
}
|
|
59877
|
+
}
|
|
59878
|
+
return out2;
|
|
59879
|
+
}
|
|
59880
|
+
function cryptoCallAsMember(call, bindings2) {
|
|
59881
|
+
const receiver = (call.receiver ?? "").trim();
|
|
59882
|
+
if (receiver === "crypto") return call;
|
|
59883
|
+
if (!receiver) {
|
|
59884
|
+
const api = bindings2.named.get(call.method_name);
|
|
59885
|
+
return api ? { ...call, receiver: "crypto", method_name: api } : call;
|
|
59886
|
+
}
|
|
59887
|
+
if (bindings2.modules.has(receiver) || REQUIRE_CRYPTO_RE.test(receiver)) {
|
|
59888
|
+
return { ...call, receiver: "crypto" };
|
|
59889
|
+
}
|
|
59890
|
+
return call;
|
|
59891
|
+
}
|
|
59892
|
+
|
|
59715
59893
|
// src/analysis/passes/weak-hash-pass.ts
|
|
59716
59894
|
var WEAK_HASH_NAMES = /* @__PURE__ */ new Set([
|
|
59717
59895
|
"md2",
|
|
@@ -59956,7 +60134,10 @@ var WeakHashPass = class {
|
|
|
59956
60134
|
const findings = [];
|
|
59957
60135
|
const constProp = ctx.hasResult("constant-propagation") ? ctx.getResult("constant-propagation") : null;
|
|
59958
60136
|
const javaBindings = language === "java" ? scanJavaStringBindings(code) : /* @__PURE__ */ new Map();
|
|
59959
|
-
|
|
60137
|
+
const isJs2 = language === "javascript" || language === "typescript";
|
|
60138
|
+
const cryptoBindings = isJs2 ? jsCryptoBindings(graph.ir.imports, graph.ir) : null;
|
|
60139
|
+
for (const irCall of graph.ir.calls) {
|
|
60140
|
+
const call = cryptoBindings ? cryptoCallAsMember(irCall, cryptoBindings) : irCall;
|
|
59960
60141
|
const enclosing = language === "java" ? graph.methodAtLine(call.location.line) : null;
|
|
59961
60142
|
const methodRange = enclosing ? { start: enclosing.method.start_line, end: enclosing.method.end_line } : null;
|
|
59962
60143
|
const detection = this.detect(call, language, constProp, javaBindings, code, ctx.resources, methodRange);
|
|
@@ -60322,7 +60503,10 @@ var WeakCryptoPass = class {
|
|
|
60322
60503
|
evidence: { ...det, language }
|
|
60323
60504
|
});
|
|
60324
60505
|
};
|
|
60325
|
-
|
|
60506
|
+
const isJs2 = language === "javascript" || language === "typescript";
|
|
60507
|
+
const cryptoBindings = isJs2 ? jsCryptoBindings(graph.ir.imports, graph.ir) : null;
|
|
60508
|
+
for (const irCall of graph.ir.calls) {
|
|
60509
|
+
const call = cryptoBindings ? cryptoCallAsMember(irCall, cryptoBindings) : irCall;
|
|
60326
60510
|
for (const det of this.detect(call, language, constProp, literalBindings)) {
|
|
60327
60511
|
emit(call.location.line, det);
|
|
60328
60512
|
}
|
|
@@ -60896,7 +61080,10 @@ var WeakPasswordHashPass = class {
|
|
|
60896
61080
|
return { findings: [] };
|
|
60897
61081
|
}
|
|
60898
61082
|
const findings = [];
|
|
60899
|
-
|
|
61083
|
+
const isJs2 = language === "javascript" || language === "typescript";
|
|
61084
|
+
const cryptoBindings = isJs2 ? jsCryptoBindings(graph.ir.imports, graph.ir) : null;
|
|
61085
|
+
for (const irCall of graph.ir.calls) {
|
|
61086
|
+
const call = cryptoBindings ? cryptoCallAsMember(irCall, cryptoBindings) : irCall;
|
|
60900
61087
|
const detection = this.detect(call, language);
|
|
60901
61088
|
if (!detection) continue;
|
|
60902
61089
|
const { kind, api } = detection;
|
|
@@ -63110,9 +63297,9 @@ function isSecretName(name2) {
|
|
|
63110
63297
|
const ws = words(name2);
|
|
63111
63298
|
if (ws.length === 0) return false;
|
|
63112
63299
|
if (ws.length > 1 && FLAG_PREFIXES.includes(ws[0])) return false;
|
|
63113
|
-
const
|
|
63114
|
-
if (SECRET_NAMES.has(
|
|
63115
|
-
return SECRET_SUFFIXES.some((s) =>
|
|
63300
|
+
const norm2 = ws.join("");
|
|
63301
|
+
if (SECRET_NAMES.has(norm2)) return true;
|
|
63302
|
+
return SECRET_SUFFIXES.some((s) => norm2.length > s.length && norm2.endsWith(s));
|
|
63116
63303
|
}
|
|
63117
63304
|
function isIdentStart(ch) {
|
|
63118
63305
|
return ch >= "a" && ch <= "z" || ch >= "A" && ch <= "Z" || ch === "_" || ch === "$";
|
|
@@ -63387,9 +63574,1498 @@ var SensitiveDataInLogPass = class {
|
|
|
63387
63574
|
}
|
|
63388
63575
|
};
|
|
63389
63576
|
|
|
63577
|
+
// src/analysis/passes/redos-regex-literal-pass.ts
|
|
63578
|
+
var Unsupported = class extends Error {
|
|
63579
|
+
};
|
|
63580
|
+
var MAX_GROUP_DEPTH = 100;
|
|
63581
|
+
var MAX_SOURCE_LENGTH = 1e4;
|
|
63582
|
+
function isDigit(ch) {
|
|
63583
|
+
return ch !== void 0 && ch >= "0" && ch <= "9";
|
|
63584
|
+
}
|
|
63585
|
+
function parseRegex(source) {
|
|
63586
|
+
if (source.length > MAX_SOURCE_LENGTH) return null;
|
|
63587
|
+
let i2 = 0;
|
|
63588
|
+
let depth = 0;
|
|
63589
|
+
const n = source.length;
|
|
63590
|
+
function readEscape() {
|
|
63591
|
+
const c = source[i2 + 1];
|
|
63592
|
+
if (c === void 0) throw new Unsupported();
|
|
63593
|
+
if (c >= "1" && c <= "9") throw new Unsupported();
|
|
63594
|
+
if (c === "k" && source[i2 + 2] === "<") throw new Unsupported();
|
|
63595
|
+
if (c === "b" || c === "B") {
|
|
63596
|
+
i2 += 2;
|
|
63597
|
+
return { kind: "assert" };
|
|
63598
|
+
}
|
|
63599
|
+
if (c === "u" && source[i2 + 2] === "{") {
|
|
63600
|
+
const close = source.indexOf("}", i2 + 3);
|
|
63601
|
+
if (close < 0) throw new Unsupported();
|
|
63602
|
+
i2 = close + 1;
|
|
63603
|
+
return { kind: "char" };
|
|
63604
|
+
}
|
|
63605
|
+
if ((c === "p" || c === "P") && source[i2 + 2] === "{") {
|
|
63606
|
+
const close = source.indexOf("}", i2 + 3);
|
|
63607
|
+
if (close < 0) throw new Unsupported();
|
|
63608
|
+
i2 = close + 1;
|
|
63609
|
+
return { kind: "char" };
|
|
63610
|
+
}
|
|
63611
|
+
if (c === "u") {
|
|
63612
|
+
i2 += 6;
|
|
63613
|
+
return { kind: "char" };
|
|
63614
|
+
}
|
|
63615
|
+
if (c === "x") {
|
|
63616
|
+
i2 += 4;
|
|
63617
|
+
return { kind: "char" };
|
|
63618
|
+
}
|
|
63619
|
+
if (c === "c") {
|
|
63620
|
+
i2 += 3;
|
|
63621
|
+
return { kind: "char" };
|
|
63622
|
+
}
|
|
63623
|
+
i2 += 2;
|
|
63624
|
+
return { kind: "char" };
|
|
63625
|
+
}
|
|
63626
|
+
function readClass() {
|
|
63627
|
+
i2++;
|
|
63628
|
+
if (source[i2] === "^") i2++;
|
|
63629
|
+
while (i2 < n) {
|
|
63630
|
+
const ch = source[i2];
|
|
63631
|
+
if (ch === "\\") {
|
|
63632
|
+
i2 += 2;
|
|
63633
|
+
continue;
|
|
63634
|
+
}
|
|
63635
|
+
i2++;
|
|
63636
|
+
if (ch === "]") return { kind: "char" };
|
|
63637
|
+
}
|
|
63638
|
+
throw new Unsupported();
|
|
63639
|
+
}
|
|
63640
|
+
function readQuantifier() {
|
|
63641
|
+
const ch = source[i2];
|
|
63642
|
+
let q = null;
|
|
63643
|
+
if (ch === "*") {
|
|
63644
|
+
q = { min: 0, max: Infinity };
|
|
63645
|
+
i2++;
|
|
63646
|
+
} else if (ch === "+") {
|
|
63647
|
+
q = { min: 1, max: Infinity };
|
|
63648
|
+
i2++;
|
|
63649
|
+
} else if (ch === "?") {
|
|
63650
|
+
q = { min: 0, max: 1 };
|
|
63651
|
+
i2++;
|
|
63652
|
+
} else if (ch === "{") {
|
|
63653
|
+
let j = i2 + 1;
|
|
63654
|
+
let a = "";
|
|
63655
|
+
while (isDigit(source[j])) a += source[j++];
|
|
63656
|
+
if (a === "") return null;
|
|
63657
|
+
let max = Number(a);
|
|
63658
|
+
if (source[j] === ",") {
|
|
63659
|
+
j++;
|
|
63660
|
+
let b = "";
|
|
63661
|
+
while (isDigit(source[j])) b += source[j++];
|
|
63662
|
+
max = b === "" ? Infinity : Number(b);
|
|
63663
|
+
}
|
|
63664
|
+
if (source[j] !== "}") return null;
|
|
63665
|
+
q = { min: Number(a), max };
|
|
63666
|
+
i2 = j + 1;
|
|
63667
|
+
}
|
|
63668
|
+
if (q && source[i2] === "?") i2++;
|
|
63669
|
+
return q;
|
|
63670
|
+
}
|
|
63671
|
+
function readAlts(inGroup) {
|
|
63672
|
+
const alts = [[]];
|
|
63673
|
+
while (i2 < n) {
|
|
63674
|
+
const ch = source[i2];
|
|
63675
|
+
if (ch === "|") {
|
|
63676
|
+
alts.push([]);
|
|
63677
|
+
i2++;
|
|
63678
|
+
continue;
|
|
63679
|
+
}
|
|
63680
|
+
if (ch === ")") {
|
|
63681
|
+
if (!inGroup) throw new Unsupported();
|
|
63682
|
+
return alts;
|
|
63683
|
+
}
|
|
63684
|
+
let atom;
|
|
63685
|
+
if (ch === "\\") atom = readEscape();
|
|
63686
|
+
else if (ch === "[") atom = readClass();
|
|
63687
|
+
else if (ch === "^") {
|
|
63688
|
+
atom = { kind: "assert" };
|
|
63689
|
+
i2++;
|
|
63690
|
+
} else if (ch === "$") {
|
|
63691
|
+
atom = { kind: "end" };
|
|
63692
|
+
i2++;
|
|
63693
|
+
} else if (ch === "(") {
|
|
63694
|
+
let lookaround = false;
|
|
63695
|
+
if (source[i2 + 1] === "?") {
|
|
63696
|
+
const k = source[i2 + 2];
|
|
63697
|
+
if (k === ":") i2 += 3;
|
|
63698
|
+
else if (k === "=" || k === "!") {
|
|
63699
|
+
lookaround = true;
|
|
63700
|
+
i2 += 3;
|
|
63701
|
+
} else if (k === "<" && (source[i2 + 3] === "=" || source[i2 + 3] === "!")) {
|
|
63702
|
+
lookaround = true;
|
|
63703
|
+
i2 += 4;
|
|
63704
|
+
} else if (k === "<") {
|
|
63705
|
+
const close = source.indexOf(">", i2 + 3);
|
|
63706
|
+
if (close < 0) throw new Unsupported();
|
|
63707
|
+
i2 = close + 1;
|
|
63708
|
+
} else throw new Unsupported();
|
|
63709
|
+
} else i2++;
|
|
63710
|
+
if (++depth > MAX_GROUP_DEPTH) throw new Unsupported();
|
|
63711
|
+
const inner = readAlts(true);
|
|
63712
|
+
depth--;
|
|
63713
|
+
if (source[i2] !== ")") throw new Unsupported();
|
|
63714
|
+
i2++;
|
|
63715
|
+
atom = lookaround ? { kind: "assert" } : { kind: "group", alts: inner };
|
|
63716
|
+
} else {
|
|
63717
|
+
atom = { kind: "char" };
|
|
63718
|
+
i2++;
|
|
63719
|
+
}
|
|
63720
|
+
const q = readQuantifier();
|
|
63721
|
+
alts[alts.length - 1].push({ atom, min: q ? q.min : 1, max: q ? q.max : 1 });
|
|
63722
|
+
}
|
|
63723
|
+
if (inGroup) throw new Unsupported();
|
|
63724
|
+
return alts;
|
|
63725
|
+
}
|
|
63726
|
+
try {
|
|
63727
|
+
const alts = readAlts(false);
|
|
63728
|
+
return i2 === n ? alts : null;
|
|
63729
|
+
} catch (e) {
|
|
63730
|
+
if (e instanceof Unsupported) return null;
|
|
63731
|
+
throw e;
|
|
63732
|
+
}
|
|
63733
|
+
}
|
|
63734
|
+
function canMatchNonEmpty(atom) {
|
|
63735
|
+
if (atom.kind === "char") return true;
|
|
63736
|
+
if (atom.kind !== "group") return false;
|
|
63737
|
+
return atom.alts.some((alt) => alt.some((t) => t.max > 0 && canMatchNonEmpty(t.atom)));
|
|
63738
|
+
}
|
|
63739
|
+
function loopsAlone(t) {
|
|
63740
|
+
if (t.max === 0) return false;
|
|
63741
|
+
if (t.max === Infinity && canMatchNonEmpty(t.atom)) return true;
|
|
63742
|
+
return t.atom.kind === "group" && t.atom.alts.some(altLoopsAlone);
|
|
63743
|
+
}
|
|
63744
|
+
function altLoopsAlone(alt) {
|
|
63745
|
+
for (let i2 = 0; i2 < alt.length; i2++) {
|
|
63746
|
+
if (!loopsAlone(alt[i2])) continue;
|
|
63747
|
+
if (alt.every((t, j) => j === i2 || t.min === 0)) return true;
|
|
63748
|
+
}
|
|
63749
|
+
return false;
|
|
63750
|
+
}
|
|
63751
|
+
function isMandatory(t) {
|
|
63752
|
+
return t.min >= 1 && (t.atom.kind === "end" || canMatchNonEmpty(t.atom));
|
|
63753
|
+
}
|
|
63754
|
+
function isExponentialRegex(source, flags2 = "") {
|
|
63755
|
+
if (flags2.includes("v")) return false;
|
|
63756
|
+
const alts = parseRegex(source);
|
|
63757
|
+
if (!alts) return false;
|
|
63758
|
+
const visit = (seqs, followed) => {
|
|
63759
|
+
for (const seq of seqs) {
|
|
63760
|
+
for (let i2 = 0; i2 < seq.length; i2++) {
|
|
63761
|
+
const t = seq[i2];
|
|
63762
|
+
const after = followed || seq.slice(i2 + 1).some(isMandatory);
|
|
63763
|
+
if (t.atom.kind !== "group") continue;
|
|
63764
|
+
if (t.max === Infinity && after && t.atom.alts.some(altLoopsAlone)) return true;
|
|
63765
|
+
if (visit(t.atom.alts, after)) return true;
|
|
63766
|
+
}
|
|
63767
|
+
}
|
|
63768
|
+
return false;
|
|
63769
|
+
};
|
|
63770
|
+
return visit(alts, false);
|
|
63771
|
+
}
|
|
63772
|
+
function splitRegexLiteral(text) {
|
|
63773
|
+
const t = text.trim();
|
|
63774
|
+
if (t.length < 3 || t[0] !== "/" || t[1] === "/" || t[1] === "*") return null;
|
|
63775
|
+
const end = t.lastIndexOf("/");
|
|
63776
|
+
if (end <= 0) return null;
|
|
63777
|
+
const flags2 = t.slice(end + 1);
|
|
63778
|
+
for (const ch of flags2) if (ch < "a" || ch > "z") return null;
|
|
63779
|
+
const source = t.slice(1, end);
|
|
63780
|
+
let inClass = false;
|
|
63781
|
+
for (let k = 0; k < source.length; k++) {
|
|
63782
|
+
const ch = source[k];
|
|
63783
|
+
if (ch === "\\") {
|
|
63784
|
+
k++;
|
|
63785
|
+
continue;
|
|
63786
|
+
}
|
|
63787
|
+
if (ch === "[") inClass = true;
|
|
63788
|
+
else if (ch === "]") inClass = false;
|
|
63789
|
+
else if (ch === "/" && !inClass) return null;
|
|
63790
|
+
else if (ch === "\n") return null;
|
|
63791
|
+
}
|
|
63792
|
+
return { source, flags: flags2 };
|
|
63793
|
+
}
|
|
63794
|
+
var REQ_NAMES = /* @__PURE__ */ new Set(["req", "request"]);
|
|
63795
|
+
var REQ_PARTS = /* @__PURE__ */ new Set(["query", "body", "params", "headers", "cookies"]);
|
|
63796
|
+
var PRESERVING_METHODS = [".trim()", ".toString()", ".toLowerCase()", ".toUpperCase()"];
|
|
63797
|
+
function isIdentStart2(ch) {
|
|
63798
|
+
return ch !== void 0 && (ch === "_" || ch === "$" || ch >= "a" && ch <= "z" || ch >= "A" && ch <= "Z");
|
|
63799
|
+
}
|
|
63800
|
+
function isIdentChar2(ch) {
|
|
63801
|
+
return isIdentStart2(ch) || isDigit(ch);
|
|
63802
|
+
}
|
|
63803
|
+
function isIdentifier(s) {
|
|
63804
|
+
if (!isIdentStart2(s[0])) return false;
|
|
63805
|
+
for (const ch of s) if (!isIdentChar2(ch)) return false;
|
|
63806
|
+
return true;
|
|
63807
|
+
}
|
|
63808
|
+
function isQuotedEmptyish(s) {
|
|
63809
|
+
const t = s.trim();
|
|
63810
|
+
return t.length >= 2 && (t[0] === "'" || t[0] === '"') && t[t.length - 1] === t[0] && !t.slice(1, -1).includes(t[0]);
|
|
63811
|
+
}
|
|
63812
|
+
function stripWrappers(expr) {
|
|
63813
|
+
let e = expr.trim();
|
|
63814
|
+
for (let guard = 0; guard < 8; guard++) {
|
|
63815
|
+
const before = e;
|
|
63816
|
+
if (e.endsWith(";")) e = e.slice(0, -1).trim();
|
|
63817
|
+
if (e.endsWith("!")) e = e.slice(0, -1).trim();
|
|
63818
|
+
const asAt = e.lastIndexOf(" as ");
|
|
63819
|
+
if (asAt > 0 && isIdentifier(e.slice(asAt + 4).trim())) e = e.slice(0, asAt).trim();
|
|
63820
|
+
for (const op of [" || ", " ?? "]) {
|
|
63821
|
+
const at = e.lastIndexOf(op);
|
|
63822
|
+
if (at > 0 && isQuotedEmptyish(e.slice(at + op.length))) e = e.slice(0, at).trim();
|
|
63823
|
+
}
|
|
63824
|
+
for (const m of PRESERVING_METHODS) if (e.endsWith(m)) e = e.slice(0, -m.length).trim();
|
|
63825
|
+
if (e.startsWith("String(") && e.endsWith(")")) e = e.slice("String(".length, -1).trim();
|
|
63826
|
+
if (e.startsWith("(") && e.endsWith(")") && balancedInner(e)) e = e.slice(1, -1).trim();
|
|
63827
|
+
if (e === before) break;
|
|
63828
|
+
}
|
|
63829
|
+
return e;
|
|
63830
|
+
}
|
|
63831
|
+
function balancedInner(e) {
|
|
63832
|
+
let depth = 0;
|
|
63833
|
+
for (let k = 0; k < e.length; k++) {
|
|
63834
|
+
if (e[k] === "(") depth++;
|
|
63835
|
+
else if (e[k] === ")") {
|
|
63836
|
+
depth--;
|
|
63837
|
+
if (depth === 0 && k !== e.length - 1) return false;
|
|
63838
|
+
}
|
|
63839
|
+
}
|
|
63840
|
+
return depth === 0;
|
|
63841
|
+
}
|
|
63842
|
+
function requestMemberBase(expr) {
|
|
63843
|
+
const e = stripWrappers(expr);
|
|
63844
|
+
const dot = e.indexOf(".");
|
|
63845
|
+
if (dot <= 0) return null;
|
|
63846
|
+
const base = e.slice(0, dot);
|
|
63847
|
+
if (!REQ_NAMES.has(base)) return null;
|
|
63848
|
+
let k = dot + 1;
|
|
63849
|
+
let part = "";
|
|
63850
|
+
while (isIdentChar2(e[k])) part += e[k++];
|
|
63851
|
+
if (!REQ_PARTS.has(part)) return null;
|
|
63852
|
+
let segments = 0;
|
|
63853
|
+
while (k < e.length) {
|
|
63854
|
+
if (e[k] === ".") {
|
|
63855
|
+
k++;
|
|
63856
|
+
const start2 = k;
|
|
63857
|
+
while (isIdentChar2(e[k])) k++;
|
|
63858
|
+
if (k === start2) return null;
|
|
63859
|
+
const seg = e.slice(start2, k);
|
|
63860
|
+
if (seg === "length") return null;
|
|
63861
|
+
segments++;
|
|
63862
|
+
} else if (e[k] === "[") {
|
|
63863
|
+
const q = e[k + 1];
|
|
63864
|
+
if (q !== "'" && q !== '"') return null;
|
|
63865
|
+
const close = e.indexOf(q, k + 2);
|
|
63866
|
+
if (close < 0 || e[close + 1] !== "]") return null;
|
|
63867
|
+
k = close + 2;
|
|
63868
|
+
segments++;
|
|
63869
|
+
} else return null;
|
|
63870
|
+
}
|
|
63871
|
+
if (segments === 0 && part !== "body") return null;
|
|
63872
|
+
return base;
|
|
63873
|
+
}
|
|
63874
|
+
function reachingDef(lk, variable, line) {
|
|
63875
|
+
for (const u of lk.dfg.uses) {
|
|
63876
|
+
if (u.variable !== variable || u.line !== line || u.def_id === null) continue;
|
|
63877
|
+
return lk.defsById.get(u.def_id) ?? null;
|
|
63878
|
+
}
|
|
63879
|
+
return null;
|
|
63880
|
+
}
|
|
63881
|
+
function isParamAt(lk, base, line) {
|
|
63882
|
+
const d = reachingDef(lk, base, line);
|
|
63883
|
+
return d !== null && d.kind === "param";
|
|
63884
|
+
}
|
|
63885
|
+
function destructuresName(pattern, name2) {
|
|
63886
|
+
for (const raw of pattern.split(",")) {
|
|
63887
|
+
let p = raw.trim();
|
|
63888
|
+
const eq = p.indexOf("=");
|
|
63889
|
+
if (eq >= 0) p = p.slice(0, eq).trim();
|
|
63890
|
+
const colon = p.indexOf(":");
|
|
63891
|
+
const bound = colon >= 0 ? p.slice(colon + 1).trim() : p;
|
|
63892
|
+
if (bound === name2) return true;
|
|
63893
|
+
}
|
|
63894
|
+
return false;
|
|
63895
|
+
}
|
|
63896
|
+
function isRequestValue(lk, expr, line, depth) {
|
|
63897
|
+
const e = stripWrappers(expr);
|
|
63898
|
+
const base = requestMemberBase(e);
|
|
63899
|
+
if (base) return isParamAt(lk, base, line);
|
|
63900
|
+
if (!isIdentifier(e) || depth <= 0) return false;
|
|
63901
|
+
const def = reachingDef(lk, e, line);
|
|
63902
|
+
if (!def || def.kind !== "local") return false;
|
|
63903
|
+
const text = (lk.lines[def.line - 1] ?? "").trim();
|
|
63904
|
+
const rhs = definitionRhs(text, e);
|
|
63905
|
+
if (rhs === null) return false;
|
|
63906
|
+
if (rhs.destructured) {
|
|
63907
|
+
const b = requestMemberBase(rhs.expr) ?? (REQ_NAMES.has(rhs.expr.split(".")[0]) ? partOnly(rhs.expr) : null);
|
|
63908
|
+
return b !== null && isParamAt(lk, b, def.line);
|
|
63909
|
+
}
|
|
63910
|
+
return isRequestValue(lk, rhs.expr, def.line, depth - 1);
|
|
63911
|
+
}
|
|
63912
|
+
function partOnly(expr) {
|
|
63913
|
+
const e = stripWrappers(expr);
|
|
63914
|
+
const dot = e.indexOf(".");
|
|
63915
|
+
if (dot <= 0) return null;
|
|
63916
|
+
const base = e.slice(0, dot);
|
|
63917
|
+
return REQ_NAMES.has(base) && REQ_PARTS.has(e.slice(dot + 1)) ? base : null;
|
|
63918
|
+
}
|
|
63919
|
+
function definitionRhs(text, name2) {
|
|
63920
|
+
let t = text;
|
|
63921
|
+
for (const kw of ["const ", "let ", "var "]) if (t.startsWith(kw)) {
|
|
63922
|
+
t = t.slice(kw.length).trim();
|
|
63923
|
+
break;
|
|
63924
|
+
}
|
|
63925
|
+
if (t.startsWith("{")) {
|
|
63926
|
+
const close = t.indexOf("}");
|
|
63927
|
+
if (close < 0) return null;
|
|
63928
|
+
if (!destructuresName(t.slice(1, close), name2)) return null;
|
|
63929
|
+
const rest2 = t.slice(close + 1).trim();
|
|
63930
|
+
if (!rest2.startsWith("=")) return null;
|
|
63931
|
+
return { expr: trimStatement(rest2.slice(1)), destructured: true };
|
|
63932
|
+
}
|
|
63933
|
+
if (!t.startsWith(name2)) return null;
|
|
63934
|
+
let rest = t.slice(name2.length);
|
|
63935
|
+
if (isIdentChar2(rest[0])) return null;
|
|
63936
|
+
rest = rest.trim();
|
|
63937
|
+
if (rest.startsWith(":")) {
|
|
63938
|
+
const eq = rest.indexOf("=");
|
|
63939
|
+
if (eq < 0) return null;
|
|
63940
|
+
rest = rest.slice(eq);
|
|
63941
|
+
}
|
|
63942
|
+
if (!rest.startsWith("=") || rest.startsWith("==") || rest.startsWith("=>")) return null;
|
|
63943
|
+
return { expr: trimStatement(rest.slice(1)), destructured: false };
|
|
63944
|
+
}
|
|
63945
|
+
function trimStatement(s) {
|
|
63946
|
+
let e = s.trim();
|
|
63947
|
+
if (e.endsWith(";")) e = e.slice(0, -1).trim();
|
|
63948
|
+
return e;
|
|
63949
|
+
}
|
|
63950
|
+
function regexOf(lk, text) {
|
|
63951
|
+
const t = text.trim();
|
|
63952
|
+
const direct = splitRegexLiteral(t);
|
|
63953
|
+
if (direct) return { ...direct, literal: t };
|
|
63954
|
+
if (!isIdentifier(t)) return null;
|
|
63955
|
+
const defs = lk.dfg.defs.filter((d) => d.variable === t);
|
|
63956
|
+
if (defs.length !== 1) return null;
|
|
63957
|
+
const line = (lk.lines[defs[0].line - 1] ?? "").trim();
|
|
63958
|
+
if (!line.startsWith("const ")) return null;
|
|
63959
|
+
const rhs = definitionRhs(line, t);
|
|
63960
|
+
if (!rhs || rhs.destructured) return null;
|
|
63961
|
+
const lit = splitRegexLiteral(rhs.expr);
|
|
63962
|
+
return lit ? { ...lit, literal: rhs.expr } : null;
|
|
63963
|
+
}
|
|
63964
|
+
var RECEIVER_REGEX_METHODS = /* @__PURE__ */ new Set(["test", "exec"]);
|
|
63965
|
+
var STRING_REGEX_METHODS = /* @__PURE__ */ new Set(["match", "matchAll", "search", "replace", "replaceAll", "split"]);
|
|
63966
|
+
function regexApplication(call) {
|
|
63967
|
+
const receiver = (call.receiver ?? "").trim();
|
|
63968
|
+
if (!receiver) return null;
|
|
63969
|
+
const arg0 = call.arguments.find((a) => a.position === 0)?.expression?.trim();
|
|
63970
|
+
if (!arg0) return null;
|
|
63971
|
+
if (RECEIVER_REGEX_METHODS.has(call.method_name)) return { regex: receiver, subject: arg0 };
|
|
63972
|
+
if (STRING_REGEX_METHODS.has(call.method_name)) return { regex: arg0, subject: receiver };
|
|
63973
|
+
return null;
|
|
63974
|
+
}
|
|
63975
|
+
var RedosRegexLiteralPass = class {
|
|
63976
|
+
name = "redos-regex-literal";
|
|
63977
|
+
category = "security";
|
|
63978
|
+
run(ctx) {
|
|
63979
|
+
const { graph, language, code } = ctx;
|
|
63980
|
+
const findings = [];
|
|
63981
|
+
if (language !== "javascript" && language !== "typescript") return { findings };
|
|
63982
|
+
const dfg = graph.ir.dfg;
|
|
63983
|
+
if (!dfg) return { findings };
|
|
63984
|
+
const lk = { dfg, lines: code.split("\n"), defsById: new Map(dfg.defs.map((d) => [d.id, d])) };
|
|
63985
|
+
const file = graph.ir.meta.file;
|
|
63986
|
+
const seen = /* @__PURE__ */ new Set();
|
|
63987
|
+
for (const call of graph.ir.calls) {
|
|
63988
|
+
const app = regexApplication(call);
|
|
63989
|
+
if (!app) continue;
|
|
63990
|
+
const line = call.location.line;
|
|
63991
|
+
if (seen.has(line)) continue;
|
|
63992
|
+
const re = regexOf(lk, app.regex);
|
|
63993
|
+
if (!re || !isExponentialRegex(re.source, re.flags)) continue;
|
|
63994
|
+
if (!isRequestValue(lk, app.subject, line, 3)) continue;
|
|
63995
|
+
seen.add(line);
|
|
63996
|
+
findings.push({ line, regex: re.literal, subject: app.subject });
|
|
63997
|
+
ctx.addFinding({
|
|
63998
|
+
id: `${this.name}-${file}-${line}`,
|
|
63999
|
+
pass: this.name,
|
|
64000
|
+
category: this.category,
|
|
64001
|
+
rule_id: this.name,
|
|
64002
|
+
cwe: "CWE-1333",
|
|
64003
|
+
severity: "medium",
|
|
64004
|
+
level: "warning",
|
|
64005
|
+
message: `Request value \`${app.subject}\` is matched against \`${re.literal}\`, a regex with a repeated group whose body can repeat on its own. A crafted input that almost matches makes the engine try exponentially many splits and blocks the event loop.`,
|
|
64006
|
+
file,
|
|
64007
|
+
line,
|
|
64008
|
+
fix: "Rewrite the pattern so each input character has one way to match: drop the outer repetition (`^[a-z0-9]+$` rather than `^([a-z0-9]+)*$`), or make the repeated body start with a required separator (`^\\w+(\\s\\w+)*$`). Bounding the input length limits but does not remove the cost.",
|
|
64009
|
+
evidence: { regex: re.literal, subject: app.subject, language }
|
|
64010
|
+
});
|
|
64011
|
+
}
|
|
64012
|
+
return { findings };
|
|
64013
|
+
}
|
|
64014
|
+
};
|
|
64015
|
+
|
|
64016
|
+
// src/analysis/passes/hardcoded-secret-argument-pass.ts
|
|
64017
|
+
var CRYPTO = ["crypto", "node:crypto"];
|
|
64018
|
+
var MYSQL = ["mysql", "mysql2", "mysql2/promise"];
|
|
64019
|
+
var RULES = [
|
|
64020
|
+
{ packages: ["jsonwebtoken"], name: "sign", form: "member", positions: [{ kind: "arg", index: 1 }], label: "jwt.sign signing key" },
|
|
64021
|
+
{ packages: ["jsonwebtoken"], name: "verify", form: "member", positions: [{ kind: "arg", index: 1 }], label: "jwt.verify key" },
|
|
64022
|
+
{ packages: CRYPTO, name: "createHmac", form: "member", positions: [{ kind: "arg", index: 1 }], label: "HMAC key" },
|
|
64023
|
+
{ packages: CRYPTO, name: "createHmac", form: "bare", positions: [{ kind: "arg", index: 1 }], label: "HMAC key" },
|
|
64024
|
+
{ packages: CRYPTO, name: "createCipheriv", form: "member", positions: [{ kind: "arg", index: 1 }], label: "cipher key" },
|
|
64025
|
+
{ packages: CRYPTO, name: "createCipheriv", form: "bare", positions: [{ kind: "arg", index: 1 }], label: "cipher key" },
|
|
64026
|
+
{ packages: CRYPTO, name: "createDecipheriv", form: "member", positions: [{ kind: "arg", index: 1 }], label: "cipher key" },
|
|
64027
|
+
{ packages: CRYPTO, name: "createDecipheriv", form: "bare", positions: [{ kind: "arg", index: 1 }], label: "cipher key" },
|
|
64028
|
+
{ packages: ["express-session"], name: "*", form: "bare", positions: [{ kind: "prop", index: 0, path: ["secret"], arrays: true }], label: "session secret" },
|
|
64029
|
+
{
|
|
64030
|
+
packages: ["cookie-session"],
|
|
64031
|
+
name: "*",
|
|
64032
|
+
form: "bare",
|
|
64033
|
+
positions: [{ kind: "prop", index: 0, path: ["secret"] }, { kind: "prop", index: 0, path: ["keys"], arrays: true }],
|
|
64034
|
+
label: "cookie-session key"
|
|
64035
|
+
},
|
|
64036
|
+
{ packages: ["cookie-parser"], name: "*", form: "bare", positions: [{ kind: "arg", index: 0, arrays: true }], label: "cookie-parser secret" },
|
|
64037
|
+
{ packages: ["express-jwt"], name: "*", form: "bare", positions: [{ kind: "prop", index: 0, path: ["secret"] }], label: "express-jwt secret" },
|
|
64038
|
+
{ packages: ["passport-jwt"], name: "JwtStrategy", form: "bare", nameFallback: true, positions: [{ kind: "prop", index: 0, path: ["secretOrKey"] }], label: "passport-jwt secretOrKey" },
|
|
64039
|
+
{ packages: ["passport-jwt"], name: "Strategy", form: "bare", positions: [{ kind: "prop", index: 0, path: ["secretOrKey"] }], label: "passport-jwt secretOrKey" },
|
|
64040
|
+
{ packages: MYSQL, name: "createConnection", form: "member", positions: [{ kind: "prop", index: 0, path: ["password"] }], label: "database password" },
|
|
64041
|
+
{ packages: MYSQL, name: "createPool", form: "member", positions: [{ kind: "prop", index: 0, path: ["password"] }], label: "database password" },
|
|
64042
|
+
{ packages: ["pg"], name: "Pool", form: "bare", positions: [{ kind: "prop", index: 0, path: ["password"] }], label: "database password" },
|
|
64043
|
+
{ packages: ["pg"], name: "Client", form: "bare", positions: [{ kind: "prop", index: 0, path: ["password"] }], label: "database password" },
|
|
64044
|
+
{ packages: ["pg"], name: "Pool", form: "member", positions: [{ kind: "prop", index: 0, path: ["password"] }], label: "database password" },
|
|
64045
|
+
{ packages: ["pg"], name: "Client", form: "member", positions: [{ kind: "prop", index: 0, path: ["password"] }], label: "database password" },
|
|
64046
|
+
{ packages: ["sequelize"], name: "Sequelize", form: "bare", positions: [{ kind: "arg", index: 2 }], label: "database password" },
|
|
64047
|
+
{ packages: ["nodemailer"], name: "createTransport", form: "member", positions: [{ kind: "prop", index: 0, path: ["auth", "pass"] }], label: "SMTP password" }
|
|
64048
|
+
];
|
|
64049
|
+
function bindings(imports) {
|
|
64050
|
+
const m = /* @__PURE__ */ new Map();
|
|
64051
|
+
for (const imp of imports) {
|
|
64052
|
+
if (!imp.from_package) continue;
|
|
64053
|
+
const local = imp.alias ?? (imp.imported_name !== "default" && imp.imported_name !== "*" ? imp.imported_name : null);
|
|
64054
|
+
if (local) m.set(local, imp.from_package);
|
|
64055
|
+
}
|
|
64056
|
+
return m;
|
|
64057
|
+
}
|
|
64058
|
+
function importsName(imports, local) {
|
|
64059
|
+
return imports.find((i2) => (i2.alias ?? i2.imported_name) === local && i2.from_package != null);
|
|
64060
|
+
}
|
|
64061
|
+
function skipString2(s, i2) {
|
|
64062
|
+
const q = s[i2];
|
|
64063
|
+
for (let j = i2 + 1; j < s.length; j++) {
|
|
64064
|
+
if (s[j] === "\\") {
|
|
64065
|
+
j++;
|
|
64066
|
+
continue;
|
|
64067
|
+
}
|
|
64068
|
+
if (s[j] === q) return j + 1;
|
|
64069
|
+
}
|
|
64070
|
+
return -1;
|
|
64071
|
+
}
|
|
64072
|
+
function splitTopLevel2(s, sep) {
|
|
64073
|
+
const out2 = [];
|
|
64074
|
+
let depth = 0;
|
|
64075
|
+
let start2 = 0;
|
|
64076
|
+
for (let i2 = 0; i2 < s.length; i2++) {
|
|
64077
|
+
const ch = s[i2];
|
|
64078
|
+
if (ch === '"' || ch === "'" || ch === "`") {
|
|
64079
|
+
const end = skipString2(s, i2);
|
|
64080
|
+
if (end < 0) return null;
|
|
64081
|
+
i2 = end - 1;
|
|
64082
|
+
continue;
|
|
64083
|
+
}
|
|
64084
|
+
if (ch === "(" || ch === "[" || ch === "{") depth++;
|
|
64085
|
+
else if (ch === ")" || ch === "]" || ch === "}") {
|
|
64086
|
+
depth--;
|
|
64087
|
+
if (depth < 0) return null;
|
|
64088
|
+
} else if (ch === sep && depth === 0) {
|
|
64089
|
+
out2.push(s.slice(start2, i2));
|
|
64090
|
+
start2 = i2 + 1;
|
|
64091
|
+
}
|
|
64092
|
+
}
|
|
64093
|
+
if (depth !== 0) return null;
|
|
64094
|
+
out2.push(s.slice(start2));
|
|
64095
|
+
return out2;
|
|
64096
|
+
}
|
|
64097
|
+
function stringLiteralValue(expr) {
|
|
64098
|
+
const e = expr.trim();
|
|
64099
|
+
if (e.length < 2) return null;
|
|
64100
|
+
const q = e[0];
|
|
64101
|
+
if (q !== '"' && q !== "'" && q !== "`" || e[e.length - 1] !== q) return null;
|
|
64102
|
+
if (skipString2(e, 0) !== e.length) return null;
|
|
64103
|
+
const body2 = e.slice(1, -1);
|
|
64104
|
+
if (q === "`" && body2.includes("${")) return null;
|
|
64105
|
+
return body2;
|
|
64106
|
+
}
|
|
64107
|
+
function literalValues(expr, arrays) {
|
|
64108
|
+
const one = stringLiteralValue(expr);
|
|
64109
|
+
if (one !== null) return [one];
|
|
64110
|
+
if (!arrays) return null;
|
|
64111
|
+
const e = expr.trim();
|
|
64112
|
+
if (!e.startsWith("[") || !e.endsWith("]")) return null;
|
|
64113
|
+
const parts2 = splitTopLevel2(e.slice(1, -1), ",");
|
|
64114
|
+
if (!parts2) return null;
|
|
64115
|
+
const vals = [];
|
|
64116
|
+
for (const p of parts2) {
|
|
64117
|
+
if (p.trim() === "") continue;
|
|
64118
|
+
const v = stringLiteralValue(p);
|
|
64119
|
+
if (v === null) return null;
|
|
64120
|
+
vals.push(v);
|
|
64121
|
+
}
|
|
64122
|
+
return vals.length > 0 ? vals : null;
|
|
64123
|
+
}
|
|
64124
|
+
function propertyValue(expr, path) {
|
|
64125
|
+
let cur = expr.trim();
|
|
64126
|
+
for (const key of path) {
|
|
64127
|
+
if (!cur.startsWith("{") || !cur.endsWith("}")) return null;
|
|
64128
|
+
const entries = splitTopLevel2(cur.slice(1, -1), ",");
|
|
64129
|
+
if (!entries) return null;
|
|
64130
|
+
let found = null;
|
|
64131
|
+
for (const entry of entries) {
|
|
64132
|
+
const colon = topLevelColon2(entry);
|
|
64133
|
+
if (colon < 0) continue;
|
|
64134
|
+
let k = (entry.slice(0, colon).split("\n").pop() ?? "").trim();
|
|
64135
|
+
const kq = stringLiteralValue(k);
|
|
64136
|
+
if (kq !== null) k = kq;
|
|
64137
|
+
if (k === key) found = entry.slice(colon + 1).trim();
|
|
64138
|
+
}
|
|
64139
|
+
if (found === null) return null;
|
|
64140
|
+
cur = found;
|
|
64141
|
+
}
|
|
64142
|
+
return cur;
|
|
64143
|
+
}
|
|
64144
|
+
function topLevelColon2(entry) {
|
|
64145
|
+
let depth = 0;
|
|
64146
|
+
for (let i2 = 0; i2 < entry.length; i2++) {
|
|
64147
|
+
const ch = entry[i2];
|
|
64148
|
+
if (ch === '"' || ch === "'" || ch === "`") {
|
|
64149
|
+
const end = skipString2(entry, i2);
|
|
64150
|
+
if (end < 0) return -1;
|
|
64151
|
+
i2 = end - 1;
|
|
64152
|
+
continue;
|
|
64153
|
+
}
|
|
64154
|
+
if (ch === "(" || ch === "[" || ch === "{") depth++;
|
|
64155
|
+
else if (ch === ")" || ch === "]" || ch === "}") depth--;
|
|
64156
|
+
else if (ch === ":" && depth === 0) return i2;
|
|
64157
|
+
}
|
|
64158
|
+
return -1;
|
|
64159
|
+
}
|
|
64160
|
+
var SLOT_NAMES = /* @__PURE__ */ new Set(["password", "passwd", "pass", "secret", "key", "username", "user", "token"]);
|
|
64161
|
+
function isRealSecret(v) {
|
|
64162
|
+
if (v.trim() === "") return false;
|
|
64163
|
+
if (PLACEHOLDER_RE.test(v)) return false;
|
|
64164
|
+
if (SLOT_NAMES.has(v.trim().toLowerCase())) return false;
|
|
64165
|
+
return true;
|
|
64166
|
+
}
|
|
64167
|
+
function isSqliteSequelize(call) {
|
|
64168
|
+
const opts = call.arguments.find((a) => a.position === 3)?.expression;
|
|
64169
|
+
if (!opts) return false;
|
|
64170
|
+
const dialect = propertyValue(opts, ["dialect"]);
|
|
64171
|
+
return dialect !== null && stringLiteralValue(dialect) === "sqlite";
|
|
64172
|
+
}
|
|
64173
|
+
function matchRule(call, imports) {
|
|
64174
|
+
const binds = bindings(imports);
|
|
64175
|
+
const receiver = (call.receiver ?? "").trim();
|
|
64176
|
+
for (const rule of RULES) {
|
|
64177
|
+
if (rule.form === "member") {
|
|
64178
|
+
if (!receiver || call.method_name !== rule.name) continue;
|
|
64179
|
+
const root = receiver.split(".")[0];
|
|
64180
|
+
const pkg = binds.get(root);
|
|
64181
|
+
if (pkg && rule.packages.includes(pkg)) return rule;
|
|
64182
|
+
continue;
|
|
64183
|
+
}
|
|
64184
|
+
if (receiver) continue;
|
|
64185
|
+
const imp = importsName(imports, call.method_name);
|
|
64186
|
+
if (imp && imp.from_package && rule.packages.includes(imp.from_package)) {
|
|
64187
|
+
if (rule.name === "*") return rule;
|
|
64188
|
+
if (call.method_name === rule.name || imp.imported_name === rule.name) return rule;
|
|
64189
|
+
continue;
|
|
64190
|
+
}
|
|
64191
|
+
if (!imp && rule.nameFallback && call.method_name === rule.name) return rule;
|
|
64192
|
+
}
|
|
64193
|
+
return null;
|
|
64194
|
+
}
|
|
64195
|
+
var HardcodedSecretArgumentPass = class {
|
|
64196
|
+
name = "hardcoded-secret-argument";
|
|
64197
|
+
category = "security";
|
|
64198
|
+
run(ctx) {
|
|
64199
|
+
const { graph, language } = ctx;
|
|
64200
|
+
const findings = [];
|
|
64201
|
+
if (language !== "javascript" && language !== "typescript") return { findings };
|
|
64202
|
+
const file = graph.ir.meta.file;
|
|
64203
|
+
if (isTestFile(file) || isGeneratedFile(file)) return { findings };
|
|
64204
|
+
const imports = graph.ir.imports ?? [];
|
|
64205
|
+
if (imports.length === 0 && !ctx.code.includes("JwtStrategy")) return { findings };
|
|
64206
|
+
const seen = /* @__PURE__ */ new Set();
|
|
64207
|
+
for (const f of ctx.getFindings?.() ?? []) {
|
|
64208
|
+
if (f.file === file && (f.rule_id === "hardcoded-credential" || f.rule_id === "hardcoded-credential-entropy")) seen.add(f.line);
|
|
64209
|
+
}
|
|
64210
|
+
const lineStarts = [0];
|
|
64211
|
+
for (let i2 = 0; i2 < ctx.code.length; i2++) if (ctx.code[i2] === "\n") lineStarts.push(i2 + 1);
|
|
64212
|
+
const lineAt = (offset) => {
|
|
64213
|
+
let lo = 0, hi = lineStarts.length - 1;
|
|
64214
|
+
while (lo < hi) {
|
|
64215
|
+
const mid = lo + hi + 1 >> 1;
|
|
64216
|
+
if (lineStarts[mid] <= offset) lo = mid;
|
|
64217
|
+
else hi = mid - 1;
|
|
64218
|
+
}
|
|
64219
|
+
return lo + 1;
|
|
64220
|
+
};
|
|
64221
|
+
for (const call of graph.ir.calls) {
|
|
64222
|
+
const rule = matchRule(call, imports);
|
|
64223
|
+
if (!rule) continue;
|
|
64224
|
+
if (rule.name === "Sequelize" && isSqliteSequelize(call)) continue;
|
|
64225
|
+
for (const pos of rule.positions) {
|
|
64226
|
+
const arg = call.arguments.find((a) => a.position === pos.index);
|
|
64227
|
+
if (!arg || !arg.expression) continue;
|
|
64228
|
+
const valueText = pos.kind === "arg" ? arg.expression : propertyValue(arg.expression, pos.path);
|
|
64229
|
+
if (valueText === null) continue;
|
|
64230
|
+
const vals = literalValues(valueText, pos.arrays === true);
|
|
64231
|
+
if (!vals || !vals.some(isRealSecret)) continue;
|
|
64232
|
+
let line = call.location.line;
|
|
64233
|
+
const from = lineStarts[Math.max(0, call.location.line - 1)] ?? 0;
|
|
64234
|
+
const argAt = ctx.code.indexOf(arg.expression, from);
|
|
64235
|
+
if (argAt >= 0) {
|
|
64236
|
+
const inArg = pos.kind === "arg" ? 0 : arg.expression.lastIndexOf(valueText);
|
|
64237
|
+
if (inArg >= 0) line = lineAt(argAt + inArg);
|
|
64238
|
+
}
|
|
64239
|
+
if (seen.has(line)) continue;
|
|
64240
|
+
seen.add(line);
|
|
64241
|
+
const api = call.receiver ? `${call.receiver}.${call.method_name}` : call.method_name;
|
|
64242
|
+
findings.push({ line, api, label: rule.label });
|
|
64243
|
+
ctx.addFinding({
|
|
64244
|
+
id: `hardcoded-credential-${file}-${line}`,
|
|
64245
|
+
pass: this.name,
|
|
64246
|
+
category: this.category,
|
|
64247
|
+
rule_id: "hardcoded-credential",
|
|
64248
|
+
cwe: "CWE-798",
|
|
64249
|
+
severity: "high",
|
|
64250
|
+
level: "error",
|
|
64251
|
+
message: `Hardcoded credential: a string literal is passed as the ${rule.label} of \`${api}\`. Anyone who can read the source can sign, decrypt or log in with it.`,
|
|
64252
|
+
file,
|
|
64253
|
+
line,
|
|
64254
|
+
fix: "Load the secret from the environment or a secrets manager (for example `process.env.JWT_SECRET`), and rotate the exposed value.",
|
|
64255
|
+
evidence: { kind: "secret-argument", api, position: rule.label, language }
|
|
64256
|
+
});
|
|
64257
|
+
}
|
|
64258
|
+
}
|
|
64259
|
+
return { findings };
|
|
64260
|
+
}
|
|
64261
|
+
};
|
|
64262
|
+
|
|
64263
|
+
// src/analysis/passes/missing-auth-middleware-pass.ts
|
|
64264
|
+
var ROUTE_METHODS = /* @__PURE__ */ new Set(["get", "post", "put", "patch", "delete", "all"]);
|
|
64265
|
+
var MUTATING_METHODS = /* @__PURE__ */ new Set(["post", "put", "patch", "delete"]);
|
|
64266
|
+
var AUTHN_NAMES = /* @__PURE__ */ new Set([
|
|
64267
|
+
"auth",
|
|
64268
|
+
"authenticate",
|
|
64269
|
+
"authenticated",
|
|
64270
|
+
"isauthenticated",
|
|
64271
|
+
"ensureauthenticated",
|
|
64272
|
+
"ensureauth",
|
|
64273
|
+
"ensureloggedin",
|
|
64274
|
+
"isloggedin",
|
|
64275
|
+
"loggedin",
|
|
64276
|
+
"requireauth",
|
|
64277
|
+
"requireauthentication",
|
|
64278
|
+
"requirelogin",
|
|
64279
|
+
"requireslogin",
|
|
64280
|
+
"mustbeloggedin",
|
|
64281
|
+
"requireuser",
|
|
64282
|
+
"requiresuser",
|
|
64283
|
+
"authmiddleware",
|
|
64284
|
+
"authrequired",
|
|
64285
|
+
"loginrequired",
|
|
64286
|
+
"verifytoken",
|
|
64287
|
+
"verifyjwt",
|
|
64288
|
+
"checkjwt",
|
|
64289
|
+
"jwt",
|
|
64290
|
+
"expressjwt",
|
|
64291
|
+
"jwtauth",
|
|
64292
|
+
"checkauth",
|
|
64293
|
+
"protect",
|
|
64294
|
+
"authguard",
|
|
64295
|
+
"requiresession",
|
|
64296
|
+
"withauth",
|
|
64297
|
+
"needsauth",
|
|
64298
|
+
"isauth",
|
|
64299
|
+
"isuser"
|
|
64300
|
+
]);
|
|
64301
|
+
var AUTHZ_NAMES = /* @__PURE__ */ new Set([
|
|
64302
|
+
"authorize",
|
|
64303
|
+
"authorized",
|
|
64304
|
+
"isauthorized",
|
|
64305
|
+
"isadmin",
|
|
64306
|
+
"requireadmin",
|
|
64307
|
+
"adminonly",
|
|
64308
|
+
"ensureadmin",
|
|
64309
|
+
"hasrole",
|
|
64310
|
+
"requirerole",
|
|
64311
|
+
"checkrole",
|
|
64312
|
+
"restrictto",
|
|
64313
|
+
"permit",
|
|
64314
|
+
"haspermission",
|
|
64315
|
+
"requirepermission",
|
|
64316
|
+
"checkpermission",
|
|
64317
|
+
"denyall",
|
|
64318
|
+
"isowner",
|
|
64319
|
+
"requireowner",
|
|
64320
|
+
"checkowner"
|
|
64321
|
+
]);
|
|
64322
|
+
function isIdentChar3(ch) {
|
|
64323
|
+
return ch !== void 0 && (ch === "_" || ch === "$" || ch >= "a" && ch <= "z" || ch >= "A" && ch <= "Z" || ch >= "0" && ch <= "9");
|
|
64324
|
+
}
|
|
64325
|
+
function isIdentifier2(s) {
|
|
64326
|
+
if (s.length === 0 || s[0] >= "0" && s[0] <= "9") return false;
|
|
64327
|
+
for (const ch of s) if (!isIdentChar3(ch)) return false;
|
|
64328
|
+
return true;
|
|
64329
|
+
}
|
|
64330
|
+
function middlewareName(expr) {
|
|
64331
|
+
let e = expr.trim();
|
|
64332
|
+
const paren = e.indexOf("(");
|
|
64333
|
+
if (paren >= 0) {
|
|
64334
|
+
if (!e.endsWith(")")) return null;
|
|
64335
|
+
e = e.slice(0, paren).trim();
|
|
64336
|
+
}
|
|
64337
|
+
const segs = e.split(".");
|
|
64338
|
+
for (const s of segs) if (!isIdentifier2(s.trim())) return null;
|
|
64339
|
+
return segs[segs.length - 1].trim();
|
|
64340
|
+
}
|
|
64341
|
+
function norm(name2) {
|
|
64342
|
+
let out2 = "";
|
|
64343
|
+
for (const ch of name2) if (ch !== "_" && ch !== "-" && ch !== "$") out2 += ch.toLowerCase();
|
|
64344
|
+
return out2;
|
|
64345
|
+
}
|
|
64346
|
+
function guardKind(expr) {
|
|
64347
|
+
const name2 = middlewareName(expr);
|
|
64348
|
+
if (!name2) return null;
|
|
64349
|
+
const n = norm(name2);
|
|
64350
|
+
if (AUTHN_NAMES.has(n)) return "authn";
|
|
64351
|
+
if (AUTHZ_NAMES.has(n)) return "authz";
|
|
64352
|
+
return null;
|
|
64353
|
+
}
|
|
64354
|
+
function stringLiteral2(expr) {
|
|
64355
|
+
const e = (expr ?? "").trim();
|
|
64356
|
+
if (e.length < 2) return null;
|
|
64357
|
+
const q = e[0];
|
|
64358
|
+
if (q !== "'" && q !== '"' && q !== "`" || e[e.length - 1] !== q) return null;
|
|
64359
|
+
const body2 = e.slice(1, -1);
|
|
64360
|
+
if (body2.includes(q) || body2.includes("\\") || q === "`" && body2.includes("${")) return null;
|
|
64361
|
+
return body2;
|
|
64362
|
+
}
|
|
64363
|
+
function resourceOf(path) {
|
|
64364
|
+
for (const raw of path.split("/")) {
|
|
64365
|
+
const s = raw.trim().toLowerCase();
|
|
64366
|
+
if (s === "" || s.startsWith(":") || s === "*") continue;
|
|
64367
|
+
if (s === "api") continue;
|
|
64368
|
+
if (s.length >= 2 && s[0] === "v" && [...s.slice(1)].every((c) => c >= "0" && c <= "9")) continue;
|
|
64369
|
+
return s;
|
|
64370
|
+
}
|
|
64371
|
+
return "";
|
|
64372
|
+
}
|
|
64373
|
+
function hasParamSegment(path) {
|
|
64374
|
+
return path.split("/").some((s) => s.startsWith(":") && s.length > 1);
|
|
64375
|
+
}
|
|
64376
|
+
var SELF_CHECK_MARKERS = [
|
|
64377
|
+
"req.user",
|
|
64378
|
+
"req.session",
|
|
64379
|
+
"req.auth",
|
|
64380
|
+
"request.user",
|
|
64381
|
+
"request.session",
|
|
64382
|
+
"res.locals.user",
|
|
64383
|
+
"isAuthenticated(",
|
|
64384
|
+
"status(401)",
|
|
64385
|
+
"status(403)",
|
|
64386
|
+
"sendStatus(401)",
|
|
64387
|
+
"sendStatus(403)"
|
|
64388
|
+
];
|
|
64389
|
+
function checksCallerItself(text) {
|
|
64390
|
+
return SELF_CHECK_MARKERS.some((m) => text.includes(m));
|
|
64391
|
+
}
|
|
64392
|
+
function sameFileFunctionText(lines, name2) {
|
|
64393
|
+
for (let i2 = 0; i2 < lines.length; i2++) {
|
|
64394
|
+
const t = lines[i2].trimStart();
|
|
64395
|
+
const isDecl = t.startsWith(`function ${name2}(`) || t.startsWith(`async function ${name2}(`) || t.startsWith(`export function ${name2}(`) || t.startsWith(`export async function ${name2}(`) || t.startsWith(`const ${name2} =`) || t.startsWith(`export const ${name2} =`);
|
|
64396
|
+
if (!isDecl) continue;
|
|
64397
|
+
const out2 = [];
|
|
64398
|
+
for (let j = i2; j < lines.length && j < i2 + 200; j++) {
|
|
64399
|
+
out2.push(lines[j]);
|
|
64400
|
+
if (j > i2 && lines[j].startsWith("}")) break;
|
|
64401
|
+
if (j === i2 && lines[j].trimEnd().endsWith(";") && !lines[j].includes("{")) break;
|
|
64402
|
+
}
|
|
64403
|
+
return out2.join("\n");
|
|
64404
|
+
}
|
|
64405
|
+
return null;
|
|
64406
|
+
}
|
|
64407
|
+
function routeOf(call) {
|
|
64408
|
+
if (!ROUTE_METHODS.has(call.method_name)) return null;
|
|
64409
|
+
const receiver = (call.receiver ?? "").trim();
|
|
64410
|
+
if (!isIdentifier2(receiver)) return null;
|
|
64411
|
+
const args2 = [...call.arguments].sort((a, b) => a.position - b.position);
|
|
64412
|
+
if (args2.length < 2) return null;
|
|
64413
|
+
const path = stringLiteral2(args2[0].expression);
|
|
64414
|
+
if (path === null || !path.startsWith("/")) return null;
|
|
64415
|
+
let guard = null;
|
|
64416
|
+
const exprs = [];
|
|
64417
|
+
for (const a of args2.slice(1)) {
|
|
64418
|
+
const e = (a.expression ?? "").trim();
|
|
64419
|
+
if (e.startsWith("[") && e.endsWith("]")) exprs.push(...e.slice(1, -1).split(","));
|
|
64420
|
+
else exprs.push(e);
|
|
64421
|
+
}
|
|
64422
|
+
for (const e of exprs) {
|
|
64423
|
+
const k = guardKind(e);
|
|
64424
|
+
if (k === "authn") {
|
|
64425
|
+
guard = "authn";
|
|
64426
|
+
break;
|
|
64427
|
+
}
|
|
64428
|
+
if (k === "authz") guard = "authz";
|
|
64429
|
+
}
|
|
64430
|
+
return {
|
|
64431
|
+
call,
|
|
64432
|
+
receiver,
|
|
64433
|
+
method: call.method_name,
|
|
64434
|
+
path,
|
|
64435
|
+
resource: resourceOf(path),
|
|
64436
|
+
guard,
|
|
64437
|
+
handler: (args2[args2.length - 1].expression ?? "").trim(),
|
|
64438
|
+
middlewareCount: args2.length - 2
|
|
64439
|
+
};
|
|
64440
|
+
}
|
|
64441
|
+
var MissingAuthMiddlewarePass = class {
|
|
64442
|
+
name = "missing-auth-middleware";
|
|
64443
|
+
category = "security";
|
|
64444
|
+
run(ctx) {
|
|
64445
|
+
const { graph, language, code } = ctx;
|
|
64446
|
+
const findings = [];
|
|
64447
|
+
if (language !== "javascript" && language !== "typescript") return { findings };
|
|
64448
|
+
const calls = graph.ir.calls;
|
|
64449
|
+
for (const c of calls) {
|
|
64450
|
+
if (c.method_name !== "use") continue;
|
|
64451
|
+
if (c.arguments.some((a) => guardKind(a.expression ?? "") !== null)) return { findings };
|
|
64452
|
+
}
|
|
64453
|
+
const routes = calls.map(routeOf).filter((r) => r !== null);
|
|
64454
|
+
if (routes.length < 2) return { findings };
|
|
64455
|
+
const lines = code.split("\n");
|
|
64456
|
+
const file = graph.ir.meta.file;
|
|
64457
|
+
const seen = /* @__PURE__ */ new Set();
|
|
64458
|
+
for (const r of routes) {
|
|
64459
|
+
if (r.guard !== null || r.middlewareCount > 0) continue;
|
|
64460
|
+
if (!MUTATING_METHODS.has(r.method) || !hasParamSegment(r.path) || r.resource === "") continue;
|
|
64461
|
+
const sibling = routes.find((s) => s !== r && s.receiver === r.receiver && s.resource === r.resource && s.guard === "authn");
|
|
64462
|
+
if (!sibling) continue;
|
|
64463
|
+
const handlerText = isIdentifier2(r.handler) ? sameFileFunctionText(lines, r.handler) ?? "" : r.handler;
|
|
64464
|
+
if (checksCallerItself(handlerText)) continue;
|
|
64465
|
+
const line = r.call.location.line;
|
|
64466
|
+
if (seen.has(line)) continue;
|
|
64467
|
+
seen.add(line);
|
|
64468
|
+
const route = `${r.method.toUpperCase()} ${r.path}`;
|
|
64469
|
+
const siblingRoute = `${sibling.method.toUpperCase()} ${sibling.path}`;
|
|
64470
|
+
findings.push({ line, route, guardedBy: siblingRoute });
|
|
64471
|
+
ctx.addFinding({
|
|
64472
|
+
id: `${this.name}-${file}-${line}`,
|
|
64473
|
+
pass: this.name,
|
|
64474
|
+
category: this.category,
|
|
64475
|
+
rule_id: this.name,
|
|
64476
|
+
cwe: "CWE-862",
|
|
64477
|
+
severity: "high",
|
|
64478
|
+
level: "error",
|
|
64479
|
+
message: `\`${r.receiver}.${r.method}('${r.path}')\` changes a record addressed by a path parameter with no authentication middleware, while \`${siblingRoute}\` on the same router requires one. Anyone can call this route.`,
|
|
64480
|
+
file,
|
|
64481
|
+
line,
|
|
64482
|
+
fix: `Add the same authentication middleware as \`${siblingRoute}\` to this route (and check that the caller may change this record), or guard the whole router with \`router.use(...)\`.`,
|
|
64483
|
+
evidence: { route, guardedSibling: siblingRoute, receiver: r.receiver, language }
|
|
64484
|
+
});
|
|
64485
|
+
}
|
|
64486
|
+
return { findings };
|
|
64487
|
+
}
|
|
64488
|
+
};
|
|
64489
|
+
|
|
64490
|
+
// src/analysis/passes/prototype-pollution-pass.ts
|
|
64491
|
+
var KEYWORDS2 = /* @__PURE__ */ new Set([
|
|
64492
|
+
"if",
|
|
64493
|
+
"for",
|
|
64494
|
+
"while",
|
|
64495
|
+
"switch",
|
|
64496
|
+
"catch",
|
|
64497
|
+
"with",
|
|
64498
|
+
"return",
|
|
64499
|
+
"typeof",
|
|
64500
|
+
"function",
|
|
64501
|
+
"new",
|
|
64502
|
+
"await",
|
|
64503
|
+
"yield",
|
|
64504
|
+
"delete",
|
|
64505
|
+
"void",
|
|
64506
|
+
"in",
|
|
64507
|
+
"of",
|
|
64508
|
+
"do",
|
|
64509
|
+
"else",
|
|
64510
|
+
"try",
|
|
64511
|
+
"finally",
|
|
64512
|
+
"throw",
|
|
64513
|
+
"case",
|
|
64514
|
+
"super"
|
|
64515
|
+
]);
|
|
64516
|
+
var PATH_NAME_WORDS = ["path", "keys", "segments", "segs", "parts", "props", "keypath", "fields"];
|
|
64517
|
+
var GUARD_NAME_WORDS = [
|
|
64518
|
+
"safe",
|
|
64519
|
+
"proto",
|
|
64520
|
+
"pollut",
|
|
64521
|
+
"forbid",
|
|
64522
|
+
"unsafe",
|
|
64523
|
+
"danger",
|
|
64524
|
+
"block",
|
|
64525
|
+
"allow",
|
|
64526
|
+
"reserved",
|
|
64527
|
+
"valid",
|
|
64528
|
+
"deny",
|
|
64529
|
+
"illegal"
|
|
64530
|
+
];
|
|
64531
|
+
var REQUEST_ROOTS = /* @__PURE__ */ new Set(["req", "request"]);
|
|
64532
|
+
var REQUEST_BAGS = /* @__PURE__ */ new Set(["body", "query", "params"]);
|
|
64533
|
+
var MAX_CODE_LENGTH = 1e6;
|
|
64534
|
+
function isIdentStart3(ch) {
|
|
64535
|
+
return ch >= "a" && ch <= "z" || ch >= "A" && ch <= "Z" || ch === "_" || ch === "$";
|
|
64536
|
+
}
|
|
64537
|
+
function isIdentChar4(ch) {
|
|
64538
|
+
return isIdentStart3(ch) || ch >= "0" && ch <= "9";
|
|
64539
|
+
}
|
|
64540
|
+
function isIdent(t) {
|
|
64541
|
+
return !!t && isIdentStart3(t[0]) && !KEYWORDS2.has(t);
|
|
64542
|
+
}
|
|
64543
|
+
function maskLiterals(code) {
|
|
64544
|
+
const out2 = code.split("");
|
|
64545
|
+
let i2 = 0;
|
|
64546
|
+
const n = code.length;
|
|
64547
|
+
while (i2 < n) {
|
|
64548
|
+
const ch = code[i2];
|
|
64549
|
+
if (ch === "/" && code[i2 + 1] === "/") {
|
|
64550
|
+
while (i2 < n && code[i2] !== "\n") out2[i2++] = " ";
|
|
64551
|
+
continue;
|
|
64552
|
+
}
|
|
64553
|
+
if (ch === "/" && code[i2 + 1] === "*") {
|
|
64554
|
+
out2[i2] = " ";
|
|
64555
|
+
out2[i2 + 1] = " ";
|
|
64556
|
+
i2 += 2;
|
|
64557
|
+
while (i2 < n && !(code[i2] === "*" && code[i2 + 1] === "/")) {
|
|
64558
|
+
if (code[i2] !== "\n") out2[i2] = " ";
|
|
64559
|
+
i2++;
|
|
64560
|
+
}
|
|
64561
|
+
if (i2 < n) {
|
|
64562
|
+
out2[i2] = " ";
|
|
64563
|
+
out2[i2 + 1] = " ";
|
|
64564
|
+
i2 += 2;
|
|
64565
|
+
}
|
|
64566
|
+
continue;
|
|
64567
|
+
}
|
|
64568
|
+
if (ch === '"' || ch === "'" || ch === "`") {
|
|
64569
|
+
i2++;
|
|
64570
|
+
while (i2 < n && code[i2] !== ch) {
|
|
64571
|
+
if (code[i2] === "\n" && ch !== "`") break;
|
|
64572
|
+
if (code[i2] === "\\") {
|
|
64573
|
+
out2[i2] = " ";
|
|
64574
|
+
i2++;
|
|
64575
|
+
if (i2 < n && code[i2] !== "\n") out2[i2] = " ";
|
|
64576
|
+
i2++;
|
|
64577
|
+
continue;
|
|
64578
|
+
}
|
|
64579
|
+
if (code[i2] !== "\n") out2[i2] = " ";
|
|
64580
|
+
i2++;
|
|
64581
|
+
}
|
|
64582
|
+
i2++;
|
|
64583
|
+
continue;
|
|
64584
|
+
}
|
|
64585
|
+
i2++;
|
|
64586
|
+
}
|
|
64587
|
+
return out2.join("");
|
|
64588
|
+
}
|
|
64589
|
+
var PUNCT3 = ["===", "!==", "??=", "||=", "&&=", "..."];
|
|
64590
|
+
var PUNCT2 = ["==", "!=", "=>", "||", "&&", "??", "<=", ">=", "+=", "-=", "?.", "++", "--"];
|
|
64591
|
+
function tokenize(masked) {
|
|
64592
|
+
const toks = [];
|
|
64593
|
+
let i2 = 0;
|
|
64594
|
+
const n = masked.length;
|
|
64595
|
+
while (i2 < n) {
|
|
64596
|
+
const ch = masked[i2];
|
|
64597
|
+
if (ch === " " || ch === "\n" || ch === " " || ch === "\r") {
|
|
64598
|
+
i2++;
|
|
64599
|
+
continue;
|
|
64600
|
+
}
|
|
64601
|
+
if (isIdentStart3(ch)) {
|
|
64602
|
+
const s = i2;
|
|
64603
|
+
while (i2 < n && isIdentChar4(masked[i2])) i2++;
|
|
64604
|
+
toks.push({ t: masked.slice(s, i2), pos: s, m: -1 });
|
|
64605
|
+
continue;
|
|
64606
|
+
}
|
|
64607
|
+
if (ch >= "0" && ch <= "9") {
|
|
64608
|
+
const s = i2;
|
|
64609
|
+
while (i2 < n && (isIdentChar4(masked[i2]) || masked[i2] === ".")) i2++;
|
|
64610
|
+
toks.push({ t: masked.slice(s, i2), pos: s, m: -1 });
|
|
64611
|
+
continue;
|
|
64612
|
+
}
|
|
64613
|
+
if (ch === '"' || ch === "'" || ch === "`") {
|
|
64614
|
+
const s = i2;
|
|
64615
|
+
i2++;
|
|
64616
|
+
while (i2 < n && masked[i2] !== ch && masked[i2] !== "\n") i2++;
|
|
64617
|
+
i2++;
|
|
64618
|
+
toks.push({ t: '"', pos: s, m: -1 });
|
|
64619
|
+
continue;
|
|
64620
|
+
}
|
|
64621
|
+
const three = masked.slice(i2, i2 + 3);
|
|
64622
|
+
if (PUNCT3.includes(three)) {
|
|
64623
|
+
toks.push({ t: three, pos: i2, m: -1 });
|
|
64624
|
+
i2 += 3;
|
|
64625
|
+
continue;
|
|
64626
|
+
}
|
|
64627
|
+
const two = masked.slice(i2, i2 + 2);
|
|
64628
|
+
if (PUNCT2.includes(two)) {
|
|
64629
|
+
toks.push({ t: two, pos: i2, m: -1 });
|
|
64630
|
+
i2 += 2;
|
|
64631
|
+
continue;
|
|
64632
|
+
}
|
|
64633
|
+
toks.push({ t: ch, pos: i2, m: -1 });
|
|
64634
|
+
i2++;
|
|
64635
|
+
}
|
|
64636
|
+
const stack = [];
|
|
64637
|
+
for (let j = 0; j < toks.length; j++) {
|
|
64638
|
+
const t = toks[j].t;
|
|
64639
|
+
if (t === "(" || t === "[" || t === "{") stack.push(j);
|
|
64640
|
+
else if (t === ")" || t === "]" || t === "}") {
|
|
64641
|
+
const want = t === ")" ? "(" : t === "]" ? "[" : "{";
|
|
64642
|
+
while (stack.length > 0 && toks[stack[stack.length - 1]].t !== want) stack.pop();
|
|
64643
|
+
const o = stack.pop();
|
|
64644
|
+
if (o !== void 0) {
|
|
64645
|
+
toks[o].m = j;
|
|
64646
|
+
toks[j].m = o;
|
|
64647
|
+
}
|
|
64648
|
+
}
|
|
64649
|
+
}
|
|
64650
|
+
return toks;
|
|
64651
|
+
}
|
|
64652
|
+
function matchClose(toks, i2) {
|
|
64653
|
+
return toks[i2]?.m ?? -1;
|
|
64654
|
+
}
|
|
64655
|
+
function matchOpen(toks, i2) {
|
|
64656
|
+
return toks[i2]?.m ?? -1;
|
|
64657
|
+
}
|
|
64658
|
+
function paramNames(toks, open, close) {
|
|
64659
|
+
const out2 = [];
|
|
64660
|
+
let depth = 0;
|
|
64661
|
+
let expectName = true;
|
|
64662
|
+
for (let j = open + 1; j < close; j++) {
|
|
64663
|
+
const t = toks[j].t;
|
|
64664
|
+
if (t === "(" || t === "[" || t === "{") depth++;
|
|
64665
|
+
else if (t === ")" || t === "]" || t === "}") depth--;
|
|
64666
|
+
else if (depth === 0 && t === ",") {
|
|
64667
|
+
expectName = true;
|
|
64668
|
+
continue;
|
|
64669
|
+
}
|
|
64670
|
+
if (depth === 0 && expectName && isIdent(t) && t !== "this") {
|
|
64671
|
+
out2.push(t);
|
|
64672
|
+
expectName = false;
|
|
64673
|
+
} else if (depth === 0 && t !== "...") expectName = false;
|
|
64674
|
+
}
|
|
64675
|
+
return out2;
|
|
64676
|
+
}
|
|
64677
|
+
function boundName(toks, start2) {
|
|
64678
|
+
let k = start2 - 1;
|
|
64679
|
+
if (toks[k]?.t === "async") k--;
|
|
64680
|
+
if (toks[k]?.t === "=" || toks[k]?.t === ":") return isIdent(toks[k - 1]?.t) ? toks[k - 1].t : null;
|
|
64681
|
+
return null;
|
|
64682
|
+
}
|
|
64683
|
+
function findFunctions(toks) {
|
|
64684
|
+
const fns = [];
|
|
64685
|
+
for (let i2 = 0; i2 < toks.length; i2++) {
|
|
64686
|
+
if (toks[i2].t !== "{") continue;
|
|
64687
|
+
const prev = toks[i2 - 1]?.t;
|
|
64688
|
+
let fn = null;
|
|
64689
|
+
if (prev === "=>") {
|
|
64690
|
+
const close = matchClose(toks, i2);
|
|
64691
|
+
if (close < 0) continue;
|
|
64692
|
+
let start2 = i2 - 2;
|
|
64693
|
+
let params = [];
|
|
64694
|
+
if (toks[start2]?.t === ")") {
|
|
64695
|
+
const po = matchOpen(toks, start2);
|
|
64696
|
+
if (po < 0) continue;
|
|
64697
|
+
params = paramNames(toks, po, start2);
|
|
64698
|
+
start2 = po;
|
|
64699
|
+
} else if (isIdent(toks[start2]?.t)) {
|
|
64700
|
+
params = [toks[start2].t];
|
|
64701
|
+
}
|
|
64702
|
+
fn = { name: boundName(toks, start2), open: i2, close, params };
|
|
64703
|
+
} else if (prev === ")") {
|
|
64704
|
+
const pc = i2 - 1;
|
|
64705
|
+
const po = matchOpen(toks, pc);
|
|
64706
|
+
if (po < 1) continue;
|
|
64707
|
+
const before = toks[po - 1].t;
|
|
64708
|
+
const close = matchClose(toks, i2);
|
|
64709
|
+
if (close < 0) continue;
|
|
64710
|
+
const params = paramNames(toks, po, pc);
|
|
64711
|
+
if (before === "function") {
|
|
64712
|
+
fn = { name: boundName(toks, po - 1), open: i2, close, params };
|
|
64713
|
+
} else if (isIdent(before)) {
|
|
64714
|
+
const kw = toks[po - 2]?.t;
|
|
64715
|
+
if (kw === "function") fn = { name: before, open: i2, close, params };
|
|
64716
|
+
else if (kw !== "." && kw !== "new") fn = { name: before, open: i2, close, params };
|
|
64717
|
+
}
|
|
64718
|
+
}
|
|
64719
|
+
if (!fn && prev !== void 0 && prev !== "=>" && prev !== ")") {
|
|
64720
|
+
for (let j = i2 - 1; j > Math.max(0, i2 - 16); j--) {
|
|
64721
|
+
if (toks[j].t === ":" && toks[j - 1]?.t === ")") {
|
|
64722
|
+
const pc = j - 1;
|
|
64723
|
+
const po = matchOpen(toks, pc);
|
|
64724
|
+
if (po < 1) break;
|
|
64725
|
+
const before = toks[po - 1].t;
|
|
64726
|
+
const close = matchClose(toks, i2);
|
|
64727
|
+
if (close < 0) break;
|
|
64728
|
+
const params = paramNames(toks, po, pc);
|
|
64729
|
+
if (before === "function") fn = { name: boundName(toks, po - 1), open: i2, close, params };
|
|
64730
|
+
else if (isIdent(before) && toks[po - 2]?.t !== ".") fn = { name: before, open: i2, close, params };
|
|
64731
|
+
break;
|
|
64732
|
+
}
|
|
64733
|
+
if (toks[j].t === "{" || toks[j].t === "}" || toks[j].t === ";") break;
|
|
64734
|
+
}
|
|
64735
|
+
}
|
|
64736
|
+
if (fn) fns.push(fn);
|
|
64737
|
+
}
|
|
64738
|
+
return fns;
|
|
64739
|
+
}
|
|
64740
|
+
function chainAt(toks, i2) {
|
|
64741
|
+
if (!isIdent(toks[i2]?.t) && toks[i2]?.t !== "this") return null;
|
|
64742
|
+
let text = toks[i2].t;
|
|
64743
|
+
let j = i2 + 1;
|
|
64744
|
+
while ((toks[j]?.t === "." || toks[j]?.t === "?.") && isIdent(toks[j + 1]?.t)) {
|
|
64745
|
+
text += "." + toks[j + 1].t;
|
|
64746
|
+
j += 2;
|
|
64747
|
+
}
|
|
64748
|
+
return { text, end: j };
|
|
64749
|
+
}
|
|
64750
|
+
function isAssign2(t) {
|
|
64751
|
+
return t === "=" || t === "||=" || t === "??=" || t === "&&=";
|
|
64752
|
+
}
|
|
64753
|
+
function lineOf(code, pos) {
|
|
64754
|
+
let line = 1;
|
|
64755
|
+
for (let i2 = code.lastIndexOf("\n", pos - 1); i2 >= 0; i2 = code.lastIndexOf("\n", i2 - 1)) line++;
|
|
64756
|
+
return line;
|
|
64757
|
+
}
|
|
64758
|
+
function hasGuard(raw, toks, from, to, keys) {
|
|
64759
|
+
if (raw.includes("__proto__") || raw.includes("constructor") || raw.includes("prototype")) return true;
|
|
64760
|
+
for (let j = from; j < to; j++) {
|
|
64761
|
+
const t = toks[j].t;
|
|
64762
|
+
if (!isIdent(t) || toks[j + 1]?.t !== "(") continue;
|
|
64763
|
+
const lower = t.toLowerCase();
|
|
64764
|
+
const membership = toks[j - 1]?.t === "." && (t === "has" || t === "includes" || t === "indexOf");
|
|
64765
|
+
if (!membership && !GUARD_NAME_WORDS.some((w) => lower.includes(w))) continue;
|
|
64766
|
+
const close = matchClose(toks, j + 1);
|
|
64767
|
+
for (let k = j + 2; k < close; k++) if (keys.has(toks[k].t)) return true;
|
|
64768
|
+
}
|
|
64769
|
+
return false;
|
|
64770
|
+
}
|
|
64771
|
+
function nullProtoNames(toks, from, to) {
|
|
64772
|
+
const out2 = /* @__PURE__ */ new Set();
|
|
64773
|
+
for (let j = from; j + 6 < to; j++) {
|
|
64774
|
+
if (toks[j + 1].t === "=" && isIdent(toks[j].t) && toks[j + 2].t === "Object" && toks[j + 3].t === "." && toks[j + 4].t === "create" && toks[j + 5].t === "(" && toks[j + 6].t === "null") out2.add(toks[j].t);
|
|
64775
|
+
}
|
|
64776
|
+
return out2;
|
|
64777
|
+
}
|
|
64778
|
+
function keyLoops(toks, from, to) {
|
|
64779
|
+
const out2 = [];
|
|
64780
|
+
for (let j = from; j < to; j++) {
|
|
64781
|
+
const t = toks[j].t;
|
|
64782
|
+
if (t === "for" && toks[j + 1]?.t === "(") {
|
|
64783
|
+
let k = j + 2;
|
|
64784
|
+
if (toks[k]?.t === "const" || toks[k]?.t === "let" || toks[k]?.t === "var") k++;
|
|
64785
|
+
let key = null;
|
|
64786
|
+
if (isIdent(toks[k]?.t)) {
|
|
64787
|
+
key = toks[k].t;
|
|
64788
|
+
k++;
|
|
64789
|
+
} else if (toks[k]?.t === "[" && isIdent(toks[k + 1]?.t)) {
|
|
64790
|
+
key = toks[k + 1].t;
|
|
64791
|
+
const c = matchClose(toks, k);
|
|
64792
|
+
if (c < 0) continue;
|
|
64793
|
+
k = c + 1;
|
|
64794
|
+
}
|
|
64795
|
+
if (!key) continue;
|
|
64796
|
+
if (toks[k]?.t === "in") {
|
|
64797
|
+
const c = chainAt(toks, k + 1);
|
|
64798
|
+
if (c && toks[c.end]?.t === ")") out2.push({ key, source: c.text });
|
|
64799
|
+
} else if (toks[k]?.t === "of" && toks[k + 1]?.t === "Object" && toks[k + 2]?.t === "." && ["keys", "entries", "getOwnPropertyNames"].includes(toks[k + 3]?.t ?? "") && toks[k + 4]?.t === "(") {
|
|
64800
|
+
const c = chainAt(toks, k + 5);
|
|
64801
|
+
if (c && toks[c.end]?.t === ")") out2.push({ key, source: c.text });
|
|
64802
|
+
}
|
|
64803
|
+
} else if (t === "Object" && toks[j + 1]?.t === "." && (toks[j + 2]?.t === "keys" || toks[j + 2]?.t === "entries") && toks[j + 3]?.t === "(") {
|
|
64804
|
+
const c = chainAt(toks, j + 4);
|
|
64805
|
+
if (!c || toks[c.end]?.t !== ")") continue;
|
|
64806
|
+
let k = c.end + 1;
|
|
64807
|
+
if (toks[k]?.t !== "." || toks[k + 1]?.t !== "forEach" || toks[k + 2]?.t !== "(") continue;
|
|
64808
|
+
k += 3;
|
|
64809
|
+
if (toks[k]?.t === "function") k++;
|
|
64810
|
+
if (toks[k]?.t === "(") k++;
|
|
64811
|
+
if (toks[k]?.t === "[") k++;
|
|
64812
|
+
if (isIdent(toks[k]?.t)) out2.push({ key: toks[k].t, source: c.text });
|
|
64813
|
+
}
|
|
64814
|
+
}
|
|
64815
|
+
return out2;
|
|
64816
|
+
}
|
|
64817
|
+
function chainBefore(toks, k) {
|
|
64818
|
+
let j = k - 1;
|
|
64819
|
+
if (!isIdent(toks[j]?.t) && toks[j]?.t !== "this") return null;
|
|
64820
|
+
const parts2 = [toks[j].t];
|
|
64821
|
+
while ((toks[j - 1]?.t === "." || toks[j - 1]?.t === "?.") && (isIdent(toks[j - 2]?.t) || toks[j - 2]?.t === "this")) {
|
|
64822
|
+
parts2.unshift(toks[j - 2].t);
|
|
64823
|
+
j -= 2;
|
|
64824
|
+
}
|
|
64825
|
+
return parts2.join(".");
|
|
64826
|
+
}
|
|
64827
|
+
function recursiveMerge(toks, fn) {
|
|
64828
|
+
if (!fn.name) return [];
|
|
64829
|
+
const out2 = [];
|
|
64830
|
+
for (const loop of keyLoops(toks, fn.open, fn.close)) {
|
|
64831
|
+
const recursedTargets = /* @__PURE__ */ new Set();
|
|
64832
|
+
for (let j = fn.open + 1; j < fn.close; j++) {
|
|
64833
|
+
if (toks[j].t !== fn.name || toks[j + 1]?.t !== "(") continue;
|
|
64834
|
+
const prev = toks[j - 1]?.t;
|
|
64835
|
+
if (prev === "function" || prev === "." && toks[j - 2]?.t !== "this") continue;
|
|
64836
|
+
const close = matchClose(toks, j + 1);
|
|
64837
|
+
for (let k = j + 2; k + 2 < close; k++) {
|
|
64838
|
+
if (toks[k].t === "[" && toks[k + 1].t === loop.key && toks[k + 2].t === "]") {
|
|
64839
|
+
const t = chainBefore(toks, k);
|
|
64840
|
+
if (t && t !== loop.source) recursedTargets.add(t);
|
|
64841
|
+
}
|
|
64842
|
+
}
|
|
64843
|
+
}
|
|
64844
|
+
if (recursedTargets.size === 0) continue;
|
|
64845
|
+
for (let j = fn.open + 1; j < fn.close; j++) {
|
|
64846
|
+
if (toks[j - 1]?.t === ".") continue;
|
|
64847
|
+
const c = chainAt(toks, j);
|
|
64848
|
+
if (!c) continue;
|
|
64849
|
+
const k = c.end;
|
|
64850
|
+
if (recursedTargets.has(c.text) && toks[k]?.t === "[" && toks[k + 1]?.t === loop.key && toks[k + 2]?.t === "]" && isAssign2(toks[k + 3]?.t)) {
|
|
64851
|
+
out2.push({ pos: toks[j].pos, target: c.text, key: loop.key });
|
|
64852
|
+
break;
|
|
64853
|
+
}
|
|
64854
|
+
}
|
|
64855
|
+
}
|
|
64856
|
+
return out2;
|
|
64857
|
+
}
|
|
64858
|
+
function isPathName(name2) {
|
|
64859
|
+
const lower = name2.toLowerCase();
|
|
64860
|
+
return PATH_NAME_WORDS.some((w) => lower === w || lower.endsWith(w));
|
|
64861
|
+
}
|
|
64862
|
+
function setByPath(toks, raw, base, fn) {
|
|
64863
|
+
let hasLoop = false;
|
|
64864
|
+
let pathEvidence = false;
|
|
64865
|
+
const pathNames = /* @__PURE__ */ new Set();
|
|
64866
|
+
for (let j = fn.open + 1; j < fn.close; j++) {
|
|
64867
|
+
const t = toks[j].t;
|
|
64868
|
+
if (t === "for" || t === "while" || t === "forEach" || t === "reduce") hasLoop = true;
|
|
64869
|
+
if (t === "split" && toks[j - 1]?.t === "." && toks[j + 1]?.t === "(") {
|
|
64870
|
+
const arg = toks[j + 2];
|
|
64871
|
+
let real = false;
|
|
64872
|
+
if (arg && arg.t === '"') {
|
|
64873
|
+
const q = raw[arg.pos - base];
|
|
64874
|
+
real = raw[arg.pos - base + 1] !== q;
|
|
64875
|
+
} else if (arg && arg.t === "/") {
|
|
64876
|
+
real = true;
|
|
64877
|
+
}
|
|
64878
|
+
if (real) {
|
|
64879
|
+
pathEvidence = true;
|
|
64880
|
+
let k = j - 2;
|
|
64881
|
+
while (k > fn.open && (isIdent(toks[k]?.t) || toks[k]?.t === "." || toks[k]?.t === ")" || toks[k]?.t === "(")) {
|
|
64882
|
+
if (toks[k].t === ")") {
|
|
64883
|
+
const o = matchOpen(toks, k);
|
|
64884
|
+
if (o < 0) break;
|
|
64885
|
+
k = o - 1;
|
|
64886
|
+
continue;
|
|
64887
|
+
}
|
|
64888
|
+
k--;
|
|
64889
|
+
}
|
|
64890
|
+
if (toks[k]?.t === "=" && isIdent(toks[k - 1]?.t)) pathNames.add(toks[k - 1].t);
|
|
64891
|
+
}
|
|
64892
|
+
}
|
|
64893
|
+
if (t === "for" && toks[j + 1]?.t === "(") {
|
|
64894
|
+
const close = matchClose(toks, j + 1);
|
|
64895
|
+
for (let k = j + 2; k < close; k++) {
|
|
64896
|
+
if (toks[k].t === "of" || toks[k].t === "in") {
|
|
64897
|
+
const c = chainAt(toks, k + 1);
|
|
64898
|
+
const last = c ? c.text.split(".").pop() ?? "" : "";
|
|
64899
|
+
if (c && (isPathName(last) || pathNames.has(last))) {
|
|
64900
|
+
pathEvidence = true;
|
|
64901
|
+
if (isIdent(toks[k - 1]?.t)) pathNames.add(toks[k - 1].t);
|
|
64902
|
+
}
|
|
64903
|
+
}
|
|
64904
|
+
}
|
|
64905
|
+
}
|
|
64906
|
+
if ((t === "forEach" || t === "reduce") && toks[j - 1]?.t === ".") {
|
|
64907
|
+
const coll = toks[j - 2]?.t;
|
|
64908
|
+
const isSplit = toks[j - 2]?.t === ")" && toks[matchOpen(toks, j - 2) - 1]?.t === "split";
|
|
64909
|
+
if (isIdent(coll) && (isPathName(coll) || pathNames.has(coll)) || isSplit) {
|
|
64910
|
+
pathEvidence = true;
|
|
64911
|
+
let k = j + 2;
|
|
64912
|
+
if (toks[k]?.t === "function") k++;
|
|
64913
|
+
if (toks[k]?.t === "(") {
|
|
64914
|
+
const c = matchClose(toks, k);
|
|
64915
|
+
for (const n of paramNames(toks, k, c)) pathNames.add(n);
|
|
64916
|
+
} else if (isIdent(toks[k]?.t)) {
|
|
64917
|
+
pathNames.add(toks[k].t);
|
|
64918
|
+
}
|
|
64919
|
+
}
|
|
64920
|
+
}
|
|
64921
|
+
}
|
|
64922
|
+
if (!hasLoop || !pathEvidence) return [];
|
|
64923
|
+
for (let j = fn.open + 1; j < fn.close; j++) {
|
|
64924
|
+
if ((toks[j].t === "const" || toks[j].t === "let" || toks[j].t === "var") && isIdent(toks[j + 1]?.t) && toks[j + 2]?.t === "=" && pathNames.has(toks[j + 3]?.t ?? "") && (toks[j + 4]?.t === "[" || toks[j + 4]?.t === ".")) {
|
|
64925
|
+
pathNames.add(toks[j + 1].t);
|
|
64926
|
+
}
|
|
64927
|
+
}
|
|
64928
|
+
const cursors = /* @__PURE__ */ new Set();
|
|
64929
|
+
for (let j = fn.open + 1; j < fn.close; j++) {
|
|
64930
|
+
const x = toks[j].t;
|
|
64931
|
+
if (x === "reduce" && toks[j - 1]?.t === "." && toks[j + 1]?.t === "(" && toks[j + 2]?.t === "(" && isIdent(toks[j + 3]?.t)) {
|
|
64932
|
+
cursors.add(toks[j + 3].t);
|
|
64933
|
+
}
|
|
64934
|
+
if (!isIdent(x) || toks[j - 1]?.t === ".") continue;
|
|
64935
|
+
if (toks[j + 1]?.t === "=" && toks[j + 2]?.t === x && toks[j + 3]?.t === "[") cursors.add(x);
|
|
64936
|
+
}
|
|
64937
|
+
const out2 = [];
|
|
64938
|
+
for (const x of cursors) {
|
|
64939
|
+
for (let j = fn.open + 1; j < fn.close; j++) {
|
|
64940
|
+
if (toks[j].t !== x || toks[j - 1]?.t === "." || toks[j + 1]?.t !== "[") continue;
|
|
64941
|
+
const c = matchClose(toks, j + 1);
|
|
64942
|
+
if (c < 0 || !isAssign2(toks[c + 1]?.t)) continue;
|
|
64943
|
+
let key = null;
|
|
64944
|
+
for (let k = j + 2; k < c; k++) if (pathNames.has(toks[k].t)) {
|
|
64945
|
+
key = toks[k].t;
|
|
64946
|
+
break;
|
|
64947
|
+
}
|
|
64948
|
+
if (!key) continue;
|
|
64949
|
+
out2.push({ pos: toks[j].pos, target: x, key });
|
|
64950
|
+
break;
|
|
64951
|
+
}
|
|
64952
|
+
}
|
|
64953
|
+
return out2;
|
|
64954
|
+
}
|
|
64955
|
+
function requestNames(toks, from, to) {
|
|
64956
|
+
const out2 = /* @__PURE__ */ new Set();
|
|
64957
|
+
const isBag = (k) => REQUEST_ROOTS.has(toks[k]?.t ?? "") && toks[k + 1]?.t === "." && REQUEST_BAGS.has(toks[k + 2]?.t ?? "");
|
|
64958
|
+
for (let j = from; j < to; j++) {
|
|
64959
|
+
const t = toks[j].t;
|
|
64960
|
+
if (t !== "const" && t !== "let" && t !== "var") continue;
|
|
64961
|
+
if (toks[j + 1]?.t === "{") {
|
|
64962
|
+
const close = matchClose(toks, j + 1);
|
|
64963
|
+
if (close < 0 || toks[close + 1]?.t !== "=" || !isBag(close + 2)) continue;
|
|
64964
|
+
let depth = 0;
|
|
64965
|
+
for (let k = j + 2; k < close; k++) {
|
|
64966
|
+
const s = toks[k].t;
|
|
64967
|
+
if (s === "{" || s === "[") depth++;
|
|
64968
|
+
else if (s === "}" || s === "]") depth--;
|
|
64969
|
+
else if (depth === 0 && isIdent(s) && toks[k + 1]?.t !== ":") out2.add(s);
|
|
64970
|
+
}
|
|
64971
|
+
} else if (isIdent(toks[j + 1]?.t) && toks[j + 2]?.t === "=" && isBag(j + 3)) {
|
|
64972
|
+
out2.add(toks[j + 1].t);
|
|
64973
|
+
}
|
|
64974
|
+
}
|
|
64975
|
+
return out2;
|
|
64976
|
+
}
|
|
64977
|
+
function requestKey(toks, open, close, names) {
|
|
64978
|
+
if (close === open + 2 && names.has(toks[open + 1].t)) return toks[open + 1].t;
|
|
64979
|
+
const k = open + 1;
|
|
64980
|
+
if (REQUEST_ROOTS.has(toks[k]?.t ?? "") && toks[k + 1]?.t === "." && REQUEST_BAGS.has(toks[k + 2]?.t ?? "") && toks[k + 3]?.t === "." && isIdent(toks[k + 4]?.t) && close === k + 5) {
|
|
64981
|
+
return `${toks[k].t}.${toks[k + 2].t}.${toks[k + 4].t}`;
|
|
64982
|
+
}
|
|
64983
|
+
return null;
|
|
64984
|
+
}
|
|
64985
|
+
function requestKeys(toks, fn) {
|
|
64986
|
+
const names = requestNames(toks, fn.open, fn.close);
|
|
64987
|
+
const out2 = [];
|
|
64988
|
+
for (let j = fn.open + 1; j < fn.close; j++) {
|
|
64989
|
+
if (toks[j - 1]?.t === ".") continue;
|
|
64990
|
+
const c = chainAt(toks, j);
|
|
64991
|
+
if (!c || toks[c.end]?.t !== "[") continue;
|
|
64992
|
+
const c1 = matchClose(toks, c.end);
|
|
64993
|
+
if (c1 < 0 || toks[c1 + 1]?.t !== "[") continue;
|
|
64994
|
+
const c2 = matchClose(toks, c1 + 1);
|
|
64995
|
+
if (c2 < 0 || !isAssign2(toks[c2 + 1]?.t)) continue;
|
|
64996
|
+
const k1 = requestKey(toks, c.end, c1, names);
|
|
64997
|
+
const k2 = requestKey(toks, c1 + 1, c2, names);
|
|
64998
|
+
if (k1 && k2) out2.push({ pos: toks[j].pos, target: c.text, key: `${k1}, ${k2}` });
|
|
64999
|
+
}
|
|
65000
|
+
return out2;
|
|
65001
|
+
}
|
|
65002
|
+
function detectPrototypePollution(code) {
|
|
65003
|
+
if (code.length > MAX_CODE_LENGTH) return [];
|
|
65004
|
+
const masked = maskLiterals(code);
|
|
65005
|
+
const toks = tokenize(masked);
|
|
65006
|
+
const fns = findFunctions(toks);
|
|
65007
|
+
const fileNullProto = nullProtoNames(toks, 0, toks.length);
|
|
65008
|
+
const hits = [];
|
|
65009
|
+
const seen = /* @__PURE__ */ new Set();
|
|
65010
|
+
for (const fn of fns) {
|
|
65011
|
+
const base = toks[fn.open].pos;
|
|
65012
|
+
const raw = code.slice(base, toks[fn.close].pos + 1);
|
|
65013
|
+
const found = [];
|
|
65014
|
+
for (const h of recursiveMerge(toks, fn)) found.push({ ...h, shape: "recursive-merge" });
|
|
65015
|
+
for (const h of setByPath(toks, raw, base, fn)) found.push({ ...h, shape: "set-by-path" });
|
|
65016
|
+
for (const h of requestKeys(toks, fn)) found.push({ ...h, shape: "request-keys" });
|
|
65017
|
+
if (found.length === 0) continue;
|
|
65018
|
+
const keys = /* @__PURE__ */ new Set();
|
|
65019
|
+
for (const h of found) for (const k of h.key.split(", ")) keys.add(k);
|
|
65020
|
+
if (hasGuard(raw, toks, fn.open, fn.close, keys)) continue;
|
|
65021
|
+
const nullProto = nullProtoNames(toks, fn.open, fn.close);
|
|
65022
|
+
for (const h of found) {
|
|
65023
|
+
const root = h.target.split(".")[0];
|
|
65024
|
+
if (nullProto.has(root) || fileNullProto.has(root)) continue;
|
|
65025
|
+
const line = lineOf(code, h.pos);
|
|
65026
|
+
if (seen.has(line)) continue;
|
|
65027
|
+
seen.add(line);
|
|
65028
|
+
hits.push({ line, shape: h.shape, target: h.target, key: h.key, fn: fn.name });
|
|
65029
|
+
}
|
|
65030
|
+
}
|
|
65031
|
+
return hits.sort((a, b) => a.line - b.line);
|
|
65032
|
+
}
|
|
65033
|
+
var MESSAGES = {
|
|
65034
|
+
"recursive-merge": (h) => `Recursive merge${h.fn ? ` \`${h.fn}\`` : ""} copies every key into \`${h.target}\` without rejecting \`__proto__\`, \`constructor\` or \`prototype\`: a source object with a \`__proto__\` key (for example from \`JSON.parse\`) writes into \`Object.prototype\`.`,
|
|
65035
|
+
"set-by-path": (h) => `Set-by-path${h.fn ? ` \`${h.fn}\`` : ""} walks \`${h.target}\` along a key path without rejecting \`__proto__\`, \`constructor\` or \`prototype\`: a path such as \`__proto__.isAdmin\` writes into \`Object.prototype\`.`,
|
|
65036
|
+
"request-keys": (h) => `\`${h.target}[\u2026][\u2026]\` is written with keys from the request (${h.key}): \`__proto__\` as the first key writes the second key into \`Object.prototype\`.`
|
|
65037
|
+
};
|
|
65038
|
+
var PrototypePollutionPass = class {
|
|
65039
|
+
name = "prototype-pollution";
|
|
65040
|
+
category = "security";
|
|
65041
|
+
run(ctx) {
|
|
65042
|
+
const { language } = ctx;
|
|
65043
|
+
if (language !== "javascript" && language !== "typescript") return { findings: [] };
|
|
65044
|
+
const file = ctx.graph.ir.meta.file;
|
|
65045
|
+
const findings = detectPrototypePollution(ctx.code);
|
|
65046
|
+
for (const h of findings) {
|
|
65047
|
+
ctx.addFinding({
|
|
65048
|
+
id: `${this.name}-${file}-${h.line}`,
|
|
65049
|
+
pass: this.name,
|
|
65050
|
+
category: this.category,
|
|
65051
|
+
rule_id: this.name,
|
|
65052
|
+
cwe: "CWE-1321",
|
|
65053
|
+
severity: h.shape === "request-keys" ? "high" : "medium",
|
|
65054
|
+
level: h.shape === "request-keys" ? "error" : "warning",
|
|
65055
|
+
message: MESSAGES[h.shape](h),
|
|
65056
|
+
file,
|
|
65057
|
+
line: h.line,
|
|
65058
|
+
fix: "Skip the keys `__proto__`, `constructor` and `prototype` before writing, or write into an object made with `Object.create(null)` or a `Map`.",
|
|
65059
|
+
evidence: { shape: h.shape, target: h.target, key: h.key, ...h.fn ? { function: h.fn } : {} }
|
|
65060
|
+
});
|
|
65061
|
+
}
|
|
65062
|
+
return { findings };
|
|
65063
|
+
}
|
|
65064
|
+
};
|
|
65065
|
+
|
|
63390
65066
|
// src/analysis/passes/csrf-samesite-none-session-pass.ts
|
|
63391
65067
|
var SESSION_FACTORIES = /* @__PURE__ */ new Set(["session", "cookieSession", "expressSession"]);
|
|
63392
|
-
var
|
|
65068
|
+
var MUTATING_METHODS2 = /* @__PURE__ */ new Set(["post", "put", "patch", "delete"]);
|
|
63393
65069
|
var DEFENCE_MARKERS = ["csrf", "csurf", "xsrf", "lusca"];
|
|
63394
65070
|
var ORIGIN_CHECK_MARKERS = [
|
|
63395
65071
|
"headers.origin",
|
|
@@ -63407,7 +65083,7 @@ var ORIGIN_CHECK_MARKERS = [
|
|
|
63407
65083
|
"header('referer')",
|
|
63408
65084
|
'header("referer")'
|
|
63409
65085
|
];
|
|
63410
|
-
function
|
|
65086
|
+
function isIdentChar5(ch) {
|
|
63411
65087
|
return ch !== void 0 && (ch === "_" || ch === "$" || ch >= "a" && ch <= "z" || ch >= "A" && ch <= "Z" || ch >= "0" && ch <= "9");
|
|
63412
65088
|
}
|
|
63413
65089
|
function sameSiteSetting(options) {
|
|
@@ -63417,7 +65093,7 @@ function sameSiteSetting(options) {
|
|
|
63417
65093
|
const at = options.indexOf("sameSite", from);
|
|
63418
65094
|
if (at < 0) return result;
|
|
63419
65095
|
from = at + "sameSite".length;
|
|
63420
|
-
if (
|
|
65096
|
+
if (isIdentChar5(options[at - 1]) || isIdentChar5(options[from])) continue;
|
|
63421
65097
|
let k = from;
|
|
63422
65098
|
if (options[k] === "'" || options[k] === '"') k++;
|
|
63423
65099
|
while (options[k] === " ") k++;
|
|
@@ -63449,9 +65125,9 @@ function sessionOptions(useCall) {
|
|
|
63449
65125
|
return null;
|
|
63450
65126
|
}
|
|
63451
65127
|
function isStateChangingRoute(call) {
|
|
63452
|
-
if (!
|
|
65128
|
+
if (!MUTATING_METHODS2.has(call.method_name)) return false;
|
|
63453
65129
|
const receiver = (call.receiver ?? "").trim();
|
|
63454
|
-
if (!receiver || [...receiver].some((ch) => !
|
|
65130
|
+
if (!receiver || [...receiver].some((ch) => !isIdentChar5(ch))) return false;
|
|
63455
65131
|
const path = (call.arguments.find((a) => a.position === 0)?.expression ?? "").trim();
|
|
63456
65132
|
return path.length >= 3 && (path[0] === "'" || path[0] === '"' || path[0] === "`") && path[1] === "/" && call.arguments.length >= 2;
|
|
63457
65133
|
}
|
|
@@ -64075,7 +65751,7 @@ var ComplexityMetricsPass = class {
|
|
|
64075
65751
|
};
|
|
64076
65752
|
|
|
64077
65753
|
// src/analysis/metrics/passes/halstead-metrics-pass.ts
|
|
64078
|
-
var
|
|
65754
|
+
var KEYWORDS3 = /* @__PURE__ */ new Set([
|
|
64079
65755
|
"if",
|
|
64080
65756
|
"else",
|
|
64081
65757
|
"for",
|
|
@@ -64166,7 +65842,7 @@ var HalsteadMetricsPass = class {
|
|
|
64166
65842
|
const { code } = ctx;
|
|
64167
65843
|
const allKeywords = Array.from(code.matchAll(KEYWORD_RE), (m) => m[0]);
|
|
64168
65844
|
const allSymbols = Array.from(code.matchAll(SYMBOL_RE), (m) => m[0]);
|
|
64169
|
-
const allIdents = Array.from(code.matchAll(IDENT_RE), (m) => m[0]).filter((t) => !
|
|
65845
|
+
const allIdents = Array.from(code.matchAll(IDENT_RE), (m) => m[0]).filter((t) => !KEYWORDS3.has(t));
|
|
64170
65846
|
const allLiterals = Array.from(code.matchAll(LITERAL_RE), (m) => m[0]);
|
|
64171
65847
|
const operators = [...allKeywords, ...allSymbols];
|
|
64172
65848
|
const operands = [...allIdents, ...allLiterals];
|
|
@@ -65401,6 +67077,10 @@ async function analyzeFile(code, filePath, language, options) {
|
|
|
65401
67077
|
if (!disabledPasses.has("cache-no-vary")) pipeline.add(new CacheNoVaryPass());
|
|
65402
67078
|
if (!disabledPasses.has("jwt-verify-disabled")) pipeline.add(new JwtVerifyDisabledPass());
|
|
65403
67079
|
if (!disabledPasses.has("sensitive-data-in-log")) pipeline.add(new SensitiveDataInLogPass());
|
|
67080
|
+
if (!disabledPasses.has("redos-regex-literal")) pipeline.add(new RedosRegexLiteralPass());
|
|
67081
|
+
if (!disabledPasses.has("hardcoded-secret-argument")) pipeline.add(new HardcodedSecretArgumentPass());
|
|
67082
|
+
if (!disabledPasses.has("missing-auth-middleware")) pipeline.add(new MissingAuthMiddlewarePass());
|
|
67083
|
+
if (!disabledPasses.has("prototype-pollution")) pipeline.add(new PrototypePollutionPass());
|
|
65404
67084
|
if (!disabledPasses.has("csrf-protection-disabled")) pipeline.add(new CsrfProtectionDisabledPass());
|
|
65405
67085
|
if (!disabledPasses.has("csrf-samesite-none-session")) pipeline.add(new CsrfSameSiteNoneSessionPass());
|
|
65406
67086
|
if (!disabledPasses.has("xml-entity-expansion")) pipeline.add(new XmlEntityExpansionPass());
|