10 Replies Latest reply on Dec 16, 2014 12:18 PM by Yanick Girouard

    BSA Compliance Issue while reading xml file

    V P



      We are performing compliance check from BSA. Below is the issue we are facing while performing.


      In compliance check, We are trying to check contents of web.xml file of one of the application but after creating the rules when we are trying validate the same rule it gives an error. Attached is the error screenshot for your reference also we have observed that when we are trying to validate the same web.xml file of same application but on different server it gives an same error.

      Any help would be appreciated.


        • 1. Re: BSA Compliance Issue while reading xml file
          Joe Piotrowski

          On the surface it looks like you're combining two different things. There is a generic file with contents, and there are Configuration Files with grammar that know how to interpret the file, and parse it in a Name/Value format.


          Can you attach the XML file you're working, what grammar file you might be associating this XML with, with and what you're trying to check for?

          • 2. Re: BSA Compliance Issue while reading xml file
            Bill Robinson

            i am going to guess that the < > and other characters are messing up the 'contains' operator.  perhaps the compliance bit isn't properly escaping those characters.

            • 3. Re: BSA Compliance Issue while reading xml file
              Monoj Padhy

              I can remember similar issues w/ double quotes (") in the searched string. So it could be the case and compliance is unable to parse escape characters.


              Just tried using web.config.xml.gm and it worked for me.



              • 4. Re: BSA Compliance Issue while reading xml file
                Monoj Padhy

                It is always worth checking Grammar files supported by BMC Server Automation - BMC Server Automation 8.5 - BMC Documentation . This will help to identify correct grammar file for your use case.

                • 5. Re: BSA Compliance Issue while reading xml file
                  Yanick Girouard

                  I think the issue here is that you are trying to look at the content of a file rather than using a proper grammar file to parse the XML and evaluate keys and values. Try creating a config file and use the xml grammar, then look for the key named init-param (to check if it exists), and then look for a key named param-name which contains value listOrders.


                  That would most likely work a lot better.


                  I made a test and it works very well. First create a local config object like this (adjust the path for your file):


                  12-16-14 11-14-24 AM.png


                  Then create your rule like this:


                  12-16-14 11-21-31 AM.png


                  I made a simple XML file to test it and it works. Here's what I tested against:


                  • 6. Re: BSA Compliance Issue while reading xml file
                    Yanick Girouard

                    By the way, your example compliance rule is not using the config file you created, it's pointing to the File type object instead and comparing the Contents of the file. You are not using the configuration file itself.

                    • 7. Re: Re: BSA Compliance Issue while reading xml file
                      V P

                      Hi Joe,


                      Attached is the xml file.


                      Below is the scenario -


                      We have written a NSH script to find the location of xml file(web.xml and server.xml) of particular location. Once location of a files is identified by the script then we have created compliance rule for web.xml to validate the contents of the web.xml file but we are getting error while validating as mentioned in the previous conversion but same rule is successfully validated for server.xml file so I don't think so rule is invalid.




                      • 8. Re: BSA Compliance Issue while reading xml file
                        Bill Robinson

                        If you have a script to find the file, why don’t you do the pattern search in the script and spit out ‘pass’ or ‘fail’ or something ?

                        • 9. Re: Re: BSA Compliance Issue while reading xml file
                          Yanick Girouard

                          Ahh I see the issue then, but there's no solution for this in the current release. When using the XML grammar you can can evaluate a specific path (path to the XML tag and it's value), but when you can have multiple tags of the same type at the same level it complicates things as they become indexed (i.e. web-app/servlet, web-app/servlet-1, etc...) so you could use wildcards to check if there is one servlet that contains a init-param with a param-name of listings, but you wouldn't be able to also check if there is another param-value with value false at the same level. You can only evaluate them separately.


                          So, the only option for you is to use your own custom script that would do the evaluation, and would then return a simple output that can be parsed by a grammar file, for example, in Windows INI format.


                          The output would have to be something like this:








                          Or whatever key/values you want to be able to evaluate with a compliance rule. Basically, the script does the compliance logic, and only returns the compliance result which is what you would evaluate in the compliance job. We've done this often in the past where the simple compliance rule language was not smart or advanced enough to satisfy the requirements. We have used Perl for example, to do this. The only issue with that is that if you need to see the raw values that were being evaluated, you'll need another version of the same script that outputs the values instead of the compliance result.