use openmoat_core::Kind;
use super::{Filesystem, Report};
use crate::sandbox::patterns::{has_glob, push_unique};
const AUDIT_LOG: &str = "/audit.db*";
impl Filesystem {
pub(super) fn hide_state_dirs(&mut self, report: &mut Report) {
let dirs: Vec<String> = self
.deny_read
.iter()
.filter_map(|entry| entry.strip_suffix(AUDIT_LOG))
.filter(|dir| dir.starts_with('/') && !has_glob(dir))
.map(str::to_owned)
.collect();
if dirs.is_empty() {
return;
}
for dir in &dirs {
push_unique(&mut self.deny_read, dir.clone());
}
report.loss(
Kind::FsRead,
"claude-code.linux-state-dir",
format!(
"on Linux Claude Code hides only the files a denyRead glob matches when each \
command starts, and the audit log's `-wal` and `-shm` files come and go, so \
OpenMoat's state directory is hidden whole from sandboxed commands, its \
policy included: {}",
dirs.join(", ")
),
);
}
}