traffic-taffy 0.9.7__py3-none-any.whl → 0.9.9__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.7"
1
+ __VERSION__ = "0.9.9"
@@ -1,14 +1,20 @@
1
1
  """Traffic-Taffy plugin to look up addresses in the BLAG blocklist."""
2
+ from pathlib import Path
2
3
  from blagbl import BlagBL
4
+ import blagbl
3
5
  import ipaddress
6
+ from logging import error
4
7
 
5
8
  from traffic_taffy.hooks import register_hook
6
9
  from traffic_taffy.dissector import POST_DISSECT_HOOK, INIT_HOOK
7
10
  from traffic_taffy.dissection import Dissection
11
+ from traffic_taffy.taffy_config import taffy_default, TaffyConfig
8
12
 
9
13
  blag = None
10
14
  blag_ips = None
11
15
 
16
+ taffy_default("modules.blag.database", str(blagbl.DEFAULT_STORE.joinpath("blag.zip")))
17
+
12
18
 
13
19
  @register_hook(INIT_HOOK)
14
20
  def init_blag(**kwargs):
@@ -17,7 +23,14 @@ def init_blag(**kwargs):
17
23
  global blag_ips
18
24
 
19
25
  if blag is None:
20
- blag = BlagBL()
26
+ config = TaffyConfig()
27
+ blag_db_path = config.get_dotnest("modules.blag.database")
28
+
29
+ if blag_db_path and not Path(blag_db_path).exists():
30
+ error(f"The ip2asn plugin requires a blag.zip file in {blag_db_path}")
31
+ error("Please run blagbl --fetch to download it")
32
+
33
+ blag = BlagBL(database=blag_db_path)
21
34
  blag.parse_blag_contents()
22
35
  blag_ips = blag.ips
23
36
 
@@ -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.DEFAULT_IP2ASN_FILE)
12
+ taffy_default("modules.ip2asn.database", str(ip2asn.DEFAULT_IP2ASN_FILE))
13
13
 
14
14
 
15
15
  @register_hook(INIT_HOOK)
@@ -21,8 +21,8 @@ def init_ip2asn(**kwargs):
21
21
  db_path = config.get_dotnest("modules.ip2asn.database")
22
22
 
23
23
  if db_path and not Path(db_path).exists():
24
- error("The ip2asn plugin requires a ip2asn-combined.tsv in this directory")
25
- error("Please download it from https://iptoasn.com/")
24
+ error(f"The ip2asn plugin requires a ip2asn-combined.tsv file in {db_path}")
25
+ error("Please run ip2asn --fetch to download it")
26
26
 
27
27
  info(f"loading {db_path}")
28
28
  i2a = ip2asn.IP2ASN(db_path)
@@ -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
@@ -32,6 +32,11 @@ try:
32
32
  except ModuleNotFoundError:
33
33
  logging.debug("psl module not loadable")
34
34
 
35
+ try:
36
+ from traffic_taffy.hooks.blag import ip_blagbl_lookup as ip_blagbl_lookup
37
+ except ModuleNotFoundError:
38
+ logging.debug("blag module not loadable")
39
+
35
40
 
36
41
  def taffy_config_parse_args() -> Namespace:
37
42
  """Parse the command line arguments."""
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: traffic-taffy
3
- Version: 0.9.7
3
+ Version: 0.9.9
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>
@@ -1,4 +1,4 @@
1
- traffic_taffy/__init__.py,sha256=KrTiNpk5yqhV4Br8BI-UzCx2ZR98WVKivhHFc_1856k,22
1
+ traffic_taffy/__init__.py,sha256=YzFL7CfEcDRyEbnlof00gym6eTq-mBSIojBAQGrorTU,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
@@ -7,7 +7,6 @@ traffic_taffy/dissectmany.py,sha256=SWFXFyERNCi0j7hiMDEeJJdPYDpa0SOlSj1V8AqpXUA,
7
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
- traffic_taffy/report.py,sha256=Yzb27hUWcWL-RxWpSQmRyM8NyWxQGT0l0jUCGHoYDSY,224
11
10
  traffic_taffy/taffy_config.py,sha256=AmdQbWAhoiV7aTNSpV1exJfd5eA0a3sYTIjikHkMPwY,1124
12
11
  traffic_taffy/algorithms/__init__.py,sha256=A7xI2ctotBT7WgG-6ItilXE_FIWF9QWc6UjdfGyThKw,737
