Xpath is not working for sonarqube6.2 Rule/ XML 1.2 plugin , please help

312 views
Skip to first unread message

Manaswinee Mohanty

unread,
Apr 4, 2017, 8:31:07 AM4/4/17
to SonarQube
Hi All,

Tried few things but not getting the result :
code snippet: 
<?xml version = '1.0' encoding = 'UTF-8'?>
    <userPermissions>
        <enabled>true</enabled>
        <name>ViewSetup</name>
    </userPermissions>
</PermissionSet> 


Xpath: 
//PermissionSet/userPermissions/name[text()="ViewSetup"]/../enabled[text()="true"]


yves.dubo...@sonarsource.com

unread,
Apr 5, 2017, 3:31:15 AM4/5/17
to SonarQube
Hello Manaswinee,

I ran your example using the latest version 1.4.2 of SonarXML. As expected, I came up with an issue on the line with <enable>true<enable>. Your value for "expression" is correct. I set "filePattern" to "**/*.xml".

Please let us know, should the trouble persist.

Yves Dubois-Pèlerin
SonarSource team

Manaswinee Mohanty

unread,
Apr 7, 2017, 2:53:14 AM4/7/17
to SonarQube

Hi Yves, 

Thank you for the reply , but no luck ... :( please find the screenshot for the sonar rule I am trying to create, keep in mind the file extension is permission-set not xml but it is contains xml format. Still i tried with the xml but ddinot wrok out. and also my xml plugin verison is 1.4.2

Yves Dubois-Pèlerin

unread,
Apr 7, 2017, 4:18:27 AM4/7/17
to Manaswinee Mohanty, SonarQube
Hello Manaswinee,

I understand that you ran the analysis with your file having ".xml" extension and no issue was raised.

I suggest the following:
1) Check that your rule is active. Please note that, by default, a new rule is not active.
2) If the trouble persists, create another rule "Track breaches of an XPath rule" with a very simple expression, e.g, expression = //PermissionSet/userPermissions. Check that the issue is raised.
3) If the trouble still persists, check the log file of your analysis.

If ever you come up with no clue, please send us your log file.

Yves Dubois-Pèlerin
SonarSource team


--
You received this message because you are subscribed to a topic in the Google Groups "SonarQube" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/sonarqube/js9O8RrJaSI/unsubscribe.
To unsubscribe from this group and all its topics, send an email to sonarqube+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sonarqube/14d37f4d-519f-40f2-9b74-aea9a2912aca%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Manaswinee Mohanty

unread,
Apr 12, 2017, 5:52:44 AM4/12/17
to SonarQube, manaswine...@gmail.com
Hi Yves,

Thank you for reaching out. I really need your help. 
I have followed the steps you have mentioned but unfortunately the rule is not getting picked up by sonnar -runner(hudson plugin we are using)
Please find attached the log synopsis and the rule screenshot.

Can you tell me which logs you need and if required I can go for an hangout call with you. 
It will be great help. 

Regards,
Manaswinee


On Friday, 7 April 2017 13:48:27 UTC+5:30, Yves Dubois-Pèlerin wrote:
Hello Manaswinee,

I understand that you ran the analysis with your file having ".xml" extension and no issue was raised.

I suggest the following:
1) Check that your rule is active. Please note that, by default, a new rule is not active.
2) If the trouble persists, create another rule "Track breaches of an XPath rule" with a very simple expression, e.g, expression = //PermissionSet/userPermissions. Check that the issue is raised.
3) If the trouble still persists, check the log file of your analysis.

If ever you come up with no clue, please send us your log file.

Yves Dubois-Pèlerin
SonarSource team
On Fri, Apr 7, 2017 at 8:53 AM, Manaswinee Mohanty <manaswine...@gmail.com> wrote:

Hi Yves, 

Thank you for the reply , but no luck ... :( please find the screenshot for the sonar rule I am trying to create, keep in mind the file extension is permission-set not xml but it is contains xml format. Still i tried with the xml but ddinot wrok out. and also my xml plugin verison is 1.4.2



On Wednesday, 5 April 2017 13:01:15 UTC+5:30, yves.dubo...@sonarsource.com wrote:
Hello Manaswinee,

I ran your example using the latest version 1.4.2 of SonarXML. As expected, I came up with an issue on the line with <enable>true<enable>. Your value for "expression" is correct. I set "filePattern" to "**/*.xml".

Please let us know, should the trouble persist.

Yves Dubois-Pèlerin
SonarSource team

--
You received this message because you are subscribed to a topic in the Google Groups "SonarQube" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/sonarqube/js9O8RrJaSI/unsubscribe.
To unsubscribe from this group and all its topics, send an email to sonarqube+...@googlegroups.com.
sonar_log.txt
sonar_rule.PNG

Yves Dubois-Pèlerin

unread,
Apr 12, 2017, 9:11:10 AM4/12/17
to Manaswinee Mohanty, SonarQube
Dear Manaswinee,

I am sorry, but I am only allowed to have direct discussions with the SonarQube customers.

I cannot see anything abnormal from your screen caption and your log file. The value you set to property "sonar.xml.file.suffixes" is compatible with the filePattern you set in your rule ("**/*.permissionset"). I just ran an example with identical config and the rule raised an issue.

Here are a few hints:
- Activate another rule for language XML (not a template rule like rule "Track breaches of an XPath rule") and try to fire it with your current configuration (you will likely need to udpate one of your .permissionset files to make it non compliant). Make sure that issues are  raised
- Scan with debug-level traces activated (-X)
- Remove the namespace reference in your XML file. That is, replace <PermissionSet xmlns="http://soap.sforce.com/2006/04/metadata"> with <PermissionSet>. It shouldn't make a difference, but you can check.

Good luck!

Yves Dubois-Pèlerin
SonarSource team


Yves Dubois-Pèlerin | SonarSource

To unsubscribe from this group and all its topics, send an email to sonarqube+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sonarqube/a4ba3d28-4105-40bf-8ed8-98b4170bba53%40googlegroups.com.

vinayak Malik

unread,
Jun 9, 2018, 12:15:27 PM6/9/18
to SonarQube
Hi Yves,

I have similar problem with xml plugin , I am using LTS 6.7 sonarqube and xml plugin directly downloaded from update center.
The problem is with activating the rule. I can create custom rules under "Track breaches of an XPath rule" but there is no option of activating the new custom rule.
Earlier i was using 5.6 LTS and xml plugin 1.4 i was able to create new xpath rules and activate and analyse but i have changed to 6.7 n now no option of activating the rule. 
Kindly help me with this problem.
Reply all
Reply to author
Forward
0 new messages