Skip to content

feat(control): mise sources check (mise-en-place, ISSUE-1013 to ISSUE-1016) - #669

Closed
Exypte wants to merge 18 commits into
mainfrom
feature/254-mise-sources
Closed

Exypte wants to merge 18 commits into
mainfrom
feature/254-mise-sources

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:

The sources check of mise-en-place: where mise fetches tools from, held to lists kept outside the repository.

Code Subject Finding Severity
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
mise:
  sources:
    enabled: true
    trustedTools: ["core:*", "aqua:*", "github:my-org/*"]
    trustedRegistries: ["https://github.com/*", "https://nodejs.org/*"]
    trustedReplacement: []
    trustedOptions: ["https://ghe.example.com/*"]

Off in plumber:default. Patterns are globs, matched case-insensitively and validated when the config loads.

  • ISSUE-1013. trustedTools is matched against the tool's full mise name: its key (aqua:jqlang/jq), or for a shorthand (terraform) the backend its lock entry records. A shorthand with no lock entry fails closed; when the lockfile check runs it already reports the missing entry (ISSUE-1001/1003), so ISSUE-1013 stays quiet.
  • ISSUE-1014. Each platform entry of mise.lock records the url mise install --locked downloads, so a change to mise.lock alone could point a trusted tool at any host. Leave trustedRegistries out and the URLs aren't checked; [] trusts none.
  • ISSUE-1015. mise sends a download to its url_replacements target first, while mise.lock keeps the original URL, so ISSUE-1014 can't see it. Absent or [] trusts none.
  • ISSUE-1016 covers api_url, url, platforms.<os-arch>.url and the pip index options (registry_url, indexes, pipx_args, uvx_args, install_env). Absent or [] trusts none.
  • A tool that isn't trusted gets ISSUE-1013 alone: its URLs and options aren't judged.
  • .tool-versions isn't judged here (ISSUE-1009). A committed *.local.toml is judged like any config.
  • The settings checks the earlier version of this PR read (plugins, build repos, mirrors, aqua.registries, [env] index variables) are gone: the locked URL covers where a download actually comes from (mise: rework the #254 stack before merge (control name, codes, trusted* keys, lockfile URL) #678).

It also fixes the lock matcher from #665: when a tool's options differ by platform, mise lock writes one entry per platform with the same specifiers, and Plumber kept only the first, which gave a false ISSUE-1007. It now merges them.

Which issue(s) this PR is related to:

Part of #254 and #678 (PR 3 of 4). Based on #666 and retargeted as the earlier PRs merge.

Closes #668

Special notes for your reviewer:

Does this PR introduce a user-facing change?

mise-en-place gets a sources check (ISSUE-1013 to ISSUE-1016): tools must match mise.sources.trustedTools, the download URLs locked in mise.lock must match trustedRegistries (when set), url_replacements targets must match trustedReplacement, and tool options that set a URL must match trustedOptions. It is off by default; add a mise.sources block to turn it on.

How was this tested?

  • make test passes: the scanner (options in every form, url_replacements, merged lock entries), config decoding (the new keys, bad globs, the old authorizedSources key rejected), the Rego cases (policies/mise_sources_test.go: each code, absent vs empty trustedRegistries, one finding per lock entry when configs share a lockfile, the hand-offs with ISSUE-1001/1003, local configs, .tool-versions left alone), and the catalog and fingerprint goldens.
  • plumber analyze on the example repo at feature/678-by-subject, without the tasks block this build rejects. sources/issue-1014 is a real mise lock with its linux URL moved to another host:
Run Result
#666 branch nothing for sources/, and a false ISSUE-1007 on sources/issue-1016
this branch 18 findings: every directory gives its own code, sources/issue-1013 to issue-1016 included, no ISSUE-1007 on sources/issue-1016
 HIGH  ISSUE-1013  mise: a tool is not trusted
 HIGH  ISSUE-1014  mise: a locked download URL is not a trusted registry
 HIGH  ISSUE-1015  mise: a URL replacement is not trusted
 MED   ISSUE-1016  mise: a tool option sets an untrusted URL

AI usage disclosure:

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

🤖 Generated with Claude Code

Exypte and others added 6 commits December 1, 2026 10:50
…SSUE-1001 to ISSUE-1008)

New control packageManagersMustBeCompliant. Its first check reads every
committed mise config and lockfile in the local checkout, without running
mise, and reports:

- ISSUE-1001: a config declares tools and its lockfile is not committed
- ISSUE-1002: a config sets lockfile = false
- ISSUE-1003: a tool request has no lock entry (fails closed on templates
  and format 0 lockfiles)
- ISSUE-1004: a locked download has no checksum
- ISSUE-1005: a locked download has no provenance (requireProvenance)
- ISSUE-1006: a required platform is not locked (requiredPlatforms)
- ISSUE-1007: the lockfile format is too old (minimumLockfileVersion)
- ISSUE-1008: a tool is declared only in .tool-versions

