WebHost: Prevent committing data packages with invalid checksums to database and prevent 500 error from invalid zip
files.
#3206
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.
What is this fixing or adding?
This is a two-fold PR just because both fixes were trivial.
Prevent committing data packages with invalid checksums to database.
If a game with a data package checksum that does not match the re-calculated checksum is uploaded, an error would flash on the screen with the specific error, but the data package would still be uploaded to the database. Then the next time a user uploads the same game data package, it will return a 500 error instead as PONY would throw an exception.
The fix was to compare the checksums first, then create a
GameDataPackage
entity as doing it before would still commit to DB even without runningcommit
.Prevent 500 error from invalid
zip
files.Similar to the above, if a
.zip
file containing the.archipelago
file with the invalid data package checksums was uploaded, it would return a 500 error regardless. This was because there was no baseException
catch. We just add the base Exception catch and flash the same error message as above.Error discovered in this tech support thread: https://discord.com/channels/731205301247803413/1232485200542433423
Adding
affects: release/blocker
as without this change, DB will still be polluted with bad checksum data.Ideally the wholeEdit: Actually impossible to check becauseGameDataPackage
table in the DB should also be run through for invalid data packages with mismatched checksums to remove existing bad entries, but that's a @Berserker66 request since I don't have access to the server. :Pupload.py
overrides the checksum from the uploaded file in both column and data package. So unless the rest of the data package is invalid, it probably can't be detected (but may be fine anyway?).How was this tested?
Ran WebHost and uploaded generations with invalid data packages and valid data packages.
If this makes graphical changes, please attach screenshots.
No pictures of my database for you. Just trust me bro.