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

fix: reject encrypted PDF on upload #21

Closed

Conversation

ublefo
Copy link
Collaborator

@ublefo ublefo commented Mar 27, 2024

Changes

Supersedes #5, do not merge until CI fixes have been merged.

  • Introduced the pdf-reader gem for proper PDF validation, which is a much more elegant solution than looking for strings from the binary file.
  • Added a unit test with some test files to test the changes, along with three test PDF files. The password for the encrypted file is password.
  • Refactored accept_file and PDF validation methods in FileHelper in order to return validation errors to the frontend.

Tests

  • Changes have been tested manually
  • All unit tests pass

Screenshots

image
image
image

Instructions for reviewers: check out the branch, try submitting the encrypted and corrupted sample PDF files I provided, they should be rejected immediately. Running unit tests locally is not strictly necessary as the GitHub Actions workflow has already been fixed, just verify the results below.

@maddernd
Copy link

This is looking good, can you please update invalid PDF message to include the possibility that it is encrypted

@ublefo ublefo force-pushed the feat/reject-encrypted-pdf branch from 9dc8959 to 9f7e52d Compare April 11, 2024 00:46
@ublefo ublefo requested a review from macite April 11, 2024 01:38
@ublefo ublefo force-pushed the feat/reject-encrypted-pdf branch from 9f7e52d to a042df5 Compare April 11, 2024 02:41
@ublefo
Copy link
Collaborator Author

ublefo commented Apr 11, 2024

Closed in favor of doubtfire-lms#436

@ublefo ublefo closed this Apr 11, 2024
@ublefo ublefo deleted the feat/reject-encrypted-pdf branch April 27, 2024 14:41
@ublefo ublefo restored the feat/reject-encrypted-pdf branch April 27, 2024 15:00
@ublefo ublefo deleted the feat/reject-encrypted-pdf branch May 2, 2024 16:32
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.

2 participants