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
---
# -- docker:compose_down_volumes --
- test: "docker-compose down -v"
  description: "match compose down with short -v flag (hyphen syntax)"
  expect_ids: ["docker:compose_down_volumes"]
- test: "docker compose down -v"
  description: "match compose down with short -v flag (space syntax)"
  expect_ids: ["docker:compose_down_volumes"]
- test: "docker-compose down --volumes"
  description: "match compose down with long --volumes flag"
  expect_ids: ["docker:compose_down_volumes"]
- test: "docker compose down --volumes"
  description: "match compose down with long --volumes flag (space syntax)"
  expect_ids: ["docker:compose_down_volumes"]
- test: "docker-compose down"
  description: "negative: compose down without -v or --volumes should not match"
  expect_ids: []
- test: "docker compose down"
  description: "negative: compose down without -v or --volumes should not match (space syntax)"
  expect_ids: []

# -- docker:force_remove_all_containers --
- test: "docker rm -f $(docker ps -aq)"
  description: "match force remove all containers via command substitution"
  expect_ids: ["docker:force_remove_all_containers"]
- test: "docker rm --force $(docker ps -aq)"
  description: "match force remove all containers with long --force flag"
  expect_ids: ["docker:force_remove_all_containers"]
- test: "docker  rm  -f  $(docker  ps -q)"
  description: "match force remove all containers with extra spaces"
  expect_ids: ["docker:force_remove_all_containers"]
- test: "docker rm mycontainer"
  description: "negative: removing a specific container without force and $(docker ps) should not match"
  expect_ids: []

# -- docker:force_remove_images --
- test: "docker rmi -f image:tag"
  description: "match force remove image with short -f flag"
  expect_ids: ["docker:force_remove_images"]
- test: "docker rmi --force image"
  description: "match force remove image with long --force flag"
  expect_ids: ["docker:force_remove_images"]
- test: "docker rmi myimage:latest"
  description: "negative: remove image without -f or --force should not match"
  expect_ids: []

# -- docker:remove_network --
- test: "docker network rm mynet"
  description: "match remove network command"
  expect_ids: ["docker:remove_network"]
- test: "docker network rm net1 net2"
  description: "match removing multiple networks"
  expect_ids: ["docker:remove_network"]
- test: "docker  network  rm production-net"
  description: "match remove network with extra spaces"
  expect_ids: ["docker:remove_network"]
- test: "docker network ls"
  description: "negative: listing networks should not match"
  expect_ids: []

# -- docker:remove_volume --
- test: "docker volume rm myvolume"
  description: "match remove volume command"
  expect_ids: ["docker:remove_volume"]
- test: "docker volume rm vol1 vol2"
  description: "match removing multiple volumes"
  expect_ids: ["docker:remove_volume"]
- test: "docker  volume  rm  data-vol"
  description: "match remove volume with extra spaces"
  expect_ids: ["docker:remove_volume"]
- test: "docker volume inspect myvol"
  description: "negative: inspecting a volume should not match"
  expect_ids: []

# -- docker:stop_all_containers --
- test: "docker stop $(docker ps -q)"
  description: "match stop all running containers via command substitution"
  expect_ids: ["docker:stop_all_containers"]
- test: "docker  stop  $(docker  ps -aq)"
  description: "match stop all containers with extra spaces"
  expect_ids: ["docker:stop_all_containers"]
- test: "docker stop $(docker ps -a -q)"
  description: "match stop all containers with separate ps flags"
  expect_ids: ["docker:stop_all_containers"]
- test: "docker stop mycontainer"
  description: "negative: stopping a specific container should not match"
  expect_ids: []

# -- docker:system_prune_all --
- test: "docker system prune -a"
  description: "match system prune with short -a flag"
  expect_ids: ["docker:system_prune_all"]
- test: "docker system prune --all"
  description: "match system prune with long --all flag"
  expect_ids: ["docker:system_prune_all"]
- test: "docker system prune"
  description: "negative: system prune without -a or --all should not match"
  expect_ids: []

# -- docker:volume_prune --
- test: "docker volume prune"
  description: "match volume prune command"
  expect_ids: ["docker:volume_prune"]
- test: "docker  volume  prune"
  description: "match volume prune with extra spaces"
  expect_ids: ["docker:volume_prune"]
- test: "docker volume prune -f"
  description: "match volume prune with force flag"
  expect_ids: ["docker:volume_prune"]
- test: "docker volume ls"
  description: "negative: listing volumes should not match"
  expect_ids: []

