NasdaqCloudDataService-SDK-Java icon indicating copy to clipboard operation
NasdaqCloudDataService-SDK-Java copied to clipboard

Switch order of literals to prevent NullPointerException

Open pixeeai opened this issue 1 year ago • 1 comments

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)

pixeeai avatar Apr 14 '24 15:04 pixeeai

FYI - This change was autogenerated from a new trending GitHub app - called Pixeebot. A code-quality GitHub App; like Dependabot, but for source code.

pixeeai avatar Apr 14 '24 15:04 pixeeai

Any chance you've had the time to review these changes?

If you're not interested implementing them at this time, no worries. I can close the PR and follow up with additional changes in the future. Also, this plugin is free for non-commercial open sourced projects, so feel free to give it an install if you want to see the other recommended PRs.

Thanks, Zach

pixeeai avatar Nov 02 '24 21:11 pixeeai