cc-safety-net 2.0.11 → 2.1.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 +47 -2
- package/dist/amp/cc-safety-net/index.ts +6 -6
- package/dist/api.d.ts +18 -0
- package/dist/api.js +1 -0
- package/dist/bin/cc-safety-net.js +84 -84
- package/dist/chunks/index-4g6x1r63.js +46 -0
- package/dist/chunks/index-znwvxg7d.js +18 -0
- package/dist/index.js +1 -1
- package/dist/openclaw/cc-safety-net/index.js +6 -6
- 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 +6 -2
- package/dist/chunks/index-9dxxkq16.js +0 -62
package/README.md
CHANGED
|
@@ -146,6 +146,50 @@ npx cc-safety-net gui
|
|
|
146
146
|
|
|
147
147
|
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).
|
|
148
148
|
|
|
149
|
+
## Library API
|
|
150
|
+
|
|
151
|
+
Node.js hosts that need an in-process allow or deny decision can call the command-check
|
|
152
|
+
function directly instead of installing an agent integration:
|
|
153
|
+
|
|
154
|
+
```bash
|
|
155
|
+
npm install cc-safety-net
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
```ts
|
|
159
|
+
import { checkCommand } from 'cc-safety-net/api';
|
|
160
|
+
|
|
161
|
+
function commandIsAllowed(command: string, cwd: string): boolean {
|
|
162
|
+
try {
|
|
163
|
+
const result = checkCommand({ command, cwd });
|
|
164
|
+
if (result.kind === 'allow') return true;
|
|
165
|
+
console.error(result.reason);
|
|
166
|
+
return false;
|
|
167
|
+
} catch (error) {
|
|
168
|
+
console.error('CC Safety Net could not check the command', error);
|
|
169
|
+
return false;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
if (commandIsAllowed('git status', process.cwd())) {
|
|
174
|
+
// The host can now decide how to run the command.
|
|
175
|
+
}
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
Usage rules:
|
|
179
|
+
|
|
180
|
+
- Requires Node.js 18 or later and ESM. There is no CommonJS build.
|
|
181
|
+
- `cwd` is required and must be an absolute directory path. It anchors relative command
|
|
182
|
+
targets and selects the project policy, so the API never defaults to hidden process state.
|
|
183
|
+
- The function reads local policy files, filesystem facts, and `CC_SAFETY_NET_*` environment
|
|
184
|
+
settings on each call. An invalid `CC_SAFETY_NET_LEVEL` is ignored and reported to stderr.
|
|
185
|
+
It does not run the command, write audit logs, change configuration, or make network requests.
|
|
186
|
+
- Commands are fully checked, including secret file access performed through commands. The
|
|
187
|
+
host's own non-shell file tools (read, write, edit, search) are not checked by this function.
|
|
188
|
+
- A `deny` result means the host must not execute the command. **If `checkCommand` throws,
|
|
189
|
+
do not execute the command either.**
|
|
190
|
+
- `reason` is display text; do not parse or compare it. Use the `kind` field for the
|
|
191
|
+
decision and treat the optional `ruleId` as diagnostic data only.
|
|
192
|
+
|
|
149
193
|
## Limitations
|
|
150
194
|
|
|
151
195
|
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.
|
|
@@ -181,8 +225,9 @@ The **[ccsafetynet.com/docs](https://ccsafetynet.com/docs)** site contains the f
|
|
|
181
225
|
|
|
182
226
|
See [CONTRIBUTING.md](CONTRIBUTING.md) to contribute to the project.
|
|
183
227
|
|
|
184
|
-
The repository tracks all
|
|
185
|
-
bundle and its type declarations, the
|
|
228
|
+
The repository tracks all 14 generated files under `dist/`. They include the library
|
|
229
|
+
bundle and its type declarations, the command-check API entry and its declaration, the CLI
|
|
230
|
+
entrypoint, the shared chunks, the vendored Zod copy,
|
|
186
231
|
and the Pi, Amp, and OpenClaw adapter files. Run `bun run verify:package` and
|
|
187
232
|
`bun run verify:repository-plugin` when changing packaging, integrations, or release automation.
|
|
188
233
|
|