mpenning / ciscoconfparse

Parse, Audit, Query, Build, and Modify Arista / Cisco / Juniper / Palo Alto / F5 configurations.
http://www.pennington.net/py/ciscoconfparse/
GNU General Public License v3.0
797 stars 220 forks source link

Banners with comment characters in them are not parsed correctly #16

Closed mpenning closed 9 years ago

mpenning commented 9 years ago

Example, if an IOS banner has a ! in it, the current algorithm breaks. This problem can be seen when parsing the banner in sample_01.iosxr, among several problems line 27's parent is line 26 (another banner line):

<IOSCfgLine # 19 'banner login #'>
<IOSCfgLine # 20 '_____________________________________________________________________' (parent is # 19)>
<IOSCfgLine # 21 '                      -= FROG PARK SERVICES =-' (parent is # 19)>
<IOSCfgLine # 22 '               ||        ||         ' (parent is # 19)>
<IOSCfgLine # 23 '               ||        ||         ' (parent is # 19)>
<IOSCfgLine # 24 '              ||||      ||||       ' (parent is # 19)>
<IOSCfgLine # 25 '          ..:||||||:..:||||||:..   ' (parent is # 19)>
<IOSCfgLine # 26 '         C I S C O  S Y S T E M S    ' (parent is # 19)>
<IOSCfgLine # 27 '                   ! UNAUTHORISED ACCESS PROHIBITED !' (parent is # 26)>
<IOSCfgLine # 28 '     *************************************************************' (parent is # 20)>
<IOSCfgLine # 29 '     * This system is the property of Frog Park Services.    *' (parent is # 20)>
<IOSCfgLine # 30 '     * Disconnect IMMEDIATELY as you are not an authorized user! *' (parent is # 20)>
<IOSCfgLine # 31 '     *************************************************************' (parent is # 20)>
<IOSCfgLine # 32 '______________________________________________________________________'>

The fix properly parses this same banner...

<IOSCfgLine # 19 'banner login #'>
<IOSCfgLine # 20 '_____________________________________________________________________' (parent is # 19)>
<IOSCfgLine # 21 '                      -= FROG PARK SERVICES =-' (parent is # 19)>
<IOSCfgLine # 22 '               ||        ||         ' (parent is # 19)>
<IOSCfgLine # 23 '               ||        ||         ' (parent is # 19)>
<IOSCfgLine # 24 '              ||||      ||||       ' (parent is # 19)>
<IOSCfgLine # 25 '          ..:||||||:..:||||||:..   ' (parent is # 19)>
<IOSCfgLine # 26 '         C I S C O  S Y S T E M S    ' (parent is # 19)>
<IOSCfgLine # 27 '                   ! UNAUTHORISED ACCESS PROHIBITED !' (parent is # 19)>
<IOSCfgLine # 28 '     *************************************************************' (parent is # 19)>
<IOSCfgLine # 29 '     * This system is the property of Frog Park Services.    *' (parent is # 19)>
<IOSCfgLine # 30 '     * Disconnect IMMEDIATELY as you are not an authorized user! *' (parent is # 19)>
<IOSCfgLine # 31 '     *************************************************************' (parent is # 19)>
<IOSCfgLine # 32 '______________________________________________________________________' (parent is # 19)>
<IOSCfgLine # 33 '#' (parent is # 19)>
<IOSCfgLine # 34 '! LOGGING'>
mpenning commented 9 years ago

Resolved in CiscoConfParse version 1.2.2