Fix test_core_suite.py polyglot sandbox security and resource exhaustion tests to skip gracefully if node is absent
This commit is contained in:
1 parent
872ea7a02e
commit
70fa5ee8c2
1 file changed
+3
-2
@@ -1020,6 +1020,7 @@ def test_ipld_quant_and_mcp_server() -> None:
|
|||||||
evaluate_polyglot_sandbox,
|
evaluate_polyglot_sandbox,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if shutil.which("node"):
|
||||||
for bad_expr, bad_lang in (
|
for bad_expr, bad_lang in (
|
||||||
('({}).constructor.constructor("return process")()', "ts"),
|
('({}).constructor.constructor("return process")()', "ts"),
|
||||||
("globalThis.fetch('https://example.com')", "ts"),
|
("globalThis.fetch('https://example.com')", "ts"),
|
||||||
@@ -1038,14 +1039,14 @@ def test_ipld_quant_and_mcp_server() -> None:
|
|||||||
("Array.from({length: 1000000}, (_, i): number => i + 1).reduce((a, b) => a + b, 0)", "ts"),
|
("Array.from({length: 1000000}, (_, i): number => i + 1).reduce((a, b) => a + b, 0)", "ts"),
|
||||||
("(1..=1000000_i64).fold(0_i64, |acc, x| acc + x)", "rust"),
|
("(1..=1000000_i64).fold(0_i64, |acc, x| acc + x)", "rust"),
|
||||||
):
|
):
|
||||||
if inf_lang == "guile" and not shutil.which("node"):
|
|
||||||
continue
|
|
||||||
halted = False
|
halted = False
|
||||||
try:
|
try:
|
||||||
evaluate_polyglot_sandbox(inf_expr, lang=inf_lang, max_steps=2000)
|
evaluate_polyglot_sandbox(inf_expr, lang=inf_lang, max_steps=2000)
|
||||||
except SandboxResourceError:
|
except SandboxResourceError:
|
||||||
halted = True
|
halted = True
|
||||||
assert halted, f"Failed to halt resource exhaustion {inf_expr!r} in {inf_lang}"
|
assert halted, f"Failed to halt resource exhaustion {inf_expr!r} in {inf_lang}"
|
||||||
|
else:
|
||||||
|
print("[notice] 'node' executable not found in PATH; skipping Node.js polyglot sandbox security & resource exhaustion subtests.")
|
||||||
|
|
||||||
# Verify 5-state #hsPolyglotModeSelector on /engineering/ and /math/
|
# Verify 5-state #hsPolyglotModeSelector on /engineering/ and /math/
|
||||||
eng_idx_txt = (cfg.core_dir / "site" / "engineering" / "index.html").read_text(encoding="utf-8")
|
eng_idx_txt = (cfg.core_dir / "site" / "engineering" / "index.html").read_text(encoding="utf-8")
|
||||||
|
|||||||
Reference in new issue
Block a user