use openmoat_core::Kind;
use super::Filesystem;
use super::Report;
use crate::sandbox::patterns::push_unique;
const GIT_EXEC_VECTORS: &[&str] = &[
"/**/.git/hooks",
"/**/.git/hooks/**",
"/**/.git/config",
"/**/.git/config.worktree",
"/**/.git/info/attributes",
"/**/.git/worktrees/*/config.worktree",
"/**/.git/worktrees/*/commondir",
"/**/.git/modules/**/hooks",
"/**/.git/modules/**/hooks/**",
"/**/.git/modules/**/config",
"/**/.git/modules/**/config.worktree",
"/**/.git/modules/**/info/attributes",
"/**/.git/modules/**/commondir",
];
impl Filesystem {
pub(super) fn git_internals(&mut self, report: &mut Report) {
for vector in GIT_EXEC_VECTORS {
push_unique(&mut self.deny_write, (*vector).to_owned());
}
report.allowance(
Kind::FsWrite,
"claude-code.git-internals",
vec!["/**/.git/**".to_owned()],
"user settings cannot name the project, so sandboxed commands may write `.git` \
(objects, refs, index: `git commit` works) in every directory, except what makes git \
run code or follow another repository (hooks, config, config.worktree, \
info/attributes, a linked worktree's commondir, the same in submodules); a script \
can still rewrite history, and the hook still asks for file-tool writes to `.git`",
);
}
}