mise does not depend on the provider, so it is configured by a new
top-level mise key in .plumber.yaml, next to gitlab and github. A missing
block or enabled: false skips it. The control is added to every run by
RunControls, after the provider's own controls. A remote run without a
checkout reports it as not evaluated. The legacy --output JSON is left
unchanged and does not carry these findings.

Refs #254

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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>
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>
Lint (errcheck) flagged the unchecked f.Close in readFile, and CodeQL
flagged len(m)+1 as a capacity hint in pinAbsentMiseChecks
(go/allocation-size-overflow). The file is read-only, so its close
error is ignored on purpose; the map needs no hint.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…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>
Covers packageManagersStatLines through the GitHub and GitLab stats
paths: configs read, tool requests summed over configs, findings, in
that order, and zeros when there is no scan.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Comment thread packagemanager/mise/mise.go Resolved
Comment thread packagemanager/mise/mise.go Resolved
Comment thread packagemanager/mise/mise.go Resolved
…des, stop on unreadable files)

Part of #678.

- The control is now mise-en-place. Codes are numbered in sequence and
  each has a subject (lockfile, presence), exported in the catalog.
- ISSUE-1005: a locked download records a provenance kind outside
  lockfile.trustedProvenance (default: slsa, github-attestations, cosign,
  minisign). Missing provenance moves to ISSUE-1006, and the next codes
  move up one (1007 platforms, 1008 format, 1009 .tool-versions).
- ISSUE-1010: with mise.required: true, a repository with no mise config
  outside exemptPaths is reported.
- ISSUE-1018: under requireChecksums, a tool from a binary backend
  (aqua, github, gitlab, ubi, http) locked with no platform table, or a
  platform with neither url nor checksum.
- ISSUE-1019: a mise local config (*.local.toml) that git tracks.
- A mise file that cannot be read (bad TOML, over 2 MiB, symlink out of
  the repository, to a device or nowhere) stops the run with one error
  listing every such file, control characters escaped. Files every
  configuration exempts don't stop it, unless a checked config pairs
  with them.
- The scan follows directory symlinks inside the repository, reads
  .tool-versions only when the lockfile check runs, maps asdf names
  (nodejs, golang), and applies an inherited lockfile = false the way
  mise does.
- The scan honors --controls / --skip-controls and reads the files when
  any platform policy needs them; each policy's verdict marks
  mise-en-place not evaluated when its data was not read.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Exypte
Exypte force-pushed the feature/254-mise-sources branch from a1a956c to 655ecb8 Compare December 2, 2026 15:32
Comment thread control/packagemanagers.go Resolved
Comment thread packagemanager/mise/mise.go Resolved
Comment thread packagemanager/mise/mise.go Resolved
@Exypte
Exypte force-pushed the feature/254-mise-sources branch from 655ecb8 to f0c7da9 Compare December 2, 2026 15:43
@github-actions

github-actions Bot commented Dec 2, 2026 •

Copy link
Copy Markdown

Claude PR review — findings not anchorable to the diff

None on the latest revision.

Part of #678. trustedProvenance: [] trusts no provenance kind, and an
absent key trusts the default four. omitempty dropped the empty list
when a config was written back to YAML (config slim does), so it read
back as absent and trusted every kind. The field is now a pointer, so
an empty list stays empty.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Exypte
Exypte force-pushed the feature/254-mise-sources branch from f0c7da9 to 54b5c2c Compare December 2, 2026 15:56
Comment thread packagemanager/mise/mise.go Resolved
Comment thread packagemanager/mise/mise.go Resolved
@Exypte Exypte changed the title feat(control): mise sources check (packageManagersMustBeCompliant, ISSUE-1021 to ISSUE-1023) feat(control): mise sources check (mise-en-place, ISSUE-1013 to ISSUE-1016) Dec 2, 2026
…he local-config git filter

A provenance table with two kinds is read as both kinds, sorted and
joined with a comma, which is the form the ISSUE-1005 rule splits. When
two configs of one directory disagree on [settings] lockfile, false wins
whichever is read first. scanPackageManagers drops a *.local.toml that
git does not track.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Exypte
Exypte force-pushed the feature/254-mise-sources branch from 54b5c2c to e81b327 Compare December 2, 2026 18:16
Exypte and others added 9 commits December 3, 2026 10:51
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Adds the versions check of #254. A tool request in a mise config that
matches mise.versions.forbiddenVersions (globs) is ISSUE-1011, high. The
check reads the request as written in mise.toml: with `latest` the
lockfile still pins a version, but `mise lock --bump` or `mise upgrade`
moves it without any change to the config.

- Fails closed: a request Plumber can't read (template, empty or
  unquoted version) is ISSUE-1011 too.
