Skip to content

Commit 68cca2b

Browse files
committed
Check for usage of native Vaadin HTML
Fixes xdev-software/vaadin-addon-template#284
1 parent 4d8074f commit 68cca2b

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

.config/pmd/ruleset.xml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,4 +194,25 @@
194194
</rule>
195195

196196
<rule ref="category/java/security.xml"/>
197+
198+
<rule name="VaadinNativeHTMLUnsafe"
199+
language="java"
200+
message="Unescaped native HTML is unsafe and will result in XSS vulnerabilities"
201+
class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" >
202+
<description>
203+
Do not used native HTML! Use Vaadin layouts and components to create required structure.
204+
If you are 100% sure that you escaped the value properly and you have no better options you can suppress this.
205+
</description>
206+
<priority>2</priority>
207+
<properties>
208+
<property name="xpath">
209+
<value>
210+
<![CDATA[
211+
//ConstructorCall[pmd-java:typeIs('com.vaadin.flow.component.Html')] |
212+
//MethodCall[@MethodName='setAttribute' and //ImportDeclaration[starts-with(@PackageName,'com.vaadin')]]/ArgumentList/StringLiteral[1][contains(lower-case(@Image),'html')]
213+
]]>
214+
</value>
215+
</property>
216+
</properties>
217+
</rule>
197218
</ruleset>

0 commit comments

Comments
 (0)