GeezerVison is showing github.com — [apex] ApexCRUDViolation: Recognize User Mode in SOQL + DML · Issue #4146 · pmd/pmd
[apex] ApexCRUDViolation: Recognize User Mode in SOQL + DML #4146Description
Affects PMD Version:
Rule: ApexCRUDViolation
Description:
With the upcoming Winter '23 (API Version 56) Salesforce is going to add more native capabilities to enforce CRUD and FLS security in SOQL queries and DML statements as described here https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_enforce_usermode.htm.
Currently, the usage of such new features is ignored by PMD and marked as a CRUD Violation. Therefor the rule needs to be extended to recognize and handle them correctly.
Code Sample demonstrating the issue:
public class UserMode {
public void coverAllCasesWithTest() {
// SOQL Queries cases
Contact c;
// Should be flagged a critical issue
c = [SELECT Name FROM Contact];
// Should be ignored
c = [SELECT Name FROM Contact WITH USER_MODE];
// Should be at best a warning because it ignores CRUD but explicitly
c = [SELECT Name FROM Contact WITH SYSTEM_MODE];
// DML cases
// Should be flagged a critical issue
insert contact;
// Should be ignored
insert as user contact;
// Should be at best a warning because it ignores CRUD but explicitly
insert as system contact;
// ...and for ALL other occurrences of System.AccessLevel
}
}
This issue should cover all cases with the optional accessLevel parameter. See Dynamic SOQL.
Database.getQueryLocator methods
Search.query methods
Database DML methods (insert, update, upsert, merge, delete, undelete, and convertLead)
Includes the *Immediate and *Async methods, such as insertImmediate and deleteAsync.
This issuers should be easy to contribute as we can just look at how the related earlier enhancements were done: #2210 Reacted by Thomas Prouvot, Jéferson Chaves, Uriel Zilberberg and Hassan ALAMI Activitychanged the title [-][apex] ApexCRUDViolation: Support SOQL and DML User Mode (GA in Winter '23)[/-] [+][apex] ApexCRUDViolation: Recognize User Mode in SOQL + DML[/+] on Oct 7, 2022Tarush-Singh35 commented on Oct 20, 2022 @rsoesemann I would like to contribute to this issue can you assign this issue to me? rsoesemann commented on Oct 21, 2022 @adangel was faster ;-)
Welcome @Tarush-Singh35. Thanks for your willingness to contribute to this very relevant change request.
Maybe you can join force with @rbklaassen from within Salesforce who also wanted to take this. Tarush-Singh35 commented on Oct 21, 2022 yeah sure, I am getting started @rsoesemann we can work something out together. how can we connect @rbklaassen please let me know Tarush-Singh35 commented on Oct 24, 2022 @rbklaassen I am getting started with the issue if you want to join do ping me.
Thanks & Regards Reacted by Robert Sösemann rbklaassen commented on Oct 25, 2022 Hi @Tarush-Singh35 , go ahead and start on this. I've been quite busy last week and preparing a go-live at customer this week, so I don't think I can help out this or next week. I'll check in after that! rbklaassen commented on Oct 25, 2022 Tarush-Singh35 commented on Oct 27, 2022 rbklaassen commented on Oct 31, 2022 Tarush-Singh35 commented on Nov 1, 2022 rsoesemann commented on Nov 9, 2022 rbklaassen commented on Nov 9, 2022 Sorry, not yet. Have had COVID and a pretty busy schedule at customer. rbklaassen commented on Nov 17, 2022 Yes, I can do some work on this tomorrow. Do you want to collaborate tomorrow @Tarush-Singh35 ? Tarush-Singh35 commented on Nov 18, 2022 rbklaassen commented on Nov 18, 2022 You need to connect with me through slack, I don't have enough details to connect to you @Tarush-Singh35 Tarush-Singh35 commented on Nov 18, 2022
You need to connect with me through slack, I don't have enough details to connect to you @Tarush-Singh35
I will create a workspace and I will ask you to join it Tarush-Singh35 commented on Nov 19, 2022 Reacted by Robert Sösemann rsoesemann commented on Nov 27, 2022 rbklaassen commented on Nov 28, 2022 Hi @rsoesemann, today we had a meeting together and discussed the way forward. I came to the conclusion that I miss the Java knowledge to really work on the code, but I can be the support-desk for @Tarush-Singh35 as I know Apex very good. Also I will be able to test his solution when needed on a local project for instance. Reacted by Robert Sösemann Tarush-Singh35 commented on Nov 29, 2022 Yeah I am formulating a solution I think so I will be able to make a pull request soon @rsoesemann and @rbklaassen are mentoring me in the apex Reacted by Robert Sösemann Tarush-Singh35 commented on Dec 12, 2022 rsoesemann commented on Dec 13, 2022 adangel commented on Dec 16, 2022
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|