All Projects → forcedotcom → Force Dot Com Esapi

forcedotcom / Force Dot Com Esapi

Licence: bsd-3-clause
Enterprise Security API for the Apex language on the Force.com platform.

Labels

Projects that are alternatives of or similar to Force Dot Com Esapi

Apex Domainbuilder
Framework to setup Apex test data in a highly flexible and readable way using the Test Data Builder pattern.
Stars: ✭ 61 (-37.76%)
Mutual labels:  apex
Connectapihelper
Helper class that makes it easier to post Chatter @-mentions, rich text, and inline images with Apex code.
Stars: ✭ 72 (-26.53%)
Mutual labels:  apex
Dialogue Generation
Generating responses with pretrained XLNet and GPT-2 in PyTorch.
Stars: ✭ 86 (-12.24%)
Mutual labels:  apex
Lwc Recipes
A collection of easy-to-digest code examples for Lightning Web Components on Salesforce Platform
Stars: ✭ 1,147 (+1070.41%)
Mutual labels:  apex
Apex Dml Manager
Enforces CRUD/FLS in the least disruptive way possible
Stars: ✭ 70 (-28.57%)
Mutual labels:  apex
Processbuilderblocks
apex invocable methods for use in Process Builder
Stars: ✭ 77 (-21.43%)
Mutual labels:  apex
Wsdl2apex
Stars: ✭ 54 (-44.9%)
Mutual labels:  apex
Awesome Low Code
Awesome Low-Code Application Platforms | 全球低代码平台开发资源大全
Stars: ✭ 90 (-8.16%)
Mutual labels:  apex
Sfdc Convert Attachments To Chatter Files
📎 Easily migrate your Attachments to Salesforce Files.
Stars: ✭ 72 (-26.53%)
Mutual labels:  apex
Batch Entry For Salesforce.com
jQuery-based quick entry screen that works with any object. Highly configurable and flexible.
Stars: ✭ 82 (-16.33%)
Mutual labels:  apex
Apexunit
ApexUnit is a powerful continuous integration tool for the Force.com platform
Stars: ✭ 69 (-29.59%)
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 (-28.57%)
Mutual labels:  apex
Query.apex
A dynamic SOQL and SOSL query builder on Salesforce.com platform
Stars: ✭ 78 (-20.41%)
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 (-33.67%)
Mutual labels:  apex
Sirono Common
Common Apex utility classes and frameworks used by Sirono products
Stars: ✭ 87 (-11.22%)
Mutual labels:  apex
Sobject Remote
JavaScript library to simplify CRUD DML operations with JavaScript Remoting on the force.com platform.
Stars: ✭ 57 (-41.84%)
Mutual labels:  apex
Visualforce Typeahead
A flexible typeahead component for use on Visualforce pages. Uses the typeahead.js library from Twitter.
Stars: ✭ 73 (-25.51%)
Mutual labels:  apex
Sfdx Travisci
Stars: ✭ 95 (-3.06%)
Mutual labels:  apex
Automated Testing For Force.com
Salesforce testing automation runs all tests and emails your team. Native Force.com Apex code delivers lightweight Salesforce continuous integration.
Stars: ✭ 88 (-10.2%)
Mutual labels:  apex
Apextestkit
A way to simplify your Salesforce data creation.
Stars: ✭ 80 (-18.37%)
Mutual labels:  apex

Getting started with Force.com ESAPI

Overview

This page is intended to give a basic understanding of how to use the Force.com ESAPI library. This library is published by Salesforce.com under the New BSD license. You should read and accept the license before you use, modify, and/or redistribute this software.

Follow the steps below to get started. For more detailed documentation on this library, please refer to the doc folder.

Getting started

We reccomend using a release tag instead of the master branch unless you intend to contribute to ESAPI or need unreleased features.

  1. Download the latest release from the download page.
  2. Make any modifications in the code if you need additional functionality not covered by the library.
  3. Upload the classes to your Force.com Org.
  4. Start using it in your other classes.

OR

One-click deployment of the latest stable release ("stable" tag): Deploy to Salesforce

Package Installation

  • Go to the releases section to get the installation link for both managed and un-managed versions of the ESAPI package.

Example Code

Input Validation:

The Validator module defines a set of methods for validating untrusted input. This allows server side validation in apex.

Example using exceptions (the get... function will throw an exception if fail, and return the input if no error has occurred):

String creditCard = ApexPages.currentPage().getParameters().get('creditcard');
try {
    creditCard = ESAPI.validator().getValidCreditCard(creditCard, false);
} catch (Exception e) {
    /*
    report error here using e.getMessage(). Make sure you escape the string before
    displaying it back on page, and also be careful not to expose any internal information.
    */
}

Example using return value (the is... function will never throw exceptions, instead it will return false in case of error):

String creditCard = ApexPages.currentPage().getParameters().get('creditcard');
if (ESAPI.validator().isValidCreditCard(creditCard, false) == false)
    // do something here

Output Encoding

The Encoder module contains a number of methods for encoding output so that it will be safe for display in visual force pages. These functions are equivalent to the visual force JSENCODE, HTMLENCODE, JSINHTMLENCODE and URLENCODE functions.

String usertext = ApexPages.currentPage().getParameters().get('usertext');
// the next line encodes the usertext similar to the VisualForce HTMLENCODE function but within an Apex class.
usertext = ESAPI.encoder().SFDC_HTMLENCODE(usertext);

Access Control

The access control module provides functionality to enforce the Force.com built in access control mechanisms: CRUD, FLS, and Sharing. As described in the apex documentation, apex classes execute in system context and not in the current user context. This is why the platform can't enforce any of the security models. For more details please see Enforcing CRUD and FLS. This ESAPI module allows apex classes execute statements such as insert object; as if operating in user context.

For example, if we want to update an object in user context, enforcing sharing rules as well as CRUD and FLS we will use the module in this way:

// s is a modified SObject

try {
    ESAPI.accessController().setSharingMode(SFDCAccessController.SharingMode.WITH);
    ESAPI.accessController().updateAsUser(s, new List<String>{'data'});
} catch (SFDCAccessControlException e) {
    message = 'Access Control violation - Type: ' + e.getExceptionType() + ' Reason: ' 
        + e.getExceptionReason() + ' Object: ' + e.getExceptionObject() + ' Field: ' 
        + e.getExceptionField() + ' Text: ' + e.getText();
}

You can use Access Control also to check which objects fields the current user can read/update etc before presenting the page and not just on the insert/update/delete operation.

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].