mirror of
https://github.com/norandom/OpenUltraSAST.git
synced 2026-12-03 02:08:18 +00:00
fix(search-with-proof): a chromium failure names the first line of its output, where its cause is
The CI run on1721b58(run 46191667349) failed tests/test_search_browser.py::test_real_browser_executes_not_reflects with "headless chromium did not produce a document:" and a register dump. On 2026-11-24 the same test failed for the opposite reason: chromium printed "FATAL ... No usable sandbox!" and did not exit, and the launch timed out. Sincec4720bathe test skips on that evidence in the launch error's cause. In the run of 2026-11-28 chromium returned, and the error carried the last 500 characters of its stderr only, the end of the dump. The skip could not see the cause, so the test failed. What changed - src/openultrasast/search/oracles.py: the error of a chromium run without a document now carries the whole stderr up to 500 characters. For a longer output it carries the first 400 characters, " ... ", and the last 100 (_stderr_excerpt). chromium prints its cause first. - tests/test_search_browser.py: one new test. A chromium that prints a cause and then a long trace raises an error that names the cause. Checks - s10_ci3_red.out: the new test at HEAD1721b58: 1 failed, 4 passed. - s10_ci3_green.out: after the change, the six test files whose text names the oracles or BrowserExecutor (browser, control, demo_replay, isolation, probe, verify): 113 passed in the project environment and 113 passed in a separate environment made from the lockfile. - s10_ci3_exits.txt: the gates with label ci3, ten zeros. s10_ci3_diffcheck.out: two files, +21 -1; git diff --check exits 0. - The s10 files are under /tmp/opencode, outside the repository. Not verified - The run on GitHub. The start of chromium's output on the runner is in no log. It may be the same "No usable sandbox!", another fatal line of the sandbox code, or error lines that push the cause past the first 400 characters: the error names a cause only within its first 400 characters or its last 100. The runner image does not explain the failure. The same register dump failed the release job of 2026-11-06, and the two runs before this one that evening did not fail this test. - tests/test_search_probe.py::test_task_boundary_probe_executes_packaged_pairs[real] failed on the runner in two runs with a status whose cause the output cut, and passed in the third. Its record is printed since1721b58if it fails again. Review. Read-only, with independent reruns under /tmp/opencode/s10_rev_ci3/. Both logs hold the core of the story: on 2026-11-24 the launch timed out and the stderr of its cause starts with the fatal line (s10_ci0_checks_job.log:2644, 2657); in run 46191667349 chromium returned and oracles.py:282 kept the last 500 characters, registers only (s10_ci3_checks_plain.log:983-989). The new test, run against the oracles.py of1721b58, fails as recorded (AssertionError at line 27, 1 failed, 4 passed, pytest exit 1); with the change the file gives 5 passed. The image does not explain the failure: the same register dump is in the release job of 2026-11-06 (s9_c9_job_failed.out:966), and the two runs before it that evening did not fail this test. Not verified: the start of chromium's output there. A cause is named only within its first 400 characters or its last 100.
This commit is contained in:
@@ -190,6 +190,13 @@ class SSRFOracle(OutputOracle):
|
|||||||
self.process.stdout.close()
|
self.process.stdout.close()
|
||||||
|
|
||||||
|
|
||||||
|
def _stderr_excerpt(stderr: str) -> str:
|
||||||
|
"""The start of chromium's output, where its cause is printed, and the end of a long crash trace."""
|
||||||
|
if len(stderr) <= 500:
|
||||||
|
return stderr
|
||||||
|
return stderr[:400] + " ... " + stderr[-100:]
|
||||||
|
|
||||||
|
|
||||||
class BrowserExecutor:
|
class BrowserExecutor:
|
||||||
"""Run captured HTML with a verifier-owned alert canary.
|
"""Run captured HTML with a verifier-owned alert canary.
|
||||||
|
|
||||||
@@ -279,7 +286,8 @@ class BrowserExecutor:
|
|||||||
except subprocess.SubprocessError as exc:
|
except subprocess.SubprocessError as exc:
|
||||||
raise OSError("headless chromium failed") from exc
|
raise OSError("headless chromium failed") from exc
|
||||||
if done.returncode or "<html" not in done.stdout.lower():
|
if done.returncode or "<html" not in done.stdout.lower():
|
||||||
raise OSError("headless chromium did not produce a document: " + done.stderr[-500:])
|
# chromium prints its cause first, then a stack trace and a register dump: keep both ends.
|
||||||
|
raise OSError("headless chromium did not produce a document: " + _stderr_excerpt(done.stderr))
|
||||||
|
|
||||||
class Marker(HTMLParser):
|
class Marker(HTMLParser):
|
||||||
seen = False
|
seen = False
|
||||||
|
|||||||
@@ -16,6 +16,18 @@ def test_browser_launch_failure_is_not_negative(monkeypatch):
|
|||||||
BrowserExecutor(binary="/fake/chromium")('<script>alert("ousast-xss")</script>', "nonce")
|
BrowserExecutor(binary="/fake/chromium")('<script>alert("ousast-xss")</script>', "nonce")
|
||||||
|
|
||||||
|
|
||||||
|
def test_browser_error_names_the_first_line_of_chromium_output(monkeypatch):
|
||||||
|
# chromium prints its cause first ("No usable sandbox!"), then a stack trace and a register dump.
|
||||||
|
stderr = "FATAL:zygote_host_impl_linux.cc:144] No usable sandbox!\n" + "#0 0x0000000000000000\n" * 400 + "[end of stack trace]"
|
||||||
|
|
||||||
|
def run(*args, **kwargs):
|
||||||
|
return subprocess.CompletedProcess(args, 1, "", stderr)
|
||||||
|
|
||||||
|
monkeypatch.setattr(subprocess, "run", run)
|
||||||
|
with pytest.raises(OSError, match="No usable sandbox"):
|
||||||
|
BrowserExecutor(binary="/fake/chromium")('<script>alert("ousast-xss")</script>', "nonce")
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.skipif(not (shutil.which("chromium") or shutil.which("chromium-browser")), reason="chromium not installed")
|
@pytest.mark.skipif(not (shutil.which("chromium") or shutil.which("chromium-browser")), reason="chromium not installed")
|
||||||
@pytest.mark.sandbox
|
@pytest.mark.sandbox
|
||||||
def test_real_browser_executes_not_reflects():
|
def test_real_browser_executes_not_reflects():
|
||||||
|
|||||||
Reference in New Issue
Block a user