aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorPetr Svenda2021-02-18 09:04:10 +0100
committerPetr Svenda2021-02-18 09:04:10 +0100
commit14acdb866a65040e5dc6b8ffae1cad0ca8316368 (patch)
treedbddce9abc9dfe50dbae3ca962bf23d6c24364e1
parent55fa1962183b53e6403593b7a263121808493b33 (diff)
downloadsec-certs-14acdb866a65040e5dc6b8ffae1cad0ca8316368.tar.gz
sec-certs-14acdb866a65040e5dc6b8ffae1cad0ca8316368.tar.zst
sec-certs-14acdb866a65040e5dc6b8ffae1cad0ca8316368.zip
minor cleaning
-rw-r--r--sec_certs/analyze_certificates.py33
-rw-r--r--sec_certs/constants.py3
2 files changed, 31 insertions, 5 deletions
diff --git a/sec_certs/analyze_certificates.py b/sec_certs/analyze_certificates.py
index b9c8444a..8c82ece8 100644
--- a/sec_certs/analyze_certificates.py
+++ b/sec_certs/analyze_certificates.py
@@ -72,6 +72,31 @@ def plot_bar_graph(data, x_data_labels, y_label, title, file_name):
plt.close()
+def plot_bar_multi_graph(data, x_data_labels, y_label, title, file_name):
+ max_len = 0
+ for item in data:
+ if max_len < len(item):
+ max_len = len(item)
+
+ fig_width = round(max_len / 2)
+ if fig_width < 10:
+ fig_width = 10
+ figure(num=None, figsize=(fig_width, 8), dpi=200, facecolor='w', edgecolor='k')
+ y_pos = np.arange(len(x_data_labels))
+ BAR_WIDTH = 0.4
+ for i in range(0, len(data)):
+ plt.bar(y_pos + i * BAR_WIDTH, data[i], alpha=0.5, width=BAR_WIDTH)
+ plt.xticks(y_pos, x_data_labels)
+ plt.xticks(rotation=45)
+ plt.ylabel(y_label)
+ plt.title(title)
+ x1, x2, y1, y2 = plt.axis()
+ plt.axis((x1, x2, y1 - 1, y2))
+ plt.savefig(file_name + '.png', bbox_inches='tight')
+ plt.savefig(file_name + '.pdf', bbox_inches='tight')
+ plt.close()
+
+
def plot_heatmap_graph(data_matrix, x_data_ticks, y_data_ticks, x_label, y_label, title, file_name):
fig_size = round(len(x_data_ticks) / 2)
if fig_size == 0:
@@ -703,7 +728,7 @@ def analyze_cert_years_frequency(all_cert_items, filter_label, force_plot_end_ye
plot_schemes_multi_graph(years, plot_scheme_date, ['DE', 'JP', 'FR', 'US', 'CA'], 'Year of issuance', 'Number of certificates issued', fig_label('CC certificates issuance frequency per scheme and year', filter_label), 'num_certs_in_years')
plot_schemes_multi_graph(years, plot_level_date, ['EAL4+', 'EAL5+','EAL2+', 'Protection Profile'], 'Year of issuance', 'Number of certificates issued', fig_label('Certificates issuance frequency per level and year', filter_label), 'num_certs_level_in_years')
plot_schemes_multi_graph(years, plot_category_date, [], 'Year of issuance', 'Number of certificates issued', fig_label('Category of certificates issued in given year', filter_label), 'num_certs_category_in_years')
- plot_schemes_multi_graph(years, plot_pp_date, [], 'Year of issuance', 'Number of certificates issued', fig_label('Certificates with/without conforming to Protection Profile', filter_label), 'num_certs_pp_in_years')
+ plot_schemes_multi_graph(years, plot_pp_date, [], 'Year of issuance', 'Number of certificates issued', fig_label('Certificates conforming to Protection Profile(s)', filter_label), 'num_certs_pp_in_years')
plot_schemes_multi_graph(years, plot_labs_date, [], 'Year of issuance', 'Number of certificates issued', fig_label('Number of certificates certified by laboratory in given year', filter_label), 'num_certs_by_lab_in_years')
plot_schemes_multi_graph(years, plot_top_manufacturers_date, sc_manufacturers, 'Year of issuance', 'Number of certificates issued', fig_label('Top 20 manufacturers of certified items per year', filter_label), 'manufacturer_in_years')
@@ -744,8 +769,8 @@ def analyze_eal_frequency(all_cert_items, filter_label):
print(' {:5}: {}x'.format(level, scheme_level[cc_scheme][level]))
print('\n')
- eal_headers = ['EAL0+', 'EAL1', 'EAL1+','EAL2', 'EAL2+','EAL3', 'EAL3+','EAL4', 'EAL4+','EAL5',
- 'EAL5+','EAL6', 'EAL6+','EAL7', 'EAL7+', 'None']
+ eal_headers = ['EAL0+', 'EAL1', 'EAL1+','EAL2', 'EAL2+', 'EAL3', 'EAL3+', 'EAL4', 'EAL4+', 'EAL5',
+ 'EAL5+', 'EAL6', 'EAL6+', 'EAL7', 'EAL7+', 'None']
total_eals = {}
for level in eal_headers:
@@ -923,7 +948,6 @@ def generate_dot_graphs(all_items_found, filter_label, highlight_certs_id=None):
def do_all_analysis(all_cert_items, filter_label, highlight_certs_id = None):
- generate_dot_graphs(all_cert_items, filter_label, highlight_certs_id)
analyze_cert_years_frequency(all_cert_items, filter_label)
analyze_references_graph(['rules_cert_id'], all_cert_items, filter_label)
analyze_eal_frequency(all_cert_items, filter_label)
@@ -931,6 +955,7 @@ def do_all_analysis(all_cert_items, filter_label, highlight_certs_id = None):
analyze_security_functional_component_frequency(all_cert_items, filter_label)
analyze_pdfmeta(all_cert_items, filter_label)
plot_certid_to_item_graph(['keywords_scan', 'rules_protection_profiles'], all_cert_items, filter_label, 'certid_pp_graph.dot', False)
+ generate_dot_graphs(all_cert_items, filter_label, highlight_certs_id)
def do_analysis_everything(all_cert_items, current_dir: Path):
diff --git a/sec_certs/constants.py b/sec_certs/constants.py
index 1923937c..2600b152 100644
--- a/sec_certs/constants.py
+++ b/sec_certs/constants.py
@@ -42,4 +42,5 @@ TAG_PP_EDITOR = 'pp_editor'
TAG_PP_REVIEWER = 'pp_reviewer'
TAG_KEYWORDS = 'keywords'
FIPS_NOT_AVAILABLE_CERT_SIZE = 10000
-FIPS_ALG_URL = 'https://csrc.nist.gov/projects/cryptographic-algorithm-validation-program/validation-search?searchMode=validation&page=' \ No newline at end of file
+FIPS_ALG_URL = 'https://csrc.nist.gov/projects/cryptographic-algorithm-validation-program/validation-search?searchMode=validation&page='
+