twpayne / chezmoi

Manage your dotfiles across multiple diverse machines, securely.
https://www.chezmoi.io/
MIT License
12.9k stars 478 forks source link

Feature Request: Allow subdirectories to opt-out of script execution. #2714

Closed peterbraden closed 1 year ago

peterbraden commented 1 year ago

Is your feature request related to a problem? Please describe.

Chezmoi runs files with the run_ prefix. However sometimes you have subdirectories where you don't want this to happen. A common example is if you use git submodules for vim plugins - any author of these could include a run_tests.sh or run_evil.sh and it would be executed next time you ran chezmoi apply.

Vendoring settings or configs is a pretty common pattern in dotfiles repos, and while chezmoi includes the option of using .chezmoiexternal.toml to include remote files, this isn't always an option.

Describe the solution you'd like

It would be great if there was a way to indicate that chezmoi should ignore file prefixes below a certain subdirectory. For example a prefix dot_vim/external_bundle/ or a sentinel file dot_vim/bundle/.chezmoiexternal.

bradenhilton commented 1 year ago

@twpayne Would it be feasible to add something like recursive_literal_*/noparse_*?

twpayne commented 1 year ago

Thanks for the feature request!

It's not just run_ scripts that are a potential security problem. If you're importing VIM plugins then any of these plugins can use vimscript's system function to run arbitrary commands on your machine. Fundamentally, if you're importing third-party files into your home directory you need to either trust or audit every change to that third-party code.

As you say, using .chezmoiexternal.toml does allow you to import third-party files without the danger of chezmoi executing run_evil.sh. I understand that in your case you prefer to use git submodules in your dotfiles repo, rather than either archive or git-repo externals.

It would be great if there was a way to indicate that chezmoi should ignore file prefixes below a certain subdirectory. For example a prefix dot_vim/external_bundle/ or a sentinel file dot_vim/bundle/.chezmoiexternal.

Would it be feasible to add something like recursive_literal_*/noparse_*?

Of these, I think the external_ prefix makes the most sense because:

What I propose is:

How does this sound?