mirror of
https://github.com/norandom/OpenUltraSAST.git
synced 2026-12-03 10:18:18 +00:00
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).
55 lines
2.4 KiB
PowerShell
55 lines
2.4 KiB
PowerShell
# OpenUltraSAST as a local command. Dot-source this from your PowerShell profile:
|
|
#
|
|
# . C:\path\to\OpenUltraSAST\ops\shell\ousast.ps1
|
|
#
|
|
# Then use it from any directory:
|
|
#
|
|
# ousast scan .
|
|
# ousast scan src\api
|
|
#
|
|
# Docker is an implementation detail. Your working directory is mounted READ-ONLY and findings are written
|
|
# to %USERPROFILE%\.cache\openultrasast\runs, the only writable mount.
|
|
|
|
$script:OusastHome = if ($env:OUSAST_HOME) { $env:OUSAST_HOME }
|
|
else { Split-Path -Parent (Split-Path -Parent $PSScriptRoot) }
|
|
|
|
function ousast {
|
|
$compose = Join-Path $script:OusastHome 'docker-compose.yml'
|
|
if (-not (Test-Path $compose)) {
|
|
Write-Error "ousast: cannot find $compose (set OUSAST_HOME to the checkout)"; return
|
|
}
|
|
if (-not (Get-Command docker -ErrorAction SilentlyContinue)) {
|
|
Write-Error "ousast: docker is not installed"; return
|
|
}
|
|
|
|
$version = if ($env:OUSAST_VERSION) { $env:OUSAST_VERSION } else { 'dev' }
|
|
docker image inspect "openultrasast:$version" *> $null
|
|
if ($LASTEXITCODE -ne 0) {
|
|
Write-Host "ousast: building the analysis image once (~2 GB of engine; later runs are instant)"
|
|
Push-Location $script:OusastHome; docker compose build; Pop-Location
|
|
}
|
|
|
|
# Rewrite paths under the current directory to their mounted equivalent; leave anything outside alone
|
|
# and say so, rather than silently rewriting it into a path the container cannot see.
|
|
$cwd = (Get-Location).Path
|
|
$mapped = foreach ($a in $args) {
|
|
if (Test-Path $a) {
|
|
$abs = (Resolve-Path $a).Path
|
|
if ($abs -eq $cwd) { '/target' }
|
|
elseif ($abs.StartsWith($cwd)) { '/target' + $abs.Substring($cwd.Length).Replace('\', '/') }
|
|
else { Write-Warning "ousast: $a is outside $cwd and is not mounted"; $a }
|
|
} else { $a }
|
|
}
|
|
|
|
$runs = Join-Path $env:USERPROFILE '.cache\openultrasast\runs'
|
|
New-Item -ItemType Directory -Force -Path $runs | Out-Null
|
|
$env:TARGET = $cwd
|
|
$env:OUSAST_REPORTS = $runs
|
|
if (-not $env:OUSAST_NETWORK) { $env:OUSAST_NETWORK = 'none' }
|
|
# /reports is the runs directory itself: the override puts the run beside a native one, to be pruned.
|
|
docker compose -f $compose run --rm -e OPENULTRASAST_RUNS_DIR=/reports ousast @mapped
|
|
}
|
|
|
|
# The LLM judge needs network and a key; opt in explicitly.
|
|
function ousast-with-judge { $env:OUSAST_NETWORK = 'bridge'; ousast @args }
|