# -- docker:system_prune_all — flag ordering --
- test: "docker system prune -f -a"
  description: "-f before -a"
  expect_ids: ["docker:system_prune_all"]

- test: "docker system prune --force -a"
  description: "--force before -a"
  expect_ids: ["docker:system_prune_all"]

- test: "docker system prune -f --all"
  description: "-f before --all"
  expect_ids: ["docker:system_prune_all"]

- test: "docker system prune --force --all"
  description: "--force before --all"
  expect_ids: ["docker:system_prune_all"]

- test: "docker system prune -af"
  description: "-af starts with -a, regex matches prefix"
  expect_ids: ["docker:system_prune_all"]

- test: "docker system prune -fa"
  description: "-fa combined"
  expect_ids: ["docker:system_prune_all"]

- test: "docker system prune -a -f"
  description: "-a first, then -f"
  expect_ids: ["docker:system_prune_all"]

- test: "docker system prune --all --force"
  description: "--all first, then --force"
  expect_ids: ["docker:system_prune_all"]

# -- docker:compose_down_volumes — flag ordering --
- test: "docker compose down --rmi all -v"
  description: "--rmi before -v"
  expect_ids: ["docker:compose_down_volumes"]

- test: "docker compose down --remove-orphans -v"
  description: "--remove-orphans before -v"
  expect_ids: ["docker:compose_down_volumes"]

- test: "docker compose down -t 30 -v"
  description: "timeout before -v"
  expect_ids: ["docker:compose_down_volumes"]

- test: "docker-compose down --rmi all --volumes"
  description: "hyphen syntax, --rmi before --volumes"
  expect_ids: ["docker:compose_down_volumes"]

- test: "docker compose down -v --rmi all"
  description: "-v first, then --rmi"
  expect_ids: ["docker:compose_down_volumes"]

- test: "docker compose down -v --remove-orphans"
  description: "-v first, then --remove-orphans"
  expect_ids: ["docker:compose_down_volumes"]

# -- docker:image_prune_all --
- test: "docker image prune -a"
  description: "match image prune with -a"
  expect_ids: ["docker:image_prune_all"]
- test: "docker image prune --all"
  description: "match image prune with --all"
  expect_ids: ["docker:image_prune_all"]
- test: "docker image prune -af"
  description: "match image prune with -af"
  expect_ids: ["docker:image_prune_all"]
- test: "docker image prune"
  description: "negative: image prune without -a should not match"
  expect_ids: []

# -- docker:container_prune --
- test: "docker container prune"
  description: "match container prune"
  expect_ids: ["docker:container_prune"]
- test: "docker container prune -f"
  description: "match container prune with force"
  expect_ids: ["docker:container_prune"]
- test: "docker container ls"
  description: "negative: container ls should not match"
  expect_ids: []

# -- docker:buildx_prune_all --
- test: "docker buildx prune --all"
  description: "match buildx prune --all"
  expect_ids: ["docker:buildx_prune_all"]
- test: "docker buildx prune --all -f"
  description: "match buildx prune --all with force"
  expect_ids: ["docker:buildx_prune_all"]
- test: "docker buildx prune"
  description: "negative: buildx prune without --all should not match"
  expect_ids: []

# -- docker:run_privileged --
- test: "docker run --privileged nginx"
  description: "match run with --privileged"
  expect_ids: ["docker:run_privileged"]
- test: "docker run -it --privileged ubuntu bash"
  description: "match run with flags before --privileged"
  expect_ids: ["docker:run_privileged"]
- test: "docker run --name mycontainer --privileged nginx"
  description: "match run with --name before --privileged"
  expect_ids: ["docker:run_privileged"]
- test: "docker  run  --privileged  nginx"
  description: "match run with extra spaces"
  expect_ids: ["docker:run_privileged"]
- test: "docker run --privileged=true nginx"
  description: "match run with --privileged=true"
  expect_ids: ["docker:run_privileged"]
- test: "docker run --privileged=false nginx"
  description: "negative: --privileged=false should not match"
  expect_ids: []
- test: "docker run nginx"
  description: "negative: run without --privileged should not match"
  expect_ids: []
- test: "docker run -it ubuntu bash"
  description: "negative: run with regular flags should not match"
  expect_ids: []

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

# -- docker:compose_down_volumes edge cases --
- test: "docker compose -f custom.yml down -v"
  description: "match compose with -f flag before down with -v"
  expect_ids: ["docker:compose_down_volumes"]
- test: "docker-compose -f docker-compose.prod.yml down --volumes"
  description: "match compose with -f flag before down with --volumes"
  expect_ids: ["docker:compose_down_volumes"]

