2

I am using Database methods for DML on SObjects. I am getting CRUD Delete issue in CheckMarx security scanner for below line:

 public SObject toDML;

 Database.delete(toDML, false);

Can anyone help me how can i resolve this issue for SObject.

Any help would be really appreciated.

Thanks

1
  • Checkmarx has issues with ID deletes and SObject deletes because the object type in the DML cannot be matched to the object type in the CRUD check. Did you discover any solution or workaround that supports generic SObject type? Jun 5, 2021 at 1:04

1 Answer 1

3

If you are submitting your app for security review ,you will need to enforce CRUD-FLS for all your DML and SOQL since apex does not enforce it automatically.

There is a blog post link below that shows how to enforce CRUD FLS

https://developer.salesforce.com/page/Enforcing_CRUD_and_FLS

You will use describe call to find the access level and prevent the DML if user does not have sufficient access .

If your project has lots of apex then you may want to use some library that's build to specifically handle heavy lifting of checking CRUD/FLS .The project is open source here

https://github.com/forcedotcom/force-dot-com-esapi

The project has utility methods to wrap the DML to perform checking of access before any DML .

Note that if you are not building a managed package and instead customizing single org and if there is no strict requirements around security enforcement you may skip these checlmarks warnings

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .