0.6 rust重构01

This commit is contained in:
lix-2026
2026-04-14 13:22:29 +08:00
parent 71fb1aee7e
commit 84a8454fa9
401 changed files with 5841 additions and 1512 deletions
+37
View File
@@ -0,0 +1,37 @@
#!/usr/bin/env node
import { readFileSync } from "node:fs";
function readStdin() {
try {
return JSON.parse(readFileSync(0, "utf8") || "{}");
} catch {
return {};
}
}
const payload = readStdin();
const command = JSON.stringify(payload).toLowerCase();
const blocked = [
"rm -rf /",
"mkfs",
"dd if=",
"shutdown",
"reboot",
"poweroff",
"git reset --hard",
];
if (blocked.some((token) => command.includes(token))) {
process.stdout.write(JSON.stringify({
decision: "block",
reason: "OMX safety hook blocked an obviously destructive command.",
}));
process.exit(0);
}
process.stdout.write(JSON.stringify({
continue: true,
hookSpecificOutput: {
hookEventName: "PreToolUse",
},
}));