You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
let hex_hex1 = "00090001000000000000000000000000000000010000000c0100000100080004";
133
133
let hex_hex2 = "000900010000000000000000000000000000000101000008c0a80001";
134
134
135
-
let combined = format!("{}{}{}", hex_hex0, hex_hex1, hex_hex2);
136
-
137
135
letmut parser = NetflowParser::builder()
138
136
.with_cache_size(100)
139
137
.build()
140
138
.unwrap();
141
139
142
-
let packets = hex::decode(combined).unwrap();
143
-
let results = parser.parse_bytes(&packets).packets;
140
+
letmut results = Vec::new();
141
+
for packet_hex in[hex_hex0, hex_hex1, hex_hex2]{
142
+
let parsed = parser.parse_bytes(&hex::decode(packet_hex).unwrap());
143
+
assert!(parsed.error.is_none());
144
+
results.extend(parsed.packets);
145
+
}
144
146
assert_yaml_snapshot!(results);
145
147
}
146
148
147
149
// Verify that a v9 template packet is parsed and can be serialized back to bytes
148
150
#[test]
149
151
fncan_read_v9(){
150
-
// Template
151
-
let hex = "0009000100000e1061db09bd000000010000000100000028010000080001000400020004000a00040004000400080004000c0004000700020015000400050001000600010016000400100004";
152
+
// One 40-byte Template FlowSet. An older fixture included 16 bytes
153
+
// beyond its declared FlowSet length; those bytes are not part of it.
154
+
let hex = "0009000100000e1061db09bd000000010000000100000028010000080001000400020004000a00040004000400080004000c00040007000200150004";
152
155
153
156
letmut parser = NetflowParser::builder()
154
157
.with_cache_size(100)
@@ -349,10 +352,11 @@ mod base_tests {
349
352
}
350
353
}
351
354
352
-
// Verify that v9 options template followed by a zeroed-out data record parses correctly
355
+
// Verify that a malformed v9 options template is not cached and its subsequent
356
+
// data record is retained as NoTemplate without relying on bytes outside either FlowSet.
353
357
#[test]
354
358
fnoptions_no_data(){
355
-
let hex = "0009000100000001639073f3000000010000000100010034010200210001000400020004000e000400160004001500040009000100070002001000040011000400180004000600010005000100b0000200b1000200b2000200b4000200b7000200b8000200ad000200ac00010038000200b9000200bd000200be000200c1000200c2000200c5000200c3000200c4000200c6000200c7000200c8000200c9000200ca000200cb000200ce000200";
359
+
let hex = "0009000100000001639073f3000000010000000100010034010200210001000400020004000e00040016000400150004000900010007000200100004001100040018000400060001";
356
360
357
361
letmut parser = NetflowParser::builder()
358
362
.with_cache_size(100)
@@ -362,7 +366,7 @@ mod base_tests {
362
366
let packet = hex::decode(hex).unwrap();
363
367
let _ = parser.parse_bytes(&packet);
364
368
365
-
let hex_data = "0009000100000002639073f300000002000000010102008400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000";
369
+
let hex_data = "0009000100000002639073f30000000200000001010200840000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000";
// Verify that v9 template followed by data in separate packets produces correct output
396
400
#[test]
397
401
fnv9_example_from_integration_test(){
398
-
let hex_template = "000900020000000563b32ef1000000010000000100000024010000060001000400020004000a00040004000400080004000c000400010038010000020001000400020004";
402
+
// Each packet ends at its declared FlowSet boundary. Older fixtures
403
+
// appended malformed bytes that the Count-as-FlowSet bug hid.
404
+
let hex_template = "000900010000000563b32ef1000000010000000100000024010000060001000400020004000a00040004000400080004000c000400010038";
399
405
400
-
let hex_hex1 = "000900020000000663b32ef10000000200000001010000240a70090a0a70090b00000001000000010000000100000001000000030000000601000008192a80e3192a80e4";
406
+
let hex_hex1 = "000900010000000663b32ef10000000200000001010000240a70090a0a70090b000000010000000100000001000000010000000300000006";
401
407
402
408
let _hex_hex2 = "000900020000000763b32ef10000000300000001010000240a700a050a700a0600000001000000010000000100000001000000030000000601000008192a80e3192a80e4";
403
409
@@ -413,9 +419,10 @@ mod base_tests {
413
419
// Verify that v9 multi-template data parsing works across sequential packets
414
420
#[test]
415
421
fnv9_example_from_integration_test_2(){
416
-
let hex1 = "000900020000000563b32ef1000000010000000100000024010000060001000400020004000a00040004000400080004000c000400010038010000020001000400020004";
422
+
// Same corrected caller-delimited fixture pair as the integration case above.
423
+
let hex1 = "000900010000000563b32ef1000000010000000100000024010000060001000400020004000a00040004000400080004000c000400010038";
417
424
418
-
let hex2 = "000900020000000663b32ef10000000200000001010000240a70090a0a70090b00000001000000010000000100000001000000030000000601000008192a80e3192a80e4";
425
+
let hex2 = "000900010000000663b32ef10000000200000001010000240a70090a0a70090b000000010000000100000001000000010000000300000006";
419
426
420
427
letmut parser = NetflowParser::builder()
421
428
.with_cache_size(100)
@@ -1080,9 +1087,14 @@ mod restored_legacy_tests {
1080
1087
fnit_parses_v9_ipv6flowlabel(){
1081
1088
let templates_hex = "0009000400a21e176658cb4600000155000000080000004c0102001100080004000c0004000f000400070002000b0002000a0002000e000200fc000400fd000400020004000100040016000400150004000400010005000101000002003d0001000000540103001300080004000c0004000f000400070002000b000200060001000a0002000e000200fc000400fd000400020004000100040016000400150004000400010005000100d1000801000002003d00010000005401050013001b0010001c0010003e001000070002000b000200060001000a0002000e000200fc000400fd00040002000400010004001600040015000400040001000500010050000601000002003d00010000005801060014001b0010001c0010003e0010001f000300070002000b000200060001000a0002000e000200fc000400fd00040002000400010004001600040015000400040001000500010050000601000002003d0001";
1082
1089
let packets_hex = "0009000200a3a50e6658cbab000001640000000801020066c0a8120a8d180c0200000000c2c00035000200000000000000000000000000010000005200a31e7700a31e771100080001c0a8120a8d180c02000000009e230035000200000000000000000000000000010000005200a3197b00a3197b110008000101060063fd010008000000002a20235f1f7b9379fd00000000000000b2f208fffe2011800000000000000000000000000000000001f676e2b5003500000200000000000000000000000000010000006600a3197b00a3197b1100109027e0436d86dd01";
1083
-
let combined = format!("{}{}", templates_hex, packets_hex);
0 commit comments