Skip to content
This repository has been archived by the owner on Nov 10, 2023. It is now read-only.

False positives on _base_pattern, can't override. #50

Open
spdkils opened this issue Nov 13, 2020 · 2 comments
Open

False positives on _base_pattern, can't override. #50

spdkils opened this issue Nov 13, 2020 · 2 comments

Comments

@spdkils
Copy link

spdkils commented Nov 13, 2020

Describe the bug

The send_command function allows for a pattern to be input to stop the parse, however the default pattern is used as an optional stop point regardless.

This causes issues if you have a comment with the switch name and a > or # following it.

The regular expression should probably be anchored ^ $ to confirm that it is not found in the middle of a line, or other erronous location causing the send_command to prematurely return.

General Information

  • WIN
  • Netdev version 9.3
  • Base.py

Debug information

Reading pattern "WAS-SF02-1-119-DC#" or "WAS-SF02-1-1.?((.?))?[>|#]" was found

^^^^ WHOOOPS!!!

My startup has this line...

description VPC Peerlink<Chassis1 WAS-SF01-1-119-DC | Chassis2 WAS-SF02-1-119-DC>

Additional context

So, without line anchors, I have to limit what descriptions I have, and I'm not sure if it's catching a truncating other commands.

The fix???

Well there are a few approaches. First if I override a pattern, it should respect that pattern, and timeout otherwise, not use both my pattern and the default pattern.

Second I think anchors in most cases would be appropriate to ensure the base prompt is found on a "clean" line, not as a mishap of some port description if I have some network admin getting fancy with their descriptions.

@spdkils
Copy link
Author

spdkils commented Nov 13, 2020

I would NORMALLY just get more picky, and override the pattern... However I can't override the pattern because the defaults, it always looks for the default pattern in the code. So I'm sunk. I have to edit this package to get around this, or search every config we have (28,000+) and ensure we never do this, and put out a memo ugh. Much prefer to make the pattern search more restrictive.

@spdkils
Copy link
Author

spdkils commented Nov 13, 2020

Sadly this version of NXOS spits out \r\n\r\n\rROUTER%
So using ^ won't anchor it, so you would have to use [\r\n] to simulate the ^ since it's out of order. (Thanks Cisco)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant