traffic-taffy 0.9.6__py3-none-any.whl → 0.9.8__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
traffic_taffy/__init__.py CHANGED
@@ -1 +1 @@
1
- __VERSION__ = "0.9.6"
1
+ __VERSION__ = "0.9.8"
@@ -259,16 +259,14 @@ class PCAPDissector:
259
259
  match_expression: str | None = None,
260
260
  ) -> None:
261
261
  """Output the results in an FSDB file."""
262
- if timestamps is None:
263
- timestamps = [0]
264
262
  import pyfsdb
265
263
 
266
264
  fh = pyfsdb.Fsdb(
267
265
  out_file_handle=sys.stdout,
268
- out_column_names=["key", "subkey", "value"],
266
+ out_column_names=["timestamp", "key", "subkey", "value"],
269
267
  converters={"value": int},
270
268
  )
271
- for _, key, subkey, value in self.dissection.find_data(
269
+ for timestamp, key, subkey, value in self.dissection.find_data(
272
270
  timestamps=timestamps,
273
271
  match_string=match_string,
274
272
  match_value=match_value,
@@ -276,7 +274,7 @@ class PCAPDissector:
276
274
  make_printable=True,
277
275
  match_expression=match_expression,
278
276
  ):
279
- fh.append([key, subkey, value])
277
+ fh.append([timestamp, key, subkey, value])
280
278
  fh.close()
281
279
 
282
280
 
@@ -0,0 +1,51 @@
1
+ """Traffic-Taffy plugin to look up addresses in the BLAG blocklist."""
2
+ from blagbl import BlagBL
3
+ import ipaddress
4
+
5
+ from traffic_taffy.hooks import register_hook
6
+ from traffic_taffy.dissector import POST_DISSECT_HOOK, INIT_HOOK
7
+ from traffic_taffy.dissection import Dissection
8
+
9
+ blag = None
10
+ blag_ips = None
11
+
12
+
13
+ @register_hook(INIT_HOOK)
14
+ def init_blag(**kwargs):
15
+ """Initialize the BLAG block list table."""
16
+ global blag
17
+ global blag_ips
18
+
19
+ if blag is None:
20
+ blag = BlagBL()
21
+ blag.parse_blag_contents()
22
+ blag_ips = blag.ips
23
+
24
+
25
+ @register_hook(POST_DISSECT_HOOK)
26
+ def ip_blagbl_lookup(dissection: Dissection, **kwargs):
27
+ """Perform IP address lookups within the BLAG block list."""
28
+ timestamps = dissection.data.keys()
29
+
30
+ for timestamp in timestamps:
31
+ keys = list(dissection.data[timestamp].keys())
32
+
33
+ for key in keys:
34
+ key = str(key)
35
+ if (
36
+ key.endswith("IP_src") or key.endswith("IP_dst")
37
+ # or key.endswith("IPv6_src")
38
+ # or key.endswith("IPv6_dst")
39
+ ):
40
+ for value in dissection.data[timestamp][key]:
41
+ try:
42
+ value = str(ipaddress.IPv4Address(value))
43
+ except Exception:
44
+ continue
45
+ count = dissection.data[timestamp][key][value]
46
+
47
+ if value in blag_ips:
48
+ for blocklist in blag_ips[value]:
49
+ dissection.data[timestamp][key + "_blocklist"][
50
+ blocklist
51
+ ] += count
@@ -9,7 +9,7 @@ from traffic_taffy.taffy_config import taffy_default, TaffyConfig
9
9
 
10
10
  i2a = None
11
11
 
12
- taffy_default("modules.ip2asn.database", "ip2asn-combined.tsv")
12
+ taffy_default("modules.ip2asn.database", ip2asn.DEFAULT_IP2ASN_FILE)
13
13
 
14
14
 
15
15
  @register_hook(INIT_HOOK)
@@ -20,7 +20,7 @@ def init_ip2asn(**kwargs):
20
20
  config = TaffyConfig()
21
21
  db_path = config.get_dotnest("modules.ip2asn.database")
22
22
 
23
- if not Path(db_path).exists():
23
+ if db_path and not Path(db_path).exists():
24
24
  error("The ip2asn plugin requires a ip2asn-combined.tsv in this directory")
25
25
  error("Please download it from https://iptoasn.com/")
26
26
 
@@ -65,6 +65,7 @@ class Console(Output):
65
65
  def output_record(self, key: str, subkey: Any, data: Dict[str, Any]) -> None:
66
66
  """Print a report to the console."""
67
67
 
68
+ marker = " "
68
69
  style = ""
69
70
  endstyle = ""
70
71
  if getattr(data, "delta_percentage", None):
@@ -73,12 +74,16 @@ class Console(Output):
73
74
  # apply some styling depending on range
74
75
  if delta_percentage < -Console.BOLD_LIMIT:
75
76
  style = "[bold red]"
77
+ marker = "v"
76
78
  elif delta_percentage < Console.POSITIVE:
77
79
  style = "[red]"
80
+ marker = "v"
78
81
  elif delta_percentage > Console.BOLD_LIMIT:
79
82
  style = "[bold green]"
83
+ marker = "^"
80
84
  elif delta_percentage > Console.POSITIVE:
81
85
  style = "[green]"
86
+ marker = "^"
82
87
  endstyle = style.replace("[", "[/")
83
88
 
84
89
  # construct the output line with styling
@@ -92,6 +97,7 @@ class Console(Output):
92
97
  style=style,
93
98
  endstyle=endstyle,
94
99
  subkey=subkey,
100
+ marker=marker,
95
101
  **field_values,
96
102
  )
