mirror of
https://github.com/norandom/OpenUltraSAST.git
synced 2026-10-16 03:49:26 +00:00
fix(cpg): the interpreter precondition probes the frontend's own parser script; 4.0.625 verified
php2cpg drives PHP-Parser through `php` from a script inside its own install. A second install the containerised interpreter had no mount for parsed 1 of 637 files and exited 0 -- caught by the build census, and now refused by name before any build. On 4.0.625 with the closure exclusion gated off: pmpro 637 of 637 in 100 s, WP Statistics 115 s with only the two data tables excluded. Phase-2 v5 verdict and the within-tier reading recorded in the brief. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01T7XD7x5KonMdmGRkp63EQG
This commit is contained in:
co-authored by
Claude Fable 5.1
parent
2de873274f
commit
3b3b96be5f
@@ -1073,3 +1073,32 @@ def test_the_closure_exclusion_stops_at_the_release_that_fixed_it(tmp_path: Path
|
||||
monkeypatch.setattr("shutil.which", lambda name: "/opt/bin/joern")
|
||||
assert joern_version() is None
|
||||
assert [Path(n).name for n in backend._files_with_frontend_defect(tmp_path, "php")] == ["bad.php"], "unknown keeps the workaround"
|
||||
|
||||
|
||||
def test_the_interpreter_must_read_the_frontend_parser_too(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
"""php2cpg drives PHP-Parser through `php` from a script inside its own install. An interpreter that can
|
||||
read the repository but not that script parses nothing, exits 0, and looks like a frontend regression --
|
||||
measured with a second Joern install the containerised `php` had no mount for. Refused by name."""
|
||||
import subprocess
|
||||
|
||||
from openultrasast.cpg.backend import JoernBackend
|
||||
|
||||
(tmp_path / "repo").mkdir()
|
||||
(tmp_path / "repo" / "a.php").write_text("<?php\n")
|
||||
install = tmp_path / "joern-cli"
|
||||
parser = install / "frontends" / "php2cpg" / "bin" / "php-parser" / "php-parser.php"
|
||||
parser.parent.mkdir(parents=True)
|
||||
parser.write_text("<?php\n")
|
||||
(install / "php2cpg").write_text("#!/bin/sh\n")
|
||||
|
||||
def runner(command, **kwargs): # type: ignore[no-untyped-def]
|
||||
if "-r" in command:
|
||||
# The interpreter's view: the repository is readable, the frontend's install is not.
|
||||
return subprocess.CompletedProcess(args=command, returncode=3 if "php-parser.php" in command[-1] else 0, stdout="", stderr="")
|
||||
raise AssertionError("no build may start when the precondition fails")
|
||||
|
||||
monkeypatch.setenv("OPENULTRASAST_JOERN_PROBE", "on")
|
||||
monkeypatch.setattr("shutil.which", lambda name: str(install / "php2cpg") if name == "php2cpg" else f"/opt/bin/{name}")
|
||||
backend = JoernBackend(runner=runner)
|
||||
assert backend.build(tmp_path / "repo", language="php") is None
|
||||
assert "php-parser.php" in backend.last_failure and "mounts the repository but not this install" in backend.last_failure
|
||||
|
||||
Reference in New Issue
Block a user