mirror of
https://github.com/norandom/OpenUltraSAST.git
synced 2026-12-03 10:18:18 +00:00
The decision of the maintainer on the ninth session's menu, answer 9 (.kiro/handover.md,
untracked, 1340-1343 as it stood on 2026-11-27; the option as offered, 1451-1452):
> 9. The ledger in the image. Answer: "Decide the key now": a digest of the tree's files
> (the `fingerprint` of the `provenance` stage is no digest), one ledger per digest under
> the runs directory; a design note is shown to the maintainer before any code.
The design note (/tmp/opencode/s10_c10_design_note.md, 299 lines) was reviewed in five
rounds before it was shown, and shown to the maintainer whole on 2026-11-27 with its three
questions. The maintainer's answers came on 2026-11-28, through the question tool, each the
recommended option as offered: "Stand as written (Recommended)" on the note's rule of reading
and writing (its section 3.3), "With the runs, by last use (Recommended)" on how long a ledger
stays (section 3.5), and "Build it now (Recommended)". The dated note on task 3.1 of
.kiro/specs/contributor-scan/tasks.md (lines 459-502) carries the rule as approved.
The fault: the image mounts the target read-only, so the ledger a scan writes into the tree
(<target>/.openultrasast/calibration/false_positive_learnings.json) cannot be written there,
the scan records ledger_not_written, and the next scan in the image starts without the
learnings of the one before.
What changed
- src/openultrasast/tree_digest.py: tree_digest(target, runs_directory) (line 48), a sha256
over one entry per file in path order (the length of the path, a colon, the path, a tab,
the sha256 of the bytes), after a version line. Left out: links, the directories a scan
ignores (IGNORED_DIRS, so that the tree's ledger does not change its own key) and the runs
directory, whichever way it is reached (by device and inode). A file that cannot be read
and a directory that cannot be listed are named "unreadable"; a directory that can be
listed but not searched raises, as the scan's own reading of the tree does.
- src/openultrasast/digest_ledger.py: the ledger of a digest, calibration/<digest>.json under
the runs directory, in the JSON of the tree's ledger. read_digest_ledger (line 47) reads it
and marks it as used; settle_digest_ledger (line 65) applies the rule.
The tree took the write: the ledger is removed. The tree refused: the ledger is written
with its own entries and this scan's new ones, never one whose finding id the tree's
ledger has, only when that differs from its content, and removed when that would leave it
empty. No write: a ledger whose every entry the tree's ledger also has is removed. One that
could not be read (a file that is not a ledger, whatever its top level or its depth) is
taken for empty and goes, unless the tree refused and this scan wrote it. It is written
through a temporary file of the writer's own and a rename (line 112).
- src/openultrasast/cli.py: the stage tree_digest, before any stage reads the tree
(cli.py:603-605); _read_ledgers (cli.py:1085-1099), the tree's ledger and then the
digest's, the tree's entry winning by finding id; _persist_calibration_feedback
(cli.py:1101-1136), which writes the tree's ledger when its content would differ from what
it held, also when only the digest's entries are new to it; the manifest's ledger block
(cli.py:731-735); a notice when the digest's ledger could not be written or removed
(cli.py:755).
- src/openultrasast/run.py: prune_expired_ledgers (run.py:112), called by prune_scan_runs
(run.py:71-99). Under calibration/ of the same two locations as the runs, a ledger, or the
temporary file it was written through, last used OPENULTRASAST_RUNS_RETENTION_DAYS days
ago is removed; 0 keeps all. Files called something else, links and directories stay. A
removal that fails is said once and costs the scan nothing.
- src/openultrasast/reports.py: write_manifest takes ledger (reports.py:212, 254-255). The
ledger_not_written sentence names the digest's ledger when it holds the learnings
(reports.py:461-467, chosen at 479-483).
- README.md, docs/examples.md, docs/architecture.md and
.agents/skills/openultrasast-scan/SKILL.md say where the learnings of a read-only tree go,
and what removes them.
Two departures from recorded decisions, both put to the maintainer in the note and accepted
with it:
- The tree's ledger is written when a scan learns nothing new, because the digest's entries
are new to it. The decision of 2026-11-24 says it "is written only when a scan learns
something" (spec.json:68).
- A ledger of a digest is removed when it expires, and its time is changed when a scan reads
it. The decision of 2026-11-24 says "the scan's own run and anything not named like a run
are never touched" (spec.json:73), and dates a run by its id, where a ledger is dated by
its use.
Measured
- The built function gives the note's prototype's digest for the four-file subject
(915506a8...) and for libpng's copy (1dcd664f...): s10_c10_port.out.
- In the image, on the final code. A probe image of openultrasast:dev (3f959b31f2f2) with
the tree's package copied over it, built at 09:06:36Z and holding the tree's 297 .py files
(s10_c10_image_probe/03_probe_sources.out, s10_c10_sources_still_equal4.out). Standard
mode, no key, network none. The four C files of contrib/examples of libpng and their
README, copied fresh and mounted read-only at /target; a scratch runs directory mounted at
/reports with the wrapper's OPENULTRASAST_RUNS_DIR=/reports (s10_c10_image_probe.sh,
stamps 09:06:36Z to 09:09:14Z, 2026-11-28).
- The first scan learns four entries and keeps them in /reports/calibration/<digest>.json:
calibrations_applied=0, project_score 26, the manifest's ledger {digest_ledger: written,
learnings_read: {digest: 0, tree: 0}} (10_, 11_). The report names the file.
- The second scan of the same bytes reads them: calibrations_applied=2 on two files,
project_score 59, penalty_total 32.0, learnings_read 4 from the digest's ledger,
digest_ledger "left as it was" (20_, 21_). The file's time is that of the second scan's
read, 09:07:19Z (22_).
- The digest the scan took in the image equals the one taken on the host for the same
files (s10_c10_image_digest_host4.out). The target is unchanged
(s10_c10_image_target_same4.out).
- Three earlier runs of this probe and of the native run below, each on the code as it
stood before a later correction of the same rule (the value for a ledger that could not
be read; a ledger whose top level is not an object; one nested too deep), gave the same
numbers. Their stamps: 08:12:50Z to 08:17:31Z, 08:23:38Z to 08:27:42Z and 08:50:15Z to
08:54:17Z. They are kept as s10_c10_image_probe_run1, _run2, s10_c10_native_run1,
_run2 and _run3; of the third image run s10_c10_image_probe_run3.out and the host,
target and sources checks numbered 3 remain, since s10_c10_image_probe_run3 is empty.
Its files were read by the reviewer in round two.
- The shipped image, the control, on the same files: calibrations_applied=0 and
project_score 26 on both scans, no ledger block and no ledger (30_ to 42_).
- Natively, on a fresh copy of the same five files, the network off (s10_c10_native.sh,
09:09:14Z to 09:10:38Z): the first scan writes the tree's ledger (calibrations_applied=0,
project_score 26, digest_ledger none), the second reads it (calibrations_applied=2,
project_score 59, learnings_read 4 from the tree's ledger), and no ledger of a digest is
made (s10_c10_native/10_ to 22_).
- The probe left no container (2 before, 2 after: 00_, 91_) and its image is removed (90_,
92_).
Tests
- tests/test_tree_digest.py (7) and tests/test_digest_ledger.py (11, one over nine contents
a file may hold); seven tests in tests/test_scan_output_location.py, six through the scan
(three over two cases) and one on _read_ledgers; six in tests/test_run_pruning.py; one
sentence in tests/test_reports.py. The scan test of a refused write selects its run by
name now, since the runs directory holds calibration/ as well.
- RED on an archive of e231b78 with the final test files: the two unit files do not import
(s10_c10_red14.out); the scan, pruning and report files give 15 failed, 101 passed
(s10_c10_red13.out; the tree's tree_digest.py and digest_ledger.py were copied into that
archive, since the test file imports both, and cli.py, run.py and reports.py were HEAD's).
On the tree before each fix: the test of a ledger that is not a JSON object failed
(s10_c10_red8.out), and so did the content nested too deep and its scan test
(s10_c10_red12.out).
- GREEN on the final tree: 134 passed over the five files (s10_c10_green9.out); 873 passed
over the 60 files of the scan path (s10_c10_wide4_full.out; the list is
s10_c10_testfiles.txt); the docs and skills tests, with the strict site build, 11 passed
(s10_c10_docs_tests4.out; no page changed after it).
- Gates on the final tree: ten zeros (s10_c10e_exits.txt), the three gate outputs equal to
the baseline.
- Review: three rounds against e231b78, by one reviewer subagent, read-only; no
docker and no wrapper run, the probes read from their files. Round one blocked
on one finding and measured it end to end on a scratch tree: a ledger of a
digest whose top level is not a JSON object raised AttributeError in the tree's
loader and stopped the scan (exit 1), against the note's "a cache must not stop
a scan". Round two approved with remarks, which the code and the tests took:
RecursionError joined the tuple (digest_ledger.py:57), with a ninth content in
the unit test and a scan test of a ledger that is not a ledger, red before the
fix (s10_c10_red12.out). Round three approved the code, the tests and the dated
note, and blocked on one sentence of this message, which named
s10_c10_image_probe_run3 as kept: that directory is empty. On the final tree the
reviewer measured the scan past a digest's ledger nested 5000 deep (exit 0,
"unreadable", the file removed) and passed 30000 contents through
read_digest_ledger, with none let through; it re-ran the five files (134
passed), the docs and skills files with two scan files outside the sixty (20
passed), ruff, mypy (297 files) and the comparison of the three gate outputs
with the baseline, the gates themselves not run; it recomputed the three
digests, matched the tree's 297 .py files to the fourth probe image's list, and
read the fourth image and native runs. The third image run's files were read in
round two, before they were lost. The sentence was reworded as the reviewer
wrote it.
By reading, not measured
- A pre-push run does not go through _run_scan, and src/openultrasast/push names no ledger:
nothing changes there.
- ousast benchmark and the MCP server call _run_scan and get the rule as a scan does.
- mark_all of the hunt tooling lists the children of a runs root it is given; it has no
caller under src.
Found and not fixed, for the maintainer
- The note says the digest stage's seconds are in the manifest. No stage's are: a stage's
time is in trace/events.jsonl (stage_start and stage_end), and so is this one's. The pages
and the dated note do not repeat the sentence.
- The report's sentence (reports.py:461-467) says this scan's learnings are kept in the
ledger of the digest whenever that file holds some of them (cli.py:1131-1133). A new
learning whose finding id the tree's ledger already holds is left out by the rule; the
tree's version stands, and the new evidence text is in the run directory alone. The
sentence is the note's as approved.
- The tree's own ledger stops the scan when its top level is not a JSON object, or when it
is nested too deep (calibration.py:157-159, read at cli.py:610 outside any stage). That
is older than this commit; the ledger of a digest does not.
- read_digest_ledger raises when calibration/ cannot be searched, as the tree's ledger does
when .openultrasast/calibration cannot (digest_ledger.py:53).
- By reading: a tree whose runs directory is the target itself gets another digest at every
scan, since its run directory is made inside the target before the stage. Such a tree can
be written, so its own ledger takes the learnings and no ledger of a digest is made.
- docs/architecture.md draws no provenance stage, which cli.py runs between
entry_point_mapping and rank.
- The wrapper builds its image only when the image is missing: until a rebuild, a scan
through it runs the shipped code, which has none of this.
- The notice of a removed ledger names the runs directory as the scan sees it (/reports in
the image), not the host's path.
Not checked
- the whole test suite; Windows; ops/shell/ousast.ps1 (not read for this commit); two scans
of one tree at once; the wrapper and the compose route (the probe used docker run with the
wrapper's mount and override); a removal that fails on a real cache; Docker Desktop, where
a directory mounted twice may not keep one inode.
489 lines
26 KiB
Markdown
489 lines
26 KiB
Markdown
# OpenUltraSAST
|
||
|
||
[](https://doi.org/10.5281/zenodo.24012764)
|
||
|
||
OpenUltraSAST is an experimental static security analyser. It aims to check security on
|
||
repositories it has never seen. It scans a checkout or the commits a `git push` would publish. It
|
||
distinguishes what it can prove from what it suspects.
|
||
|
||
A scan combines up to four parts:
|
||
|
||
- language-scoped pattern rules;
|
||
- a tree-sitter overlay (a syntax tree of each file, built by the tree-sitter parser);
|
||
- a Joern code property graph (a graph of the program's syntax, control flow and data flow);
|
||
- optionally, a model. It is asked only the question the graph cannot settle.
|
||
|
||
Every finding includes its supporting evidence. When a scan cannot check something, it records
|
||
a degradation instead of reporting a clean result.
|
||
|
||
Where a repository's application can be built and run, an experimental proof arm goes further. It
|
||
demonstrates a finding by executing it. The issue triggers on the vulnerable revision and not on
|
||
the fixed one, which makes the finding reproducible. This arm is in pilot testing and is being
|
||
qualified on repositories the tool has never seen; see [Status](#status).
|
||
|
||
`ousast` is the interface. Model work over whole repositories runs on a separate agentic plane
|
||
(google/ax). A learned decision engine is in development. A scan needs neither of them.
|
||
|
||
Each section in this file links to the corresponding page on the documentation site.
|
||
The site is published at <https://norandom.github.io/OpenUltraSAST/>. Its sources are in `docs/` and
|
||
`mkdocs.yml`; to preview it locally, run `uv sync --extra docs && uv run mkdocs serve`.
|
||
|
||
## Status
|
||
|
||
**v2.1.0-alpha.1 checkpoint, state as of 2026-11-06.** The pre-push safety net is **not yet released**. Blocking on
|
||
the static analyser by hand is **NO-GO** against every M4 gate, and the project no longer tries to
|
||
meet those gates that way.
|
||
|
||
- No blocking hook capability is enabled; the pre-push hook is advisory only.
|
||
- Two independent populations (case sets frozen before any scan) have been spent on the static
|
||
engine: recall was 1 of 11, then 0 of 17. The learned decision engine ranks findings but does not block for any
|
||
family.
|
||
- Static abstract interpretation could not prove the precision needed to block a push. Current
|
||
work focuses on a **dynamic proof arm**. It builds and runs a repository's app and
|
||
demonstrates a finding by a differential: the issue triggers on the vulnerable revision and not
|
||
on the fixed one. Execution establishes the finding as ground truth, so it can justify a block
|
||
without calibration. Pilot demonstrations exist, including one executed on the cluster; the arm
|
||
is being qualified, not shipped.
|
||
- The release gate is a **measured** catch-rate and false-alarm number on repositories the tool
|
||
has never seen (the unseen-repo evaluation). Until that number
|
||
exists, treat all output as advisory.
|
||
|
||
Every detection change must show an improvement in a controlled measurement on held-out repositories.
|
||
The current status and the record behind each figure are in
|
||
[docs/where-we-stand.md](docs/where-we-stand.md). For developers, the pre-push check and its
|
||
honest limits: [docs/pre-push-for-developers.md](docs/pre-push-for-developers.md); the
|
||
catch–prove–fix–re-verify loop: [docs/use-case-fix-and-reverify.md](docs/use-case-fix-and-reverify.md).
|
||
The release history is in [RELEASE_NOTES.md](RELEASE_NOTES.md).
|
||
|
||
## Install and first scan
|
||
|
||
Pick the tier you need:
|
||
|
||
1. Tier 1: a deterministic scan of a checkout, or a CI gate.
|
||
2. Tier 2: the Joern engine (`standard`, `deep`).
|
||
3. Tier 3, for maintainers: model work over whole repositories on the plane.
|
||
4. Tier 4 does not exist yet.
|
||
|
||
### Tier 1: quick scan, no Docker
|
||
|
||
The core install depends only on PyYAML. From a checkout, `uv sync` (or `pip install .`) installs
|
||
the `ousast` entry point. `uv sync --group dev` adds the test and lint tools.
|
||
|
||
```bash
|
||
uv sync
|
||
uv run ousast scan /path/to/repo --mode quick
|
||
uv run ousast scan . --mode quick --fail-on verified # CI: exit 1 on any evidence-verified finding
|
||
```
|
||
|
||
This runs the language-scoped pattern rules, entry-point reachability hints, ranking,
|
||
verification and scoring. It is deterministic and reproducible. It needs no network and no keys.
|
||
|
||
The same install gives you the advisory pre-push hook for any repository. It runs the quick rules
|
||
on the lines a push changes, names every check it could not run, and never blocks a push:
|
||
|
||
```bash
|
||
cd /path/to/your/repository && ousast pre-push install # remove: ousast pre-push uninstall
|
||
```
|
||
|
||
What it cannot do:
|
||
|
||
- There is no engine. It cannot follow a value across statements or files.
|
||
- The PHP quick rules are a low-precision, in-sample development set. Per-rule precision lower
|
||
bounds run from 0.03 to 1.0 on the real pins
|
||
(`benchmarks/measurements/2026-09-30-php-quick-rules/measurement.json`).
|
||
|
||
The optional `semantic` extra (`uv sync --extra semantic`) installs the tree-sitter grammars for
|
||
the overlay.
|
||
|
||
### Tier 2: standard and deep scans (Docker)
|
||
|
||
`standard` and `deep` need Joern. The Docker image includes the tool and
|
||
Joern v4.0.625. It also includes `php-cli`, which the PHP frontend needs. Each release publishes the image
|
||
to GHCR. It is big: a JRE plus about 2 GB of Joern. Pull it instead of building, and tag it with the name the
|
||
shell wrapper uses:
|
||
|
||
```bash
|
||
docker pull ghcr.io/norandom/openultrasast:2.0.1
|
||
docker tag ghcr.io/norandom/openultrasast:2.0.1 openultrasast:dev # or build: docker compose build
|
||
```
|
||
|
||
The shell wrapper runs `ousast` in the container. It builds the image only if `openultrasast:dev`
|
||
is missing. Your directory is mounted read-only and the container network is off. For the pre-push
|
||
hook, use `ousast pre-push install --docker`: Git cannot call a shell function, so it installs the
|
||
script `ousast-docker` beside the hook.
|
||
|
||
```bash
|
||
source /path/to/OpenUltraSAST/ops/shell/ousast.sh # PowerShell: ops/shell/ousast.ps1
|
||
ousast scan . --mode standard # the graph decides; no model is asked
|
||
ousast-with-judge scan . --mode standard # network on, the model is asked (DEEPSEEK_API_KEY)
|
||
```
|
||
|
||
`docker compose build` and `TARGET=/path/to/repo docker compose run --rm ousast scan /target` do
|
||
the same without the wrapper. Create `reports/` first (`mkdir -p reports`): compose does not create it,
|
||
because a directory Docker creates is root-owned and the image runs as an ordinary user. Findings land there.
|
||
|
||
`deep` requests the REGRESS stage, which was retired on 2026-10-13: the scan records a `regress_retired` degradation and otherwise equals `standard`. Execution proof now comes from the search-with-proof arm.
|
||
|
||
Details, including the host install, are in [ops/README.md](ops/README.md).
|
||
|
||
Keys and store settings live in `.env` in the working directory. The file is gitignored;
|
||
`.env.example` lists the names.
|
||
|
||
- Every LLM call uses `DEEPSEEK_API_KEY`.
|
||
- `OPENROUTER_API_KEY` is used for embeddings only (`ousast learn memory embed`).
|
||
- `.env` never overrides a variable already exported in your shell. If a key change seems to have
|
||
no effect, `unset` the stale export.
|
||
- The plane's memory store defaults to a local file store under `~/ousast-results/plane/memory`.
|
||
- An S3-compatible bucket is optional: `uv sync --extra s3`, then `OUSAST_MEMORY=s3://<bucket>`
|
||
with `S3_ENDPOINT` and the AWS credentials in `.env`. Nothing in a scan needs it.
|
||
|
||
### Tier 3: the plane on ax (maintainers)
|
||
|
||
Tier 1 and 2 need none of this. The local profile is a single-node kind cluster on the maintainer's
|
||
host. That cluster is stopped since 2026-11-24: the code stays, `ops/ax/up.sh` recreates the
|
||
cluster, and whether the executor code is deleted is decided at the plane re-plan.
|
||
|
||
- `ops/ax/up.sh` needs `docker`, `go`, `kubectl`, `kind`, `ko` and `ax` on the PATH. It refuses to
|
||
start when one is missing.
|
||
- It builds Agent Substrate and ax from their checkouts under `~/.cache/ousast/ax-src/`.
|
||
- Measured idle footprint with two workers: the kind node takes 1.7 GiB of memory (27% of the
|
||
7.7 GiB host) and 4.9 GB of disk for images. The build uses several GB more for Go caches.
|
||
- The worker pool is sized for that 7 GB host.
|
||
- The verify and roles tasks need `DEEPSEEK_API_KEY`.
|
||
- Memory lives in the local file store or the S3 store. RustFS is the tested server.
|
||
|
||
See [ops/ax/README.md](ops/ax/README.md) for bring-up and doctor instructions, along with the smoke Run.
|
||
|
||
### Tier 4: Kubernetes (k3s), planned
|
||
|
||
Nothing has been deployed to any cluster other than that kind cluster, stopped on 2026-11-24. The
|
||
target is two profiles of one code base: `kind` locally and `k3s` in production. The same `ousast
|
||
plane run` would submit a Run in a remote execution mode. It needs:
|
||
|
||
- a kubeconfig context or the cluster's ingress (and an `imagePullSecret` on the worker
|
||
ServiceAccount for a private package);
|
||
- runner and engine images published to GHCR and pinned by digest;
|
||
- the S3 store as the artifact path, with no receiver on a laptop.
|
||
|
||
The plan and required code changes, with file paths, are in
|
||
[docs/deployment.md](docs/deployment.md#production-topology-ax-on-a-kubernetes-cluster).
|
||
|
||
## Scan modes
|
||
|
||
There are three modes. Each adds to the one before.
|
||
|
||
- `quick` runs the pattern rules, hints, ranking, verification and score. It needs nothing.
|
||
- `standard` adds the MAP stage: complexity map, semantic overlay, authorization obligations and
|
||
the Joern model layer. The model layer builds one code property graph per repository. It decides
|
||
taint, guard-dominance and configuration questions on that graph. A model is asked only the
|
||
residual question. Without a key, that question is skipped and only the graph's entailed
|
||
findings are reported.
|
||
- `deep` requests the REGRESS stage, which was retired on 2026-10-13: the scan records a `regress_retired` degradation and otherwise equals `standard`. Execution proof now comes from the search-with-proof arm.
|
||
|
||
A missing engine is a recorded degradation (`cpg_unavailable`, `regress_retired`), never a
|
||
clean result.
|
||
|
||
`--fail-on never|findings|verified|worth-fixing` sets the exit code. `--config openultrasast.toml`
|
||
loads settings. Every run writes `manifest.json`, `findings.json`, `verification.json`,
|
||
`score.json`, `report.md`, `report.sarif` and `trace/events.jsonl` under
|
||
`~/.cache/openultrasast/runs/<scan-id>/`, or under `$XDG_CACHE_HOME/openultrasast/runs/` when that
|
||
variable is set to an absolute path. The scan prints that path (`run_dir=<path>`).
|
||
`OPENULTRASAST_RUNS_DIR` moves the run directory: an absolute path is used as given, and a relative
|
||
one is resolved against the current working directory, never against the directory being scanned.
|
||
After a scan writes its run to the default location, with no `OPENULTRASAST_RUNS_DIR` set, the runs
|
||
there older than 30 days are removed, and `ousast` prints one `notice:` line when it removes any;
|
||
`OPENULTRASAST_RUNS_RETENTION_DAYS` sets the number of days (`0` keeps every run), and nothing is
|
||
ever removed from a location chosen with `OPENULTRASAST_RUNS_DIR`, except through the shell wrapper:
|
||
it mounts `~/.cache/openultrasast/runs` at `/reports` in the image, and a scan through it removes the
|
||
expired runs there as well; the ledgers of tree digests (`calibration/` under the same directories)
|
||
go by the same number of days, dated by their last use. A scan does not read the files
|
||
under its runs directory when that directory lies inside the scanned path; when this leaves source
|
||
files out of the scan, `ousast` prints one `notice:` line naming the directory and how many.
|
||
|
||
`ousast benchmark` writes its run to the same runs directory, as
|
||
`<runs_dir>/<benchmark-run-id>/` beside the scan runs, and prints that path
|
||
(`benchmark_run_dir=<path>`); run retention removes it like a scan run. The MCP tool
|
||
`openultrasast.benchmark` uses the same directory.
|
||
|
||
A scan that rejects or holds a finding writes one file into the scanned tree,
|
||
`<target>/.openultrasast/calibration/false_positive_learnings.json`, and only when that file's
|
||
content would change. On a read-only tree the scan records `ledger_not_written` instead and keeps
|
||
the learnings in the ledger of the tree's digest, `<runs_dir>/calibration/<digest>.json`, where the
|
||
digest is a sha256 of every file's name and bytes under the target. Only a scan of the very same
|
||
bytes reads it; the first scan that can write the tree carries its entries into the tree's ledger
|
||
and removes it. The `ledger` block of `manifest.json` names the digest, how many learnings came
|
||
from each ledger, and what became of the digest's ledger. A digest's ledger is removed like a run
|
||
once its last use is `OPENULTRASAST_RUNS_RETENTION_DAYS` days past.
|
||
|
||
`ousast pre-push` (experimental) analyses the commits a push would publish against their base.
|
||
First, the quick rules run on the changed lines. Then the engine compares head with base, and only
|
||
new or worsened defects become candidates. It is advisory by default, and it prints one line per
|
||
check it could not run. Its capability registry is empty, so it emits no normal alert today. An
|
||
engine finding the push introduced is shown as advisory. Install, settings, skip reasons and a CI
|
||
recipe: [docs/scanning.md](docs/scanning.md#first-run-install-the-hook-on-any-repository).
|
||
|
||
Flows and the per-language rule table: [docs/scanning.md](docs/scanning.md).
|
||
|
||
## How detection works
|
||
|
||
The tool uses three representations of code, from cheap to expensive:
|
||
|
||
1. Text: regex quick rules, one statement at a time.
|
||
2. Tree: the tree-sitter CST (concrete syntax tree) and an IR (intermediate representation) per
|
||
function. The overlay and the obligations use it.
|
||
3. Graph: the Joern CPG. It is the only one that follows a value across statements, calls and
|
||
files.
|
||
|
||
Taint analysis uses fact tables and queries on the graph to produce verdicts. Absence bugs involve
|
||
operations that should have been guarded. The tool finds them through obligations and dominance
|
||
checks, plus a configuration census. A model answers only the residual question.
|
||
|
||
- [docs/detection-techniques.md](docs/detection-techniques.md) explains each technique, with the
|
||
code it comes from and what it misses.
|
||
- [docs/architecture.md](docs/architecture.md) gives the stage order and the evidence ladder (a
|
||
state machine, not a label a model may assign). It also covers the central CWE policy, the
|
||
project score.
|
||
|
||
Quick rules cover C/C++, Python, JavaScript/TypeScript, Java with Groovy templates, and PHP. Each
|
||
rule runs only against files of its language.
|
||
|
||
The detection gate (`uv run python -m openultrasast.gate`) enforces at least 90% recall and under
|
||
10% false positives per language on the bundled cheat-sheet corpora. On this tree it reports
|
||
93.62% recall (44/47) and 0.0% false positives. Those corpora show that a rule change did not
|
||
break a known detection. They are not a recall estimate on real code, and PHP is not in the gate.
|
||
|
||
Framework knowledge (WordPress, Flask, Django, Express, Spring) is tagged as an optional prior in
|
||
`src/openultrasast/ruleset/frameworks.toml`. Its contribution can be measured and switched off.
|
||
|
||
## The plane on ax
|
||
|
||
Model-driven work over whole repositories runs as a Run manifest. A Run is a DAG of ax Tasks. Each
|
||
Task runs in its own gVisor actor (an isolated sandbox) on Agent Substrate. ax is the only agentic
|
||
executor; there is no local subprocess path.
|
||
|
||
- Each Task binds at most one Model and its own `usd`/`calls` budget.
|
||
- Egress is deny-by-default per Task, by hostname only.
|
||
- The provider key travels only in the Task's start request, never in a manifest or an image.
|
||
|
||
Measured on the first increment: the plane agreed on 16 of 20 declared sites at $0.0205 per
|
||
candidate.
|
||
|
||
```bash
|
||
uv run ousast plane doctor # kind, Agent Substrate, ax controller, runner image
|
||
uv run ousast plane run plane/runs/validation-46.yaml # a rerun skips tasks already done; --workers bounds tasks in flight
|
||
uv run ousast plane status validation-46 # per-task status and the token attribution table
|
||
uv run ousast plane remember validation-46 # ingest the run's rows into the memory store
|
||
```
|
||
|
||
`workspaces`, `harvest`, `alerts-engine` and `memory-normalise` generate Runs, their inputs and
|
||
the store's rewrites. The flow and the task catalogue: [docs/plane.md](docs/plane.md). How the plane
|
||
was deployed on the maintainer's host, and what moving it to a separate cluster would take:
|
||
[docs/deployment.md](docs/deployment.md).
|
||
|
||
HarnessX, the earlier agentic extra, was retired 2026-09-30. A `[harnessx]` section is ignored
|
||
with one warning. `[models] verifier`, `[fusion] panel_model` and `[fusion] decider_model` fail and
|
||
name the plane replacement. Config keys that nothing ever read fail the same way. Fusion is
|
||
deterministic.
|
||
|
||
## Memory
|
||
|
||
One store holds what plane runs and the decision engine learned. It is keyed by repository and pin.
|
||
It holds two kinds of data:
|
||
|
||
- rows: facts, verdicts, unit costs, alerts, coverage and feature records;
|
||
- content-addressed blobs: excerpts, embeddings, cached responses and compiled programs.
|
||
|
||
`OUSAST_MEMORY` selects the backend. It is either a local file store or `s3://<bucket>` on any
|
||
S3-compatible server. The S3 server must support versioning, lifecycle rules, object tags and S3
|
||
Select. RustFS is the tested server.
|
||
|
||
An admin sets the bucket up once. The store verifies it at every start. If anything is missing, it
|
||
refuses to run and names each missing piece. It does not fall back.
|
||
|
||
- Layout and the read and write paths: [docs/memory.md](docs/memory.md).
|
||
- The bucket policy and admin steps: [docs/rustfs.md](docs/rustfs.md).
|
||
- How stored rows are meant to turn into better decisions:
|
||
[docs/memory-and-detection.md](docs/memory-and-detection.md).
|
||
|
||
## Decision engine and evaluation
|
||
|
||
A learned decision engine is being built to replace hand-tuned detection edits. Its rules are:
|
||
|
||
- Every instrument produces signals, never verdicts.
|
||
- Labels come from ground truth only.
|
||
- A compiled AI classifier with local memory turns retrieved similar cases and the candidate's
|
||
signals into a calibrated probability. It has BLOCK and ADVISORY operating points.
|
||
|
||
It is **in development, not adopted**. No scan, pre-push check or report uses it.
|
||
|
||
It was measured on six families, on repositories the compiled program was not shown:
|
||
|
||
- The pooled AUC (area under the ROC curve) of its score runs from 0.77 (injection) to 0.96
|
||
(access control).
|
||
- The stricter within-pair AUC is 0.72 to 0.93 across the same families.
|
||
- BLOCK is offered for no family
|
||
(`benchmarks/measurements/2026-10-02-decision-engine-slice-2/record.json`).
|
||
|
||
Maintainer surface: `ousast learn labels|memory|compile|evaluate|curve|experiment|audit-leaks`.
|
||
The design and evaluation slices are in [docs/decision-engine.md](docs/decision-engine.md), along with the A/B protocol.
|
||
|
||
[docs/evaluation.md](docs/evaluation.md) explains how anything is measured on code the tool was not
|
||
tuned on. It covers the pair corpora, the independent populations and the M4 gates. It also covers
|
||
the fold discipline that keeps learned decisions out of their own training data. Population v3
|
||
(PHP, 15 cases) is frozen as the one-time final check. Nothing in the tree may read it. Population v4
|
||
(11 cases) was frozen on 2026-11-23 and is unscanned; `protocol-v4.md` is committed and no result
|
||
exists.
|
||
|
||
```bash
|
||
uv run ousast benchmark benchmarks/manifests/python-vulnerable.toml --mode quick
|
||
uv run ousast pairs --slice sast # fire on the vulnerable side, stay silent on the fix
|
||
uv run python -m openultrasast.pair_gate # CI: local pairs must all pass
|
||
```
|
||
|
||
## Token economics
|
||
|
||
Model tokens are the one running cost. At runtime the plane routes them:
|
||
|
||
- one Model and one budget per Task;
|
||
- a metered client that refuses the next call at the ceiling;
|
||
- repository facts computed without a model and reused;
|
||
- blobs replayed at $0, with no new model call;
|
||
- triage before the hunt;
|
||
- a tie-break only on disputed candidates.
|
||
|
||
In development, 85.5% of the maintainers' coding-session tokens were tool input and output rather
|
||
than reasoning. That is down from 90%. The remedies in `benchmarks/dev/` target that share.
|
||
Mechanisms, the measured costs and the before-and-after table:
|
||
[docs/token-ergonomics.md](docs/token-ergonomics.md).
|
||
|
||
## Examples, threat model
|
||
|
||
- End-to-end walkthroughs, from a quick scan to an MCP client: [docs/examples.md](docs/examples.md).
|
||
- What the tool trusts and what it does not: [docs/threat-model.md](docs/threat-model.md). This
|
||
covers scanned code as untrusted input, secret redaction, per-task egress, budgets and the
|
||
`deep` sandbox.
|
||
|
||
## Contributing and maintainer tooling
|
||
|
||
```bash
|
||
uv run pytest # tests, incl. the 90/10 detection gate
|
||
uv run ruff check . # lint
|
||
uv run ruff format --check . # format
|
||
uv run mypy src/openultrasast # types
|
||
uv run python -m openultrasast.gate # standalone detection gate
|
||
uv run python -m openultrasast.pair_gate # local vuln-vs-fix pairs
|
||
uv run python dagger/ci.py # containerized CI pipeline
|
||
```
|
||
|
||
An agent that can run shell commands needs nothing but the CLI. For [OpenCode](https://opencode.ai)
|
||
there are two project skills in `.agents/skills/`:
|
||
|
||
- `openultrasast-scan`: modes and their prerequisites, `--fail-on`, the evidence ladder, recorded
|
||
degradations and run artifacts.
|
||
- `openultrasast-triage`: false-positive reasons, what an adjudication may feed, and fixing and
|
||
re-scanning.
|
||
|
||
`ousast mcp` runs a narrow MCP (Model Context Protocol) server over stdio. It has ten tools:
|
||
`openultrasast.scan`, `status`, `findings`, `get_finding`, `evidence`, `artifacts`, `benchmark`,
|
||
`explain`, `propose_patch` and `export_report`. No tool runs a shell, Docker or a free-form
|
||
command.
|
||
|
||
```jsonc
|
||
{ "command": "uv", "args": ["run", "ousast", "mcp"] }
|
||
```
|
||
|
||
The `kiro-*` skills, `AGENTS.md` and the Kiro-style specifications under `.kiro/` are the
|
||
maintainer's development tooling. Users can ignore them. Other maintainer commands:
|
||
|
||
- `ousast repos`: pinned known-vulnerable checkouts.
|
||
- `ousast model candidates`: what the candidate enumerator can reach.
|
||
|
||
## Licence
|
||
|
||
OpenUltraSAST is licensed under the [Apache License 2.0](LICENSE). Third-party material keeps its
|
||
own terms:
|
||
|
||
- Joern (Apache-2.0) is downloaded at image build time.
|
||
- The tree-sitter wheels of the `semantic` extra are MIT.
|
||
- The published benchmark cases were licence-checked one by one. v1's OpenCVE case is BUSL-1.1, see [RELEASE_NOTES.md](RELEASE_NOTES.md).
|
||
|
||
## Engine traces on kube-ax
|
||
|
||
`benchmarks/learn/engine_trace.py --executor ax` submits AX v0.3.1 Tasks with
|
||
`ax apply -f -` and removes them with `ax delete task NAME`. The operator supplies
|
||
kubeconfig and AX access; the dispatcher creates no Kubernetes resources or secrets.
|
||
The `ousast-engine-task` GHCR package **must be made Public once** in its package
|
||
settings so the actors can pull it without registry credentials.
|
||
|
||
The task image contains the current engine and worker code. Rebuild it after code
|
||
changes and pass its digest with `--image`; no analyzer download is needed. The host
|
||
prepares each pin as usual and uploads source and prepared questions under
|
||
`engine-queue/<run>/<pin>/`. Only object-scoped presigned URLs and deadline parameters
|
||
enter Task env. Credentials stay on the coordinator. Configure `OUSAST_MEMORY=s3://…`
|
||
and the store credentials in the coordinator's `.env` or environment, with
|
||
`S3_ENDPOINT=https://files.because-security.com`. Presigned links expire after the
|
||
pin deadline plus ten minutes. IP and HTTP endpoints are rejected: the operator's
|
||
actor EgressPolicy must allow files.because-security.com:443.
|
||
|
||
The result object marks completion, even while AX reports Running. Failed phases and
|
||
host deadlines produce explicit failure/timeout rows. Task and staging-object cleanup
|
||
runs on success and failure; cleanup failure stops further dispatch. Per-pin files,
|
||
`--rerun-status`, resume and `progress.json` retain the existing trace-runner behavior.
|
||
AX results include `executor: "ax"`, `worker_ip`, and the image digest. Placement is
|
||
random; `--parallel` defaults to two AX tasks and cannot exceed two.
|
||
|
||
AX workers use `--heap-profile cluster` with
|
||
`-Xms1700m -Xmx1700m -XX:MaxMetaspaceSize=256m -XX:ReservedCodeCacheSize=128m -XX:MaxDirectMemorySize=256m -Xss512k -XX:ActiveProcessorCount=1 -XX:+UseG1GC`
|
||
on every frontend/query JVM; instruments record the flags. A `JVM out of memory`
|
||
result is automatically re-queued to one local Docker lane with `--heap-profile vm`
|
||
(2560m), recording `fallback: "vm-oom"` and the AX attempt. `mixed-ax` also uses this
|
||
one Docker lane for overflow, prioritizing pending OOM fallbacks. Thus a mixed run has
|
||
up to two AX tasks plus one Docker container. Use `--docker-image` for the locally
|
||
available VM image; Docker never pulls it implicitly. A STOP file prevents new
|
||
launches; interrupted fallback queues are recovered on resume.
|
||
|
||
Coordinator commands, from this worktree (the AX binary and kubeconfig remain
|
||
configurable). Build the image of the Docker lane, then set `TASK_IMAGE` to the
|
||
`ousast-engine-task` reference the Engine image workflow printed:
|
||
|
||
```bash
|
||
cd /home/mc/Source/OpenUltraSAST/.claude/worktrees/engine-ax
|
||
export PATH=/home/mc/Source/OpenUltraSAST/.venv/bin:$PATH
|
||
export PYTHONPATH="$PWD/src"
|
||
OUSAST_VERSION=engine-ax docker compose build
|
||
# The ousast-engine-task reference the Engine image workflow printed, in its log and its summary:
|
||
export TASK_IMAGE="ghcr.io/norandom/ousast-engine-task@sha256:<digest>"
|
||
```
|
||
|
||
`docker compose build` takes the base from the defaults in `docker-compose.yml`,
|
||
which a test keeps equal to `plane/task-base.digest`; `OUSAST_VERSION` sets the tag
|
||
of the image, here `openultrasast:engine-ax`. The Engine image workflow also
|
||
builds/pushes both images and prints each digest; CI needs the changes published
|
||
before dispatch. When the workflow runs is the rebuild policy in
|
||
[ops/ax/README.md](ops/ax/README.md). The Docker lane runs the local image,
|
||
committed or not; the AX lanes run the task image of the revision the workflow built.
|
||
|
||
With `KUBECONFIG` pointing to the operator's kube-ax config and store settings in
|
||
`.env`, run a one-pin smoke using the default experiment units and local example
|
||
memory (or add `--examples /path/to/frozen-examples.jsonl`). Use the `ax` binary at
|
||
`$HOME/go/bin/ax`. `$HOME/.local/ax-v0.3.1/ax` hits the AX-lane dispatch blocker:
|
||
|
||
```bash
|
||
: "${KUBECONFIG:?Set KUBECONFIG to the operator kube-ax configuration}"
|
||
python benchmarks/learn/engine_trace.py --executor ax \
|
||
--ax-bin "$HOME/go/bin/ax" --kubeconfig "$KUBECONFIG" \
|
||
--atespace default --image "$TASK_IMAGE" --docker-image openultrasast:engine-ax \
|
||
--parallel 1 --limit 1 --deadline 900 \
|
||
--out "$HOME/ousast-results/plane/engine-ax-smoke"
|
||
```
|
||
|
||
Then run the mixed lanes (repeat to resume; defaults re-run failed/timeout pins):
|
||
|
||
```bash
|
||
python benchmarks/learn/engine_trace.py --executor mixed-ax \
|
||
--ax-bin "$HOME/go/bin/ax" --kubeconfig "$KUBECONFIG" \
|
||
--atespace default --image "$TASK_IMAGE" --docker-image openultrasast:engine-ax \
|
||
--parallel 2 --deadline 900 --rerun-status failed,timeout \
|
||
--out "$HOME/ousast-results/plane/engine-ax-mixed"
|
||
```
|