- plumber:default turns it on with latest, lts, lts/*, lts-*, stable,
  nightly, beta, branch:*, path:*, system, sub-* and prefix:*. ref:* is
  left out because a ref pinned to a commit SHA can't move.
- An invalid glob is rejected when the config loads. Before, glob.match
  failed silently and the rule matched nothing.
- An unreadable config stops the run when only the versions check runs.
  That check alone reads no lockfile and no .tool-versions
  (mise.Options.Lockfiles), so an unreadable one does not stop it.
- config slim pins an absent versions block off for a legacy source, as
  it does for lockfile.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Part of #678. A tool request Plumber can't read without running mise (a
{{ }} template, an empty version, an unquoted one like `node = 24`) was
a second ISSUE-1011 rule. It is now its own code, ISSUE-1012 (subject
versions, high), and ISSUE-1011 only reports a request that matches
forbiddenVersions.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
[tools.<name>.platforms.<platform>] gives the same platforms as the
quoted "platforms.<platform>" form, sorted by name.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Adds the sources check of #254, configured by mise.sources
(authorizedSources, authorizedRegistries; globs checked at load). It is
off in plumber:default.

- ISSUE-1021: a tool comes from a backend outside authorizedSources. A
  key with a backend is its own source; a shorthand takes the backend of
  its lock entry. A tool whose backend no lock entry records fails closed,
  unless the entry is missing and the lockfile check already reports it.
  .tool-versions entries are judged too.
- ISSUE-1022: a [settings] redirect (url_replacements, aqua registries,
  mirrors, build repos), a [plugins] URL or an [env] index variable
  points outside authorizedRegistries.
- ISSUE-1023: a tool on an authorized backend overrides its download
  location (api_url, url, platforms.<p>.url, pypi indexes) with a URL
  outside authorizedRegistries.

The collector now keeps committed *.local.toml files (judged by sources
and versions, never by the lockfile check), and merges the platforms of
lock entries that share specifiers: mise writes one entry per platform
when a tool's options differ by platform, and Plumber used to keep the
first one only, which gave a false ISSUE-1007.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…013 to ISSUE-1016)

Part of #678, covers #668.

- trustedTools replaces authorizedSources: matched against the tool's
  full mise name (its key, or the backend its lock entry records).
  ISSUE-1013 (was ISSUE-1021).
- trustedRegistries is checked against every download url mise.lock
  records for a trusted tool, the URL `mise install --locked` fetches.
  Absent: not checked; [] trusts none. ISSUE-1014 (new).
- trustedReplacement: [settings] url_replacements targets. mise requests
  the replacement first while the lockfile keeps the original URL.
  ISSUE-1015 (was ISSUE-1022).
- trustedOptions: URL options of a trusted tool (api_url, url,
  platforms.<p>.url, pip indexes). ISSUE-1016 (was ISSUE-1023).
- A tool that is not trusted gets ISSUE-1013 alone.
- The scanner no longer reads [plugins] URLs, build repos, mirrors,
  aqua.registries or [env] index variables, and the sources check no
  longer judges .tool-versions (ISSUE-1009 covers it).
- MISE_URL_REPLACEMENTS set in the CI file goes with #675.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…kout

A root mise.local.toml with [monorepo] lockfile = true does not pair
subprojects with the root lockfile. The versions check judges a
committed local config. The sources check alone reads lockfiles, so a
broken mise.lock stops the run.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
pipx_args and uvx_args are command lines, so a flag like --include-deps
was reported as an untrusted source (ISSUE-1016) and a real index URL
could not match trustedOptions. Every URL in them is now judged on its
own, whatever flag carries it, since pip accepts attached short values
and long-option prefixes. install_env also reads UV_DEFAULT_INDEX,
UV_EXTRA_INDEX_URL, UV_INDEX and npm scoped registries. The mirror
settings comment no longer says ISSUE-1014 covers go, npm, cargo or pip
tools.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Exypte
Exypte force-pushed the feature/254-mise-sources branch from e81b327 to fb0c26d Compare December 3, 2026 10:10
@Exypte

Exypte commented Dec 3, 2026

Copy link
Copy Markdown
Contributor Author

#681 replaces this path. Remote runs read the mise files there, and TestRunGitHubAnalysisRemote_Mise drives RunGitHubAnalysisRemote, including the gap marking. No test added here.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔴 Test coverage

Medium: invalid-glob validation and its tests cover versions/sources glob fields but not mise.lockfile.requireProvenance or mise.exemptPackages, so a typo in those fields loads without error and silently weakens the check untested. (Medium)

validateGlobs exists precisely because the Rego rules call glob.match, which "fails on a bad pattern and then matches nothing, so a typo would silently change what the check passes" (see its doc comment at configuration/packagemanagers.go:229). It is applied to mise.versions.forbiddenVersions (line 160) and the four mise.sources.* lists (line 222), and configuration/packagemanagers_test.go (TestMiseConfigDecoding) asserts rejection for trustedTools, trustedRegistries, and forbiddenVersions.

Two other fields are documented as glob lists and consumed by glob.match in the Rego, but are never passed to validateGlobs and have no test exercising an invalid pattern:

  • mise.lockfile.requireProvenance — MiseLockfileCheckConfig.UnmarshalYAML (configuration/packagemanagers.go:116) only rejects unknown keys. The Rego rule for ISSUE-1006 (policies/mise_lockfile.rego:915) does glob.match(pattern, null, tool.locked.backend) over these patterns.
  • mise.exemptPackages — MiseConfig.UnmarshalYAML likewise does not validate it; _exempt in policies/mise_lockfile.rego:752 does glob.match(pattern, null, name) over it.

Concrete failure scenario: a config with mise:\n lockfile:\n requireProvenance: ["aqua:[infra"] loads with no error (no config test catches this). At evaluation, glob.match errors on the malformed pattern, so it is undefined and ISSUE-1006 never fires — a tool locked without provenance passes silently, the opposite of what the user configured. A typo in exemptPackages (e.g. ["aqua:[x"]) similarly fails to exempt the intended tool, producing spurious findings. Neither behavior is caught by any test.

Suggested tests / fix: route RequireProvenance through validateGlobs("mise.lockfile.requireProvenance", ...) in MiseLockfileCheckConfig.UnmarshalYAML and ExemptPackages through validateGlobs("mise.exemptPackages", ...) in MiseConfig.UnmarshalYAML, then add TestMiseConfigDecoding cases asserting that requireProvenance: ["aqua:[infra"] and exemptPackages: ["aqua:[x"] each return a config error (matching the existing invalid-glob cases for the other fields).

Control: .github/claude-prompts/test-coverage.md · resolve this conversation once addressed.

// 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 mise sources check misses a lowercase npm_config_registry in a tool's install_env, letting a trusted npm tool redirect downloads to an untrusted registry without triggering ISSUE-1016. (Medium)

isIndexEnvVar decides whether an install_env key counts as a download-redirecting option (ISSUE-1016). The global index variables are matched case-sensitively via slices.Contains(indexEnvVars, k) (mise.go:764–780), where indexEnvVars contains "NPM_CONFIG_REGISTRY". Only the scoped npm branch is case-insensitive (strings.ToUpper(k) at mise.go:778).

npm's config loader matches the npm_config_ prefix case-insensitively and lowercases the remainder of the key, so npm_config_registry, Npm_Config_Registry, and NPM_CONFIG_REGISTRY are all honored by npm (and environment variable names on Linux are case-sensitive, so mise passes whatever casing the config wrote straight through to the install process). The same is true of npm's scoped form — which is exactly why the authors made that branch case-insensitive.

Concrete failure scenario: a repo trusts its npm tools (e.g. mise.sources.trustedTools: ["npm:*"]) and a committed mise.toml contains:

[tools]
"npm:some-pkg" = { version = "1.2.3", install_env = { npm_config_registry = "https://evil.example/" } }

tableSourceOptions (mise.go:832–838) calls isIndexEnvVar("npm_config_registry"), which returns false: the key is not byte-equal to NPM_CONFIG_REGISTRY, and the scoped branch requires @ + :REGISTRY. The key is therefore dropped from SourceOptions, so the ISSUE-1016 rule in policies/mise_sources.rego (lines 169–184) never sees it. mise install runs npm with npm_config_registry=https://evil.example/, pulling the package from an attacker-controlled registry, and the sources check passes clean — a silent bypass of the control whose purpose is to catch download redirection. Using the uppercase NPM_CONFIG_REGISTRY is detected, so the lowercase form is a pure evasion.

Suggested fix: match the global index variables case-insensitively for the npm vars (or normalize k the way npm does before comparison), consistent with the existing scoped-registry handling. Add a test fixture with a lowercase npm_config_registry (and mixed-case) in install_env to packagemanager/mise/mise_test.go / policies/mise_sources_test.go, which currently only exercise the uppercase PIP_INDEX_URL/UV_EXTRA_INDEX_URL and scoped NPM_CONFIG_@acme:registry forms.

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

Base automatically changed from feature/254-mise-versions to main December 3, 2026 10:25
@Exypte

Exypte commented Dec 3, 2026

Copy link
Copy Markdown
Contributor Author

Collapsed into #665, which now carries the whole stack (head ebb6db6), so CI runs on all of it. The description of #665 covers this part.

@Exypte Exypte closed this Dec 3, 2026
@Exypte
Exypte deleted the feature/254-mise-sources branch December 3, 2026 10:53
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.

mise sources: the download URL locked in mise.lock is never checked

1 participant