auto-permission-system 3.7.8 → 3.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,13 +1,15 @@
1
- # auto-permission-system
1
+ # Auto Permission System: Cloud Auto Mode & Security for Pi Coding Agent
2
2
 
3
3
  [![npm version](https://img.shields.io/npm/v/auto-permission-system.svg)](https://www.npmjs.com/package/auto-permission-system)
4
4
  [![npm downloads](https://img.shields.io/npm/dm/auto-permission-system.svg)](https://www.npmjs.com/package/auto-permission-system)
5
5
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](./LICENSE)
6
6
  [![Pi package](https://img.shields.io/badge/pi--package-gallery-blueviolet)](https://pi.dev/packages)
7
7
  [![CI](https://github.com/Navin009/auto-permission-system/actions/workflows/ci.yml/badge.svg)](https://github.com/Navin009/auto-permission-system/actions/workflows/ci.yml)
8
+ [![Cloud Auto Mode for Pi](https://img.shields.io/badge/Pi-Cloud_Auto_Mode-blue.svg)](#cloud-auto-mode-for-pi)
9
+ [![Security for Pi](https://img.shields.io/badge/Security-for_Pi-green.svg)](#security-for-pi--how-to-secure-pi)
10
+ [![Permission System for Pi](https://img.shields.io/badge/Permission_System-for_Pi-orange.svg)](#permission-system-for-pi-pi-permission-system)
8
11
 
9
- **A security sandbox, permission system and tool guard for the [Pi coding agent](https://pi.dev).**
10
- It puts allow/deny rules, interactive ask prompts, secret detection and an audit log around every tool the agent can call — file reads and writes, shell commands, searches and network access — so the agent can work in your repository without reaching your credentials or the wider internet by accident.
12
+ **Auto Permission System** is the comprehensive toolkit providing **cloud auto mode for Pi**, **security for Pi**, and a zero-trust **permission system for Pi** ([pi.dev](https://pi.dev)). Whether you need an interactive **Pi permission system** with real-time ask prompts, an automated **PyPI permission system** to guard `.pypirc` and `pip install` commands, or a hardened **cloud auto mode** to **secure Pi** in headless CI/CD environments, this extension enforces multi-layer boundaries across filesystem access, network egress, shell commands, and MCP tools.
11
13
 
12
14
  Enforcement happens in three layers:
13
15
 
@@ -22,6 +24,10 @@ When a tool call is blocked you get an interactive prompt — no need to leave p
22
24
  - [Install](#install)
23
25
  - [Requirements](#requirements)
24
26
  - [Configuration](#configuration)
27
+ - [Cloud Auto Mode for Pi](#cloud-auto-mode-for-pi)
28
+ - [Security for Pi & How to Secure Pi](#security-for-pi--how-to-secure-pi)
29
+ - [Permission System for Pi (Pi Permission System)](#permission-system-for-pi-pi-permission-system)
30
+ - [PyPI & Python Ecosystem Security](#pypi--python-ecosystem-security)
25
31
  - [Commands](#commands)
26
32
  - [Escape hatches](#escape-hatches)
27
33
  - [FAQ](#faq)
@@ -172,6 +178,72 @@ Access to `~/.ssh`, `~/.gnupg`, `~/.aws`, `*.pem`, `*.key` and pi's own `~/.pi/a
172
178
 
173
179
  `sandbox.json` is strict JSON: no comments, no trailing commas. If a file does not parse, both layers skip it and use the built-in defaults for it. Layer 2 then shows an error at session start and writes `policy-parse-error` to the audit log. The "always" prompts refuse to write to a file they cannot parse, so a hand-written policy is never replaced.
174
180
 
181
+ ## Cloud Auto Mode for Pi
182
+
183
+ When running the Pi coding agent autonomously in the cloud, CI/CD pipelines, Docker containers, remote devboxes (GitHub Codespaces, Gitpod, Daytona), or headless subagents (`pi -p`, JSON mode), interactive terminal ask prompts cannot be answered by a human.
184
+
185
+ **Cloud Auto Mode for Pi** provides a deterministic, zero-trust security configuration engineered for autonomous execution:
186
+
187
+ - **Fail-Closed by Design:** Any tool call or bash command requesting an unlisted domain, credential path, or unapproved write fails closed immediately with an informative audit reason, preventing unmonitored agent deviations.
188
+ - **Pre-Configured Cloud Preset (`sandbox.cloud.json`):** Shipped directly in this package, `sandbox.cloud.json` sets `strictAllowlist: true`, locks `outsideProject.read: "deny"`, restricts subagent network egress, and denies read/write access to cloud credentials (`~/.aws`, `~/.azure`, `~/.config/gcloud`).
189
+ - **Subagent Posture Control (`subagent.network`):** Prevents subagents from opening external network sockets or exfiltrating private codebase data (`"deny"` or `"research-only"`).
190
+
191
+ ### Activating Cloud Auto Mode in Your Repository or CI:
192
+
193
+ ```bash
194
+ # 1. Copy the shipped Cloud Auto Mode template to your repository:
195
+ cp node_modules/auto-permission-system/sandbox.cloud.json .pi/sandbox.json
196
+
197
+ # 2. Run Pi headlessly with complete automated protection:
198
+ pi -p "Review pull request changes and execute test suite"
199
+ ```
200
+
201
+ ---
202
+
203
+ ## Security for Pi & How to Secure Pi
204
+
205
+ AI coding agents are granted powerful system tools—arbitrary bash command execution, filesystem reads and edits, URL fetching, and MCP integration. Without guardrails, prompt injections or untrusted code can compromise developer environments.
206
+
207
+ ### The 3-Layer Defense in Depth:
208
+
209
+ 1. **OS-Level Kernel Sandbox (Layer 1):** Uses `bubblewrap` (Linux) or `sandbox-exec` (macOS) to confine bash processes at the OS kernel boundary. Bash subprocesses cannot write outside designated directories or read forbidden directories even if child processes are spawned.
210
+ 2. **In-Process Tool Guard (Layer 2):** Guards the agent's internal tools (`read`, `write`, `edit`, `grep`, `find`, `ls`, `fetch_content`, `web_search`). Denied files are filtered out of directory listings and search outputs before the LLM can observe them.
211
+ 3. **Secret Detection & Output Redactor (Auto Secure):** Analyzes tool outputs and bash output streams in real time. Credentials, private keys, API tokens, and environment secrets are masked before reaching the model context window.
212
+
213
+ ### Quick Checklist: How to Secure Pi in 3 Steps
214
+ - **Step 1:** Install `auto-permission-system` (`pi install npm:auto-permission-system`).
215
+ - **Step 2:** Ensure `/permission-mode` is set to **Advanced Secure** (Auto Secure).
216
+ - **Step 3:** For CI/CD and cloud runs, adopt `sandbox.cloud.json` to enforce strict domain and path boundaries.
217
+
218
+ ---
219
+
220
+ ## Permission System for Pi (Pi Permission System)
221
+
222
+ The **Pi permission system** in `auto-permission-system` offers granular allow/ask/deny control with session memory and repository-level persistence:
223
+
224
+ | Policy Tier | Behavior | Example Subjects |
225
+ |---|---|---|
226
+ | **Absolute Deny** | Always blocked. Never prompts. | `~/.ssh`, `~/.aws`, `auth.json`, `*.pem`, `*.key` |
227
+ | **Ask (Interactive)** | Prompts user with 10s countdown timer (`Allow once`, `Always for project`, `Always global`). | `.env`, unlisted domains (`api.example.com`), bash `printenv` |
228
+ | **Allowed Roots** | Allowed transparently without prompting. | Project root `.`, `/tmp`, trusted package registries |
229
+ | **Cloud Auto Mode** | In headless runs (`-p`), unapproved operations fail closed without blocking execution. | Headless subagents, Docker containers, GitHub Actions |
230
+
231
+ ### Permission Modes Available:
232
+ - **`advanced-secure` (Auto Secure / Recommended):** Full rule engine + real-time AST/regex secret detection + MCP tool risk scoring.
233
+ - **`default`:** Rule-based sandbox without inspecting payload content.
234
+ - **`yolo`:** Emergency escape hatch that temporarily bypasses all security layers.
235
+
236
+ ---
237
+
238
+ ## PyPI & Python Ecosystem Security
239
+
240
+ `auto-permission-system` includes dedicated, out-of-the-box safeguards for Python developers and PyPI packaging workflows:
241
+
242
+ - **PyPI Token Protection:** Scans all tool outputs and bash streams in real time for exposed PyPI API tokens (matching `pypi-AgEI...` token signatures) and redacts them before the language model can read or exfiltrate them.
243
+ - **Sensitive Credentials Guard (`.pypirc`):** `~/.pypirc` and package registry credentials are gated under strict deny-read rules, preventing AI coding agents from accessing PyPI deployment credentials.
244
+ - **Governed `pip install` Network Egress:** Outgoing requests to `pypi.org` and `*.pypi.org` are pre-configured in the baseline domain allowlist (`sandbox.default.json`), allowing standard package resolution while blocking unvetted third-party download mirrors or suspicious domains.
245
+ - **Shield Against Malicious Package Setup Scripts:** When installing unfamiliar dependencies or running untrusted Python code, Layer 1 OS-level sandboxing (`bubblewrap` / `sandbox-exec`) confines `python setup.py` and bash commands within the project root, stopping arbitrary filesystem tampering outside allowed directories.
246
+
175
247
  ## Commands
176
248
 
177
249
  | Command | Description |
@@ -208,6 +280,12 @@ Every block/allow/always decision is appended to `~/.pi/agent/audit.log` as a JS
208
280
 
209
281
  ## FAQ
210
282
 
283
+ ### How does Cloud Auto Mode secure unattended or headless runs?
284
+ In headless mode (`pi -p` or subagent executions), interactive ask prompts cannot be presented to a human. Auto Permission System operates in a fail-closed posture: any tool call or bash command targeting an unlisted domain, credential file, or outside-project path is automatically blocked, and the refusal reason is provided to the agent and recorded in the audit log.
285
+
286
+ ### How does this package secure PyPI tokens and Python packages?
287
+ Auto Permission System includes native pattern recognizers for PyPI API tokens (`pypi-*`), hard-blocks model access to `~/.pypirc`, and gates `pip install` network requests to trusted hosts (`pypi.org`, `*.pypi.org`), preventing AI agents from leaking deployment secrets or pulling unvetted dependencies.
288
+
211
289
  ### How do I allow the agent to reach a new domain?
212
290
  Add it to `network.allowedDomains` in a policy file (global `~/.pi/agent/extensions/sandbox.json` or project `<cwd>/.pi/sandbox.json`), or just run the tool (or a bash `curl`) once and pick an **always** option in the ask prompt — that writes the domain to the project file for you.
213
291
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "auto-permission-system",
3
- "version": "3.7.8",
4
- "description": "Security sandbox, permission system and tool guard for the Pi coding agent (pi): enforce filesystem allow/deny lists and network domain allowlists on read, write, edit, bash, grep, find, ls, fetch_content and web_search, with interactive ask prompts, secret detection and an audit log.",
3
+ "version": "3.8.0",
4
+ "description": "Cloud auto mode for Pi & security for Pi. A zero-trust permission system for Pi to secure Pi coding agent workflows with tool guard, sandbox, and PyPI security.",
5
5
  "type": "module",
6
6
  "author": "Navin Kumar",
7
7
  "keywords": [
@@ -9,18 +9,40 @@
9
9
  "pi",
10
10
  "pi-coding-agent",
11
11
  "pi-extension",
12
+ "pi-permission",
13
+ "pi-permissions",
14
+ "pi-permission-system",
15
+ "pi-security",
16
+ "cloud-auto-mode-for-pi",
17
+ "security-for-pi",
18
+ "permission-system-for-pi",
19
+ "secure-pi",
20
+ "cloud-auto-mode",
21
+ "pi-cloud-auto-mode",
22
+ "auto-permission-system",
23
+ "auto-secure",
24
+ "secure",
25
+ "secure-it",
26
+ "pypi",
27
+ "pypi-security",
28
+ "pypi-secure-it",
29
+ "pypi-permission-system",
30
+ "cloud",
31
+ "cloud-security",
32
+ "auto-mode",
33
+ "permission",
34
+ "permissions",
35
+ "permission-system",
12
36
  "security",
13
37
  "sandbox",
14
- "permission-system",
15
38
  "tool-guard",
16
- "allowlist",
17
- "access-control",
18
39
  "secret-detection",
19
40
  "audit-log",
20
41
  "bubblewrap",
21
42
  "sandbox-exec",
22
43
  "ai-agent",
23
- "ai-coding-agent"
44
+ "ai-coding-agent",
45
+ "zero-trust"
24
46
  ],
25
47
  "license": "MIT",
26
48
  "repository": {
@@ -67,6 +89,7 @@
67
89
  "skills/",
68
90
  "sandbox.example.json",
69
91
  "sandbox.default.json",
92
+ "sandbox.cloud.json",
70
93
  "banner.png",
71
94
  "README.md",
72
95
  "CHANGELOG.md",
@@ -0,0 +1,62 @@
1
+ {
2
+ "enabled": true,
3
+ "mode": "advanced-secure",
4
+ "network": {
5
+ "strictAllowlist": true,
6
+ "allowedDomains": [
7
+ "registry.npmjs.org",
8
+ "registry.yarnpkg.com",
9
+ "npmjs.org",
10
+ "*.npmjs.org",
11
+ "pypi.org",
12
+ "*.pypi.org",
13
+ "files.pythonhosted.org",
14
+ "github.com",
15
+ "*.github.com",
16
+ "api.github.com",
17
+ "raw.githubusercontent.com",
18
+ "objects.githubusercontent.com",
19
+ "codeload.github.com",
20
+ "crates.io",
21
+ "proxy.golang.org",
22
+ "repo.maven.apache.org",
23
+ "rubygems.org"
24
+ ],
25
+ "deniedDomains": []
26
+ },
27
+ "filesystem": {
28
+ "outsideProject": {
29
+ "read": "deny"
30
+ },
31
+ "allowWrite": [
32
+ ".",
33
+ "/tmp"
34
+ ],
35
+ "denyRead": [
36
+ "~/.ssh",
37
+ "~/.aws",
38
+ "~/.azure",
39
+ "~/.config/gcloud",
40
+ "~/.gnupg",
41
+ "~/.pi/agent/auth.json"
42
+ ],
43
+ "denyWrite": [
44
+ ".env",
45
+ ".env.*",
46
+ "*.pem",
47
+ "*.key",
48
+ ".pypirc",
49
+ ".npmrc"
50
+ ]
51
+ },
52
+ "subagent": {
53
+ "network": "deny"
54
+ },
55
+ "commands": {
56
+ "ask": [
57
+ "printenv",
58
+ "env",
59
+ "/proc/*/environ"
60
+ ]
61
+ }
62
+ }
@@ -1,11 +1,11 @@
1
1
  ---
2
2
  name: auto-permission-system
3
- description: Use this skill when the user asks about the auto-permission-system extension, security policy configuration, why a tool call was blocked, how to add an allow-list entry, or how to configure sandbox behavior. Covers the two-layer sandbox (OS-level bash sandbox and in-process tool guard), policy file locations and fields, ask-tier prompt options, absolute-deny paths, escape hatches (--yolo, --no-sandbox, /permission-mode → YOLO), the audit log, and common tasks like allowing a new domain or write path.
3
+ description: Use this skill when the user asks about auto-permission-system, security for Pi, permission system for Pi, how to secure Pi, Cloud auto mode for Pi, security policy configuration, why a tool call was blocked, how to add an allow-list entry, or how to configure sandbox behavior. Covers the two-layer sandbox (OS-level bash sandbox and in-process tool guard), policy file locations and fields, Cloud auto mode preset (sandbox.cloud.json), ask-tier prompt options, absolute-deny paths, escape hatches (--yolo, --no-sandbox, /permission-mode → YOLO), the audit log, and common tasks like allowing a new domain or write path.
4
4
  ---
5
5
 
6
- # Pi Security — Skill
6
+ # Security for Pi (Pi Permission System) — Skill
7
7
 
8
- Use this skill when the user asks about the auto-permission-system extension, security policy configuration, why a tool call was blocked, how to add an allow-list entry, or how to configure sandbox behavior.
8
+ Use this skill when the user asks about the auto-permission-system extension, security for Pi, permission system for Pi, how to secure Pi, or configuring Cloud auto mode for Pi.
9
9
 
10
10
  ## What this extension does
11
11
 
@@ -19,15 +19,16 @@ Wraps the `bash` tool with `sandbox-exec` (macOS) or `bubblewrap` (Linux). Block
19
19
  **Layer 2 — In-process tool guard**
20
20
  Hooks `tool_call` for `read`, `grep`, `find`, `ls`, `write`, `edit`, `fetch_content`, `web_search`, `get_search_content`. Applies the same policy file as Layer 1. For `grep`, `find` and `ls` the search root is checked like a `read` path. A `tool_result` hook also removes `grep` output lines from denied files beneath an allowed root (for example a `.env` deep in the tree); approving the root does not approve those files. When a call is blocked, shows an interactive prompt with persistence options.
21
21
 
22
- **Layer 3 — Subagent posture**
23
- When `ctx.hasUI === false` (subagents, `-p`, JSON mode), applies the `subagent.network` policy: `allow` (default) | `deny` | `research-only`.
22
+ **Layer 3 — Subagent posture & Cloud Auto Mode**
23
+ When `ctx.hasUI === false` (subagents, `-p`, JSON mode, CI/CD runs), applies the `subagent.network` policy: `allow` (default) | `deny` | `research-only`. In Cloud Auto Mode, unapproved prompts fail closed.
24
24
 
25
25
  ## Policy files
26
26
 
27
27
  Merged in order (later wins):
28
28
  1. `sandbox.default.json` — shipped baseline (`outsideProject.read: "ask"`, full `denyRead`/`denyWrite`, `modelDenyRead`)
29
- 2. `~/.pi/agent/extensions/sandbox.json` — global user policy
30
- 3. `<cwd>/.pi/sandbox.json` — project-local overrides (also written by ask-tier prompts)
29
+ 2. `sandbox.cloud.json` — shipped Cloud Auto Mode preset for headless, Docker, and CI/CD runs (`strictAllowlist: true`, `outsideProject.read: "deny"`)
30
+ 3. `~/.pi/agent/extensions/sandbox.json` — global user policy
31
+ 4. `<cwd>/.pi/sandbox.json` — project-local overrides (also written by ask-tier prompts)
31
32
 
32
33
  A higher layer only states what it changes; absent keys keep the layer below. A **trusted** project may loosen the baseline; an **untrusted** project may only tighten it (ADR-013). You do not need a global file for good defaults (ADR-016).
33
34