@4onstudios/iris-agent 0.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/LICENSE +21 -0
- package/README.md +690 -0
- package/dist/api/acp/acpServer.d.ts +23 -0
- package/dist/api/acp/acpServer.js +814 -0
- package/dist/api/acp/index.d.ts +2 -0
- package/dist/api/acp/index.js +2 -0
- package/dist/api/acp/irisClient.d.ts +58 -0
- package/dist/api/acp/irisClient.js +214 -0
- package/dist/api/agent.d.ts +14 -0
- package/dist/api/agent.js +4171 -0
- package/dist/api/backendService.d.ts +4 -0
- package/dist/api/backendService.js +14 -0
- package/dist/api/core/agent/host/AgentContract.d.ts +82 -0
- package/dist/api/core/agent/host/AgentContract.js +1 -0
- package/dist/api/core/agent/host/AgentRegistry.d.ts +24 -0
- package/dist/api/core/agent/host/AgentRegistry.js +125 -0
- package/dist/api/core/agent/host/defaultRegistry.d.ts +15 -0
- package/dist/api/core/agent/host/defaultRegistry.js +46 -0
- package/dist/api/core/agent/host/externalAgentLifecycle.d.ts +65 -0
- package/dist/api/core/agent/host/externalAgentLifecycle.js +117 -0
- package/dist/api/core/agent/host/hostSessionManager.d.ts +111 -0
- package/dist/api/core/agent/host/hostSessionManager.js +352 -0
- package/dist/api/core/agent/host/index.d.ts +5 -0
- package/dist/api/core/agent/host/index.js +5 -0
- package/dist/api/core/agent/index.d.ts +87 -0
- package/dist/api/core/agent/index.js +1024 -0
- package/dist/api/core/agent/publicContracts.d.ts +35 -0
- package/dist/api/core/agent/publicContracts.js +103 -0
- package/dist/api/core/agent/tools/applyDiff.d.ts +51 -0
- package/dist/api/core/agent/tools/applyDiff.js +131 -0
- package/dist/api/core/agent/tools/backgroundTasks.d.ts +240 -0
- package/dist/api/core/agent/tools/backgroundTasks.js +313 -0
- package/dist/api/core/agent/tools/createDirectory.d.ts +43 -0
- package/dist/api/core/agent/tools/createDirectory.js +77 -0
- package/dist/api/core/agent/tools/deleteFile.d.ts +37 -0
- package/dist/api/core/agent/tools/deleteFile.js +66 -0
- package/dist/api/core/agent/tools/editFile.d.ts +73 -0
- package/dist/api/core/agent/tools/editFile.js +173 -0
- package/dist/api/core/agent/tools/executeCommand.d.ts +59 -0
- package/dist/api/core/agent/tools/executeCommand.js +250 -0
- package/dist/api/core/agent/tools/fileContent.d.ts +54 -0
- package/dist/api/core/agent/tools/fileContent.js +227 -0
- package/dist/api/core/agent/tools/findDefinition.d.ts +72 -0
- package/dist/api/core/agent/tools/findDefinition.js +109 -0
- package/dist/api/core/agent/tools/findReferences.d.ts +86 -0
- package/dist/api/core/agent/tools/findReferences.js +135 -0
- package/dist/api/core/agent/tools/formatDocument.d.ts +67 -0
- package/dist/api/core/agent/tools/formatDocument.js +90 -0
- package/dist/api/core/agent/tools/getCodeActions.d.ts +77 -0
- package/dist/api/core/agent/tools/getCodeActions.js +97 -0
- package/dist/api/core/agent/tools/getCodeCompletion.d.ts +77 -0
- package/dist/api/core/agent/tools/getCodeCompletion.js +174 -0
- package/dist/api/core/agent/tools/getCodeContext.d.ts +14 -0
- package/dist/api/core/agent/tools/getCodeContext.js +282 -0
- package/dist/api/core/agent/tools/getSignatureHelp.d.ts +61 -0
- package/dist/api/core/agent/tools/getSignatureHelp.js +85 -0
- package/dist/api/core/agent/tools/getSymbols.d.ts +50 -0
- package/dist/api/core/agent/tools/getSymbols.js +164 -0
- package/dist/api/core/agent/tools/getSymbolsLSP.d.ts +58 -0
- package/dist/api/core/agent/tools/getSymbolsLSP.js +147 -0
- package/dist/api/core/agent/tools/getTypeInfo.d.ts +70 -0
- package/dist/api/core/agent/tools/getTypeInfo.js +84 -0
- package/dist/api/core/agent/tools/getWorkspaceInfo.d.ts +80 -0
- package/dist/api/core/agent/tools/getWorkspaceInfo.js +281 -0
- package/dist/api/core/agent/tools/getWorkspaceSymbols.d.ts +53 -0
- package/dist/api/core/agent/tools/getWorkspaceSymbols.js +97 -0
- package/dist/api/core/agent/tools/grepSearch.d.ts +100 -0
- package/dist/api/core/agent/tools/grepSearch.js +211 -0
- package/dist/api/core/agent/tools/languageModelToolsIntegration.d.ts +13 -0
- package/dist/api/core/agent/tools/languageModelToolsIntegration.js +22 -0
- package/dist/api/core/agent/tools/listDirectory.d.ts +66 -0
- package/dist/api/core/agent/tools/listDirectory.js +161 -0
- package/dist/api/core/agent/tools/mcpTools.d.ts +48 -0
- package/dist/api/core/agent/tools/mcpTools.js +442 -0
- package/dist/api/core/agent/tools/queryKnowledgeGraph.d.ts +120 -0
- package/dist/api/core/agent/tools/queryKnowledgeGraph.js +306 -0
- package/dist/api/core/agent/tools/readFile.d.ts +92 -0
- package/dist/api/core/agent/tools/readFile.js +337 -0
- package/dist/api/core/agent/tools/renameFile.d.ts +49 -0
- package/dist/api/core/agent/tools/renameFile.js +86 -0
- package/dist/api/core/agent/tools/renameSymbol.d.ts +70 -0
- package/dist/api/core/agent/tools/renameSymbol.js +106 -0
- package/dist/api/core/agent/tools/runTerminalCommand.d.ts +72 -0
- package/dist/api/core/agent/tools/runTerminalCommand.js +69 -0
- package/dist/api/core/agent/tools/searchFiles.d.ts +82 -0
- package/dist/api/core/agent/tools/searchFiles.js +280 -0
- package/dist/api/core/agent/tools/terminalAutoApprove.d.ts +3 -0
- package/dist/api/core/agent/tools/terminalAutoApprove.js +676 -0
- package/dist/api/core/agent/tools/treeTraversal.d.ts +60 -0
- package/dist/api/core/agent/tools/treeTraversal.js +217 -0
- package/dist/api/core/agent/tools/webSearch.d.ts +37 -0
- package/dist/api/core/agent/tools/webSearch.js +80 -0
- package/dist/api/core/agent/tools/writeFile.d.ts +59 -0
- package/dist/api/core/agent/tools/writeFile.js +97 -0
- package/dist/api/core/agent/utils/capturedWorkspaceMutationBridge.d.ts +12 -0
- package/dist/api/core/agent/utils/capturedWorkspaceMutationBridge.js +67 -0
- package/dist/api/core/agent/utils/diffUtils.d.ts +14 -0
- package/dist/api/core/agent/utils/diffUtils.js +39 -0
- package/dist/api/core/agent/utils/environmentSnapshot.d.ts +42 -0
- package/dist/api/core/agent/utils/environmentSnapshot.js +213 -0
- package/dist/api/core/agent/utils/errorRecovery.d.ts +49 -0
- package/dist/api/core/agent/utils/errorRecovery.js +229 -0
- package/dist/api/core/agent/utils/multimodalTokenLimiter.d.ts +8 -0
- package/dist/api/core/agent/utils/multimodalTokenLimiter.js +238 -0
- package/dist/api/core/agent/utils/openRouterModelSettings.d.ts +12 -0
- package/dist/api/core/agent/utils/openRouterModelSettings.js +34 -0
- package/dist/api/core/agent/utils/pathRecovery.d.ts +1 -0
- package/dist/api/core/agent/utils/pathRecovery.js +29 -0
- package/dist/api/core/agent/utils/repoMapIndex.d.ts +3 -0
- package/dist/api/core/agent/utils/repoMapIndex.js +197 -0
- package/dist/api/core/agent/utils/skillsDiscovery.d.ts +10 -0
- package/dist/api/core/agent/utils/skillsDiscovery.js +50 -0
- package/dist/api/core/agent/utils/toolCallBudget.d.ts +9 -0
- package/dist/api/core/agent/utils/toolCallBudget.js +55 -0
- package/dist/api/core/agent/utils/toolLifecycle.d.ts +30 -0
- package/dist/api/core/agent/utils/toolLifecycle.js +361 -0
- package/dist/api/core/agent/utils/toolResultSafetyProcessor.d.ts +12 -0
- package/dist/api/core/agent/utils/toolResultSafetyProcessor.js +57 -0
- package/dist/api/core/agent/utils/workspaceMutationBridge.d.ts +13 -0
- package/dist/api/core/agent/utils/workspaceMutationBridge.js +149 -0
- package/dist/api/core/agent/utils/workspacePathGuard.d.ts +7 -0
- package/dist/api/core/agent/utils/workspacePathGuard.js +79 -0
- package/dist/api/core/containers/chat/toolResultSerialization.d.ts +8 -0
- package/dist/api/core/containers/chat/toolResultSerialization.js +71 -0
- package/dist/api/core/library/BrowserManager.d.ts +11 -0
- package/dist/api/core/library/BrowserManager.js +66 -0
- package/dist/api/core/library/desktopWorkspace.d.ts +1 -0
- package/dist/api/core/library/desktopWorkspace.js +3 -0
- package/dist/api/core/library/extensionManager.d.ts +10 -0
- package/dist/api/core/library/extensionManager.js +27 -0
- package/dist/api/core/library/knowledgeGraph.d.ts +268 -0
- package/dist/api/core/library/knowledgeGraph.js +989 -0
- package/dist/api/core/library/languageModelTools.d.ts +141 -0
- package/dist/api/core/library/languageModelTools.js +207 -0
- package/dist/api/core/library/localRuntime.d.ts +23 -0
- package/dist/api/core/library/localRuntime.js +144 -0
- package/dist/api/core/library/lsp/coreLsp.d.ts +367 -0
- package/dist/api/core/library/lsp/coreLsp.js +2076 -0
- package/dist/api/core/library/lsp/protocol.d.ts +25 -0
- package/dist/api/core/library/lsp/protocol.js +1 -0
- package/dist/api/core/library/lsp/serverManager.d.ts +37 -0
- package/dist/api/core/library/lsp/serverManager.js +427 -0
- package/dist/api/core/library/mcpServerProvider.d.ts +69 -0
- package/dist/api/core/library/mcpServerProvider.js +152 -0
- package/dist/api/core/library/mcpSettings.d.ts +20 -0
- package/dist/api/core/library/mcpSettings.js +131 -0
- package/dist/api/core/library/patternMatcher.d.ts +66 -0
- package/dist/api/core/library/patternMatcher.js +284 -0
- package/dist/api/core/library/regexEscape.d.ts +4 -0
- package/dist/api/core/library/regexEscape.js +4 -0
- package/dist/api/core/library/runtimeEventBus.d.ts +27 -0
- package/dist/api/core/library/runtimeEventBus.js +78 -0
- package/dist/api/core/library/safetyMiddleware.d.ts +98 -0
- package/dist/api/core/library/safetyMiddleware.js +215 -0
- package/dist/api/core/library/tauri.d.ts +71 -0
- package/dist/api/core/library/tauri.js +222 -0
- package/dist/api/core/library/tauriImport.d.ts +5 -0
- package/dist/api/core/library/tauriImport.js +7 -0
- package/dist/api/core/library/terminalAutoApproveSettings.d.ts +32 -0
- package/dist/api/core/library/terminalAutoApproveSettings.js +529 -0
- package/dist/api/core/library/workspaceIdentity.d.ts +10 -0
- package/dist/api/core/library/workspaceIdentity.js +49 -0
- package/dist/api/core/library/workspaceSummary.d.ts +19 -0
- package/dist/api/core/library/workspaceSummary.js +35 -0
- package/dist/api/core/skills/agent-customization/SKILL.md +27 -0
- package/dist/api/core/skills/bug-fix/SKILL.md +21 -0
- package/dist/api/core/skills/create-pr/SKILL.md +32 -0
- package/dist/api/core/skills/dev-server/SKILL.md +20 -0
- package/dist/api/core/skills/fix-suggestions/SKILL.md +21 -0
- package/dist/api/core/skills/github-search/SKILL.md +21 -0
- package/dist/api/core/skills/github-summary/SKILL.md +25 -0
- package/dist/api/core/skills/integration-tests/SKILL.md +29 -0
- package/dist/api/core/skills/pr-comments/SKILL.md +23 -0
- package/dist/api/core/skills/project-setup/SKILL.md +20 -0
- package/dist/api/core/skills/search-integration/SKILL.md +19 -0
- package/dist/api/core/skills/search-results/SKILL.md +19 -0
- package/dist/api/core/skills/typescript-upgrade/SKILL.md +21 -0
- package/dist/api/data/runStore.d.ts +46 -0
- package/dist/api/data/runStore.js +244 -0
- package/dist/api/helpers/agentUtils.d.ts +11 -0
- package/dist/api/helpers/agentUtils.js +23 -0
- package/dist/api/helpers/modelTokenLimits.d.ts +2 -0
- package/dist/api/helpers/modelTokenLimits.js +158 -0
- package/dist/api/helpers/observationalMemory.d.ts +10 -0
- package/dist/api/helpers/observationalMemory.js +36 -0
- package/dist/api/helpers/promptBudget.d.ts +30 -0
- package/dist/api/helpers/promptBudget.js +216 -0
- package/dist/api/helpers/resolveImageMessageParts.d.ts +9 -0
- package/dist/api/helpers/resolveImageMessageParts.js +140 -0
- package/dist/api/helpers/slashCommands.d.ts +31 -0
- package/dist/api/helpers/slashCommands.js +129 -0
- package/dist/api/helpers/tokenUsage.d.ts +19 -0
- package/dist/api/helpers/tokenUsage.js +81 -0
- package/dist/api/routes/fileRoutes.d.ts +2 -0
- package/dist/api/routes/fileRoutes.js +108 -0
- package/dist/api/routes/lspDocumentRoutes.d.ts +4 -0
- package/dist/api/routes/lspDocumentRoutes.js +84 -0
- package/dist/api/routes/lspHierarchyRoutes.d.ts +4 -0
- package/dist/api/routes/lspHierarchyRoutes.js +122 -0
- package/dist/api/routes/lspPositionRoutes.d.ts +4 -0
- package/dist/api/routes/lspPositionRoutes.js +263 -0
- package/dist/api/routes/lspQueryRoutes.d.ts +4 -0
- package/dist/api/routes/lspQueryRoutes.js +679 -0
- package/dist/api/routes/lspResolveRoutes.d.ts +4 -0
- package/dist/api/routes/lspResolveRoutes.js +143 -0
- package/dist/api/routes/lspSemanticDocumentRoutes.d.ts +4 -0
- package/dist/api/routes/lspSemanticDocumentRoutes.js +98 -0
- package/dist/api/routes/semanticRoutes.d.ts +2 -0
- package/dist/api/routes/semanticRoutes.js +126 -0
- package/dist/cli.d.ts +8 -0
- package/dist/cli.js +160 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/server.d.ts +2 -0
- package/dist/server.js +38 -0
- package/package.json +100 -0
|
@@ -0,0 +1,676 @@
|
|
|
1
|
+
import { escapeRegExp } from "../../library/regexEscape.js";
|
|
2
|
+
const WRAPPER_PROGRAMS = new Set([
|
|
3
|
+
"sudo",
|
|
4
|
+
"doas",
|
|
5
|
+
"time",
|
|
6
|
+
"command",
|
|
7
|
+
"builtin",
|
|
8
|
+
"exec",
|
|
9
|
+
"nice",
|
|
10
|
+
"ionice",
|
|
11
|
+
"nohup",
|
|
12
|
+
"env",
|
|
13
|
+
"xargs",
|
|
14
|
+
"stdbuf",
|
|
15
|
+
"unbuffer",
|
|
16
|
+
"script",
|
|
17
|
+
"timeout",
|
|
18
|
+
]);
|
|
19
|
+
const SHELL_PROGRAMS = new Set([
|
|
20
|
+
"bash",
|
|
21
|
+
"sh",
|
|
22
|
+
"zsh",
|
|
23
|
+
"fish",
|
|
24
|
+
"ksh",
|
|
25
|
+
"csh",
|
|
26
|
+
"tcsh",
|
|
27
|
+
"dash",
|
|
28
|
+
"pwsh",
|
|
29
|
+
"powershell",
|
|
30
|
+
"powershell.exe",
|
|
31
|
+
"cmd",
|
|
32
|
+
"cmd.exe",
|
|
33
|
+
]);
|
|
34
|
+
const NEVER_AUTO_APPROVE_COMMANDS = new Set([
|
|
35
|
+
"bash",
|
|
36
|
+
"sh",
|
|
37
|
+
"zsh",
|
|
38
|
+
"fish",
|
|
39
|
+
"ksh",
|
|
40
|
+
"csh",
|
|
41
|
+
"tcsh",
|
|
42
|
+
"dash",
|
|
43
|
+
"pwsh",
|
|
44
|
+
"powershell",
|
|
45
|
+
"powershell.exe",
|
|
46
|
+
"cmd",
|
|
47
|
+
"cmd.exe",
|
|
48
|
+
"python",
|
|
49
|
+
"python3",
|
|
50
|
+
"node",
|
|
51
|
+
"ruby",
|
|
52
|
+
"perl",
|
|
53
|
+
"php",
|
|
54
|
+
"lua",
|
|
55
|
+
"eval",
|
|
56
|
+
"exec",
|
|
57
|
+
"source",
|
|
58
|
+
"sudo",
|
|
59
|
+
"su",
|
|
60
|
+
"doas",
|
|
61
|
+
"curl",
|
|
62
|
+
"wget",
|
|
63
|
+
"invoke-restmethod",
|
|
64
|
+
"invoke-webrequest",
|
|
65
|
+
"irm",
|
|
66
|
+
"iwr",
|
|
67
|
+
]);
|
|
68
|
+
const SAFE_REDIRECT_TARGETS = new Set([
|
|
69
|
+
"/dev/null",
|
|
70
|
+
"/dev/stdout",
|
|
71
|
+
"/dev/stderr",
|
|
72
|
+
"/dev/tty",
|
|
73
|
+
]);
|
|
74
|
+
const ENV_ASSIGN_RE = /^[A-Za-z_][A-Za-z0-9_]*=.*$/;
|
|
75
|
+
const MAX_UNWRAP_DEPTH = 8;
|
|
76
|
+
function getPreviousNonWhitespaceChar(input, index) {
|
|
77
|
+
for (let cursor = index; cursor >= 0; cursor--) {
|
|
78
|
+
const char = input[cursor];
|
|
79
|
+
if (!/\s/.test(char)) {
|
|
80
|
+
return char;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return undefined;
|
|
84
|
+
}
|
|
85
|
+
const NEVER_MATCH_REGEX = /(?!.*)/;
|
|
86
|
+
const DEFAULT_RULES = {
|
|
87
|
+
cd: true,
|
|
88
|
+
echo: true,
|
|
89
|
+
ls: true,
|
|
90
|
+
dir: true,
|
|
91
|
+
pwd: true,
|
|
92
|
+
cat: true,
|
|
93
|
+
head: true,
|
|
94
|
+
tail: true,
|
|
95
|
+
findstr: true,
|
|
96
|
+
wc: true,
|
|
97
|
+
tr: true,
|
|
98
|
+
cut: true,
|
|
99
|
+
cmp: true,
|
|
100
|
+
which: true,
|
|
101
|
+
basename: true,
|
|
102
|
+
dirname: true,
|
|
103
|
+
realpath: true,
|
|
104
|
+
readlink: true,
|
|
105
|
+
stat: true,
|
|
106
|
+
file: true,
|
|
107
|
+
od: true,
|
|
108
|
+
du: true,
|
|
109
|
+
df: true,
|
|
110
|
+
sleep: true,
|
|
111
|
+
nl: true,
|
|
112
|
+
column: true,
|
|
113
|
+
find: true,
|
|
114
|
+
rg: true,
|
|
115
|
+
sed: true,
|
|
116
|
+
sort: true,
|
|
117
|
+
tree: true,
|
|
118
|
+
xxd: true,
|
|
119
|
+
grep: true,
|
|
120
|
+
"/^find\\b(?!.*\\s-(delete|exec|execdir|fprint|fprintf|fls|ok|okdir)\\b)/i": true,
|
|
121
|
+
"/^rg\\b(?!.*\\s(--pre|--hostname-bin)\\b)/i": true,
|
|
122
|
+
"/^sort\\b(?!.*\\s-(o|S)\\b)/i": true,
|
|
123
|
+
"/^tree\\b(?!.*\\s-o\\b)/i": true,
|
|
124
|
+
"/^column\\b.*\\s-c\\s+[0-9]{1,3}\\b/i": true,
|
|
125
|
+
"/^date\\b(?!.*\\s(-s|--set)\\b)/i": true,
|
|
126
|
+
"/^git(\\s+(-C\\s+\\S+|--no-pager))*\\s+status\\b/i": true,
|
|
127
|
+
"/^git(\\s+(-C\\s+\\S+|--no-pager))*\\s+diff\\b/i": true,
|
|
128
|
+
"/^git(\\s+(-C\\s+\\S+|--no-pager))*\\s+show\\b/i": true,
|
|
129
|
+
"/^git(\\s+(-C\\s+\\S+|--no-pager))*\\s+log\\b/i": true,
|
|
130
|
+
"/^git(\\s+(-C\\s+\\S+|--no-pager))*\\s+ls-files\\b/i": true,
|
|
131
|
+
"/^git(\\s+(-C\\s+\\S+|--no-pager))*\\s+rev-parse\\b/i": true,
|
|
132
|
+
"/^git(\\s+(-C\\s+\\S+|--no-pager))*\\s+grep\\b/i": true,
|
|
133
|
+
"/^git(\\s+(-C\\s+\\S+|--no-pager))*\\s+branch\\b/i": true,
|
|
134
|
+
"/^npm\\s+(ls|list|outdated|view|info|show|explain|why|root|prefix|bin|search|doctor|fund|repo|bugs|docs|home|help(-search)?)\\b/i": true,
|
|
135
|
+
"/^npm\\s+config\\s+(list|get)\\b/i": true,
|
|
136
|
+
"/^npm\\s+pkg\\s+get\\b/i": true,
|
|
137
|
+
"/^npm\\s+audit$/i": true,
|
|
138
|
+
"/^npm\\s+cache\\s+verify\\b/i": true,
|
|
139
|
+
"/^npm\\s+ci$/i": true,
|
|
140
|
+
"/^yarn\\s+(list|outdated|info|why|bin|help|versions)\\b/i": true,
|
|
141
|
+
"/^yarn\\s+licenses\\b/i": true,
|
|
142
|
+
"/^yarn\\s+audit\\b(?!.*\\bfix\\b)/i": true,
|
|
143
|
+
"/^yarn\\s+config\\s+(list|get)\\b/i": true,
|
|
144
|
+
"/^yarn\\s+cache\\s+dir\\b/i": true,
|
|
145
|
+
"/^yarn\\s+install\\s+--frozen-lockfile\\b/i": true,
|
|
146
|
+
"/^pnpm\\s+(ls|list|outdated|why|root|bin|doctor)\\b/i": true,
|
|
147
|
+
"/^pnpm\\s+licenses\\b/i": true,
|
|
148
|
+
"/^pnpm\\s+audit\\b(?!.*\\bfix\\b)/i": true,
|
|
149
|
+
"/^pnpm\\s+config\\s+(list|get)\\b/i": true,
|
|
150
|
+
"/^pnpm\\s+install\\s+--frozen-lockfile\\b/i": true,
|
|
151
|
+
"/^docker\\s+(ps|images|info|version|inspect|logs|top|stats|port|diff|search|events)\\b/i": true,
|
|
152
|
+
"/^docker\\s+(container|image|network|volume|context|system)\\s+(ls|ps|inspect|history|show|df|info)\\b/i": true,
|
|
153
|
+
"/^docker\\s+compose\\s+(ps|ls|top|logs|images|config|version|port|events)\\b/i": true,
|
|
154
|
+
"Get-ChildItem": true,
|
|
155
|
+
"Get-Content": true,
|
|
156
|
+
"Get-Date": true,
|
|
157
|
+
"Get-Random": true,
|
|
158
|
+
"Get-Location": true,
|
|
159
|
+
"Set-Location": true,
|
|
160
|
+
"Write-Host": true,
|
|
161
|
+
"Write-Output": true,
|
|
162
|
+
"Out-String": true,
|
|
163
|
+
"Split-Path": true,
|
|
164
|
+
"Join-Path": true,
|
|
165
|
+
"Start-Sleep": true,
|
|
166
|
+
"Where-Object": true,
|
|
167
|
+
"/^Select-[a-z0-9]/i": true,
|
|
168
|
+
"/^Measure-[a-z0-9]/i": true,
|
|
169
|
+
"/^Compare-[a-z0-9]/i": true,
|
|
170
|
+
"/^Format-[a-z0-9]/i": true,
|
|
171
|
+
"/^Sort-[a-z0-9]/i": true,
|
|
172
|
+
rm: false,
|
|
173
|
+
rmdir: false,
|
|
174
|
+
del: false,
|
|
175
|
+
"Remove-Item": false,
|
|
176
|
+
ri: false,
|
|
177
|
+
rd: false,
|
|
178
|
+
erase: false,
|
|
179
|
+
dd: false,
|
|
180
|
+
kill: false,
|
|
181
|
+
ps: false,
|
|
182
|
+
top: false,
|
|
183
|
+
taskkill: false,
|
|
184
|
+
"taskkill.exe": false,
|
|
185
|
+
"Stop-Process": false,
|
|
186
|
+
spps: false,
|
|
187
|
+
chmod: false,
|
|
188
|
+
chown: false,
|
|
189
|
+
curl: false,
|
|
190
|
+
wget: false,
|
|
191
|
+
"Invoke-RestMethod": false,
|
|
192
|
+
"Invoke-WebRequest": false,
|
|
193
|
+
irm: false,
|
|
194
|
+
iwr: false,
|
|
195
|
+
"Set-ItemProperty": false,
|
|
196
|
+
sp: false,
|
|
197
|
+
"Set-Acl": false,
|
|
198
|
+
jq: false,
|
|
199
|
+
xargs: false,
|
|
200
|
+
eval: false,
|
|
201
|
+
"Invoke-Expression": false,
|
|
202
|
+
iex: false,
|
|
203
|
+
"/^column\\b.*\\s-c\\s+[0-9]{4,}\\b/i": false,
|
|
204
|
+
"/^git(\\s+(-C\\s+\\S+|--no-pager))*\\s+log\\b.*\\s--output(=|\\s|$)/i": false,
|
|
205
|
+
"/^git(\\s+(-C\\s+\\S+|--no-pager))*\\s+branch\\b.*\\s-(d|D|m|M|-delete|-force)\\b/i": false,
|
|
206
|
+
"/^find\\b.*\\s-(delete|exec|execdir|fprint|fprintf|fls|ok|okdir)\\b/i": false,
|
|
207
|
+
"/^sed\\b.*\\s(-[a-zA-Z]*(e|f)[a-zA-Z]*|--expression|--file)\\b/i": false,
|
|
208
|
+
"/^sed\\b.*s\\/.*\\/.*\\/[ew]/i": false,
|
|
209
|
+
"/^sed\\b.*;W/i": false,
|
|
210
|
+
"/^sort\\b.*\\s-(o|S)\\b/i": false,
|
|
211
|
+
"/^tree\\b.*\\s-o\\b/i": false,
|
|
212
|
+
"/^date\\b.*\\s(-s|--set)\\b/i": false,
|
|
213
|
+
"/^xxd$/i": true,
|
|
214
|
+
"/^xxd\\b(\\s+-\\S+)*\\s+[^-\\s]\\S*$/i": true,
|
|
215
|
+
};
|
|
216
|
+
function normalizeCommandKeyword(token) {
|
|
217
|
+
if (!token) {
|
|
218
|
+
return undefined;
|
|
219
|
+
}
|
|
220
|
+
const unquoted = token.replace(/^['"]|['"]$/g, "");
|
|
221
|
+
if (!unquoted) {
|
|
222
|
+
return undefined;
|
|
223
|
+
}
|
|
224
|
+
const parts = unquoted.split(/[\\/]/);
|
|
225
|
+
const base = parts[parts.length - 1]?.toLowerCase() ?? "";
|
|
226
|
+
const normalized = base.replace(/\.(?:exe|cmd|bat|ps1)$/i, "");
|
|
227
|
+
return normalized || undefined;
|
|
228
|
+
}
|
|
229
|
+
function splitSegments(command) {
|
|
230
|
+
const segments = [];
|
|
231
|
+
let current = "";
|
|
232
|
+
let inSingle = false;
|
|
233
|
+
let inDouble = false;
|
|
234
|
+
const push = () => {
|
|
235
|
+
const trimmed = current.trim();
|
|
236
|
+
if (trimmed) {
|
|
237
|
+
segments.push({ raw: trimmed });
|
|
238
|
+
}
|
|
239
|
+
current = "";
|
|
240
|
+
};
|
|
241
|
+
for (let index = 0; index < command.length; index++) {
|
|
242
|
+
const char = command[index];
|
|
243
|
+
if (inSingle) {
|
|
244
|
+
current += char;
|
|
245
|
+
if (char === "'") {
|
|
246
|
+
inSingle = false;
|
|
247
|
+
}
|
|
248
|
+
continue;
|
|
249
|
+
}
|
|
250
|
+
if (inDouble) {
|
|
251
|
+
if (char === "\\" && index + 1 < command.length) {
|
|
252
|
+
current += char + command[index + 1];
|
|
253
|
+
index++;
|
|
254
|
+
continue;
|
|
255
|
+
}
|
|
256
|
+
current += char;
|
|
257
|
+
if (char === '"') {
|
|
258
|
+
inDouble = false;
|
|
259
|
+
}
|
|
260
|
+
continue;
|
|
261
|
+
}
|
|
262
|
+
if (char === "\\" && index + 1 < command.length) {
|
|
263
|
+
current += char + command[index + 1];
|
|
264
|
+
index++;
|
|
265
|
+
continue;
|
|
266
|
+
}
|
|
267
|
+
if (char === "'") {
|
|
268
|
+
inSingle = true;
|
|
269
|
+
current += char;
|
|
270
|
+
continue;
|
|
271
|
+
}
|
|
272
|
+
if (char === '"') {
|
|
273
|
+
inDouble = true;
|
|
274
|
+
current += char;
|
|
275
|
+
continue;
|
|
276
|
+
}
|
|
277
|
+
if (char === "|" && command[index + 1] === "|") {
|
|
278
|
+
push();
|
|
279
|
+
index++;
|
|
280
|
+
continue;
|
|
281
|
+
}
|
|
282
|
+
if (char === "&" && command[index + 1] === "&") {
|
|
283
|
+
push();
|
|
284
|
+
index++;
|
|
285
|
+
continue;
|
|
286
|
+
}
|
|
287
|
+
if (char === "&") {
|
|
288
|
+
const prev = getPreviousNonWhitespaceChar(command, index - 1);
|
|
289
|
+
const next = command[index + 1];
|
|
290
|
+
const isRedirectAmpersand = prev === ">" || prev === "<" || next === ">";
|
|
291
|
+
if (!isRedirectAmpersand) {
|
|
292
|
+
push();
|
|
293
|
+
continue;
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
if (char === "|" || char === ";") {
|
|
297
|
+
push();
|
|
298
|
+
continue;
|
|
299
|
+
}
|
|
300
|
+
if (char === "&" && command[index + 1] === "&") {
|
|
301
|
+
push();
|
|
302
|
+
index++;
|
|
303
|
+
continue;
|
|
304
|
+
}
|
|
305
|
+
current += char;
|
|
306
|
+
}
|
|
307
|
+
push();
|
|
308
|
+
return segments.map((segment) => {
|
|
309
|
+
const rawTokens = tokenize(segment.raw);
|
|
310
|
+
const { tokens } = stripPrefixesAndWrappers(rawTokens);
|
|
311
|
+
return {
|
|
312
|
+
raw: segment.raw,
|
|
313
|
+
rawTokens,
|
|
314
|
+
tokens,
|
|
315
|
+
};
|
|
316
|
+
});
|
|
317
|
+
}
|
|
318
|
+
function tokenize(segment) {
|
|
319
|
+
const tokens = [];
|
|
320
|
+
let current = "";
|
|
321
|
+
let inSingle = false;
|
|
322
|
+
let inDouble = false;
|
|
323
|
+
let hasContent = false;
|
|
324
|
+
for (let index = 0; index < segment.length; index++) {
|
|
325
|
+
const char = segment[index];
|
|
326
|
+
if (inSingle) {
|
|
327
|
+
if (char === "'") {
|
|
328
|
+
inSingle = false;
|
|
329
|
+
}
|
|
330
|
+
else {
|
|
331
|
+
current += char;
|
|
332
|
+
}
|
|
333
|
+
continue;
|
|
334
|
+
}
|
|
335
|
+
if (inDouble) {
|
|
336
|
+
if (char === "\\" && index + 1 < segment.length) {
|
|
337
|
+
const next = segment[index + 1];
|
|
338
|
+
if (next === "\\" || next === '"' || next === "$" || next === "`") {
|
|
339
|
+
current += next;
|
|
340
|
+
index++;
|
|
341
|
+
continue;
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
if (char === '"') {
|
|
345
|
+
inDouble = false;
|
|
346
|
+
}
|
|
347
|
+
else {
|
|
348
|
+
current += char;
|
|
349
|
+
}
|
|
350
|
+
continue;
|
|
351
|
+
}
|
|
352
|
+
if (char === "\\" && index + 1 < segment.length) {
|
|
353
|
+
current += segment[index + 1];
|
|
354
|
+
index++;
|
|
355
|
+
hasContent = true;
|
|
356
|
+
continue;
|
|
357
|
+
}
|
|
358
|
+
if (char === "'") {
|
|
359
|
+
inSingle = true;
|
|
360
|
+
hasContent = true;
|
|
361
|
+
continue;
|
|
362
|
+
}
|
|
363
|
+
if (char === '"') {
|
|
364
|
+
inDouble = true;
|
|
365
|
+
hasContent = true;
|
|
366
|
+
continue;
|
|
367
|
+
}
|
|
368
|
+
if (/\s/.test(char)) {
|
|
369
|
+
if (current.length > 0 || hasContent) {
|
|
370
|
+
tokens.push(current);
|
|
371
|
+
current = "";
|
|
372
|
+
hasContent = false;
|
|
373
|
+
}
|
|
374
|
+
continue;
|
|
375
|
+
}
|
|
376
|
+
current += char;
|
|
377
|
+
hasContent = true;
|
|
378
|
+
}
|
|
379
|
+
if (current.length > 0 || hasContent) {
|
|
380
|
+
tokens.push(current);
|
|
381
|
+
}
|
|
382
|
+
return tokens;
|
|
383
|
+
}
|
|
384
|
+
function stripPrefixesAndWrappers(rawTokens) {
|
|
385
|
+
let index = 0;
|
|
386
|
+
while (index < rawTokens.length && ENV_ASSIGN_RE.test(rawTokens[index])) {
|
|
387
|
+
index++;
|
|
388
|
+
}
|
|
389
|
+
while (index < rawTokens.length) {
|
|
390
|
+
const token = normalizeCommandKeyword(rawTokens[index]);
|
|
391
|
+
if (!token || !WRAPPER_PROGRAMS.has(token)) {
|
|
392
|
+
break;
|
|
393
|
+
}
|
|
394
|
+
index++;
|
|
395
|
+
while (index < rawTokens.length) {
|
|
396
|
+
const next = rawTokens[index];
|
|
397
|
+
if (next === "--") {
|
|
398
|
+
index++;
|
|
399
|
+
break;
|
|
400
|
+
}
|
|
401
|
+
if (next.startsWith("-")) {
|
|
402
|
+
index++;
|
|
403
|
+
continue;
|
|
404
|
+
}
|
|
405
|
+
if (ENV_ASSIGN_RE.test(next)) {
|
|
406
|
+
index++;
|
|
407
|
+
continue;
|
|
408
|
+
}
|
|
409
|
+
if ((token === "timeout" || token === "nice" || token === "ionice") && /^\d/.test(next)) {
|
|
410
|
+
index++;
|
|
411
|
+
continue;
|
|
412
|
+
}
|
|
413
|
+
break;
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
return {
|
|
417
|
+
tokens: rawTokens.slice(index),
|
|
418
|
+
};
|
|
419
|
+
}
|
|
420
|
+
function readRedirectDestination(command, startIndex) {
|
|
421
|
+
let index = startIndex;
|
|
422
|
+
while (index < command.length && /\s/.test(command[index])) {
|
|
423
|
+
index++;
|
|
424
|
+
}
|
|
425
|
+
if (index >= command.length) {
|
|
426
|
+
return { dest: undefined, endIndex: index };
|
|
427
|
+
}
|
|
428
|
+
const quote = command[index];
|
|
429
|
+
if (quote === "'" || quote === '"') {
|
|
430
|
+
index++;
|
|
431
|
+
const begin = index;
|
|
432
|
+
while (index < command.length && command[index] !== quote) {
|
|
433
|
+
if (command[index] === "\\" && quote === '"' && index + 1 < command.length) {
|
|
434
|
+
index += 2;
|
|
435
|
+
continue;
|
|
436
|
+
}
|
|
437
|
+
index++;
|
|
438
|
+
}
|
|
439
|
+
return {
|
|
440
|
+
dest: command.slice(begin, index),
|
|
441
|
+
endIndex: index,
|
|
442
|
+
};
|
|
443
|
+
}
|
|
444
|
+
const begin = index;
|
|
445
|
+
while (index < command.length && !/\s/.test(command[index])) {
|
|
446
|
+
index++;
|
|
447
|
+
}
|
|
448
|
+
return {
|
|
449
|
+
dest: command.slice(begin, index),
|
|
450
|
+
endIndex: index,
|
|
451
|
+
};
|
|
452
|
+
}
|
|
453
|
+
function isSafeRedirectDestination(dest) {
|
|
454
|
+
if (!dest) {
|
|
455
|
+
return false;
|
|
456
|
+
}
|
|
457
|
+
const cleaned = dest.trim();
|
|
458
|
+
if (!cleaned) {
|
|
459
|
+
return false;
|
|
460
|
+
}
|
|
461
|
+
if (/^&[0-9]+-?$/.test(cleaned)) {
|
|
462
|
+
return true;
|
|
463
|
+
}
|
|
464
|
+
return SAFE_REDIRECT_TARGETS.has(cleaned);
|
|
465
|
+
}
|
|
466
|
+
function hasUnsafeWriteRedirect(command) {
|
|
467
|
+
let inSingle = false;
|
|
468
|
+
let inDouble = false;
|
|
469
|
+
for (let index = 0; index < command.length; index++) {
|
|
470
|
+
const char = command[index];
|
|
471
|
+
if (inSingle) {
|
|
472
|
+
if (char === "'") {
|
|
473
|
+
inSingle = false;
|
|
474
|
+
}
|
|
475
|
+
continue;
|
|
476
|
+
}
|
|
477
|
+
if (inDouble) {
|
|
478
|
+
if (char === "\\" && index + 1 < command.length) {
|
|
479
|
+
index++;
|
|
480
|
+
continue;
|
|
481
|
+
}
|
|
482
|
+
if (char === '"') {
|
|
483
|
+
inDouble = false;
|
|
484
|
+
}
|
|
485
|
+
continue;
|
|
486
|
+
}
|
|
487
|
+
if (char === "\\" && index + 1 < command.length) {
|
|
488
|
+
index++;
|
|
489
|
+
continue;
|
|
490
|
+
}
|
|
491
|
+
if (char === "'") {
|
|
492
|
+
inSingle = true;
|
|
493
|
+
continue;
|
|
494
|
+
}
|
|
495
|
+
if (char === '"') {
|
|
496
|
+
inDouble = true;
|
|
497
|
+
continue;
|
|
498
|
+
}
|
|
499
|
+
if (char !== ">") {
|
|
500
|
+
continue;
|
|
501
|
+
}
|
|
502
|
+
if (index + 1 < command.length && command[index + 1] === ">") {
|
|
503
|
+
index++;
|
|
504
|
+
}
|
|
505
|
+
if (index + 1 < command.length && command[index + 1] === "|") {
|
|
506
|
+
index++;
|
|
507
|
+
}
|
|
508
|
+
const { dest, endIndex } = readRedirectDestination(command, index + 1);
|
|
509
|
+
if (!isSafeRedirectDestination(dest)) {
|
|
510
|
+
return true;
|
|
511
|
+
}
|
|
512
|
+
index = endIndex;
|
|
513
|
+
}
|
|
514
|
+
return false;
|
|
515
|
+
}
|
|
516
|
+
function extractShellCommand(tokens) {
|
|
517
|
+
const head = normalizeCommandKeyword(tokens[0]);
|
|
518
|
+
if (!head || !SHELL_PROGRAMS.has(head)) {
|
|
519
|
+
return undefined;
|
|
520
|
+
}
|
|
521
|
+
for (let index = 1; index < tokens.length; index++) {
|
|
522
|
+
const token = tokens[index];
|
|
523
|
+
if (!token) {
|
|
524
|
+
continue;
|
|
525
|
+
}
|
|
526
|
+
if (/^--(?:command)$/i.test(token) || /^-(?:c|Command)$/i.test(token)) {
|
|
527
|
+
return tokens[index + 1];
|
|
528
|
+
}
|
|
529
|
+
if (/^-[A-Za-z]+$/.test(token) && token.toLowerCase().includes("c")) {
|
|
530
|
+
return tokens[index + 1];
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
return undefined;
|
|
534
|
+
}
|
|
535
|
+
function extractCommands(commandLine, depth = 0) {
|
|
536
|
+
if (depth > MAX_UNWRAP_DEPTH) {
|
|
537
|
+
return {
|
|
538
|
+
commands: [],
|
|
539
|
+
hasUnsafeWrite: false,
|
|
540
|
+
parseFailed: true,
|
|
541
|
+
};
|
|
542
|
+
}
|
|
543
|
+
const segments = splitSegments(commandLine);
|
|
544
|
+
if (segments.length === 0) {
|
|
545
|
+
return {
|
|
546
|
+
commands: [],
|
|
547
|
+
hasUnsafeWrite: false,
|
|
548
|
+
parseFailed: false,
|
|
549
|
+
};
|
|
550
|
+
}
|
|
551
|
+
const commands = [];
|
|
552
|
+
let hasUnsafeWrite = false;
|
|
553
|
+
let parseFailed = false;
|
|
554
|
+
for (const segment of segments) {
|
|
555
|
+
if (hasUnsafeWriteRedirect(segment.raw)) {
|
|
556
|
+
hasUnsafeWrite = true;
|
|
557
|
+
}
|
|
558
|
+
if (segment.tokens.length === 0) {
|
|
559
|
+
continue;
|
|
560
|
+
}
|
|
561
|
+
const nestedCommand = extractShellCommand(segment.tokens);
|
|
562
|
+
if (nestedCommand) {
|
|
563
|
+
const nested = extractCommands(nestedCommand, depth + 1);
|
|
564
|
+
commands.push(...nested.commands);
|
|
565
|
+
hasUnsafeWrite ||= nested.hasUnsafeWrite;
|
|
566
|
+
parseFailed ||= nested.parseFailed || nested.commands.length === 0;
|
|
567
|
+
continue;
|
|
568
|
+
}
|
|
569
|
+
commands.push(segment.tokens.join(" "));
|
|
570
|
+
}
|
|
571
|
+
return {
|
|
572
|
+
commands,
|
|
573
|
+
hasUnsafeWrite,
|
|
574
|
+
parseFailed,
|
|
575
|
+
};
|
|
576
|
+
}
|
|
577
|
+
function matchesRule(commandLine, rules) {
|
|
578
|
+
return rules.some((rule) => rule.test(commandLine));
|
|
579
|
+
}
|
|
580
|
+
function convertAutoApproveEntryToRegex(value) {
|
|
581
|
+
const regexMatch = value.match(/^\/(?<pattern>.+)\/(?<flags>[dgimsuvy]*)$/);
|
|
582
|
+
const regexPattern = regexMatch?.groups?.pattern;
|
|
583
|
+
if (regexPattern) {
|
|
584
|
+
let flags = regexMatch.groups?.flags || "";
|
|
585
|
+
if (flags.includes("g")) {
|
|
586
|
+
flags = flags.replaceAll("g", "");
|
|
587
|
+
}
|
|
588
|
+
try {
|
|
589
|
+
return new RegExp(regexPattern, flags || undefined);
|
|
590
|
+
}
|
|
591
|
+
catch {
|
|
592
|
+
return NEVER_MATCH_REGEX;
|
|
593
|
+
}
|
|
594
|
+
}
|
|
595
|
+
if (value === "") {
|
|
596
|
+
return NEVER_MATCH_REGEX;
|
|
597
|
+
}
|
|
598
|
+
const escaped = escapeRegExp(value);
|
|
599
|
+
return new RegExp(`^${escaped}\\b`, "i");
|
|
600
|
+
}
|
|
601
|
+
function compileRules(ruleConfig) {
|
|
602
|
+
const allowRules = [];
|
|
603
|
+
const denyRules = [];
|
|
604
|
+
const allowCommandLineRules = [];
|
|
605
|
+
const denyCommandLineRules = [];
|
|
606
|
+
for (const [key, value] of Object.entries(ruleConfig || {})) {
|
|
607
|
+
const regex = convertAutoApproveEntryToRegex(key);
|
|
608
|
+
const ruleValue = value;
|
|
609
|
+
if (typeof ruleValue === "boolean") {
|
|
610
|
+
if (ruleValue) {
|
|
611
|
+
allowRules.push(regex);
|
|
612
|
+
}
|
|
613
|
+
else {
|
|
614
|
+
denyRules.push(regex);
|
|
615
|
+
}
|
|
616
|
+
continue;
|
|
617
|
+
}
|
|
618
|
+
if (ruleValue.approve) {
|
|
619
|
+
if (ruleValue.matchCommandLine === true) {
|
|
620
|
+
allowCommandLineRules.push(regex);
|
|
621
|
+
}
|
|
622
|
+
else {
|
|
623
|
+
allowRules.push(regex);
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
else if (ruleValue.matchCommandLine === true) {
|
|
627
|
+
denyCommandLineRules.push(regex);
|
|
628
|
+
}
|
|
629
|
+
else {
|
|
630
|
+
denyRules.push(regex);
|
|
631
|
+
}
|
|
632
|
+
}
|
|
633
|
+
return {
|
|
634
|
+
allowRules,
|
|
635
|
+
denyRules,
|
|
636
|
+
allowCommandLineRules,
|
|
637
|
+
denyCommandLineRules,
|
|
638
|
+
};
|
|
639
|
+
}
|
|
640
|
+
function isApprovedLeafCommand(commandLine, customRules, defaultRules) {
|
|
641
|
+
const tokens = tokenize(commandLine);
|
|
642
|
+
const head = normalizeCommandKeyword(tokens[0]);
|
|
643
|
+
if (!head || NEVER_AUTO_APPROVE_COMMANDS.has(head)) {
|
|
644
|
+
return false;
|
|
645
|
+
}
|
|
646
|
+
if (matchesRule(commandLine, customRules.denyRules)) {
|
|
647
|
+
return false;
|
|
648
|
+
}
|
|
649
|
+
if (matchesRule(commandLine, customRules.allowRules)) {
|
|
650
|
+
return true;
|
|
651
|
+
}
|
|
652
|
+
if (matchesRule(commandLine, defaultRules.denyRules)) {
|
|
653
|
+
return false;
|
|
654
|
+
}
|
|
655
|
+
return matchesRule(commandLine, defaultRules.allowRules);
|
|
656
|
+
}
|
|
657
|
+
export function shouldAutoApproveTerminalCommand(commandLine, customRuleConfig) {
|
|
658
|
+
const trimmed = commandLine?.trim();
|
|
659
|
+
if (!trimmed) {
|
|
660
|
+
return true;
|
|
661
|
+
}
|
|
662
|
+
const customRules = compileRules(customRuleConfig);
|
|
663
|
+
const defaultRules = compileRules(DEFAULT_RULES);
|
|
664
|
+
if (matchesRule(trimmed, customRules.denyCommandLineRules)) {
|
|
665
|
+
return false;
|
|
666
|
+
}
|
|
667
|
+
const extracted = extractCommands(trimmed);
|
|
668
|
+
if (extracted.parseFailed || extracted.hasUnsafeWrite || extracted.commands.length === 0) {
|
|
669
|
+
return false;
|
|
670
|
+
}
|
|
671
|
+
const allLeafCommandsApproved = extracted.commands.every((command) => isApprovedLeafCommand(command, customRules, defaultRules));
|
|
672
|
+
if (allLeafCommandsApproved) {
|
|
673
|
+
return true;
|
|
674
|
+
}
|
|
675
|
+
return matchesRule(trimmed, customRules.allowCommandLineRules);
|
|
676
|
+
}
|