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

Support for non UTF-8 characters in the configuration #802

Open
bminnix opened this issue Aug 27, 2024 · 0 comments
Open

Support for non UTF-8 characters in the configuration #802

bminnix opened this issue Aug 27, 2024 · 0 comments

Comments

@bminnix
Copy link

bminnix commented Aug 27, 2024

Environment

  • Nautobot version: 2.2.x +
  • nautobot-golden-config version: 2.1.1

Proposed Functionality

Allow non UTF-8 characters to be read into the configuration when comparing the backup and intended values.

Use Case

Currently the diff function is setting encoding to utf-8

nautobot-golden-config/nornir_plays/config_compliance.py

def diff_files(backup_file, intended_file):
    """Utility function to provide `Unix Diff` between two files."""
    with open(backup_file, encoding="utf-8") as file:
        backup = file.readlines()
    with open(intended_file, encoding="utf-8") as file:
        intended = file.readlines()

We've ran into a case where a legit, non UTF-8 encoded character is in the device running config output and causes a UnicodeDecodeError.

! NAME: "<ifacename>", DESCR: "<description>"
! PID: SFP-10G-SR        , VID: V03, SN: xxxxxxxx�xx

In this specific situation, the value is being caused by an SFP module that has a non-standard S/N value, yet it is the assigned valid value read from the module. The enforcement of UTF-8 is causing this to fail while being read into the function.

Since these characters are permitted into the operating system, there may be other cases for other values where they are present and also legit (but I can't think of any).

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

No branches or pull requests

2 participants