From ca9a39f0ed801730d0f864e1c91b61f857c956a2 Mon Sep 17 00:00:00 2001 From: Poshan Peeroo Date: Mon, 15 Jul 2024 14:56:46 +0400 Subject: [PATCH] result --- results/formatted_results.csv | 48 +++++++++++++++++++++++++++++++++++ utils/data.py | 43 +++++++++++++++++++++++++++++++ 2 files changed, 91 insertions(+) create mode 100644 results/formatted_results.csv create mode 100644 utils/data.py diff --git a/results/formatted_results.csv b/results/formatted_results.csv new file mode 100644 index 0000000..ab3fa00 --- /dev/null +++ b/results/formatted_results.csv @@ -0,0 +1,48 @@ +Country, 1111, 0000, 0001 TO 1110, IPv4-Good-%, IPv4-Bad-% +Ethiopia, 1775, 34, 40, 96.0, 2.16 +Angola, 494, 2, 10, 97.63, 1.98 +Gambia, 143, 2, 3, 96.62, 2.03 +Nigeria, 496, 23, 8, 94.12, 1.52 +Madagascar, 638, 9, 7, 97.55, 1.07 +Sierra Leone, 195, 4, 4, 96.06, 1.97 +Benin, 279, 10, 9, 93.62, 3.02 +Rwanda, 1492, 21, 40, 96.07, 2.58 +Burundi, 181, 9, 9, 90.95, 4.52 +Togo, 61, 28, 0, 68.54, 0.0 +Kenya, 4498, 376, 148, 89.57, 2.95 +Chad, 106, 7, 1, 92.98, 0.88 +South Sudan, 241, 27, 1, 89.59, 0.37 +Cameroon, 629, 8, 12, 96.92, 1.85 +Eritrea, 0, 0, 1, 0.0, 100.0 +Somalia, 376, 15, 24, 90.6, 5.78 +Djibouti, 45, 0, 2, 95.74, 4.26 +Botswana, 967, 10, 10, 97.97, 1.01 +Zimbabwe, 1193, 22, 33, 95.59, 2.64 +Namibia, 2054, 15, 58, 96.57, 2.73 +Malawi, 714, 8, 3, 98.48, 0.41 +Eswatini, 1262, 3, 25, 97.83, 1.94 +Congo, 653, 50, 11, 91.46, 1.54 +Mauritius, 3439, 213, 95, 91.78, 2.54 +Uganda, 2131, 44, 66, 95.09, 2.95 +Burkina Faso, 863, 4, 10, 98.4, 1.14 +Côte d'Ivoire, 857, 9, 19, 96.84, 2.15 +Comoros, 52, 1, 0, 98.11, 0.0 +Réunion, 747, 6, 7, 98.29, 0.92 +Niger, 174, 7, 8, 92.06, 4.23 +Mali, 346, 231, 12, 58.74, 2.04 +Libya, 2242, 26, 22, 97.9, 0.96 +Guinea, 158, 29, 0, 84.49, 0.0 +Indonesia, 48, 27, 0, 64.0, 0.0 +Central African Republic, 68, 0, 0, 100.0, 0.0 +Cabo Verde, 545, 10, 25, 93.97, 4.31 +Liberia, 190, 42, 1, 81.55, 0.43 +Ghana, 370, 2, 6, 97.88, 1.59 +Sao Tome and Principe, 61, 1, 1, 96.83, 1.59 +Gabon, 69, 5, 2, 90.79, 2.63 +Seychelles, 8959, 105, 67, 98.12, 0.73 +Equatorial Guinea, 138, 38, 0, 78.41, 0.0 +Zambia, 1277, 17, 13, 97.7, 0.99 +Lesotho, 28, 0, 2, 93.33, 6.67 +Senegal, 374, 6, 3, 97.65, 0.78 +Algeria, 208, 1, 7, 96.3, 3.24 +Mozambique, 209, 9, 0, 95.87, 0.0 diff --git a/utils/data.py b/utils/data.py new file mode 100644 index 0000000..99a67e1 --- /dev/null +++ b/utils/data.py @@ -0,0 +1,43 @@ +import os +import json + + +def format_results(directory): + csv = 'Country, 1111, 0000, 0001 TO 1110, IPv4-Good-%, IPv4-Bad-%\n' + for filename in os.listdir(directory): + servers = 0 + tlsv1_2 = 0 + misconfigured_tlsv1_2 = 0 + tlsv1_3 = 0 + misconfigured_tlsv1_3 = 0 + if filename.endswith('.json'): + continue + if os.path.exists(directory + filename + '/tldr_process_v1.2_results.json') and os.path.exists(directory + filename + '/tldr_process_v1.3_results.json'): + with open(directory + filename + '/tldr_process_v1.2_results.json') as f: + data = json.load(f) + tlsv1_2 = data['total_ip_checked'] + properly_configure_tlsv1_2 = len(data['encoded_ip_addresses']['1111']) + not_running_tlsv1_2 = len(data['encoded_ip_addresses']['0000']) + + with open(directory + filename + '/tldr_process_v1.3_results.json') as f: + data = json.load(f) + tlsv1_3 = data['total_ip_checked'] + properly_configure_tlsv1_3 = len(data['encoded_ip_addresses']['1111']) + not_running_tlsv1_3 = len(data['encoded_ip_addresses']['0000']) + + servers = tlsv1_2 + tlsv1_3 + + misconfigured_tlsv1_2 = tlsv1_2 - properly_configure_tlsv1_2 - not_running_tlsv1_2 + misconfigured_tlsv1_3 = tlsv1_3 - properly_configure_tlsv1_3 - not_running_tlsv1_3 + properly_configured_servers = properly_configure_tlsv1_2 + properly_configure_tlsv1_3 + not_running = not_running_tlsv1_2 + not_running_tlsv1_3 + misconfigured_servers = misconfigured_tlsv1_2 + misconfigured_tlsv1_3 + csv += f'{filename}, {properly_configured_servers}, {not_running}, {misconfigured_servers}, {round((properly_configured_servers)/servers*100, 2)}, {round((misconfigured_servers)/servers*100, 2)}\n' + + else: + print(filename) + + with open(directory + 'formatted_results.csv', 'w') as f: + f.write(csv) + +format_results('results/') \ No newline at end of file