Skip to content

Commit

Permalink
Closes #28: Add legacy ssh algorithms to support old OS versions (#29)
Browse files Browse the repository at this point in the history
* Add legacy ssh algorithms to support old OS versions
  • Loading branch information
miaow2 committed Sep 29, 2023
1 parent 11c6814 commit 546bff3
Show file tree
Hide file tree
Showing 7 changed files with 83 additions and 7 deletions.
4 changes: 4 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion netbox_config_diff/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

__author__ = "Artem Kotik"
__email__ = "miaow2@yandex.ru"
__version__ = "1.2.1"
__version__ = "1.2.2"


class ConfigDiffConfig(PluginConfig):
Expand Down
36 changes: 36 additions & 0 deletions netbox_config_diff/compliance/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
4 changes: 2 additions & 2 deletions netbox_config_diff/compliance/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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()
2 changes: 1 addition & 1 deletion netbox_config_diff/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",)
Expand Down
36 changes: 36 additions & 0 deletions tests/test_compliance.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
],
},
},
}


Expand Down
6 changes: 3 additions & 3 deletions tests/test_compliance_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
Expand Down

0 comments on commit 546bff3

Please sign in to comment.