-
Notifications
You must be signed in to change notification settings - Fork 32
/
ruleset.xml
178 lines (159 loc) · 8.82 KB
/
ruleset.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
<?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="My ruleset 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</description>
<!-- STANDARD RULES -->
<rule ref="category/apex/security.xml">
<priority>1</priority>
</rule>
<rule ref="category/apex/design.xml" />
<rule ref="category/apex/performance.xml">
<exclude name="AvoidDebugStatements" />
</rule>
<rule ref="category/apex/codestyle.xml" />
<rule ref="category/apex/bestpractices.xml">
<exclude name="ApexAssertionsShouldIncludeMessage" />
</rule>
<rule ref="category/apex/documentation.xml">
<exclude name="ApexDoc"/>
</rule>
<!-- CUSTOM APEX RULES -->
<rule name="AvoidProductionDebugLogs" language="apex" message="Avoid leaving System.debug() statments in code as they negativly influence performance." class="net.sourceforge.pmd.lang.rule.xpath.XPathRule">
<priority>3</priority>
<properties>
<property name="xpath">
<value>
<![CDATA[
//MethodCallExpression[@FullMethodName='System.debug'][count(*)=2]
]]>
</value>
</property>
</properties>
</rule>
<!-- CUSTOM SF METADATA RULES -->
<rule name="NoUnderscoresInFieldNames" language="xml" message="Custom fields should not contain underscores." class="net.sourceforge.pmd.lang.rule.xpath.XPathRule">
<properties>
<property name="xpath">
<value><![CDATA[
//CustomField/fullName/text[matches(@Image, ".*_.*__c")]
]]></value>
</property>
</properties>
</rule>
<rule name="CustomFieldNamingConvention" language="xml" message="Incorrectly named field" class="net.sourceforge.pmd.lang.rule.xpath.XPathRule">
<properties>
<property name="xpath">
<value><![CDATA[
//CustomField[
(fullName/text[not(matches(@Image, "chk_([A-Z][a-z0-9]+)+__c"))] and type/text[@Image="Checkbox"]) or
(fullName/text[not(matches(@Image, "txt_([A-Z][a-z0-9]+)+__c"))] and type/text[@Image="Text"]) or
(fullName/text[not(matches(@Image, "txa_([A-Z][a-z0-9]+)+__c"))] and type/text[@Image="Textarea"]) or
(fullName/text[not(matches(@Image, "txr_([A-Z][a-z0-9]+)+__c"))] and type/text[@Image="Richtext"]) or
(fullName/text[not(matches(@Image, "txl_([A-Z][a-z0-9]+)+__c"))] and type/text[@Image="LongTextArea"]) or
(fullName/text[not(matches(@Image, "num_([A-Z][a-z0-9]+)+__c"))] and type/text[@Image="Number"]) or
(fullName/text[not(matches(@Image, "dat_([A-Z][a-z0-9]+)+__c"))] and type/text[@Image="Date"]) or
(fullName/text[not(matches(@Image, "lkp_([A-Z][a-z0-9]+)+__c"))] and type/text[@Image="Lookup"]) or
(fullName/text[not(matches(@Image, "mdr_([A-Z][a-z0-9]+)+__c"))] and type/text[@Image="MasterDetail"]) or
(fullName/text[not(matches(@Image, "dtm_([A-Z][a-z0-9]+)+__c"))] and type/text[@Image="DateTime"]) or
(fullName/text[not(matches(@Image, "url_([A-Z][a-z0-9]+)+__c"))] and type/text[@Image="Url"]) or
(fullName/text[not(matches(@Image, "pkl_([A-Z][a-z0-9]+)+__c"))] and type/text[@Image="Picklist"]) or
(fullName/text[not(matches(@Image, "pkm_([A-Z][a-z0-9]+)+__c"))] and type/text[@Image="MultiselectPicklist"]) or
(fullName/text[not(matches(@Image, "cur_([A-Z][a-z0-9]+)+__c"))] and type/text[@Image="Currency"]) or
(fullName/text[not(matches(@Image, "pct_([A-Z][a-z0-9]+)+__c"))] and type/text[@Image="Percent"]) or
(fullName/text[not(matches(@Image, "fcur_([A-Z][a-z0-9]+)+__c"))] and type/text[@Image="Currency"] and formula) or
(fullName/text[not(matches(@Image, "rcnt_([A-Z][a-z0-9]+)+__c"))] and type/text[@Image="Summary"] and summaryOperation/text[@Image="count"])
]
]]></value>
</property>
</properties>
</rule>
<rule name="UnrestrictedPasswordPolicy" language="xml" message="It is a high security risk for any profile to have "No Restriction" as the password complexity requirement." class="net.sourceforge.pmd.lang.rule.xpath.XPathRule">
<priority>3</priority>
<properties>
<property name="xpath">
<value><![CDATA[
//SecuritySettings/passwordPolicies/complexity[ text[@Image='No restriction'] ]
]]> </value>
</property>
</properties>
</rule>
<rule name="TooShortPasswordPolicy" language="xml" message="The default value for the password length is 8 characters. Less than 8 characters is not secure." class="net.sourceforge.pmd.lang.rule.xpath.XPathRule">
<priority>3</priority>
<properties>
<property name="xpath">
<value><![CDATA[
//SecuritySettings/passwordPolicies/minimumPasswordLength[ text[@Image<'8'] ]
]]> </value>
</property>
</properties>
</rule>
<rule name="ModifyAllOnSysAdminProfile" language="xml" message="Only Admins can view and modify all data, if any other profile get these permissions, they could manipulate records that shouldn't" class="net.sourceforge.pmd.lang.rule.xpath.XPathRule">
<priority>3</priority>
<properties>
<property name="xpath">
<value><![CDATA[
//Profile/userPermissions[ name/text[@Image='ModifyAllData' or @Image='ViewAllData'] and enabled/text[@Image='true'] and pmd:fileName() != 'System Administrator' ]
]]> </value>
</property>
</properties>
</rule>
<rule name="ModifyAllOnPermSet" language="xml" message="Allowing this user permission can give access and ability to modify sensitive data." class="net.sourceforge.pmd.lang.rule.xpath.XPathRule">
<priority>3</priority>
<properties>
<property name="xpath">
<value><![CDATA[
//PermissionSet/userPermissions[ name/text[@Image='ModifyAllData'] and enabled/text[@Image='true'] ]
]]> </value>
</property>
</properties>
</rule>
<rule name="ViewAllOnPermSet" language="xml" message="Allowing this user permission can give access to sensitive data." class="net.sourceforge.pmd.lang.rule.xpath.XPathRule">
<priority>3</priority>
<properties>
<property name="xpath">
<value><![CDATA[
//PermissionSet/userPermissions[ name/text[@Image='ViewAllData'] and enabled/text[@Image='true'] ]
]]> </value>
</property>
</properties>
</rule>
<rule name="ManageUsersByNonSysAdmins" language="xml" message="Managing users need to be limited to System Administrator Profile only." class="net.sourceforge.pmd.lang.rule.xpath.XPathRule">
<priority>3</priority>
<properties>
<property name="xpath">
<value><![CDATA[
//Profile/userPermissions[ pmd:fileName() != 'System Administrator' and name/text[@Image='ManageUsers'] ]
]]> </value>
</property>
</properties>
</rule>
<rule name="TooLongSessionTimeout" language="xml" message="Allowing access to an inactive session for more than 12 hours is a security risk." class="net.sourceforge.pmd.lang.rule.xpath.XPathRule">
<priority>3</priority>
<properties>
<property name="xpath">
<value><![CDATA[
//SecuritySettings/sessionTimeout[ text[@Image='24 hours of inactivity'] or text[@Image='12 hours of inactivity'] ]
]]> </value>
</property>
</properties>
</rule>
<rule name="PasswordsNeverExpire" language="xml" message="Passwords need to expire every 90 days for security." class="net.sourceforge.pmd.lang.rule.xpath.XPathRule">
<priority>3</priority>
<properties>
<property name="xpath">
<value><![CDATA[
//SecuritySettings/passwordPolicies/expiration[ text[@Image='Never'] or text[@Image='SixMonths'] or text[@Image='OneYear'] ]
]]> </value>
</property>
</properties>
</rule>
<rule name="ViewSetupByNonSysAdmins" language="xml" message="Exposing the setup menu to non-authorized users." class="net.sourceforge.pmd.lang.rule.xpath.XPathRule">
<priority>3</priority>
<properties>
<property name="xpath">
<value><![CDATA[
//Profile/userPermissions[ pmd:fileName() != 'System Administrator' and enabled/text[@Image='true'] and name/text[@Image='ViewSetup'] ]
]]> </value>
</property>
</properties>
</rule>
</ruleset>