Add validation utils for encrypted file metadata #25
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When scanning an encrypted file, clients are expected to send the content scanner some metadata it can use to decrypt it. This is typically the
file
property of them.room.message
event content. See https://github.com/matrix-org/matrix-content-scanner-python/blob/main/docs/api.md#post-_matrixmedia_proxyunstabledownload_encrypted to see how it fits into the API, and an example.This adds a
validate_encrypted_file_metadata
util that performs a few validation checks on the client-provided data to ensure it's in the right format before passing it on to the scanner. This will then be used by the http handler code (coming in a future PR, see https://github.com/matrix-org/matrix-content-scanner-python-wip/blob/main/matrix_content_scanner/servlets/__init__.py#L166-L241 to see what it will looks like).Closes #7