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

[Bug]: Issue parsing F5 BigIP config file #287

Closed
1 task done
i-m-d opened this issue Oct 10, 2023 · 6 comments
Closed
1 task done

[Bug]: Issue parsing F5 BigIP config file #287

i-m-d opened this issue Oct 10, 2023 · 6 comments

Comments

@i-m-d
Copy link

i-m-d commented Oct 10, 2023

Contact Details

mundoimd@gmail.com

What happened?

I am using CiscoConfigParse to parse F5 BigIP configuration files, which work very well, but i have a bug, but i think the problem is how F5 config file write the config, i explain:

if a code block contains a "{" and after contains text WITHOUT a "}" in the same LINE, the parse do not work correctly.

if a code block contains text before a "}" and not a "{" in the same LINE, the parse do not work correctly.

Config sample1 that parse OK:

sys syslog {
    remote-servers {
        /Common/remotesyslog1 {
            host 10.0.0.45
        }
    }
}
sys diags ihealth {
    expiration 30
    no-ihealth false
    options none
    password none
    user none
}

Config sample2 that parse with ERROR:

sys syslog {
    remote-servers {
        /Common/remotesyslog1 {   host 10.0.0.45
        }
    }
}
sys diags ihealth {
    expiration 30
    no-ihealth false
    options none
    password none
    user none
}

Config sample3 that parse with ERROR:

sys syslog {
    remote-servers {
        /Common/remotesyslog1 {
           host 10.0.0.45   }
    }
}
sys diags ihealth {
    expiration 30
    no-ihealth false
    options none
    password none
    user none
}

CiscoConfParse Version

Version 1.7.24

What Operating System are you using?

Linux - Debian, Ubuntu, CentOS, RHEL or others

What Python version(s) have this problem?

Python 3.9

Show us how to reproduce the problem. Please tell us if the problem is specific to certain inputs or situations.

# config sample1 OK

In [1]: from ciscoconfparse import CiscoConfParse

In [2]: config_file = "sample1"

In [3]: configparse = CiscoConfParse(config_file, syntax='junos', comment='#')

In [4]: configparse.find_objects('^sys ')[0].children
Out[4]: [<IOSCfgLine # 1 '    remote-servers' (parent is # 0)>]

In [5]: configparse.find_objects('^sys ')[1].children
Out[5]:
[<IOSCfgLine # 5 '    expiration 30' (parent is # 4)>,
 <IOSCfgLine # 6 '    no-ihealth false' (parent is # 4)>,
 <IOSCfgLine # 7 '    options none' (parent is # 4)>,
 <IOSCfgLine # 8 '    password none' (parent is # 4)>,
 <IOSCfgLine # 9 '    user none' (parent is # 4)>]


# config sample2 ERROR

In [1]: from ciscoconfparse import CiscoConfParse

In [2]: config_file = "sample2"

In [3]: configparse = CiscoConfParse(config_file, syntax='junos', comment='#')

In [4]: configparse.find_objects('^sys ')[0].children
Out[4]: [<IOSCfgLine # 1 '    remote-servers' (parent is # 0)>]

In [5]: configparse.find_objects('^sys ')[1].children
Out[5]: []



# config sample3 ERROR

In [1]: from ciscoconfparse import CiscoConfParse

In [2]: config_file = "sample3"

In [3]: configparse = CiscoConfParse(config_file, syntax='junos', comment='#')

In [4]: configparse.find_objects('^sys ')[0].children
Out[4]:
[<IOSCfgLine # 1 '    remote-servers' (parent is # 0)>,
 <IOSCfgLine # 4 '    sys diags ihealth' (parent is # 0)>]

In [5]: configparse.find_objects('^sys ')[1].children
---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
Input In [5], in <cell line: 1>()
----> 1 configparse.find_objects('^sys ')[1].children

IndexError: list index out of range


Python tracebacks

NO TRACEBACK

Relevant log output

No response

Code of Conduct

@i-m-d i-m-d added the bug label Oct 10, 2023
@mpenning
Copy link
Owner

mpenning commented Oct 26, 2023

Please add the entire F5 configuration, including all the info mentioned above; I won't try to tackle part of this problem without seeing what else may be broken in the config.

@i-m-d
Copy link
Author

i-m-d commented Nov 22, 2023

Sorry for delay.

The entire f5 configuration is over 25000 lines and has private info.

I can upload a portion with a few lines.

Cheers

@i-m-d
Copy link
Author

i-m-d commented Nov 22, 2023

The main problem is the irule config that is not formated, it is free format config.
The f5 config (other than irule = ltm rule) is formated correctly by the system.
The irule config are written in a text box with free format, so, curly brackets may be incorrectly set, so CiscoConfParse produces erroneous parsing.

@mpenning
Copy link
Owner

The entire f5 configuration is over 25000 lines and has private info.

Sanitize the private information and please email the file to me... penningtonthing@gmail.com. I will be forced to close this if I can't get a complete config file.

@i-m-d
Copy link
Author

i-m-d commented Dec 5, 2023

Hello @mpenning,

Here is the config:

config-f5.txt

The problem is after parsing ltm rule.

Cheers

Repository owner deleted a comment from github-actions bot Feb 5, 2024
@mpenning
Copy link
Owner

mpenning commented Feb 5, 2024

parse with ERROR:

sys syslog {
    remote-servers {
        /Common/remotesyslog1 {
           host 10.0.0.45   }
    }
}
sys diags ihealth {
    expiration 30
    no-ihealth false
    options none
    password none
    user none
}

This is fixed in ciscoconfparse2 version 0.5.0

FYI... several other things in the config-f5.txt do not parse correctly, but I will handle that as a different effort (which may require a dedicated parser).

@mpenning mpenning closed this as completed Feb 5, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 27, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants