Skip to content

Commit a009a34

Browse files
authored
[fix] Security Hardening: Fix SOQL Injection & XSS Vulnerabilities, Update API to v65 (#184)
* Upgrade api version to 65 * Create test suite to quickly run all package tests * Fix SOQL Injection Vulnerability * Remove sobject parameter deduced from recordId * fix issues with jsEncode * Update VSCode settings and change sharing model for ActionPlanCreateInvocable and ActionPlansTriggerHandlers classes * Fix XSS vulnerability * Remove unused settings and update PMD rules to use correct Visualforce category * Dummy update to test pr.yml on fork * Test removing namespace * Fix typo * prettier fix * Prettier apex controller * fix PMD old flag with v7 one
1 parent 07a50cd commit a009a34

File tree

84 files changed

+240
-139
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+240
-139
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,4 +65,4 @@ jobs:
6565
6666
# Run PMD scan
6767
- name: 'Run PMD scan'
68-
run: ~/pmd/bin/pmd check -d sfdx-source/LabsActionPlans -R pmd/deployRules.xml -f text --cache .pmdCache -min 2
68+
run: ~/pmd/bin/pmd check -d sfdx-source/LabsActionPlans -R pmd/deployRules.xml -f text --cache .pmdCache --minimum-priority 2

.github/workflows/pr.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ jobs:
2525
- name: 'Checkout source code'
2626
uses: actions/checkout@v3
2727

28-
# Install PMD
29-
- name: 'Install PMD'
28+
# Install Latest PMD
29+
- name: 'Install Latest PMD'
3030
run: |
3131
PMD_VERSION=$(curl -s https://api.github.com/repos/pmd/pmd/releases/latest | grep '.tag_name' | sed 's:.*/::' | sed 's:",::')
3232
wget https://github.com/pmd/pmd/releases/download/pmd_releases%2F$PMD_VERSION/pmd-dist-$PMD_VERSION-bin.zip
@@ -67,9 +67,9 @@ jobs:
6767
run: sf org login sfdx-url --sfdx-url-file ./DEVHUB_SFDX_URL.txt --alias devhub --set-default-dev-hub
6868

6969
# Add namespace to project config
70-
- name: Add namespace to project config
71-
run: |
72-
sed -i 's,"namespace": "","namespace": "LabsActionPlans",' sfdx-project.json
70+
# - name: Add namespace to project config
71+
# run: |
72+
# sed -i 's,"namespace": "","namespace": "LabsActionPlans",' sfdx-project.json
7373

7474
# Create scratch org
7575
- name: 'Create scratch org'
@@ -104,6 +104,6 @@ jobs:
104104
run: sf org delete scratch --no-prompt --target-org ActionPlans
105105

106106
# Remove namespace from project config
107-
- name: Remove namespace from project config
108-
run: |
109-
sed -i 's,"namespace": "LabsActionPlans","namespace": "",' sfdx-project.json
107+
# - name: Remove namespace from project config
108+
# run: |
109+
# sed -i 's,"namespace": "LabsActionPlans","namespace": "",' sfdx-project.json

pmd/deployRules.xml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@
308308
<!-- <rule ref="category/apex/errorprone.xml/OverrideBothEqualsAndHashcode" /> -->
309309

310310
<!-- VISUALFORCE RULES -->
311-
<rule ref="category/vf/security.xml/VfHtmlStyleTagXss" message="Dynamic EL content within URL in style tag should be URLENCODED or JSINHTMLENCODED as appropriate">
311+
<rule ref="category/visualforce/security.xml/VfHtmlStyleTagXss" message="Dynamic EL content within URL in style tag should be URLENCODED or JSINHTMLENCODED as appropriate">
312312
<!--
313313
<apex:page>
314314
<style>
@@ -324,12 +324,13 @@
324324
<priority>3</priority>
325325
</rule>
326326

327-
<!--Example <apex:outputText value="Potential XSS is {! here }" escape="false" /> -->
328-
<!-- <rule ref="category/vf/security.xml/VfUnescapeEl" message="Avoid unescaped user controlled content in EL as it results in XSS.">
327+
<!--Example
328+
<apex:outputText value="Potential XSS is {! here }" escape="false" /> -->
329+
<!-- <rule ref="category/visualforce/security.xml/VfUnescapeEl" message="Avoid unescaped user controlled content in EL as it results in XSS.">
329330
<priority>3</priority>
330331
</rule> -->
331332

332333
<!-- Error on apex:page action usage -->
333334
<!-- <apex:page controller="AcRestActionsController" action="{!csrfInitMethod}" > -->
334-
<rule ref="category/vf/security.xml/VfCsrf" />
335-
</ruleset>
335+
<rule ref="category/visualforce/security.xml/VfCsrf" />
336+
</ruleset>

sfdx-project.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"ancestorVersion": "HIGHEST",
1010
"releaseNotesUrl": "https://github.com/SalesforceLabs/ActionPlansV4/blob/main/README.md",
1111
"definitionFile": "config/install-scratch-def.json",
12-
"versionDescription": "Action Plans now suppports Tasks owned by Queues and Professional Edition",
12+
"versionDescription": "Action Plans now supports Tasks owned by Queues and Professional Edition",
1313
"postInstallScript": "ActionPlansPostInstallScript",
1414
"postInstallUrl": "https://salesforcelabs.github.io/ActionPlansV4/"
1515
},
@@ -20,7 +20,7 @@
2020
"name": "Action Plans",
2121
"namespace": "",
2222
"sfdcLoginUrl": "https://login.salesforce.com",
23-
"sourceApiVersion": "56.0",
23+
"sourceApiVersion": "65.0",
2424
"packageAliases": {
2525
"Action Plans": "0Ho5f000000oLlrCAE",
2626
"ActionPlans": "0Ho5f000000oLlrCAE",

sfdx-source/LabsActionPlans/main/default/classes/ActionPlanCreateInvocable.cls

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,19 @@ SPDX-License-Identifier: BSD-3-Clause
1414
For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
1515
*/
1616
/**
17+
* Invocable class for creating Action Plans from templates.
18+
*
19+
* This class uses `inherited sharing` to respect the calling context's sharing rules:
20+
* - When invoked from Flows/Process Builder (system context), it executes without sharing restrictions
21+
* - When invoked from Apex code with sharing rules, it respects those rules
22+
*
23+
* This approach provides flexibility for automation while maintaining security when called from user context.
24+
*
1725
* @group Invocable
1826
* @author {@link [David Schach](https://github.com/dschach)}
1927
* @since 2022
2028
*/
21-
global without sharing class ActionPlanCreateInvocable {
29+
global inherited sharing class ActionPlanCreateInvocable {
2230
/**
2331
* Invocable Apex for creating Action Plans from a template, a parent ID, and days from now to start the task due dates
2432
* @param requests Wrapper of `CreateActionPlanRequest`
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
3-
<apiVersion>62.0</apiVersion>
3+
<apiVersion>65.0</apiVersion>
44
<status>Active</status>
55
</ApexClass>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
3-
<apiVersion>62.0</apiVersion>
3+
<apiVersion>65.0</apiVersion>
44
<status>Active</status>
55
</ApexClass>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
3-
<apiVersion>62.0</apiVersion>
3+
<apiVersion>65.0</apiVersion>
44
<status>Active</status>
55
</ApexClass>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
3-
<apiVersion>62.0</apiVersion>
3+
<apiVersion>65.0</apiVersion>
44
<status>Active</status>
55
</ApexClass>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
3-
<apiVersion>62.0</apiVersion>
3+
<apiVersion>65.0</apiVersion>
44
<status>Active</status>
55
</ApexClass>

0 commit comments

Comments
 (0)