Skip to content

Conversation

@NogaNHS
Copy link
Contributor

@NogaNHS NogaNHS commented Feb 11, 2026

Overview

Jira ticket: PRMP-1384

Description

  • Implement check for locked or corrupt files during document upload process.
  • Introduce new INVALID status for documents that are password protected or corrupted.
  • Create requirements for files_lambda_layer to include msoffcrypto-tool.

Context

Checklist

Tasks for all changes:

  • 1. I have linked this PR to its Jira ticket.
  • 2. I have run git pre-commits. (WIP)
  • 3. I have added and/or updated relevant tests.
  • 4. I have updated relevant documentation.
  • 5. I have considered the cross-team impact (and have PR approval from both Core & Demographics if necessary).
  • 6. I have successfully deployed this change to a sandbox and witnessed unit and e2e tests passing:

NogaNHS and others added 4 commits February 11, 2026 11:48
…dencies

- Implement check for locked or corrupt files during document upload process.
- Introduce new INVALID status for documents that are password protected or corrupted.
- Create requirements for files_lambda_layer to include msoffcrypto-tool.
@NogaNHS NogaNHS marked this pull request as ready for review February 11, 2026 11:54
@NogaNHS NogaNHS requested review from a team as code owners February 11, 2026 11:54
@github-actions
Copy link

Code security issues found

View full details here.

@sonarqubecloud
Copy link


def get_object_stream(self, bucket: str, key: str):
response = self.client.get_object(Bucket=bucket, Key=key)
def get_object_stream(self, bucket: str, key: str, byte_range: str = None):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

byte_range: str | None = None

if doc_ref.doc_status == "cancelled":
if doc_ref.virus_scanner_result == VirusScanResult.INFECTED:
return DocumentStatus.INFECTED.display, DocumentStatus.INFECTED.code
elif doc_ref.virus_scanner_result == VirusScanResult.INVALID:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can probably just be
if doc_ref.virus....... instead of elif

assert result["doc-id-4"]["error_code"] == DocumentStatus.INFECTED.code


def test_get_document_references_by_id_invalid_document(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could be a good idea to include some e2e tests for this scenario

)
mock_stream.read.assert_called_once_with()
mock_bytesio.assert_called_once_with(file_content)
mock_check.assert_called_once_with(mock_file_stream, file_extension)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe some more tests here that include failure scenarios.
file_name missing/None.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants