From 99d9f771acef3e2a3410a5c02e02f5d79d966ec0 Mon Sep 17 00:00:00 2001 From: Spyros Date: Sun, 11 Feb 2024 14:26:40 +0000 Subject: [PATCH] cloud native security controls parser +tests --- .../parsers/cloud_native_security_controls.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/application/utils/external_project_parsers/parsers/cloud_native_security_controls.py b/application/utils/external_project_parsers/parsers/cloud_native_security_controls.py index 81d834c31..23be54375 100644 --- a/application/utils/external_project_parsers/parsers/cloud_native_security_controls.py +++ b/application/utils/external_project_parsers/parsers/cloud_native_security_controls.py @@ -15,7 +15,7 @@ class CloudNativeSecurityControls(ParserInterface): name = "Cloud Native Security Controls" - def parse(self, cache: db.Node_collection, prompt: prompt_client.PromptHandler): + def parse(self, cache: db.Node_collection, ph: prompt_client.PromptHandler): resp = requests.get( "https://raw.githubusercontent.com/cloud-native-security-controls/controls-catalog/main/controls/controls_catalog.csv" ) @@ -48,15 +48,15 @@ def parse(self, cache: db.Node_collection, prompt: prompt_client.PromptHandler): f"Node {cnsc.todict()} already exists and has embeddings, skipping" ) continue - cnsc_embeddings = prompt.get_text_embeddings(cnsc.subsection) + cnsc_embeddings = ph.get_text_embeddings(cnsc.subsection) cnsc.embeddings = cnsc_embeddings cnsc.embeddings_text = cnsc.subsection - cre_id = prompt.get_id_of_most_similar_cre(cnsc_embeddings) + cre_id = ph.get_id_of_most_similar_cre(cnsc_embeddings) if not cre_id: logger.info( f"could not find an appropriate CRE for Clound Native Security Control {cnsc.section}, findings similarities with standards instead" ) - standard_id = prompt.get_id_of_most_similar_node(cnsc_embeddings) + standard_id = ph.get_id_of_most_similar_node(cnsc_embeddings) dbstandard = cache.get_node_by_db_id(standard_id) logger.info( f"found an appropriate standard for Cloud Native Security Control {cnsc.section}:{cnsc.subsection}, it is: {dbstandard.name}:{dbstandard.section}" @@ -83,4 +83,4 @@ def parse(self, cache: db.Node_collection, prompt: prompt_client.PromptHandler): f"stored {cnsc.__repr__()} but could not link it to any CRE reliably" ) standard_entries.append(cnsc) - return cnsc + return standard_entries