diff options
| author | Adam Janovsky | 2021-04-19 10:48:24 +0200 |
|---|---|---|
| committer | Adam Janovsky | 2021-04-19 10:48:24 +0200 |
| commit | 1c1cd7cf6bc6dfb2e3b99cb0ce29fe1b723ba1ce (patch) | |
| tree | e6b75a943084be02c2fea9013a231af9fb4642b2 | |
| parent | 2282511d6c3dfe6b50ff17174e401f2441adbdfd (diff) | |
| download | sec-certs-1c1cd7cf6bc6dfb2e3b99cb0ce29fe1b723ba1ce.tar.gz sec-certs-1c1cd7cf6bc6dfb2e3b99cb0ce29fe1b723ba1ce.tar.zst sec-certs-1c1cd7cf6bc6dfb2e3b99cb0ce29fe1b723ba1ce.zip | |
rename get -> compute
| -rw-r--r-- | sec_certs/certificate.py | 11 | ||||
| -rw-r--r-- | sec_certs/dataset.py | 6 | ||||
| -rw-r--r-- | test/test_cve_cpe_matching.py | 2 |
3 files changed, 9 insertions, 10 deletions
diff --git a/sec_certs/certificate.py b/sec_certs/certificate.py index 5f5526e5..b873ac37 100644 --- a/sec_certs/certificate.py +++ b/sec_certs/certificate.py @@ -1235,7 +1235,7 @@ class CommonCriteriaCert(Certificate, ComplexSerializableType): cert.state.errors.append(response) return cert - def get_heuristics_version(self): + def compute_heuristics_version(self): """ Will extract possible versions from the name """ @@ -1257,22 +1257,21 @@ class CommonCriteriaCert(Certificate, ComplexSerializableType): else: self.heuristics.extracted_versions = ['-'] - # TODO: Move this to heuristics dataclass? - def get_heuristics_cpe_vendors(self, cpe_dataset: CPEDataset): + def compute_heuristics_cpe_vendors(self, cpe_dataset: CPEDataset): """ With the help of the CPE dataset, will find CPE vendors that could match the given certificate vendor """ self.heuristics.cpe_candidate_vendors = cpe_dataset.get_candidate_list_of_vendors(self.manufacturer) - def get_heuristics_cpe_match(self, cpe_dataset: CPEDataset): - self.get_heuristics_cpe_vendors(cpe_dataset) + def compute_heuristics_cpe_match(self, cpe_dataset: CPEDataset): + self.compute_heuristics_cpe_vendors(cpe_dataset) self.heuristics.cpe_matches = cpe_dataset.get_cpe_matches(self.name, self.heuristics.cpe_candidate_vendors, self.heuristics.extracted_versions, n_max_matches=constants.CPE_MAX_MATCHES, threshold=constants.CPE_MATCHING_THRESHOLD) - def get_heuristics_related_cves(self, cve_dataset: CVEDataset): + def compute_heuristics_related_cves(self, cve_dataset: CVEDataset): if self.heuristics.verified_cpe_matches: related_cves = [cve_dataset.get_cves_for_cpe(x.uri) for x in self.heuristics.verified_cpe_matches] related_cves = list(filter(lambda x: x is not None, related_cves)) diff --git a/sec_certs/dataset.py b/sec_certs/dataset.py index 3d396a0a..37ddbc2a 100644 --- a/sec_certs/dataset.py +++ b/sec_certs/dataset.py @@ -711,12 +711,12 @@ class CCDataset(Dataset, ComplexSerializableType): def compute_candidate_versions(): logger.info('Computing heuristics: possible product versions in certificate name') for cert in self: - cert.get_heuristics_version() + cert.compute_heuristics_version() def compute_cpe_matches(cpe_dataset: CPEDataset): logger.info('Computing heuristics: Finding CPE matches for certificates') for cert in self: - cert.get_heuristics_cpe_match(cpe_dataset) + cert.compute_heuristics_cpe_match(cpe_dataset) compute_candidate_versions() cpe_dset = self.prepare_cpe_dataset(download_fresh_cpes) @@ -772,7 +772,7 @@ class CCDataset(Dataset, ComplexSerializableType): logger.error('No certificates with verified CPE match detected. You must run dset.manually_verify_cpe_matches() first. Returning.') return for cert in verified_cpe_rich_certs: - cert.get_heuristics_related_cves(cve_dset) + cert.compute_heuristics_related_cves(cve_dset) class FIPSDataset(Dataset, ComplexSerializableType): diff --git a/test/test_cve_cpe_matching.py b/test/test_cve_cpe_matching.py index c9dd05f6..3ba55455 100644 --- a/test/test_cve_cpe_matching.py +++ b/test/test_cve_cpe_matching.py @@ -57,7 +57,7 @@ class TestCPEandCVEMatching(TestCase): self.assertEqual(self.cc_dset['c01e5375331b25dc'].heuristics.extracted_versions, ['8.2'], 'The version extracted from the certificate does not match the template') new_cert = CommonCriteriaCert('', '', 'IDOneClassIC Card : ID-One Cosmo 64 RSA v5.4 and applet IDOneClassIC v1.0 embedded on P5CT072VOP', '', '', '', None, None, '', '', '', '', '', set(), set(), None, None, None) - new_cert.get_heuristics_version() + new_cert.compute_heuristics_version() self.assertEqual(set(new_cert.heuristics.extracted_versions), {'5.4', '1.0'}, 'The extracted versions do not match the template.') |