# -- docker:force_remove_all_containers edge cases --
- test: "docker rm -f `docker ps -aq`"
  description: "match force remove all containers with backtick syntax"
  expect_ids: ["docker:force_remove_all_containers"]

# -- docker:run_privileged edge cases --
- test: "docker run --security-opt seccomp=unconfined --privileged nginx"
  description: "EDGE: long option before --privileged"
  expect_ids: ["docker:run_privileged"]

# -- docker --
- test: 'docker network prune -f'
  description: "network prune"
  expect_ids: ["docker:network_prune"]
- test: 'docker kill $(docker ps -q)'
  description: "kill all"
  expect_ids: ["docker:kill_all_containers"]
- test: 'docker kill web'
  description: "negative: one container"
  expect_ids: []
# -- docker:run_mount_host_root --
- test: 'docker run -v /:/host -it alpine sh'
  description: "host root bind mount"
  expect_ids: ["docker:run_mount_host_root"]
- test: 'docker run --mount type=bind,source=/,target=/host alpine'
  description: "host root via --mount"
  expect_ids: ["docker:run_mount_host_root"]
- test: 'docker run -v /data:/data alpine'
  description: "negative: a data directory"
  expect_ids: []
- test: "nerdctl run -v /:/host alpine sh"
  description: "nerdctl host root mount"
  expect_ids: ["docker:run_mount_host_root"]
- test: "docker run -v /var/run/docker.sock:/var/run/docker.sock alpine"
  description: "the docker socket is root on the host"
  expect_ids: ["docker:run_mount_host_sensitive"]
- test: "docker run -v /etc:/host-etc alpine"
  description: "the host /etc"
  expect_ids: ["docker:run_mount_host_sensitive"]
- test: "docker run -v /etc/nginx/conf.d:/etc/nginx/conf.d:ro nginx"
  description: "one config directory read-only is fine"
  expect_ids: []

# ---- anchoring and housekeeping ----
# -- docker:system_prune_all --
- test: "xdocker system prune -a"
  description: "another tool whose name ends in docker"
  expect_ids: []
- test: "sudo docker system prune -a"
  description: "sudo is removed by the parser"
  expect_ids: ["docker:system_prune_all"]

# -- docker <object> <verb> long forms --
- test: "docker image rm -f abc"
  description: "image rm -f is rmi -f"
  expect_ids: ["docker:force_remove_images"]
- test: "docker image remove --force abc"
  description: "image remove --force is rmi -f"
  expect_ids: ["docker:force_remove_images"]
- test: "docker image rm abc"
  description: "negative: without -f, like rmi"
  expect_ids: []
- test: "docker container rm -f $(docker container ls -aq)"
  description: "container rm -f of every container"
  expect_ids: ["docker:force_remove_all_containers"]
- test: "docker container remove -f $(docker ps -aq)"
  description: "container remove -f of every container"
  expect_ids: ["docker:force_remove_all_containers"]
- test: "docker volume remove $(docker volume ls -q)"
  description: "volume remove is volume rm"
  expect_ids: ["docker:remove_volume"]
- test: "docker network remove frontend"
  description: "network remove is network rm"
  expect_ids: ["docker:remove_network"]
- test: "docker volume ls"
  description: "negative: listing volumes"
  expect_ids: []
- test: "podman system reset -f"
  description: "podman system reset -f"
  expect_ids: ["docker:podman_system_reset"]
- test: "podman ps -a"
  description: "negative: podman ps -a"
  expect_ids: []
# -- podman parity --
- test: "podman volume prune -f"
  description: "podman volume prune"
  expect_ids: ["docker:volume_prune"]
- test: "podman system prune -a"
  description: "podman system prune -a"
  expect_ids: ["docker:system_prune_all"]

# -- help requests are print-only --
- test: "docker run --rm -v /:/host alpine sh -c 'rm -rf /host/etc' --help"
  description: "the help word does not make this print-only"
  expect_ids: ["docker:run_mount_host_root"]
- test: "docker run -h box --rm -v /:/host alpine rm -rf /host/etc"
  description: "the help word does not make this print-only"
  expect_ids: ["docker:run_mount_host_root"]
- test: "docker volume prune --help"
  description: "negative: a help request only prints usage"
  expect_ids: []

# -- docker compose --dry-run (the last dry-run word, not an option's value) --
- test: "docker compose down -v --dry-run"
  description: "negative: a compose dry run changes nothing"
  expect_ids: []
- test: "docker compose --dry-run down -v"
  description: "negative: a compose dry run changes nothing"
  expect_ids: []
