networktocode / netutils

Python library that is a collection of functions and objects for common network automation tasks.
https://netutils.readthedocs.io/
Other
217 stars 51 forks source link

Cisco ASA Banner Parsing Issue #556

Open kisahae opened 4 months ago

kisahae commented 4 months ago

Environment

Expected Behavior

Banner as children probably should not be parsed like banner login or banner motd.

Observed Behavior

Example config: We have a snippet code like this group-policy Grs-POLICY attributes   banner value xxx   banner value xxxxx   dns-server value x.x.x.x x.x.x.x This raises an error message raise ValueError("There was an error parsing your banner, the end of the banner could not be found")

Steps to Reproduce

from netutils.config.parser import ASAConfigParser, ConfigLine config = ''' group-policy Grs-POLICY attributes banner value xxx banner value xxxxx dns-server value x.x.x.x x.x.x.x''' config_tree = ASAConfigParser(str(config)) print(config_tree)

NB: Our temporary solution is to remove the lstrip() from def is_banner_start(self, line: str) in parser.py file. We are still not sure if this can affect other device platform. Perhaps opening the issue and discussing it together is a better option. Have a nice day everyone!

itdependsnetworks commented 4 months ago

Can you show the actual config on the asa, e.g. not what you put in your Python shell, but the actual show run of the device?

huacchob commented 4 weeks ago

The config is similar to what is shown in the issue description.

In the issue I am facing, there is no top level banner config, like banner motd or banner login, just this implementation of the banner

group-policy Grs-POLICY attributes
 banner value xxx
 banner value xxxxx
 dns-server value x.x.x.x x.x.x.x

It seems that when a banner message is multiline, and implemented like so, you would write the banner as

group-policy Grs-POLICY attributes
 banner value banner message line 1
 banner value banner message line 2

Please let me know if there is any other information I can provide to assist