-
Notifications
You must be signed in to change notification settings - Fork 64
[NTC-4957] Fixed parsing Palo banners that start on the same line #794
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
Open
joewesch
wants to merge
3
commits into
develop
Choose a base branch
from
u/joewesch-fix-palo-banner-parsing
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+327
−1
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Fixed parsing of login banner in Palo Alto Networks config. |
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
1 change: 1 addition & 0 deletions
1
tests/unit/mock/config/compliance/compliance/paloalto_panos/paloalto_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 |
|---|---|---|
| @@ -1,3 +1,4 @@ | ||
| features = [ | ||
| {"name": "management", "ordered": False, "section": ["set mgt-config "]}, | ||
| {"name": "banner", "ordered": False, "section": ["set deviceconfig system login-banner "]}, | ||
| ] |
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
45 changes: 45 additions & 0 deletions
45
tests/unit/mock/config/conversion/paloalto_panos/paloalto_banner_same_line_converted.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,45 @@ | ||
| set deviceconfig system ip-address 192.0.2.72 | ||
| set deviceconfig system netmask 255.255.255.0 | ||
| set deviceconfig system update-server updates.paloaltonetworks.com | ||
| set deviceconfig system update-schedule threats recurring weekly day-of-week wednesday | ||
| set deviceconfig system update-schedule threats recurring weekly at 01:02 | ||
| set deviceconfig system update-schedule threats recurring weekly action download-only | ||
| set deviceconfig system timezone UTC | ||
| set deviceconfig system service disable-telnet yes | ||
| set deviceconfig system service disable-http yes | ||
| set deviceconfig system service disable-snmp no | ||
| set deviceconfig system hostname pa-ntc | ||
| set deviceconfig system type static | ||
| set deviceconfig system default-gateway 192.0.2.1 | ||
| set deviceconfig system domain ntc | ||
| set deviceconfig system locale en | ||
| set deviceconfig system speed-duplex auto-negotiate | ||
| set deviceconfig system dns-setting servers primary 8.8.8.8 | ||
| set deviceconfig system dns-setting servers secondary 1.1.1.1 | ||
| set deviceconfig system device-telemetry device-health-performance yes | ||
| set deviceconfig system device-telemetry product-usage yes | ||
| set deviceconfig system device-telemetry threat-prevention yes | ||
| set deviceconfig system device-telemetry region Americas | ||
| set deviceconfig system panorama local-panorama panorama-server 192.0.2.58 | ||
| set deviceconfig system server-verification no | ||
| set deviceconfig system ntp-servers primary-ntp-server ntp-server-address time.google.com | ||
| set deviceconfig system ntp-servers primary-ntp-server authentication-type none | ||
| set deviceconfig system login-banner "#################################################### | ||
| WARNING TO UNAUTHORIZED USERS: | ||
| This system is for use by authorized users only. | ||
| Any individual using this system, by such use, | ||
| acknowledges and consents to the right of the | ||
| company to monitor, access, use, and disclose any | ||
| information generated, received, or stored on the | ||
| systems, and waives any right of privacy or | ||
| expectation of privacy on the part of that | ||
| individual in connection with his or her use of | ||
| this system. Unauthorized and/or improper use of | ||
| this system, as delineated by corporate policies, | ||
| is not tolerated and the company may take formal | ||
| action against such individuals. | ||
| #################################################### | ||
| " | ||
| set deviceconfig system snmp-setting access-setting version v2c snmp-community-string ntc1234 | ||
| set deviceconfig system snmp-setting snmp-system location ntc | ||
| set deviceconfig system snmp-setting snmp-system contact "john smith" |
93 changes: 93 additions & 0 deletions
93
tests/unit/mock/config/conversion/paloalto_panos/paloalto_banner_same_line_sent.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,93 @@ | ||
| config { | ||
| devices { | ||
| localhost.localdomain { | ||
| deviceconfig { | ||
| system { | ||
| ip-address 192.0.2.72; | ||
| netmask 255.255.255.0; | ||
| update-server updates.paloaltonetworks.com; | ||
| update-schedule { | ||
| threats { | ||
| recurring { | ||
| weekly { | ||
| day-of-week wednesday; | ||
| at 01:02; | ||
| action download-only; | ||
| } | ||
| } | ||
| } | ||
| } | ||
| timezone UTC; | ||
| service { | ||
| disable-telnet yes; | ||
| disable-http yes; | ||
| disable-snmp no; | ||
| } | ||
| hostname pa-ntc; | ||
| type { | ||
| static; | ||
| } | ||
| default-gateway 192.0.2.1; | ||
| domain ntc; | ||
| locale en; | ||
| speed-duplex auto-negotiate; | ||
| dns-setting { | ||
| servers { | ||
| primary 8.8.8.8; | ||
| secondary 1.1.1.1; | ||
| } | ||
| } | ||
| device-telemetry { | ||
| device-health-performance yes; | ||
| product-usage yes; | ||
| threat-prevention yes; | ||
| region Americas; | ||
| } | ||
| panorama { | ||
| local-panorama { | ||
| panorama-server 192.0.2.58; | ||
| } | ||
| } | ||
| server-verification no; | ||
| ntp-servers { | ||
| primary-ntp-server { | ||
| ntp-server-address time.google.com; | ||
| authentication-type { | ||
| none; | ||
| } | ||
| } | ||
| } | ||
| login-banner "#################################################### | ||
| WARNING TO UNAUTHORIZED USERS: | ||
| This system is for use by authorized users only. | ||
| Any individual using this system, by such use, | ||
| acknowledges and consents to the right of the | ||
| company to monitor, access, use, and disclose any | ||
| information generated, received, or stored on the | ||
| systems, and waives any right of privacy or | ||
| expectation of privacy on the part of that | ||
| individual in connection with his or her use of | ||
| this system. Unauthorized and/or improper use of | ||
| this system, as delineated by corporate policies, | ||
| is not tolerated and the company may take formal | ||
| action against such individuals. | ||
| #################################################### | ||
| "; | ||
| snmp-setting { | ||
| access-setting { | ||
| version { | ||
| v2c { | ||
| snmp-community-string ntc1234; | ||
| } | ||
| } | ||
| } | ||
| snmp-system { | ||
| location ntc; | ||
| contact "john smith"; | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } |
53 changes: 53 additions & 0 deletions
53
tests/unit/mock/config/parser/base/paloalto_panos/paloalto_banner_same_line_received.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,53 @@ | ||
| from netutils.config.parser import ConfigLine | ||
|
|
||
| data = [ | ||
| ConfigLine(config_line="set deviceconfig system ip-address 192.0.2.72", parents=()), | ||
| ConfigLine(config_line="set deviceconfig system netmask 255.255.255.0", parents=()), | ||
| ConfigLine(config_line="set deviceconfig system update-server updates.paloaltonetworks.com", parents=()), | ||
| ConfigLine( | ||
| config_line="set deviceconfig system update-schedule threats recurring weekly day-of-week wednesday", parents=() | ||
| ), | ||
| ConfigLine(config_line="set deviceconfig system update-schedule threats recurring weekly at 01:02", parents=()), | ||
| ConfigLine( | ||
| config_line="set deviceconfig system update-schedule threats recurring weekly action download-only", parents=() | ||
| ), | ||
| ConfigLine(config_line="set deviceconfig system timezone UTC", parents=()), | ||
| ConfigLine(config_line="set deviceconfig system service disable-telnet yes", parents=()), | ||
| ConfigLine(config_line="set deviceconfig system service disable-http yes", parents=()), | ||
| ConfigLine(config_line="set deviceconfig system service disable-snmp no", parents=()), | ||
| ConfigLine(config_line="set deviceconfig system hostname pa-ntc", parents=()), | ||
| ConfigLine(config_line="set deviceconfig system type static", parents=()), | ||
| ConfigLine(config_line="set deviceconfig system default-gateway 192.0.2.1", parents=()), | ||
| ConfigLine(config_line="set deviceconfig system domain ntc", parents=()), | ||
| ConfigLine(config_line="set deviceconfig system locale en", parents=()), | ||
| ConfigLine(config_line="set deviceconfig system speed-duplex auto-negotiate", parents=()), | ||
| ConfigLine(config_line="set deviceconfig system dns-setting servers primary 8.8.8.8", parents=()), | ||
| ConfigLine(config_line="set deviceconfig system dns-setting servers secondary 1.1.1.1", parents=()), | ||
| ConfigLine(config_line="set deviceconfig system device-telemetry device-health-performance yes", parents=()), | ||
| ConfigLine(config_line="set deviceconfig system device-telemetry product-usage yes", parents=()), | ||
| ConfigLine(config_line="set deviceconfig system device-telemetry threat-prevention yes", parents=()), | ||
| ConfigLine(config_line="set deviceconfig system device-telemetry region Americas", parents=()), | ||
| ConfigLine(config_line="set deviceconfig system panorama local-panorama panorama-server 192.0.2.58", parents=()), | ||
| ConfigLine(config_line="set deviceconfig system server-verification no", parents=()), | ||
| ConfigLine( | ||
| config_line="set deviceconfig system ntp-servers primary-ntp-server ntp-server-address time.google.com", | ||
| parents=(), | ||
| ), | ||
| ConfigLine( | ||
| config_line="set deviceconfig system ntp-servers primary-ntp-server authentication-type none", parents=() | ||
| ), | ||
| ConfigLine( | ||
| config_line='set deviceconfig system login-banner "####################################################', | ||
| parents=(), | ||
| ), | ||
| ConfigLine( | ||
| config_line='WARNING TO UNAUTHORIZED USERS:\nThis system is for use by authorized users only.\nAny individual using this system, by such use,\nacknowledges and consents to the right of the\ncompany to monitor, access, use, and disclose any\ninformation generated, received, or stored on the\nsystems, and waives any right of privacy or\nexpectation of privacy on the part of that\nindividual in connection with his or her use of\nthis system. Unauthorized and/or improper use of\nthis system, as delineated by corporate policies,\nis not tolerated and the company may take formal\naction against such individuals.\n####################################################\n"', | ||
| parents=('set deviceconfig system login-banner "####################################################',), | ||
| ), | ||
| ConfigLine( | ||
| config_line="set deviceconfig system snmp-setting access-setting version v2c snmp-community-string ntc1234", | ||
| parents=(), | ||
| ), | ||
| ConfigLine(config_line="set deviceconfig system snmp-setting snmp-system location ntc", parents=()), | ||
| ConfigLine(config_line='set deviceconfig system snmp-setting snmp-system contact "john smith"', parents=()), | ||
| ] | ||
93 changes: 93 additions & 0 deletions
93
tests/unit/mock/config/parser/base/paloalto_panos/paloalto_banner_same_line_sent.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,93 @@ | ||
| config { | ||
| devices { | ||
| localhost.localdomain { | ||
| deviceconfig { | ||
| system { | ||
| ip-address 192.0.2.72; | ||
| netmask 255.255.255.0; | ||
| update-server updates.paloaltonetworks.com; | ||
| update-schedule { | ||
| threats { | ||
| recurring { | ||
| weekly { | ||
| day-of-week wednesday; | ||
| at 01:02; | ||
| action download-only; | ||
| } | ||
| } | ||
| } | ||
| } | ||
| timezone UTC; | ||
| service { | ||
| disable-telnet yes; | ||
| disable-http yes; | ||
| disable-snmp no; | ||
| } | ||
| hostname pa-ntc; | ||
| type { | ||
| static; | ||
| } | ||
| default-gateway 192.0.2.1; | ||
| domain ntc; | ||
| locale en; | ||
| speed-duplex auto-negotiate; | ||
| dns-setting { | ||
| servers { | ||
| primary 8.8.8.8; | ||
| secondary 1.1.1.1; | ||
| } | ||
| } | ||
| device-telemetry { | ||
| device-health-performance yes; | ||
| product-usage yes; | ||
| threat-prevention yes; | ||
| region Americas; | ||
| } | ||
| panorama { | ||
| local-panorama { | ||
| panorama-server 192.0.2.58; | ||
| } | ||
| } | ||
| server-verification no; | ||
| ntp-servers { | ||
| primary-ntp-server { | ||
| ntp-server-address time.google.com; | ||
| authentication-type { | ||
| none; | ||
| } | ||
| } | ||
| } | ||
| login-banner "#################################################### | ||
| WARNING TO UNAUTHORIZED USERS: | ||
| This system is for use by authorized users only. | ||
| Any individual using this system, by such use, | ||
| acknowledges and consents to the right of the | ||
| company to monitor, access, use, and disclose any | ||
| information generated, received, or stored on the | ||
| systems, and waives any right of privacy or | ||
| expectation of privacy on the part of that | ||
| individual in connection with his or her use of | ||
| this system. Unauthorized and/or improper use of | ||
| this system, as delineated by corporate policies, | ||
| is not tolerated and the company may take formal | ||
| action against such individuals. | ||
| #################################################### | ||
| "; | ||
| snmp-setting { | ||
| access-setting { | ||
| version { | ||
| v2c { | ||
| snmp-community-string ntc1234; | ||
| } | ||
| } | ||
| } | ||
| snmp-system { | ||
| location ntc; | ||
| contact "john smith"; | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } |
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.