Do not treat an indented banner as the start of a banner - #909
Open
ggiesen wants to merge 1 commit into
Open
Conversation
is_banner_start matches the stripped line, while the banner patterns anchor at the start of it. Where the two disagreed the line could not yield a delimiter, and the ValueError that followed left __init__, so a single indented banner made the whole configuration unparseable. CiscoConfigParser now checks the line against its own regex_banner before accepting it, so the two agree by construction and each subclass keeps its own pattern. EOSConfigParser has no such pattern and matches the terminator by name, so it stops stripping instead. Both mirror ASAConfigParser, which already avoided this by not stripping in its own is_banner_start. Fixes networktocode#907
ggiesen
requested review from
itdependsnetworks and
jeffkala
as code owners
September 10, 2026 17:33
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #907.
is_banner_start()matches the stripped line, while the banner patterns anchor at the start of it. Where the two disagree the line cannot yield a delimiter, and theValueErrorthat follows leaves__init__, so one indented banner loses the whole config.CiscoConfigParser.is_banner_start()now checks the line against its ownregex_bannerbefore accepting it, so the two agree by construction and each subclass keeps its own pattern.EOSConfigParserhas no such pattern and matches its terminator by name, so it stops stripping instead. Both mirrorASAConfigParser, which already avoided this by not stripping in its ownis_banner_start().This takes the "don't recognise it" direction rather than "allow leading whitespace in the patterns". I tried the other one first: relaxing the anchors makes an indented
banner value helloresolvehas its delimiter and then fail hunting for a terminator, which trades one exception for another. Removing the strip from the base class instead breakshp_comware, since_HPEConfigParserrelies on it for indentedheaderlines.Covers cisco_ios, cisco_nxos, cisco_iosxr and arista_eos. Tests assert both that the indented line no longer aborts the parse and that a real top-level banner still folds. 825 passed, 6 skipped; ruff, pylint and mypy clean.