4 Replies Latest reply on May 23, 2017 4:21 AM by c.thomas

    Network Configuration Manager Compliance check fails when an end of line character ($) is used

    c.thomas

      I have several RegEx-rules which all validate fine in the form of

      ^\s{1,}authentication event no-response action authorize vlan 666[\r\n]*$

      ...but I have one rule which is made like the one above which fails:

      ^\s{1,}authentication event server alive action reinitialize[\r\n]*$

      ...it fails on every single switch I have tested (running and startup config) - I copied and pasted the string until I found out that leaving out the '$' will actually validate fine.

        • Re: Network Configuration Manager Compliance check fails when an end of line character ($) is used
          CourtesyIT

          make sure you watch for extra spaces or carriage returns at the end of line.  cnorborg is a regex pro and may be able to assist? 

          1 of 1 people found this helpful
          • Re: Network Configuration Manager Compliance check fails when an end of line character ($) is used
            Craig Norborg

            Your regex's are a bit confusing and has some stuff I'd consider to be superfluous.   Let's take the first one.

             

            ^\s{1,}authentication event no-response action authorize vlan 666[\r\n]*$

             

            The "^" is good, you're anchoring it to the beginning of a line so you know where you want to start comparing.

             

            The "\s{1,}" is a bit odd to me, its saying you want at least one space there.   Most folks would probably do it as "\s+" which is pretty much the equivalent AFAIK.  ie: if you put a {0,}, that would be the same as a "*" (ie: any number).   Doing a {1,}, which means you want one or more, is the same as using a "+".  Most consider the curly's only good to use when you want 2 or more items, or a specific number or range of them.

             

            Then you match on the end of this line with the [\r\n]*, which will match on any number of newlines basically.

             

            The "$" in most regex's matches the end of line also, although its behavior in NCM tends to be a bit odd.   I believe that if you are testing a rule, it will work as expected while [\r\n] might not.  But, once you have the rule active, "$" tends to not work and you have to use the [\r\n].   Unless your testing the rule, I'd leave the "$" out of it.   Now, in thinking about it a bit, the "[\r\n]*$", should work both in testing mode and production since it will match on 0 instances of "[\r\n]" while testing and go ahead and match on the "$", but the problem is what the "$" and multiple newlines might do when the rule is in production, its a variable I wouldn't want to introduce myself!

             

            Now, how would I do this rule?   Probably like this:

             

            ^\s+authentication event no-response action authorize vlan 666[\r\n]

             

            Little bit cleaner, no funky stuff going on.

             

            HTH!

            2 of 2 people found this helpful