All Projects → patronmanager → Apex Dml Manager

patronmanager / Apex Dml Manager

Enforces CRUD/FLS in the least disruptive way possible

Labels

Projects that are alternatives of or similar to Apex Dml Manager

Objectmerge
Open-source solution for merging Salesforce objects and their related objects.
Stars: ✭ 35 (-50%)
Mutual labels:  apex
Stripeforce
Stripe API Client Library for Force.com
Stars: ✭ 50 (-28.57%)
Mutual labels:  apex
Purealoe
Salesforce Sample App part of the sample gallery. Agriculture and retail use case. Get inspired and learn best practices.
Stars: ✭ 65 (-7.14%)
Mutual labels:  apex
Data Ingestion Platform
Stars: ✭ 39 (-44.29%)
Mutual labels:  apex
Ridge
AWS Lambda HTTP Proxy integration event bridge to Go net/http.
Stars: ✭ 45 (-35.71%)
Mutual labels:  apex
Apex Legends Internal
Simple Apex Legends esp source
Stars: ✭ 53 (-24.29%)
Mutual labels:  apex
Sendgrid Apex
SendGrid (http://sendgrid.com) Apex helper library.
Stars: ✭ 33 (-52.86%)
Mutual labels:  apex
Rflib
Salesforce open source library with logging framework, trigger framework, feature switches, and advanced monitoring capabilities
Stars: ✭ 69 (-1.43%)
Mutual labels:  apex
Dg Net
Joint Discriminative and Generative Learning for Person Re-identification. CVPR'19 (Oral)
Stars: ✭ 1,042 (+1388.57%)
Mutual labels:  apex
Apex Domainbuilder
Framework to setup Apex test data in a highly flexible and readable way using the Test Data Builder pattern.
Stars: ✭ 61 (-12.86%)
Mutual labels:  apex
Forcedotcomsprintwall
An agile sprint wall built on the force.com platform with jQuery and Javascript Remoting
Stars: ✭ 42 (-40%)
Mutual labels:  apex
Gh Polls
Create a poll with gh-polls
Stars: ✭ 45 (-35.71%)
Mutual labels:  apex
Wsdl2apex
Stars: ✭ 54 (-22.86%)
Mutual labels:  apex
Forcedotcom Enterprise Architecture
Force.com Enterprise Architecture - First Edition - Source Code
Stars: ✭ 35 (-50%)
Mutual labels:  apex
Lwc Recipes
A collection of easy-to-digest code examples for Lightning Web Components on Salesforce Platform
Stars: ✭ 1,147 (+1538.57%)
Mutual labels:  apex
Grid
A Lightning Component grid implementation that expects a server-side data store.
Stars: ✭ 35 (-50%)
Mutual labels:  apex
Streams
Durable event pipelines.
Stars: ✭ 51 (-27.14%)
Mutual labels:  apex
Cinnamon
Cinnamon is a Force.com app that enables you to build and run Selenium tests to validate custom UI pages with Visualforce/Javascript in your Salesforce org.
Stars: ✭ 70 (+0%)
Mutual labels:  apex
Apexunit
ApexUnit is a powerful continuous integration tool for the Force.com platform
Stars: ✭ 69 (-1.43%)
Mutual labels:  apex
Sobject Remote
JavaScript library to simplify CRUD DML operations with JavaScript Remoting on the force.com platform.
Stars: ✭ 57 (-18.57%)
Mutual labels:  apex

Overview

The purpose of DMLManager is to act as a low-risk remediation to Apex that was not architected with CRUD/FLS enforcement in mind. There are limitations, outlined below, but in 95% of cases, the additional SOQL query and retrieved row increases are far better than the risk of extensive code refactoring.

The topic is documented here:

http://wiki.developerforce.com/index.php/Testing_CRUD_and_FLS_Enforcement

and here:

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

Usage

List<Contact> contactList = [SELECT Id, FirstName, LastName FROM Contact];

//Manipulate the contactList
...

//Instead of calling "update contactList", use:
DMLManager.updateAsUser(contactList);

(there are overloaded versions of insert/update/upsert/delete that take either a single SObject or a List)

DMLManager.CRUDException is raised for respective CRUD permission failures

DMLManager.FLSException is raised for respective FLS permission problems

Goals

The security review team suggests using the ESAPI SFDCAccessController for CRUD and FLS enforcement, but this implementation has serious limitations:

  • It performs DML on clones of the passed in collections of SObjects -- This results in the calling code not having access to the same object references that were ultimately used in the DML. In practice, this causes problems with Lists and other collections that are used when building Master-Detail and Lookups to a parent record persisted earlier in the transaction.
  • The insertAsUser and updateAsUser methods require a fieldsToSet collection -- this is an unreasonable burden to compute and trying to maintain a list of affected fields is a recipe for tightly coupled and unmaintainable code
  • There’s no implementation of upsertAsUser.

Limitations

It's not all roses and gumdrops with DMLManager. There are some things to keep in mind:

  • Adds an extra SOQL query for each call to insertAsUser/updateAsUser/upsertAsUser for each distinct SObjectType in the passed in collection. Additionally, since each record in the passed in collection is retrieved, the maximum query row limit (50k) per transaction may also come into play
  • The current implementation of upsertAsUser does not take an External ID column as a possible key candidate for upsert. We’ll gladly accept pull requests if you want to implement this feature.
  • While the code is optimized to only query the database if the calling User’s profile has FLS restricting them from access to a nonzero number of fields, in practice, there are many fields on Standard Objects that aren’t writable, but are indiscernible from fields that are FLS-restricted. For example. Opportunity.ExpectedRevenue is not a true formula field (isCalculated() is false), but it’s not writable so it is considered a restricted field and results in us needing to requery the database for existing records each time an Opportunity is passed through updateAsUser/upsertAsUser.

Contributors

Eric Whipple @modernapple
David Esposito @daveespo
Tom Fuda @tfuda
Scott Covert [@scottbcovert] (https://github.com/scottbcovert)

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].