mirror of
https://github.com/norandom/OpenUltraSAST.git
synced 2026-12-03 10:18:18 +00:00
88ea171dbe1048c0247c030dcd862734815cf0e9
3
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
52c9afb85f |
feat(contributor-scan): a scan says how many source files it left out under its runs directory (3.1, follow-up)
`56c4620` made a scan skip its runs directory when it lies inside the scanned path, and said nothing about it. By the maintainer's decision of 2026-11-25, recorded in the handover, the scan now prints one notice. The decision, as the handover records it: "When source files lie under the runs directory inside the scanned path, the scan prints one notice: line naming the path and the number left out, the way run retention does." The line is `notice: skipped <n> source files under the runs directory <path>` (`source file` at one). `ousast scan` prints it, the `openultrasast.scan` tool returns it among its notices, and `openultrasast.benchmark` returns the notices of the scan it runs. Nothing is added to the manifest or the report. The count follows the scanned tree's own rules, so it is the number the skip took: a source file that the target's root `.gitignore` already keeps out, or that lies under a directory the scan ignores, brings no notice, and a `.gitignore` inside the runs directory does not hide what was left out. To that end `enumerate_source_files` in src/openultrasast/preprocess.py and the new `count_skipped_source_files` share one private predicate, `_is_read_as_source`. The enumeration returns the lists it returned before (the skip test now comes first, so a path under the skipped directory is no longer stat'ed). The count is taken after the preprocess stage, so a tree whose ignore file cannot be read stops the scan inside that stage, as before. It costs one more read of the target's root `.gitignore` and, where there is one, one more `git ls-files`, and only when the runs directory lies inside the scanned path. Nothing is said when no source file is left out, when the runs directory lies outside the scanned path, or when it is the target or lies above it. Tests: the notice tests failed on the code as it was (6 failed) and pass after the change. Four more failed on a first cut that counted by the runs directory's own `.gitignore` and pass on this one: a `.gitignore` inside the runs directory does not hide what the scan left out, nothing is left out where the target already ignores the runs directory, nothing under a directory the scan ignores, and a directory named `.gitignore` costs the scan nothing. The test that a target inside the runs directory is read as it was now also pins that nothing is said; a count that covered that target failed it. The 23 test files around the change pass (241 passed); ruff, mypy, the three gates and compileall pass, and the gates print what they printed before the change. An independent reviewer approved the change in two rounds. Its first round found the count by the wrong rules, which this cut closes. Its second round named two things that are left open and recorded in the handover: were the target's root `.gitignore` to become unreadable between the preprocess stage and the count, the scan would stop with no failed stage recorded in its trace and no manifest; and no test pins that a tracked source file under an ignored runs directory is counted. |
||
|
|
56c4620087 |
feat(contributor-scan): a scan skips its runs directory when it lies inside the scanned path (3.1, follow-up)
Since part A a native scan writes its run under the user cache or wherever `OPENULTRASAST_RUNS_DIR` points. A scan of a path that contains that directory, a home directory or a tree with the runs directory set inside it, took the files under it for source: those of earlier runs and those of its own run. On the code as it was, a source file under the runs directory inside the target was read and its finding reported (`file_targets=3 findings=2` for a tree of two files and one such copy). By the maintainer's decision, recorded as step 2c of the handover, the scan skips the runs directory only: `config.runs_dir`, the default location or the override. The other directories under `~/.cache/openultrasast` are read as before, and so is every tree whose runs directory lies outside it. `preprocess_repository` and `enumerate_source_files` in src/openultrasast/preprocess.py take a `skip` directory, and the preprocess stage of a scan (`_map_scan_targets` in cli.py) passes `Path(config.runs_dir)`. The skip applies only where the runs directory lies inside the scanned path: a target that is the runs directory or lies inside it is read as it was, so a runs directory set to `.` does not silence a scan. Both paths are compared resolved, so a symlinked or relative name is found, and the excluded path is built under the root as the walk spells it, so a relative root works too. Every other caller of the two functions passes no `skip` and is unchanged. No run of this package keeps a source file today (the independent reviewer's count: a quick run holds 15 files, all `.json`, `.jsonl`, `.md` or `.sarif`; the two benchmark runs in the real cache hold `.json` and `.toml`). The copy in the tests is a constructed case. Tests: four tests failed on the code as it was and pass after the change: the runs directory inside the scanned path, by the override, by the default location and by the override through a symlink, and the rest of the cache still read. Two more pin the narrow reading, a target that is the runs directory or lies inside it is read as it was; they failed on a first cut that skipped more than was decided. A direct call with a relative root pins the path comparison. The nine test files around the change pass (113 passed), as do the 37 files that exercise the scan path (362 passed); ruff, mypy, the three gates and compileall pass. Runs of the real CLI on one scratch subject, the code at HEAD against this tree: with the runs directory inside the target the copy under it is no longer read (`file_targets=4 findings=3` for five source files); with the runs directory a parent of the target, or the target itself, both read the same five files and report the same four findings. An independent reviewer approved the change in three rounds; its first round found that the first cut also silenced a scan whose target lay inside the runs directory, which this cut narrows to the decided case. |
||
|
|
6edae3a585 |
feat(contributor-scan): a scan writes its run to the user cache, and the ledger only when it learns (3.1, part A)
Where a scan writes. A native scan now creates its run under the user cache, ~/.cache/openultrasast/runs/<scan-id>/ by default ($XDG_CACHE_HOME when it is set and absolute), prints run_dir=<path> once, and no longer writes anything under the analysed tree. OPENULTRASAST_RUNS_DIR still wins: an absolute value is used as given, a relative one resolves against the working directory. Pre-push storage is unchanged. The calibration ledger, by maintainer decision: .openultrasast/calibration/ stays the store, and a scan writes the false-positive ledger into the tree only when its content would change. On a read-only tree the scan records ledger_not_written, with a sentence in the report, and completes; before, a read-only target with one rejected finding crashed before report.md existed. benchmarks/repos/measure.py follows the printed run directory. It read the run from under the scanned copy, which would have recorded every repository as failed, and it also read a stale run left in a copy. Tests: tests/test_scan_output_location.py drives the real CLI and compares the whole tree before and after; tests/test_repo_measure.py pins the measurement script; an autouse fixture keeps every test's scan runs out of the developer's cache; fourteen test files follow the run to its new place. README, docs/examples.md and the scan skill name the ledger as the one write a scan makes. _run_scan is touched by one line and stays over the complexity cap. Task 3.1 stays open for part B, the readable summary. |