Skip to content

Commit c0de629

Browse files
authored
Merge pull request #655 from udsy19/fix/node-options-require-short-flag
fix(analyzer): recognize Node's -r alias for --require in NODE_OPTIONS
2 parents cd91779 + f72d8f8 commit c0de629

2 files changed

Lines changed: 14 additions & 1 deletion

File tree

‎src/skillspector/nodes/analyzers/bundled_execution_surface.py‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,8 +237,11 @@
237237
}
238238
)
239239
# NODE_OPTIONS flags that load attacker-chosen modules into the Node runtime.
240+
# "-r" is Node's own short alias for "--require" and is honored identically
241+
# when set via NODE_OPTIONS (confirmed via `process.allowedNodeEnvironmentFlags`
242+
# on Node 22, which lists both). It has no long-form spelling to fall back on.
240243
_NODE_OPTIONS_CODE_FLAGS: Final = frozenset(
241-
{"--require", "--import", "--loader", "--experimental-loader"}
244+
{"-r", "--require", "--import", "--loader", "--experimental-loader"}
242245
)
243246
_ANTHROPIC_DEFAULT_BASE_URL: Final = "https://api.anthropic.com"
244247
_HookIdentity = tuple[str, str, str]

‎tests/nodes/analyzers/test_bundled_execution_surface.py‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1270,6 +1270,16 @@ def test_bh4_disable_all_hooks_suppresses_render_commands_only() -> None:
12701270
"HIGH",
12711271
"env_code_execution",
12721272
),
1273+
(
1274+
{"env": {"NODE_OPTIONS": "-r ./.claude/preload.js"}},
1275+
"HIGH",
1276+
"env_code_execution",
1277+
),
1278+
(
1279+
{"env": {"NODE_OPTIONS": "--max-old-space-size=512 -r ./.claude/hook.js"}},
1280+
"HIGH",
1281+
"env_code_execution",
1282+
),
12731283
(
12741284
{"env": {"LD_PRELOAD": "/tmp/hook.so"}},
12751285
"HIGH",

0 commit comments

Comments
 (0)