micro-models-agent 0.56.5 → 0.57.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +481 -463
- package/README.md +358 -358
- package/dist/certification/certifications.json +493 -493
- package/dist/cli/commands.js +447 -0
- package/dist/cli/completer.js +167 -0
- package/dist/cli/index.js +2 -0
- package/dist/cli/main.js +153 -0
- package/dist/cli/plugin-commands.js +36 -0
- package/dist/cli/repl-commands.js +761 -0
- package/dist/cli/repl.js +702 -0
- package/dist/cli/run-result.js +33 -0
- package/dist/cli/security-commands.js +164 -0
- package/dist/cli/setup.js +237 -0
- package/dist/config/config.js +276 -0
- package/dist/config/defaults.js +141 -0
- package/dist/config/domains.js +179 -0
- package/dist/config/experts.js +15 -0
- package/dist/config/index.js +4 -0
- package/dist/config/security.js +213 -0
- package/dist/config/types.js +1 -0
- package/dist/core/agent-moe.js +102 -0
- package/dist/core/agent.js +1018 -0
- package/dist/core/bootstrap.js +481 -0
- package/dist/core/crash-handler.js +51 -0
- package/dist/core/environment.js +199 -0
- package/dist/core/index.js +2 -0
- package/dist/core/prompt-builder.js +76 -0
- package/dist/core/session-logger.js +251 -0
- package/dist/core/types.js +1 -0
- package/dist/core/version.js +26 -0
- package/dist/core/workspace.js +76 -0
- package/dist/i18n/en.json +679 -0
- package/dist/i18n/index.js +46 -0
- package/dist/i18n/ru.json +679 -0
- package/dist/index.js +22 -0
- package/dist/llm/image-utils.js +143 -0
- package/dist/llm/index.js +4 -0
- package/dist/llm/model-loader.js +78 -0
- package/dist/llm/openai-compat.js +497 -0
- package/dist/llm/orchestrator.js +200 -0
- package/dist/llm/provider.js +10 -0
- package/dist/llm/response.js +39 -0
- package/dist/llm/token-counter.js +39 -0
- package/dist/llm/types.js +1 -0
- package/dist/logger/app-logger.js +189 -0
- package/dist/logger/file-log.js +151 -0
- package/dist/logger/index.js +1 -0
- package/dist/main.js +457 -324
- package/dist/migration/backup.js +45 -0
- package/dist/migration/detect.js +50 -0
- package/dist/migration/index.js +2 -0
- package/dist/modules/artifacts/store.js +61 -0
- package/dist/modules/browser/actions.js +76 -0
- package/dist/modules/browser/bridge-client.js +199 -0
- package/dist/modules/browser/bridge-path.js +10 -0
- package/dist/modules/browser/bridge-server.mjs +219 -219
- package/dist/modules/browser/cookie-store.js +24 -0
- package/dist/modules/browser/driver.js +136 -0
- package/dist/modules/browser/index.js +7 -0
- package/dist/modules/browser/module.js +29 -0
- package/dist/modules/browser/session.js +342 -0
- package/dist/modules/browser/snapshot.js +148 -0
- package/dist/modules/browser/types.js +12 -0
- package/dist/modules/certification/cli.js +213 -0
- package/dist/modules/certification/fact-checker.js +82 -0
- package/dist/modules/certification/loader.js +106 -0
- package/dist/modules/certification/manifest.js +58 -0
- package/dist/modules/certification/runner.js +245 -0
- package/dist/modules/certification/scenarios.js +407 -0
- package/dist/modules/certification/types.js +1 -0
- package/dist/modules/context/chunk-query.js +100 -0
- package/dist/modules/context/fact-extractor.js +168 -0
- package/dist/modules/context/history.js +15 -0
- package/dist/modules/context/index.js +1 -0
- package/dist/modules/context/manager.js +440 -0
- package/dist/modules/execution/audit-runners.js +206 -0
- package/dist/modules/execution/auditor.js +218 -0
- package/dist/modules/execution/execution-plugin.js +431 -0
- package/dist/modules/execution/index.js +8 -0
- package/dist/modules/execution/module.js +625 -0
- package/dist/modules/execution/moe-executor.js +304 -0
- package/dist/modules/execution/plan-coverage.js +68 -0
- package/dist/modules/execution/plan-persister.js +46 -0
- package/dist/modules/execution/plan-store.js +196 -0
- package/dist/modules/execution/plan-tool.js +677 -0
- package/dist/modules/execution/plan-validator.js +153 -0
- package/dist/modules/execution/planner.js +94 -0
- package/dist/modules/execution/stuck-detector.js +746 -0
- package/dist/modules/execution/tracker.js +69 -0
- package/dist/modules/execution/types.js +1 -0
- package/dist/modules/execution/verifier.js +235 -0
- package/dist/modules/execution/windows-commands.js +41 -0
- package/dist/modules/hallucination/confidence.js +66 -0
- package/dist/modules/hallucination/consistency.js +26 -0
- package/dist/modules/hallucination/detector.js +47 -0
- package/dist/modules/hallucination/factual.js +169 -0
- package/dist/modules/hallucination/index.js +5 -0
- package/dist/modules/hallucination/js-identifiers.js +262 -0
- package/dist/modules/hallucination/llm-judge.js +101 -0
- package/dist/modules/index.js +5 -0
- package/dist/modules/indexer/cache.js +40 -0
- package/dist/modules/indexer/index.js +3 -0
- package/dist/modules/indexer/module.js +246 -0
- package/dist/modules/indexer/project-profile.js +183 -0
- package/dist/modules/indexer/walker.js +101 -0
- package/dist/modules/lsp/check-tool.js +58 -0
- package/dist/modules/lsp/client.js +389 -0
- package/dist/modules/lsp/command.js +60 -0
- package/dist/modules/lsp/config.js +135 -0
- package/dist/modules/lsp/index.js +3 -0
- package/dist/modules/lsp/module.js +260 -0
- package/dist/modules/lsp/probe.js +86 -0
- package/dist/modules/lsp/project-root.js +32 -0
- package/dist/modules/lsp/startup-check.js +144 -0
- package/dist/modules/lsp/types.js +1 -0
- package/dist/modules/mcp/client.js +399 -0
- package/dist/modules/mcp/index.js +3 -0
- package/dist/modules/mcp/module.js +142 -0
- package/dist/modules/mcp/registry.js +15 -0
- package/dist/modules/memory/index.js +1 -0
- package/dist/modules/memory/module.js +96 -0
- package/dist/modules/memory/search.js +42 -0
- package/dist/modules/memory/store.js +69 -0
- package/dist/modules/pipelines/engine.js +60 -0
- package/dist/modules/pipelines/index.js +3 -0
- package/dist/modules/pipelines/parser.js +56 -0
- package/dist/modules/pipelines/template.js +14 -0
- package/dist/modules/plugins/builtin/lint-on-write.js +334 -0
- package/dist/modules/plugins/builtin/notify.js +9 -0
- package/dist/modules/plugins/index.js +1 -0
- package/dist/modules/plugins/loader.js +70 -0
- package/dist/modules/plugins/manager.js +261 -0
- package/dist/modules/plugins/types.js +1 -0
- package/dist/modules/pricing/index.js +61 -0
- package/dist/modules/pricing/prices.js +129 -0
- package/dist/modules/processes/detect.js +34 -0
- package/dist/modules/processes/index.js +2 -0
- package/dist/modules/processes/registry.js +327 -0
- package/dist/modules/processes/runner.js +23 -0
- package/dist/modules/providers/create.js +22 -0
- package/dist/modules/providers/fallback.js +79 -0
- package/dist/modules/providers/health.js +46 -0
- package/dist/modules/providers/index.js +5 -0
- package/dist/modules/providers/manager.js +161 -0
- package/dist/modules/providers/presets.js +128 -0
- package/dist/modules/providers/registry.js +22 -0
- package/dist/modules/providers/types.js +1 -0
- package/dist/modules/registry.js +48 -0
- package/dist/modules/security/audit-log.js +136 -0
- package/dist/modules/security/audit-notifier.js +292 -0
- package/dist/modules/security/command-validator.js +219 -0
- package/dist/modules/security/content-scanner.js +53 -0
- package/dist/modules/security/data-sanitizer.js +89 -0
- package/dist/modules/security/encryption.js +242 -0
- package/dist/modules/security/index.js +14 -0
- package/dist/modules/security/network-validator.js +88 -0
- package/dist/modules/security/path-validator.js +203 -0
- package/dist/modules/security/rate-limiter.js +119 -0
- package/dist/modules/security/security-policies.js +531 -0
- package/dist/modules/security/session-encryption.js +210 -0
- package/dist/modules/security/session-isolation.js +95 -0
- package/dist/modules/session/index.js +3 -0
- package/dist/modules/session/manager.js +172 -0
- package/dist/modules/session/module.js +24 -0
- package/dist/modules/session/store.js +222 -0
- package/dist/modules/session/types.js +1 -0
- package/dist/modules/skills/index.js +2 -0
- package/dist/modules/skills/loader.js +72 -0
- package/dist/modules/skills/matcher.js +27 -0
- package/dist/modules/skills/module.js +129 -0
- package/dist/modules/types.js +1 -0
- package/dist/modules/updater/checker.js +96 -0
- package/dist/modules/updater/index.js +2 -0
- package/dist/modules/updater/module.js +116 -0
- package/dist/modules/user-profile/compressor.js +16 -0
- package/dist/modules/user-profile/index.js +1 -0
- package/dist/modules/user-profile/profile.js +68 -0
- package/dist/skills/builtin/git.md +36 -36
- package/dist/skills/builtin/typescript.md +35 -35
- package/dist/tools/approve.js +33 -0
- package/dist/tools/attach-image.js +101 -0
- package/dist/tools/bash.js +519 -0
- package/dist/tools/browser.js +115 -0
- package/dist/tools/chunk-query.js +100 -0
- package/dist/tools/create-dir.js +56 -0
- package/dist/tools/delete-file.js +63 -0
- package/dist/tools/download-file.js +117 -0
- package/dist/tools/edit-file.js +80 -0
- package/dist/tools/enable-tools.js +59 -0
- package/dist/tools/executor.js +154 -0
- package/dist/tools/file-info.js +47 -0
- package/dist/tools/filter-tools.js +17 -0
- package/dist/tools/glob-tool.js +27 -0
- package/dist/tools/grep-tool.js +125 -0
- package/dist/tools/hidden-tools-block.js +37 -0
- package/dist/tools/index.js +78 -0
- package/dist/tools/list-dir.js +49 -0
- package/dist/tools/load-skill.js +43 -0
- package/dist/tools/mcp-call.js +69 -0
- package/dist/tools/move-file.js +86 -0
- package/dist/tools/path-utils.js +101 -0
- package/dist/tools/pipeline-run.js +145 -0
- package/dist/tools/preview.js +2 -0
- package/dist/tools/process-kill.js +40 -0
- package/dist/tools/process-list.js +37 -0
- package/dist/tools/process-log.js +54 -0
- package/dist/tools/question.js +141 -0
- package/dist/tools/read-file.js +179 -0
- package/dist/tools/recall.js +118 -0
- package/dist/tools/registry.js +47 -0
- package/dist/tools/remember.js +68 -0
- package/dist/tools/scope-check.js +32 -0
- package/dist/tools/search-history.js +85 -0
- package/dist/tools/subagent.js +196 -0
- package/dist/tools/types.js +1 -0
- package/dist/tools/user-input.js +123 -0
- package/dist/tools/web-browse.js +87 -0
- package/dist/tools/web-fetch.js +119 -0
- package/dist/tools/web-search.js +105 -0
- package/dist/tools/write-file.js +82 -0
- package/dist/ui/box.js +77 -0
- package/dist/ui/colors.js +4 -0
- package/dist/ui/diff.js +178 -0
- package/dist/ui/index.js +6 -0
- package/dist/ui/line-editor.js +822 -0
- package/dist/ui/line-math.js +73 -0
- package/dist/ui/md-formatter.js +212 -0
- package/dist/ui/output.js +13 -0
- package/dist/ui/plan-view.js +103 -0
- package/dist/ui/renderer.js +259 -0
- package/dist/ui/spinner.js +70 -0
- package/dist/ui/table.js +144 -0
- package/package.json +51 -51
|
@@ -0,0 +1,531 @@
|
|
|
1
|
+
import { mergeSecurityConfig } from "../../config/security";
|
|
2
|
+
/**
|
|
3
|
+
* Strict security policy - maximum security, minimum flexibility
|
|
4
|
+
* Recommended for: production environments, sensitive data, multi-user systems
|
|
5
|
+
*/
|
|
6
|
+
export const STRICT_POLICY = {
|
|
7
|
+
name: "Strict",
|
|
8
|
+
description: "Maximum security with minimal flexibility. Blocks most dangerous operations.",
|
|
9
|
+
preset: "strict",
|
|
10
|
+
recommendedFor: ["production", "sensitive-data", "multi-user", "enterprise"],
|
|
11
|
+
config: {
|
|
12
|
+
enabled: true,
|
|
13
|
+
bash: {
|
|
14
|
+
enabled: true,
|
|
15
|
+
blacklist: [
|
|
16
|
+
"rm",
|
|
17
|
+
"dd",
|
|
18
|
+
"chmod",
|
|
19
|
+
"wget",
|
|
20
|
+
"curl",
|
|
21
|
+
"scp",
|
|
22
|
+
"ssh",
|
|
23
|
+
"nc",
|
|
24
|
+
"netcat",
|
|
25
|
+
"mknod",
|
|
26
|
+
"mkfifo",
|
|
27
|
+
"ln",
|
|
28
|
+
"chown",
|
|
29
|
+
"chgrp",
|
|
30
|
+
"useradd",
|
|
31
|
+
"usermod",
|
|
32
|
+
"passwd",
|
|
33
|
+
"sudo",
|
|
34
|
+
"su",
|
|
35
|
+
"exec",
|
|
36
|
+
"eval",
|
|
37
|
+
"source",
|
|
38
|
+
"kill",
|
|
39
|
+
"pkill",
|
|
40
|
+
"killall",
|
|
41
|
+
"shutdown",
|
|
42
|
+
"reboot",
|
|
43
|
+
"halt",
|
|
44
|
+
"poweroff",
|
|
45
|
+
"format",
|
|
46
|
+
"fdisk",
|
|
47
|
+
"parted",
|
|
48
|
+
"mkfs",
|
|
49
|
+
"mount",
|
|
50
|
+
"umount",
|
|
51
|
+
"mv",
|
|
52
|
+
"cp",
|
|
53
|
+
],
|
|
54
|
+
whitelist: ["ls", "cat", "echo", "grep", "find", "pwd", "whoami", "date"],
|
|
55
|
+
blockDangerousFlags: true,
|
|
56
|
+
dangerousFlags: [
|
|
57
|
+
"--force",
|
|
58
|
+
"-rf",
|
|
59
|
+
"--no-preserve-root",
|
|
60
|
+
"--recursive",
|
|
61
|
+
"--all",
|
|
62
|
+
"-x",
|
|
63
|
+
"-e",
|
|
64
|
+
"--delete",
|
|
65
|
+
"--remove",
|
|
66
|
+
"--dangerous",
|
|
67
|
+
"--yes",
|
|
68
|
+
"-y",
|
|
69
|
+
"--no-confirm",
|
|
70
|
+
"-R",
|
|
71
|
+
"--no-clobber",
|
|
72
|
+
],
|
|
73
|
+
dangerousOperators: [">", ">>", "2>", "2>>", "|", "&&", "||", ";", "&", "`"],
|
|
74
|
+
logCommands: true,
|
|
75
|
+
},
|
|
76
|
+
paths: {
|
|
77
|
+
enabled: true,
|
|
78
|
+
denied: [
|
|
79
|
+
".git/",
|
|
80
|
+
"node_modules/",
|
|
81
|
+
".env",
|
|
82
|
+
"*.key",
|
|
83
|
+
"*.pem",
|
|
84
|
+
"*.crt",
|
|
85
|
+
"*.p12",
|
|
86
|
+
"*.pfx",
|
|
87
|
+
"*.secret",
|
|
88
|
+
"*.token",
|
|
89
|
+
"package-lock.json",
|
|
90
|
+
"bun.lock",
|
|
91
|
+
"yarn.lock",
|
|
92
|
+
"pnpm-lock.yaml",
|
|
93
|
+
".ssh/",
|
|
94
|
+
".config/",
|
|
95
|
+
".bashrc",
|
|
96
|
+
".bash_profile",
|
|
97
|
+
".zshrc",
|
|
98
|
+
".profile",
|
|
99
|
+
"/etc/",
|
|
100
|
+
"/usr/",
|
|
101
|
+
"/var/",
|
|
102
|
+
"/bin/",
|
|
103
|
+
"/sbin/",
|
|
104
|
+
"/root/",
|
|
105
|
+
"/home/",
|
|
106
|
+
],
|
|
107
|
+
allowed: [],
|
|
108
|
+
},
|
|
109
|
+
network: {
|
|
110
|
+
enabled: true,
|
|
111
|
+
deniedDomains: [
|
|
112
|
+
"localhost",
|
|
113
|
+
"127.0.0.1",
|
|
114
|
+
"0.0.0.0",
|
|
115
|
+
"::1",
|
|
116
|
+
"*.internal",
|
|
117
|
+
"*.local",
|
|
118
|
+
"192.168.*",
|
|
119
|
+
"10.*",
|
|
120
|
+
"172.16.*",
|
|
121
|
+
],
|
|
122
|
+
allowedDomains: [],
|
|
123
|
+
requestTimeout: 10000,
|
|
124
|
+
maxResponseSize: 10000,
|
|
125
|
+
},
|
|
126
|
+
maxRecursionDepth: 2,
|
|
127
|
+
maxFileOperations: 50,
|
|
128
|
+
rateLimits: {
|
|
129
|
+
maxRequestsPerMinute: 30,
|
|
130
|
+
maxParallelTasks: 3,
|
|
131
|
+
},
|
|
132
|
+
contentScan: {
|
|
133
|
+
enabled: true,
|
|
134
|
+
dangerousPatterns: [
|
|
135
|
+
/eval\(/,
|
|
136
|
+
/new Function\(/,
|
|
137
|
+
/child_process\.exec\(/,
|
|
138
|
+
/child_process\.spawn\(/,
|
|
139
|
+
/require\('child_process'\)/,
|
|
140
|
+
/require\('http'\)\.createServer/,
|
|
141
|
+
/require\('net'\)\.createServer/,
|
|
142
|
+
/process\.exit\(/,
|
|
143
|
+
/while\(true\)/,
|
|
144
|
+
/for\(\;\;\)/,
|
|
145
|
+
/rm -rf/,
|
|
146
|
+
/dd if=/,
|
|
147
|
+
/chmod 777/,
|
|
148
|
+
/wget /,
|
|
149
|
+
/curl /,
|
|
150
|
+
/ssh /,
|
|
151
|
+
/scp /,
|
|
152
|
+
],
|
|
153
|
+
},
|
|
154
|
+
sessionEncryption: {
|
|
155
|
+
enabled: true,
|
|
156
|
+
encryptHistory: true,
|
|
157
|
+
encryptSessionLog: true,
|
|
158
|
+
},
|
|
159
|
+
auditNotifier: {
|
|
160
|
+
enabled: true,
|
|
161
|
+
minSeverity: "low",
|
|
162
|
+
eventTypes: [
|
|
163
|
+
"security_block",
|
|
164
|
+
"bash_command",
|
|
165
|
+
"file_operation",
|
|
166
|
+
"network_request",
|
|
167
|
+
"authentication",
|
|
168
|
+
"configuration_change",
|
|
169
|
+
"session_start",
|
|
170
|
+
"session_end",
|
|
171
|
+
],
|
|
172
|
+
maxRetries: 3,
|
|
173
|
+
},
|
|
174
|
+
},
|
|
175
|
+
};
|
|
176
|
+
/**
|
|
177
|
+
* Balanced security policy - good security with reasonable flexibility
|
|
178
|
+
* Recommended for: development, single-user systems, general use
|
|
179
|
+
*/
|
|
180
|
+
export const BALANCED_POLICY = {
|
|
181
|
+
name: "Balanced",
|
|
182
|
+
description: "Good security with reasonable flexibility. Default policy.",
|
|
183
|
+
preset: "balanced",
|
|
184
|
+
recommendedFor: ["development", "single-user", "general-use", "testing"],
|
|
185
|
+
config: {
|
|
186
|
+
enabled: true,
|
|
187
|
+
bash: {
|
|
188
|
+
enabled: true,
|
|
189
|
+
blacklist: [
|
|
190
|
+
"rm",
|
|
191
|
+
"dd",
|
|
192
|
+
"chmod",
|
|
193
|
+
"wget",
|
|
194
|
+
"curl",
|
|
195
|
+
"scp",
|
|
196
|
+
"ssh",
|
|
197
|
+
"nc",
|
|
198
|
+
"netcat",
|
|
199
|
+
"mknod",
|
|
200
|
+
"mkfifo",
|
|
201
|
+
"useradd",
|
|
202
|
+
"usermod",
|
|
203
|
+
"passwd",
|
|
204
|
+
"sudo",
|
|
205
|
+
"su",
|
|
206
|
+
"shutdown",
|
|
207
|
+
"reboot",
|
|
208
|
+
"halt",
|
|
209
|
+
"poweroff",
|
|
210
|
+
"format",
|
|
211
|
+
"fdisk",
|
|
212
|
+
"parted",
|
|
213
|
+
"mkfs",
|
|
214
|
+
],
|
|
215
|
+
whitelist: [],
|
|
216
|
+
blockDangerousFlags: true,
|
|
217
|
+
dangerousFlags: [
|
|
218
|
+
"--force",
|
|
219
|
+
"-rf",
|
|
220
|
+
"--no-preserve-root",
|
|
221
|
+
"--recursive",
|
|
222
|
+
"--all",
|
|
223
|
+
"--delete",
|
|
224
|
+
"--remove",
|
|
225
|
+
"--dangerous",
|
|
226
|
+
"--yes",
|
|
227
|
+
"-y",
|
|
228
|
+
"--no-confirm",
|
|
229
|
+
],
|
|
230
|
+
dangerousOperators: ["|", "&&", "||", ";", "&", "`"],
|
|
231
|
+
logCommands: true,
|
|
232
|
+
},
|
|
233
|
+
paths: {
|
|
234
|
+
enabled: true,
|
|
235
|
+
denied: [
|
|
236
|
+
".git/",
|
|
237
|
+
"node_modules/",
|
|
238
|
+
".env",
|
|
239
|
+
"*.key",
|
|
240
|
+
"*.pem",
|
|
241
|
+
"*.crt",
|
|
242
|
+
"*.p12",
|
|
243
|
+
"*.pfx",
|
|
244
|
+
"*.secret",
|
|
245
|
+
"*.token",
|
|
246
|
+
"package-lock.json",
|
|
247
|
+
"bun.lock",
|
|
248
|
+
"yarn.lock",
|
|
249
|
+
"pnpm-lock.yaml",
|
|
250
|
+
".ssh/",
|
|
251
|
+
],
|
|
252
|
+
allowed: [],
|
|
253
|
+
},
|
|
254
|
+
network: {
|
|
255
|
+
enabled: true,
|
|
256
|
+
deniedDomains: [],
|
|
257
|
+
allowedDomains: [],
|
|
258
|
+
requestTimeout: 15000,
|
|
259
|
+
maxResponseSize: 15000,
|
|
260
|
+
},
|
|
261
|
+
maxRecursionDepth: 3,
|
|
262
|
+
maxFileOperations: 100,
|
|
263
|
+
rateLimits: {
|
|
264
|
+
maxRequestsPerMinute: 60,
|
|
265
|
+
maxParallelTasks: 5,
|
|
266
|
+
},
|
|
267
|
+
contentScan: {
|
|
268
|
+
enabled: true,
|
|
269
|
+
dangerousPatterns: [
|
|
270
|
+
/eval\(/,
|
|
271
|
+
/new Function\(/,
|
|
272
|
+
/child_process\.exec\(/,
|
|
273
|
+
/child_process\.spawn\(/,
|
|
274
|
+
/require\('child_process'\)/,
|
|
275
|
+
/process\.exit\(/,
|
|
276
|
+
/while\(true\)/,
|
|
277
|
+
/for\(\;\;\)/,
|
|
278
|
+
/rm -rf/,
|
|
279
|
+
/dd if=/,
|
|
280
|
+
/chmod 777/,
|
|
281
|
+
],
|
|
282
|
+
},
|
|
283
|
+
sessionEncryption: {
|
|
284
|
+
enabled: false,
|
|
285
|
+
encryptHistory: true,
|
|
286
|
+
encryptSessionLog: true,
|
|
287
|
+
},
|
|
288
|
+
auditNotifier: {
|
|
289
|
+
enabled: false,
|
|
290
|
+
minSeverity: "medium",
|
|
291
|
+
eventTypes: ["security_block", "bash_command", "file_operation", "network_request"],
|
|
292
|
+
maxRetries: 3,
|
|
293
|
+
},
|
|
294
|
+
},
|
|
295
|
+
};
|
|
296
|
+
/**
|
|
297
|
+
* Permissive security policy - minimal security, maximum flexibility
|
|
298
|
+
* Recommended for: trusted environments, local development, testing
|
|
299
|
+
*/
|
|
300
|
+
export const PERMISSIVE_POLICY = {
|
|
301
|
+
name: "Permissive",
|
|
302
|
+
description: "Minimal security with maximum flexibility. Use with caution.",
|
|
303
|
+
preset: "permissive",
|
|
304
|
+
recommendedFor: ["trusted-environment", "local-dev", "testing", "sandbox"],
|
|
305
|
+
config: {
|
|
306
|
+
enabled: true,
|
|
307
|
+
bash: {
|
|
308
|
+
enabled: true,
|
|
309
|
+
blacklist: [
|
|
310
|
+
"rm",
|
|
311
|
+
"dd",
|
|
312
|
+
"shutdown",
|
|
313
|
+
"reboot",
|
|
314
|
+
"halt",
|
|
315
|
+
"poweroff",
|
|
316
|
+
"format",
|
|
317
|
+
"fdisk",
|
|
318
|
+
"parted",
|
|
319
|
+
"mkfs",
|
|
320
|
+
],
|
|
321
|
+
whitelist: [],
|
|
322
|
+
blockDangerousFlags: false,
|
|
323
|
+
dangerousFlags: ["--force", "-rf", "--no-preserve-root"],
|
|
324
|
+
dangerousOperators: [],
|
|
325
|
+
logCommands: true,
|
|
326
|
+
},
|
|
327
|
+
paths: {
|
|
328
|
+
enabled: true,
|
|
329
|
+
denied: [".env", "*.key", "*.pem", "*.crt", "*.p12", "*.pfx"],
|
|
330
|
+
allowed: [],
|
|
331
|
+
},
|
|
332
|
+
network: {
|
|
333
|
+
enabled: true,
|
|
334
|
+
deniedDomains: [],
|
|
335
|
+
allowedDomains: [],
|
|
336
|
+
requestTimeout: 30000,
|
|
337
|
+
maxResponseSize: 30000,
|
|
338
|
+
},
|
|
339
|
+
maxRecursionDepth: 5,
|
|
340
|
+
maxFileOperations: 200,
|
|
341
|
+
rateLimits: {
|
|
342
|
+
maxRequestsPerMinute: 120,
|
|
343
|
+
maxParallelTasks: 10,
|
|
344
|
+
},
|
|
345
|
+
contentScan: {
|
|
346
|
+
enabled: true,
|
|
347
|
+
dangerousPatterns: [
|
|
348
|
+
/eval\(/,
|
|
349
|
+
/new Function\(/,
|
|
350
|
+
/while\(true\)/,
|
|
351
|
+
/for\(\;\;\)/,
|
|
352
|
+
/rm -rf/,
|
|
353
|
+
/dd if=/,
|
|
354
|
+
],
|
|
355
|
+
},
|
|
356
|
+
sessionEncryption: {
|
|
357
|
+
enabled: false,
|
|
358
|
+
encryptHistory: false,
|
|
359
|
+
encryptSessionLog: false,
|
|
360
|
+
},
|
|
361
|
+
auditNotifier: {
|
|
362
|
+
enabled: false,
|
|
363
|
+
minSeverity: "high",
|
|
364
|
+
eventTypes: ["security_block"],
|
|
365
|
+
maxRetries: 2,
|
|
366
|
+
},
|
|
367
|
+
},
|
|
368
|
+
};
|
|
369
|
+
/**
|
|
370
|
+
* All available security policies
|
|
371
|
+
*/
|
|
372
|
+
export const SECURITY_POLICIES = {
|
|
373
|
+
strict: STRICT_POLICY,
|
|
374
|
+
balanced: BALANCED_POLICY,
|
|
375
|
+
permissive: PERMISSIVE_POLICY,
|
|
376
|
+
custom: {
|
|
377
|
+
name: "Custom",
|
|
378
|
+
description: "Custom security configuration",
|
|
379
|
+
preset: "custom",
|
|
380
|
+
recommendedFor: [],
|
|
381
|
+
config: {},
|
|
382
|
+
},
|
|
383
|
+
};
|
|
384
|
+
/**
|
|
385
|
+
* Security policy manager
|
|
386
|
+
*/
|
|
387
|
+
export class SecurityPolicyManager {
|
|
388
|
+
currentPolicy = "balanced";
|
|
389
|
+
customConfig = {};
|
|
390
|
+
/**
|
|
391
|
+
* Get all available policies
|
|
392
|
+
*/
|
|
393
|
+
getPolicies() {
|
|
394
|
+
return Object.values(SECURITY_POLICIES);
|
|
395
|
+
}
|
|
396
|
+
/**
|
|
397
|
+
* Get a specific policy by name
|
|
398
|
+
*/
|
|
399
|
+
getPolicy(preset) {
|
|
400
|
+
return SECURITY_POLICIES[preset] || SECURITY_POLICIES.balanced;
|
|
401
|
+
}
|
|
402
|
+
/**
|
|
403
|
+
* Get the current policy
|
|
404
|
+
*/
|
|
405
|
+
getCurrentPolicy() {
|
|
406
|
+
if (this.currentPolicy === "custom") {
|
|
407
|
+
return {
|
|
408
|
+
...SECURITY_POLICIES.custom,
|
|
409
|
+
config: this.customConfig,
|
|
410
|
+
};
|
|
411
|
+
}
|
|
412
|
+
return this.getPolicy(this.currentPolicy);
|
|
413
|
+
}
|
|
414
|
+
/**
|
|
415
|
+
* Set the current policy
|
|
416
|
+
*/
|
|
417
|
+
setPolicy(preset) {
|
|
418
|
+
this.currentPolicy = preset;
|
|
419
|
+
}
|
|
420
|
+
/**
|
|
421
|
+
* Set custom configuration (for 'custom' preset)
|
|
422
|
+
*/
|
|
423
|
+
setCustomConfig(config) {
|
|
424
|
+
this.customConfig = config;
|
|
425
|
+
this.currentPolicy = "custom";
|
|
426
|
+
}
|
|
427
|
+
/**
|
|
428
|
+
* Get the current security configuration
|
|
429
|
+
*/
|
|
430
|
+
getConfig() {
|
|
431
|
+
const policy = this.getCurrentPolicy();
|
|
432
|
+
return mergeSecurityConfig({
|
|
433
|
+
...policy.config,
|
|
434
|
+
...(this.currentPolicy === "custom" ? this.customConfig : {}),
|
|
435
|
+
});
|
|
436
|
+
}
|
|
437
|
+
/**
|
|
438
|
+
* Apply a policy and return the merged configuration
|
|
439
|
+
*/
|
|
440
|
+
applyPolicy(preset, customOverrides) {
|
|
441
|
+
this.setPolicy(preset);
|
|
442
|
+
if (customOverrides) {
|
|
443
|
+
this.customConfig = customOverrides;
|
|
444
|
+
this.currentPolicy = "custom";
|
|
445
|
+
}
|
|
446
|
+
return this.getConfig();
|
|
447
|
+
}
|
|
448
|
+
/**
|
|
449
|
+
* Get policy recommendation for a use case
|
|
450
|
+
*/
|
|
451
|
+
getRecommendation(useCase) {
|
|
452
|
+
for (const policy of this.getPolicies()) {
|
|
453
|
+
if (policy.recommendedFor.includes(useCase)) {
|
|
454
|
+
return policy;
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
return BALANCED_POLICY;
|
|
458
|
+
}
|
|
459
|
+
/**
|
|
460
|
+
* Check if current policy allows a specific action
|
|
461
|
+
*/
|
|
462
|
+
allowsAction(action, context) {
|
|
463
|
+
const config = this.getConfig();
|
|
464
|
+
switch (action) {
|
|
465
|
+
case "bash":
|
|
466
|
+
if (context?.command) {
|
|
467
|
+
const cmd = context.command.split(" ")[0];
|
|
468
|
+
return !config.bash.blacklist.includes(cmd);
|
|
469
|
+
}
|
|
470
|
+
return true;
|
|
471
|
+
case "file_access":
|
|
472
|
+
if (context?.path) {
|
|
473
|
+
for (const denied of config.paths.denied) {
|
|
474
|
+
if (context.path.includes(denied.replace("*", ""))) {
|
|
475
|
+
return false;
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
return true;
|
|
480
|
+
case "network":
|
|
481
|
+
if (context?.path) {
|
|
482
|
+
for (const denied of config.network.deniedDomains) {
|
|
483
|
+
if (context.path.includes(denied.replace("*", ""))) {
|
|
484
|
+
return false;
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
return true;
|
|
489
|
+
default:
|
|
490
|
+
return true;
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
/**
|
|
494
|
+
* Get policy comparison
|
|
495
|
+
*/
|
|
496
|
+
comparePolicies(policy1, policy2) {
|
|
497
|
+
const config1 = this.getPolicy(policy1).config;
|
|
498
|
+
const config2 = this.getPolicy(policy2).config;
|
|
499
|
+
const comparison = {};
|
|
500
|
+
const keys = new Set([...Object.keys(config1), ...Object.keys(config2)]);
|
|
501
|
+
for (const key of keys) {
|
|
502
|
+
comparison[key] = {
|
|
503
|
+
policy1: config1[key],
|
|
504
|
+
policy2: config2[key],
|
|
505
|
+
};
|
|
506
|
+
}
|
|
507
|
+
return comparison;
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
/**
|
|
511
|
+
* Global security policy manager instance
|
|
512
|
+
*/
|
|
513
|
+
export const globalSecurityPolicyManager = new SecurityPolicyManager();
|
|
514
|
+
/**
|
|
515
|
+
* Create a security policy manager with custom configuration
|
|
516
|
+
*/
|
|
517
|
+
export function createSecurityPolicyManager() {
|
|
518
|
+
return new SecurityPolicyManager();
|
|
519
|
+
}
|
|
520
|
+
/**
|
|
521
|
+
* Get a policy by name
|
|
522
|
+
*/
|
|
523
|
+
export function getSecurityPolicy(preset) {
|
|
524
|
+
return globalSecurityPolicyManager.getPolicy(preset);
|
|
525
|
+
}
|
|
526
|
+
/**
|
|
527
|
+
* Apply a security policy
|
|
528
|
+
*/
|
|
529
|
+
export function applySecurityPolicy(preset, customOverrides) {
|
|
530
|
+
return globalSecurityPolicyManager.applyPolicy(preset, customOverrides);
|
|
531
|
+
}
|