-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathsfdx-scanner-appexchange-ruleset.xml
607 lines (569 loc) · 29.6 KB
/
sfdx-scanner-appexchange-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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
<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.xpath.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">
<description>Detects where System.setPassword() exists in Apex code. Use this method with caution.</description>
<priority>1</priority>
<properties>
<property name="xpath">
<value>
<![CDATA[
//MethodCallExpression[
lower-case(@FullMethodName) = lower-case("System.setPassword") or
lower-case(@FullMethodName) = lower-case("setPassword")
]
]]>
</value>
</property>
</properties>
</rule>
<!--AvoidCallingSystemResetPasswordWithEmailTemplate-->
<rule language="apex" class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" name="AvoidCallingSystemResetPasswordWithEmailTemplate" message="Before calling System.resetPasswordWithEmailTemplate(), perform the necessary authorization checks." externalInfoUrl="https://github.com/forcedotcom/sfdx-scanner/blob/dev/pmd-appexchange/docs/AvoidCallingSystemResetPasswordWithEmailTemplate.md">
<description>Detects where System.resetPasswordWithEmailTemplate() exists in Apex code. Use this method with caution.</description>
<priority>1</priority>
<properties>
<property name="xpath">
<value>
<![CDATA[
//MethodCallExpression[
lower-case(@FullMethodName) = lower-case("System.resetPasswordWithEmailTemplate") or
lower-case(@FullMethodName) = lower-case("resetPasswordWithEmailTemplate")
]
]]>
</value>
</property>
</properties>
</rule>
<!--AvoidUnsafeSystemMovePassword-->
<rule language="apex" externalInfoUrl="https://github.com/forcedotcom/sfdx-scanner/blob/dev/pmd-appexchange/docs/AvoidUnsafeSystemMovePassword.md" class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" name="AvoidUnsafeSystemMovePassword" message="Before calling System.movePassword(), perform the necessary authorization checks.">
<description>Detects where System.movePassword() is used in Apex code. Use this method with caution.</description>
<priority>1</priority>
<properties>
<property name="xpath">
<value>
<![CDATA[
//MethodCallExpression[
lower-case(@FullMethodName) = lower-case("System.movePassword") or
lower-case(@FullMethodName) = lower-case("movePassword")
]
]]>
</value>
</property>
</properties>
</rule>
<!--AvoidChangeProtectionUnprotected-->
<rule language="apex" externalInfoUrl="https://github.com/forcedotcom/sfdx-scanner/blob/dev/pmd-appexchange/docs/AvoidChangeProtectionUnprotected.md" class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" name="AvoidChangeProtectionUnprotected" message="Update your code to avoid using FeatureManagement.changeProtection called by an UnProtected argument.">
<!-- TBD
May be use only one rule? "SFCustom-DangerousMethod-changeProtection"
-->
<description>Detects potential misuse of FeatureManagement.changeProtection.</description>
<priority>1</priority>
<properties>
<property name="xpath">
<value>
<![CDATA[
//MethodCallExpression[
lower-case(@FullMethodName)=lower-case("FeatureManagement.changeProtection") or
lower-case(@FullMethodName)=lower-case("System.FeatureManagement.changeProtection")
]
//LiteralExpression[lower-case(@Image)=lower-case("Unprotected")]//ancestor::MethodCallExpression
]]>
</value>
</property>
</properties>
</rule>
<!--AvoidUnauthorizedGetSessionIdInApex-->
<rule language="apex" class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" name="AvoidUnauthorizedGetSessionIdInApex" message="Use of UserInfo.getSessionId might not be authorized." externalInfoUrl="https://github.com/forcedotcom/sfdx-scanner/blob/dev/pmd-appexchange/docs/AvoidUnauthorizedGetSessionIdInApex.md">
<!--
TBD: Add extUrlInfo
Add links to OAuth Workflows
-->
<description>Detects use of UserInfo.getSessionId() to retrieve a session ID.</description>
<priority>3</priority>
<properties>
<property name="xpath">
<value>
<![CDATA[
//MethodCallExpression[upper-case(@FullMethodName)="SYSTEM.USERINFO.GETSESSIONID"
or upper-case(@FullMethodName) = "USERINFO.GETSESSIONID"
]
]]>
</value>
</property>
</properties>
</rule>
<!--AvoidUnsafeSystemResetPassword-->
<rule language="apex" class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" name="AvoidUnsafeSystemResetPassword" message="Before calling System.resetPassword(), perform the necessary authorization checks." externalInfoUrl="https://github.com/forcedotcom/sfdx-scanner/blob/dev/pmd-appexchange/docs/AvoidUnsafeSystemResetPassword.md">
<description>Detects where System.resetPassword() exists in Apex code. Use this method with caution.</description>
<priority>1</priority>
<properties>
<property name="xpath">
<value>
<![CDATA[
//MethodCallExpression[
lower-case(@FullMethodName) = lower-case("System.resetPassword") or
lower-case(@FullMethodName) = lower-case("resetPassword")
]
]]>
</value>
</property>
</properties>
</rule>
<!--AvoidWithoutSharingInRestApiController-->
<rule language="apex" class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" name="AvoidWithoutSharingInRestApiController" message="Use "with sharing" in Apex classes with the @RestResource annotation." externalInfoUrl="https://github.com/forcedotcom/sfdx-scanner/blob/dev/pmd-appexchange/docs/AvoidWithoutSharingInRestApiController.md">
<description>Detects use of "without sharing" in an Apex class exposed with the @RestResource annotation.</description>
<priority>2</priority>
<properties>
<property name="xpath">
<value>
<![CDATA[
if (./ModifierNode/Annotation[@Image = "RestResource"])
then
./ModifierNode[@WithSharing = false() and @InheritedSharing = false()]
else
false
]]>
</value>
</property>
</properties>
</rule>
<!--AvoidHardcodedCredentials-->
<rule language="apex" class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="https://github.com/forcedotcom/sfdx-scanner/blob/dev/pmd-appexchange/docs/AvoidHardcodedCredentials.md" name="AvoidHardcodedCredentials" message="Remove hard-coded credentials from source code.">
<description>Identifies hard-coded credentials in source code that must be protected using Protected Custom metadata or Protected Custom settings.</description>
<priority>3</priority>
<properties>
<property name="xpath">
<value>
<!--
Intentionally ignored others in the //LiteralExpression query
-->
<![CDATA[
//VariableDeclaration[
(upper-case(@Image)="KEY") or (upper-case(@Image)="ACCESSKEY") or (upper-case(@Image)="APIKEY") or
(upper-case(@Image)="PASS") or (upper-case(@Image)="PASSWORD") or (upper-case(@Image)="ENCRYPTION") or
(upper-case(@Image)="TOKEN") or (upper-case(@Image)="SECRET") or (upper-case(@Image)="HASH")
or (upper-case(@Image)="API_KEY") or (upper-case(@Image)="ACCESS_KEY") or (upper-case(@Image)="ACCESS_TOKEN") or
(upper-case(@Image)="ENC_KEY")
]/LiteralExpression |
//VariableExpression[
(upper-case(@Image)="KEY") or (upper-case(@Image)="_ACCESSKEY") or (upper-case(@Image)="APIKEY") or
(upper-case(@Image)="PASS") or (upper-case(@Image)="PASSWORD") or (upper-case(@Image)="ENCRYPTION") or
(upper-case(@Image)="TOKEN") or (upper-case(@Image)="SECRET") or (upper-case(@Image)="HASH")
or (upper-case(@Image)="API_KEY") or (upper-case(@Image)="ACCESS_KEY") or (upper-case(@Image)="ACCESS_TOKEN") or
(upper-case(@Image)="ENC_KEY")
]/ancestor::AssignmentExpression/LiteralExpression |
//VariableExpression[
(upper-case(@Image)="KEY") or (upper-case(@Image)="_ACCESSKEY") or (upper-case(@Image)="APIKEY") or
(upper-case(@Image)="PASS") or (upper-case(@Image)="PASSWORD") or (upper-case(@Image)="ENCRYPTION") or
(upper-case(@Image)="TOKEN") or (upper-case(@Image)="SECRET") or (upper-case(@Image)="HASH")
or (upper-case(@Image)="API_KEY") or (upper-case(@Image)="ACCESS_KEY") or (upper-case(@Image)="ACCESS_TOKEN") or
(upper-case(@Image)="ENC_KEY")
] /ancestor::AssignmentExpression/TernaryExpression/LiteralExpression
|
//LiteralExpression[
contains(upper-case(@Image),"APIKEY") or contains(upper-case(@Image),"ACCESSKEY") or contains(upper-case(@Image),"ACCESSTOKEN")
or contains(upper-case(@Image),"PASSWORD") or contains(upper-case(@Image),"SECRET")
or contains(upper-case(@Image),"API_KEY") or contains(upper-case(@Image),"ACCESS_KEY") or contains(upper-case(@Image),"ACCESS_TOKEN")
or contains(upper-case(@Image),"API-KEY")
]
]]>
</value>
</property>
</properties>
</rule>
<!--LimitPermissionSetAssignment-->
<rule language="apex" externalInfoUrl="https://github.com/forcedotcom/sfdx-scanner/blob/dev/pmd-appexchange/docs/LimitPermissionSetAssignment.md" class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" name="LimitPermissionSetAssignment" message="Ensure that DML operations against PermissionSetAssignment use trusted input.">
<description>Detects usage of PermissionSetAssignment. Use caution when allowing DML operations against the PermissionSetAssignment object.</description>
<priority>2</priority>
<properties>
<property name="xpath">
<value>
<![CDATA[
//*[local-name()="VariableDeclaration" or local-name() = "AssignmentExpression"]//*
[local-name()="NewKeyValueObjectExpression" or
local-name() = "NewListInitExpression" or
local-name() = "NewObjectExpression"
]
[@*
[local-name()="Type"
and
(upper-case(.)=upper-case("PermissionSetAssignment") or upper-case(.)=upper-case("List<PermissionSetAssignment>"))
]
]
/
ancestor::*[local-name()="VariableDeclaration" or local-name()="AssignmentExpression"]
]]>
</value>
</property>
</properties>
</rule>
<!--AvoidChangeProtection-->
<rule language="apex" externalInfoUrl="https://github.com/forcedotcom/sfdx-scanner/blob/dev/pmd-appexchange/docs/AvoidChangeProtection.md" class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" name="AvoidChangeProtection" message="Update your code to avoid using FeatureManagement.changeProtection.">
<description>Detects potential misuse of FeatureManagement.changeProtection.</description>
<priority>2</priority>
<properties>
<property name="xpath">
<value>
<![CDATA[
//MethodCallExpression[
lower-case(@FullMethodName)=lower-case("FeatureManagement.changeProtection") or
lower-case(@FullMethodName)=lower-case("System.FeatureManagement.changeProtection")
]/child::*[4][local-name()!="LiteralExpression"]
]]>
</value>
</property>
</properties>
</rule>
<!--AvoidUnauthorizedApiSessionIdInApex-->
<rule language="apex" class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" name="AvoidUnauthorizedApiSessionIdInApex" message="Use of API.Session_ID might not be authorized." externalInfoUrl="https://github.com/forcedotcom/sfdx-scanner/blob/dev/pmd-appexchange/docs/AvoidUnauthorizedApiSessionIdInApex.md">
<description>Detects use of Api.Session_ID to retrieve a session ID.</description>
<priority>2</priority>
<properties>
<property name="xpath">
<value>
<![CDATA[
//LiteralExpression[
contains(upper-case(@Image),upper-case("{!API.Session_ID}"))
]
]]>
</value>
</property>
</properties>
</rule>
<!-- VISUALFORCE RULES -->
<!--AvoidUnauthorizedGetSessionIdInVisualforce-->
<rule language="vf" class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" name="AvoidUnauthorizedGetSessionIdInVisualforce" message="Use of session ID with GETSESSIONID is not authorized." externalInfoUrl="https://github.com/forcedotcom/sfdx-scanner/blob/dev/pmd-appexchange/docs/AvoidUnauthorizedGetSessionIdInVisualforce.md">
<description>Detects use of GETSESSIONID() to retrieve a session ID in Visualforce code.</description>
<priority>2</priority>
<properties>
<property name="version" value="2.0"/>
<property name="xpath">
<value>
<![CDATA[
//Expression/Identifier[upper-case(@Image)="GETSESSIONID"]/parent::Expression/Arguments/parent::Expression
]]>
</value>
</property>
</properties>
</rule>
<!--AvoidUnauthorizedApiSessionIdVisualforce-->
<rule language="vf" class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" name="AvoidUnauthorizedApiSessionIdVisualforce" message="Retrieval of session ID using API.Session_ID is not authorized." externalInfoUrl="https://github.com/forcedotcom/sfdx-scanner/blob/dev/pmd-appexchange/docs/AvoidUnauthorizedApiSessionIdVisualforce.md">
<description>Detects use of Api.Session_ID to retrieve a session ID in Visualforce code.</description>
<priority>3</priority>
<properties>
<property name="version" value="2.0"/>
<property name="xpath">
<value>
<![CDATA[
//Expression/Identifier[upper-case(@Image)="$API"]/parent::Expression/
DotExpression/Identifier[upper-case(@Image)="SESSION_ID"]/parent::DotExpression/parent::Expression
]]>
</value>
</property>
</properties>
</rule>
<!--AvoidUnauthorizedGetSessionIdInVisualforce-->
<rule language="visualforce" class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" name="AvoidUnauthorizedGetSessionIdInVisualforce" message="Use of session ID with GETSESSIONID is not authorized." externalInfoUrl="https://github.com/forcedotcom/sfdx-scanner/blob/dev/pmd-appexchange/docs/AvoidUnauthorizedGetSessionIdInVisualforce.md">
<description>Detects use of GETSESSIONID() to retrieve a session ID in Visualforce code.</description>
<priority>2</priority>
<properties>
<property name="xpath">
<value>
<![CDATA[
//Expression/Identifier[upper-case(@Image)="GETSESSIONID"]/parent::Expression/Arguments/parent::Expression
]]>
</value>
</property>
</properties>
</rule>
<!--AvoidUnauthorizedApiSessionIdVisualforce-->
<rule language="visualforce" class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" name="AvoidUnauthorizedApiSessionIdVisualforce" message="Retrieval of session ID using API.Session_ID is not authorized." externalInfoUrl="https://github.com/forcedotcom/sfdx-scanner/blob/dev/pmd-appexchange/docs/AvoidUnauthorizedApiSessionIdVisualforce.md">
<description>Detects use of Api.Session_ID to retrieve a session ID in Visualforce code.</description>
<priority>3</priority>
<properties>
<property name="xpath">
<value>
<![CDATA[
//Expression/Identifier[upper-case(@Image)="$API"]/parent::Expression/
DotExpression/Identifier[upper-case(@Image)="SESSION_ID"]/parent::DotExpression/parent::Expression
]]>
</value>
</property>
</properties>
</rule>
<!-- JAVASCRIPT -->
<!--AvoidLwcBubblesComposedTrue-->
<rule language="ecmascript" externalInfoUrl="https://github.com/forcedotcom/sfdx-scanner/blob/dev/pmd-appexchange/docs/AvoidLwcBubblesComposedTrue.md" class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" name="AvoidLwcBubblesComposedTrue" message="Avoid setting both Lightning Web component bubbles and composed=true at the same time.">
<description>Detects Lightning Web Component event configurations where bubbles and composed are both set to true. To avoid sharing sensitive information unintentionally, use this configuration with caution.</description>
<priority>3</priority>
<properties>
<property name="xpath">
<value>
<![CDATA[
//ObjectLiteral[
ObjectProperty/Name[@Image="bubbles"]/parent::ObjectProperty/KeywordLiteral[@Image="true"]
and
ObjectProperty/Name[@Image="composed"]/parent::ObjectProperty/KeywordLiteral[@Image="true"]
]
]]>
</value>
</property>
</properties>
</rule>
<!-- HTML -->
<!--UseLwcDomManual-->
<rule language="html" class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="https://github.com/forcedotcom/sfdx-scanner/blob/dev/pmd-appexchange/docs/UseLwcDomManual.md" name="UseLwcDomManual" message="Protect against XSS when using lwc:dom="manual".">
<description>Detects instances of lwc:dom="manual" that could allow unintentional or malicious user input. Don't allow user input on these elements.</description>
<priority>3</priority>
<example>
<![CDATA[
<template><div class="chart slds-var-m-around_medium slds-theme_default cursor" lwc:dom="manual"></div></template>
&
If template has a direct user input. Then XSS is possible.
]]>
</example>
<properties>
<property name="xpath">
<value>
<![CDATA[
//*[@*[local-name()="lwc:dom" and .="manual"]]
]]>
</value>
</property>
</properties>
</rule>
<!-- Metadata XML -->
<!--AvoidLmcIsExposedTrue-->
<rule language="xml" class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" name="AvoidLmcIsExposedTrue" message="Use Lightning Message Channel with isExposed set to false." externalInfoUrl="https://github.com/forcedotcom/sfdx-scanner/blob/dev/pmd-appexchange/docs/AvoidLmcIsExposedTrue.md">
<description>Detects a Lightning Message Channel with isExposed=true, which isn’t allowed in managed packages.</description>
<priority>2</priority>
<properties>
<property name="xpath">
<value>
<![CDATA[
/LightningMessageChannel/isExposed/text[@Image="true"]
]]>
</value>
</property>
</properties>
</rule>
<!--AvoidApiSessionId-->
<rule language="xml" class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" name="AvoidApiSessionId" message="Session ID use is not approved." externalInfoUrl="https://github.com/forcedotcom/sfdx-scanner/blob/dev/pmd-appexchange/docs/AvoidApiSessionId.md">
<!--
TBD: Add extUrlInfo
Add links to OAuth Workflows
-->
<description>Detects use of Api.Session_ID to retrieve a session ID.</description>
<priority>2</priority>
<properties>
<property name="xpath">
<value>
<![CDATA[
//text[
contains(upper-case(@Image),"API.SESSION_ID")
or
contains(upper-case(@Image),"GETSESSIONID")
]/..
]]>
</value>
</property>
</properties>
</rule>
<!--UpgradeLwcLockerSecuritySupport-->
<rule language="xml" class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" name="UpgradeLwcLockerSecuritySupport" message="To enable Lightning Locker, update the API version to version 40 or greater." externalInfoUrl="https://github.com/forcedotcom/sfdx-scanner/blob/dev/pmd-appexchange/docs/UpgradeLwcLockerSecuritySupport.md">
<description>Detects use of API versions with Lightning Locker disabled. Use API version 40 or greater.</description>
<priority>1</priority>
<properties>
<property name="xpath">
<value>
<!--
This may not be needed; as LWC is available only from version 46!
https://developer.salesforce.com/docs/component-library/documentation/en/lwc/lwc.security_locker_api_setting
-->
<![CDATA[
/LightningComponentBundle/apiVersion/text[number(@Image) lt 40]
]]>
</value>
</property>
</properties>
</rule>
<!--AvoidUnauthorizedApiSessionIdInFlows-->
<rule language="xml" class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" name="AvoidUnauthorizedApiSessionIdInFlows" message="$Api.Session_ID usage is not approved." externalInfoUrl="https://github.com/forcedotcom/sfdx-scanner/blob/dev/pmd-appexchange/docs/AvoidUnauthorizedApiSessionIdInFlows.md">
<description>Detects use of session ID in SOAP API calls in flows.</description>
<priority>2</priority>
<properties>
<property name="xpath">
<value>
<![CDATA[
/Flow//elementReference/text[upper-case(@Image)="$API.SESSION_ID"]
]]>
</value>
</property>
</properties>
</rule>
<!--UseHttpsCallbackUrl-->
<rule language="xml" class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" name="UseHttpsCallbackUrl" message="Update to secure Oauth callback URL over HTTPS." externalInfoUrl="https://github.com/forcedotcom/sfdx-scanner/blob/dev/pmd-appexchange/docs/UseHttpsCallbackUrl.md">
<description>Detects instances of an OAuth callback URL that uses HTTP. Use HTTPS instead.</description>
<priority>3</priority>
<properties>
<property name="xpath">
<value>
<![CDATA[
/ConnectedApp/oauthConfig/callbackUrl/text[contains(lower-case(@Image),"http://")]
]]>
</value>
</property>
</properties>
</rule>
<!--AvoidJsLinksInCustomObject-->
<rule language="xml" class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" name="AvoidJsLinksInCustomObject" message="Avoid clickable JavaScript-style URLs." externalInfoUrl="https://github.com/forcedotcom/sfdx-scanner/blob/dev/pmd-appexchange/docs/AvoidJsLinksInCustomObject.md">
<description>Detects instances of JavaScript-style URLs (javascript:) in Salesforce DOM components, such as web links and buttons. Avoid JavaScript-style URLs in managed packages.</description>
<priority>1</priority>
<properties>
<property name="xpath">
<value>
<![CDATA[
/CustomObject//url/text[contains(upper-case(@Image),"JAVASCRIPT:")]/..
]]>
</value>
</property>
</properties>
</rule>
<!--AvoidJavaScriptWeblink-->
<rule language="xml" externalInfoUrl="https://github.com/forcedotcom/sfdx-scanner/blob/dev/pmd-appexchange/docs/AvoidJavaScriptWeblink.md" class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" name="AvoidJavaScriptWeblink" message="Avoid using JavaScript in web links.">
<description>Detects use of custom JavaScript actions in web links.</description>
<priority>2</priority>
<properties>
<property name="xpath">
<value>
<![CDATA[
/CustomPageWebLink/openType/text[@Image="onClickJavaScript"]/..
]]>
</value>
</property>
</properties>
</rule>
<!--LimitConnectedAppScope-->
<rule language="xml" class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" name="LimitConnectedAppScope" message="Update the connected app request to limited scope instead of full scope." externalInfoUrl="https://github.com/forcedotcom/sfdx-scanner/blob/dev/pmd-appexchange/docs/LimitConnectedAppScope.md">
<description>Detects if a connected app uses full scope. Explain this use case in your AppExchange security review submission.</description>
<priority>3</priority>
<!--
TBD: What if the developer chooses ALL the scopes instead of just full??
Create an issue for this
-->
<properties>
<property name="xpath">
<value>
<![CDATA[
/ConnectedApp/oauthConfig/scopes/text[upper-case(@Image)="FULL"]
]]>
</value>
</property>
</properties>
</rule>
<!--AvoidSystemModeInFlows-->
<rule language="xml" class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="https://github.com/forcedotcom/sfdx-scanner/blob/dev/pmd-appexchange/docs/AvoidSystemModeInFlows.md" name="AvoidSystemModeInFlows" message="Reconfigure to avoid running flows in system mode.">
<description>Detects where default mode must be used in flows instead of system mode.</description>
<priority>3</priority>
<properties>
<property name="xpath">
<value>
<![CDATA[
(/Flow/runInMode/text[@Image="SystemModeWithoutSharing"] | /Flow/runInMode/text[@Image="SystemModeWithSharing"])
]]>
</value>
</property>
</properties>
</rule>
<!--AvoidJavaScriptHomePageComponent-->
<rule language="xml" externalInfoUrl="https://github.com/forcedotcom/sfdx-scanner/blob/dev/pmd-appexchange/docs/AvoidJavaScriptHomePageComponent.md" class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" name="AvoidJavaScriptHomePageComponent" message="Avoid JavaScript in a home page component body.">
<description>Detects use of custom JavaScript actions in home page components.</description>
<priority>2</priority>
<properties>
<property name="xpath">
<value>
<![CDATA[
/HomePageComponent/body/text[contains(upper-case(@Image),upper-case('<script '))
or
contains(upper-case(@Image),upper-case('javascript:'))
]
]]>
</value>
</property>
</properties>
</rule>
<!--ProtectSensitiveData-->
<rule language="xml" class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" externalInfoUrl="https://github.com/forcedotcom/sfdx-scanner/blob/dev/pmd-appexchange/docs/ProtectSensitiveData.md" name="ProtectSensitiveData" message="To store secrets, use Protected Custom settings or Protected Custom metadata.">
<description>Detects where sensitive data must be stored with Protected Custom metadata or Protected Custom settings.</description>
<priority>3</priority>
<properties>
<property name="xpath">
<value>
<![CDATA[
(
//CustomObject/visibility/text[@Image="Public"]
/ancestor::CustomObject/customSettingsType/ancestor::CustomObject/fields/fullName/text
[contains(upper-case(@Image), "KEY") or contains(upper-case(@Image),"ACCESSKEY") or
contains(upper-case(@Image),"PASS") or contains(upper-case(@Image),"PASSWORD") or contains(upper-case(@Image),"ENCRYPT") or
contains(upper-case(@Image),"TOKEN") or contains(upper-case(@Image),"SECRET") or contains(upper-case(@Image),"HASH")]
)
|
(
//CustomObject/visibility/text[@Image="Public"]
/ancestor::CustomObject/fields/fullName/text
[contains(upper-case(@Image),"KEY") or contains(upper-case(@Image),"ACCESSKEY") or
contains(upper-case(@Image),"PASS") or contains(upper-case(@Image),"PASSWORD") or contains(upper-case(@Image),"ENCRYPT") or
contains(upper-case(@Image),"TOKEN") or contains(upper-case(@Image),"SECRET") or contains(upper-case(@Image),"HASH")]
)
]]>
</value>
</property>
</properties>
</rule>
<!--AvoidJsLinksInWebLinks-->
<rule language="xml" class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" name="AvoidJsLinksInWebLinks" message="Avoid clickable JavaScript-style URLs." externalInfoUrl="https://github.com/forcedotcom/sfdx-scanner/blob/dev/pmd-appexchange/docs/AvoidJsLinksInWebLinks.md">
<description>Detects instances of JavaScript-style URLs (javascript:) in Salesforce DOM components, such as web links and buttons. Avoid JavaScript-style URLs in managed packages.</description>
<priority>1</priority>
<properties>
<property name="xpath">
<value>
<![CDATA[
/CustomPageWebLink/url/text[contains(upper-case(@Image),"JAVASCRIPT:")]/..
]]>
</value>
</property>
</properties>
</rule>
<!--AvoidJavaScriptCustomRule-->
<rule language="xml" externalInfoUrl="https://github.com/forcedotcom/sfdx-scanner/blob/dev/pmd-appexchange/docs/AvoidJavaScriptCustomRule.md" class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" name="AvoidJavaScriptCustomRule" message="Avoid using JavaScript to execute custom button actions.">
<description>Detects use of custom JavaScript actions in custom rules.</description>
<priority>2</priority>
<properties>
<property name="xpath">
<value>
<![CDATA[
/CustomObject/webLinks/openType/text[@Image="onClickJavaScript"]/..
]]>
</value>
</property>
</properties>
</rule>
<!--AvoidAuraWithLockerDisabled-->
<rule language="xml" class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" name="AvoidAuraWithLockerDisabled" message="To enable Lightning Locker, update the apiVersion to version 40 or greater." externalInfoUrl="https://github.com/forcedotcom/sfdx-scanner/blob/dev/pmd-appexchange/docs/AvoidAuraWithLockerDisabled.md">
<description>Detects use of API versions with Lightning Locker disabled in Aura components. Use API version 40 or greater.</description>
<priority>1</priority>
<properties>
<property name="xpath">
<value>
<![CDATA[
/AuraDefinitionBundle/apiVersion/text[number(@Image) lt 40]
]]>
</value>
</property>
</properties>
</rule>
</ruleset>