Fix/857 directobject try with resources - #919
Open
shishir-cyber wants to merge 3 commits into
Open
shishir-cyber wants to merge 3 commits into
shishir-cyber wants to merge 3 commits into
Conversation
…dmin Replace the inaccurate "JavaScript validation bypassed" ERROR log with an accurate WARN message describing a server-side validation failure. - Log the length of the offending username/password/address fields instead of asserting a JS bypass, so operators can tell which constraint (username 3-32 chars, password 8-512 chars, address <=128 chars) was violated. - Never log the actual field values (especially the password). - Downgrade log level from ERROR to WARN, since this is a routine input-validation rejection, not a tamper signal. - Apply the same fix to CreateNewAdmin.java, which had the identical issue. - User-facing response message is unchanged. Fixes OWASP#860
Replaces manual Database.closeConnection() calls with try-with-resources for Connection/PreparedStatement/ResultSet, closing a connection leak on the exception path. Verified with spotless:apply and mvn test (169 passed).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Part of #857
Converts the 5 DB-touching files in the DirectObject* family (DirectObject1, DirectObject2, DirectObjectBankLogin, DirectObjectBankRegistration, DirectObjectBankTransfer) to try-with-resources, following the same pattern used in #834/#846.
DirectObjectBankCurrentBalance and DirectObjectBankLogout are excluded since neither touches the database.
Connections were previously only closed at the end of the try block, so any exception skipped cleanup.
getAccountBalance()had it worse, every exceptional path leaked, including a condition it throws itself.No behavior change, same queries, same output, same intentionally vulnerable IDOR in DirectObject1/2.
Verified: google-java-format clean,
mvn testpasses.