I am new to SonarQube tool and would like to use scan the couple of xml files (apigee proxy bundle). As part of this I would like perform custom checks in the xml files and for that I need to create custom rules.
As per the help from sonarqube, need to use xpath expression to add the rules. Can anyone help me with step-by-step procedure to write rules for xml.
Also I am using sonar-apigee-plugin-X.X.X.jar downloaded from here. Can anyone help me to how to change the existing rules under this plugin.
Sorry for the delay answering you. i’m only going to answer the first part of your question, as I don’t know the apigee plugin.
There is no need to write custom rules (and therefore creating a custom-plugin) to write purely XPath-based rules. Assuming you are using SonarQube (and not SonarCloud), you can simply define new XPath-based rules using the template rule xml:S140 (or “xml:XPathCheck”). Note that the only constraint I know for sure is that you will need to use XPath 1.0. XPath 2.0 is not supported.
You will also be able to define different instances of this rules if you need to apply multiple XPath queries (this rule being a “template” rule). Please refer to the documentation (under “Rules Template”) for more details.
I need help in writing the xpath custom rules for APIGEE. I want to write a xpath expression to check whether policy xml file name (under /apiproxy/policies) should match with “policy name”. The code should look for all the xml files in /apiproxy/policies and check policy name in respective xml file. If it is not matching it should show an error/bug.
Not sure whether this is achievable using just xpath expression.
Will you please let me know and appreciate all your help. TIA.