traffic-taffy 0.9.5__tar.gz → 0.9.7__tar.gz

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.
Files changed (60) hide show
  1. {traffic_taffy-0.9.5 → traffic_taffy-0.9.7}/LICENSE.txt +1 -1
  2. {traffic_taffy-0.9.5 → traffic_taffy-0.9.7}/PKG-INFO +4 -3
  3. {traffic_taffy-0.9.5 → traffic_taffy-0.9.7}/pyproject.toml +7 -3
  4. traffic_taffy-0.9.7/traffic_taffy/__init__.py +1 -0
  5. {traffic_taffy-0.9.5 → traffic_taffy-0.9.7}/traffic_taffy/dissection.py +0 -12
  6. {traffic_taffy-0.9.5 → traffic_taffy-0.9.7}/traffic_taffy/dissector.py +3 -5
  7. {traffic_taffy-0.9.5 → traffic_taffy-0.9.7}/traffic_taffy/dissector_engine/scapy.py +2 -0
  8. traffic_taffy-0.9.7/traffic_taffy/hooks/blag.py +51 -0
  9. {traffic_taffy-0.9.5 → traffic_taffy-0.9.7}/traffic_taffy/hooks/ip2asn.py +2 -2
  10. {traffic_taffy-0.9.5 → traffic_taffy-0.9.7}/traffic_taffy/tools/dissect.py +11 -2
  11. traffic_taffy-0.9.5/traffic_taffy/__init__.py +0 -1
  12. {traffic_taffy-0.9.5 → traffic_taffy-0.9.7}/.gitignore +0 -0
  13. {traffic_taffy-0.9.5 → traffic_taffy-0.9.7}/README.md +0 -0
  14. {traffic_taffy-0.9.5 → traffic_taffy-0.9.7}/traffic_taffy/algorithms/__init__.py +0 -0
  15. {traffic_taffy-0.9.5 → traffic_taffy-0.9.7}/traffic_taffy/algorithms/comparecorrelation.py +0 -0
  16. {traffic_taffy-0.9.5 → traffic_taffy-0.9.7}/traffic_taffy/algorithms/comparecorrelationchanges.py +0 -0
  17. {traffic_taffy-0.9.5 → traffic_taffy-0.9.7}/traffic_taffy/algorithms/compareseries.py +0 -0
  18. {traffic_taffy-0.9.5 → traffic_taffy-0.9.7}/traffic_taffy/algorithms/compareslices.py +0 -0
  19. {traffic_taffy-0.9.5 → traffic_taffy-0.9.7}/traffic_taffy/algorithms/statistical.py +0 -0
  20. {traffic_taffy-0.9.5 → traffic_taffy-0.9.7}/traffic_taffy/compare.py +0 -0
  21. {traffic_taffy-0.9.5 → traffic_taffy-0.9.7}/traffic_taffy/comparison.py +0 -0
  22. {traffic_taffy-0.9.5 → traffic_taffy-0.9.7}/traffic_taffy/config.py +0 -0
  23. {traffic_taffy-0.9.5 → traffic_taffy-0.9.7}/traffic_taffy/dissectmany.py +0 -0
  24. {traffic_taffy-0.9.5 → traffic_taffy-0.9.7}/traffic_taffy/dissector_engine/__init__.py +0 -0
  25. {traffic_taffy-0.9.5 → traffic_taffy-0.9.7}/traffic_taffy/dissector_engine/dnstap.py +0 -0
  26. {traffic_taffy-0.9.5 → traffic_taffy-0.9.7}/traffic_taffy/dissector_engine/dpkt.py +0 -0
  27. {traffic_taffy-0.9.5 → traffic_taffy-0.9.7}/traffic_taffy/graph.py +0 -0
  28. {traffic_taffy-0.9.5 → traffic_taffy-0.9.7}/traffic_taffy/graphdata.py +0 -0
  29. {traffic_taffy-0.9.5 → traffic_taffy-0.9.7}/traffic_taffy/hooks/__init__.py +0 -0
  30. {traffic_taffy-0.9.5 → traffic_taffy-0.9.7}/traffic_taffy/hooks/labels.py +0 -0
  31. {traffic_taffy-0.9.5 → traffic_taffy-0.9.7}/traffic_taffy/hooks/psl.py +0 -0
  32. {traffic_taffy-0.9.5 → traffic_taffy-0.9.7}/traffic_taffy/iana/tables.msgpak +0 -0
  33. {traffic_taffy-0.9.5 → traffic_taffy-0.9.7}/traffic_taffy/output/__init__.py +0 -0
  34. {traffic_taffy-0.9.5 → traffic_taffy-0.9.7}/traffic_taffy/output/console.py +0 -0
  35. {traffic_taffy-0.9.5 → traffic_taffy-0.9.7}/traffic_taffy/output/fsdb.py +0 -0
  36. {traffic_taffy-0.9.5 → traffic_taffy-0.9.7}/traffic_taffy/output/memory.py +0 -0
  37. {traffic_taffy-0.9.5 → traffic_taffy-0.9.7}/traffic_taffy/report.py +0 -0
  38. {traffic_taffy-0.9.5 → traffic_taffy-0.9.7}/traffic_taffy/reports/__init__.py +0 -0
  39. {traffic_taffy-0.9.5 → traffic_taffy-0.9.7}/traffic_taffy/reports/compareslicesreport.py +0 -0
  40. {traffic_taffy-0.9.5 → traffic_taffy-0.9.7}/traffic_taffy/reports/correlationchangereport.py +0 -0
  41. {traffic_taffy-0.9.5 → traffic_taffy-0.9.7}/traffic_taffy/reports/correlationreport.py +0 -0
  42. {traffic_taffy-0.9.5 → traffic_taffy-0.9.7}/traffic_taffy/taffy_config.py +0 -0
  43. {traffic_taffy-0.9.5 → traffic_taffy-0.9.7}/traffic_taffy/tests/test_compare_results.py +0 -0
  44. {traffic_taffy-0.9.5 → traffic_taffy-0.9.7}/traffic_taffy/tests/test_config.py +0 -0
  45. {traffic_taffy-0.9.5 → traffic_taffy-0.9.7}/traffic_taffy/tests/test_dict_merge.py +0 -0
  46. {traffic_taffy-0.9.5 → traffic_taffy-0.9.7}/traffic_taffy/tests/test_dpkt_engine.py +0 -0
  47. {traffic_taffy-0.9.5 → traffic_taffy-0.9.7}/traffic_taffy/tests/test_global_config.py +0 -0
  48. {traffic_taffy-0.9.5 → traffic_taffy-0.9.7}/traffic_taffy/tests/test_hooks.py +0 -0
  49. {traffic_taffy-0.9.5 → traffic_taffy-0.9.7}/traffic_taffy/tests/test_normalize.py +0 -0
  50. {traffic_taffy-0.9.5 → traffic_taffy-0.9.7}/traffic_taffy/tests/test_pcap_dissector.py +0 -0
  51. {traffic_taffy-0.9.5 → traffic_taffy-0.9.7}/traffic_taffy/tests/test_pcap_splitter.py +0 -0
  52. {traffic_taffy-0.9.5 → traffic_taffy-0.9.7}/traffic_taffy/tests/test_splitter.py +0 -0
  53. {traffic_taffy-0.9.5 → traffic_taffy-0.9.7}/traffic_taffy/tests/test_value_printing.py +0 -0
  54. {traffic_taffy-0.9.5 → traffic_taffy-0.9.7}/traffic_taffy/tools/__init__.py +0 -0
  55. {traffic_taffy-0.9.5 → traffic_taffy-0.9.7}/traffic_taffy/tools/cache_info.py +0 -0
  56. {traffic_taffy-0.9.5 → traffic_taffy-0.9.7}/traffic_taffy/tools/compare.py +0 -0
  57. {traffic_taffy-0.9.5 → traffic_taffy-0.9.7}/traffic_taffy/tools/config.py +0 -0
  58. {traffic_taffy-0.9.5 → traffic_taffy-0.9.7}/traffic_taffy/tools/explore.py +0 -0
  59. {traffic_taffy-0.9.5 → traffic_taffy-0.9.7}/traffic_taffy/tools/export.py +0 -0
  60. {traffic_taffy-0.9.5 → traffic_taffy-0.9.7}/traffic_taffy/tools/graph.py +0 -0
