Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add document hashes. #221

Merged
merged 1 commit into from
May 30, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions sec_certs/sample/common_criteria.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,12 @@ class InternalState(ComplexSerializableType):

st_pdf_path: Path
report_pdf_path: Path
st_pdf_hash: Optional[str]
report_pdf_hash: Optional[str]
st_txt_path: Path
report_txt_path: Path
st_txt_hash: Optional[str]
report_txt_hash: Optional[str]

def __init__(
self,
Expand All @@ -124,8 +128,12 @@ def serialized_attributes(self) -> List[str]:
return [
"st_download_ok",
"report_download_ok",
"st_pdf_hash",
"report_pdf_hash",
"st_convert_ok",
"report_convert_ok",
"st_txt_hash",
"report_txt_hash",
"st_extract_ok",
"report_extract_ok",
"errors",
Expand Down Expand Up @@ -673,6 +681,8 @@ def download_pdf_report(cert: CommonCriteriaCert) -> CommonCriteriaCert:
logger.error(f"Cert dgst: {cert.dgst} " + error_msg)
cert.state.report_download_ok = False
cert.state.errors.append(error_msg)
else:
cert.state.report_pdf_hash = helpers.get_sha256_filepath(cert.state.report_pdf_path)
return cert

@staticmethod
Expand All @@ -693,6 +703,8 @@ def download_pdf_st(cert: CommonCriteriaCert) -> CommonCriteriaCert:
logger.error(f"Cert dgst: {cert.dgst}" + error_msg)
cert.state.st_download_ok = False
cert.state.errors.append(error_msg)
else:
cert.state.st_pdf_hash = helpers.get_sha256_filepath(cert.state.st_pdf_path)
return cert

@staticmethod
Expand All @@ -709,6 +721,8 @@ def convert_report_pdf(cert: CommonCriteriaCert) -> CommonCriteriaCert:
logger.error(f"Cert dgst: {cert.dgst}" + error_msg)
cert.state.report_convert_ok = False
cert.state.errors.append(error_msg)
else:
cert.state.report_txt_hash = helpers.get_sha256_filepath(cert.state.report_txt_path)
return cert

@staticmethod
Expand All @@ -725,6 +739,8 @@ def convert_st_pdf(cert: CommonCriteriaCert) -> CommonCriteriaCert:
logger.error(f"Cert dgst: {cert.dgst}" + error_msg)
cert.state.st_convert_ok = False
cert.state.errors.append(error_msg)
else:
cert.state.st_txt_hash = helpers.get_sha256_filepath(cert.state.st_txt_path)
return cert

@staticmethod
Expand Down