97
103
 
@@ -34,7 +34,7 @@ class CompareSlicesReport(Report):
34
34
  @property
35
35
  def header_string(self) -> str:
36
36
  """Header string."""
37
- line = " {style}{subkey:<50}{endstyle}"
37
+ line = " {style} {subkey:<50}{endstyle}"
38
38
  line += " {left_count:>8} {right_count:>8} {delta_absolute:>8}"
39
39
  line += " {left_percentage:>7} {right_percentage:>7} {delta_percentage:>7}"
40
40
 
@@ -43,7 +43,7 @@ class CompareSlicesReport(Report):
43
43
  @property
44
44
  def format_string(self) -> str:
45
45
  """Formatting string for each printed line."""
46
- line = " {style}{subkey:<50}{endstyle}"
46
+ line = " {style}{marker} {subkey:<50}{endstyle}"
47
47
  line += " {left_count:>8} {right_count:>8} {delta_absolute:>8}"
48
48
  line += " {left_percentage:>7.2f} {right_percentage:>7.2f} {delta_percentage:>7.2f}"
49
49
 
@@ -28,7 +28,7 @@ class CorrelationChangeReport(Report):
28
28
  @property
29
29
  def header_string(self) -> str:
30
30
  """Formatting string for each printed line."""
31
- line = " {style}{subkey:<50}{endstyle}"
31
+ line = " {style} {subkey:<50}{endstyle}"
32
32
  line += " {timestamp:>10}"
33
33
  line += " {left_correlation:>17}"
34
34
  line += " {right_correlation:>17}"
@@ -39,7 +39,7 @@ class CorrelationChangeReport(Report):
39
39
  @property
40
40
  def format_string(self) -> str:
41
41
  """Formatting string for each printed line."""
42
- line = " {style}{subkey:<50}{endstyle}"
42
+ line = " {style}{marker} {subkey:<50}{endstyle}"
43
43
  line += " {timestamp:>10}"
44
44
  line += " {left_correlation:>17.2f}"
45
45
  line += " {right_correlation:>17.2f}"
@@ -22,7 +22,7 @@ class CorrelationReport(Report):
22
22
  @property
23
23
  def header_string(self) -> str:
24
24
  """Formatting string for each printed line."""
25
- line = " {style}{subkey:<50}{endstyle}"
25
+ line = " {style} {subkey:<50}{endstyle}"
26
26
  line += " {correlation:>11}"