@@ -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.
@@ -1,10 +1,11 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: traffic-taffy
3
- Version: 0.9.5
3
+ Version: 0.9.7
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>
7
7
  License-File: LICENSE.txt
8
+ Classifier: License :: OSI Approved :: Apache Software License
8
9
  Classifier: Operating System :: OS Independent
9
10
  Classifier: Programming Language :: Python :: 3
10
11
  Requires-Python: >=3.7
@@ -13,7 +14,7 @@ Requires-Dist: cryptography
13
14
  Requires-Dist: dnssplitter
14
15
  Requires-Dist: dotnest>=1.0
15
16
  Requires-Dist: dpkt
16
- Requires-Dist: ip2asn
17
+ Requires-Dist: ip2asn>=1.6.6
17
18
  Requires-Dist: msgpack
18
19
  Requires-Dist: pandas
19
20
  Requires-Dist: pcap-parallel
@@ -1,5 +1,5 @@
1
1
  [build-system]
2
- requires = ["hatchling"]
2
+ requires = ["hatchling>=1.26.1"]
3
3
  build-backend = "hatchling.build"
4
4
 
5
5
  [project]
@@ -7,7 +7,10 @@ name = "traffic-taffy"
7
7
  dynamic = ["version"]
8
8
  description = "A tool for doing differential analysis of pcap files"
