1

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

4

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.