traffic-taffy 0.9.1__py3-none-any.whl → 0.9.3__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.1"
1
+ __VERSION__ = "0.9.3"
@@ -64,7 +64,10 @@ class ComparisonStatistical(ComparisonSlicesAlgorithm):
64
64
  left_count = 0
65
65
  right_count = right_side[key][subkey]
66
66
  left_percentage = 0.0
67
- right_percentage = right_side[key][subkey] / right_side_total
67
+ if right_side_total == 0:
68
+ right_percentage = 100
69
+ else:
70
+ right_percentage = right_side[key][subkey] / right_side_total
68
71
  new_right_count += 1 # this value wasn't in the left
69
72
 
70
73
  report[key][subkey] = CompareSlicesReport(
@@ -47,6 +47,7 @@ class TTL_CFG:
47
47
 
48
48
 
49
49
  POST_DISSECT_HOOK: str = "post_dissect"
50
+ INIT_HOOK: str = "init_hooks"
50
51
 
51
52
 
52
53
  def dissector_default(name: str, value: Any) -> None:
@@ -455,6 +456,7 @@ def dissector_handle_arguments(args) -> None:
455
456
  """Handle checking and loading arguments."""
456
457
  check_dissector_level(args.dissection_level)
457
458
  dissector_load_extra_modules(args.modules)
459
+ call_hooks(INIT_HOOK)
458
460
 
459
461
 
460
462
  def dissector_load_extra_modules(modules: List[str]) -> None:
@@ -3,7 +3,7 @@ from logging import error, info, debug
3
3
  import ip2asn
4
4
 
5
5
  from traffic_taffy.hooks import register_hook
6
- from traffic_taffy.dissector import POST_DISSECT_HOOK
6
+ from traffic_taffy.dissector import POST_DISSECT_HOOK, INIT_HOOK
7
7
  from traffic_taffy.dissection import Dissection
8
8
  from traffic_taffy.taffy_config import taffy_default, TaffyConfig
9
9
 
@@ -12,8 +12,8 @@ i2a = None
12
12
  taffy_default("modules.ip2asn.database", "ip2asn-combined.tsv")
13
13
 
14
14
 
15
- @register_hook(POST_DISSECT_HOOK)
16
- def ip_to_asn(dissection: Dissection, **kwargs):
15
+ @register_hook(INIT_HOOK)
16
+ def init_ip2asn(**kwargs):
17
17
  global i2a
18
18
 
19
19
  if i2a is None:
@@ -28,6 +28,11 @@ def ip_to_asn(dissection: Dissection, **kwargs):
28
28
  i2a = ip2asn.IP2ASN(db_path)
29
29
  info(" ... loaded")
30
30
 
31
+
32
+ @register_hook(POST_DISSECT_HOOK)
33
+ def ip_to_asn(dissection: Dissection, **kwargs):
34
+ init_ip2asn()
35
+
31
36
  timestamps = dissection.data.keys()
32
37
 
33
38
  for timestamp in timestamps:
@@ -30,6 +30,8 @@ def split_dns_names(dissection: Dissection, **kwargs):
30
30
  parts = value.split(".")
31
31
  if parts[-1] == "":
32
32
  parts = parts[:-1] # drop the empty end "." split
33
+ if len(parts) == 0:
34
+ continue
33
35
  dissection.data[timestamp][key + "_tld"][parts[-1]] += count
34
36
  if len(parts) > 1:
35
37
  dissection.data[timestamp][key + "_sld"][parts[-2]] += count
@@ -2,7 +2,7 @@ from logging import info
2
2
  import dnssplitter
3
3
 
4
4
  from traffic_taffy.hooks import register_hook
5
- from traffic_taffy.dissector import POST_DISSECT_HOOK
5
+ from traffic_taffy.dissector import POST_DISSECT_HOOK, INIT_HOOK
6
6
  from traffic_taffy.dissection import Dissection
7
7
  from traffic_taffy.taffy_config import taffy_default, TaffyConfig
8
8
 
@@ -11,8 +11,8 @@ splitter = None
11
11
  taffy_default("modules.psl.database", "__internal__")
12
12
 
13
13
 
14
- @register_hook(POST_DISSECT_HOOK)
15
- def split_dns_names(dissection: Dissection, **kwargs):
14
+ @register_hook(INIT_HOOK)
15
+ def init_splitter(**kwargs):
16
16
  global splitter
17
17
 
18
18
  if not splitter:
@@ -28,6 +28,11 @@ def split_dns_names(dissection: Dissection, **kwargs):
28
28
  info(f"loading PSL from {path}")
29
29
  splitter.load_psl_file(path)
30
30
 
31
+
32
+ @register_hook(POST_DISSECT_HOOK)
33
+ def split_dns_names(dissection: Dissection, **kwargs):
34
+ init_splitter()
35
+
31
36
  timestamps = dissection.data.keys()
32
37
 
33
38
  for timestamp in timestamps:
@@ -33,48 +33,48 @@ except ModuleNotFoundError:
33
33
  logging.debug("psl module not loadable")
34
34
 
35
35
 
36
+ def taffy_config_parse_args() -> Namespace:
37
+ """Parse the command line arguments."""
38
+
39
+ config: TaffyConfig = TaffyConfig()
40
+ config.config_option_names = ["-y", "--config"]
41
+ config[TT_CFG.LOG_LEVEL] = "info"
42
+
43
+ config.read_configfile_from_arguments(sys.argv)
44
+
45
+ parser = ArgumentParser(
46
+ formatter_class=RichHelpFormatter,
47
+ description=__doc__,
48
+ epilog="Example Usage: taffy-config > defaults.yml",
49
+ )
50
+
51
+ parser.add_argument(
52
+ "-y",
53
+ "--config",
54
+ default=None,
55
+ type=str,
56
+ help="Configuration file (YAML) to load.",
57
+ )
58
+
59
+ parser.add_argument(
60
+ "--log-level",
61
+ "--ll",
62
+ default="info",
63
+ help="Define the logging verbosity level (debug, info, warning, error, fotal, critical).",
64
+ )
65
+
66
+ args = parser.parse_args()
67
+ log_level = args.log_level.upper()
68
+ logging.basicConfig(level=log_level, format="%(levelname)-10s:\t%(message)s")
69
+
70
+ config.load_namespace(args)
71
+ return config
72
+
73
+
36
74
  def main() -> None:
37
75
  """Dissect a pcap file and report contents."""
38
76
 
39
- def parse_args() -> Namespace:
40
- """Parse the command line arguments."""
41
-
42
- config: TaffyConfig = TaffyConfig()
43
- config.config_option_names = ["-y", "--config"]
44
- config[TT_CFG.LOG_LEVEL] = "info"
45
-
46
- config.read_configfile_from_arguments(sys.argv)
47
-
48
- parser = ArgumentParser(
49
- formatter_class=RichHelpFormatter,
50
- description=__doc__,
51
- epilog="Example Usage: taffy-config > defaults.yml",
52
- )
53
-
54
- parser.add_argument(
55
- "-y",
56
- "--config",
57
- default=None,
58
- type=str,
59
- help="Configuration file (YAML) to load.",
60
- )
61
-
62
- parser.add_argument(
63
- "--log-level",
64
- "--ll",
65
- default="info",
66
- help="Define the logging verbosity level (debug, info, warning, error, fotal, critical).",
67
- )
68
-
69
- args = parser.parse_args()
70
- log_level = args.log_level.upper()
71
- logging.basicConfig(level=log_level, format="%(levelname)-10s:\t%(message)s")
72
-
73
- config.load_namespace(args)
74
- return config
75
-
76
- config = parse_args()
77
- config.as_namespace()
77
+ config = taffy_config_parse_args()
78
78
 
79
79
  print(yaml.dump(dict(config)))
80
80
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: traffic-taffy
3
- Version: 0.9.1
3
+ Version: 0.9.3
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>
@@ -56,6 +56,12 @@ might be coming that will cause merge conflicts.
56
56
 
57
57
  # Copyright and License
58
58
 
59
+ Traffic-taffy was created by [Wes Hardaker], a computer scientist at
60
+ [USC/ISI], with support from the Comcast Innovation Fund.
61
+
62
+ [Wes Hardaker]: https://ant.isi.edu/~hardaker/
63
+ [USC/ISI]: https://www.isi.edu/
64
+
59
65
  This project is copyrighted by the University of Southern California,
60
66
  Information Sciences institute. It is released under the Apache 2.0
61
67
  license.
@@ -1,10 +1,10 @@
1
- traffic_taffy/__init__.py,sha256=u9pJ9wMqnfaUDvpAnje_QL_Ge7wmEMvP3I7LcFNVbmw,22
1
+ traffic_taffy/__init__.py,sha256=QTKEpzY_ZMDccPfhHR5VeIEETRWrA3oohe60v8oSycU,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=dW6UxJ_RY5oMipyh3J2CvsjP-E9Llly7IgjbPFSSTzU,24571
6
6
  traffic_taffy/dissectmany.py,sha256=SWFXFyERNCi0j7hiMDEeJJdPYDpa0SOlSj1V8AqpXUA,5189
7
- traffic_taffy/dissector.py,sha256=Q5dYLY8ZVPt2Iz4T0asdmBBwma2YPBk9XOwtmOATX10,15626
7
+ traffic_taffy/dissector.py,sha256=M5MHVPwfeMHa6s4TG8ZiiNjk7qaht65wdqm0nmRHdQ8,15682
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
@@ -13,15 +13,15 @@ traffic_taffy/algorithms/comparecorrelation.py,sha256=gakZJotZNOVj96y4_-vtt_ka8p
13
13
  traffic_taffy/algorithms/comparecorrelationchanges.py,sha256=-ztWKpNN5lm_6e7hTSZytwzuK1RpMpfe1ksQgsb0_tk,7646
14
14
  traffic_taffy/algorithms/compareseries.py,sha256=cVonTV6TnMZAaHlGqZ6shn0aDQTTHzK-tPvUAk3OkuQ,4165
15
15
  traffic_taffy/algorithms/compareslices.py,sha256=aIDhISKi-m8uD65pBd3A2naoxYD9zeay6y7mAk4hXdg,4336
16
- traffic_taffy/algorithms/statistical.py,sha256=McP8fdg4P2zRHm57Gq7xKLukrvh7ITZNlj4lhv51IPE,4158
16
+ traffic_taffy/algorithms/statistical.py,sha256=7ddz3nPaTbhCNpfNcWx2sLmnv3ZYnmvEc72M9cAOU-0,4281
17
17
  traffic_taffy/dissector_engine/__init__.py,sha256=Hu-UQtz7yhivmQLUP5b8tFQLEhy2bfvrRV3Q4aZp6vg,2202
18
18
  traffic_taffy/dissector_engine/dnstap.py,sha256=rBzVlB0D3YVhHOsr17cbnCIZU13g20srgR4sE7ZfNUE,4810
19
19
  traffic_taffy/dissector_engine/dpkt.py,sha256=YgFceo_6cy1VN-ODIijSsOfH3w8OzHPbpUS463is3YI,10949
20
20
  traffic_taffy/dissector_engine/scapy.py,sha256=WrZUfV_viR2Tro0kM3QKUkufIcM3RyYaZ3ncA1yZsaU,4897
21
21
  traffic_taffy/hooks/__init__.py,sha256=Bvhl6RnyBqQkWuCU6TS0O_ZHe4qCQsC4HE8FELigWPw,661
22
- traffic_taffy/hooks/ip2asn.py,sha256=FCjTbHQZEuOvlw1fMyQgcJFiZrJfpNpUVZTdsxtUldw,2132
23
- traffic_taffy/hooks/labels.py,sha256=QayehHzvaqILf_bP3avwGXa-xL4IBEndo6ILbLtqcKU,1860
24
- traffic_taffy/hooks/psl.py,sha256=ym1vzBS9esgIRxZi5hWFcUl0vax5go_f9-2P_6kynts,2031
22
+ traffic_taffy/hooks/ip2asn.py,sha256=7UA52L6jej0RYBptzP9izO0yXMcqH7wcp2ocDRUN5dg,2216
23
+ traffic_taffy/hooks/labels.py,sha256=5jHXq3-kxDQj9PRYgak-gDzE8dvSUiCEq9mBs9nE014,1933
24
+ traffic_taffy/hooks/psl.py,sha256=A3maHS9FOholOEv1LuX0xSO3u34GyqeYl9_EtJG1pMY,2119
25
25
  traffic_taffy/iana/tables.msgpak,sha256=d-R5Xw9yG9t4RqGJRrpE6cjH4YfaxQBwQiBhNjKZbwI,172825
26
26
  traffic_taffy/output/__init__.py,sha256=qqlAUA99fxWlHEns-ji7A2RrcA8RA-AKXK7n2D737c8,3312
27
27
  traffic_taffy/output/console.py,sha256=QizlMIRbUKm7S57SojBiTAOB4KM9DCcj8EKiH1roO6U,3031
@@ -44,13 +44,13 @@ traffic_taffy/tests/test_value_printing.py,sha256=rhmCUqnh1Lk1TTZvZi7ksvUWm4XDB4
44
44
  traffic_taffy/tools/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
45
45
  traffic_taffy/tools/cache_info.py,sha256=ZanO6jDlTdfJ7w0N_7BkLyJj4NyZGShaH7SrUulbIoE,2085
46
46
  traffic_taffy/tools/compare.py,sha256=oT5fIqfPeY6nGI9vSVAoKDsAVzzqfXJDzyOw2BhPfSI,3509
47
- traffic_taffy/tools/config.py,sha256=XVsKA0E429K2HCyjuPuHwS1iPBkscQxa82Zu53Wmpqw,2458
47
+ traffic_taffy/tools/config.py,sha256=RwJYyfI1yiAKbMzU5mcPTguBiH-hGRy5vk_YvAAjPuM,2343
48
48
  traffic_taffy/tools/dissect.py,sha256=B-7e7aqEOWtJ-0P2Y-mzmrzoDqVrDCJ2JzGR45QtuuQ,3073
49
49
  traffic_taffy/tools/explore.py,sha256=gUcOfAgangJJI1si1gLPUoWRUKmWUAXSP0oTD2JJygw,24149
50
50
  traffic_taffy/tools/export.py,sha256=9zBBGhZK95b4ZiLJ8XK30GPsaBjgR84Sk1HoPIxRpTI,2844
51
51
  traffic_taffy/tools/graph.py,sha256=KiKDY9R8JLT5-JouANoi_1WGcdFMhXsLnYlhPsFRWpM,2316
52
- traffic_taffy-0.9.1.dist-info/METADATA,sha256=DnMSh8c3gJmQqp_kP6NZCiHfsC29fJ8dZf8pfLv4olU,2033
53
- traffic_taffy-0.9.1.dist-info/WHEEL,sha256=TJPnKdtrSue7xZ_AVGkp9YXcvDrobsjBds1du3Nx6dc,87
54
- traffic_taffy-0.9.1.dist-info/entry_points.txt,sha256=F0lqjvw94nQ3hY4eerN7faT9aKhhGUHbqBhuEr9q1r8,361
55
- traffic_taffy-0.9.1.dist-info/licenses/LICENSE.txt,sha256=hiV1DJgDQeSM1r7P-ez5oxily11S5nsCedU0jKzKKzo,11338
56
- traffic_taffy-0.9.1.dist-info/RECORD,,
52
+ traffic_taffy-0.9.3.dist-info/METADATA,sha256=G_or2oWTR_IcAq8WvyhloYLjDc9i8ySjOQ9U2Y9LKvc,2241
53
+ traffic_taffy-0.9.3.dist-info/WHEEL,sha256=TJPnKdtrSue7xZ_AVGkp9YXcvDrobsjBds1du3Nx6dc,87
54
+ traffic_taffy-0.9.3.dist-info/entry_points.txt,sha256=F0lqjvw94nQ3hY4eerN7faT9aKhhGUHbqBhuEr9q1r8,361
55
+ traffic_taffy-0.9.3.dist-info/licenses/LICENSE.txt,sha256=hiV1DJgDQeSM1r7P-ez5oxily11S5nsCedU0jKzKKzo,11338
56
+ traffic_taffy-0.9.3.dist-info/RECORD,,