Skip to content

Commit c15588b

Browse files
address timon's feedback
1 parent 68f41f4 commit c15588b

2 files changed

Lines changed: 10 additions & 10 deletions

File tree

static/js/render/tool_result/dual_path_parity_oracle.test.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,9 @@ import { renderBashResult } from './bash.js';
2222
// tests/test_dual_path_parity_oracle.py.
2323
const PAYLOAD = '<img src=x onerror=alert(1)>';
2424

25-
// Parsed bash dict that mirrors what ``_parse_tool_result`` / ``_tool_result_build_bash``
26-
// would produce for the adversarial blob.
25+
// Hand-built parsed shape for the JS renderer only. Classification and fields from
26+
// ``_parse_tool_result`` are asserted in tests/test_dual_path_parity_oracle.py;
27+
// this file will not catch drift if the Python bash builder changes key names.
2728
const ADVERSARIAL_PARSED = {
2829
result_type: 'bash',
2930
slug: null,

tests/test_dual_path_parity_oracle.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,7 @@ def test_adversarial_bash_result_python_path_wraps_in_code_fence() -> None:
116116
code fence, neutralising the XSS vector as inert literal text.
117117
118118
Negative control: if the code fence were removed from ``_render_tool_result``
119-
(renderer regressed to raw prose), ``opening_fence`` below would be None and
120-
the assertion would fail — a diverging renderer cannot pass this test.
119+
(renderer regressed to raw prose), the odd-fence check below would fail.
121120
"""
122121
parsed = _parse_tool_result(_adversarial_bash_tr())
123122
assert parsed is not None
@@ -140,13 +139,13 @@ def test_adversarial_bash_result_python_path_wraps_in_code_fence() -> None:
140139
assert payload_indices, "adversarial payload must appear in at least one output line"
141140

142141
payload_idx = payload_indices[0]
143-
opening_fence = next((i for i in fence_indices if i < payload_idx), None)
144-
closing_fence = next((i for i in fence_indices if i > payload_idx), None)
145-
146-
assert opening_fence is not None, (
147-
f"no opening code fence before payload at line {payload_idx}; "
148-
"payload is exposed in bare Markdown prose — Python renderer diverged"
142+
fences_before = [i for i in fence_indices if i < payload_idx]
143+
assert len(fences_before) % 2 == 1, (
144+
f"payload at line {payload_idx} must sit inside an open code fence "
145+
f"({len(fences_before)} fence marker(s) before it); "
146+
"bare prose between fenced blocks would still pass a naive before/after check"
149147
)
148+
closing_fence = next((i for i in fence_indices if i > payload_idx), None)
150149
assert closing_fence is not None, (
151150
f"no closing code fence after payload at line {payload_idx}; "
152151
"code fence is unclosed — Python renderer diverged"

0 commit comments

Comments
 (0)