-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
NEW(pmd): @W-17310939@: Add in 3 more AppExchange rules: AvoidApiSess…
…ionId, AvoidAuraWithLockerDisabled, AvoidDisableProtocolSecurity
- Loading branch information
1 parent
1e32050
commit 44dfc10
Showing
11 changed files
with
289 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
...d-engine/pmd-rules/src/test/java/sfca/rulesets/appexchange_xml/AvoidApiSessionIdTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package sfca.rulesets.appexchange_xml; | ||
|
||
import net.sourceforge.pmd.test.SimpleAggregatorTst; | ||
|
||
public class AvoidApiSessionIdTest extends SimpleAggregatorTst { | ||
@Override | ||
protected void setUp() { | ||
// The test data xml file for this rule's test will always be in the resources directory using a naming | ||
// convention based off the package for this test and the rule being tested: | ||
// "resources/<TestPackageName>/xml/<RuleName>.xml". | ||
// In this case "sfca.rulesets.appexchange_xml" is the package name of this test file. Thus, the associated test | ||
// data xml file for this rule must be found at: | ||
// "resource/sfca/rulesets/appexchange_xml/xml/AvoidApiSessionId.xml" | ||
addRule("sfca/rulesets/AppExchange_xml.xml", "AvoidApiSessionId"); | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
...md-rules/src/test/java/sfca/rulesets/appexchange_xml/AvoidAuraWithLockerDisabledTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package sfca.rulesets.appexchange_xml; | ||
|
||
import net.sourceforge.pmd.test.SimpleAggregatorTst; | ||
|
||
public class AvoidAuraWithLockerDisabledTest extends SimpleAggregatorTst { | ||
@Override | ||
protected void setUp() { | ||
// The test data xml file for this rule's test will always be in the resources directory using a naming | ||
// convention based off the package for this test and the rule being tested: | ||
// "resources/<TestPackageName>/xml/<RuleName>.xml". | ||
// In this case "sfca.rulesets.appexchange_xml" is the package name of this test file. Thus, the associated test | ||
// data xml file for this rule must be found at: | ||
// "resource/sfca/rulesets/appexchange_xml/xml/AvoidAuraWithLockerDisabled.xml" | ||
addRule("sfca/rulesets/AppExchange_xml.xml", "AvoidAuraWithLockerDisabled"); | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
...d-rules/src/test/java/sfca/rulesets/appexchange_xml/AvoidDisableProtocolSecurityTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package sfca.rulesets.appexchange_xml; | ||
|
||
import net.sourceforge.pmd.test.SimpleAggregatorTst; | ||
|
||
public class AvoidDisableProtocolSecurityTest extends SimpleAggregatorTst { | ||
@Override | ||
protected void setUp() { | ||
// The test data xml file for this rule's test will always be in the resources directory using a naming | ||
// convention based off the package for this test and the rule being tested: | ||
// "resources/<TestPackageName>/xml/<RuleName>.xml". | ||
// In this case "sfca.rulesets.appexchange_xml" is the package name of this test file. Thus, the associated test | ||
// data xml file for this rule must be found at: | ||
// "resource/sfca/rulesets/appexchange_xml/xml/AvoidDisableProtocolSecurity.xml" | ||
addRule("sfca/rulesets/AppExchange_xml.xml", "AvoidDisableProtocolSecurity"); | ||
} | ||
} |
58 changes: 58 additions & 0 deletions
58
...gine/pmd-rules/src/test/resources/sfca/rulesets/appexchange_xml/xml/AvoidApiSessionId.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<test-data | ||
xmlns="http://pmd.sourceforge.net/rule-tests" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://pmd.sourceforge.net/rule-tests https://pmd.sourceforge.net/rule-tests_1_0_0.xsd"> | ||
|
||
<test-code> | ||
<description>When custom object weblinks use GETSESSIONID(), then report violation</description> | ||
<expected-problems>1</expected-problems> | ||
<expected-linenumbers>6</expected-linenumbers> | ||
<code><![CDATA[ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<CustomObject xmlns="http://soap.sforce.com/2006/04/metadata"> | ||
<!-- ... --> | ||
<webLinks> | ||
<!-- ... --> | ||
<url>{!REQUIRESCRIPT('/soap/ajax/26.0/connection.js')} | ||
sforce.connection.sessionId = '{!GETSESSIONID()}'; | ||
</url> | ||
</webLinks> | ||
</CustomObject> | ||
]]></code> | ||
</test-code> | ||
|
||
<test-code> | ||
<description>When custom object weblinks use API.Session_Id, then report violation</description> | ||
<expected-problems>1</expected-problems> | ||
<expected-linenumbers>6</expected-linenumbers> | ||
<code><![CDATA[ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<CustomObject xmlns="http://soap.sforce.com/2006/04/metadata"> | ||
<!-- ... --> | ||
<webLinks> | ||
<!-- ... --> | ||
<url> | ||
/apex/something?id={!something__c.Id}&sessionId={!$Api.Session_ID}&instance={!$Api.Partner_Server_URL_260} | ||
</url> | ||
</webLinks> | ||
</CustomObject> | ||
]]></code> | ||
</test-code> | ||
|
||
<test-code> | ||
<description>When custom tab uses API.Session_Id, then report violation</description> | ||
<expected-problems>1</expected-problems> | ||
<expected-linenumbers>4</expected-linenumbers> | ||
<code><![CDATA[ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<CustomTab xmlns="http://soap.sforce.com/2006/04/metadata"> | ||
<!-- ... --> | ||
<url> | ||
https://test.example.com/dummy.ph?param1={!API.Enterprise_Server_URL_540}&sessionId={!API.Session_ID}&param2={!Organization.Name}&param3={!User.Email} | ||
</url> | ||
</CustomTab> | ||
]]></code> | ||
</test-code> | ||
|
||
</test-data> |
32 changes: 32 additions & 0 deletions
32
...ules/src/test/resources/sfca/rulesets/appexchange_xml/xml/AvoidAuraWithLockerDisabled.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<test-data | ||
xmlns="http://pmd.sourceforge.net/rule-tests" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://pmd.sourceforge.net/rule-tests https://pmd.sourceforge.net/rule-tests_1_0_0.xsd"> | ||
|
||
<test-code> | ||
<description>When AuraDefinitionBundle has version less than 40, then report violation</description> | ||
<expected-problems>1</expected-problems> | ||
<expected-linenumbers>3</expected-linenumbers> | ||
<code><![CDATA[ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<AuraDefinitionBundle xmlns="http://soap.sforce.com/2006/04/metadata"> | ||
<apiVersion>39.0</apiVersion> | ||
<!-- ... --> | ||
</AuraDefinitionBundle> | ||
]]></code> | ||
</test-code> | ||
|
||
<test-code> | ||
<description>When AuraDefinitionBundle has version greater than 40, then do not report violation</description> | ||
<expected-problems>0</expected-problems> | ||
<code><![CDATA[ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<AuraDefinitionBundle xmlns="http://soap.sforce.com/2006/04/metadata"> | ||
<apiVersion>53.0</apiVersion> | ||
<!-- ... --> | ||
</AuraDefinitionBundle> | ||
]]></code> | ||
</test-code> | ||
|
||
</test-data> |
32 changes: 32 additions & 0 deletions
32
...les/src/test/resources/sfca/rulesets/appexchange_xml/xml/AvoidDisableProtocolSecurity.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<test-data | ||
xmlns="http://pmd.sourceforge.net/rule-tests" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://pmd.sourceforge.net/rule-tests https://pmd.sourceforge.net/rule-tests_1_0_0.xsd"> | ||
|
||
<test-code> | ||
<description>When RemoteSite Setting Disable Protocol Security is true, then report violation</description> | ||
<expected-problems>1</expected-problems> | ||
<expected-linenumbers>3</expected-linenumbers> | ||
<code><![CDATA[ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<RemoteSiteSetting xmlns="http://soap.sforce.com/2006/04/metadata"> | ||
<disableProtocolSecurity>true</disableProtocolSecurity> | ||
<!-- ... --> | ||
</RemoteSiteSetting> | ||
]]></code> | ||
</test-code> | ||
|
||
<test-code> | ||
<description>When RemoteSite Setting Disable Protocol Security is false, then do not report violation</description> | ||
<expected-problems>0</expected-problems> | ||
<code><![CDATA[ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<RemoteSiteSetting xmlns="http://soap.sforce.com/2006/04/metadata"> | ||
<disableProtocolSecurity>false</disableProtocolSecurity> | ||
<!-- ... --> | ||
</RemoteSiteSetting> | ||
]]></code> | ||
</test-code> | ||
|
||
</test-data> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters