Commit Graph

6 Commits

Author SHA1 Message Date
jdx 94f0219613 feat(manager/mise): run mise lock in safe mode without allowedUnsafeExecutions (#44749)
* feat(manager/mise): run mise lock in safe mode without allowedUnsafeExecutions

When `constraints.mise` pins a version that supports mise safe mode
(`MISE_SAFE=1`), run `mise lock` with safe mode enabled instead of
requiring `mise` in `allowedUnsafeExecutions`. Safe mode is a hard
boundary against project config executing code (templates exec/read_file,
_.source, hooks, tasks, asdf scripts, plugin installs are all refused),
so it — not the allowlist — protects the host.

The existing allowlisted path is unchanged: allowlisted repos run
`mise lock` exactly as before, without forcing safe mode, so configs
that legitimately execute code during locking keep working.

Safe mode also removes the need to pre-install node/npm/golang/ruby as
resolver tools, since npm version listing uses mise's built-in registry
HTTP client and go runs with GOTOOLCHAIN=local.

Refs: jdx/mise#11146 (safe mode), jdx/mise#11145 (lock --bump)

* fix: address oxlint and pin safe-mode min version to 2026.7.12

- logger.warn requires a static message with interpolated values in the
  metadata object (oxlint rule); move the version into metadata
- set MISE_SAFE_MODE_MIN_VERSION to 2026.7.12, the expected first release
  containing safe mode (merged after v2026.7.11)

* feat(manager/mise): use mise lock --bump for lock file maintenance

lockFileMaintenance means "update to the latest versions", but plain
`mise lock` only refreshes metadata for already-locked versions. Use
`mise lock --bump` so fuzzy selectors (e.g. node = "22") advance to the
latest matching version. `--bump` requires the same minimum mise version
as safe mode, so it is gated on the mise constraint and falls back to a
plain refresh otherwise.

Generalizes the version-gate helper (miseConstraintGuarantees) shared by
safe mode and --bump.

* refactor(manager/mise): detect mise version at runtime instead of via constraints

Determine safe-mode / --bump support by running `mise version` (which
does not load or execute project config) rather than requiring a pinned
`constraints.mise`. This works off whatever mise is actually installed,
so no extra configuration is needed.

The probe is skipped on the allowlisted, non-maintenance path, where the
version cannot change the outcome — keeping that hot path unchanged.

* feat(manager/mise): skip mise trust in safe mode

Safe mode now makes an untrusted config fully inert and no longer
requires trust to load it (jdx/mise#11151), so on the safe-mode path
`mise trust` is unnecessary and is skipped — `mise lock` runs with
`MISE_SAFE=1` alone. The allowlisted path is unchanged and still runs
`mise trust`.

* feat(manager/mise): confirm safe mode min version against v2026.7.12 release

MISE_SAFE=1 safe mode and `mise lock --bump` first shipped in mise
v2026.7.12 (released 2026-07-23), confirming the assumed
MISE_SAFE_MODE_MIN_VERSION. Resolve the pending-release TODO and align
the test version fixture with the real release date.

Validated end-to-end against the real v2026.7.12 binary: `mise version`
output matches the parser, `MISE_SAFE=1 mise lock` refreshes an untrusted
config without trust, `mise lock --bump` advances fuzzy selectors, and
project [env] is ignored under safe mode.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* test(manager/mise): cover mise version probe failure path

Add a test for the detectMiseVersion catch branch (exec throwing), so the
non-allowlisted path falls back to conservative behavior. Restores 100%
patch coverage for the mise manager.

* Update lib/modules/manager/mise/readme.md

Co-authored-by: Sebastian Poxhofer <secustor@users.noreply.github.com>

* Update lib/modules/manager/mise/readme.md

Co-authored-by: Sebastian Poxhofer <secustor@users.noreply.github.com>

* docs(mise): fix safe mode section link

---------

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
Co-authored-by: Sebastian Poxhofer <secustor@users.noreply.github.com>
2026-07-27 06:26:22 +00:00
Jamie Tanna 0e6429b13e refactor(types): document localDir isn't a globalOnly option (#44635)
* refactor(types): document `localDir` isn't a `globalOnly` option

To make sure that it's clear when reviewing `GlobalConfig`, as well as
working with our types, we can move the `localDir` definition into a
separate type.

* fixup! refactor(types): document `localDir` isn't a `globalOnly` option

* fixup! refactor(types): document `localDir` isn't a `globalOnly` option

Co-authored-by: Claude Sonnet 5 <jamie.tanna+claude-code@mend.io>

* fixup! refactor(types): document `localDir` isn't a `globalOnly` option

Co-authored-by: Claude Sonnet 5 <jamie.tanna+claude-code@mend.io>

* fixup! refactor(types): document `localDir` isn't a `globalOnly` option

Co-authored-by: Claude Sonnet 5 <jamie.tanna+claude-code@mend.io>

---------

Co-authored-by: Claude Sonnet 5 <jamie.tanna+claude-code@mend.io>
2026-07-20 08:07:17 +00:00
Sebastian Poxhofer 7436b80cda test(linter): add renovate/no-redundant-mock-reset rule (#44557)
ci(linter): add renovate/no-redundant-mock-reset rule

Vitest sets mockReset: true globally in vitest.config.mts, which resets
all mocks before each test. This makes vi.resetAllMocks() /
vi.clearAllMocks() and per-mock .mockReset() / .mockClear() calls inside
beforeEach/afterEach hooks redundant. Add a custom oxlint rule (enabled
for **/*.spec.ts and test/**) flagging such calls, and remove the 40
redundant calls it found. restoreAllMocks/mockRestore are not flagged
because restoreMocks is not enabled globally.

Two sites keep an inline disable with a reason: nested beforeEach hooks
in filter-checks.spec.ts and onboarding/pr/index.spec.ts intentionally
call mockReset() to discard once-values queued by an outer beforeEach.

Requested by maintainer review feedback (review comment 3052324877).

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-07-14 11:26:20 +00:00
Taku Kodama 333ace1fcf fix(manager/mise): install resolver tools during mise lock (#44174)
* fix(manager/mise): install resolver tools during mise lock

When binarySource=install, Containerbase only installs tools listed in
toolConstraints. mise lock can invoke npm, go, and gem CLIs while
resolving versions for those backends, but Renovate previously only
installed mise itself.

* fix(manager/mise): use go constraint for golang resolver

* test(manager/mise): remove redundant resolver constraint test

* test(manager/mise): cover resolver tool dynamic installs

* test(manager/mise): cover unconstrained resolver lock updates

* Update lib/modules/manager/mise/artifacts.ts

Co-authored-by: Jamie Tanna <github@jamietanna.co.uk>

* style(manager/mise): fix prettier whitespace in JSDoc comment

* test(manager/mise): clarify what happens with no `constraints`

* chore(manager/mise): update JsDoc

---------

Co-authored-by: Jamie Tanna <github@jamietanna.co.uk>
Co-authored-by: Jamie Tanna <jamie.tanna@mend.io>
2026-06-30 21:20:47 +00:00
Gregor Zeitlinger 0338dd74ba fix(mise): require allowlisting for lock updates (#43606)
* fix(mise): trust Renovate repo checkout during lock file updates

* docs(mise): document trusted config paths for lock updates

* refactor(mise): sanitize config files for lock updates

* test(mise): cover sanitized lock update flow

* docs(mise): describe sanitized lock update flow

* test(mise): cover sanitize failure paths

* fix(mise): clarify mirror read coverage

* fix(mise): allowlist mirrored settings

* test(mise): fix schema and integration specs

* fix(mise): trust only sanitized mirror workspace

* test(mise): fix mirrored cwd type narrowing

* test(mise): focus coverage on sanitized mirror flow

* test(mise): cover recursive settings schema

* fix(mise): ignore misreported lcov branch

* test(mise): remove redundant integration gate

* test(mise): drop local integration spec

* fix(mise): gate lock updates as unsafe execution

* fix(mise): restore settings schema typing

* fix(mise): generalize unsafe execution to mise

Rename allowedUnsafeExecutions value miseLock -> mise since any mise
command reading repo config can execute arbitrary code, not just
mise lock. Drop unused smol-toml dependency left over from the
abandoned config-sanitize approach.

Addresses PR review feedback.

* fix(mise): drop unused settings schema parsing

Nothing reads MiseFile.settings — the lock-update flow gates on
allowedUnsafeExecutions and relies on CI=true auto-trust, not config
sanitization. Remove the dead schema + tests per review.

Signed-off-by: Gregor Zeitlinger <gregor.zeitlinger@grafana.com>

* fix(mise): trust repo config via trusted paths

* fix(mise): explicitly trust config before lock

---------

Signed-off-by: Gregor Zeitlinger <gregor.zeitlinger@grafana.com>
2026-06-03 16:17:46 +00:00
Gregor Zeitlinger a2b96944f9 feat(mise): add lock file support (#42591)
* feat(mise): add lock file support

- Add lockfile.ts with getLockFileName() for deriving lock file paths
- Add artifacts.ts with updateArtifacts() and updateLockedDependency()
- Add MiseLockFile Zod schema for parsing lock files
- Update extract.ts to be async and extract lockedVersion from lock files
- Export supportsLockFileMaintenance, lockFileNames, updateArtifacts, updateLockedDependency

* refactor(mise): remove redundant comments

Remove comments that simply restate what the code already clearly
communicates. Keep valuable comments that explain non-obvious behavior
(e.g., why temporary errors are rethrown) and move helpful examples
into JSDoc comments.

* fix(mise): improve lock file version lookup and add tests

- Fix lock file key lookup for non-registry tools (aqua:, ubi:, etc.)
  Registry tools use short names (node), non-registry use full names
  (aqua:cli/cli). New getLockedVersion() tries both patterns.

- Add injection prevention test for shell quoting
- Add update-failed test for error handling
- Add comprehensive tests for getLockedVersion()
- Add null check for depName in updateLockedDependency
- Add JSDoc to updateArtifacts and extractPackageFile
- Add lock file support documentation to README
- Remove code duplication by consolidating into lockfile.ts

* fix(mise): pass --local flag and MISE_ENV for env/local config files

When updating mise.local.toml, `mise lock` updates mise.lock, not
mise.local.lock. Add --local flag to target the correct lock file.

For env-specific configs (mise.test.toml), set MISE_ENV=test so mise
reads and locks the correct configuration.

Extracted getConfigType() from getLockFileName() to share the parsing
logic between lock file name derivation and command flag generation.

Builds on #42099 by altendky.

* test(mise): cover tool absent from lock file

* refactor(mise): remove dead branches in extractPackageFile

tools is required by MiseFile schema so if(tools) is always true.
depName is always set by createDependency so if(dep.depName) is always true.

Add test for tool absent from lock file to cover the lockedVersion
assignment branch.

* fix(mise): address review feedback on lock file support

* fix(mise): remove unsupported tool constraint

* fix(mise): add containerbase tool definition

* fix(mise): add typed exec constraint support

* fix(config): restore requireConfig typing

* test(mise): await registry extraction cases

* Update lib/modules/manager/mise/artifacts.ts

Co-authored-by: Michael Kriese <michael.kriese@gmx.de>

* fix: revert unrelated types cleanup

* fix: drop missing VersioningName import

* fix(mise): use npm versioning string after import removal

* test(mise): set binarySource=global in artifacts spec

GlobalConfig.get now returns defaults; without explicit binarySource the
test fell into containerbase dynamic install and tried to resolve the
mise version via the github-releases datasource, causing missing HTTP
mock errors. Force binarySource=global so the spec only exercises the
mocked exec path.

---------

Co-authored-by: Kyle Altendorf <sda@fstab.net>
Co-authored-by: Michael Kriese <michael.kriese@gmx.de>
Co-authored-by: Jamie Tanna <jamie.tanna@mend.io>
2026-05-19 15:23:23 +00:00