27
27
 
28
28
  return line
@@ -30,7 +30,7 @@ class CorrelationReport(Report):
30
30
  @property
31
31
  def format_string(self) -> str:
32
32
  """Formatting string for each printed line."""
33
- line = " {style}{subkey:<50}{endstyle}"
33
+ line = " {style}{marker} {subkey:<50}{endstyle}"
34
34
  line += " {correlation:>11.2f}"
35
35
 
36
36
  return line
@@ -43,6 +43,12 @@ def dissect_parse_args() -> Namespace:
43
43
  help="Print results in an FSDB formatted output",
44
44
  )
45
45
 
46
+ parser.add_argument(
47
+ "-t", "--fsdb-all-timestamps",
48
+ action="store_true",
49
+ help="Print FSDB that includes all timestamps",
50
+ )
51
+
46
52
  parser.add_argument(
47
53
  "--dont-fork",
48
54
  action="store_true",
@@ -89,9 +95,12 @@ def main() -> None:
89
95
  pd.dissection = dissection
90
96
 
91
97
  # output as requested
92
- if args.fsdb:
98
+ if args.fsdb or args.fsdb_all_timestamps:
99
+ timestamps = [0]
100
+ if args.fsdb_all_timestamps:
101
+ timestamps = None
93
102
  pd.print_to_fsdb(
94
- timestamps=[0],
103
+ timestamps,
95
104
  match_string=args.match_string,
96
105
  match_value=args.match_value,
97
106
  minimum_count=args.minimum_count,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: traffic-taffy
3
- Version: 0.9.6
3
+ Version: 0.9.8
4
4
  Summary: A tool for doing differential analysis of pcap files
5
5
  Project-URL: Homepage, https://traffic-taffy.github.io/
6
6
  Author-email: Wes Hardaker <opensource@hardakers.net>
@@ -14,7 +14,7 @@ Requires-Dist: cryptography
14
14
  Requires-Dist: dnssplitter
15
15
  Requires-Dist: dotnest>=1.0
16
16
  Requires-Dist: dpkt
17
- Requires-Dist: ip2asn
17
+ Requires-Dist: ip2asn>=1.6.6
18
18
  Requires-Dist: msgpack
19
19
  Requires-Dist: pandas
20
20
  Requires-Dist: pcap-parallel
@@ -1,10 +1,10 @@
1
- traffic_taffy/__init__.py,sha256=9xmdbHPOaHkUt61kunVWy2yjchW2Zvmp7Ti49qS99iM,22
1
+ traffic_taffy/__init__.py,sha256=uP67YUi8VVs_JVB_tdvT_PnmKv3-I2IqRNX1DcwDqGs,22
2
2
  traffic_taffy/compare.py,sha256=g9rU6oa_2Wy0nUJ7K6TI8JTctyGCRvYEUakDBf7blOY,8644
3
3
  traffic_taffy/comparison.py,sha256=KJxOp4UqhfRkF4LI1PMDRIefeyTm2w5sbdr7VUTS4KM,1451
4
4
  traffic_taffy/config.py,sha256=DgTu2kA1Ec4Hbwl_44kTsdyJYvxAabgJk9a7aOH2XXU,4444
5
5
  traffic_taffy/dissection.py,sha256=DNxcXoNyk2lpJiaSzvAq1YHwHhYPY6xtlVkHTs-eb9Q,23904
6
6
  traffic_taffy/dissectmany.py,sha256=SWFXFyERNCi0j7hiMDEeJJdPYDpa0SOlSj1V8AqpXUA,5189
7
- traffic_taffy/dissector.py,sha256=M5MHVPwfeMHa6s4TG8ZiiNjk7qaht65wdqm0nmRHdQ8,15682
7
+ traffic_taffy/dissector.py,sha256=9QwGMGugHzVE8GWRpsfPXfSj02Sm2i_ZNU0Ah9AZ7BI,15654
8
8
  traffic_taffy/graph.py,sha256=EfkxH5D9PNlDpvftkh9GyUusV05EV537QGB7JOMeW4w,4730
9
9
  traffic_taffy/graphdata.py,sha256=r_QNXO3FzC7Vx4123SdCliAh7j2NCQ4Lb5uoOJnlt2M,3376
10
10
  traffic_taffy/taffy_config.py,sha256=AmdQbWAhoiV7aTNSpV1exJfd5eA0a3sYTIjikHkMPwY,1124
@@ -19,18 +19,19 @@ traffic_taffy/dissector_engine/dnstap.py,sha256=rBzVlB0D3YVhHOsr17cbnCIZU13g20sr
19
19
  traffic_taffy/dissector_engine/dpkt.py,sha256=q7cJz6WWpe9xUcEbAY_yn_cma_4loXuS3QKIVln6FHQ,12788
20
20
  traffic_taffy/dissector_engine/scapy.py,sha256=S3yrUmSeDjt3oE1I07L3iLFLF8Df8XAZg535FY_eu90,5004
21
21
  traffic_taffy/hooks/__init__.py,sha256=Bvhl6RnyBqQkWuCU6TS0O_ZHe4qCQsC4HE8FELigWPw,661
22
- traffic_taffy/hooks/ip2asn.py,sha256=7UA52L6jej0RYBptzP9izO0yXMcqH7wcp2ocDRUN5dg,2216
22
+ traffic_taffy/hooks/blag.py,sha256=KWFhDYbH8sRcUsujCSdlycE0pYkX5ymyRRbHxi20z3U,1626
23
+ traffic_taffy/hooks/ip2asn.py,sha256=G7zo2lFRLK-fbbzGMMcsaxIIh9ME6BoM0E6cJDaeE18,2233
23
24
  traffic_taffy/hooks/labels.py,sha256=5jHXq3-kxDQj9PRYgak-gDzE8dvSUiCEq9mBs9nE014,1933
24
25
  traffic_taffy/hooks/psl.py,sha256=A3maHS9FOholOEv1LuX0xSO3u34GyqeYl9_EtJG1pMY,2119
25
26
  traffic_taffy/iana/tables.msgpak,sha256=d-R5Xw9yG9t4RqGJRrpE6cjH4YfaxQBwQiBhNjKZbwI,172825
26
27
  traffic_taffy/output/__init__.py,sha256=qqlAUA99fxWlHEns-ji7A2RrcA8RA-AKXK7n2D737c8,3312
27
- traffic_taffy/output/console.py,sha256=QizlMIRbUKm7S57SojBiTAOB4KM9DCcj8EKiH1roO6U,3031
28
+ traffic_taffy/output/console.py,sha256=x68iZYCq3jCn86AsnP339CnDJVLVojfmOOwSbJtaQjk,3195
28
29
  traffic_taffy/output/fsdb.py,sha256=0z2zDydfnqOVM8Mj6pTJf4n4pGPupWykuYPgdgjJRN8,1859
29
30
  traffic_taffy/output/memory.py,sha256=86tgJ-jMt3UVX31eP6U02YbbYRoqbYhhR4kXJQmYzO4,1870
30
31
  traffic_taffy/reports/__init__.py,sha256=lMDS7q35aIdDrJ7G8ot4Q_6t9nYllr0C9510FL43rZY,113
31
- traffic_taffy/reports/compareslicesreport.py,sha256=Clrif58TPBTwP4BNxh9PcHkyASbUUscrOWtSgLrItN4,2754
32
- traffic_taffy/reports/correlationchangereport.py,sha256=W8tKWMk5Ss45Ho3wh_mAcK2Jj2fpL7vnNyun2C_lRgw,1575
33
- traffic_taffy/reports/correlationreport.py,sha256=9PdL_53mxfO619PFSoeRsTEm63L1J_u-B4sVvlH8xaU,1109
32
+ traffic_taffy/reports/compareslicesreport.py,sha256=zLGlW158orhWuneav2_t2pJrEmIIskQEPsbIJMJesX8,2765
33
+ traffic_taffy/reports/correlationchangereport.py,sha256=GazkJe0dx7F0TiGl9G6_l3zHHkglYpA2PfpibvEdalE,1586
34
+ traffic_taffy/reports/correlationreport.py,sha256=QwwFzf1XKsPYQ-m5sHnLeCne0IMcHGamzsOEJBzL32c,1120
34
35
  traffic_taffy/tests/test_compare_results.py,sha256=iLcS9wvEqxgKszIspLtD2Zw8Qk5JxOCurQwWYzhtOkM,2318
35
36
  traffic_taffy/tests/test_config.py,sha256=UCqSJXVwpFFchcIbyFzLqjVF-wgEV755KlQ7thommro,4284
36
37
  traffic_taffy/tests/test_dict_merge.py,sha256=t3rZSQQ0AlBxRKfLborx9SxYN53cCAQQzZ2w-__WT2Y,1429
@@ -45,12 +46,12 @@ traffic_taffy/tools/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSu
45
46
  traffic_taffy/tools/cache_info.py,sha256=ZanO6jDlTdfJ7w0N_7BkLyJj4NyZGShaH7SrUulbIoE,2085
46
47
  traffic_taffy/tools/compare.py,sha256=oT5fIqfPeY6nGI9vSVAoKDsAVzzqfXJDzyOw2BhPfSI,3509
47
48
  traffic_taffy/tools/config.py,sha256=RwJYyfI1yiAKbMzU5mcPTguBiH-hGRy5vk_YvAAjPuM,2343
48
- traffic_taffy/tools/dissect.py,sha256=B-7e7aqEOWtJ-0P2Y-mzmrzoDqVrDCJ2JzGR45QtuuQ,3073
49
+ traffic_taffy/tools/dissect.py,sha256=kGG0K2d9-OwrAhEU97id2m29PvhYaXZYIw1nLi1aVsE,3346
49
50
  traffic_taffy/tools/explore.py,sha256=gUcOfAgangJJI1si1gLPUoWRUKmWUAXSP0oTD2JJygw,24149
50
51
  traffic_taffy/tools/export.py,sha256=9zBBGhZK95b4ZiLJ8XK30GPsaBjgR84Sk1HoPIxRpTI,2844
51
52
  traffic_taffy/tools/graph.py,sha256=KiKDY9R8JLT5-JouANoi_1WGcdFMhXsLnYlhPsFRWpM,2316
52
- traffic_taffy-0.9.6.dist-info/METADATA,sha256=pc-nZx_uzZb6DSBR1ZWCbDrKnHPVlkB6EhlSU4T9SWc,2304
53
- traffic_taffy-0.9.6.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
54
- traffic_taffy-0.9.6.dist-info/entry_points.txt,sha256=F0lqjvw94nQ3hY4eerN7faT9aKhhGUHbqBhuEr9q1r8,361
55
- traffic_taffy-0.9.6.dist-info/licenses/LICENSE.txt,sha256=hiV1DJgDQeSM1r7P-ez5oxily11S5nsCedU0jKzKKzo,11338
56
- traffic_taffy-0.9.6.dist-info/RECORD,,
53
+ traffic_taffy-0.9.8.dist-info/METADATA,sha256=AhnwUs9q5jfXHgQOWbF5wYFEkSX3al81a02UgMZLgak,2311
54
+ traffic_taffy-0.9.8.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
55
+ traffic_taffy-0.9.8.dist-info/entry_points.txt,sha256=F0lqjvw94nQ3hY4eerN7faT9aKhhGUHbqBhuEr9q1r8,361
56
+ traffic_taffy-0.9.8.dist-info/licenses/LICENSE.txt,sha256=eFp2vwcZFJW55SUQRoEfXio3K9XdwvsaI_WHntR7I2M,11338
57
+ traffic_taffy-0.9.8.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
- Copyright 2023-2024 USC/ISI
1
+ Copyright 2023-2025 USC/ISI
2
2
 
3
3
  Licensed under the Apache License, Version 2.0 (the "License");
4
4
  you may not use this file except in compliance with the License.