mirror of
https://github.com/norandom/OpenUltraSAST.git
synced 2026-12-03 02:08:18 +00:00
3e134f4e0d73183e5c5410e54294f33320bdb314
4
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
efa311a112 |
fix(shell): the wrapper passes the retention days into the image (item 5b)
The maintainer's second decision on answer 7, taken on 2026-11-27 while the scan path change ( |
||
|
|
d8b4cac023 |
fix(shell): the wrapper says so when it cannot make its runs directory (item 5b)
The maintainer's answer 4 of 2026-11-27, "Guard it" (.kiro/handover.md:1409-1413), as
offered: "a clear message when HOME is unset, and a failed mkdir stops the wrapper
with exit 1; a test first." The fault it answers, in the same words: "With HOME unset
the wrapper now fails ($HOME/.cache becomes /.cache), where it wrote ./.ousast
before; a failed mkdir is not checked, as before."
What changed
- ops/shell/ousast.sh, the container path: the wrapper returns 1 with "ousast: HOME is
not set, so there is no ~/.cache/openultrasast/runs to write the runs to" when HOME
is unset or empty, and with "ousast: cannot create <runs>, where the runs are
written" when mkdir -p fails (mkdir's own line comes first).
- The two lines that set `runs` and ran mkdir -p moved up to that place, from after the
build. The placement is the session's reading of "stops the wrapper": a cold build
pulls ~2 GB, and a run that cannot write its runs should say so before it waits.
- The native path names no HOME and is not touched.
Tests (tests/test_shell_wrapper.py)
- test_the_container_path_stops_when_home_is_not_set: exit 1, that one line on
stderr, nothing on stdout, so neither the build nor the container is started.
- test_a_runs_directory_that_cannot_be_made_stops_the_wrapper: a file where
$HOME/.cache should be; exit 1, the wrapper's line last on stderr, nothing on stdout.
- The helper `ousast` takes `without_home`. The docker stub answers `image inspect`
with exit 1, so the wrapper takes its build branch in each test that reaches the
build (the second and the third); before that, "nothing on stdout" said nothing
about the build.
- RED, on an archive of HEAD with the final test file (s10_c4_red5.out): 2 failed, 3
passed, each `assert 0 == 1`. For the reason of the fault: the wrapper builds, mkdir
is refused ("/.cache: Permission denied", run as uid 1000) or fails ("Not a
directory"), the wrapper goes on to the container (with reports=/.cache/... when
HOME is unset), and the exit status is 0.
- GREEN, on the working tree (s10_c4_green5.out): 5 passed.
- A mutant with the guard behind the build fails both new tests on the build's line
(/tmp/opencode/s10_c4_mutant.py, output s10_c4_mut.out), so the tests pin the
placement; with another shebang in STUB it fails the same way (s10_c4_nopin.out).
- Gates (s10_c4e_exits.txt): ten zeros; the three gate outputs equal the baseline's.
Measured outside the stubs (/tmp/opencode/s10_c4_probe.sh, output s10_c4_probe.out):
real bash on this machine, the native path switched off so that no probe can scan.
HOME unset, HOME empty, and bash under set -u with HOME unset each print the one line
and exit 1; a file at $HOME/.cache prints mkdir's line, then the wrapper's, exit 1.
By reading, not measured
- zsh can source the wrapper as well. The block uses `[ -z "${HOME:-}" ]`, `local`,
`if ! mkdir -p`, `echo ... >&2` and `return 1`; zsh is not installed here, so no
probe ran.
- A run as root with HOME unset had another shape on HEAD: mkdir -p /.cache succeeds
there, so the runs went to the filesystem root with no error. The guard closes it
the same way. This session's runs are as uid 1000.
Found and not fixed, for the maintainer
- The helper's second parameter is `executables`. The third test passes "scan" there
(tests/test_shell_wrapper.py:65, HEAD:63), which makes four stubs named s, c, a and
n beside docker's. Nothing calls them. The new tests pass an empty tuple.
- A runs directory that exists but cannot be written to passes the guard: mkdir -p
exits 0 on it (s10_c4_readonly_runs.out), and the wrapper goes on to docker. The
decision says "a failed mkdir".
- The container path reads $HOME/.cache alone and ignores XDG_CACHE_HOME, which the
native path honours (src/openultrasast/config.py:198-203); README.md:189-190 and
docs/examples.md:3-5 state the rule for every run. From before this commit.
- ops/shell/ousast.ps1:44-45 has the same shape, a New-Item whose result is not
checked, after the build. Read, not run: pwsh is not installed.
- The wrapper's message for an unset HOME (ops/shell/ousast.sh:53) describes the
container path, which reads $HOME alone. Without HOME, Python's Path.home() and
bash's `~` still give /home/mc on this machine (s10_c4_pathhome.out), and a native
scan's default runs directory comes from the former unless XDG_CACHE_HOME is set to
an absolute path (src/openultrasast/config.py:198-203 and :216-226). As decided.
Review
- Review: four rounds against
|
||
|
|
d1f61fbe6f |
fix(contributor-scan): the wrapper writes its runs to the user cache (item 5a)
The shell wrapper wrote the runs of the image to ./.ousast, inside the repository it was scanning (the eighth session: three runs under it). It now creates ~/.cache/openultrasast/runs, mounts it at /reports, the one writable mount, and passes -e OPENULTRASAST_RUNS_DIR=/reports to its compose run, so nothing is written to the scanned directory. The override is the maintainer's choice of 2026-11-27, on a measurement. Answer 4 of the menu of 2026-11-26 was worded as the mount alone. Measured that day: compose sets OPENULTRASAST_RUNS_DIR=/reports/runs in the service, so the mount alone put the run on the host at ~/.cache/openultrasast/runs/runs/<run>, one level below a native run, and nothing prunes it there (prune_old_runs removes only run directories directly under the root whose names match the run id). With the override the run lands beside native runs. Two things the choice does not change: a scan in the image never prunes, so the wrapper's runs are removed by a later native scan on the default location; and the wrapper writes to ~/.cache/openultrasast/runs whether or not XDG_CACHE_HOME or OPENULTRASAST_RUNS_DIR moves a native run elsewhere. ops/shell/ousast.ps1 gets the same change, the maintainer's second choice: it writes %USERPROFILE%\.cache\openultrasast\runs and passes the same override. That file was edited by reading and WAS NOT RUN: there is no PowerShell on this machine. Tests: tests/test_shell_wrapper.py has a third test. It failed before the change (no runs directory under HOME) and again until the override was passed. After: 3 passed. Measured on 2026-11-27 through the shell wrapper with the real Docker, from a directory without .env, both API keys unset: `ousast scan examples --mode quick` on a copy of libpng's contrib/examples prints run_dir=/reports/<run>, the container prefix, with file_targets=4, findings=4, exit 0; the run is on the host directly under ~/.cache/openultrasast/runs, owned by the user; the scanned directory stays empty. The eight tests of tests/test_docs_site.py and tests/test_removed_plane_references.py pass, `mkdocs build --strict` exits 0, ruff format, ruff check, mypy, the three gates and compileall pass, and the gates print what they printed before the change. An independent reviewer approved the change in one round; its remarks on the README clause, on the test, on the evidence and on the width of one line are applied. Left as it is, for the maintainer: with HOME unset the shell wrapper now fails, where it wrote ./.ousast before ($HOME is empty, so the path is /.cache/openultrasast/runs, and a failed mkdir is not checked, as it was not before). |
||
|
|
a6e8e2615a |
fix(contributor-scan): the wrapper's native path runs in the caller's directory (item 5a)
`ousast scan .` through ops/shell/ousast.sh with a native install scanned the wrong tree. The native path changed into the checkout before it passed the arguments on, so `.` was the OpenUltraSAST checkout and a relative file name was looked up there. The eighth session showed it with a stub interpreter in place of `.venv/bin/python` (`cwd=/tmp/opencode/s8_fakehome args=-m openultrasast.cli scan .`). The check also looked for `joern-parse` only, while the batch queries run `joern`: with `joern-parse` alone on PATH every batch query failed and a standard scan still exited 0 (2026-11-26, 14 findings where the working launcher gives 15). The native path now runs the checkout's interpreter by its absolute path, in the caller's directory, as the container path does, and it is taken only when `joern` is on PATH as well. So `.`, relative names and relative options mean the caller's files. The reviewer found, and a run confirmed, what dropping the `cd` brings: `-m` alone puts the working directory first on the interpreter's path, so a file of the scanned tree could stand in for a module the CLI imports (a `json.py` in the caller's directory: `ousast --help` printed SHADOW-EXECUTED and exited 3). The interpreter is started with `-P`, which keeps that directory off the path; the flag needs Python 3.11, the project's floor (pyproject.toml). Changes a caller sees, beyond the one the decision named: - The checkout's .env is no longer read on the native path; the CLI reads .env from the working directory, which is now the caller's. ops/README.md says so. - `ousast pairs` and `ousast repos` no longer find their defaults outside the checkout, because `benchmarks/` is read relative to the working directory. Measured for `pairs`: through the wrapper natively, and on the container path, `pairs --slice vibe-py` ends with "pair catalog is not a file: benchmarks/pairs/catalog.toml", exit 1, so the container path already behaved this way. `repos` by reading. Run from the checkout root they find their defaults again (by reading; not run). The header's `ousast pairs --slice vibe-py` example is removed. This is a reading the maintainer may correct. - The message for a machine without Docker names both executables. Tests: the new tests/test_shell_wrapper.py runs the wrapper by bash with a stub of the interpreter, `joern`, `joern-parse` and `docker` ahead of /usr/bin and /bin on PATH. Its two tests failed before the change (2 failed: the interpreter ran in the fake checkout, and the native path was taken without `joern`), and the first failed again until `-P` was passed (1 failed). With the real venv and Joern 4.0.625 on PATH, from a directory without .env: `ousast scan examples --mode quick` on a fresh copy of libpng's contrib/examples gives file_targets=4, findings=4, exit 0, before and after the flag, the figures of the eighth session. The eight tests of tests/test_docs_site.py and tests/test_removed_plane_references.py pass, `mkdocs build --strict` exits 0, ruff format, ruff check, mypy, the three gates and compileall pass, and the gates print what they printed before the change. An independent reviewer approved the change in the second round; its two findings of the first round led to the `-P` flag and to the removal of the header example. Found by the reviewer and left alone, outside this decision: the background child of `ousast pre-push` (src/openultrasast/push/background.py) starts the CLI with `-m` and without `-P`, from the pushed repository. |