-
Notifications
You must be signed in to change notification settings - Fork 64
Add HP Comware config parser #467
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
Merged
itdependsnetworks
merged 6 commits into
networktocode:develop
from
bintangf:feature/parsers/hp_comware
Mar 28, 2024
Merged
Changes from 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
9481cad
Add HP Comware config parser
bintangf 209f5d0
add non-compliant banner test
bintangf 93428c4
bad banner different delimiter & single line banner
bintangf 523c97a
Refactor HP Parser & Make linting tests happy
bintangf ddf2c68
Merge branch 'develop' into feature/parsers/hp_comware
itdependsnetworks d525c15
Update netutils/lib_mapper.py
itdependsnetworks File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
5 changes: 5 additions & 0 deletions
5
tests/unit/mock/config/compliance/compliance/hp_comware/hp_comware_bad_banner_backup.txt
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| # | ||
| header motd "my banner" | ||
| # | ||
| hwtacacs nas-ip 1.1.1.1 | ||
| # |
3 changes: 3 additions & 0 deletions
3
tests/unit/mock/config/compliance/compliance/hp_comware/hp_comware_bad_banner_feature.py
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| features = [ | ||
| {"name": "header", "ordered": True, "section": ["header "]}, | ||
| ] |
9 changes: 9 additions & 0 deletions
9
tests/unit/mock/config/compliance/compliance/hp_comware/hp_comware_bad_banner_intended.txt
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| # | ||
| header motd ^C | ||
| =================================================== | ||
| * GOOD DATA LINE 1 | ||
| * BAD DATA LINE 2 | ||
| ==================================================^C | ||
| # | ||
| hwtacacs nas-ip 1.1.1.4 | ||
| # |
12 changes: 12 additions & 0 deletions
12
tests/unit/mock/config/compliance/compliance/hp_comware/hp_comware_bad_banner_received.json
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| { | ||
| "header": { | ||
| "compliant": false, | ||
| "missing": "header motd ^C\n===================================================\n* GOOD DATA LINE 1\n* BAD DATA LINE 2\n==================================================^C", | ||
| "extra": "header motd \"my banner\"", | ||
| "cannot_parse": true, | ||
| "unordered_compliant": false, | ||
| "ordered_compliant": false, | ||
| "actual": "header motd \"my banner\"", | ||
| "intended": "header motd ^C\n===================================================\n* GOOD DATA LINE 1\n* BAD DATA LINE 2\n==================================================^C" | ||
| } | ||
| } |
48 changes: 48 additions & 0 deletions
48
tests/unit/mock/config/compliance/compliance/hp_comware/hp_comware_basic_backup.txt
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| sysname HP-JKT-01 | ||
| # | ||
| dhcp enable | ||
| dhcp server forbidden-ip 10.10.10.1 10.10.10.100 | ||
| dhcp server always-broadcast | ||
| # | ||
| dhcp server ip-pool CKP | ||
| gateway-list 10.10.10.1 | ||
| domain-name intra.data.co.id | ||
| expired day 30 | ||
| netbios-type b-node | ||
| # | ||
| bgp 65330 | ||
| router-id 10.10.10.254 | ||
| graceful-restart | ||
| graceful-restart timer restart 120 | ||
| graceful-restart timer wait-for-rib 360 | ||
| peer 10.20.240.1 description ***Point to Point Connection** | ||
| peer 10.20.240.1 ebgp-max-hop 10 | ||
| peer 10.30.240.1 password cipher $x$x$xxxxxxxxxxxxxxxxxxxxxxxxxxxx/xxxxxxxxxxxx== | ||
| address-family ipv4 unicast | ||
| balance 4 | ||
| peer 10.30.240.1 enable | ||
| peer 10.30.240.1 route-policy P2P-FirstTry import | ||
| peer 10.30.240.1 route-policy P2P-FirstTry export | ||
| # | ||
| snmp-agent | ||
| snmp-agent local-engineid 8000XXX123456789AB503C00000001 | ||
| snmp-agent community read RO | ||
| snmp-agent community read read | ||
| snmp-agent community read ro | ||
| # | ||
| acl advanced name HPE | ||
| rule 1 permit source 10.180.50.254 0 destination 10.1.0.249 0 | ||
| rule 2 permit source 10.180.50.0 0.0.0.127 destination 10.1.4.62 0 | ||
| rule 3 permit source 10.180.50.0 0.0.0.127 destination 10.2.4.62 0 | ||
| # | ||
| header motd # | ||
| =================================================== | ||
|
|
||
| !!! WARNING !!! | ||
| system monitoring for law enforcement and other | ||
| purpose. Unauthorized use of this machine may | ||
| subject you to criminal prosecution and penalties | ||
|
|
||
| ==================================================# | ||
| # | ||
| return |
7 changes: 7 additions & 0 deletions
7
tests/unit/mock/config/compliance/compliance/hp_comware/hp_comware_basic_feature.py
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| features = [ | ||
| {"name": "bgp", "ordered": True, "section": ["bgp "]}, | ||
| {"name": "snmp-agent", "ordered": True, "section": ["snmp-server "]}, | ||
| {"name": "dhcp", "ordered": False, "section": ["dhcp "]}, | ||
| {"name": "header", "ordered": True, "section": ["header "]}, | ||
| {"name": "acl", "ordered": True, "section": ["acl "]}, | ||
| ] |
48 changes: 48 additions & 0 deletions
48
tests/unit/mock/config/compliance/compliance/hp_comware/hp_comware_basic_intended.txt
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| sysname HP-JKT-01 | ||
| # | ||
| dhcp enable | ||
| dhcp server forbidden-ip 10.10.10.1 10.10.10.100 | ||
| dhcp server always-broadcast | ||
| # | ||
| dhcp server ip-pool CKP | ||
| gateway-list 10.10.10.1 | ||
| domain-name intra.data.co.id | ||
| expired day 30 | ||
| netbios-type b-node | ||
| # | ||
| bgp 65330 | ||
| router-id 10.10.10.254 | ||
| graceful-restart | ||
| graceful-restart timer restart 120 | ||
| graceful-restart timer wait-for-rib 360 | ||
| peer 10.20.240.1 description ***Point to Point Connection** | ||
| peer 10.20.240.1 ebgp-max-hop 10 | ||
| peer 10.30.240.1 password cipher $x$x$xxxxxxxxxxxxxxxxxxxxxxxxxxxx/xxxxxxxxxxxx== | ||
| address-family ipv4 unicast | ||
| balance 4 | ||
| peer 10.30.240.1 enable | ||
| peer 10.30.240.1 route-policy P2P-FirstTry import | ||
| peer 10.30.240.1 route-policy P2P-FirstTry export | ||
| # | ||
| snmp-agent | ||
| snmp-agent local-engineid 8000XXX123456789AB503C00000001 | ||
| snmp-agent community read RO | ||
| snmp-agent community read read | ||
| snmp-agent community read ro | ||
| # | ||
| acl advanced name HPE | ||
| rule 1 permit source 10.180.60.254 0 destination 10.1.0.249 0 | ||
| rule 2 permit source 10.180.60.0 0.0.0.127 destination 10.1.4.62 0 | ||
| rule 3 permit source 10.180.60.0 0.0.0.127 destination 10.2.4.62 0 | ||
| # | ||
| header motd # | ||
| =================================================== | ||
|
|
||
| !!! WARNING !!! | ||
| system monitoring for law enforcement and other | ||
| purpose. Unauthorized use of this machine may | ||
| subject you to criminal prosecution and penalties | ||
|
|
||
| ==================================================# | ||
| # | ||
| return |
52 changes: 52 additions & 0 deletions
52
tests/unit/mock/config/compliance/compliance/hp_comware/hp_comware_basic_received.json
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| { | ||
| "bgp": { | ||
| "compliant": true, | ||
| "missing": "", | ||
| "extra": "", | ||
| "cannot_parse": true, | ||
| "unordered_compliant": true, | ||
| "ordered_compliant": true, | ||
| "actual": "bgp 65330\n router-id 10.10.10.254\n graceful-restart\n graceful-restart timer restart 120\n graceful-restart timer wait-for-rib 360\n peer 10.20.240.1 description ***Point to Point Connection**\n peer 10.20.240.1 ebgp-max-hop 10\n peer 10.30.240.1 password cipher $x$x$xxxxxxxxxxxxxxxxxxxxxxxxxxxx/xxxxxxxxxxxx==\n address-family ipv4 unicast\n balance 4\n peer 10.30.240.1 enable\n peer 10.30.240.1 route-policy P2P-FirstTry import\n peer 10.30.240.1 route-policy P2P-FirstTry export", | ||
| "intended": "bgp 65330\n router-id 10.10.10.254\n graceful-restart\n graceful-restart timer restart 120\n graceful-restart timer wait-for-rib 360\n peer 10.20.240.1 description ***Point to Point Connection**\n peer 10.20.240.1 ebgp-max-hop 10\n peer 10.30.240.1 password cipher $x$x$xxxxxxxxxxxxxxxxxxxxxxxxxxxx/xxxxxxxxxxxx==\n address-family ipv4 unicast\n balance 4\n peer 10.30.240.1 enable\n peer 10.30.240.1 route-policy P2P-FirstTry import\n peer 10.30.240.1 route-policy P2P-FirstTry export" | ||
| }, | ||
| "snmp-agent": { | ||
| "compliant": true, | ||
| "missing": "", | ||
| "extra": "", | ||
| "cannot_parse": true, | ||
| "unordered_compliant": true, | ||
| "ordered_compliant": true, | ||
| "actual": "", | ||
| "intended": "" | ||
| }, | ||
| "dhcp": { | ||
| "compliant": true, | ||
| "missing": "", | ||
| "extra": "", | ||
| "cannot_parse": true, | ||
| "unordered_compliant": true, | ||
| "ordered_compliant": true, | ||
| "actual": "dhcp enable\ndhcp server forbidden-ip 10.10.10.1 10.10.10.100\ndhcp server always-broadcast\ndhcp server ip-pool CKP\n gateway-list 10.10.10.1\n domain-name intra.data.co.id\n expired day 30\n netbios-type b-node", | ||
| "intended": "dhcp enable\ndhcp server forbidden-ip 10.10.10.1 10.10.10.100\ndhcp server always-broadcast\ndhcp server ip-pool CKP\n gateway-list 10.10.10.1\n domain-name intra.data.co.id\n expired day 30\n netbios-type b-node" | ||
| }, | ||
| "header": { | ||
| "compliant": true, | ||
| "missing": "", | ||
| "extra": "", | ||
| "cannot_parse": true, | ||
| "unordered_compliant": true, | ||
| "ordered_compliant": true, | ||
| "actual": "header motd #\n===================================================\n!!! WARNING !!!\nsystem monitoring for law enforcement and other\npurpose. Unauthorized use of this machine may\nsubject you to criminal prosecution and penalties\n==================================================#", | ||
| "intended": "header motd #\n===================================================\n!!! WARNING !!!\nsystem monitoring for law enforcement and other\npurpose. Unauthorized use of this machine may\nsubject you to criminal prosecution and penalties\n==================================================#" | ||
| }, | ||
| "acl": { | ||
| "compliant": false, | ||
| "missing": "acl advanced name HPE\n rule 1 permit source 10.180.60.254 0 destination 10.1.0.249 0\n rule 2 permit source 10.180.60.0 0.0.0.127 destination 10.1.4.62 0\n rule 3 permit source 10.180.60.0 0.0.0.127 destination 10.2.4.62 0", | ||
| "extra": "acl advanced name HPE\n rule 1 permit source 10.180.50.254 0 destination 10.1.0.249 0\n rule 2 permit source 10.180.50.0 0.0.0.127 destination 10.1.4.62 0\n rule 3 permit source 10.180.50.0 0.0.0.127 destination 10.2.4.62 0", | ||
| "cannot_parse": true, | ||
| "unordered_compliant": false, | ||
| "ordered_compliant": false, | ||
| "actual": "acl advanced name HPE\n rule 1 permit source 10.180.50.254 0 destination 10.1.0.249 0\n rule 2 permit source 10.180.50.0 0.0.0.127 destination 10.1.4.62 0\n rule 3 permit source 10.180.50.0 0.0.0.127 destination 10.2.4.62 0", | ||
| "intended": "acl advanced name HPE\n rule 1 permit source 10.180.60.254 0 destination 10.1.0.249 0\n rule 2 permit source 10.180.60.0 0.0.0.127 destination 10.1.4.62 0\n rule 3 permit source 10.180.60.0 0.0.0.127 destination 10.2.4.62 0" | ||
| } | ||
| } |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.