Thanks to visit codestin.com
Credit goes to github.com

Skip to content

panconf produces invalid set output #50

@dhalperi

Description

@dhalperi

Hey @kevinsteves - thanks for this lib.

The actual CLI on devices does not produce valid output if users have newlines, quotes, etc in their descriptions, etc. So we recommend our Batfish users to use Panconf to fetch XML and then convert it to SET via panconf: https://pybatfish.readthedocs.io/en/latest/formats.html#from-panorama-preferred

We're running into an issue where XML nodes that contain complicated text (like JSON) make output files that are unparseable. Panconf is better than the device CLI, but it has similar issues. I think the culprit is this code:

def __quote_arg(self, s):
# XXX string with " etc.
if '"' in s:
return "'%s'" % s
if ' ' in s:
return '"%s"' % s
return s

It clearly will do the wrong thing on, e.g., a cell that contains only '" (single-quote double-quote) -- it will output ''"' (single/single/double/single) which is still not a valid string (three single-quotes).

Is this desired behavior for some reason? If not, would you be open to a PR that does some escaping to produce parseable output? Do you have an opinion for how that output should look?

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions