diff --git a/docs/changelog.md b/docs/changelog.md index 315755e..fcf94fb 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -1,5 +1,9 @@ # Changelog +## 1.2.2 (2023-09-29) + +* [#28](https://github.com/miaow2/netbox-config-diff/issues/28) Add legacy ssh algorithms to support old OS versions + ## 1.2.1 (2023-09-07) * [#26](https://github.com/miaow2/netbox-config-diff/issues/26) Add dark theme for diff diff --git a/netbox_config_diff/__init__.py b/netbox_config_diff/__init__.py index 2e3570c..048da91 100644 --- a/netbox_config_diff/__init__.py +++ b/netbox_config_diff/__init__.py @@ -2,7 +2,7 @@ __author__ = "Artem Kotik" __email__ = "miaow2@yandex.ru" -__version__ = "1.2.1" +__version__ = "1.2.2" class ConfigDiffConfig(PluginConfig): diff --git a/netbox_config_diff/compliance/models.py b/netbox_config_diff/compliance/models.py index c1571d6..4f135b9 100644 --- a/netbox_config_diff/compliance/models.py +++ b/netbox_config_diff/compliance/models.py @@ -36,6 +36,42 @@ def to_scrapli(self): "platform": self.platform, "auth_strict_key": self.auth_strict_key, "transport": self.transport, + "transport_options": { + "asyncssh": { + "kex_algs": [ + "curve25519-sha256", + "curve25519-sha256@libssh.org", + "curve448-sha512", + "ecdh-sha2-nistp521", + "ecdh-sha2-nistp384", + "ecdh-sha2-nistp256", + "ecdh-sha2-1.3.132.0.10", + "diffie-hellman-group-exchange-sha256", + "diffie-hellman-group14-sha256", + "diffie-hellman-group15-sha512", + "diffie-hellman-group16-sha512", + "diffie-hellman-group17-sha512", + "diffie-hellman-group18-sha512", + "diffie-hellman-group14-sha256@ssh.com", + "diffie-hellman-group14-sha1", + "rsa2048-sha256", + "diffie-hellman-group1-sha1", + "diffie-hellman-group-exchange-sha1", + "diffie-hellman-group-exchange-sha256", + ], + "encryption_algs": [ + "aes256-cbc", + "aes192-cbc", + "aes128-cbc", + "3des-cbc", + "aes256-ctr", + "aes192-ctr", + "aes128-ctr", + "aes128-gcm@openssh.com", + "chacha20-poly1305@openssh.com", + ], + }, + }, } def to_db(self): diff --git a/netbox_config_diff/compliance/utils.py b/netbox_config_diff/compliance/utils.py index 448cede..f714780 100644 --- a/netbox_config_diff/compliance/utils.py +++ b/netbox_config_diff/compliance/utils.py @@ -19,7 +19,7 @@ def get_unified_diff(rendered_config: str, actual_config: str, device: str) -> str: diff = unified_diff( - rendered_config.splitlines(), + rendered_config.strip().splitlines(), actual_config.splitlines(), fromfiledate=device, tofiledate=device, @@ -31,4 +31,4 @@ def get_unified_diff(rendered_config: str, actual_config: str, device: str) -> s def exclude_lines(text: str, regex: str) -> str: for item in regex.splitlines(): text = re.sub(item, "", text, flags=re.MULTILINE) - return text + return text.strip() diff --git a/netbox_config_diff/models.py b/netbox_config_diff/models.py index 7c20b65..82d41c5 100644 --- a/netbox_config_diff/models.py +++ b/netbox_config_diff/models.py @@ -83,7 +83,7 @@ class PlatformSetting(NetBoxModel): ) exclude_regex = models.TextField( blank=True, - help_text=_("Regex patterns to exclude from actual config, specify each pattern on a new line."), + help_text=_("Regex patterns to exclude config lines from actual config, specify each pattern on a new line."), ) prerequisite_models = ("dcim.Platform",) diff --git a/tests/test_compliance.py b/tests/test_compliance.py index a011460..8dc8a5c 100644 --- a/tests/test_compliance.py +++ b/tests/test_compliance.py @@ -90,6 +90,42 @@ def test_devicedataclass_to_scrapli(devicedataclass_data: "DeviceDataClassData") "platform": devicedataclass_data.platform, "auth_strict_key": devicedataclass_data.auth_strict_key, "transport": devicedataclass_data.transport, + "transport_options": { + "asyncssh": { + "kex_algs": [ + "curve25519-sha256", + "curve25519-sha256@libssh.org", + "curve448-sha512", + "ecdh-sha2-nistp521", + "ecdh-sha2-nistp384", + "ecdh-sha2-nistp256", + "ecdh-sha2-1.3.132.0.10", + "diffie-hellman-group-exchange-sha256", + "diffie-hellman-group14-sha256", + "diffie-hellman-group15-sha512", + "diffie-hellman-group16-sha512", + "diffie-hellman-group17-sha512", + "diffie-hellman-group18-sha512", + "diffie-hellman-group14-sha256@ssh.com", + "diffie-hellman-group14-sha1", + "rsa2048-sha256", + "diffie-hellman-group1-sha1", + "diffie-hellman-group-exchange-sha1", + "diffie-hellman-group-exchange-sha256", + ], + "encryption_algs": [ + "aes256-cbc", + "aes192-cbc", + "aes128-cbc", + "3des-cbc", + "aes256-ctr", + "aes192-ctr", + "aes128-ctr", + "aes128-gcm@openssh.com", + "chacha20-poly1305@openssh.com", + ], + }, + }, } diff --git a/tests/test_compliance_utils.py b/tests/test_compliance_utils.py index c2a1d74..234ea17 100644 --- a/tests/test_compliance_utils.py +++ b/tests/test_compliance_utils.py @@ -22,15 +22,15 @@ [ ( "^interface.?\n^Building", - "hostname test-1\n\nfa-0/0\n switchport mode access\n switchport access vlan 100\n", + "hostname test-1\n\nfa-0/0\n switchport mode access\n switchport access vlan 100", ), ( "^interface.*$\n^Building", - "hostname test-1\n\n\n switchport mode access\n switchport access vlan 100\n", + "hostname test-1\n\n\n switchport mode access\n switchport access vlan 100", ), ( "^Building", - "hostname test-1\n\ninterface fa-0/0\n switchport mode access\n switchport access vlan 100\n", + "hostname test-1\n\ninterface fa-0/0\n switchport mode access\n switchport access vlan 100", ), ], ids=["part of line", "full line", "no effect"],