Skip to content

Conversation

@zcarroll4
Copy link

This change defensively switches the order of literals in comparison expressions to ensure that no null pointer exceptions are unexpectedly thrown. Runtime exceptions especially can cause exceptional and unexpected code paths to be taken, and this can result in unexpected behavior.

Both simple vulnerabilities (like information disclosure) and complex vulnerabilities (like business logic flaws) can take advantage of these unexpected code paths.

Our changes look something like this:

 String fieldName = header.getFieldName(); String fieldValue = header.getFieldValue(); - if(fieldName.equals("requestId")) { + if("requestId".equals(fieldName)) { logRequest(fieldValue); }
More reading

Powered by: pixeebot (codemod ID: pixee:java/switch-literal-first)

Co-authored-by: pixeebot[bot] <23113631+pixeebot@users.noreply.github.com>
@tzolov
Copy link
Contributor

tzolov commented Sep 21, 2023

Thanks for the streamlining @zcarroll4 !

@tzolov tzolov merged commit 9474999 into spring-projects:main Sep 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants