Hi all,
I'm entirely new to SonarQube. However, I have been tasked with using it to scan my company's in-house code base (which is mostly Java) for security vulnerabilities, paying special attention to the OWASP-2013 Top Ten. While the Sonar Way profile has some excellent coverage of the OWASP vulnerabilities, one of the places it's completely lacking in is A3: XSS (Cross-Site Scripting). So I have set out to make my first custom Java rule, which is supposed to check to see if strings are sanitized.
The rule currently uses OWASP's own
ESAPI to canonicalize strings, and
Jsoup to test for sanitization against a basic whitelist. As such, both ESAPI and Jsoup have been included as dependencies in the Sonar Plugin's POM.xml as follows:
<dependency>
<groupId>org.owasp.esapi</groupId>
<artifactId>esapi</artifactId>
<version>2.1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
<version>1.8.3</version>
<scope>provided</scope>
</dependency>
The scopes of both of these are "provided" because the plugin won't build if they aren't. As it is, the plugin builds, and the rule is visible on the Sonar UI under "Rules."
Now, the problem: Right now the rule is very basic. I was hoping to test it out a little before increasing its complexity, but whenever I try to run the Sonar-Runner, I get a NoClassDefFoundError on one of the ESAPI classes (org.owasp.esapi.ESAPI). This the first "external" (non-Sonar) class used in the rule. I suspect that, if I took it out, it would fail on the next "external" class call...
I've tried messing with the dependency scope of both of these libraries, but anything other than "provided" results in build failure. On a hunch, I also tried adding these classes to the list returned by getExtensions() in my plugin entrypoint class (the one that extends SonarPlugin), but this also caused the build to fail. I've tried researching it but found very little.
So, my question is: How do I use "external" classes in my Sonar rules without them failing at runtime during analysis?
Any advice is appreciated. Thanks!