- test: "docker compose down --volumes --dry-run"
  description: "negative: a compose dry run changes nothing"
  expect_ids: []
- test: "docker compose down -v --remove-orphans --dry-run"
  description: "negative: a compose dry run changes nothing"
  expect_ids: []
- test: "docker compose --dry-run down --volumes"
  description: "negative: a compose dry run changes nothing"
  expect_ids: []
- test: "docker compose --dry-run rm -fsv"
  description: "negative: a compose dry run changes nothing"
  expect_ids: []
- test: "docker compose down -v"
  description: "still a real run: no effective dry-run flag"
  expect_ids: ["docker:compose_down_volumes"]
- test: "docker compose down --volumes"
  description: "still a real run: no effective dry-run flag"
  expect_ids: ["docker:compose_down_volumes"]
- test: "docker compose down -v --dry-run=false"
  description: "still a real run: no effective dry-run flag"
  expect_ids: ["docker:compose_down_volumes"]
- test: "docker compose down -v --dry-run --dry-run=false"
  description: "still a real run: no effective dry-run flag"
  expect_ids: ["docker:compose_down_volumes"]
- test: "docker compose --dry-run=false down -v"
  description: "still a real run: no effective dry-run flag"
  expect_ids: ["docker:compose_down_volumes"]
- test: "docker compose down -v -t --dry-run"
  description: "still a real run: no effective dry-run flag"
  expect_ids: ["docker:compose_down_volumes"]
- test: "docker compose down -v --timeout --dry-run"
  description: "still a real run: no effective dry-run flag"
  expect_ids: ["docker:compose_down_volumes"]
- test: "docker compose -f --dry-run down -v"
  description: "still a real run: no effective dry-run flag"
  expect_ids: ["docker:compose_down_volumes"]
- test: "docker compose -p --dry-run down -v"
  description: "still a real run: no effective dry-run flag"
  expect_ids: ["docker:compose_down_volumes"]
- test: "docker compose down -v '--dry-run'"
  description: "still a real run: no effective dry-run flag"
  expect_ids: ["docker:compose_down_volumes"]
- test: "docker compose down -v --dry-run && docker compose down -v"
  description: "still a real run: no effective dry-run flag"
  expect_ids: ["docker:compose_down_volumes"]
- test: "docker compose down -v --dry-run; docker compose down -v"
  description: "still a real run: no effective dry-run flag"
  expect_ids: ["docker:compose_down_volumes"]
- test: "docker-compose down -v --dry-run"
  description: "still a real run: no effective dry-run flag"
  expect_ids: ["docker:compose_down_volumes"]
- test: "sudo docker compose down -v"
  description: "still a real run: no effective dry-run flag"
  expect_ids: ["docker:compose_down_volumes"]
- test: "echo docker compose down -v | sh"
  description: "still a real run: no effective dry-run flag"
  expect_ids: ["docker:compose_down_volumes"]
- test: "docker compose down --rmi --dry-run -v"
  description: "still a real run: no effective dry-run flag"
  expect_ids: ["docker:compose_down_volumes"]

# -- docker:compose_rm_volumes --
- test: "docker compose rm -f"
  description: "negative: no anonymous volumes are removed"
  expect_ids: []
- test: "docker compose rm -fs web"
  description: "negative: no anonymous volumes are removed"
  expect_ids: []
- test: "docker compose run --rm -v ./data:/data app"
  description: "negative: no anonymous volumes are removed"
  expect_ids: []
- test: "docker compose ps -v"
  description: "negative: no anonymous volumes are removed"
  expect_ids: []
- test: "docker compose rm -fsv"
  description: "removing the anonymous volumes deletes their data"
  expect_ids: ["docker:compose_rm_volumes"]
- test: "docker compose rm -v -f"
  description: "removing the anonymous volumes deletes their data"
  expect_ids: ["docker:compose_rm_volumes"]
- test: "docker-compose rm -fsv"
  description: "removing the anonymous volumes deletes their data"
  expect_ids: ["docker:compose_rm_volumes"]
- test: "docker compose rm --volumes web"
  description: "removing the anonymous volumes deletes their data"
  expect_ids: ["docker:compose_rm_volumes"]
- test: "docker compose -f prod.yml rm -sv"
  description: "removing the anonymous volumes deletes their data"
  expect_ids: ["docker:compose_rm_volumes"]
- test: "docker compose rm -f -v db"
  description: "removing the anonymous volumes deletes their data"
  expect_ids: ["docker:compose_rm_volumes"]