Skip to content

Instantly share code, notes, and snippets.

View rsoesemann's full-sized avatar

Robert Sösemann rsoesemann

  • https://bit.ly/robert-gpt
  • Tübingen, Germany
  • 03:17 (UTC -12:00)
  • X @rsoesemann
View GitHub Profile
@rsoesemann
rsoesemann / sfdx-scanner-appexchange-ruleset.xml
Last active January 12, 2024 11:30
Custom XPath Rules provided as special Security Scanner engine 'pmd-appexchange' from v.3.20
<ruleset name="AppExchange Security Review v.3.20" xmlns="http://pmd.sourceforge.net/ruleset/2.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0 https://pmd.sourceforge.io/ruleset_2_0_0.xsd">
<description>
Custom XPath Rules provided as special Security Scanner engine 'pmd-appexchange' from v.3.20
Decompiled with https://jdec.app/ from Java libs from https://github.com/forcedotcom/sfdx-scanner/tree/dev/pmd-appexchange/lib
</description>
<!-- APEX RULES -->
<!--AvoidUnsafeSystemSetPassword-->
<rule language="apex" class="net.sourceforge.pmd.lang.rule.XPathRule" name="AvoidUnsafeSystemSetPassword" message="Before calling System.setPassword() in Apex, perform necessary authorization checks." externalInfoUrl="https://github.com/forcedotcom/sfdx-scanner/blob/dev/pmd-appexchange/docs/AvoidUnsafeSystemSetPassword.md">
@rsoesemann
rsoesemann / app_analytics_with_errors.csv
Created September 28, 2022 08:06
Salesforce App Analytics Package Log CSV with Exceptions
We can make this file beautiful and searchable if this error is corrected: It looks like row 2 should actually have 68 columns, instead of 1 in line 1.
timestamp_derived,log_record_type,request_id,organization_id,organization_name,organization_status,organization_edition,organization_country_code,organization_language_locale,organization_time_zone,organization_instance,organization_type,cloned_from_organization_id,user_id_token,user_type,url,package_id,package_version_id,managed_package_namespace,custom_entity,custom_entity_type,operation_type,operation_count,request_status,referrer_uri,session_key,login_key,user_agent,user_country_code,user_time_zone,api_type,api_version,rows_processed,request_size,response_size,http_method,http_status_code,num_fields,run_time,cpu_time,db_total_time,db_blocks,db_cpu_time,visualforce_page_exec_time,app_name,page_app_name,page_context,ui_event_source,ui_event_type,ui_event_sequence_num,target_ui_element,parent_ui_element,page_url,prevpage_url,class_name,method_name,event,event_subscriber,event_count,apex_exec_time,apex_callout_time,entry_point,quiddity,num_soql_queries,stack_trace,bulk_job_id,bulk_batch_id,bulk_operation
2021
@rsoesemann
rsoesemann / sfge-output.json
Created June 23, 2022 12:18
JSON output of Salesforce Graph Engine (SFGE)
[
{
"engine":"sfge",
"fileName":"/Users/rsoesemann/dev/projects/lma-app-cockpit/force-app/main/default/classes/SetupArchiveErrors.cls",
"violations":[
{
"ruleName":"ApexFlsViolationRule",
"severity":1,
"message":"FLS validation is missing for [READ] operation on [ArchivedAppError__b] with field(s) [dtm_ArchivedDate__c]",
"category":"Security",
@rsoesemann
rsoesemann / ruleset.xml
Last active May 26, 2021 20:57
PMD ruleset with custom XPath rule "AvoidProductionDebugLogs"
<?xml version="1.0" encoding="UTF-8"?>
<ruleset xmlns="http://pmd.sourceforge.net/ruleset/2.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="Default ruleset used by the CodeClimate Engine for Salesforce.com Apex" xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0 https://pmd.sourceforge.io/ruleset_2_0_0.xsd">
<description>Default ruleset for PMD/Codacy</description>
<!-- CUSTOM RULES -->
<rule name="AvoidProductionDebugLogs" language="apex" class="net.sourceforge.pmd.lang.apex.rule.ApexXPathRule"
message="Avoid leaving System.debug() statments in code as they negativly influence performance.">
@rsoesemann
rsoesemann / lesmiserables.json
Last active September 8, 2020 11:22
lesmiserables.json
{
"rawGraph":{
"nodes":[
{
"id":"Napoleon",
"degree":1,
"pagerank":0.005542802377608484,
"node_id":"Napoleon"
},
{
@rsoesemann
rsoesemann / HttpMock.cls
Last active June 1, 2021 13:20
apex-http-mock
@IsTest
public class HttpMock implements HttpCalloutMock {
private static final String ANY_URL = null;
private Map<String, Map<String, Object>> responses = new Map<String, Map<String, Object>>();
// PUBLIC
@rsoesemann
rsoesemann / ruleset.xml
Last active February 26, 2022 23:34
CustomField names need Type prefix and CamelCase
<?xml version="1.0" encoding="UTF-8"?>
<ruleset xmlns="http://pmd.sourceforge.net/ruleset/2.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="Default ruleset used by the CodeClimate Engine for Salesforce.com Apex" xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0 https://pmd.sourceforge.io/ruleset_2_0_0.xsd">
<description>Default ruleset</description>
<rule name="CustomFieldNamingConvention" language="xml" message="Incorrectly named field" class="net.sourceforge.pmd.lang.rule.XPathRule">
<properties>
<property name="version" value="2.0"/>
<property name="xpath">
<value><![CDATA[
//CustomField[
@rsoesemann
rsoesemann / AnyWorkBatch.cls
Created March 12, 2019 10:53
Batch that can do every work
public class WorkBatch implements Database.Batchable<Work>, Database.Stateful {
private StateInfo state = new StateInfo();
// PUBLIC
public List<Work> start(Database.BatchableContext context) {
return new List<Work>{ new AccountWork(), new ContactWork(), new OpportunityWork() };
}
@rsoesemann
rsoesemann / Accounts.cls
Last active January 28, 2019 20:34
Logic-free trigger handler with overlap and centralized functionality
public with sharing class Accounts extends fflib_SObjectDomain {
public Accounts(List<Account> records) {
super(records);
}
public override void onAfterUpdate(Map<Id,SObject> old) {
new UnitOfWork(records)
.execute(new CheckTeamPermissions())
.execute(new EnhanceData())
@rsoesemann
rsoesemann / Opportunities.cls
Last active April 26, 2019 07:50
(fflib) Domain classes should have no logic besides User Story-related commands
public with sharing class Opportunities extends fflib_SObjectDomain {
public Opportunities(List<Opportunity> records) {
super(records);
}
public override void onAfterInsert() {
new ApplyDefaultCurrency(recors).execute();
new CalculateRevenueForecast(records)
.andThen(new PublishLeadScore().forNew(records)).execute();