-
-
Notifications
You must be signed in to change notification settings - Fork 85
/
tests.yaml
1108 lines (1026 loc) · 46.8 KB
/
tests.yaml
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
config-file: tenzir.yaml
fixtures:
ExampleConfigFileTester:
enter: | # python
node = Server(self.cmd,
['-e', f'127.0.0.1:{TENZIR_PORT}', '-i', 'node', 'start'],
work_dir, name='node', port=TENZIR_PORT,
config_file='tenzir.yaml.example')
cmd += ['-e', f'127.0.0.1:{TENZIR_PORT}']
exit: | # python
node.stop()
ServerTester:
enter: | # python
node = Server(self.cmd,
['-e', f'127.0.0.1:{TENZIR_PORT}', '-i', 'node', 'start'],
work_dir, name='node', port=TENZIR_PORT,
config_file=self.config_file)
cmd += ['-e', f'127.0.0.1:{TENZIR_PORT}']
exit: | # python
node.stop()
ServerTesterMetricsEnabled:
enter: | # python
node = Server(self.cmd,
['-e', f'127.0.0.1:{TENZIR_PORT}', '-i', 'node',
'--enable-metrics', 'start'],
work_dir, name='node', port=TENZIR_PORT,
config_file=self.config_file)
cmd += ['-e', f'127.0.0.1:{TENZIR_PORT}']
exit: | # python
node.stop()
DiskMonitorTester:
enter: | # python
node = Server(self.cmd,
['-e', f'127.0.0.1:{TENZIR_PORT}',
'-i', 'node',
'--max-partition-size=8462',
'start',
'--disk-budget-check-interval=2',
'--disk-budget-check-binary=' + os.path.dirname(os.path.abspath(__file__)) + '/misc/scripts/count_partitions_plus1.sh',
'--disk-budget-high=1',
'--disk-budget-low=0'],
work_dir, name='node', port=TENZIR_PORT)
cmd += ['-e', f'127.0.0.1:{TENZIR_PORT}']
exit: | # python
node.stop()
tests:
Parse basic:
tags: [parser]
steps:
- command: exec --dump-ast " "
- command: exec --dump-ast "// comment"
- command: exec --dump-ast "#!/usr/bin/env tenzir"
Parse operators:
tags: [parser]
steps:
- command: exec --dump-ast "show version"
- command: exec "show version --tev"
expected_result: error
- command: exec "show version 42"
expected_result: error
- command: exec "from a/b/c.json read json"
expected_result: error
- command: exec --dump-ast "from file a/b/c.json"
- command: exec --dump-ast "from file a/b/c.json read cef"
- command: exec --dump-ast "read zeek-tsv"
- command: exec --dump-ast "head 42"
- command: exec --dump-ast "local remote local pass"
- command: exec --dump-ast "where :ip == 1.2.3.4"
- command: exec --dump-ast "to file xyz.json"
Conn log counting:
tags: [node, counting, zeek]
steps:
- command: -N --max-partition-size=64 import zeek
input: data/zeek/conn.log.gz
- command: -N count ":ip == 192.168.1.104"
- command: -N count -e ":ip == 192.168.1.104"
- command: -N count "resp_p == 80"
- command: -N count "resp_p != 80"
- command: -N count 861237
Node Zeek conn log:
tags: [node, import-export, zeek]
steps:
- command: -N import zeek
input: data/zeek/conn.log.gz
- command: -N export ascii 'where resp_h == 192.168.1.104'
- command: -N export ascii 'where orig_bytes > 1k && orig_bytes < 1Ki'
- command: -N export ascii 'where :string == "OrfTtuI5G4e" || :port == 67 || :uint64 == 67'
- command: '-N export ascii "where #schema == \"zeek.conn\" && resp_h == 192.168.1.104"'
- command: '-N export ascii "where #schema != \"zeek.conn\" && #schema != \"tenzir.metrics\""'
- command: '-N export ascii "where #schema != \"foobar\" && resp_h == 192.168.1.104"'
Node Zeek multiple imports:
tags: [node, import-export, zeek]
steps:
- command: -N import zeek
input: data/zeek/conn.log.gz
- command: -N import zeek
input: data/zeek/dns.log.gz
- command: -N export ascii 'where resp_h == 192.168.1.104'
- command: -N export ascii 'where zeek.conn.id.resp_h == 192.168.1.104'
- command: '-N count ":timestamp >= 1970-01-01 && #schema != \"tenzir.metrics\""'
- command: -N count '#schema == "zeek.conn"'
Node Zeek dns log:
tags: [node, import-export, zeek]
steps:
- command: -N import zeek
input: data/zeek/dns.log.gz
- command: -N export ascii 'where resp_h == 192.168.1.104'
- command: -N export zeek 'where resp_h == 192.168.1.104'
transformation: awk '!/^#(open|close)/'
- command: -N count ':port == 53'
- command: '-N count ":uint64 == 53 && #schema == \"zeek.dns\""'
Node Zeek http log:
tags: [node, import-export, zeek]
steps:
- command: -N import zeek
input: data/zeek/http.log.gz
- command: -N export ascii 'where resp_h == 216.240.189.196'
Node Zeek snmp log:
tags: [node, import-export, zeek]
steps:
- command: -N import zeek
input: data/zeek/snmp.log.gz
- command: -N export ascii 'where duration >= 3s'
Node Zeek JSON:
tags: [node, import-export, zeek, json]
steps:
- command: -N import -b zeek-json
input: data/zeek/zeek.json
- command: '-N export json "where \"zeek\" in #schema"'
transformation: jq -ec '.'
Export json:
tags: [json, zeek]
steps:
- command: -N import zeek
input: data/zeek/conn.log.gz
- command: -N export json 'where resp_h == 192.168.1.104'
transformation: jq -ec '.'
- command: -N export json --omit-nulls 'where resp_h == 192.168.1.104'
transformation: jq -ec '.'
Shutdown with Metrics:
tags: [metrics, shutdown]
fixture: ServerTesterMetricsEnabled
steps:
- command: status
# We just care about the exit code; the steps list cannot be empty, so
# it's like a dummy check that confirms whether the server can be
# connected to.
transformation: jq -ec 'empty'
Malformed Query:
tags: [export]
fixture: ServerTester
steps:
- command: export json 'yo that is not a query'
expected_result: error
- command: and that is not a command
expected_result: error
Flush:
tags: [server, import, flush]
fixture: ServerTester
steps:
- command: import zeek
input: data/zeek/conn.log.gz
- command: status catalog
transformation: jq -ec '.catalog."num-partitions"'
- command: flush
- command: status catalog
transformation: jq -ec '.catalog."num-partitions"'
Server Zeek conn log:
tags: [server, import-export, zeek]
fixture: ServerTester
steps:
- command: import -b zeek
input: data/zeek/conn.log.gz
- command: export ascii 'where resp_h == 192.168.1.104'
# import some more to make sure accounting data is in the system.
- command: import -b --batch-size=10 zeek
input: data/zeek/conn.log.gz
- command: import -b --batch-size=1000 zeek
input: data/zeek/conn.log.gz
- command: import -b --batch-size=100000 zeek
input: data/zeek/conn.log.gz
- command: import -b --batch-size=1 -n 242 zeek
input: data/zeek/conn.log.gz
- command: flush
- command: status --detailed
transformation: jq '.catalog.schemas | with_entries(.value = .value."num-events")'
- command: status --detailed
transformation: jq -ec 'del(.version) | del(.system."swap-space-usage") | del(.index.patitions.cached) | paths(scalars) as $p | {path:$p, type:(getpath($p) | type)}'
- command: status --detailed index importer
transformation: jq -ec 'del(.index.patitions.cached) | paths(scalars) as $p | {path:$p, type:(getpath($p) | type)}'
Server Zeek multiple imports:
tags: [server, import-export, zeek]
fixture: ServerTester
steps:
- command: import -b zeek
input: data/zeek/conn.log.gz
- command: import -b zeek
input: data/zeek/dns.log.gz
- command: export ascii 'where resp_h == 192.168.1.104'
- command: export ascii 'where zeek.conn.id.resp_h == 192.168.1.104'
- command: 'count ":timestamp >= 1970-01-01 && #schema != \"tenzir.metrics\""'
- command: count '#schema == "zeek.conn"'
Query Operators:
tags: [server, operator]
fixture: ServerTester
steps:
- command: import -b zeek
input: data/zeek/conn.log.gz
- command: export ascii 'where conn.duration <= 1.0s'
- command: export json 'where duration >= 10.0s && duration < 15s'
- command: export json --numeric-durations 'where duration >= 1.8s && duration < 2.0s'
- command: export ascii 'where service == "smtp"'
- command: export ascii 'where missed_bytes != 0'
- command: export ascii 'where id.orig_h !in 192.168.1.0/24'
- command: export ascii 'where id.orig_h in fe80:5074:1b53:7e7::/64'
- command: export ascii 'where id.orig_h ni fe80:5074:1b53:7e7::/64'
Expressions:
tags: [server, expression]
fixture: ServerTester
steps:
- command: import -b zeek
input: data/zeek/conn.log.gz
- command: export ascii 'where fe80::5074:1b53:7e7:ad4d || 169.254.225.22'
- command: export ascii 'where "OrfTtuI5G4e" || fe80::5074:1b53:7e7:ad4d'
Node Type Query:
tags: [node, type, ch6104]
steps:
- command: -N import -n 20 zeek
input: data/zeek/conn.log.gz
- command: -N export ascii
Type Query:
tags: [server, type, ch5404]
fixture: ServerTester
steps:
- command: import -b -n 20 zeek
input: data/zeek/conn.log.gz
- command: 'export ascii "where #schema == \"zeek.conn\""'
Node json zeek conn:
tags: [node, import-export, zeek, json]
steps:
- command: -N import -s @./misc/schema/zeek-conn.schema -t zeek.conn.custom json
input: data/json/conn.log.json.gz
- command: -N export ascii 'where duration > 6s'
- command: -N export ascii 'where :timestamp >= 2011-08-15T03:48'
- command: -N export ascii 'where :time >= 2011-08-15T03:48'
Node suricata alert:
tags: [node, import-export, suricata, eve, import-filter]
steps:
- command: -N import suricata '#schema != "suricata.stats" && event_type != "flow"'
input: data/suricata/eve.json
- command: -N export ascii 'where src_ip == 147.32.84.165'
- command: '-N export csv "where #schema == /suricata.*/"'
- command: '-N export zeek "where #schema == /suricata.alert/"'
- command: -N export json --omit-nulls --omit-empty-records
Node suricata rrdata:
tags: [node, import-export, suricata, eve]
steps:
- command: -N import json --selector=event_type:suricata
input: data/suricata/rrdata-eve.json
- command: -N export ascii
- command: -N export json
Node argus csv:
tags: [node, import-export, argus, csv]
steps:
- command: -N import -t argus.record csv
input: data/csv/argus-M57-10k-pkts.csv.gz
- command: -N export ascii 'where State != "CON" && Dur > 4900ms'
- command: -N export ascii 'where Cause == "Status" && Dur > 1s'
Node argus ssv:
tags: [node, import-export, argus, ssv, csv]
steps:
- command: -N import -t argus.record csv '--separator=" "'
input: data/csv/argus-additional-fields.ssv
- command: -N export csv
Node argus tsv:
tags: [node, import-export, argus, tsv, csv]
steps:
- command: -N import -t argus.record csv '--separator="\t"'
input: data/csv/argus-reordered.tsv
- command: -N export csv
Multi addr query:
tags: [import-export, zeek]
steps:
- command: -N import zeek
input: data/zeek/conn.log.gz
- command: -N export ascii
input: queries/multi_addr.txt
Taxonomy queries:
tags: [concepts, models]
fixture: ServerTester
steps:
- command: import -b zeek
input: data/pcap/zeek/conn.log.gz
- command: import -b suricata
input: data/pcap/suricata/eve.json.gz
- command: count "net.src.ip == 192.168.168.100"
Arrow Full Data Model:
tags: [export, arrow]
steps:
- command: -N import --batch-encoding=arrow --schema-file="@./misc/schema/all-types.schema" --type=all_types json
input: data/json/all-types.json
- command: '-N export arrow "where #schema == \"all_types\""'
transformation: python @./misc/scripts/print-arrow.py
Arrow Export:
tags: [export, arrow]
steps:
- command: -N import --batch-encoding=arrow zeek
input: data/zeek/conn.log.gz
- command: '-N export -n 10 arrow "where #schema == \"zeek.conn\""'
transformation: python @./misc/scripts/print-arrow.py
- command: -N import --batch-encoding=arrow suricata
input: data/suricata/eve.json
- command: '-N export arrow "where #schema == \"suricata.http\""'
transformation: python @./misc/scripts/print-arrow.py
Arrow Import:
tags: [import, arrow]
fixture: ServerTester
steps:
- command: import -b --batch-encoding=arrow arrow
# the input corresponds to conn.log.gz + eve.json (see above)
input: data/suricata/arrow_ipc.bin
- command: 'export -n 10 arrow "where #schema == \"zeek.conn\""'
transformation: python @./misc/scripts/print-arrow.py
- command: 'export arrow "where #schema == \"suricata.http\""'
transformation: python @./misc/scripts/print-arrow.py
- command: count
Import syslog:
tags: [syslog, import]
steps:
- command: -N import syslog
input: data/syslog/syslog.log
- command: '-N export ascii "where #schema == /syslog.*/"'
Heterogeneous JSONL import:
tags: [import, json, sysmon]
steps:
- command: -N import json
input: data/json/sysmon.json
- command: -N import suricata
input: data/suricata/eve.json
- command: -N export json 'where "®" in :string'
transformation: jq -ec '.'
- command: '-N export json "where #schema ni \"suricata\""'
transformation: jq -ec '.'
- command: -N export json 'where ProcessGuid == /\{[0-9a-f]{8}-[0-9a-f]{4}-5ec2-7.15-[0-9a-f]{12}\}/'
transformation: jq -ec '.'
# Testing the #import_time meta extractor is a bit tricky and requires
# sleeping. If this turns out to be a flaky test, increase durations and
# queries respectively.
# TODO: Re-enable this test once its flakiness has been resolved.
# Import Time:
# tags: [import, json, suricata]
# steps:
# - command: -N import suricata '#schema == "suricata.stats"'
# input: data/suricata/eve.json
# transformation: sleep 5
# - command: -N import suricata '#schema == "suricata.stats"'
# input: data/suricata/eve.json
# - command: -N export json '#import_time < 5 seconds ago'
# transformation: jq -ec '.'
# - command: sleep 5
# prepend_tenzir: false
# - command: -N export json '#import_time < 5 seconds ago'
# transformation: jq -ec '.'
Extractor Predicates:
tags: [import, export, suricata]
steps:
- command: -N import suricata
input: data/suricata/eve.json
- command: -N count "timestamp && :ip"
- command: -N count does_not_exist
- command: -N export json "where flow.alerted"
# Nesting Records in Lists is not currently fully supported, but its presence
# should also not crash the JSON reader.
Nested Records:
tags: [import, json]
steps:
- command: '-N import --schema="type custom = record { a: list<record { b: string, c: uint64, }>, d: uint64, }" --type=custom --batch-encoding=arrow json'
input: data/json/record-in-list.json
- command: '-N export ascii "where #schema == \"custom\""'
Example config file:
tags: [import-export, zeek]
fixture: ExampleConfigFileTester
config-file: tenzir.yaml.example
steps:
- command: import -b zeek
input: data/zeek/conn.log.gz
- command: export ascii 'where net.app !in ["dns", "ftp", "http", "ssl"]'
# The `DiskMonitorTester` is set up to run every second and to delete all
# partitions on disk. We first import the complete zeek dataset with 8462
# events, and then wait some to give the disk monitor enough time to run.
# After that, all events from the first import should have been erased.
Disk monitor:
tags: [disk-quota]
fixture: DiskMonitorTester
steps:
- command: import -b zeek
input: data/zeek/conn.log.gz
- command: sleep 4
prepend_tenzir: false
- command: count '#schema == /zeek.*/'
Export pipeline operator parsing everything but summarize:
tags: [server, client, import-export, transforms]
fixture: ServerTester
steps:
- command: import -b suricata
input: data/suricata/eve.json
- command: |
export json
'pass'
- command: |
export json
' pass
/* a comment here */
| select /* and a comment there /**/ timestamp, flow_id, src_ip, dest_ip, src_port
/**/ /*foo*/
'
- command: "export json 'pass
| select timestamp, flow_id, src_ip, dest_ip, src_port
| drop timestamp'"
- command: "export json 'pass
| select timestamp, flow_id, src_ip, dest_ip, src_port
| drop timestamp
| hash --salt=\"abcdefghij12\" flow_id'"
- command: "export json 'pass
| select timestamp, flow_id, src_ip, dest_ip, src_port
| drop timestamp
| hash --salt=\"abcdefghij12\" flow_id
| drop flow_id'"
- command: "export json 'pass
| select timestamp, flow_id, src_ip, dest_ip, src_port
| drop timestamp
| hash --salt=\"abcdefghij12\" flow_id
| drop flow_id
| pseudonymize -m \"crypto-pan\" -s \"123456abcdef\" src_ip, dest_ip'"
- command: "export json 'pass
| select timestamp, flow_id, src_ip, dest_ip, src_port
| drop timestamp
| hash --salt=\"abcdefghij12\" flow_id
| drop flow_id
| pseudonymize -m \"crypto-pan\" -s \"123456abcdef\" src_ip, dest_ip
| rename source_ip=src_ip'"
- command: "export json 'pass
| select timestamp, flow_id, src_ip, dest_ip, src_port
| drop timestamp
| hash --salt=\"abcdefghij12\" flow_id
| drop flow_id
| pseudonymize -m \"crypto-pan\" -s \"123456abcdef\" src_ip, dest_ip
| rename source_ip=src_ip
| where #schema ==\"suricata.alert\" || #schema == \"suricata.fileinfo\"'"
Export pipeline operator parsing only summarize:
tags: [server, client, import-export, transforms]
fixture: ServerTester
steps:
- command: import -b -t sysmon.NetworkConnection json
input: data/json/sysmon.json
- command: export json 'summarize distinct(SourcePort) by SourceIp'
- command: export json 'summarize any(Initiated) by SourceIp, SourcePort, DestinationPoint, UtcTime resolution 1 minute'
- command: export json 'summarize usercount=count(User), initiated=all(Initiated) by ProcessId'
Export pipeline operator parsing after expression:
tags: [server, client, import-export, transforms]
fixture: ServerTester
steps:
- command: import -b suricata
input: data/suricata/eve.json
- command: "export json 'where src_ip==147.32.84.165 && (src_port==1181 || src_port == 138)'"
- command: "export json 'where src_ip==147.32.84.165 && (src_port==1181 || src_port == 138)
| pass'"
- command: "export json 'where src_ip==147.32.84.165 && (src_port==1181 || src_port == 138)
| pass
| select timestamp, flow_id, src_ip, dest_ip, src_port'"
- command: "export json 'where src_ip==147.32.84.165 && (src_port==1181 || src_port == 138)
| pass
| select timestamp, flow_id, src_ip, dest_ip, src_port
| drop timestamp'"
- command: "export json 'where src_ip==147.32.84.165 && (src_port==1181 || src_port == 138)
| pass
| select timestamp, flow_id, src_ip, dest_ip, src_port
| drop timestamp
| hash --salt=\"abcdefghij12\" flow_id'"
- command: "export json 'where src_ip==147.32.84.165 && (src_port==1181 || src_port == 138)
| pass
| select timestamp, flow_id, src_ip, dest_ip, src_port
| drop timestamp
| hash --salt=\"abcdefghij12\" flow_id
| drop flow_id'"
- command: "export json 'where src_ip==147.32.84.165 && (src_port==1181 || src_port == 138)
| pass
| select timestamp, flow_id, src_ip, dest_ip, src_port
| drop timestamp
| hash --salt=\"abcdefghij12\" flow_id
| drop flow_id
| pseudonymize -m \"crypto-pan\" -s \"123456abcdef\" src_ip, dest_ip'"
- command: "export json 'where src_ip==147.32.84.165 && (src_port==1181 || src_port == 138)
| pass
| select timestamp, flow_id, src_ip, dest_ip, src_port
| drop timestamp
| hash --salt=\"abcdefghij12\" flow_id
| drop flow_id
| pseudonymize -m \"crypto-pan\" -s \"123456abcdef\" src_ip, dest_ip'"
- command: "export json 'where src_ip==147.32.84.165 && (src_port==1181 || src_port == 138)
| pass
| select timestamp, flow_id, src_ip, dest_ip, src_port
| drop timestamp
| hash --salt=\"abcdefghij12\" flow_id
| drop flow_id
| pseudonymize -m \"crypto-pan\" -s \"123456abcdef\" src_ip, dest_ip
| rename source_ip=src_ip'"
- command: "export json 'where src_ip==147.32.84.165 && (src_port==1181 || src_port == 138)
| pass
| select timestamp, flow_id, src_ip, dest_ip, src_port
| drop timestamp
| hash --salt=\"abcdefghij12\" flow_id
| drop flow_id
| pseudonymize -m \"crypto-pan\" -s \"123456abcdef\" src_ip, dest_ip
| rename source_ip=src_ip'"
- command: "export json 'where src_ip==147.32.84.165 && (src_port==1181 || src_port == 138)
| pass
| select timestamp, flow_id, src_ip, dest_ip, src_port
| drop timestamp
| hash --salt=\"abcdefghij12\" flow_id
| drop flow_id
| pseudonymize -m \"crypto-pan\" -s \"123456abcdef\" src_ip, dest_ip
| rename source_ip=src_ip
| where #schema ==\"suricata.alert\" || #schema == \"suricata.fileinfo\"'"
Self Repair:
tags: [fault]
steps:
- command: -N import zeek
input: data/zeek/conn.log.gz
- command: exec 'show version'
transformation: "@./misc/scripts/break-sizelimit.sh"
# We use an extra import step to trigger the repair because querying
# directly would not wait for the repair step.
- command: -N import suricata
input: data/suricata/eve.json
- command: -N count "zeek.conn.id.orig_h == 192.168.1.104"
# Checks if the import and export works as usual when we ignore creation
# of partition indexes for all field names
Optional Partition Indexes:
tags: [import, export, csv]
steps:
- command: -N --config=@./tenzir-optional-indexes.yaml import -t argus.record csv '--separator=" "'
input: data/csv/argus-additional-fields.ssv
- command: -N export csv
Process Query For Field With Skip Attribute:
tags: [import, export]
steps:
- command: -N import --schema-file="@./misc/schema/zeek-with-skip.schema" zeek-json
input: data/zeek/zeek.json
- command: -N export json 'where username == "steve"'
Rebuild undersized partitions:
fixture: ExampleConfigFileTester
tags: [import, export, rebuild]
steps:
- command: import --blocking suricata
input: data/suricata/eve.json
- command: import --blocking suricata
input: data/suricata/eve.json
- command: status --detailed catalog
transformation: jq '.catalog.partitions | length'
- command: export arrow
transformation: python @./misc/scripts/print-arrow-batch-size.py
- command: rebuild start --undersized
- command: status --detailed catalog
transformation: jq '.catalog.partitions | length'
- command: export json
- command: export arrow
transformation: python @./misc/scripts/print-arrow-batch-size.py
Export shutdown behavior:
fixture: ServerTester
tags: [import, export]
steps:
- command: export json
- command: import --blocking suricata
input: data/suricata/eve.json
- command: export --max-events=2 json 'head 1'
transformation: jq -ers 'length'
- command: export json 'head 1'
transformation: jq -ers 'length'
- command: export --max-events=1 json 'head 0'
- command: export json 'head 0'
CEF:
tags: [server, import-export, cef]
fixture: ServerTester
steps:
- command: exec 'read cef | import'
input: data/cef/cynet.log
- command: exec 'read cef | import'
input: data/cef/checkpoint.log
- command: exec 'read cef | import'
input: data/cef/forcepoint.log
- command: export json 'where cef_version >= 0 && device_vendor == "Cynet"'
- command: export json 'where 172.31.5.93'
- command: export json 'where act == /Accept|Bypass/'
- command: export json 'where dvc == 10.1.1.8'
Export in Pipeline:
fixture: ServerTester
tags: [import, export, pipelines]
steps:
- command: exec 'export | to stdout'
- command: exec 'read cef | import'
input: data/cef/cynet.log
- command: exec 'export | to stdout'
- command: flush
- command: exec 'export | to stdout'
- command: exec 'read cef | import'
input: data/cef/checkpoint.log
- command: exec 'export | to stdout'
- command: flush
- command: exec 'export | to stdout'
transformation: jq length
- command: exec 'export | where device_product == "VPN-1 & FireWall-1" | to stdout'
transformation: jq length
- command: exec 'export | where device_product == "VPN-1 & FireWall-1" | where 192.168.101.100 | to stdout'
- command: exec 'export | where device_product == "VPN-1 & FireWall-1" && 192.168.101.100 | to stdout'
Patterns:
fixture: ServerTester
tags: [import, export]
steps:
- command: import -b suricata
input: data/suricata/eve.json
- command: export json 'where event_type == /.*flow$/'
- command: export json 'where event_type == /.*FLOW$/i'
Comments:
fixture: ServerTester
tags: [pipelines, comments]
steps:
- command: import --blocking suricata
input: data/suricata/eve.json
- command: export json 'select timestamp /*double beginning /* is valid */'
- command: export json 'select timestamp | /**/'
expected_result: error
- command: export json 'select timestamp /*double ending*/ slash*/'
expected_result: error
Local Pipeline Execution:
tags: [pipelines]
steps:
# - is an alternative form of stdin and stdout
- command: exec 'from stdin read json | write json | save stdout'
input: data/json/sip.log.json.gz
- command: exec 'from file - read json | to stdout write json'
input: data/json/sip.log.json.gz
# stdin and stdout are the defaults
- command: exec 'read json | write json'
input: data/json/files.log.json.gz
# - is an alternative form of stdin and stdout
- command: exec 'from - read json | to - write json '
input: data/json/irc.log.json.gz
- command: exec 'from file - read json | to - write json'
input: data/json/irc.log.json.gz
Read from JSON File:
tags: [pipelines]
steps:
- command: exec 'from file @./data/json/record-in-list.json read json | write json'
Type mismatch in a column:
tags: [pipelines]
steps:
- command: exec 'from file @./data/json/type-mismatch.json read json | write json'
Use schema time unit when converting from a double to a duration:
tags: [pipelines]
steps:
- command: exec 'from file @./data/json/double-to-duration-cast.json read json --selector=schema:argus | select SIntPkt | write json'
Read from suricata file:
tags: [pipelines]
steps:
- command: exec 'from file @./data/suricata/eve.json read suricata | write json'
- command: exec 'from file @./data/suricata/eve.json read json --schema=suricata.alert --no-infer | write json'
Skip columns that are not in the schema for suricata input with no-infer option:
tags: [pipelines]
steps:
- command: exec 'from file @./data/suricata/dns-with-no-schema-column.json read suricata --no-infer | select custom_field | write json'
Read from zeek json file:
tags: [pipelines]
steps:
- command: exec 'from file @./data/zeek/zeek.json read zeek-json | write json'
Read JSON from tshark output:
tags: [json]
steps:
- command: exec 'from file @./data/pcap/tshark.json'
Read JSON with new field in record list:
tags: [json]
steps:
- command: exec 'from file @./data/json/record-list-new-field.json'
Read JSON with differents fields in one record list:
tags: [json]
steps:
- command: exec 'from file @./data/json/record-list-different-fields.json'
Read JSON with list config in overwritten field:
tags: [json]
steps:
- command: exec 'from file @./data/json/record-list-conflict-field-overwrite.json'
Read JSON record list with nulls and conflict:
tags: [json]
steps:
- command: exec 'from file @./data/json/record-list-with-null-conflict.json'
Schema ID Extractor:
tags: [pipelines, cef]
steps:
- command: 'exec "read cef | put fingerprint = #schema_id | write json"'
input: data/cef/forcepoint.log
- command: 'exec "read cef | where #schema_id == \"212b9111d2ee64a0\" | write json"'
input: data/cef/forcepoint.log
- command: 'exec "read cef | where #schema_id != \"212b9111d2ee64a0\" | write json"'
input: data/cef/forcepoint.log
Measure Events:
tags: [pipelines]
steps:
- command: exec 'read json | measure | summarize events=sum(events) by schema | write json'
input: data/json/files.log.json.gz
- command: exec 'read json | measure --real-time | summarize events=sum(events) by schema | write json'
input: data/json/files.log.json.gz
Measure Bytes:
tags: [pipelines]
steps:
- command: exec 'load stdin | measure | summarize bytes=sum(bytes) | write json'
input: data/json/conn.log.json.gz
- command: exec 'load stdin | measure --real-time | summarize bytes=sum(bytes) | write json'
input: data/json/conn.log.json.gz
Batch Events:
tags: [pipelines]
steps:
- command: exec 'show version | repeat 10 | batch 5 | measure | select events'
- command: exec 'show version | repeat 10 | batch 1 | measure | select events'
- command: exec 'show version | repeat 10 | batch 3 | measure | select events'
- command: exec 'show version | repeat 10 | batch 15 | measure | select events'
Empty Record in Pipeline:
tags: [pipelines]
steps:
- command: exec 'from - read json| write json'
input: data/json/empty-record.json
- command: exec 'from - read json | write csv'
input: data/json/empty-record.json
- command: exec 'from - read json | write xsv " " ; NULL'
input: data/json/empty-record.json
Repeat:
tags: [pipelines, repeat]
steps:
- command: exec 'load file - | read cef | write json'
input: data/cef/forcepoint.log
- command: exec 'load file - | repeat 5 | read cef | write json'
input: data/cef/forcepoint.log
- command: exec 'load file - | read cef | repeat 5 | write json'
input: data/cef/forcepoint.log
- command: exec 'load file - | read cef | measure | summarize sum(events) by schema | write json'
input: data/cef/forcepoint.log
- command: exec 'load file - | repeat 5 | read cef | measure | summarize sum(events) by schema | write json'
input: data/cef/forcepoint.log
- command: exec 'load file - | read cef | repeat 5 | measure | summarize sum(events) by schema | write json'
input: data/cef/forcepoint.log
Zeek TSV Pipeline Format:
tags: [pipelines, zeek]
steps:
- command: exec 'from stdin read zeek-tsv | write json'
input: data/zeek/merge.log
- command: exec 'from stdin read zeek-tsv | write json'
input: data/zeek/merge_with_whitespace_separation.log
- command: exec 'from stdin read zeek-tsv | head 300 | write zeek-tsv --disable-timestamp-tags'
input: data/zeek/dns.log.gz
- command: exec 'from stdin read zeek-tsv | head 300 | write csv'
input: data/zeek/dns.log.gz
- command: exec 'from stdin read zeek-tsv | write zeek-tsv --disable-timestamp-tags --set-separator ";" --empty-field "empty" --unset-field "NULLVAL"'
input: data/zeek/whitespace_start.log
- command: exec 'from stdin read json | write zeek-tsv --disable-timestamp-tags'
input: data/json/snmp.log.json.gz
- command: exec 'from stdin read zeek-tsv | write zeek-tsv --disable-timestamp-tags'
input: data/zeek/empty.log
- command: exec 'from stdin read zeek-tsv | write zeek-tsv --disable-timestamp-tags'
input: data/zeek/broken_no_separator_header.log
- command: exec 'from stdin read zeek-tsv | write zeek-tsv --disable-timestamp-tags'
input: data/zeek/broken_no_set_separator_header.log
- command: exec 'from stdin read zeek-tsv | write zeek-tsv --disable-timestamp-tags'
input: data/zeek/broken_no_separator_value.log
- command: exec 'from stdin read zeek-tsv | write zeek-tsv --disable-timestamp-tags'
input: data/zeek/broken_no_empty_and_unset_fields.log
- command: exec 'from stdin read zeek-tsv | write zeek-tsv --disable-timestamp-tags'
input: data/zeek/broken_unequal_fields_types_length.log
expected_result: error
- command: exec 'from stdin read zeek-tsv | write zeek-tsv --disable-timestamp-tags'
input: data/zeek/broken_duplicate_close_tag.log
expected_result: error
- command: exec 'from stdin read zeek-tsv | write zeek-tsv --disable-timestamp-tags'
input: data/zeek/broken_data_after_close_tag.log
expected_result: error
- command: exec 'from stdin read zeek-tsv | write zeek-tsv --disable-timestamp-tags'
input: data/zeek/broken_no_closing_tag.log
expected_result: error
- command: exec 'from stdin read zeek-tsv | write zeek-tsv --disable-timestamp-tags'
input: data/zeek/broken_no_data_after_open.log
Zeek TSV with Remote Import:
fixture: ServerTester
tags: [pipelines, zeek]
steps:
- command: exec 'from stdin read zeek-tsv | import'
input: data/zeek/merge.log
Enumerate:
tags: [pipelines]
steps:
- command: -N import -n 10 zeek
input: data/zeek/conn.log.gz
- command: -N import -n 10 zeek
input: data/zeek/dns.log.gz
- command: -N export json 'select uid | enumerate index'
- command: -N export json 'select uid | enumerate uid'
Sort:
tags: [pipelines, zeek]
steps:
- command: exec 'read zeek-tsv | select ts, uid | sort ts | write json'
input: data/zeek/merge.log
- command: exec 'read zeek-tsv | select uid | sort uid desc | write json'
input: data/zeek/merge.log
- command: exec 'read zeek-tsv | head | select service | sort service | write json'
input: data/zeek/conn.log.gz
- command: exec 'read zeek-tsv | head | select service | sort service nulls-first | write json'
input: data/zeek/conn.log.gz
Sort with Remote Operators:
fixture: ServerTester
tags: [import, export, pipelines]
steps:
- command: exec 'read cef | import'
input: data/cef/forcepoint.log
- command: flush
- command: exec 'export | sort signature_id asc | write json'
- command: exec 'export | sort uid asc | head 10 | write json'
# This tests for a bug fixed by tenzir/tenzir#3171 that caused sliced nested
# arrays to be accessed incorrectly, resulting in a crash. The head 8 and tail
# 3 operators are intentionally chosen to slice in the middle of a batch.
Slice Regression Test:
tags: [pipelines]
steps:
- command: exec 'read cef | select extension.dvc | head 8 | extend foo=extension.dvc | write json'
input: data/cef/forcepoint.log
- command: exec 'read cef | select extension.dvc | tail 3 | extend foo=extension.dvc | write json'
input: data/cef/forcepoint.log
Shell:
tags: [pipelines, zeek]
steps:
- command: exec 'read zeek-tsv | head 1 | write json -c | shell rev'
input: data/zeek/conn.log.gz
- command: exec 'shell "echo foo"'
- command: exec 'shell "{ echo \"#\"; seq 1 2 10; }" | read csv | write json -c'
Top and Rare Operators:
fixture: ServerTester
tags: [pipelines, zeek]
steps:
- command: exec 'read zeek-tsv | import'
input: data/zeek/conn.log.gz
- command: flush
- command: exec 'export | top id.orig_h | to stdout'
- command: exec 'export | rare id.orig_h | to stdout'
- command: exec 'export | top id.orig_h --count-field=amount | to stdout'
- command: exec 'export | rare id.orig_h -c amount | to stdout'
- command: exec 'export | top count | to stdout'
expected_result: error
- command: exec 'export | top id.orig_h --count-field=id.orig_h | to stdout'
expected_result: error
- command: exec 'export | rare id.orig_h -c id.orig_h | to stdout'
expected_result: error
- command: exec 'export | rare | to stdout'
expected_result: error
- command: exec 'export | top | to stdout'
expected_result: error
- command: exec 'export | top "" | to stdout'
expected_result: error
# The summarize operator supports using fields which do not exist, using
# `null` instead of their value. Here, we test many combinations of this
# behavior. We use the letters A, N and S for all, none and some,
# respectively. For example, SA means that the some (but not all)
# schemas do not have the aggregation column present, but for all
# of them, the group-by column exists.
Summarize All None Some:
tags: [pipelines]
steps:
# AA
- command: exec 'read zeek-json | summarize x=distinct(_path) by _path'
input: data/zeek/zeek.json
# NN
- command: exec 'read zeek-json | summarize x=distinct(y) by z'
input: data/zeek/zeek.json
# NA
- command: exec 'read zeek-json | summarize x=distinct(y) by _path'
input: data/zeek/zeek.json
# AN
- command: exec 'read zeek-json | summarize x=distinct(_path) by z'
input: data/zeek/zeek.json
# NS
- command: exec 'read zeek-json | summarize x=distinct(y) by id.orig_h'
input: data/zeek/zeek.json
# SN
- command: exec 'read zeek-json | summarize x=distinct(id.orig_h) by z'
input: data/zeek/zeek.json
# AS
- command: exec 'read zeek-json | summarize x=distinct(_path) by id.orig_h'
input: data/zeek/zeek.json
# SA
- command: exec 'read zeek-json | summarize x=distinct(id.orig_h) by _path'
input: data/zeek/zeek.json
# SS
- command: exec 'read zeek-json | summarize x=distinct(id.orig_h) by id.orig_h'
input: data/zeek/zeek.json
# A
- command: exec 'read zeek-json | summarize x=distinct(_path)'
input: data/zeek/zeek.json
# S
- command: exec 'read zeek-json | summarize x=distinct(id.orig_h)'
input: data/zeek/zeek.json
# N
- command: exec 'read zeek-json | summarize x=distinct(y)'
input: data/zeek/zeek.json
Summarize Dot:
tags: [pipelines]
steps:
- command: exec 'read zeek-json | summarize x=count(.)'
input: data/zeek/zeek.json
- command: exec 'read zeek-json | summarize x=distinct(.)'
input: data/zeek/zeek.json
expected_result: error
- command: exec 'read zeek-json | summarize x=count(_path) by .'
input: data/zeek/zeek.json
expected_result: error
Flatten Operator:
tags: [pipelines, zeek]
steps:
- command: exec 'read zeek-tsv | tail 10 | flatten | to stdout'
input: data/zeek/dns.log.gz