Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions e2e/tasks/test_tool_versions_trust
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env bash

# .tool-versions files can't define tasks, so plain ones should never
# trigger a trust error in the task runner.

export MISE_TRUSTED_CONFIG_PATHS=""

echo "tiny 3.1.0" >.tool-versions
assert_not_contains "MISE_YES=0 mise task ls" "not trusted"
2 changes: 1 addition & 1 deletion src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1096,7 +1096,7 @@ fn all_dirs_from(start_dir: &Path) -> Result<Vec<PathBuf>> {
}

/// Returns true if a path is a .tool-versions file (lower priority for writes)
fn is_tool_versions_file(p: &Path) -> bool {
pub(crate) fn is_tool_versions_file(p: &Path) -> bool {
p.file_name()
.is_some_and(|f| f.to_string_lossy().ends_with(".tool-versions"))
}
Expand Down
10 changes: 7 additions & 3 deletions src/task/task_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,15 +120,19 @@ async fn err_no_task(config: &Config, name: &str) -> Result<()> {
}

// Check if there are any untrusted config files in the current directory
// that might contain tasks
// that might contain tasks.
if let Some(cwd) = &*dirs::CWD {
use crate::config::config_file::{config_trust_root, is_trusted};
use crate::config::config_files_in_dir;
use crate::config::{config_files_in_dir, is_tool_versions_file};

let config_files = config_files_in_dir(cwd);
let untrusted_configs: Vec<_> = config_files
.iter()
.filter(|p| !is_trusted(&config_trust_root(p)) && !is_trusted(p))
.filter(|p| {
!is_tool_versions_file(p)
&& !is_trusted(&config_trust_root(p))
&& !is_trusted(p)
})
.collect();

if !untrusted_configs.is_empty() {
Expand Down
Loading