cc-safety-net 1.0.6 → 2.0.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/LICENSE +1 -1
- package/README.md +177 -877
- package/THIRD_PARTY_LICENSES.txt +23 -0
- package/dist/amp/cc-safety-net.ts +102 -0
- package/dist/bin/cc-safety-net.js +4825 -10427
- package/dist/chunks/index-25nh5wqs.js +45 -0
- package/dist/chunks/index-9s8cwhj0.js +64 -0
- package/dist/index.d.ts +2 -15
- package/dist/index.js +1 -6404
- package/dist/openclaw/cc-safety-net/index.js +101 -0
- package/dist/openclaw/cc-safety-net/openclaw.plugin.json +14 -0
- package/dist/openclaw/cc-safety-net/package.json +11 -0
- package/dist/pi/index.js +2 -6540
- package/package.json +55 -30
- package/dist/bin/cc-safety-net.d.ts +0 -2
- package/dist/bin/commands/doctor.d.ts +0 -11
- package/dist/bin/commands/explain.d.ts +0 -16
- package/dist/bin/commands/hook.d.ts +0 -14
- package/dist/bin/commands/index.d.ts +0 -82
- package/dist/bin/commands/rule.d.ts +0 -14
- package/dist/bin/commands/statusline.d.ts +0 -10
- package/dist/bin/commands/types.d.ts +0 -45
- package/dist/bin/doctor/activity.d.ts +0 -5
- package/dist/bin/doctor/config.d.ts +0 -15
- package/dist/bin/doctor/environment.d.ts +0 -5
- package/dist/bin/doctor/flags.d.ts +0 -5
- package/dist/bin/doctor/format.d.ts +0 -37
- package/dist/bin/doctor/hooks.d.ts +0 -25
- package/dist/bin/doctor/index.d.ts +0 -6
- package/dist/bin/doctor/system-info.d.ts +0 -29
- package/dist/bin/doctor/types.d.ts +0 -159
- package/dist/bin/doctor/updates.d.ts +0 -5
- package/dist/bin/explain/analyze.d.ts +0 -5
- package/dist/bin/explain/config.d.ts +0 -25
- package/dist/bin/explain/flags.d.ts +0 -9
- package/dist/bin/explain/format-helpers.d.ts +0 -35
- package/dist/bin/explain/format.d.ts +0 -8
- package/dist/bin/explain/index.d.ts +0 -7
- package/dist/bin/explain/redact.d.ts +0 -20
- package/dist/bin/explain/segment.d.ts +0 -11
- package/dist/bin/help.d.ts +0 -19
- package/dist/bin/hook/claude-code.d.ts +0 -1
- package/dist/bin/hook/common.d.ts +0 -18
- package/dist/bin/hook/config-edit.d.ts +0 -11
- package/dist/bin/hook/constants.d.ts +0 -6
- package/dist/bin/hook/copilot-cli.d.ts +0 -1
- package/dist/bin/hook/gemini-cli.d.ts +0 -1
- package/dist/bin/hook/install/kimi-code.d.ts +0 -3
- package/dist/bin/hook/install/types.d.ts +0 -4
- package/dist/bin/hook/install.d.ts +0 -3
- package/dist/bin/hook/integrations.d.ts +0 -12
- package/dist/bin/hook/kimi-code.d.ts +0 -1
- package/dist/bin/integration-metadata.d.ts +0 -68
- package/dist/bin/rule/doc.d.ts +0 -1
- package/dist/bin/rule/format.d.ts +0 -14
- package/dist/bin/rule/index.d.ts +0 -1
- package/dist/bin/rule/migrate.d.ts +0 -6
- package/dist/bin/rule/verify.d.ts +0 -9
- package/dist/bin/statusline.d.ts +0 -1
- package/dist/bin/utils/colors.d.ts +0 -36
- package/dist/builtin-commands/templates/cc-safety-net.d.ts +0 -1
- package/dist/core/analyze/analyze-command.d.ts +0 -6
- package/dist/core/analyze/awk.d.ts +0 -3
- package/dist/core/analyze/child-analyzer.d.ts +0 -16
- package/dist/core/analyze/child-command.d.ts +0 -15
- package/dist/core/analyze/constants.d.ts +0 -1
- package/dist/core/analyze/dangerous-text.d.ts +0 -1
- package/dist/core/analyze/find.d.ts +0 -8
- package/dist/core/analyze/index.d.ts +0 -4
- package/dist/core/analyze/interpreters.d.ts +0 -2
- package/dist/core/analyze/parallel.d.ts +0 -13
- package/dist/core/analyze/rm-flags.d.ts +0 -1
- package/dist/core/analyze/rm.d.ts +0 -9
- package/dist/core/analyze/segment.d.ts +0 -11
- package/dist/core/analyze/shell-git-env.d.ts +0 -10
- package/dist/core/analyze/shell-wrappers.d.ts +0 -1
- package/dist/core/analyze/tmpdir.d.ts +0 -1
- package/dist/core/analyze/xargs.d.ts +0 -16
- package/dist/core/audit.d.ts +0 -20
- package/dist/core/config.d.ts +0 -14
- package/dist/core/env.d.ts +0 -39
- package/dist/core/format.d.ts +0 -11
- package/dist/core/git/config.d.ts +0 -1
- package/dist/core/git/env.d.ts +0 -15
- package/dist/core/git/index.d.ts +0 -3
- package/dist/core/git/parse.d.ts +0 -9
- package/dist/core/git/rules.d.ts +0 -8
- package/dist/core/git/worktree-relaxation.d.ts +0 -11
- package/dist/core/git/worktree.d.ts +0 -11
- package/dist/core/path.d.ts +0 -1
- package/dist/core/rules/custom-rule-validation.d.ts +0 -5
- package/dist/core/rules/custom.d.ts +0 -2
- package/dist/core/rules/policy/config-file.d.ts +0 -19
- package/dist/core/rules/policy/index.d.ts +0 -5
- package/dist/core/rules/policy/lockfile.d.ts +0 -5
- package/dist/core/rules/policy/paths.d.ts +0 -32
- package/dist/core/rules/policy/resolver.d.ts +0 -16
- package/dist/core/rules/policy/scope-policy.d.ts +0 -19
- package/dist/core/rules/policy/sources.d.ts +0 -28
- package/dist/core/rules/policy/sync.d.ts +0 -10
- package/dist/core/rules/policy/types.d.ts +0 -76
- package/dist/core/rules/rulebook.d.ts +0 -30
- package/dist/core/shell/command.d.ts +0 -2
- package/dist/core/shell/index.d.ts +0 -4
- package/dist/core/shell/options.d.ts +0 -3
- package/dist/core/shell/segments.d.ts +0 -6
- package/dist/core/shell/shared.d.ts +0 -4
- package/dist/core/shell/wrappers.d.ts +0 -17
- package/dist/opencode/builtin-commands/commands.d.ts +0 -2
- package/dist/opencode/builtin-commands/index.d.ts +0 -2
- package/dist/opencode/builtin-commands/types.d.ts +0 -6
- package/dist/pi/builtin-commands/commands.d.ts +0 -16
- package/dist/pi/builtin-commands/index.d.ts +0 -1
- package/dist/pi/index.d.ts +0 -5
- package/dist/pi/tool-call.d.ts +0 -21
- package/dist/types.d.ts +0 -275
package/dist/types.d.ts
DELETED
|
@@ -1,275 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Shared types for the safety-net plugin.
|
|
3
|
-
*/
|
|
4
|
-
/** Custom blocking rule definition. */
|
|
5
|
-
export interface CustomRule {
|
|
6
|
-
/** Unique identifier for the rule */
|
|
7
|
-
name: string;
|
|
8
|
-
/** Base command to match (e.g., "git", "npm") */
|
|
9
|
-
command: string;
|
|
10
|
-
/** Optional subcommand to match (e.g., "add", "install") */
|
|
11
|
-
subcommand?: string;
|
|
12
|
-
/** Arguments that trigger the block */
|
|
13
|
-
block_args: string[];
|
|
14
|
-
/** Message shown when blocked */
|
|
15
|
-
reason: string;
|
|
16
|
-
}
|
|
17
|
-
/** Runtime configuration used by command analysis. */
|
|
18
|
-
export interface Config {
|
|
19
|
-
/** Schema version (must be 1) */
|
|
20
|
-
version: number;
|
|
21
|
-
/** Custom blocking rules */
|
|
22
|
-
rules: CustomRule[];
|
|
23
|
-
/** Fail-closed reason when rule-backed config cannot be loaded safely. */
|
|
24
|
-
failClosedReason?: string;
|
|
25
|
-
}
|
|
26
|
-
/** Result of config validation */
|
|
27
|
-
export interface ValidationResult {
|
|
28
|
-
/** List of validation error messages */
|
|
29
|
-
errors: string[];
|
|
30
|
-
/** Set of rule names found (for duplicate detection) */
|
|
31
|
-
ruleNames: Set<string>;
|
|
32
|
-
}
|
|
33
|
-
/** Result of command analysis */
|
|
34
|
-
export interface AnalyzeResult {
|
|
35
|
-
/** The reason the command was blocked */
|
|
36
|
-
reason: string;
|
|
37
|
-
/** The specific segment that triggered the block */
|
|
38
|
-
segment: string;
|
|
39
|
-
/** Whether the caller should ask for manual permission instead of auto-denying. */
|
|
40
|
-
manualPermissionAdvice?: boolean;
|
|
41
|
-
}
|
|
42
|
-
/** Claude Code hook input format */
|
|
43
|
-
export interface HookInput {
|
|
44
|
-
session_id?: string;
|
|
45
|
-
transcript_path?: string;
|
|
46
|
-
cwd?: string;
|
|
47
|
-
permission_mode?: string;
|
|
48
|
-
hook_event_name: string;
|
|
49
|
-
tool_name: string;
|
|
50
|
-
tool_input: {
|
|
51
|
-
command: string;
|
|
52
|
-
description?: string;
|
|
53
|
-
};
|
|
54
|
-
tool_use_id?: string;
|
|
55
|
-
}
|
|
56
|
-
/** Claude Code hook output format */
|
|
57
|
-
export interface HookOutput {
|
|
58
|
-
hookSpecificOutput: {
|
|
59
|
-
hookEventName: string;
|
|
60
|
-
permissionDecision: 'allow' | 'deny';
|
|
61
|
-
permissionDecisionReason?: string;
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
/** Gemini CLI hook input format */
|
|
65
|
-
export interface GeminiHookInput {
|
|
66
|
-
session_id?: string;
|
|
67
|
-
transcript_path?: string;
|
|
68
|
-
cwd?: string;
|
|
69
|
-
hook_event_name: string;
|
|
70
|
-
timestamp?: string;
|
|
71
|
-
tool_name?: string;
|
|
72
|
-
tool_input?: {
|
|
73
|
-
command?: string;
|
|
74
|
-
[key: string]: unknown;
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
/** Gemini CLI hook output format */
|
|
78
|
-
export interface GeminiHookOutput {
|
|
79
|
-
decision: 'deny';
|
|
80
|
-
reason: string;
|
|
81
|
-
systemMessage: string;
|
|
82
|
-
continue?: boolean;
|
|
83
|
-
stopReason?: string;
|
|
84
|
-
suppressOutput?: boolean;
|
|
85
|
-
}
|
|
86
|
-
/** Kimi Code hook input format */
|
|
87
|
-
export interface KimiCodeHookInput {
|
|
88
|
-
session_id?: string;
|
|
89
|
-
cwd?: string;
|
|
90
|
-
hook_event_name: string;
|
|
91
|
-
tool_name?: string;
|
|
92
|
-
tool_input?: {
|
|
93
|
-
command?: string;
|
|
94
|
-
[key: string]: unknown;
|
|
95
|
-
};
|
|
96
|
-
tool_call_id?: string;
|
|
97
|
-
}
|
|
98
|
-
/** GitHub Copilot CLI preToolUse hook input format */
|
|
99
|
-
export interface CopilotCliHookInput {
|
|
100
|
-
timestamp: number;
|
|
101
|
-
cwd: string;
|
|
102
|
-
toolName: string;
|
|
103
|
-
toolArgs: string;
|
|
104
|
-
}
|
|
105
|
-
/** GitHub Copilot CLI preToolUse hook output format */
|
|
106
|
-
export interface CopilotCliHookOutput {
|
|
107
|
-
permissionDecision: 'allow' | 'deny' | 'ask';
|
|
108
|
-
permissionDecisionReason?: string;
|
|
109
|
-
}
|
|
110
|
-
/** Options for command analysis */
|
|
111
|
-
export interface AnalyzeOptions {
|
|
112
|
-
/** Current working directory */
|
|
113
|
-
cwd?: string;
|
|
114
|
-
/** Effective cwd after cd commands (null = unknown, undefined = use cwd) */
|
|
115
|
-
effectiveCwd?: string | null;
|
|
116
|
-
/** Environment assignments inherited by nested command analysis */
|
|
117
|
-
envAssignments?: ReadonlyMap<string, string>;
|
|
118
|
-
/** Loaded configuration */
|
|
119
|
-
config?: Config;
|
|
120
|
-
/** Fail-closed on unparseable commands */
|
|
121
|
-
strict?: boolean;
|
|
122
|
-
/** Block non-temp rm -rf even within cwd */
|
|
123
|
-
paranoidRm?: boolean;
|
|
124
|
-
/** Block interpreter one-liners */
|
|
125
|
-
paranoidInterpreters?: boolean;
|
|
126
|
-
/** Allow local Git discard commands in linked worktrees */
|
|
127
|
-
worktreeMode?: boolean;
|
|
128
|
-
/** Allow $TMPDIR paths (false when TMPDIR is overridden to non-temp) */
|
|
129
|
-
allowTmpdirVar?: boolean;
|
|
130
|
-
}
|
|
131
|
-
export interface AnalyzeNestedOverrides {
|
|
132
|
-
effectiveCwd?: string | null;
|
|
133
|
-
envAssignments?: ReadonlyMap<string, string>;
|
|
134
|
-
worktreeMode?: boolean;
|
|
135
|
-
}
|
|
136
|
-
/** Audit log entry */
|
|
137
|
-
export interface AuditLogEntry {
|
|
138
|
-
ts: string;
|
|
139
|
-
decision?: 'allow' | 'deny';
|
|
140
|
-
command: string;
|
|
141
|
-
segment: string;
|
|
142
|
-
reason: string;
|
|
143
|
-
cwd?: string | null;
|
|
144
|
-
}
|
|
145
|
-
/** Constants */
|
|
146
|
-
export declare const MAX_RECURSION_DEPTH = 10;
|
|
147
|
-
export declare const MAX_STRIP_ITERATIONS = 20;
|
|
148
|
-
export declare const NAME_PATTERN: RegExp;
|
|
149
|
-
export declare const COMMAND_PATTERN: RegExp;
|
|
150
|
-
export declare const MAX_REASON_LENGTH = 256;
|
|
151
|
-
/** Shell operators that split commands */
|
|
152
|
-
export declare const SHELL_OPERATORS: Set<string>;
|
|
153
|
-
/** Shell wrappers that need recursive analysis */
|
|
154
|
-
export declare const SHELL_WRAPPERS: Set<string>;
|
|
155
|
-
/** Interpreters that can execute code */
|
|
156
|
-
export declare const INTERPRETERS: Set<string>;
|
|
157
|
-
/** Dangerous commands to detect in interpreter code */
|
|
158
|
-
export declare const DANGEROUS_PATTERNS: RegExp[];
|
|
159
|
-
export declare const PARANOID_INTERPRETERS_SUFFIX = "\n\n(Paranoid mode: interpreter one-liners are blocked.)";
|
|
160
|
-
/** Trace step for explain command - discriminated union of all step types */
|
|
161
|
-
export type TraceStep = {
|
|
162
|
-
type: 'parse';
|
|
163
|
-
input: string;
|
|
164
|
-
segments: string[][];
|
|
165
|
-
} | {
|
|
166
|
-
type: 'env-strip';
|
|
167
|
-
input: string[];
|
|
168
|
-
envVars: Record<string, '<redacted>'>;
|
|
169
|
-
output: string[];
|
|
170
|
-
} | {
|
|
171
|
-
type: 'leading-tokens-stripped';
|
|
172
|
-
input: string[];
|
|
173
|
-
removed: string[];
|
|
174
|
-
output: string[];
|
|
175
|
-
} | {
|
|
176
|
-
type: 'shell-wrapper';
|
|
177
|
-
wrapper: string;
|
|
178
|
-
innerCommand: string;
|
|
179
|
-
} | {
|
|
180
|
-
type: 'interpreter';
|
|
181
|
-
interpreter: string;
|
|
182
|
-
codeArg: string;
|
|
183
|
-
paranoidBlocked: boolean;
|
|
184
|
-
} | {
|
|
185
|
-
type: 'busybox';
|
|
186
|
-
subcommand: string;
|
|
187
|
-
} | {
|
|
188
|
-
type: 'recurse';
|
|
189
|
-
reason: 'shell-wrapper' | 'interpreter' | 'busybox';
|
|
190
|
-
innerCommand: string;
|
|
191
|
-
depth: number;
|
|
192
|
-
} | {
|
|
193
|
-
type: 'rule-check';
|
|
194
|
-
ruleModule: string;
|
|
195
|
-
ruleFunction: string;
|
|
196
|
-
matched: boolean;
|
|
197
|
-
reason?: string;
|
|
198
|
-
} | {
|
|
199
|
-
type: 'worktree-relaxation';
|
|
200
|
-
originalReason: string;
|
|
201
|
-
gitCwd: string;
|
|
202
|
-
} | {
|
|
203
|
-
type: 'tmpdir-check';
|
|
204
|
-
tmpdirValue: string | null;
|
|
205
|
-
isOverriddenToNonTemp: boolean;
|
|
206
|
-
allowTmpdirVar: boolean;
|
|
207
|
-
} | {
|
|
208
|
-
type: 'fallback-scan';
|
|
209
|
-
tokensScanned: string[];
|
|
210
|
-
embeddedCommandFound?: string;
|
|
211
|
-
} | {
|
|
212
|
-
type: 'custom-rules-check';
|
|
213
|
-
rulesChecked: boolean;
|
|
214
|
-
matched: boolean;
|
|
215
|
-
reason?: string;
|
|
216
|
-
} | {
|
|
217
|
-
type: 'cwd-change';
|
|
218
|
-
segment: string;
|
|
219
|
-
effectiveCwdNowUnknown: true;
|
|
220
|
-
} | {
|
|
221
|
-
type: 'dangerous-text';
|
|
222
|
-
token: string;
|
|
223
|
-
matched: boolean;
|
|
224
|
-
reason?: string;
|
|
225
|
-
} | {
|
|
226
|
-
type: 'strict-unparseable';
|
|
227
|
-
rawCommand: string;
|
|
228
|
-
reason: string;
|
|
229
|
-
} | {
|
|
230
|
-
type: 'segment-skipped';
|
|
231
|
-
index: number;
|
|
232
|
-
reason: 'prior-segment-blocked';
|
|
233
|
-
} | {
|
|
234
|
-
type: 'error';
|
|
235
|
-
message: string;
|
|
236
|
-
partial?: boolean;
|
|
237
|
-
};
|
|
238
|
-
/** Trace data for explain command */
|
|
239
|
-
export interface ExplainTrace {
|
|
240
|
-
steps: TraceStep[];
|
|
241
|
-
segments: {
|
|
242
|
-
index: number;
|
|
243
|
-
steps: TraceStep[];
|
|
244
|
-
}[];
|
|
245
|
-
}
|
|
246
|
-
/** Options for explain command */
|
|
247
|
-
export interface ExplainOptions {
|
|
248
|
-
json?: boolean;
|
|
249
|
-
cwd?: string;
|
|
250
|
-
userConfigDir?: string;
|
|
251
|
-
asciiOnly?: boolean;
|
|
252
|
-
strict?: boolean;
|
|
253
|
-
config?: Config;
|
|
254
|
-
}
|
|
255
|
-
/** Result of explain command */
|
|
256
|
-
export interface ExplainResult {
|
|
257
|
-
trace: ExplainTrace;
|
|
258
|
-
result: 'blocked' | 'allowed';
|
|
259
|
-
reason?: string;
|
|
260
|
-
segment?: string;
|
|
261
|
-
customRule?: {
|
|
262
|
-
id: string;
|
|
263
|
-
rulebook?: {
|
|
264
|
-
name: string;
|
|
265
|
-
version: string;
|
|
266
|
-
};
|
|
267
|
-
source?: string;
|
|
268
|
-
override?: {
|
|
269
|
-
type: 'reason';
|
|
270
|
-
reason: string;
|
|
271
|
-
};
|
|
272
|
-
};
|
|
273
|
-
configSource: string | null;
|
|
274
|
-
configValid: boolean;
|
|
275
|
-
}
|