What this artifact is for
The quick orientation layer before you go deeper upstream.
Summary
Block dangerous bash commands and protect sensitive paths from writes
Seed description: Block dangerous bash commands and protect sensitive paths from writes
Category: Extensions
Best for: Not yet synthesized.
How to read this page
Workflow tags: none captured
Integrations: none captured
Caveats: No caveats captured yet
Maturity: No maturity signals captured
Source excerpt
More of the actual upstream surface so you can skim here before deciding to open the repo.
Preview source: captured upstream text ↗
Quick topics
Skim bullets
import type { ExtensionAPI } from "@mariozechner/pi-coding-agent";
import * as path from "node:path";
/**
* Comprehensive security hook:
* - Blocks dangerous bash commands (rm -rf, sudo, chmod 777, etc.)
* - Protects sensitive paths from writes (.env, node_modules, .git, keys)
*/
export default function (pi: ExtensionAPI) {
const dangerousCommands = [
{ pattern: /\brm\s+(-[^\s]*r|--recursive)/, desc: "recursive delete" }, // rm -rf, rm -r, rm --recursive
{ pattern: /\bsudo\b/, desc: "sudo command" }, // sudo anything
{ pattern: /\b(chmod|chown)\b.*777/, desc: "dangerous permissions" }, // chmod 777, chown 777
{ pattern: /\bmkfs\b/, desc: "filesystem format" }, // mkfs.ext4, mkfs.xfs
{ pattern: /\bdd\b.*\bof=\/dev\//, desc: "raw device write" }, // dd if=x of=/dev/sda
{ pattern: />\s*\/dev\/sd[a-z]/, desc: "raw device overwrite" }, // echo x > /dev/sda
{ pattern: /\bkill\s+-9\s+-1\b/, desc: "kill all processes" }, // kill -9 -1
{ pattern: /:\(\)\s*\{\s*:\s*\|\s*:\s*&\s*\}\s*;/, desc: "fork bomb" }, // :(){:|:&};:
];
const protectedPaths = [
{ pattern: /\.env($|\.(?!example))/, desc: "environment file" }, // .env, .env.local (but not .env.example)
{ pattern: /\.dev\.vars($|\.[^/]+$)/, desc: "dev vars file" }, // .dev.vars
{ pattern: /node_modules\//, desc: "node_modules" }, // node_modules/
{ pattern: /^\.git\/|\/\.git\//, desc: "git directory" }, // .git/
{ pattern: /\.pem$|\.key$/, desc: "private key file" }, // *.pem, *.key
{ pattern: /id_rsa|id_ed25519|id_ecdsa/, desc: "SSH key" }, // id_rsa, id_ed25519
{ pattern: /\.ssh\//, desc: ".ssh directory" }, // .ssh/Sources and provenance
Everything on this page should be traceable back to the list seed or an upstream surface.
Discovery reason: Listed in the awesome-pi-agent README
Discovered from: michalvavra-agents
Claim confidence: medium
Surface capture kind: blob-code