- Shell 86.5%
- Python 13.5%
| __pycache__ | ||
| tests | ||
| paru-codex-review | ||
| paru-screening | ||
| README.md | ||
paru-codex-review
A fail-closed static Codex review of AUR recipes for Paru's PreBuildCommand. It never intentionally executes or sources a recipe. A low-risk verdict allows Paru to continue; a model block or controlled review error stops it.
Installation
Install Bash, Codex CLI, jq, Git, GNU coreutils, file, and flock (util-linux). Authenticate Codex as your normal user. This hook copies a regular ~/.codex/auth.json into a private temporary Codex home, or forwards OPENAI_API_KEY.
Install as your normal user, without sudo:
git clone https://git.tsbprodesk.co.uk/localuser/paru-codex-review.git
cd paru-codex-review
./paru-codex-review --install
Following the pid distribution pattern, this clones a managed checkout into ~/.local/share/paru-codex-review/source and creates:
~/.local/bin/paru-codex-review -> ~/.local/share/paru-codex-review/source/paru-codex-review
It also creates or updates [bin] / PreBuildCommand in ~/.config/paru/paru.conf, using a shell-quoted absolute launcher path. Existing settings are preserved, and a changed existing config is backed up as paru.conf.backup.<random>. A different existing hook is not overwritten or chained: edit/remove that entry first, including an old manual /usr/local/bin/paru-codex-review setting. A symlinked config is refused; use PARU_CODEX_PARU_CONF to explicitly name its actual target if desired. An unrelated existing launcher is also refused.
Put ~/.local/bin on PATH for maintenance commands; the configured hook does not depend on PATH. Running --install again performs a clean reinstall, replacing local changes in the managed checkout. Keep development work in your original clone, not the managed source.
The installer does not install dependencies, log you into Codex, or change system-wide Paru settings. The default executable paths are /usr/bin/codex, /usr/bin/jq and /usr/bin/timeout. Override them with PARU_CODEX_BIN, PARU_CODEX_JQ_BIN and PARU_CODEX_TIMEOUT_BIN if needed. Use PARU_CODEX_MODEL to select an available model; the current default is gpt-6.1-sol. Your installed Codex must support the flags used by the script. The isolated configuration deliberately does not inherit custom provider settings, plugins, or local Codex instructions.
Automatic updates
Before each non-bypassed hook invocation, a managed installation fetches its recorded branch/tag from origin and compares full Git commit hashes (HEAD versus FETCH_HEAD). Identical hashes do not change the checkout. A different commit is accepted only if it is a fast-forward and contains a regular executable hook that passes Bash syntax validation. Git hooks and filesystem-monitor hooks are disabled for distribution operations. A successful check reloads the installed script once, preserving the recipe working directory, so a concurrent updater cannot leave that invocation running stale code.
Tracked or non-ignored untracked local changes prevent updates; divergent history is never reset automatically. Fetches are bounded by a 20-second timeout with a 5-second termination grace period. If an automatic check fails, the installed version still performs the security review and explains the fallback. It does not allow the package merely because Git is offline. There is no background timer or daemon; updates happen when the hook runs.
paru-codex-review --update # Explicit update; failures return non-zero.
PARU_CODEX_SKIP_SELF_UPDATE=1 paru -Syu # Skip Git checks, not package reviews.
paru-codex-review --skip-update # Review cwd without a Git check.
Codex can still require network access when Git checks are skipped. A plain development clone or manually copied script does not auto-update; only --install creates the managed marker. Review bypasses skip the automatic Git check too. Commit hashes identify revisions, not publisher authenticity: automatic updates trust the configured repository and its branch, and syntax validation is not a security audit.
Installation settings
These variables are used by --install; the clone URL becomes origin, and the ref is recorded for later updates.
| Variable | Default |
|---|---|
PARU_CODEX_REPO_URL |
https://git.tsbprodesk.co.uk/localuser/paru-codex-review.git |
PARU_CODEX_REPO_REF |
main (branch or tag) |
PARU_CODEX_INSTALL_ROOT |
${XDG_DATA_HOME:-$HOME/.local/share}/paru-codex-review |
PARU_CODEX_PARU_CONF |
${XDG_CONFIG_HOME:-$HOME/.config}/paru/paru.conf |
Paths must be absolute and contain no newlines. The launcher remains in ~/.local/bin. Installation Git operations have a 60-second timeout plus a 5-second termination grace period.
Review source: Paru Screening
The review can run through Codex (default), Pi Coding Agent (pi) or Claude Code (claude -p). --install also links ~/.local/bin/paru-screening and registers a "Paru Screening" launcher entry (~/.local/share/applications/paru-screening.desktop; an existing entry not created by the installer is left alone). Paru Screening is a small Qt window that picks the source, model and effort and saves them to ${XDG_CONFIG_HOME:-$HOME/.config}/paru-codex-review/config.json:
{"source": "pi", "model": "mistral/deepseek-v4-1-flash-1017", "effort": "high"}
It needs Python 3 with PyQt6 or PySide6 (Arch: python-pyqt6 or pyside6; Fedora: python3-pyqt6 or python3-pyside6). Models are loaded automatically from codex debug models and pi --list-models --offline --no-extensions. Claude Code has no listing command, so enter an alias (opus, sonnet, haiku) or a full model ID. You can always type a model name.
| Source | Model | Effort values | Credentials copied into the isolated home |
|---|---|---|---|
codex |
default gpt-6.1-sol |
none minimal low medium high xhigh max ultra (per model) |
~/.codex/auth.json or OPENAI_API_KEY |
pi |
provider/model, required |
off minimal low medium high xhigh max |
$PI_CODING_AGENT_DIR/auth.json (default ~/.pi/agent), plus models.json and models-store.json (model catalogue) if present |
claude |
default opus |
low medium high xhigh max |
~/.claude/.credentials.json, ANTHROPIC_API_KEY or CLAUDE_CODE_OAUTH_TOKEN |
The default effort is high. PARU_CODEX_SOURCE, PARU_CODEX_MODEL and PARU_CODEX_EFFORT override the file. If the environment selects a different source, the file's model and effort are ignored. PARU_PI_BIN and PARU_CLAUDE_BIN override CLI paths; otherwise they are found on PATH. PARU_CODEX_CONFIG overrides the config path. Invalid settings block the build.
Pi runs with --no-tools --no-extensions --no-skills --no-mcp --no-context-files --no-session --offline. It has no schema enforcement, so its output must be exactly one JSON object (a single Markdown fence is tolerated). Claude runs with --tools '' --disallowedTools 'mcp__*' --strict-mcp-config --no-session-persistence --json-schema. Pi has no built-in sandbox; isolation relies on disabling tools. Cache entries are keyed on source, model and effort.
Bypassing a review
Read the findings and inspect the recipe before bypassing. Both model blocks and controlled gate errors display guidance. The hook remains non-interactive so it cannot consume input intended for Paru or silently approve an unattended build.
To skip one exact package base, prefix your original Paru command with PARU_CODEX_SKIP_PKGBASE=some-base. For example:
PARU_CODEX_SKIP_PKGBASE=some-base paru -S some-package
# Or, when repeating an upgrade:
PARU_CODEX_SKIP_PKGBASE=some-base paru -Syu
Replace the examples with the base shown by the hook and your original Paru arguments. The hook cannot reconstruct those arguments. The package base is not necessarily an installable package name: one base can produce several split packages, and the bypass covers all of them. Matching is literal, with no globbing or prefix matching; other package bases still undergo review.
Using this command-prefix form scopes the setting to that invocation and its child processes. No approval is cached or persisted by the bypass. It is not a single-use or content-bound approval: every hook call with that matching base and environment will bypass review. Do not export the variable if you want an invocation-only exception.
The legacy PARU_CODEX_SKIP=1 remains supported, but disables review for all package bases in that invocation, including AUR dependencies. Its warning now states that scope explicitly. Neither bypass can make an otherwise broken Paru build work; it only disables this review gate.
Review policy and limits
The prompt asks the model to trace top-level Bash, helpers, patches, install lifecycle scripts, launchers and persistence mechanisms. It also calls out indirect execution through npm/pnpm/yarn lifecycle hooks, Python build backends, Cargo build scripts/procedural macros, Go helpers and Electron tooling. Normal ecosystem builds, VCS sources, install hooks and binary packaging are not automatically treated as malware.
Checksums establish agreement with a declared digest, not that the selected source is benign. Source and registry selection, lockfiles and verification settings are assessed in context. The model must not invent upstream contents, registry reputation, ownership history or changes relative to an unavailable trusted baseline.
Important limits:
- In a Git clone, tracked files are included even if they match
.gitignoreor end in.part. Ignored untracked files and regular untracked files ending in.partare excluded. This lets interrupted downloads resume without exceeding snapshot limits or triggering change checks. The suffix is a residue heuristic, not proof of file purpose: track any local recipe helpers named.partif they need review. Symlinks ending in.partand contents of directories named.partare not exempted. Non-Git recipes retain the inspect-everything policy. Downloaded sources and dependency trees are not fetched for analysis. - Binary contents are omitted; only metadata is supplied. Source URLs, lockfiles and valid hashes cannot prove that omitted code is safe.
- The script checks for changes during review, but cannot stop changes after it returns. Current upstream Paru performs interactive review after this hook, so edits there are not automatically re-reviewed.
- Cached allows are keyed by snapshot, model and policy version, not by future downloaded contents.
PARU_CODEX_FORCE_REVIEW=1requests a fresh model verdict. Policy version2026-04-12.5invalidates approvals from the previous policy. - An AI verdict is advisory evidence, not proof of safety or a replacement for build isolation and human review.
Research informing the policy
- Arch's 2018 acroread compromise notice: malicious recipe modifications included
curl | bash. - Arch's July 2025 malicious-browser-package notice: three AUR packages installed a GitHub-hosted script identified as a RAT.
- npm lifecycle documentation: dependency installation can invoke install/prepare scripts.
- PEP 517: Python build-backend hooks are executable code.
- Cargo build scripts and procedural macros: compilation can involve code execution.
- Arch PKGBUILD manual: recipe functions, source handling, install scripts and integrity checks.
These illustrate attack mechanisms and execution capabilities; using a documented build feature alone is not evidence of malware.
Tests
With Bash, jq, Git and the standard GNU/Linux utilities available, run:
for test in tests/test_*.sh; do bash "$test" || exit; done
bash -n paru-codex-review
shellcheck --severity=warning paru-codex-review tests/test_*.sh
python3 -m py_compile paru-screening
The tests use isolated temporary fixtures, local Git remotes and mocked Codex responses, not real credentials or network access. They verify installation/configuration, commit-based fast-forward updates, same-invocation reloads, update failure safety, empty-file handling, partial-download exclusions, size limits, scoped bypasses, prompt delivery, cache invalidation, structured-result validation and detection of changes during review. test_sources.sh covers source/config selection with mock pi/claude, and test_screening.sh covers the Paru Screening helpers plus an offscreen GUI smoke test (skipped without PyQt6/PySide6). They do not measure model detection accuracy or establish compatibility with your installed Codex/Paru versions.