13
12
  traffic_taffy/algorithms/comparecorrelation.py,sha256=gakZJotZNOVj96y4_-vtt_ka8pZLBVERf44Yixtq_yE,5875
@@ -20,23 +19,22 @@ traffic_taffy/dissector_engine/dnstap.py,sha256=rBzVlB0D3YVhHOsr17cbnCIZU13g20sr
20
19
  traffic_taffy/dissector_engine/dpkt.py,sha256=q7cJz6WWpe9xUcEbAY_yn_cma_4loXuS3QKIVln6FHQ,12788
21
20
  traffic_taffy/dissector_engine/scapy.py,sha256=S3yrUmSeDjt3oE1I07L3iLFLF8Df8XAZg535FY_eu90,5004
22
21
  traffic_taffy/hooks/__init__.py,sha256=Bvhl6RnyBqQkWuCU6TS0O_ZHe4qCQsC4HE8FELigWPw,661
23
- traffic_taffy/hooks/blag.py,sha256=KWFhDYbH8sRcUsujCSdlycE0pYkX5ymyRRbHxi20z3U,1626
24
- traffic_taffy/hooks/ip2asn.py,sha256=G7zo2lFRLK-fbbzGMMcsaxIIh9ME6BoM0E6cJDaeE18,2233
22
+ traffic_taffy/hooks/blag.py,sha256=NgXcJ0uRFMUk-YkBeAdixNKFuzZ5iZJhh9rxuLb5zrI,2172
23
+ traffic_taffy/hooks/ip2asn.py,sha256=wTOevUytyogehV20JU-UdJ0vRhzgm7te1KVIuuKCvH0,2235
25
24
  traffic_taffy/hooks/labels.py,sha256=5jHXq3-kxDQj9PRYgak-gDzE8dvSUiCEq9mBs9nE014,1933
26
25
  traffic_taffy/hooks/psl.py,sha256=A3maHS9FOholOEv1LuX0xSO3u34GyqeYl9_EtJG1pMY,2119
27
26
  traffic_taffy/iana/tables.msgpak,sha256=d-R5Xw9yG9t4RqGJRrpE6cjH4YfaxQBwQiBhNjKZbwI,172825
28
27
  traffic_taffy/output/__init__.py,sha256=qqlAUA99fxWlHEns-ji7A2RrcA8RA-AKXK7n2D737c8,3312
29
- traffic_taffy/output/console.py,sha256=QizlMIRbUKm7S57SojBiTAOB4KM9DCcj8EKiH1roO6U,3031
28
+ traffic_taffy/output/console.py,sha256=x68iZYCq3jCn86AsnP339CnDJVLVojfmOOwSbJtaQjk,3195
30
29
  traffic_taffy/output/fsdb.py,sha256=0z2zDydfnqOVM8Mj6pTJf4n4pGPupWykuYPgdgjJRN8,1859
31
30
  traffic_taffy/output/memory.py,sha256=86tgJ-jMt3UVX31eP6U02YbbYRoqbYhhR4kXJQmYzO4,1870
32
31
  traffic_taffy/reports/__init__.py,sha256=lMDS7q35aIdDrJ7G8ot4Q_6t9nYllr0C9510FL43rZY,113
33
- traffic_taffy/reports/compareslicesreport.py,sha256=Clrif58TPBTwP4BNxh9PcHkyASbUUscrOWtSgLrItN4,2754
34
- traffic_taffy/reports/correlationchangereport.py,sha256=W8tKWMk5Ss45Ho3wh_mAcK2Jj2fpL7vnNyun2C_lRgw,1575
35
- 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
36
35
  traffic_taffy/tests/test_compare_results.py,sha256=iLcS9wvEqxgKszIspLtD2Zw8Qk5JxOCurQwWYzhtOkM,2318
37
36
  traffic_taffy/tests/test_config.py,sha256=UCqSJXVwpFFchcIbyFzLqjVF-wgEV755KlQ7thommro,4284
38
37
  traffic_taffy/tests/test_dict_merge.py,sha256=t3rZSQQ0AlBxRKfLborx9SxYN53cCAQQzZ2w-__WT2Y,1429
39
- traffic_taffy/tests/test_dpkt_engine.py,sha256=512Wfq7D1qVkfhGwf1u2QSgZooWqZQWV9L4OhpAr4AE,489
40
38
  traffic_taffy/tests/test_global_config.py,sha256=kjr1wy1cXWagVLb0OnQYH0vz2htxLs944Xo42lNsir4,597
