cc-safety-net 2.2.2 → 2.3.1
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 +80 -78
- package/dist/amp/cc-safety-net/index.ts +55 -55
- package/dist/api.js +1 -1
- package/dist/bin/cc-safety-net.js +761 -142
- package/dist/chunks/{index-j6a67cs3.js → index-2z9vsvqb.js} +2 -2
- package/dist/chunks/index-6fvz7zfr.js +46 -0
- package/dist/chunks/index-y9vmf6ts.js +2 -0
- package/dist/index.js +1 -1
- package/dist/openclaw/cc-safety-net/index.js +55 -55
- package/dist/openclaw/cc-safety-net/openclaw.plugin.json +1 -1
- package/dist/openclaw/cc-safety-net/package.json +1 -1
- package/dist/pi/index.js +2 -2
- package/package.json +2 -2
- package/dist/chunks/index-25nh5wqs.js +0 -45
- package/dist/chunks/index-z08yh4sm.js +0 -46
package/README.md
CHANGED
|
@@ -19,36 +19,14 @@
|
|
|
19
19
|
|
|
20
20
|
</div>
|
|
21
21
|
|
|
22
|
-
CC Safety Net
|
|
22
|
+
CC Safety Net (Coding CLI Safety Net) blocks destructive commands and access to secrets such as SSH keys and `.env` files before the tool call runs. It parses what the command does. Wrapping the command or reordering flags does not hide it. A broken config file never blocks anything.
|
|
23
23
|
|
|
24
24
|
> [!NOTE]
|
|
25
25
|
> **[Full documentation →](https://ccsafetynet.com/docs)** covers installation, configuration, reference material, guides, and the security model. This README is the short version.
|
|
26
26
|
|
|
27
|
-
## Why this exists
|
|
28
|
-
|
|
29
|
-
We built CC Safety Net after an agent [wiped hours of work](https://www.reddit.com/r/ClaudeAI/comments/1pgxckk/claude_cli_deleted_my_entire_home_directory_wiped/) with one `rm -rf ~/` or `git checkout --`. Instructions did not stop it. Rules in `CLAUDE.md` or `AGENTS.md` can guide an agent, but they cannot enforce a technical limit. CC Safety Net watches relevant tool calls and blocks destructive commands and secret access before they reach the shell. See [What is CC Safety Net](https://ccsafetynet.com/docs/introduction) for the full background.
|
|
30
|
-
|
|
31
|
-
## Quick start
|
|
32
|
-
|
|
33
|
-
You need Node.js 18 or higher.
|
|
34
|
-
|
|
35
|
-
Run the interactive selector to install CC Safety Net into one or more installed coding CLIs:
|
|
36
|
-
|
|
37
|
-
```bash
|
|
38
|
-
npx -y cc-safety-net@latest install
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
To update every installed integration:
|
|
42
|
-
|
|
43
|
-
```bash
|
|
44
|
-
npx -y cc-safety-net@latest update
|
|
45
|
-
```
|
|
46
|
-
|
|
47
|
-
Keep the `@latest` qualifier; a bare `cc-safety-net` spec can run an older cached copy from the npx cache. `npx -y cc-safety-net uninstall` removes integrations interactively, and `npm install -g cc-safety-net` gives you `ccsn`, a shorter alias for the same commands.
|
|
48
|
-
|
|
49
27
|
## Supported coding CLIs
|
|
50
28
|
|
|
51
|
-
CC Safety Net supports the coding agent CLIs below on Windows, macOS, and Linux. Automated tests cover the analyzer and some Windows integrations.
|
|
29
|
+
CC Safety Net supports the coding agent CLIs below on Windows, macOS, and Linux. Automated tests cover the analyzer and some Windows integrations. Windows support for the remaining CLIs is best effort and has not been tested.
|
|
52
30
|
|
|
53
31
|
<table align="center">
|
|
54
32
|
<tr>
|
|
@@ -72,35 +50,56 @@ CC Safety Net supports the coding agent CLIs below on Windows, macOS, and Linux.
|
|
|
72
50
|
</tr>
|
|
73
51
|
</table>
|
|
74
52
|
|
|
75
|
-
|
|
53
|
+
Amp documents macOS, Linux, and WSL, but not native Windows.
|
|
76
54
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
55
|
+
## Features
|
|
56
|
+
|
|
57
|
+
- **Blocks destructive commands.** `git reset --hard`, `git push --force`, `rm -rf` on dangerous targets, `find -delete`, and PowerShell `Remove-Item`. The hook still blocks the same command inside `bash -c` or `python -c`. A sandbox still allows `git reset --hard` inside your project. See [vs Sandboxing](https://ccsafetynet.com/docs/guides/vs-sandboxing).
|
|
58
|
+
- **Blocks secret access.** SSH keys, `.env` files, `~/.aws`, and the credential files coding CLIs keep. The rules cover the shell and the agent's read, edit, write, and search tools. Blocking a CLI's own settings files is optional. It stays off until you turn it on.
|
|
59
|
+
- **Customize the rules in a GUI.** Run `npx cc-safety-net gui` and open Policy. Turn individual block and secret rules off. Add paths to allow or deny. You cannot turn off the rules that catch wiping `/` or `~`.
|
|
60
|
+
- **Adds blocks through rulebooks.** Official packs for Terraform, AWS, gcloud, and Azure, or JSON you write yourself. A rulebook can only add blocks. It cannot turn built-in protection off. The packs live in [cc-safety-net/rulebooks](https://github.com/cc-safety-net/rulebooks). Install a pack with:
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
npx -y cc-safety-net rule add --only terraform aws --global
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
See [Official Rulebooks](https://ccsafetynet.com/docs/configuration/rulebooks).
|
|
67
|
+
- **Shares policy through git.** Commit `.cc-safety-net/` so clones and cloud sessions pick up the same rules. If a project file tries to loosen a member's stricter settings, `status` and `doctor` report it. `policy apply` asks for confirmation in a terminal. Copying the folder is not enough. The hook still has to be installed. See [Team Setup](https://ccsafetynet.com/docs/guides/team-setup) and [Cloud Environments](https://ccsafetynet.com/docs/guides/cloud-environments).
|
|
68
|
+
- **Embeds in your own tools.** Install the npm package and call `checkCommand` to get allow or deny from your own code. No hook required. See [Library API](#library-api).
|
|
86
69
|
|
|
87
70
|
Full rule catalogs: [Blocked Commands](https://ccsafetynet.com/docs/reference/blocked-commands) · [Allowed Commands](https://ccsafetynet.com/docs/reference/allowed-commands) · [Secret Protection](https://ccsafetynet.com/docs/reference/secret-protection).
|
|
88
71
|
|
|
89
|
-
##
|
|
72
|
+
## Quick start
|
|
73
|
+
|
|
74
|
+
You need Node.js 18 or higher.
|
|
75
|
+
|
|
76
|
+
To install into the coding CLIs on this machine, run:
|
|
90
77
|
|
|
91
|
-
|
|
78
|
+
```bash
|
|
79
|
+
npx -y cc-safety-net@latest install
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
To update every installed integration:
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
npx -y cc-safety-net@latest update
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
Keep the `@latest` qualifier. A bare `cc-safety-net` spec can run an older copy from the npx cache. To uninstall, run `npx -y cc-safety-net uninstall`. `npm install -g cc-safety-net` also installs the `ccsn` alias.
|
|
92
89
|
|
|
93
90
|
## Safety presets
|
|
94
91
|
|
|
95
|
-
|
|
92
|
+
To set a preset, run `npx cc-safety-net gui` and open Policy.
|
|
96
93
|
|
|
97
94
|
| Preset | Effect |
|
|
98
95
|
|---|---|
|
|
99
96
|
| Standard | Blocks recognizable destructive Git and filesystem commands. Allows metadata-only checks of built-in sensitive paths while continuing to block content access. Recommended for normal coding. |
|
|
100
|
-
| Strict | Standard, plus blocks dynamic or unparseable commands the analyzer cannot verify safely
|
|
97
|
+
| Strict | Standard, plus blocks dynamic or unparseable commands the analyzer cannot verify safely. Also blocks metadata-only discovery of built-in sensitive paths. Occasional false positives on advanced shell. |
|
|
101
98
|
| Paranoid | Strict, plus blocks `rm -rf` inside your project and interpreter one-liners. Expect friction; for untrusted agents or high-stakes repos. |
|
|
102
99
|
|
|
103
|
-
|
|
100
|
+
Linked-worktree mode relaxes only local discard. See [Modes](https://ccsafetynet.com/docs/configuration/modes).
|
|
101
|
+
|
|
102
|
+
## Diagnostics
|
|
104
103
|
|
|
105
104
|
```bash
|
|
106
105
|
# Summarize what is being enforced right now
|
|
@@ -119,45 +118,13 @@ npx cc-safety-net gui
|
|
|
119
118
|
|
|
120
119
|
Details: [CLI Commands](https://ccsafetynet.com/docs/reference/cli-commands) · [Explain Trace](https://ccsafetynet.com/docs/reference/explain-trace) · [Audit Log](https://ccsafetynet.com/docs/reference/audit-log) · [Dashboard](https://ccsafetynet.com/docs/guides/dashboard) · [Configuration Recovery](https://ccsafetynet.com/docs/configuration/recovery).
|
|
121
120
|
|
|
122
|
-
##
|
|
123
|
-
|
|
124
|
-
Node.js hosts that need an in-process allow or deny decision can call the command-check
|
|
125
|
-
function directly instead of installing an agent integration:
|
|
126
|
-
|
|
127
|
-
```bash
|
|
128
|
-
npm install cc-safety-net
|
|
129
|
-
```
|
|
130
|
-
|
|
131
|
-
```ts
|
|
132
|
-
import { checkCommand } from 'cc-safety-net/api';
|
|
133
|
-
|
|
134
|
-
function commandIsAllowed(command: string, cwd: string): boolean {
|
|
135
|
-
try {
|
|
136
|
-
const result = checkCommand({ command, cwd });
|
|
137
|
-
if (result.kind === 'allow') return true;
|
|
138
|
-
console.error(result.reason);
|
|
139
|
-
return false;
|
|
140
|
-
} catch (error) {
|
|
141
|
-
console.error('CC Safety Net could not check the command', error);
|
|
142
|
-
return false;
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
if (commandIsAllowed('git status', process.cwd())) {
|
|
147
|
-
// The host can now decide how to run the command.
|
|
148
|
-
}
|
|
149
|
-
```
|
|
121
|
+
## Limitations
|
|
150
122
|
|
|
151
|
-
|
|
123
|
+
CC Safety Net denies a tool call before it runs. It does not set filesystem permissions, watch network egress, or contain a process.
|
|
152
124
|
|
|
153
|
-
- `
|
|
154
|
-
targets and selects the project policy.
|
|
155
|
-
- A `deny` result means the host must not execute the command. **If `checkCommand` throws,
|
|
156
|
-
do not execute the command either.**
|
|
125
|
+
The policy and secret-path extractors are mostly POSIX. For PowerShell they resolve a home prefix (`$HOME`, `$env:USERPROFILE`, `$env:HOME`, or `~`) joined to a literal suffix with `\` or `/`. The same check applies to `Get-Content`, `Set-Content`, `Add-Content`, `Copy-Item`, `Move-Item`, `Remove-Item`, and their aliases. `Get-Content $HOME\.ssh\id_rsa` is denied. A path built by concatenation, a subexpression, or `Join-Path` is not.
|
|
157
126
|
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
CC Safety Net denies a tool call before it runs. It does not enforce filesystem permissions, inspect network egress, or contain a process. Two v2 limits matter. First, the policy and sensitive-path command extractors remain mainly POSIX-oriented. Native PowerShell path expressions such as `Get-Content $HOME\.ssh\id_rsa` can evade static path extraction. Second, policy-file protection is a best-effort exact-path guard. It does not emulate commands. Use operating-system permissions, a sandbox, or equivalent runtime controls when you need complete protection.
|
|
127
|
+
Policy-file protection matches exact paths. It does not emulate commands. Use OS permissions or a sandbox when you need that.
|
|
161
128
|
|
|
162
129
|
Codex has one integration-specific limit. Its unified exec path is the default on macOS and Linux. It sends a hook payload when a command starts a session, but it sends none for `write_stdin`. CC Safety Net can inspect and audit the command that opens the session. It cannot inspect or audit text that the model types into the running session. Codex emits no event for that call, so an adapter change cannot close this gap.
|
|
163
130
|
|
|
@@ -167,6 +134,8 @@ Codex has one integration-specific limit. Its unified exec path is the default o
|
|
|
167
134
|
|
|
168
135
|
Run the `update` command from [Quick start](#quick-start) to upgrade every installed integration to the current release.
|
|
169
136
|
|
|
137
|
+
If you installed rulebooks from GitHub on version 2.2 or earlier, run `npx -y cc-safety-net rule sync` once per scope after upgrading. Add `--global` for user-scope sources. Rulebooks are now live files in your config. The command copies each cached rulebook into that location and removes the leftovers. Until you run it, those GitHub-sourced rules are inactive. `status` and `doctor` report the degraded sources.
|
|
138
|
+
|
|
170
139
|
> [!WARNING]
|
|
171
140
|
> If you defined custom rules in a legacy inline config such as `.safety-net.json` or `~/.cc-safety-net/config.json`, CC Safety Net no longer loads those files at runtime. Their rules enforce nothing. Normal use does not show this failure because the commands now run. Run `npx -y cc-safety-net rule migrate` to convert the rules to the rulebook layout. Then run `npx -y cc-safety-net doctor` and confirm that the runtime is `ready`. See the [migration guide](https://ccsafetynet.com/docs/configuration/custom-rules#migrate-legacy-configuration).
|
|
172
141
|
|
|
@@ -176,12 +145,45 @@ The **[ccsafetynet.com/docs](https://ccsafetynet.com/docs)** site contains the f
|
|
|
176
145
|
|
|
177
146
|
| Area | Pages |
|
|
178
147
|
|---|---|
|
|
179
|
-
| Get started | [Introduction](https://ccsafetynet.com/docs/introduction) · [Installation](https://ccsafetynet.com/docs/installation) · [Quickstart](https://ccsafetynet.com/docs/quickstart) · [How It Works](https://ccsafetynet.com/docs/guides/how-it-works) · [Dashboard](https://ccsafetynet.com/docs/guides/dashboard) |
|
|
180
|
-
| Configuration | [Modes](https://ccsafetynet.com/docs/configuration/modes) · [Policy](https://ccsafetynet.com/docs/configuration/policy) · [Environment](https://ccsafetynet.com/docs/configuration/environment) · [Custom Rules](https://ccsafetynet.com/docs/configuration/custom-rules) · [Status Line](https://ccsafetynet.com/docs/configuration/status-line) · [Configuration Recovery](https://ccsafetynet.com/docs/configuration/recovery) |
|
|
148
|
+
| Get started | [Introduction](https://ccsafetynet.com/docs/introduction) · [Installation](https://ccsafetynet.com/docs/installation) · [Quickstart](https://ccsafetynet.com/docs/quickstart) · [Team Setup](https://ccsafetynet.com/docs/guides/team-setup) · [Cloud Environments](https://ccsafetynet.com/docs/guides/cloud-environments) · [How It Works](https://ccsafetynet.com/docs/guides/how-it-works) · [Dashboard](https://ccsafetynet.com/docs/guides/dashboard) |
|
|
149
|
+
| Configuration | [Modes](https://ccsafetynet.com/docs/configuration/modes) · [Policy](https://ccsafetynet.com/docs/configuration/policy) · [Environment](https://ccsafetynet.com/docs/configuration/environment) · [Custom Rules](https://ccsafetynet.com/docs/configuration/custom-rules) · [Official Rulebooks](https://ccsafetynet.com/docs/configuration/rulebooks) · [Status Line](https://ccsafetynet.com/docs/configuration/status-line) · [Configuration Recovery](https://ccsafetynet.com/docs/configuration/recovery) |
|
|
181
150
|
| Reference | [Blocked Commands](https://ccsafetynet.com/docs/reference/blocked-commands) · [Allowed Commands](https://ccsafetynet.com/docs/reference/allowed-commands) · [Secret Protection](https://ccsafetynet.com/docs/reference/secret-protection) · [Audit Log](https://ccsafetynet.com/docs/reference/audit-log) · [CLI Commands](https://ccsafetynet.com/docs/reference/cli-commands) · [Explain Trace](https://ccsafetynet.com/docs/reference/explain-trace) · [Glossary](https://ccsafetynet.com/docs/reference/glossary) |
|
|
182
|
-
| Guides | [Architecture](https://ccsafetynet.com/docs/guides/architecture) · [Analysis Engine](https://ccsafetynet.com/docs/guides/analysis-engine) · [Design Principles](https://ccsafetynet.com/docs/guides/design-principles) · [Security Model](https://ccsafetynet.com/docs/guides/security-model) · [vs Sandboxing](https://ccsafetynet.com/docs/guides/vs-sandboxing) · [Integration Architecture](https://ccsafetynet.com/docs/guides/integration-architecture) · [Known Limitations](https://ccsafetynet.com/docs/guides/known-limitations) · [Troubleshooting](https://ccsafetynet.com/docs/guides/troubleshooting) |
|
|
151
|
+
| Guides | [Architecture](https://ccsafetynet.com/docs/guides/architecture) · [Analysis Engine](https://ccsafetynet.com/docs/guides/analysis-engine) · [Design Principles](https://ccsafetynet.com/docs/guides/design-principles) · [Security Model](https://ccsafetynet.com/docs/guides/security-model) · [vs Sandboxing](https://ccsafetynet.com/docs/guides/vs-sandboxing) · [Integration Architecture](https://ccsafetynet.com/docs/guides/integration-architecture) · [Embedding](https://ccsafetynet.com/docs/guides/embedding) · [Known Limitations](https://ccsafetynet.com/docs/guides/known-limitations) · [Troubleshooting](https://ccsafetynet.com/docs/guides/troubleshooting) |
|
|
183
152
|
| Project | [Contributing](https://ccsafetynet.com/docs/contributing) · [Security Policy](https://ccsafetynet.com/docs/security) |
|
|
184
153
|
|
|
154
|
+
## The cc-safety-net skill
|
|
155
|
+
|
|
156
|
+
The skill is the operating manual for CC Safety Net. Ask it anything about the tool: why a command was blocked, whether a block was wrong, how to write or migrate custom rules, how to change the policy or safety level, how to install or remove an integration, or whether protection is working at all. When the CLI output cannot settle a question, it reads the source of the installed version and answers from that.
|
|
157
|
+
|
|
158
|
+
```text
|
|
159
|
+
/cc-safety-net why was my last git command blocked
|
|
160
|
+
/cc-safety-net block terraform destroy in this repo
|
|
161
|
+
/cc-safety-net is secret protection active in Codex?
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
The command ships with the Claude Code plugin and is built into the OpenCode and Pi integrations. The skill loads only when you invoke it, so it takes no context-window space until you type the command. The agent cannot trigger it on its own.
|
|
165
|
+
|
|
166
|
+
## Library API
|
|
167
|
+
|
|
168
|
+
To check a command from Node.js without installing the hook:
|
|
169
|
+
|
|
170
|
+
```bash
|
|
171
|
+
npm install cc-safety-net
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
```ts
|
|
175
|
+
import { checkCommand } from 'cc-safety-net/api';
|
|
176
|
+
|
|
177
|
+
const result = checkCommand({ command: 'git status', cwd: process.cwd() });
|
|
178
|
+
if (result.kind !== 'allow') {
|
|
179
|
+
throw new Error(result.reason);
|
|
180
|
+
}
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
`cwd` must be an absolute directory path. If `checkCommand` throws, do not run the command.
|
|
184
|
+
|
|
185
|
+
A full example is in [Embedding](https://ccsafetynet.com/docs/guides/embedding).
|
|
186
|
+
|
|
185
187
|
## Development
|
|
186
188
|
|
|
187
189
|
See [CONTRIBUTING.md](CONTRIBUTING.md) to contribute to the project.
|