@phuetz/code-buddy 0.1.13 → 0.1.14
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 +228 -13
- package/dist/agent/architect-mode.d.ts +11 -0
- package/dist/agent/architect-mode.js +133 -25
- package/dist/agent/architect-mode.js.map +1 -1
- package/dist/agent/codebuddy-agent.d.ts +24 -0
- package/dist/agent/codebuddy-agent.js +118 -16
- package/dist/agent/codebuddy-agent.js.map +1 -1
- package/dist/agent/execution/agent-executor.d.ts +9 -0
- package/dist/agent/execution/agent-executor.js +61 -0
- package/dist/agent/execution/agent-executor.js.map +1 -1
- package/dist/agent/message-queue.d.ts +77 -0
- package/dist/agent/message-queue.js +116 -0
- package/dist/agent/message-queue.js.map +1 -0
- package/dist/agent/middleware/auto-observation.d.ts +37 -0
- package/dist/agent/middleware/auto-observation.js +231 -0
- package/dist/agent/middleware/auto-observation.js.map +1 -0
- package/dist/agent/middleware/index.d.ts +2 -0
- package/dist/agent/middleware/index.js +1 -0
- package/dist/agent/middleware/index.js.map +1 -1
- package/dist/agent/tool-handler.js +3 -2
- package/dist/agent/tool-handler.js.map +1 -1
- package/dist/agent/types.d.ts +7 -2
- package/dist/analytics/budget-alerts.d.ts +81 -0
- package/dist/analytics/budget-alerts.js +126 -0
- package/dist/analytics/budget-alerts.js.map +1 -0
- package/dist/analytics/cost-predictor.d.ts +79 -0
- package/dist/analytics/cost-predictor.js +150 -0
- package/dist/analytics/cost-predictor.js.map +1 -0
- package/dist/analytics/index.d.ts +2 -0
- package/dist/analytics/index.js +2 -0
- package/dist/analytics/index.js.map +1 -1
- package/dist/auth/profile-manager.d.ts +205 -0
- package/dist/auth/profile-manager.js +484 -0
- package/dist/auth/profile-manager.js.map +1 -0
- package/dist/browser-automation/browser-manager.d.ts +79 -1
- package/dist/browser-automation/browser-manager.js +265 -2
- package/dist/browser-automation/browser-manager.js.map +1 -1
- package/dist/browser-automation/profile-manager.d.ts +32 -0
- package/dist/browser-automation/profile-manager.js +83 -0
- package/dist/browser-automation/profile-manager.js.map +1 -0
- package/dist/browser-automation/route-interceptor.d.ts +29 -0
- package/dist/browser-automation/route-interceptor.js +103 -0
- package/dist/browser-automation/route-interceptor.js.map +1 -0
- package/dist/browser-automation/screenshot-annotator.d.ts +23 -0
- package/dist/browser-automation/screenshot-annotator.js +86 -0
- package/dist/browser-automation/screenshot-annotator.js.map +1 -0
- package/dist/browser-automation/types.d.ts +47 -0
- package/dist/channels/discord/client.d.ts +2 -1
- package/dist/channels/discord/client.js +28 -16
- package/dist/channels/discord/client.js.map +1 -1
- package/dist/channels/google-chat/index.d.ts +210 -0
- package/dist/channels/google-chat/index.js +505 -0
- package/dist/channels/google-chat/index.js.map +1 -0
- package/dist/channels/group-security.d.ts +182 -0
- package/dist/channels/group-security.js +407 -0
- package/dist/channels/group-security.js.map +1 -0
- package/dist/channels/index.d.ts +17 -1
- package/dist/channels/index.js +16 -0
- package/dist/channels/index.js.map +1 -1
- package/dist/channels/matrix/index.d.ts +181 -0
- package/dist/channels/matrix/index.js +643 -0
- package/dist/channels/matrix/index.js.map +1 -0
- package/dist/channels/offline-queue.d.ts +92 -0
- package/dist/channels/offline-queue.js +112 -0
- package/dist/channels/offline-queue.js.map +1 -0
- package/dist/channels/reconnection-manager.d.ts +117 -0
- package/dist/channels/reconnection-manager.js +171 -0
- package/dist/channels/reconnection-manager.js.map +1 -0
- package/dist/channels/signal/index.d.ts +184 -0
- package/dist/channels/signal/index.js +488 -0
- package/dist/channels/signal/index.js.map +1 -0
- package/dist/channels/slack/client.d.ts +2 -1
- package/dist/channels/slack/client.js +30 -20
- package/dist/channels/slack/client.js.map +1 -1
- package/dist/channels/teams/index.d.ts +196 -0
- package/dist/channels/teams/index.js +477 -0
- package/dist/channels/teams/index.js.map +1 -0
- package/dist/channels/telegram/client.d.ts +3 -1
- package/dist/channels/telegram/client.js +29 -2
- package/dist/channels/telegram/client.js.map +1 -1
- package/dist/channels/webchat/index.d.ts +103 -0
- package/dist/channels/webchat/index.js +697 -0
- package/dist/channels/webchat/index.js.map +1 -0
- package/dist/channels/whatsapp/index.d.ts +105 -0
- package/dist/channels/whatsapp/index.js +533 -0
- package/dist/channels/whatsapp/index.js.map +1 -0
- package/dist/codebuddy/client.js +6 -3
- package/dist/codebuddy/client.js.map +1 -1
- package/dist/codebuddy/tool-definitions/advanced-tools.d.ts +1 -0
- package/dist/codebuddy/tool-definitions/advanced-tools.js +103 -3
- package/dist/codebuddy/tool-definitions/advanced-tools.js.map +1 -1
- package/dist/codebuddy/tool-definitions/index.d.ts +1 -1
- package/dist/codebuddy/tool-definitions/index.js +1 -1
- package/dist/codebuddy/tool-definitions/index.js.map +1 -1
- package/dist/codebuddy/tools.js +3 -1
- package/dist/codebuddy/tools.js.map +1 -1
- package/dist/commands/cli/config-command.d.ts +8 -0
- package/dist/commands/cli/config-command.js +90 -0
- package/dist/commands/cli/config-command.js.map +1 -0
- package/dist/commands/cli/openclaw-commands.d.ts +12 -0
- package/dist/commands/cli/openclaw-commands.js +446 -0
- package/dist/commands/cli/openclaw-commands.js.map +1 -0
- package/dist/commands/cli/utility-commands.js +30 -0
- package/dist/commands/cli/utility-commands.js.map +1 -1
- package/dist/commands/client-dispatcher.js +22 -2
- package/dist/commands/client-dispatcher.js.map +1 -1
- package/dist/commands/enhanced-command-handler.js +21 -2
- package/dist/commands/enhanced-command-handler.js.map +1 -1
- package/dist/commands/handlers/extra-handlers.d.ts +30 -0
- package/dist/commands/handlers/extra-handlers.js +547 -0
- package/dist/commands/handlers/extra-handlers.js.map +1 -0
- package/dist/commands/handlers/index.d.ts +1 -0
- package/dist/commands/handlers/index.js +2 -0
- package/dist/commands/handlers/index.js.map +1 -1
- package/dist/commands/slash/builtin-commands.js +41 -34
- package/dist/commands/slash/builtin-commands.js.map +1 -1
- package/dist/config/env-schema.d.ts +58 -0
- package/dist/config/env-schema.js +789 -0
- package/dist/config/env-schema.js.map +1 -0
- package/dist/config/feature-flags.js +2 -1
- package/dist/config/feature-flags.js.map +1 -1
- package/dist/context/bootstrap-loader.d.ts +48 -0
- package/dist/context/bootstrap-loader.js +123 -0
- package/dist/context/bootstrap-loader.js.map +1 -0
- package/dist/copilot/copilot-proxy.d.ts +15 -1
- package/dist/copilot/copilot-proxy.js +81 -22
- package/dist/copilot/copilot-proxy.js.map +1 -1
- package/dist/daemon/heartbeat.d.ts +112 -0
- package/dist/daemon/heartbeat.js +339 -0
- package/dist/daemon/heartbeat.js.map +1 -0
- package/dist/desktop-automation/smart-snapshot.d.ts +11 -0
- package/dist/desktop-automation/smart-snapshot.js +28 -0
- package/dist/desktop-automation/smart-snapshot.js.map +1 -1
- package/dist/identity/identity-manager.d.ts +95 -0
- package/dist/identity/identity-manager.js +242 -0
- package/dist/identity/identity-manager.js.map +1 -0
- package/dist/index.js +147 -17
- package/dist/index.js.map +1 -1
- package/dist/integrations/github-integration.js +1 -1
- package/dist/integrations/github-integration.js.map +1 -1
- package/dist/persistence/conversation-branches.js +2 -1
- package/dist/persistence/conversation-branches.js.map +1 -1
- package/dist/persistence/session-store.d.ts +1 -1
- package/dist/persistence/session-store.js +1 -1
- package/dist/persistence/session-store.js.map +1 -1
- package/dist/sandbox/auto-sandbox.d.ts +59 -0
- package/dist/sandbox/auto-sandbox.js +145 -0
- package/dist/sandbox/auto-sandbox.js.map +1 -0
- package/dist/security/audit-logger.d.ts +127 -0
- package/dist/security/audit-logger.js +194 -0
- package/dist/security/audit-logger.js.map +1 -0
- package/dist/security/bash-allowlist/allowlist-store.js +3 -2
- package/dist/security/bash-allowlist/allowlist-store.js.map +1 -1
- package/dist/security/bash-parser.js +0 -2
- package/dist/security/bash-parser.js.map +1 -1
- package/dist/security/code-validator.d.ts +51 -0
- package/dist/security/code-validator.js +185 -0
- package/dist/security/code-validator.js.map +1 -0
- package/dist/security/dangerous-patterns.d.ts +68 -0
- package/dist/security/dangerous-patterns.js +218 -0
- package/dist/security/dangerous-patterns.js.map +1 -0
- package/dist/security/remote-approval.d.ts +65 -0
- package/dist/security/remote-approval.js +138 -0
- package/dist/security/remote-approval.js.map +1 -0
- package/dist/security/security-audit.d.ts +7 -0
- package/dist/security/security-audit.js +23 -0
- package/dist/security/security-audit.js.map +1 -1
- package/dist/security/syntax-validator.d.ts +17 -0
- package/dist/security/syntax-validator.js +292 -0
- package/dist/security/syntax-validator.js.map +1 -0
- package/dist/server/index.js +277 -2
- package/dist/server/index.js.map +1 -1
- package/dist/services/prompt-builder.js +16 -0
- package/dist/services/prompt-builder.js.map +1 -1
- package/dist/skills/hub.d.ts +231 -0
- package/dist/skills/hub.js +694 -0
- package/dist/skills/hub.js.map +1 -0
- package/dist/skills/skill-loader.js +1 -1
- package/dist/skills/skill-loader.js.map +1 -1
- package/dist/skills/skill-manager.js +2 -1
- package/dist/skills/skill-manager.js.map +1 -1
- package/dist/tools/apply-patch.d.ts +1 -0
- package/dist/tools/apply-patch.js +57 -10
- package/dist/tools/apply-patch.js.map +1 -1
- package/dist/tools/bash/bash-tool.d.ts +123 -0
- package/dist/tools/bash/bash-tool.js +549 -0
- package/dist/tools/bash/bash-tool.js.map +1 -0
- package/dist/tools/bash/command-validator.d.ts +49 -0
- package/dist/tools/bash/command-validator.js +223 -0
- package/dist/tools/bash/command-validator.js.map +1 -0
- package/dist/tools/bash/index.d.ts +7 -0
- package/dist/tools/bash/index.js +8 -0
- package/dist/tools/bash/index.js.map +1 -0
- package/dist/tools/bash/security-patterns.d.ts +44 -0
- package/dist/tools/bash/security-patterns.js +234 -0
- package/dist/tools/bash/security-patterns.js.map +1 -0
- package/dist/tools/bash/streaming-executor.d.ts +23 -0
- package/dist/tools/bash/streaming-executor.js +134 -0
- package/dist/tools/bash/streaming-executor.js.map +1 -0
- package/dist/tools/code-formatter.js +41 -27
- package/dist/tools/code-formatter.js.map +1 -1
- package/dist/tools/code-review.js +1 -1
- package/dist/tools/code-review.js.map +1 -1
- package/dist/tools/computer-control-tool.js +21 -0
- package/dist/tools/computer-control-tool.js.map +1 -1
- package/dist/tools/document-tool.js +3 -2
- package/dist/tools/document-tool.js.map +1 -1
- package/dist/tools/git-tool.d.ts +45 -0
- package/dist/tools/git-tool.js +222 -0
- package/dist/tools/git-tool.js.map +1 -1
- package/dist/tools/index.d.ts +1 -1
- package/dist/tools/index.js +1 -1
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/multi-edit.js +31 -3
- package/dist/tools/multi-edit.js.map +1 -1
- package/dist/tools/process-tool.d.ts +69 -0
- package/dist/tools/process-tool.js +222 -0
- package/dist/tools/process-tool.js.map +1 -0
- package/dist/tools/registry/git-tools.d.ts +32 -0
- package/dist/tools/registry/git-tools.js +211 -0
- package/dist/tools/registry/git-tools.js.map +1 -0
- package/dist/tools/registry/index.d.ts +2 -0
- package/dist/tools/registry/index.js +8 -0
- package/dist/tools/registry/index.js.map +1 -1
- package/dist/tools/registry/misc-tools.d.ts +32 -4
- package/dist/tools/registry/misc-tools.js +230 -90
- package/dist/tools/registry/misc-tools.js.map +1 -1
- package/dist/tools/registry/process-tools.d.ts +20 -0
- package/dist/tools/registry/process-tools.js +141 -0
- package/dist/tools/registry/process-tools.js.map +1 -0
- package/dist/tools/registry/types.d.ts +2 -0
- package/dist/ui/components/ChatInterface.js +9 -0
- package/dist/ui/components/ChatInterface.js.map +1 -1
- package/dist/utils/autonomy-manager.js +3 -2
- package/dist/utils/autonomy-manager.js.map +1 -1
- package/dist/utils/config-validation/schema.d.ts +15 -15
- package/dist/utils/confirmation-service.d.ts +16 -0
- package/dist/utils/confirmation-service.js +37 -3
- package/dist/utils/confirmation-service.js.map +1 -1
- package/dist/utils/custom-instructions.js +2 -1
- package/dist/utils/custom-instructions.js.map +1 -1
- package/dist/utils/graceful-shutdown.js +9 -9
- package/dist/utils/graceful-shutdown.js.map +1 -1
- package/dist/utils/head-tail-truncation.d.ts +18 -0
- package/dist/utils/head-tail-truncation.js +127 -0
- package/dist/utils/head-tail-truncation.js.map +1 -1
- package/dist/utils/history-manager.js +3 -2
- package/dist/utils/history-manager.js.map +1 -1
- package/dist/utils/performance.js +16 -15
- package/dist/utils/performance.js.map +1 -1
- package/dist/utils/update-notifier.js +2 -1
- package/dist/utils/update-notifier.js.map +1 -1
- package/dist/workflows/pipeline.d.ts +54 -1
- package/dist/workflows/pipeline.js +128 -7
- package/dist/workflows/pipeline.js.map +1 -1
- package/dist/workflows/step-manager.js +2 -1
- package/dist/workflows/step-manager.js.map +1 -1
- package/package.json +6 -3
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Command validation and environment filtering for BashTool.
|
|
3
|
+
*
|
|
4
|
+
* Contains:
|
|
5
|
+
* - extractBaseCommand: Parses the base command from a shell string
|
|
6
|
+
* - hasShellBypassFeatures: Detects shell features that could bypass validation
|
|
7
|
+
* - validateCommand: Full security validation pipeline
|
|
8
|
+
* - getFilteredEnv: Environment variable filtering for child processes
|
|
9
|
+
*/
|
|
10
|
+
import { BLOCKED_PATTERNS, BLOCKED_CONTROL_CHARS, ANSI_ESCAPE_PATTERN, BLOCKED_COMMANDS, SAFE_ENV_VARS, BLOCKED_PATHS, } from './security-patterns.js';
|
|
11
|
+
import { parseBashCommand } from '../../security/bash-parser.js';
|
|
12
|
+
import { isDangerousCommand } from '../../security/dangerous-patterns.js';
|
|
13
|
+
import { auditLogger } from '../../security/audit-logger.js';
|
|
14
|
+
/**
|
|
15
|
+
* Extract the base command from a command string
|
|
16
|
+
* Handles paths, env var prefixes, and common shell constructs
|
|
17
|
+
*/
|
|
18
|
+
export function extractBaseCommand(command) {
|
|
19
|
+
// Trim and handle empty
|
|
20
|
+
const trimmed = command.trim();
|
|
21
|
+
if (!trimmed)
|
|
22
|
+
return null;
|
|
23
|
+
// Skip leading environment variable assignments (VAR=value cmd)
|
|
24
|
+
let remaining = trimmed;
|
|
25
|
+
while (/^[A-Za-z_][A-Za-z0-9_]*=\S*\s+/.test(remaining)) {
|
|
26
|
+
remaining = remaining.replace(/^[A-Za-z_][A-Za-z0-9_]*=\S*\s+/, '');
|
|
27
|
+
}
|
|
28
|
+
// Get the first token
|
|
29
|
+
const match = remaining.match(/^(\S+)/);
|
|
30
|
+
if (!match)
|
|
31
|
+
return null;
|
|
32
|
+
let cmd = match[1];
|
|
33
|
+
// Remove path prefix (e.g., /usr/bin/ls -> ls)
|
|
34
|
+
if (cmd.includes('/')) {
|
|
35
|
+
cmd = cmd.split('/').pop() || cmd;
|
|
36
|
+
}
|
|
37
|
+
// Handle ./ prefix
|
|
38
|
+
if (cmd.startsWith('./')) {
|
|
39
|
+
cmd = cmd.slice(2);
|
|
40
|
+
}
|
|
41
|
+
return cmd.toLowerCase();
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Check if command uses shell features that could bypass validation
|
|
45
|
+
*/
|
|
46
|
+
export function hasShellBypassFeatures(command) {
|
|
47
|
+
// Check for multiple commands via && || ; |
|
|
48
|
+
// But allow single pipes for grep, etc.
|
|
49
|
+
const multiCommandPatterns = [
|
|
50
|
+
{ pattern: /;\s*\S/, reason: 'Command chaining with semicolon' },
|
|
51
|
+
{ pattern: /&&\s*\S/, reason: 'Command chaining with &&' },
|
|
52
|
+
{ pattern: /\|\|\s*\S/, reason: 'Command chaining with ||' },
|
|
53
|
+
{ pattern: /\|\s*(?:bash|sh|zsh|ksh|csh|fish|dash)\b/i, reason: 'Pipe to shell' },
|
|
54
|
+
];
|
|
55
|
+
for (const { pattern, reason } of multiCommandPatterns) {
|
|
56
|
+
if (pattern.test(command)) {
|
|
57
|
+
// Check if this is a safe pipe (e.g., grep | wc)
|
|
58
|
+
if (reason === 'Pipe to shell') {
|
|
59
|
+
return { bypass: true, reason };
|
|
60
|
+
}
|
|
61
|
+
// For other chaining, check if the second command is safe
|
|
62
|
+
// For now, we'll allow chaining but each command gets validated separately
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
// Check for process substitution
|
|
66
|
+
if (/[<>]\(/.test(command)) {
|
|
67
|
+
return { bypass: true, reason: 'Process substitution detected' };
|
|
68
|
+
}
|
|
69
|
+
// Check for here-string/here-doc that could contain encoded payloads
|
|
70
|
+
if (/<<</.test(command)) {
|
|
71
|
+
return { bypass: true, reason: 'Here-string detected' };
|
|
72
|
+
}
|
|
73
|
+
return { bypass: false };
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Validate command for dangerous patterns
|
|
77
|
+
*
|
|
78
|
+
* Security checks performed (in order):
|
|
79
|
+
* 1. Control characters - blocks terminal manipulation
|
|
80
|
+
* 2. ANSI escape sequences - blocks display manipulation
|
|
81
|
+
* 3. Shell bypass features - blocks process substitution, here-strings, etc.
|
|
82
|
+
* 4. Base command blocklist - blocks known dangerous commands
|
|
83
|
+
* 5. Blocked command patterns - blocks known dangerous patterns
|
|
84
|
+
* 6. Protected paths - blocks access to sensitive directories
|
|
85
|
+
*
|
|
86
|
+
* Note: Sandbox manager validation is performed separately by the caller
|
|
87
|
+
* since it requires instance state.
|
|
88
|
+
*/
|
|
89
|
+
export function validateCommand(command) {
|
|
90
|
+
// Check for dangerous control characters
|
|
91
|
+
if (BLOCKED_CONTROL_CHARS.test(command)) {
|
|
92
|
+
return {
|
|
93
|
+
valid: false,
|
|
94
|
+
reason: 'Command contains blocked control characters'
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
// Check for ANSI escape sequences that could manipulate terminal
|
|
98
|
+
if (ANSI_ESCAPE_PATTERN.test(command)) {
|
|
99
|
+
return {
|
|
100
|
+
valid: false,
|
|
101
|
+
reason: 'Command contains blocked ANSI escape sequences'
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
// Check for shell bypass features
|
|
105
|
+
const bypassCheck = hasShellBypassFeatures(command);
|
|
106
|
+
if (bypassCheck.bypass) {
|
|
107
|
+
return {
|
|
108
|
+
valid: false,
|
|
109
|
+
reason: `Shell bypass blocked: ${bypassCheck.reason}`
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
// Extract base command and check against blocklist
|
|
113
|
+
const baseCmd = extractBaseCommand(command);
|
|
114
|
+
if (baseCmd && BLOCKED_COMMANDS.has(baseCmd)) {
|
|
115
|
+
return {
|
|
116
|
+
valid: false,
|
|
117
|
+
reason: `Blocked command: ${baseCmd}`
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
// Check for blocked patterns
|
|
121
|
+
for (const pattern of BLOCKED_PATTERNS) {
|
|
122
|
+
if (pattern.test(command)) {
|
|
123
|
+
return {
|
|
124
|
+
valid: false,
|
|
125
|
+
reason: `Blocked command pattern detected: ${pattern.source}`
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
// Check for access to blocked paths
|
|
130
|
+
for (const blockedPath of BLOCKED_PATHS) {
|
|
131
|
+
if (command.includes(blockedPath)) {
|
|
132
|
+
auditLogger.logCommandValidation({ command, valid: false, reason: `Protected path: ${blockedPath}`, source: 'command-validator' });
|
|
133
|
+
return {
|
|
134
|
+
valid: false,
|
|
135
|
+
reason: `Access to protected path blocked: ${blockedPath}`
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
// Phase 2: AST-based validation via bash-parser
|
|
140
|
+
// Parse the command into individual commands and validate each
|
|
141
|
+
try {
|
|
142
|
+
const parsed = parseBashCommand(command);
|
|
143
|
+
for (const cmd of parsed.commands) {
|
|
144
|
+
// Check each parsed command name against centralized dangerous commands
|
|
145
|
+
if (isDangerousCommand(cmd.command)) {
|
|
146
|
+
// Allow if it's already in the legacy BLOCKED_COMMANDS (already checked above)
|
|
147
|
+
// This catches commands the regex-based approach might miss
|
|
148
|
+
if (!BLOCKED_COMMANDS.has(cmd.command.toLowerCase())) {
|
|
149
|
+
auditLogger.logCommandValidation({
|
|
150
|
+
command,
|
|
151
|
+
valid: false,
|
|
152
|
+
reason: `Dangerous command detected by parser: ${cmd.command}`,
|
|
153
|
+
source: 'bash-parser',
|
|
154
|
+
});
|
|
155
|
+
return {
|
|
156
|
+
valid: false,
|
|
157
|
+
reason: `Blocked command (AST): ${cmd.command}`,
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
// Check subshell commands too
|
|
162
|
+
if (cmd.isSubshell && isDangerousCommand(cmd.command)) {
|
|
163
|
+
auditLogger.logCommandValidation({
|
|
164
|
+
command,
|
|
165
|
+
valid: false,
|
|
166
|
+
reason: `Dangerous command in subshell: ${cmd.command}`,
|
|
167
|
+
source: 'bash-parser',
|
|
168
|
+
});
|
|
169
|
+
return {
|
|
170
|
+
valid: false,
|
|
171
|
+
reason: `Blocked command in subshell: ${cmd.command}`,
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
catch {
|
|
177
|
+
// If parsing fails, fall through to allow (already validated by regex above)
|
|
178
|
+
}
|
|
179
|
+
auditLogger.logCommandValidation({ command, valid: true, source: 'command-validator' });
|
|
180
|
+
return { valid: true };
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Filter environment variables to only include safe ones
|
|
184
|
+
* This prevents credential leakage to child processes
|
|
185
|
+
*
|
|
186
|
+
* Security measures:
|
|
187
|
+
* - Only allowlisted variable names are passed through
|
|
188
|
+
* - Values containing shell metacharacters are sanitized
|
|
189
|
+
* - Values that look like secrets are excluded
|
|
190
|
+
*/
|
|
191
|
+
export function getFilteredEnv() {
|
|
192
|
+
const filtered = {};
|
|
193
|
+
// Patterns that suggest a value is a secret (even if var name is allowed)
|
|
194
|
+
const secretPatterns = [
|
|
195
|
+
/^sk-[a-zA-Z0-9]{20,}$/, // OpenAI-style keys
|
|
196
|
+
/^xai-[a-zA-Z0-9]{20,}$/, // xAI keys
|
|
197
|
+
/^ghp_[a-zA-Z0-9]{36}$/, // GitHub PAT
|
|
198
|
+
/^gho_[a-zA-Z0-9]{36}$/, // GitHub OAuth
|
|
199
|
+
/^github_pat_/i, // GitHub fine-grained PAT
|
|
200
|
+
/^AKIA[A-Z0-9]{16}$/, // AWS Access Key
|
|
201
|
+
/^npm_[a-zA-Z0-9]{36}$/, // NPM token
|
|
202
|
+
/^eyJ[a-zA-Z0-9_-]+\.[a-zA-Z0-9_-]+\.[a-zA-Z0-9_-]+$/, // JWT
|
|
203
|
+
/^[a-f0-9]{64}$/i, // Hex-encoded secrets (64 chars)
|
|
204
|
+
/^-----BEGIN.*PRIVATE KEY-----/m, // Private keys
|
|
205
|
+
];
|
|
206
|
+
for (const [key, value] of Object.entries(process.env)) {
|
|
207
|
+
if (value === undefined)
|
|
208
|
+
continue;
|
|
209
|
+
// Only allow safe variable names
|
|
210
|
+
if (!SAFE_ENV_VARS.has(key))
|
|
211
|
+
continue;
|
|
212
|
+
// Check if value looks like a secret
|
|
213
|
+
const looksLikeSecret = secretPatterns.some(pattern => pattern.test(value));
|
|
214
|
+
if (looksLikeSecret)
|
|
215
|
+
continue;
|
|
216
|
+
// Sanitize value - remove control characters
|
|
217
|
+
// eslint-disable-next-line no-control-regex
|
|
218
|
+
const sanitized = value.replace(/[\x00-\x1f\x7f]/g, '');
|
|
219
|
+
filtered[key] = sanitized;
|
|
220
|
+
}
|
|
221
|
+
return filtered;
|
|
222
|
+
}
|
|
223
|
+
//# sourceMappingURL=command-validator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command-validator.js","sourceRoot":"","sources":["../../../src/tools/bash/command-validator.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EACL,gBAAgB,EAChB,qBAAqB,EACrB,mBAAmB,EACnB,gBAAgB,EAChB,aAAa,EACb,aAAa,GACd,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,EAAE,kBAAkB,EAAE,MAAM,sCAAsC,CAAC;AAC1E,OAAO,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAE7D;;;GAGG;AACH,MAAM,UAAU,kBAAkB,CAAC,OAAe;IAChD,wBAAwB;IACxB,MAAM,OAAO,GAAG,OAAO,CAA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AAe,EAAe,0BAA0B;QACxD,oBAAoB,EAAU,iBAAiB;QAC/C,uBAAuB,EAAO,YAAY;QAC1C,qDAAqD,EAAE,MAAM;QAC7D,iBAAiB,EAAa,iCAAiC;QAC/D,gCAAgC,EAAE,eAAe;KAClD,CAAC;IAEF,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;QACvD,IAAI,KAAK,KAAK,SAAS;YAAE,SAAS;QAElC,iCAAiC;QACjC,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,GAAG,CAAC;YAAE,SAAS;QAEtC,qCAAqC;QACrC,MAAM,eAAe,GAAG,cAAc,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;QAC5E,IAAI,eAAe;YAAE,SAAS;QAE9B,6CAA6C;QAC7C,4CAA4C;QAC5C,MAAM,SAAS,GAAG,KAAK,CAAC,OAAO,CAAC,kBAAkB,EAAE,EAAE,CAAC,CAAC;QAExD,QAAQ,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC;IAC5B,CAAC;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/tools/bash/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Security patterns and constants for BashTool command validation.
|
|
3
|
+
*
|
|
4
|
+
* Contains:
|
|
5
|
+
* - BLOCKED_PATTERNS: Regex patterns for always-blocked commands
|
|
6
|
+
* - BLOCKED_CONTROL_CHARS: Control characters that are never allowed
|
|
7
|
+
* - ANSI_ESCAPE_PATTERN: Terminal manipulation sequences
|
|
8
|
+
* - ALLOWED_COMMANDS: Allowlist for strict mode (reserved)
|
|
9
|
+
* - BLOCKED_COMMANDS: Commands blocked even in non-strict mode
|
|
10
|
+
* - SAFE_ENV_VARS: Allowlist of environment variables for child processes
|
|
11
|
+
* - BLOCKED_PATHS: Sensitive paths that should never be accessed
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* Dangerous command patterns that are always blocked
|
|
15
|
+
*/
|
|
16
|
+
export declare const BLOCKED_PATTERNS: RegExp[];
|
|
17
|
+
/**
|
|
18
|
+
* Control characters that are never allowed in commands
|
|
19
|
+
* These could be used to manipulate terminal output or bypass validation
|
|
20
|
+
*/
|
|
21
|
+
export declare const BLOCKED_CONTROL_CHARS: RegExp;
|
|
22
|
+
/**
|
|
23
|
+
* ANSI escape sequences that could manipulate terminal display
|
|
24
|
+
*/
|
|
25
|
+
export declare const ANSI_ESCAPE_PATTERN: RegExp;
|
|
26
|
+
/**
|
|
27
|
+
* Allowlist of safe base commands
|
|
28
|
+
* Only commands starting with these are allowed in strict mode
|
|
29
|
+
* Reserved for future strict mode implementation
|
|
30
|
+
*/
|
|
31
|
+
export declare const _ALLOWED_COMMANDS: Set<string>;
|
|
32
|
+
/**
|
|
33
|
+
* Commands that should be completely blocked even in non-strict mode
|
|
34
|
+
*/
|
|
35
|
+
export declare const BLOCKED_COMMANDS: Set<string>;
|
|
36
|
+
/**
|
|
37
|
+
* Whitelist of safe environment variables to pass to child processes
|
|
38
|
+
* All other env vars (especially secrets) are filtered out
|
|
39
|
+
*/
|
|
40
|
+
export declare const SAFE_ENV_VARS: Set<string>;
|
|
41
|
+
/**
|
|
42
|
+
* Paths that should never be accessed
|
|
43
|
+
*/
|
|
44
|
+
export declare const BLOCKED_PATHS: string[];
|
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Security patterns and constants for BashTool command validation.
|
|
3
|
+
*
|
|
4
|
+
* Contains:
|
|
5
|
+
* - BLOCKED_PATTERNS: Regex patterns for always-blocked commands
|
|
6
|
+
* - BLOCKED_CONTROL_CHARS: Control characters that are never allowed
|
|
7
|
+
* - ANSI_ESCAPE_PATTERN: Terminal manipulation sequences
|
|
8
|
+
* - ALLOWED_COMMANDS: Allowlist for strict mode (reserved)
|
|
9
|
+
* - BLOCKED_COMMANDS: Commands blocked even in non-strict mode
|
|
10
|
+
* - SAFE_ENV_VARS: Allowlist of environment variables for child processes
|
|
11
|
+
* - BLOCKED_PATHS: Sensitive paths that should never be accessed
|
|
12
|
+
*/
|
|
13
|
+
import path from 'path';
|
|
14
|
+
import os from 'os';
|
|
15
|
+
/**
|
|
16
|
+
* Dangerous command patterns that are always blocked
|
|
17
|
+
*/
|
|
18
|
+
export const BLOCKED_PATTERNS = [
|
|
19
|
+
// Filesystem destruction
|
|
20
|
+
/rm\s+(-rf?|--recursive)\s+[/~]/i, // rm -rf / or ~
|
|
21
|
+
/rm\s+.*\/\s*$/i, // rm something/
|
|
22
|
+
/>\s*\/dev\/sd[a-z]/i, // Write to disk device
|
|
23
|
+
/dd\s+.*if=.*of=\/dev/i, // dd to device
|
|
24
|
+
/mkfs/i, // Format filesystem
|
|
25
|
+
/:\(\)\s*\{\s*:\|:&\s*\};:/, // Fork bomb :(){ :|:& };:
|
|
26
|
+
/chmod\s+-R\s+777\s+\//i, // chmod 777 /
|
|
27
|
+
// Remote code execution via pipe to shell
|
|
28
|
+
/wget.*\|\s*(ba)?sh/i, // wget | sh
|
|
29
|
+
/curl.*\|\s*(ba)?sh/i, // curl | sh
|
|
30
|
+
/sudo\s+(rm|dd|mkfs)/i, // sudo dangerous commands
|
|
31
|
+
// Command injection via command substitution
|
|
32
|
+
/\$\([^)]*(?:rm|dd|mkfs|chmod|chown|curl|wget|nc|netcat|bash|sh|eval|exec)/i, // $(dangerous_cmd)
|
|
33
|
+
/`[^`]*(?:rm|dd|mkfs|chmod|chown|curl|wget|nc|netcat|bash|sh|eval|exec)/i, // `dangerous_cmd`
|
|
34
|
+
// Dangerous variable expansion that could leak secrets
|
|
35
|
+
/\$\{?(?:GROK_API_KEY|AWS_SECRET|AWS_ACCESS_KEY|AWS_SESSION_TOKEN|GITHUB_TOKEN|NPM_TOKEN|MORPH_API_KEY|DATABASE_URL|DB_PASSWORD|SECRET_KEY|PRIVATE_KEY|API_KEY|API_SECRET|AUTH_TOKEN|ACCESS_TOKEN|OPENAI_API_KEY|ANTHROPIC_API_KEY|SLACK_TOKEN|DISCORD_TOKEN)\}?/i,
|
|
36
|
+
// Eval and exec injection
|
|
37
|
+
/\beval\s+.*\$/i, // eval with variable expansion
|
|
38
|
+
/\bexec\s+\d*[<>]/i, // exec with redirections
|
|
39
|
+
// Hex/octal encoded dangerous commands (bypass attempts)
|
|
40
|
+
/\\x[0-9a-f]{2}/i, // Hex escape sequences
|
|
41
|
+
/\\[0-7]{3}/, // Octal escape sequences
|
|
42
|
+
/\$'\\x/i, // ANSI-C quoting with hex
|
|
43
|
+
/\$'\\[0-7]/, // ANSI-C quoting with octal
|
|
44
|
+
/\$'[^']*\\[nrtbfv]/i, // ANSI-C with escape sequences
|
|
45
|
+
// Base64 decode piped to shell
|
|
46
|
+
/base64\s+(-d|--decode).*\|\s*(ba)?sh/i,
|
|
47
|
+
// Network exfiltration patterns
|
|
48
|
+
/\|\s*(nc|netcat|curl|wget)\s+[^|]*(>|>>)/i, // pipe to network tool with redirect
|
|
49
|
+
/>\s*\/dev\/(tcp|udp)\//i, // bash network redirection
|
|
50
|
+
/\bnc\s+-[elp]/i, // netcat listen/exec modes
|
|
51
|
+
/\bbash\s+-i\s+>&?\s*\/dev\/(tcp|udp)/i, // bash reverse shell
|
|
52
|
+
// Additional bypass patterns
|
|
53
|
+
/\bprintf\s+['"]%b['"].*\\x/i, // printf %b with hex (bypass)
|
|
54
|
+
/\becho\s+-e\s+.*\\x/i, // echo -e with hex
|
|
55
|
+
/\becho\s+\$'\\x/i, // echo with ANSI-C quoting
|
|
56
|
+
/\bxxd\s+-r.*\|\s*(ba)?sh/i, // xxd decode to shell
|
|
57
|
+
/\bpython[23]?\s+-c\s+['"].*(?:exec|eval|os\.system|subprocess|__import__)/i, // Python code exec
|
|
58
|
+
/\bperl\s+-e\s+['"].*(?:system|exec|`)/i, // Perl code exec
|
|
59
|
+
/\bruby\s+-e\s+['"].*(?:system|exec|`)/i, // Ruby code exec
|
|
60
|
+
/\bnode\s+-e\s+['"].*(?:exec|spawn|child_process)/i, // Node.js code exec
|
|
61
|
+
/\bawk\s+.*\bsystem\s*\(/i, // awk system() call
|
|
62
|
+
// Unicode/special character bypass attempts
|
|
63
|
+
// eslint-disable-next-line no-control-regex
|
|
64
|
+
/[\u0000-\u001f]/, // Control characters (except common whitespace handled separately)
|
|
65
|
+
/[\u007f-\u009f]/, // Delete and C1 control codes
|
|
66
|
+
/[\u200b-\u200f]/, // Zero-width and directional chars
|
|
67
|
+
/[\u2028\u2029]/, // Line/paragraph separators
|
|
68
|
+
/[\ufeff]/, // BOM
|
|
69
|
+
/[\ufff0-\uffff]/, // Specials block
|
|
70
|
+
];
|
|
71
|
+
/**
|
|
72
|
+
* Control characters that are never allowed in commands
|
|
73
|
+
* These could be used to manipulate terminal output or bypass validation
|
|
74
|
+
*/
|
|
75
|
+
// eslint-disable-next-line no-control-regex
|
|
76
|
+
export const BLOCKED_CONTROL_CHARS = /[\x00-\x08\x0b\x0c\x0e-\x1f\x7f]/;
|
|
77
|
+
/**
|
|
78
|
+
* ANSI escape sequences that could manipulate terminal display
|
|
79
|
+
*/
|
|
80
|
+
// eslint-disable-next-line no-control-regex
|
|
81
|
+
export const ANSI_ESCAPE_PATTERN = /\x1b\[[0-9;]*[a-zA-Z]|\x1b[PX^_][^\x1b]*\x1b\\|\x1b\][^\x07]*\x07/;
|
|
82
|
+
/**
|
|
83
|
+
* Allowlist of safe base commands
|
|
84
|
+
* Only commands starting with these are allowed in strict mode
|
|
85
|
+
* Reserved for future strict mode implementation
|
|
86
|
+
*/
|
|
87
|
+
export const _ALLOWED_COMMANDS = new Set([
|
|
88
|
+
// File operations (read-only or safe)
|
|
89
|
+
'ls', 'cat', 'head', 'tail', 'less', 'more', 'file', 'stat', 'wc',
|
|
90
|
+
'find', 'locate', 'which', 'whereis', 'type',
|
|
91
|
+
// Text processing
|
|
92
|
+
'grep', 'egrep', 'fgrep', 'rg', 'ag', 'ack',
|
|
93
|
+
'sed', 'awk', 'cut', 'sort', 'uniq', 'tr', 'diff', 'comm',
|
|
94
|
+
// Development tools
|
|
95
|
+
'git', 'npm', 'npx', 'yarn', 'pnpm', 'bun',
|
|
96
|
+
'node', 'deno', 'python', 'python3', 'pip', 'pip3',
|
|
97
|
+
'cargo', 'rustc', 'go', 'java', 'javac', 'mvn', 'gradle',
|
|
98
|
+
'make', 'cmake', 'gcc', 'g++', 'clang',
|
|
99
|
+
// Build and test
|
|
100
|
+
'jest', 'vitest', 'mocha', 'pytest', 'tsc', 'esbuild', 'vite', 'webpack',
|
|
101
|
+
'eslint', 'prettier', 'biome',
|
|
102
|
+
// System info (safe read-only)
|
|
103
|
+
'echo', 'printf', 'pwd', 'date', 'whoami', 'hostname', 'uname',
|
|
104
|
+
'env', 'printenv', 'id', 'groups',
|
|
105
|
+
// Process info
|
|
106
|
+
'ps', 'top', 'htop', 'pgrep',
|
|
107
|
+
// Network diagnostics (read-only)
|
|
108
|
+
'ping', 'dig', 'nslookup', 'host',
|
|
109
|
+
// Archives (read operations)
|
|
110
|
+
'tar', 'zip', 'unzip', 'gzip', 'gunzip', 'bzip2', 'xz',
|
|
111
|
+
// Directory operations
|
|
112
|
+
'mkdir', 'rmdir', 'cd',
|
|
113
|
+
// Safe file operations
|
|
114
|
+
'cp', 'mv', 'touch', 'ln',
|
|
115
|
+
// Docker (controlled)
|
|
116
|
+
'docker', 'docker-compose', 'podman',
|
|
117
|
+
// Kubernetes (controlled)
|
|
118
|
+
'kubectl', 'helm',
|
|
119
|
+
// Cloud CLI (controlled)
|
|
120
|
+
'aws', 'gcloud', 'az',
|
|
121
|
+
// Misc safe commands
|
|
122
|
+
'jq', 'yq', 'tree', 'realpath', 'basename', 'dirname',
|
|
123
|
+
'sleep', 'true', 'false', 'test', '[',
|
|
124
|
+
// Package managers
|
|
125
|
+
'apt', 'apt-get', 'brew', 'dnf', 'yum', 'pacman',
|
|
126
|
+
]);
|
|
127
|
+
/**
|
|
128
|
+
* Commands that should be completely blocked even in non-strict mode
|
|
129
|
+
*/
|
|
130
|
+
export const BLOCKED_COMMANDS = new Set([
|
|
131
|
+
'rm', 'shred', 'wipefs', // Destructive file operations (blocked without confirmation path)
|
|
132
|
+
'mkfs', 'fdisk', 'parted', // Disk operations
|
|
133
|
+
'dd', // Raw disk operations
|
|
134
|
+
'chmod', 'chown', 'chgrp', // Permission changes (blocked at base level)
|
|
135
|
+
'sudo', 'su', 'doas', // Privilege escalation
|
|
136
|
+
'nc', 'netcat', 'ncat', // Network tools that can be dangerous
|
|
137
|
+
'socat', // Socket relay
|
|
138
|
+
'telnet', 'ftp', // Insecure protocols
|
|
139
|
+
'nmap', 'masscan', // Port scanning
|
|
140
|
+
'tcpdump', 'wireshark', 'tshark', // Packet capture
|
|
141
|
+
'strace', 'ltrace', 'ptrace', // Process tracing
|
|
142
|
+
'gdb', 'lldb', // Debuggers (can be abused)
|
|
143
|
+
'reboot', 'shutdown', 'poweroff', 'halt', // System control
|
|
144
|
+
'init', 'systemctl', 'service', // Service control
|
|
145
|
+
'iptables', 'nft', 'firewall-cmd', // Firewall
|
|
146
|
+
'mount', 'umount', // Mount operations
|
|
147
|
+
'insmod', 'rmmod', 'modprobe', // Kernel modules
|
|
148
|
+
'sysctl', // Kernel parameters
|
|
149
|
+
'crontab', 'at', // Scheduled tasks
|
|
150
|
+
'useradd', 'userdel', 'usermod', // User management
|
|
151
|
+
'passwd', 'chpasswd', // Password changes
|
|
152
|
+
'visudo', // Sudoers editing
|
|
153
|
+
'ssh-keygen', 'ssh-add', // SSH key operations
|
|
154
|
+
'gpg', // GPG operations
|
|
155
|
+
'openssl', // Certificate operations (can leak keys)
|
|
156
|
+
]);
|
|
157
|
+
/**
|
|
158
|
+
* Whitelist of safe environment variables to pass to child processes
|
|
159
|
+
* All other env vars (especially secrets) are filtered out
|
|
160
|
+
*/
|
|
161
|
+
export const SAFE_ENV_VARS = new Set([
|
|
162
|
+
// System paths and locale
|
|
163
|
+
'PATH',
|
|
164
|
+
'HOME',
|
|
165
|
+
'USER',
|
|
166
|
+
'SHELL',
|
|
167
|
+
'LANG',
|
|
168
|
+
'LC_ALL',
|
|
169
|
+
'LC_CTYPE',
|
|
170
|
+
'TERM',
|
|
171
|
+
'TZ',
|
|
172
|
+
'TMPDIR',
|
|
173
|
+
'TEMP',
|
|
174
|
+
'TMP',
|
|
175
|
+
// Node.js
|
|
176
|
+
'NODE_ENV',
|
|
177
|
+
'NODE_PATH',
|
|
178
|
+
'NODE_OPTIONS',
|
|
179
|
+
// Development tools
|
|
180
|
+
'EDITOR',
|
|
181
|
+
'VISUAL',
|
|
182
|
+
'PAGER',
|
|
183
|
+
'LESS',
|
|
184
|
+
// Git (non-sensitive)
|
|
185
|
+
'GIT_AUTHOR_NAME',
|
|
186
|
+
'GIT_AUTHOR_EMAIL',
|
|
187
|
+
'GIT_COMMITTER_NAME',
|
|
188
|
+
'GIT_COMMITTER_EMAIL',
|
|
189
|
+
'GIT_TERMINAL_PROMPT',
|
|
190
|
+
// CI/CD flags (non-sensitive)
|
|
191
|
+
'CI',
|
|
192
|
+
'CONTINUOUS_INTEGRATION',
|
|
193
|
+
// Display
|
|
194
|
+
'DISPLAY',
|
|
195
|
+
'COLORTERM',
|
|
196
|
+
// Python
|
|
197
|
+
'PYTHONPATH',
|
|
198
|
+
'PYTHONIOENCODING',
|
|
199
|
+
'VIRTUAL_ENV',
|
|
200
|
+
// Package managers (non-sensitive config)
|
|
201
|
+
'NPM_CONFIG_YES',
|
|
202
|
+
'YARN_ENABLE_PROGRESS_BARS',
|
|
203
|
+
'DEBIAN_FRONTEND',
|
|
204
|
+
// History control
|
|
205
|
+
'HISTFILE',
|
|
206
|
+
'HISTSIZE',
|
|
207
|
+
// Output control
|
|
208
|
+
'NO_COLOR',
|
|
209
|
+
'FORCE_COLOR',
|
|
210
|
+
'NO_TTY',
|
|
211
|
+
// Current working directory
|
|
212
|
+
'PWD',
|
|
213
|
+
'OLDPWD',
|
|
214
|
+
]);
|
|
215
|
+
/**
|
|
216
|
+
* Paths that should never be accessed
|
|
217
|
+
*/
|
|
218
|
+
export const BLOCKED_PATHS = [
|
|
219
|
+
path.join(os.homedir(), '.ssh'),
|
|
220
|
+
path.join(os.homedir(), '.gnupg'),
|
|
221
|
+
path.join(os.homedir(), '.aws'),
|
|
222
|
+
path.join(os.homedir(), '.docker'),
|
|
223
|
+
path.join(os.homedir(), '.npmrc'),
|
|
224
|
+
path.join(os.homedir(), '.gitconfig'),
|
|
225
|
+
path.join(os.homedir(), '.netrc'),
|
|
226
|
+
path.join(os.homedir(), '.env'),
|
|
227
|
+
path.join(os.homedir(), '.config/gh'),
|
|
228
|
+
path.join(os.homedir(), '.config/gcloud'),
|
|
229
|
+
path.join(os.homedir(), '.kube'),
|
|
230
|
+
'/etc/passwd',
|
|
231
|
+
'/etc/shadow',
|
|
232
|
+
'/etc/sudoers',
|
|
233
|
+
];
|
|
234
|
+
//# sourceMappingURL=security-patterns.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"security-patterns.js","sourceRoot":"","sources":["../../../src/tools/bash/security-patterns.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,MAAM,IAAI,CAAC;AAEpB;;GAEG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAa;IACxC,yBAAyB;IACzB,iCAAiC,EAAG,gBAAgB;IACpD,gBAAgB,EAAuB,gBAAgB;IACvD,qBAAqB,EAAkB,uBAAuB;IAC9D,uBAAuB,EAAe,eAAe;IACrD,OAAO,EAAgC,oBAAoB;IAC3D,2BAA2B,EAAW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ACV,aAAa;IACb,QAAQ;IACR,4BAA4B;IAC5B,KAAK;IACL,QAAQ;CACT,CAAC,CAAC;AAEH;;GAEG;AACH,MAAM,CAAC,MAAM,aAAa,GAAa;IACrC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,MAAM,CAAC;IAC/B,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,QAAQ,CAAC;IACjC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,MAAM,CAAC;IAC/B,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,SAAS,CAAC;IAClC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,QAAQ,CAAC;IACjC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,YAAY,CAAC;IACrC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,QAAQ,CAAC;IACjC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,MAAM,CAAC;IAC/B,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,YAAY,CAAC;IACrC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,gBAAgB,CAAC;IACzC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,OAAO,CAAC;IAChC,aAAa;IACb,aAAa;IACb,cAAc;CACf,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Streaming execution for BashTool.
|
|
3
|
+
*
|
|
4
|
+
* Contains the executeStreaming AsyncGenerator that yields output chunks
|
|
5
|
+
* as they arrive from the spawned process.
|
|
6
|
+
*/
|
|
7
|
+
import { ToolResult } from '../../types/index.js';
|
|
8
|
+
export interface StreamingExecutorDeps {
|
|
9
|
+
getCurrentDirectory: () => string;
|
|
10
|
+
getSandboxManager: () => {
|
|
11
|
+
validateCommand(cmd: string): {
|
|
12
|
+
valid: boolean;
|
|
13
|
+
reason?: string;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
getRunningProcesses: () => Set<import('child_process').ChildProcess>;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Execute a command with streaming output.
|
|
20
|
+
* Yields each line of stdout/stderr as it arrives.
|
|
21
|
+
* Validates and confirms the command before execution.
|
|
22
|
+
*/
|
|
23
|
+
export declare function executeStreaming(command: string, timeout: number | undefined, deps: StreamingExecutorDeps): AsyncGenerator<string, ToolResult, undefined>;
|