dotCMS / core

Headless/Hybrid Content Management System for Enterprises
http://dotcms.com
Other
865 stars 467 forks source link

Possible NullPointerException #11887

Closed AppChecker closed 5 years ago

AppChecker commented 7 years ago

Hi! Please inspect these code fragments: 1) src/main/java/com/liferay/portal/struts/PortalRequestProcessor.java

if(host != null || sendMeTo.getHostId().equals(host.getInode())){

if host is null, (host != null) will be false, so method host.getInode() will be invoked -> NPE will be thrown.

2) src/main/java/com/dotmarketing/portlets/workflows/ajax/WfActionAjax.jav

if(origAction !=null || !origAction.isNew()){

Similarly

3) src/main/java/com/dotmarketing/business/ajax/PermissionAjax.java

if(permParent !=null || InodeUtils.isSet(permParent.getPermissionId())){

Similarly

4) src/functional-test/java/com/dotcms/publisher/ajax/RemotePublishAjaxActionTest.java#L202

assertTrue( foundBundles != null || !foundBundles.isEmpty() );

Similarly

5) src/main/java/com/dotmarketing/viewtools/content/ContentMap.java

if(parseVelocity && ret != null && (f == null || ... )  ){
...
    template = ve.getTemplate((EDIT_OR_PREVIEW_MODE ? "working/":"live/") + content.getInode() + "_" + f.getInode() + "." + Config.getStringProperty("VELOCITY_FIELD_EXTENSION"));
...
}

if f is null and (parseVelocity && ret != null ) is true, method f.getInode() will be invoked -> NPE will be thrown.

6) src/main/java/com/dotmarketing/business/PermissionBitFactoryImpl.java

if (p != null && permissionExists(p)) {
 ..
} else {
  String cause = String.format("deletePermission: %s not found", p.toString());
}

if p is NULL, else-statement will be executed -> p.toString() will be invoked -> NPE will be thrown.

7) src/main/java/com/dotmarketing/business/PermissionBitFactoryImpl.java

if(permissionable == null || ! UtilMethods.isSet(permissionable.getPermissionId())){
  throw new DotDataException("Invalid Permissionable passed in. permissionable:" + permissionable.getPermissionId());
}

if permissionable is null, permissionable.getPermissionId() will be invoked -> NPE will be thrown.

These possible defects found by AppChecker

stale[bot] commented 5 years ago

This issue has been automatically marked as stale because it has not had activity within the past 90 days. It will be closed in 30 days no further activity occurs. Thank you.