Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changes/780.fixed
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed parsing of login banner in Palo Alto Networks config.
2 changes: 1 addition & 1 deletion netutils/config/conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ def paloalto_panos_brace_to_set(cfg: str, cfg_type: str = "file") -> str:
line = line.split("config ", 1)[1]
line = "set " + line
cfg_value.append(line.strip())
elif line.endswith('login-banner "') or line.endswith('content "'):
elif "login-banner" in line or line.endswith('content "'):
_first_banner_line = "".join(str(s) for s in stack) + line
cfg_value.append("set " + _first_banner_line.split("config ", 1)[1])

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,20 @@ set deviceconfig system service disable-http yes
set deviceconfig system service disable-snmp no
set deviceconfig system snmp-setting snmp-system
set deviceconfig system hostname firewall1
set deviceconfig system login-banner "
************************************************************************
* firewall1.example.com * [PROD VM500 firewalls]
************************************************************************
* WARNING *
* Unauthorized access to this device or devices attached to *
* or accessible from this network is strictly prohibited. *
* Possession of passwords or devices enabling access to this *
* device or devices does not constitute authorization. Unauthorized *
* access will be prosecuted to the fullest extent of the law. *
* *
************************************************************************

"
set deviceconfig system default-gateway 10.1.1.1
set deviceconfig system dns-setting servers primary 10.1.1.3
set deviceconfig system dns-setting servers secondary 10.1.1.4
Expand Down
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 "]},
]
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,22 @@ set deviceconfig system service disable-http yes
set deviceconfig system service disable-snmp no
set deviceconfig system snmp-setting snmp-system
set deviceconfig system hostname firewall1
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 default-gateway 10.1.1.1
set deviceconfig system dns-setting servers primary 10.1.1.3
set deviceconfig system dns-setting servers secondary 10.1.1.4
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,15 @@
"missing": "",
"ordered_compliant": true,
"unordered_compliant": true
},
"banner": {
"compliant": false,
"missing": "set deviceconfig system login-banner \"####################################################\nWARNING 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\"",
"extra": "set deviceconfig system login-banner \"\n************************************************************************\n* firewall1.example.com * [PROD VM500 firewalls]\n************************************************************************\n* WARNING *\n* Unauthorized access to this device or devices attached to *\n* or accessible from this network is strictly prohibited. *\n* Possession of passwords or devices enabling access to this *\n* device or devices does not constitute authorization. Unauthorized *\n* access will be prosecuted to the fullest extent of the law. *\n* *\n************************************************************************\n\"",
"cannot_parse": true,
"unordered_compliant": false,
"ordered_compliant": false,
"actual": "set deviceconfig system login-banner \"\n************************************************************************\n* firewall1.example.com * [PROD VM500 firewalls]\n************************************************************************\n* WARNING *\n* Unauthorized access to this device or devices attached to *\n* or accessible from this network is strictly prohibited. *\n* Possession of passwords or devices enabling access to this *\n* device or devices does not constitute authorization. Unauthorized *\n* access will be prosecuted to the fullest extent of the law. *\n* *\n************************************************************************\n\"",
"intended": "set deviceconfig system login-banner \"####################################################\nWARNING 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\""
}
}
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"
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";
}
}
}
}
}
}
}
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=()),
]
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";
}
}
}
}
}
}
}