mirror of
https://github.com/norandom/OpenUltraSAST.git
synced 2026-12-03 10:18:18 +00:00
GitHub CI's checks job failed nine search tests on the ubuntu-26.04 runner
(run 45352669096), which has chromium and bubblewrap. Three causes:
- chromium prints "No usable sandbox!" inside the bubblewrap user namespace
and does not exit. The browser test skips on that evidence in the launch
error's cause, as it already did on "Operation not permitted" and
"Permission denied"; an ordinary browser failure still fails.
- `unshare --user --map-root-user --net` is refused ("write failed
/proc/self/uid_map: Operation not permitted"). The ssrf differential and
the namespace handoff test probe that command first and skip when it
fails. The other three differential families do not need it.
- The six node fixture tests could not run their app on the runner. They
need /usr/bin/node, the path the demo launcher uses, and now skip when
it is not executable. The runner's log does not name the missing path;
hiding it locally reproduces the same six failures.
A present but broken node, or a browser that fails for its own reasons,
remains a failure.
57 lines
2.4 KiB
Python
57 lines
2.4 KiB
Python
import html
|
|
import shutil
|
|
import subprocess
|
|
|
|
import pytest
|
|
|
|
from openultrasast.search.oracles import BrowserExecutor
|
|
|
|
|
|
def test_browser_launch_failure_is_not_negative(monkeypatch):
|
|
def fail(*args, **kwargs):
|
|
return subprocess.CompletedProcess(args, 1, "", "failed")
|
|
|
|
monkeypatch.setattr(subprocess, "run", fail)
|
|
with pytest.raises(OSError):
|
|
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.sandbox
|
|
def test_real_browser_executes_not_reflects():
|
|
browser = BrowserExecutor()
|
|
payload = '<script>alert("ousast-xss")</script>'
|
|
try:
|
|
observed = browser(payload, "nonce")
|
|
except OSError as exc:
|
|
# A present binary is insufficient on restricted hosts. Only known
|
|
# host permission denials skip; ordinary browser failures remain failures.
|
|
# oracles.py raises a fixed message `from` the launch error: the cause carries the evidence.
|
|
cause = exc.__cause__ or exc
|
|
evidence = " ".join(str(part) for part in (cause, getattr(cause, "stderr", None)))
|
|
denied = next((text for text in ("No usable sandbox", "Operation not permitted", "Permission denied") if text in evidence), None)
|
|
if denied:
|
|
pytest.skip("host denies browser isolation/socket setup: " + denied)
|
|
raise
|
|
assert observed
|
|
assert not browser(html.escape(payload), "nonce")
|
|
assert not browser("<p>nonce</p>", "nonce")
|
|
|
|
|
|
@pytest.mark.parametrize("executed", [False, True])
|
|
@pytest.mark.sandbox
|
|
def test_marker_is_dom_attribute_not_source_text(monkeypatch, executed):
|
|
import re
|
|
from urllib.parse import unquote
|
|
|
|
def run(command, **kwargs):
|
|
assert "--headless" in command and "--dump-dom" in command
|
|
assert "--unshare-all" in command and "--no-sandbox" not in command
|
|
document = unquote(command[-1].split(",", 1)[1])
|
|
attr, value = re.search(r'setAttribute\("([^"]+)","([^"]+)"\)', document).groups()
|
|
root = f'<html {attr}="{value}">' if executed else "<html>"
|
|
return subprocess.CompletedProcess(command, 0, root + document + "</html>", "")
|
|
|
|
monkeypatch.setattr(subprocess, "run", run)
|
|
assert BrowserExecutor(binary="/usr/bin/chromium")("<p>reflected nonce</p>", "nonce") is executed
|