dsh-web-toggle 0.0.0-stage → 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 +96 -2
- package/client.js +381 -0
- package/cordis.patch.yml +11 -0
- package/docs/DETAIL.md +67 -0
- package/docs/REDTEAM.md +212 -0
- package/docs/VERIFY.md +66 -0
- package/icon.svg +8 -0
- package/index.js +554 -0
- package/locale/en.json +7 -0
- package/locale/zh.json +7 -0
- package/package.json +51 -4
- package/scripts/sync-to-profile.mjs +50 -0
- package/tests/client.test.mjs +355 -0
- package/tests/host.test.mjs +395 -0
|
@@ -0,0 +1,395 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 离线验证 Host 半侧(index.js)的状态机,不依赖真实 DSH:
|
|
3
|
+
* 用假的 ctx / agent 跑一遍开关、幂等、轮次拒绝、参数校验与销毁清理。
|
|
4
|
+
* 用法:node tests/host.test.mjs
|
|
5
|
+
*/
|
|
6
|
+
import assert from 'node:assert/strict'
|
|
7
|
+
import fs from 'node:fs'
|
|
8
|
+
import os from 'node:os'
|
|
9
|
+
import path from 'node:path'
|
|
10
|
+
import { apply } from '../index.js'
|
|
11
|
+
|
|
12
|
+
/** 假工具目录:本地工具 + 各种能出网的通道 + 一个未列入白名单的本地工具。 */
|
|
13
|
+
const CATALOG = new Set([
|
|
14
|
+
// 本地
|
|
15
|
+
'acp_read_original_image',
|
|
16
|
+
'acp_status',
|
|
17
|
+
'ask_user_question',
|
|
18
|
+
'compress',
|
|
19
|
+
'create_goal',
|
|
20
|
+
'create_skill',
|
|
21
|
+
'create_worktree',
|
|
22
|
+
'decompress',
|
|
23
|
+
'edit',
|
|
24
|
+
'get_goal',
|
|
25
|
+
'job_kill',
|
|
26
|
+
'job_list',
|
|
27
|
+
'job_output',
|
|
28
|
+
'list_agents',
|
|
29
|
+
'list_subagent_models',
|
|
30
|
+
'load_workspace_dependencies',
|
|
31
|
+
'ops_discover_tools',
|
|
32
|
+
'ops_glob',
|
|
33
|
+
'ops_grep',
|
|
34
|
+
'ops_inspect_local_file',
|
|
35
|
+
'present',
|
|
36
|
+
'read_animation',
|
|
37
|
+
'read_image',
|
|
38
|
+
'remember',
|
|
39
|
+
'schedule_list',
|
|
40
|
+
'schedule_view',
|
|
41
|
+
'search_context',
|
|
42
|
+
'skill',
|
|
43
|
+
'switch_session_preset',
|
|
44
|
+
'todo_write',
|
|
45
|
+
'update_goal',
|
|
46
|
+
'working_directory',
|
|
47
|
+
'write',
|
|
48
|
+
// 能出网 / 能驱动别人出网
|
|
49
|
+
'bsk_page',
|
|
50
|
+
'bsk_session',
|
|
51
|
+
'computer_ctrl',
|
|
52
|
+
'mcp__snowluma__qq_send_message',
|
|
53
|
+
'ops_bash',
|
|
54
|
+
'plugin_manager',
|
|
55
|
+
'read_mcp_resource',
|
|
56
|
+
'schedule_create',
|
|
57
|
+
'send_message',
|
|
58
|
+
'subagent',
|
|
59
|
+
'subagent_fork',
|
|
60
|
+
'video_probe',
|
|
61
|
+
'web_fetch',
|
|
62
|
+
'web_search',
|
|
63
|
+
'workbuddy_draw_image',
|
|
64
|
+
'workflow',
|
|
65
|
+
// 未列入白名单的本地工具:必须一并隐藏(fail closed)
|
|
66
|
+
'read',
|
|
67
|
+
])
|
|
68
|
+
|
|
69
|
+
/** 造一个能被 apply 接受的 ctx,并记录注册过的命令与监听器。 */
|
|
70
|
+
function makeCtx() {
|
|
71
|
+
const commands = new Map()
|
|
72
|
+
const listeners = new Map()
|
|
73
|
+
const ctx = {
|
|
74
|
+
commands: {
|
|
75
|
+
register(definition) {
|
|
76
|
+
commands.set(definition.name, definition)
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
agents: {
|
|
80
|
+
turnBoundaryOf: () => ({ openTurnStartSeq: null }),
|
|
81
|
+
},
|
|
82
|
+
tools: {
|
|
83
|
+
// 本部署的工具目录:既含本地工具,也含各种能出网的工具;'read' 是未列入白名单的
|
|
84
|
+
// 本地工具,'acp_cache' 故意不注册,用来验证"只保留目录里真实存在的名字"。
|
|
85
|
+
view: () => ({ restrictableNames: CATALOG }),
|
|
86
|
+
},
|
|
87
|
+
on(event, listener) {
|
|
88
|
+
listeners.set(event, listener)
|
|
89
|
+
return () => listeners.delete(event)
|
|
90
|
+
},
|
|
91
|
+
}
|
|
92
|
+
return { ctx, commands, listeners }
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/** 造一个 agent:tools.restrict 记录调用并返回一个可观察的 disposer。 */
|
|
96
|
+
function makeAgent(id, { running = false } = {}) {
|
|
97
|
+
const restrictions = []
|
|
98
|
+
const disposals = []
|
|
99
|
+
const guards = []
|
|
100
|
+
const guardDisposals = []
|
|
101
|
+
const agent = {
|
|
102
|
+
status: running ? 'running' : 'idle',
|
|
103
|
+
session: { id },
|
|
104
|
+
ctx: {
|
|
105
|
+
tools: {
|
|
106
|
+
guard(fn) {
|
|
107
|
+
guards.push(fn)
|
|
108
|
+
guardDisposals.push('registered')
|
|
109
|
+
return () => guardDisposals.push('lifted')
|
|
110
|
+
},
|
|
111
|
+
restrict(filter) {
|
|
112
|
+
// 关闭 = 白名单:只给 allow,不给 deny。
|
|
113
|
+
assert.equal(filter.deny, undefined, '关闭应使用 allow 白名单,而不是 deny 少数工具')
|
|
114
|
+
assert.ok(Array.isArray(filter.allow) && filter.allow.length > 0, 'allow 不能为空')
|
|
115
|
+
for (const name of filter.allow) {
|
|
116
|
+
assert.ok(CATALOG.has(name), `allow 里出现了目录中没有的工具:${name}`)
|
|
117
|
+
}
|
|
118
|
+
restrictions.push(filter)
|
|
119
|
+
let lifted = false
|
|
120
|
+
const dispose = () => {
|
|
121
|
+
if (lifted) disposals.push('double-dispose')
|
|
122
|
+
lifted = true
|
|
123
|
+
disposals.push('lifted')
|
|
124
|
+
}
|
|
125
|
+
return dispose
|
|
126
|
+
},
|
|
127
|
+
},
|
|
128
|
+
},
|
|
129
|
+
}
|
|
130
|
+
return { agent, restrictions, disposals, guards, guardDisposals }
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
const { ctx, commands, listeners } = makeCtx()
|
|
134
|
+
apply(ctx)
|
|
135
|
+
const command = commands.get('webtoggle')
|
|
136
|
+
assert.ok(command !== undefined, '应注册 webtoggle 命令')
|
|
137
|
+
|
|
138
|
+
const call = (agent, rawInput) => command.handler({ agent, rawInput })
|
|
139
|
+
|
|
140
|
+
// 1. 初始状态:开
|
|
141
|
+
{
|
|
142
|
+
const { agent, restrictions } = makeAgent('s1')
|
|
143
|
+
const result = call(agent, 'status')
|
|
144
|
+
assert.equal(result.kind, 'success')
|
|
145
|
+
assert.match(result.text, /\[web:on\]/)
|
|
146
|
+
assert.equal(restrictions.length, 0)
|
|
147
|
+
console.log('1 初始状态=开 ok')
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
// 2. off 加上一次限制,回报 off
|
|
151
|
+
{
|
|
152
|
+
const { agent, restrictions } = makeAgent('s1')
|
|
153
|
+
const result = call(agent, 'off')
|
|
154
|
+
assert.equal(result.kind, 'success')
|
|
155
|
+
assert.match(result.text, /\[web:off\]/)
|
|
156
|
+
assert.equal(restrictions.length, 1)
|
|
157
|
+
console.log('2 off 生效 ok')
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
// 3. 幂等:重复 off 不再 restrict
|
|
161
|
+
{
|
|
162
|
+
const { agent, restrictions } = makeAgent('s1')
|
|
163
|
+
call(agent, 'off')
|
|
164
|
+
call(agent, 'off')
|
|
165
|
+
call(agent, '')
|
|
166
|
+
assert.equal(restrictions.length, 1, '重复关闭不应叠加限制')
|
|
167
|
+
console.log('3 重复关闭幂等 ok')
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
// 4. on 撤销,且只撤销一次
|
|
171
|
+
{
|
|
172
|
+
const { agent, restrictions, disposals } = makeAgent('s1')
|
|
173
|
+
call(agent, 'off')
|
|
174
|
+
const on = call(agent, 'on')
|
|
175
|
+
assert.match(on.text, /\[web:on\]/)
|
|
176
|
+
assert.equal(disposals.filter((item) => item === 'lifted').length, 1)
|
|
177
|
+
call(agent, 'on')
|
|
178
|
+
assert.equal(disposals.filter((item) => item === 'lifted').length, 1, '重复开启不应重复 dispose')
|
|
179
|
+
assert.equal(restrictions.length, 1)
|
|
180
|
+
console.log('4 on 撤销 ok')
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
// 5. 无参切换
|
|
184
|
+
{
|
|
185
|
+
const { agent } = makeAgent('s1')
|
|
186
|
+
assert.match(call(agent, '').text, /\[web:off\]/)
|
|
187
|
+
assert.match(call(agent, '').text, /\[web:on\]/)
|
|
188
|
+
console.log('5 无参切换 ok')
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
// 6. 轮次进行中拒绝,且不加限制
|
|
192
|
+
{
|
|
193
|
+
const { agent, restrictions } = makeAgent('s1', { running: true })
|
|
194
|
+
const result = call(agent, 'off')
|
|
195
|
+
assert.equal(result.kind, 'error')
|
|
196
|
+
assert.equal(restrictions.length, 0)
|
|
197
|
+
console.log('6 运行中拒绝 ok')
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
// 7. 会话隔离:两条会话互不影响
|
|
201
|
+
{
|
|
202
|
+
const a = makeAgent('sa')
|
|
203
|
+
const b = makeAgent('sb')
|
|
204
|
+
call(a.agent, 'off')
|
|
205
|
+
assert.match(call(b.agent, 'status').text, /\[web:on\]/, '另一个会话不应被波及')
|
|
206
|
+
assert.equal(b.restrictions.length, 0)
|
|
207
|
+
console.log('7 会话隔离 ok')
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
// 8. 非法参数
|
|
211
|
+
{
|
|
212
|
+
const { agent } = makeAgent('s1')
|
|
213
|
+
assert.equal(call(agent, 'maybe').kind, 'error')
|
|
214
|
+
console.log('8 参数校验 ok')
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
// 9. 会话销毁:撤销限制并清理记录
|
|
218
|
+
{
|
|
219
|
+
const { agent, disposals } = makeAgent('s1')
|
|
220
|
+
call(agent, 'off')
|
|
221
|
+
const disposed = listeners.get('agent/disposed')
|
|
222
|
+
assert.equal(typeof disposed, 'function', '应监听 agent/disposed')
|
|
223
|
+
disposed({ agent })
|
|
224
|
+
assert.deepEqual(disposals, ['lifted'])
|
|
225
|
+
const another = makeAgent('s1')
|
|
226
|
+
assert.match(call(another.agent, 'status').text, /\[web:on\]/, '销毁后记录应清空')
|
|
227
|
+
console.log('9 销毁清理 ok')
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
// 10. pre-step:有标记时重建请求序列,消费后不再重复
|
|
231
|
+
{
|
|
232
|
+
const preStep = listeners.get('agent/pre-step')
|
|
233
|
+
assert.equal(typeof preStep, 'function', '应监听 agent/pre-step')
|
|
234
|
+
const { agent } = makeAgent('s10')
|
|
235
|
+
preStep.__armed = undefined
|
|
236
|
+
call(agent, 'off')
|
|
237
|
+
const payload = { agent, signal: { aborted: false } }
|
|
238
|
+
const decision = { kind: 'enter', messages: [{ role: 'user' }] }
|
|
239
|
+
const wrapped = await preStep(payload, async () => decision)
|
|
240
|
+
assert.equal(wrapped.startsRequestSeries, true, '关掉后下一步应重建请求序列')
|
|
241
|
+
const again = await preStep(payload, async () => decision)
|
|
242
|
+
assert.equal(again.startsRequestSeries, undefined, '标记只消费一次')
|
|
243
|
+
|
|
244
|
+
const { agent: running } = makeAgent('s11')
|
|
245
|
+
call(running, 'off')
|
|
246
|
+
const aborted = await preStep({ agent: running, signal: { aborted: true } }, async () => decision)
|
|
247
|
+
assert.equal(aborted.startsRequestSeries, undefined, '被取消的步骤不消费标记')
|
|
248
|
+
console.log('10 请求序列重建 ok')
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
// 11. 白名单内容:本地工具留下,能出网的一律隐藏,目录里没有的名字被过滤
|
|
252
|
+
{
|
|
253
|
+
const { agent, restrictions } = makeAgent('s12')
|
|
254
|
+
call(agent, 'off')
|
|
255
|
+
const allow = new Set(restrictions[0].allow)
|
|
256
|
+
for (const name of [
|
|
257
|
+
'web_search',
|
|
258
|
+
'web_fetch',
|
|
259
|
+
'bsk_page',
|
|
260
|
+
'bsk_session',
|
|
261
|
+
'computer_ctrl',
|
|
262
|
+
'mcp__snowluma__qq_send_message',
|
|
263
|
+
'read_mcp_resource',
|
|
264
|
+
'video_probe',
|
|
265
|
+
'workbuddy_draw_image',
|
|
266
|
+
'subagent',
|
|
267
|
+
'subagent_fork',
|
|
268
|
+
'send_message',
|
|
269
|
+
'workflow',
|
|
270
|
+
'plugin_manager',
|
|
271
|
+
'schedule_create',
|
|
272
|
+
]) {
|
|
273
|
+
assert.equal(allow.has(name), false, `断网后不应保留 ${name}`)
|
|
274
|
+
}
|
|
275
|
+
for (const name of ['ops_bash', 'ops_inspect_local_file', 'ops_glob', 'ops_grep', 'write', 'edit', 'todo_write', 'present', 'remember']) {
|
|
276
|
+
assert.equal(allow.has(name), true, `断网后应保留本地工具 ${name}`)
|
|
277
|
+
}
|
|
278
|
+
assert.equal(allow.has('read'), false, '未列入白名单的工具默认隐藏(fail closed)')
|
|
279
|
+
assert.equal(allow.has('acp_cache'), false, '目录里没有的名字应被过滤,而不是让 restrict 抛错')
|
|
280
|
+
assert.equal(allow.has('schedule_list'), true, '只读的计划查询属于本地工具')
|
|
281
|
+
console.log('11 白名单内容 ok')
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
// 12. 双用途工具(ops_bash)留着,但联网命令被 guard 拦下
|
|
285
|
+
{
|
|
286
|
+
const { agent, guards, guardDisposals } = makeAgent('s13')
|
|
287
|
+
call(agent, 'off')
|
|
288
|
+
assert.equal(guards.length, 1, '关闭时应注册一个 guard')
|
|
289
|
+
const guard = guards[0]
|
|
290
|
+
const bash = (command) => guard({ name: 'ops_bash', arguments: { command } })
|
|
291
|
+
|
|
292
|
+
for (const command of [
|
|
293
|
+
'curl https://example.com',
|
|
294
|
+
'wget http://x/y.zip',
|
|
295
|
+
'git clone https://github.com/a/b',
|
|
296
|
+
'pnpm add lodash',
|
|
297
|
+
'pip install requests',
|
|
298
|
+
'node -e "require(\'https\').get(...)"',
|
|
299
|
+
'python -c "import urllib.request"',
|
|
300
|
+
'ssh user@host',
|
|
301
|
+
'Invoke-WebRequest http://x',
|
|
302
|
+
'robocopy . \\\\server\\share /E',
|
|
303
|
+
// 红队复现:Python 原生 socket/ssl
|
|
304
|
+
`python -c "import socket;print(socket.gethostbyname('www.baidu.com'))"`,
|
|
305
|
+
`python -c "import socket,ssl;s=socket.create_connection(('x',443),12)"`,
|
|
306
|
+
`python -c "import ssl"`,
|
|
307
|
+
// 红队复现:npm 取元数据/打包
|
|
308
|
+
'npm view lodash version',
|
|
309
|
+
'npm pack lodash --pack-destination .',
|
|
310
|
+
'pnpm publish --dry-run',
|
|
311
|
+
// 红队复现:PowerShell .NET WebClient,URL 拆段拼接
|
|
312
|
+
`powershell -NoProfile -Command '$u="htt"+"ps"+"://x"; $c=New-Object Net.WebClient; $c.DownloadString($u)'`,
|
|
313
|
+
'powershell -EncodedCommand ZgBvAG8A',
|
|
314
|
+
// 编码载荷管道进 shell
|
|
315
|
+
"echo aHR0cHM6Ly9leGFtcGxlLmNvbQ== | base64 -d | sh",
|
|
316
|
+
// 其它联网子命令
|
|
317
|
+
'git submodule update --init',
|
|
318
|
+
'gh release list',
|
|
319
|
+
'pip index versions requests',
|
|
320
|
+
]) {
|
|
321
|
+
assert.equal(typeof bash(command), 'string', `应拦下:${command}`)
|
|
322
|
+
}
|
|
323
|
+
for (const command of [
|
|
324
|
+
'ls -la',
|
|
325
|
+
'node scripts/test.mjs',
|
|
326
|
+
'git status',
|
|
327
|
+
'git log --oneline -3',
|
|
328
|
+
'git commit -m "fix docs"',
|
|
329
|
+
'npm test',
|
|
330
|
+
'npm run build',
|
|
331
|
+
'pnpm build',
|
|
332
|
+
'pnpm run build',
|
|
333
|
+
'npm ls',
|
|
334
|
+
'python -c "print(1+1)"',
|
|
335
|
+
'python scripts/build.py',
|
|
336
|
+
'rm -rf tmp/x',
|
|
337
|
+
'cat package.json',
|
|
338
|
+
"echo 'www.baidu.com'",
|
|
339
|
+
]) {
|
|
340
|
+
assert.equal(bash(command), undefined, `不应拦下:${command}`)
|
|
341
|
+
}
|
|
342
|
+
assert.equal(guard({ name: 'write', arguments: { file_path: 'a' } }), undefined, '别的工具不受这个 guard 影响')
|
|
343
|
+
|
|
344
|
+
// 拒绝原因要写成可执行指令,而不是只说"被拦了"
|
|
345
|
+
const reason = bash('curl https://example.com')
|
|
346
|
+
assert.ok(reason.includes('一切形式的联网工具'), '要说明本会话禁用一切联网工具')
|
|
347
|
+
assert.ok(reason.includes('向用户说明'), '要给出出口:请用户暂时打开开关')
|
|
348
|
+
assert.ok(reason.includes('不要写脚本'), '要明确禁止换通道绕过(写脚本/编码/子进程)')
|
|
349
|
+
assert.ok(reason.includes('误判'), '要说明误判时的处理方式')
|
|
350
|
+
const noCommand = guard({ name: 'ops_bash', arguments: {} })
|
|
351
|
+
assert.ok(noCommand.includes('一切形式的联网工具'), '无命令文本的拒绝也要带同一条规则')
|
|
352
|
+
assert.equal(typeof guard({ name: 'ops_bash', arguments: {} }), 'string', '没有可检查的命令时按保守处理拒绝')
|
|
353
|
+
|
|
354
|
+
call(agent, 'on')
|
|
355
|
+
assert.deepEqual(guardDisposals, ['registered', 'lifted'], '恢复时应撤销 guard')
|
|
356
|
+
// —— 第二轮红队:引号拆分、脚本文件、npm run ——
|
|
357
|
+
const tmp = fs.mkdtempSync(path.join(os.tmpdir(), 'dsh-web-toggle-'))
|
|
358
|
+
const pkg = path.join(tmp, 'pkg')
|
|
359
|
+
fs.mkdirSync(pkg)
|
|
360
|
+
fs.writeFileSync(path.join(tmp, 'net.py'), "import socket\nprint(socket.gethostbyname('x'))\n")
|
|
361
|
+
fs.writeFileSync(path.join(tmp, 'plain.py'), "print('local only')\n")
|
|
362
|
+
fs.writeFileSync(path.join(tmp, 'plain.js'), "console.log('local only')\n")
|
|
363
|
+
fs.writeFileSync(path.join(pkg, 'package.json'), JSON.stringify({
|
|
364
|
+
scripts: { deploy: 'curl https://example.com', build: 'node plain.js', dev: 'vite --host' },
|
|
365
|
+
}))
|
|
366
|
+
fs.writeFileSync(path.join(pkg, 'plain.js'), "console.log('local only')\n")
|
|
367
|
+
|
|
368
|
+
// 引号拆分能被还原后命中
|
|
369
|
+
assert.equal(typeof bash(`printf 'import so''cket\n' > ${path.join(tmp, 'x.py')}`), 'string', "so''cket 要能还原成 socket")
|
|
370
|
+
assert.equal(typeof bash('echo "cur""l example"'), 'string', '"cur""l" 要能还原成 curl')
|
|
371
|
+
// 写盘再执行:读脚本内容
|
|
372
|
+
assert.equal(typeof bash(`python ${path.join(tmp, 'net.py')}`), 'string', '执行含 socket 的脚本要拦')
|
|
373
|
+
assert.equal(bash(`python ${path.join(tmp, 'plain.py')}`), undefined, '纯本地脚本照常放行')
|
|
374
|
+
assert.equal(bash(`node ${path.join(tmp, 'plain.js')}`), undefined, '纯本地 node 脚本照常放行')
|
|
375
|
+
// npm run 的脚本体要看
|
|
376
|
+
const runScript = (command) => guard({ name: 'ops_bash', arguments: { command, workdir: pkg } })
|
|
377
|
+
assert.equal(typeof runScript('npm run deploy'), 'string', 'npm 脚本体里的 curl 要拦')
|
|
378
|
+
assert.equal(typeof runScript('pnpm deploy'), 'string', 'pnpm 脚本体同样要拦')
|
|
379
|
+
assert.equal(runScript('npm run build'), undefined, '本地 npm 脚本照常放行')
|
|
380
|
+
assert.equal(runScript('npm run dev'), undefined, 'vite 之类本地脚本不受影响')
|
|
381
|
+
|
|
382
|
+
// 加号拼接 / 动态导入 / 解码载荷
|
|
383
|
+
assert.equal(typeof bash(`python -c "s=__import__('so'+'cket')"`), 'string', '加号拼接的模块名要还原')
|
|
384
|
+
assert.equal(typeof bash(`python -c "import base64;exec(base64.b64decode('eA=='))"`), 'string', 'b64decode 包裹的载荷要拦')
|
|
385
|
+
|
|
386
|
+
// —— 误判修复:asyncio、点分数字 ——
|
|
387
|
+
assert.equal(bash(`python -c "import asyncio;print('ok')"`), undefined, 'asyncio 本身不该拦')
|
|
388
|
+
assert.equal(bash(`python -c "print('1.2.3.4')"`), undefined, '点分数字不该当成 IP 拦')
|
|
389
|
+
assert.equal(bash(`node -e "console.log('v1.2.3.4')"`), undefined, '版本号同样放行')
|
|
390
|
+
assert.equal(typeof bash(`python -c "import asyncio;asyncio.open_connection('h',80)"`), 'string', 'asyncio.open_connection 仍要拦')
|
|
391
|
+
|
|
392
|
+
console.log('12 shell 命令过滤 ok')
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
console.log('\n全部通过')
|