9
9
  readme = "README.md"
10
- license = ""
10
+ # license = "Apache License, Version 2.0"
11
+ # license = { file = "LICENSE.txt" }
12
+ # license-expression = "Apache 2.0"
13
+ # license-file = "LICENSE.txt"
11
14
  requires-python = ">=3.7"
12
15
  authors = [
13
16
  { name = "Wes Hardaker", email = "opensource@hardakers.net" },
@@ -15,6 +18,7 @@ authors = [
15
18
  classifiers = [
16
19
  "Operating System :: OS Independent",
17
20
  "Programming Language :: Python :: 3",
21
+ "License :: OSI Approved :: Apache Software License",
18
22
  ]
19
23
  dependencies = [
20
24
  "dpkt",
@@ -30,7 +34,7 @@ dependencies = [
30
34
  "cryptography",
31
35
  "pyOpenSSL==22.1.0",
32
36
  "dnssplitter",
33
- "ip2asn",
37
+ "ip2asn>=1.6.6",
34
38
  "dotnest>=1.0",
35
39
  "argparse-with-config>=0.1.4",
36
40
  ]
@@ -0,0 +1 @@
1
+ __VERSION__ = "0.9.7"
@@ -134,8 +134,6 @@ class Dissection:
134
134
  # note: there should be no recorded tcpdump files from 1970 Jan 01 :-)
135
135
  self.data[0][key][value] += count
136
136
  if self.timestamp:
137
- if self.timestamp not in self.data:
138
- self.data[self.timestamp] = defaultdict(Counter)
139
137
  self.data[self.timestamp][key][value] += count
140
138
 
141
139
  def calculate_metadata(self: Dissection) -> None:
@@ -159,16 +157,6 @@ class Dissection:
159
157
  for timestamp in other_dissection.data:
160
158
  for key in other_dissection.data[timestamp]:
161
159
  for subkey in other_dissection.data[timestamp][key]:
162
- # TODO(hardaker): this is horribly inefficient
163
- if timestamp not in self.data:
164
- self.data[timestamp] = defaultdict(Counter)
165
- elif key not in self.data[timestamp]:
166
- self.data[timestamp][key] = Counter()
167
- elif (
168
- isinstance(self.data[timestamp][key], dict)
169
- and subkey not in self.data[timestamp][key]
170
- ):
171
- self.data[timestamp][key][subkey] = 0
172
160
  self.data[timestamp][key][subkey] += other_dissection.data[
173
161
  timestamp
174
162
  ][key][subkey]
@@ -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
 
@@ -113,6 +113,8 @@ class DissectionEngineScapy(DissectionEngine):
113
113
 
114
114
  try:
115
115
  field_value = getattr(layer, field_name)
116
+ if not field_value: ## can return empty field values like []
117
+ continue
116
118
  if hasattr(field_value, "fields"):
117
119
  self.add_layer(field_value, new_prefix + "_")
118
120
  else:
@@ -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
 
@@ -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 +0,0 @@
1
- __VERSION__ = "0.9.5"
File without changes
File without changes