{"id":4535,"date":"2018-01-08T11:48:37","date_gmt":"2018-01-08T11:48:37","guid":{"rendered":"http:\/\/www.scmgalaxy.com\/tutorials\/?p=4535"},"modified":"2018-01-08T11:48:49","modified_gmt":"2018-01-08T11:48:49","slug":"sonar-support-with-jsp-html-2","status":"publish","type":"post","link":"https:\/\/www.devopsschool.com\/blog\/sonar-support-with-jsp-html-2\/","title":{"rendered":"Sonar Support with JSP &#038; HTML"},"content":{"rendered":"<p>JSP\/HTML land, usefull tests could be done via some regexp, ie check if style\/css are used (to avoid dirty colors\/fonts hard-coded for example).<\/p>\n<p>If we want to build something pretty robust and extensible, I think we should integrate a java library which is able to transform a XHTML or badly formatted HTML document into a DOM :<\/p>\n<p><a href=\"http:\/\/htmlparser.sourceforge.net\/\" rel=\"nofollow noopener\" target=\"_blank\">http:\/\/htmlparser.sourceforge.net\/<\/a><br \/>\n<a href=\"http:\/\/jtidy.sourceforge.net\/\" rel=\"nofollow noopener\" target=\"_blank\">http:\/\/jtidy.sourceforge.net\/<\/a><br \/>\n<a href=\"http:\/\/sourceforge.net\/projects\/nekohtml\/\" rel=\"nofollow noopener\" target=\"_blank\">http:\/\/sourceforge.net\/projects\/nekohtml\/<\/a><\/p>\n<p>a complete list of available libraries is available here :\u00a0<a href=\"http:\/\/java-source.net\/open-source\/html-parsers\" rel=\"nofollow noopener\" target=\"_blank\">http:\/\/java-source.net\/open-source\/html-parsers<\/a><\/p>\n<p>With a DOM we could then imagine to implement a visitor pattern in order to let users create new rules.<\/p>\n<p><strong>Some very simple rules in order to start.<\/strong><br \/>\nRule 1: disallow scriptlets<br \/>\nRule 2: disallow some taglibs (JSTL SQL comes to mind). Could be parametrized by Taglib URL to list all disallowed taglibs.<br \/>\nRule 3: enforce JSP style (XML syntax)<br \/>\nRule 4: disallow hard coded labels<br \/>\nRule 5: disallow dynamic JSP includes (&lt;jsp:include&gt;)<br \/>\nRule 6: disallow external file in page attribute of dynamic JSP include<br \/>\nRule 7: disallow TLD location for URI in taglib declaration<br \/>\nFor HTML<br \/>\nRule 8: enforce &lt;script&gt; at the end of the body<br \/>\nRule 9: disallow &lt;style&gt;<br \/>\nRule 10: disallow non empty &lt;script&gt; content<br \/>\nRule 11: enforce a limit on the number of called external files (js and css)<\/p>\n","protected":false},"excerpt":{"rendered":"<p>JSP\/HTML land, usefull tests could be done via some regexp, ie check if style\/css are used (to avoid dirty colors\/fonts hard-coded for example). If we want to build something pretty&#8230; <\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_joinchat":[],"footnotes":""},"categories":[2],"tags":[4459,4458,516,4460],"class_list":["post-4535","post","type-post","status-publish","format-standard","hentry","category-uncategorised","tag-html","tag-jsp","tag-sonar","tag-sonar-support-with-jsp-html"],"_links":{"self":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/4535","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/comments?post=4535"}],"version-history":[{"count":1,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/4535\/revisions"}],"predecessor-version":[{"id":4536,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/4535\/revisions\/4536"}],"wp:attachment":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media?parent=4535"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/categories?post=4535"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/tags?post=4535"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}