diff options
| author | J08nY | 2022-07-11 19:19:41 +0200 |
|---|---|---|
| committer | J08nY | 2022-07-11 19:19:41 +0200 |
| commit | 68b5ed3c888d3a21d64c8a1aeaa8f4e56bf051f6 (patch) | |
| tree | a2da01ae4e2ac8a334afd933b33896bc8c180b21 | |
| parent | 878ba1057161ef9b843533a473bd3736c7481564 (diff) | |
| download | sec-certs-68b5ed3c888d3a21d64c8a1aeaa8f4e56bf051f6.tar.gz sec-certs-68b5ed3c888d3a21d64c8a1aeaa8f4e56bf051f6.tar.zst sec-certs-68b5ed3c888d3a21d64c8a1aeaa8f4e56bf051f6.zip | |
FIPS: Fix #211.
The connections need to be sourced from the References object.
| -rw-r--r-- | sec_certs/dataset/fips.py | 15 | ||||
| -rw-r--r-- | sec_certs/sample/fips.py | 14 |
2 files changed, 19 insertions, 10 deletions
diff --git a/sec_certs/dataset/fips.py b/sec_certs/dataset/fips.py index 40aa977c..f829da9d 100644 --- a/sec_certs/dataset/fips.py +++ b/sec_certs/dataset/fips.py @@ -296,9 +296,9 @@ class FIPSDataset(Dataset[FIPSCertificate], ComplexSerializableType): certificate.pdf_data.algorithms += algorithms return not_decoded - def _remove_algorithms_from_extracted_data(self) -> None: + def _compute_heuristics_keywords(self) -> None: for cert in self.certs.values(): - cert.remove_algorithms() + cert.compute_heuristics_keywords() def _unify_algorithms(self) -> None: for certificate in self.certs.values(): @@ -444,7 +444,7 @@ class FIPSDataset(Dataset[FIPSCertificate], ComplexSerializableType): """ logger.info("Entering 'analysis' and building connections between certificates.") self._unify_algorithms() - self._remove_algorithms_from_extracted_data() + self._compute_heuristics_keywords() self._validate_results() if perform_cpe_heuristics: _, _, cve_dset = self.compute_cpe_heuristics() @@ -478,13 +478,13 @@ class FIPSDataset(Dataset[FIPSCertificate], ComplexSerializableType): ) def _get_processed_list(self, connection_list: str, dgst: str) -> List[str]: - attr = {"pdf": "pdf_data", "web": "web_data", "heuristics": "heuristics"}[connection_list] - return getattr(self.certs[dgst], attr).connections + attr = {"st": "st_references", "web": "web_references"}[connection_list] + return getattr(self.certs[dgst].heuristics, attr).directly_referencing def _create_dot_graph( self, output_file_name: str, - connection_list: str = "heuristics", + connection_list: str = "st", highlighted_vendor: str = "Red Hat®, Inc.", show: bool = True, ) -> None: @@ -495,8 +495,7 @@ class FIPSDataset(Dataset[FIPSCertificate], ComplexSerializableType): :param show: display graph right on screen :param highlighted_vendor: vendor whose certificates should be highlighted in red color :param output_file_name: prefix to "connections", "connections.pdf", "single" and "single.pdf" - :param connection_list: 'heuristics', 'web', or 'pdf' - plots a graph from this source - default - heuristics + :param connection_list: 'st' or 'web' - plots a graph from this source """ dot = Digraph(comment="Certificate ecosystem") single_dot = Digraph(comment="Modules with no dependencies") diff --git a/sec_certs/sample/fips.py b/sec_certs/sample/fips.py index 6d4ddb02..33c25742 100644 --- a/sec_certs/sample/fips.py +++ b/sec_certs/sample/fips.py @@ -660,9 +660,11 @@ class FIPSCertificate(Certificate["FIPSCertificate", "FIPSCertificate.Heuristics if int("".join(filter(str.isdigit, cert_no))) == int("".join(filter(str.isdigit, cert))): to_pop.add(cert) - def remove_algorithms(self) -> None: + def compute_heuristics_keywords(self) -> None: """ - Removes algorithms from the certificate. + Compute the heuristics keywords. + + - Removes algorithm mentions from the cert_id rule matches. """ self.state.file_status = True if not self.pdf_data.keywords: @@ -670,6 +672,14 @@ class FIPSCertificate(Certificate["FIPSCertificate", "FIPSCertificate.Heuristics self.heuristics.keywords = copy.deepcopy(self.pdf_data.keywords) + # XXX: Do not do this, the heuristics keywords need to be from the Security target only, + # because the "st_references" are computed based on these, and the "web_references" + # are computed based on "web_data.mentioned_certs". + # Add the mentioned certs + # if self.web_data.mentioned_certs: + # for cert_id, value in self.web_data.mentioned_certs.items(): + # self.heuristics.keywords["fips_cert_id"]["Cert"]["#" + str(cert_id)] = value["count"] + alg_set = self._create_alg_set() for cert_rule in fips_rules["fips_cert_id"]["Cert"]: to_pop = set() |
