-
Notifications
You must be signed in to change notification settings - Fork 273
Open
Labels
bugSomething isn't workingSomething isn't working
Description
In Sw360ProjectService.java, the setObligationsFromAdminSection method has a potential NullPointerException vulnerability when the oblLevel parameter is null.
Location
- File: rest/resource-server/src/main/java/org/eclipse/sw360/rest/resourceserver/project/Sw360ProjectService.java
- Lines: 738, 742, 746
Issue
The method calls oblLevel.equalsIgnoreCase(...) without checking if oblLevel is null. If oblLevel is null, it will throw NullPointerException.
Current Code (buggy):
if (oblLevel.equalsIgnoreCase("Project")) {
// ...
} else if (oblLevel.equalsIgnoreCase("Organization")) {
// ...
} else if (oblLevel.equalsIgnoreCase("Component")) {
// ...
}
Recommended Fix:
if ("Project".equalsIgnoreCase(oblLevel)) {
// ...
} else if ("Organization".equalsIgnoreCase(oblLevel)) {
// ...
} else if ("Component".equalsIgnoreCase(oblLevel)) {
// ...
}
This is a standard Java idiom to avoid NullPointerException - by putting the constant string first, if oblLevel is null, it simply returns false instead of throwing an NPE.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working