Skip to content

[apex] ApexCRUDViolation: Support WITH SECURITY_ENFORCED #2210

@adangel

Description

@adangel

Affects PMD Version:

Rule: ApexCRUDViolation

Description:
(from https://sourceforge.net/p/pmd/discussion/188192/thread/5aef500464/?limit=25#196a)

Hi,

PMD is going to take in consideration new apex function stripInaccessible https://releasenotes.docs.salesforce.com/en-us/spring20/release-notes/rn_apex_Security_stripInaccessible_GA.htm
or WITH SECURITY_ENFORCED https://releasenotes.docs.salesforce.com/en-us/spring20/release-notes/rn_apex_WithSecurityEnforced_GA.htm
concerning the security error "ApexCRUDViolation " ?

Thanks

Code Sample demonstrating the issue:

public class Foo {
	public Contact foo(String tempID) {
                Contact c;
                // this is missing with security enforced
                c = [SELECT Name FROM Contact WHERE Id=: tempID];
                // that's ok
		c = [SELECT Name FROM Contact WHERE Id=: tempID WITH SECURITY_ENFORCED];
		return c;
	}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    an:enhancementAn improvement on existing features / rules

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions