aboutsummaryrefslogtreecommitdiffhomepage
path: root/sec_certs/sample
diff options
context:
space:
mode:
authorJ08nY2022-07-11 19:47:31 +0200
committerJ08nY2022-07-11 19:47:31 +0200
commit52ed539690da1df3445f95d44de04ae208744ea3 (patch)
tree7755eb1ad87f88f169f8572c622e4df4da03cf1e /sec_certs/sample
parent68b5ed3c888d3a21d64c8a1aeaa8f4e56bf051f6 (diff)
downloadsec-certs-52ed539690da1df3445f95d44de04ae208744ea3.tar.gz
sec-certs-52ed539690da1df3445f95d44de04ae208744ea3.tar.zst
sec-certs-52ed539690da1df3445f95d44de04ae208744ea3.zip
FIPS: Extract ST metadata and store it.
Diffstat (limited to 'sec_certs/sample')
-rw-r--r--sec_certs/sample/fips.py23
1 files changed, 8 insertions, 15 deletions
diff --git a/sec_certs/sample/fips.py b/sec_certs/sample/fips.py
index 33c25742..3fc230ef 100644
--- a/sec_certs/sample/fips.py
+++ b/sec_certs/sample/fips.py
@@ -106,16 +106,6 @@ class FIPSCertificate(Certificate["FIPSCertificate", "FIPSCertificate.Heuristics
sw_versions: Optional[str]
product_url: Optional[str]
- @property
- def dgst(self) -> str:
- return helpers.get_first_16_bytes_sha256(
- self.product_url
- if self.product_url is not None
- else "" + self.vendor_www
- if self.vendor_www is not None
- else ""
- )
-
def __repr__(self) -> str:
return (
self.module_name
@@ -137,12 +127,9 @@ class FIPSCertificate(Certificate["FIPSCertificate", "FIPSCertificate.Heuristics
cert_id: int
keywords: Dict
algorithms: List
+ st_metadata: Optional[Dict[str, Any]] = field(default=None)
# TODO: Add metadata processing.
- @property
- def dgst(self) -> str:
- return helpers.get_first_16_bytes_sha256(str(self.keywords))
-
def __repr__(self) -> str:
return str(self.cert_id)
@@ -352,11 +339,17 @@ class FIPSCertificate(Certificate["FIPSCertificate", "FIPSCertificate.Heuristics
"""
Downloads security policy file from web. Staticmethod to allow for parametrization.
"""
- exit_code = helpers.download_file(*cert, delay=1)
+ exit_code = helpers.download_file(*cert, delay=constants.FIPS_DOWNLOAD_DELAY)
if exit_code != requests.codes.ok:
logger.error(f"Failed to download security policy from {cert[0]}, code: {exit_code}")
@staticmethod
+ def extract_sp_metadata(cert: FIPSCertificate) -> FIPSCertificate:
+ """Extract the PDF metadata from the security policy. Staticmethod to allow for parametrization."""
+ response, cert.pdf_data.st_metadata = sec_certs.utils.pdf.extract_pdf_metadata(cert.state.sp_path)
+ return cert
+
+ @staticmethod
def _initialize_dictionary() -> Dict[str, Any]:
return {
"module_name": None,