aKode fase 5: rinomina interna (crate akode-*, akode-rs/, akode-cli/, binario akode, AKODE_*, ~/.akode, snapshot)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
andrea.difonzo
2026-11-11 11:06:46 +01:00
parent df99318392
commit 86e7c72e5f
10383 changed files with 749164 additions and 749170 deletions

View File

@@ -0,0 +1,24 @@
//! Mandatory pathname and network protections for privileged daemon sockets.
//! Emit these after all grants, including implicit platform access.
use super::SeatbeltPreparationError;
use std::path::Path;
pub(super) fn protection_policy(directory: &Path) -> Result<String, SeatbeltPreparationError> {
let quoted = serde_json::to_string(&directory.to_string_lossy())
.map_err(|error| SeatbeltPreparationError::FileSystem(error.to_string()))?;
let mut rules = vec![format!(
"(deny file-read* file-write* (literal {quoted}) (subpath {quoted}))\n\
(deny network-outbound (remote unix-socket (subpath {quoted})))"
)];
// Moving an ancestor would relocate the entire protected subtree beyond
// both pathname rules. Only unlink is denied; sibling writes still work.
for ancestor in directory.ancestors().skip(/*n*/ 1) {
let quoted = serde_json::to_string(&ancestor.to_string_lossy())
.map_err(|error| SeatbeltPreparationError::FileSystem(error.to_string()))?;
rules.push(format!(
"(deny file-write-unlink (require-all (vnode-type DIRECTORY) (literal {quoted})))"
));
}
Ok(rules.join("\n"))
}