Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ASA config: find_objects_w_child(): why is the wrong parent object returned? #138

Closed
danielarapi opened this Issue Mar 28, 2019 · 3 comments

Comments

Projects
None yet
2 participants
@danielarapi
Copy link

danielarapi commented Mar 28, 2019

Device: Cisco ASA
All running-configs are saved to the variable config.
I am trying to use find_objects_w_child() to search for any parent that has a child with the keyword nat in it

regex for parentspec = r"^\w"
regex for childspec = r"^\s+.*nat"

 for item in configs.find_objects_w_child(r"^\w", r"^\s+.*nat.*"):
    print(item) 

Output:

<IOSCfgLine # 52 'banner motd           WARNING: Use of this system is Restricted and Monitored!'>
<IOSCfgLine # 70 'banner motd     Firm policy, your improper or unauthorized use of this system may result' (parent is # 69)>
<IOSCfgLine # 112 'object network obj_any' (parent is # 70)>

It should be returning object network obj_any as the parent of nat (inside,outside) dynamic interface

object network obj_any
 nat (inside,outside) dynamic interface

It should be returning

@danielarapi

This comment has been minimized.

Copy link
Author

danielarapi commented Mar 28, 2019

Temporary workaround to this is to use the following regex that skips banner configs:

for item in configs.find_objects_w_child(r"^(?!banner)^\w", r"^\s+.*nat.*"):
    print(item) 
@mpenning

This comment has been minimized.

Copy link
Owner

mpenning commented Mar 28, 2019

Please add an ASA config which can be used to reproduce this problem... it doesn't need to be big

@mpenning mpenning changed the title wrong parent object returned ASA config: find_objects_w_child(): wrong parent object returned Mar 31, 2019

@mpenning

This comment has been minimized.

Copy link
Owner

mpenning commented Mar 31, 2019

I'm going to go out on a limb and guess that you parsed your ASA config like this: parse = CiscoConfParse(config_lines).

ASA configs must be parsed like this: parse = CiscoConfParse(config_lines, syntax='asa')

@mpenning mpenning changed the title ASA config: find_objects_w_child(): wrong parent object returned ASA config: find_objects_w_child(): why is the wrong parent object returned? Mar 31, 2019

@mpenning mpenning added the question label Mar 31, 2019

@mpenning mpenning self-assigned this Mar 31, 2019

@mpenning mpenning closed this Apr 2, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.