I've just gone through a biggish code base making sure that WITH SECURITY_ENFORCED is set on every query. Most were, but for some recent additions, it hadn't been included. For managed packages that need to go through security reviews, this is a great way to respect object and field level security on reads. But tedious to manually check big code bases, especially where dynamic SOQL is used.
- Does anyone have a PMD Apex Security Rule created for this that they would be happy to share?
- IMHO it would be great if
WITH
became the default mode at say API 55 with aWITHOUT SECURITY_ENFORCED
option also provided. (Or some other mechanism used to turnWITH
on everywhere.)
WITHOUT SECURITY_ENFORCED
. It's secure be default unless you type out something that fills people with dread and sets off all sorts of alarm bells. Can you can easily search the code base for instances bypassing security.