Skip to content

fix(nix): run bats --jobs on rush instead of GNU parallel - #1711

Merged
c-vigo merged 4 commits into
devfrom
bugfix/1708-perl-free-bats-parallel
Sep 25, 2026
Merged

c-vigo merged 4 commits into
devfrom
bugfix/1708-perl-free-bats-parallel

Conversation

@c-vigo

@c-vigo c-vigo commented Sep 25, 2026

Copy link
Copy Markdown
Contributor

Description

The 2026-09-25 nightly vulnix scan went red on dev (#1708) with three unexcepted HIGH/CRITICAL findings in perl 5.42.0 (CVE-2026-4176 9.8, CVE-2026-13221 9.1, CVE-2026-57432 8.4) while main scanned green on the same nixpkgs pin. The runtime-closure diff main → dev is exactly + bats-with-libraries, + parallel, + perl: #1690 (#1687) put GNU parallel on the bats wrapper's PATH so bats --jobs works, GNU parallel is a perl script, and the wrapper ships in the image env. That silently reversed the perl eviction from #1108, whose CVE exception batch had been retired on the strength of perl being gone.

nixos-26.05 still carries perl 5.42.0 (5.42.3 is only on master/nixos-unstable, no backport), so a pin advance cannot clear this. The fix swaps the runner for shenwei356/rush, which bats-exec-suite supports natively via BATS_PARALLEL_BINARY_NAME; the wrapper sets it, so bats -j still needs nothing from the caller. rush is Go: no interpreter, and the image's runtime closure measures 47 MiB smaller. No .vulnixignore entry is needed since perl leaves the closure.

A negative image test now pins the eviction on both axes (command -v perl fails and no *-perl-* derivation in /nix/store). The PATH half alone was blind — perl was never on PATH while it sat in the closure, which is where vulnix looks — and that blindness is why nothing caught #1690.

Type of Change

  • feat -- New feature
  • fix -- Bug fix
  • docs -- Documentation only
  • chore -- Maintenance task (deps, config, etc.)
  • refactor -- Code restructuring (no behavior change)
  • test -- Adding or updating tests
  • ci -- CI/CD pipeline changes
  • build -- Build system or dependency changes
  • revert -- Reverts a previous commit
  • style -- Code style (formatting, whitespace)

Modifiers

  • Breaking change (!) -- This change breaks backward compatibility

Changes Made

nix/bats.nix

  • pkgs.rush-parallel replaces pkgs.parallel in the wrapper's PATH prefix; --set-default BATS_PARALLEL_BINARY_NAME rush so callers keep running plain bats -j
  • Header comment explains the runner choice and why GNU parallel is out

tests/test_image.py

  • TestFileStructure.test_perl_absent_from_image: command -v perl must fail and /nix/store must hold no ^[a-z0-9]{32}-perl5?[-.][0-9] entry. Fails on the pre-fix image with perl is back in the image's runtime closure: myzwgd3y…-perl-5.42.0, passes on the post-fix image

justfile, .github/actions/test-project/action.yml, tests/bats/just.bats

  • Comment-only: the sites that said GNU parallel rides with the wrapper now name rush. The assertion that the justfile carries no command -v parallel branch is unchanged

CHANGELOG.md, assets/workspace/.devcontainer/CHANGELOG.md

Changelog Entry

Fixed

  • bats --jobs runs on rush, keeping perl out of the image
    (#1708)
    • The parallel runner that arrived with bats -j
      (#1687) was GNU parallel,
      which is a perl script. The bats wrapper ships in the image env, so perl
      5.42.0 re-entered the image's runtime closure —
      #1108 had evicted it
      precisely so its CVE exception batch could be retired — carrying three
      findings the register holds no exception for (CVE-2026-4176 9.8,
      CVE-2026-13221 9.1, CVE-2026-57432 8.4). The nightly vulnix gate on dev
      caught it; no release carried it.
    • The runner is now shenwei356/rush,
      which bats supports natively via BATS_PARALLEL_BINARY_NAME (the wrapper
      sets it, so bats -j still needs nothing from the caller). rush is Go: no
      interpreter behind it, and the image's runtime closure drops 47 MiB.
    • A negative image test pins the eviction, which nothing had: no perl on PATH
      and no perl derivation anywhere in the image's store. The second half is
      the one that matters — perl was never on PATH even while it sat in the
      closure, which is where the vulnix scan looks.

Testing

  • Tests pass locally (just test)
  • Manual testing performed (describe below)

Manual Testing Details

  • RED: pre-fix nix build .#devkitImage → podman load → TEST_CONTAINER_TAG=nix-dev uv run pytest tests/test_image.py -k perl_absent → 1 failed (myzwgd3ylpl3d8zrl7kl3l97i7zl8mw6-perl-5.42.0 in the closure; the PATH assertion alone passed)
  • GREEN: post-fix image, same command → passes; whole tests/test_image.py → 113 passed. Inside the container: perl absent, parallel absent, bats -j 3 on a 3-test fixture runs 3/3
  • Closure proof: nix path-info -r $(nix build .#devkitImageEnv --print-out-paths) | grep -- '-perl-' → empty; -rush-parallel- → 26ibnf7m…-rush-parallel-0.9.0. Closure bytes 1718506032 → 1668846688 (−47.36 MiB)
  • Suite under the new wrapper (nix develop): all files except worktree.bats, bats -j $(nproc) → 596 ok, 0 failures, 60 s wall. Parallelism is engaged: just.bats 5.4 s serial vs 1.9 s at -j 8; BATS_PARALLEL_BINARY_NAME=nosuchrunner fails with command not found
  • command -v rush finds nothing in the dev shell: rush rides inside the wrapper only
  • prek run --all-files → all 53 hooks passed; uv run pytest tests/test_bats_shape.py tests/test_flake_hooks.py → 96 passed

Checklist

  • My code follows the project's style guidelines
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have updated the documentation accordingly (edit docs/templates/, then run just docs)
  • I have updated CHANGELOG.md in the [Unreleased] section (and pasted the entry above)
  • My changes generate no new warnings or errors
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published

Additional Notes

Diagnosis with the nix why-depends chain is on the issue. #1708 closes itself once the next scheduled security-scan.yml run passes the gate on dev.

Refs: #1708

#1108 evicted perl from the image and retired its CVE exception batch;
#1690 re-imported it by putting GNU parallel — a perl script — on the
bats wrapper's PATH, and nothing failed. Nothing pinned the eviction.

The test asserts both halves: no perl on PATH, and no perl derivation
anywhere under /nix/store in the image. The second is the one that
matters — perl was never on PATH even while it sat in the closure, which
is exactly where the nightly vulnix gate looks.

RED, proven against a locally built pre-fix image (`nix build
.#devkitImage` at this branch's parent, loaded as
`ghcr.io/vig-os/devcontainer:nix-dev`):

    AssertionError: perl is back in the image's runtime closure:
    myzwgd3ylpl3d8zrl7kl3l97i7zl8mw6-perl-5.42.0

The PATH half passed; the closure half failed.

Refs: #1708
`bats --jobs N` shells out to a parallel runner on bats' own PATH, and
#1690 supplied GNU parallel. GNU parallel is a perl script, and the bats
wrapper ships in the image env, so perl 5.42.0 walked straight back into
the image's runtime closure — the one #1108 emptied of perl so its CVE
exception batch could be retired. The nightly vulnix gate on `dev` found
it with three unexcepted findings (CVE-2026-4176 9.8, CVE-2026-13221 9.1,
CVE-2026-57432 8.4); `main`, on the same nixpkgs pin, stayed green.

bats accepts shenwei356/rush as well as GNU parallel: bats-exec-suite
resolves the runner through BATS_PARALLEL_BINARY_NAME, which the wrapper
now sets by default so `bats -j` needs nothing from the caller. rush is
Go, so no interpreter rides behind it.

GREEN:

    nix build .#devkitImageEnv --print-out-paths
      /nix/store/9kcjnjxn...-devcontainer-image-env
    nix path-info -r <out> | grep -- '-perl-'            -> no matches
    nix path-info -r <out> | grep -- '-rush-parallel-'
      /nix/store/26ibnf7m...-rush-parallel-0.9.0

The image closure drops 47 MiB (1718506032 -> 1668846688 bytes).

    nix develop --command bats -j 4 tests/bats/just.bats \
        tests/bats/upgrade-atomicity.bats
      65 tests, 0 failures

rush stays off the dev-shell PATH (`command -v rush` finds nothing there)
— it rides inside the wrapper, bats being its only consumer — and jobs are
genuinely engaged: just.bats is 5.4s serial against 1.9s at -j 8, and the
same run with a deliberately bogus BATS_PARALLEL_BINARY_NAME fails with
"command not found", so the lookup is live rather than silently serial.

Refs: #1708
An Unreleased `### Fixed` entry for the regression and its fix, and a
correction to the Unreleased #1687 bullet, which still credited GNU
parallel as the runner that rides with the bats wrapper and quoted an
incremental-closure figure measured for it. Both land in the same release,
so the entry that describes the runner has to name the one that shipped.

The synced mirror is edited alongside: sync-manifest skip-lists the
changelogs, so it does not regenerate them.

Refs: #1708
nixpkgs names perl modules `<hash>-perl5.42.0-Foo-Bar`, with no hyphen
before the version, so `-perl-[0-9]` only caught the interpreter. The pin
promises no perl derivation anywhere in the store; make the pattern say so.

Refs: #1708
@c-vigo
c-vigo merged commit 464aa88 into dev Sep 25, 2026
17 checks passed
@c-vigo
c-vigo deleted the bugfix/1708-perl-free-bats-parallel branch September 25, 2026 14:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant