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

Restructure file validation code #4976

Merged
merged 2 commits into from
Dec 31, 2024
Merged

Conversation

sergei-maertens
Copy link
Member

Closes #4795 (noticed the code structure when working on that ticket)

Changes

  • Uses pattern matching for the pre/post-processing for certain edge cases
  • Added support for libmagic 5.46 edge case w/r to zip files

Checklist

Check off the items that are completed or not relevant.

  • Impact on features

    • Checked copying a form
    • Checked import/export of a form
    • Config checks in the configuration overview admin page
    • Problem detection in the admin email digest is handled
  • Release management

    • I have labelled the PR as "needs-backport" accordingly
  • I have updated the translations assets (you do NOT need to provide translations)

    • Ran ./bin/makemessages_js.sh
    • Ran ./bin/compilemessages_js.sh
  • Dockerfile/scripts

    • Updated the Dockerfile with the necessary scripts from the ./bin folder
  • Commit hygiene

    • Commit messages refer to the relevant Github issue
    • Commit messages explain the "why" of change, not the how

This makes the cases that need to be handled a bit more readable rather
than the contrived if/elif flows.
Copy link

codecov bot commented Dec 30, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.66%. Comparing base (5e67644) to head (4574fe8).
Report is 21 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4976      +/-   ##
==========================================
+ Coverage   96.64%   96.66%   +0.01%     
==========================================
  Files         761      761              
  Lines       25908    25943      +35     
  Branches     3386     3392       +6     
==========================================
+ Hits        25040    25078      +38     
+ Misses        604      601       -3     
  Partials      264      264              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Validated with Sonny who's also using Arch - since libmagic 5.46 the
detected content type for these 'exotic' zip formats no longer reports
application/zip, but instead it returns application/octet-stream, or
otherwise said: it doesn't know those magic bytes (anymore).

Given the earlier patches, all we can do is allow these files to go
through.

Our Docker images are based on Debian bookworm, which ships libmagic
5.44. Debian unstable currently still has 5.44.
@sergei-maertens sergei-maertens force-pushed the cleanup/4795-restructure-code branch from aa43480 to 4574fe8 Compare December 31, 2024 11:23
@sergei-maertens sergei-maertens merged commit fffe77b into master Dec 31, 2024
13 of 15 checks passed
@sergei-maertens sergei-maertens deleted the cleanup/4795-restructure-code branch December 31, 2024 11:23
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.

.msg files cannot be uploaded
2 participants