41
39
  traffic_taffy/tests/test_hooks.py,sha256=amjEbtMwOZZCg_RCJ0wQR7aOqNfwz3IG3WY-9CwjSF4,1260
42
40
  traffic_taffy/tests/test_normalize.py,sha256=sKHyiV8YXcKKcWqsbZP94nu_g5oEMJzzj6umeHxwa64,2638
@@ -47,13 +45,13 @@ traffic_taffy/tests/test_value_printing.py,sha256=rhmCUqnh1Lk1TTZvZi7ksvUWm4XDB4
47
45
  traffic_taffy/tools/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
48
46
  traffic_taffy/tools/cache_info.py,sha256=ZanO6jDlTdfJ7w0N_7BkLyJj4NyZGShaH7SrUulbIoE,2085
49
47
  traffic_taffy/tools/compare.py,sha256=oT5fIqfPeY6nGI9vSVAoKDsAVzzqfXJDzyOw2BhPfSI,3509
50
- traffic_taffy/tools/config.py,sha256=RwJYyfI1yiAKbMzU5mcPTguBiH-hGRy5vk_YvAAjPuM,2343
48
+ traffic_taffy/tools/config.py,sha256=lW9KKlWedGsVpq6c2KyC4TzbowYmGHWyEY3WqfGnhVI,2501
51
49
  traffic_taffy/tools/dissect.py,sha256=kGG0K2d9-OwrAhEU97id2m29PvhYaXZYIw1nLi1aVsE,3346
52
50
  traffic_taffy/tools/explore.py,sha256=gUcOfAgangJJI1si1gLPUoWRUKmWUAXSP0oTD2JJygw,24149
53
51
  traffic_taffy/tools/export.py,sha256=9zBBGhZK95b4ZiLJ8XK30GPsaBjgR84Sk1HoPIxRpTI,2844
54
52
  traffic_taffy/tools/graph.py,sha256=KiKDY9R8JLT5-JouANoi_1WGcdFMhXsLnYlhPsFRWpM,2316
55
- traffic_taffy-0.9.7.dist-info/METADATA,sha256=JBugfulFVW9XOxNcx9vjDPyVIkWN4F8AAvT5qTewBBk,2311
56
- traffic_taffy-0.9.7.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
57
- traffic_taffy-0.9.7.dist-info/entry_points.txt,sha256=F0lqjvw94nQ3hY4eerN7faT9aKhhGUHbqBhuEr9q1r8,361
58
- traffic_taffy-0.9.7.dist-info/licenses/LICENSE.txt,sha256=eFp2vwcZFJW55SUQRoEfXio3K9XdwvsaI_WHntR7I2M,11338
59
- traffic_taffy-0.9.7.dist-info/RECORD,,
53
+ traffic_taffy-0.9.9.dist-info/METADATA,sha256=c287QYMbyfRv0cjIKLnaoyTowxqr6mVa_sd4q9MUW5w,2311
54
+ traffic_taffy-0.9.9.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
55
+ traffic_taffy-0.9.9.dist-info/entry_points.txt,sha256=F0lqjvw94nQ3hY4eerN7faT9aKhhGUHbqBhuEr9q1r8,361
56
+ traffic_taffy-0.9.9.dist-info/licenses/LICENSE.txt,sha256=eFp2vwcZFJW55SUQRoEfXio3K9XdwvsaI_WHntR7I2M,11338
57
+ traffic_taffy-0.9.9.dist-info/RECORD,,
traffic_taffy/report.py DELETED
@@ -1,12 +0,0 @@
1
- from dataclasses import dataclass
2
-
3
-
4
- @dataclass
5
- class Report:
6
- delta_percentage: float
7
- delta_absolute: int
8
- total: int
9
- left_count: int
10
- right_count: int
11
- left_percentage: float
12
- right_percentage: float
@@ -1,15 +0,0 @@
1
- import os
2
- from traffic_taffy.dissection import PCAPDissectorLevel
3
- from traffic_taffy.dissector_engine.dpkt import DissectionEngineDpkt
4
-
5
- def test_dpkt_engine():
6
- test_pcap = "dns.pcap"
7
- test_pcap = "port53-2023-30-31_20.pcap"
8
- test_pcap = "airplane-wireless.pcap"
9
- if not os.path.exists(test_pcap):
10
- return
11
-
12
- engine = DissectionEngineDpkt(test_pcap,
13
- dissector_level = PCAPDissectorLevel.COMMON_LAYERS)
14
- dissection = engine.load()
15
-