Skip to content

Use dot notation for commands #119

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
merged 1 commit into from
Aug 27, 2024
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
commands={'chk_cmd': 'show ip admission auth-proxy-banner http'}
)
def rule_134_set_the_banner_text_for_webauth_banner(commands, ref):
banner_text = commands['chk_cmd']
banner_text = commands.chk_cmd
assert 'Unauthorized access is prohibited' in banner_text, ref + " - Missing or incorrect banner text."
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def rule_1510_require_aes_128_as_minimum_for_snmp_server(configuration, commands
AssertionError: If any SNMPv3 user is not configured with AES 128 encryption.
"""

snmp_users_output = commands['show_snmp_user'].splitlines()
snmp_users_output = commands.show_snmp_user.splitlines()
snmp_v3_users_aes128 = [line for line in snmp_users_output if 'AES 128' in line or 'AES128' in line]

# Verify that there is at least one SNMPv3 user configured with AES 128
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
commands={'show_snmp_group': 'show snmp group'}
)
def rule_159_set_priv_for_each_snmp_server_group(configuration, commands, device, devices):
snmp_groups_output = commands['show_snmp_group'].splitlines()
snmp_groups_output = commands.show_snmp_group.splitlines()
snmp_v3_priv_groups = [
line for line in snmp_groups_output
if 'v3' in line and 'auth' in line and 'priv' in line
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ def rule_163_configuring_kerberos(configuration, commands, device, devices):
AssertionError: If Kerberos is not configured correctly or credentials are not set properly.
"""

kerberos_cred_output = commands['show_kerberos_cred']
config_lines = commands['show_running_config'].splitlines()
kerberos_cred_output = commands.show_kerberos_cred
config_lines = commands.show_running_config.splitlines()

# Check if Kerberos is enabled
assert 'kerberos' in config_lines, "Kerberos is not enabled on this device."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ def rule_164_configure_web_interface(configuration, commands, device, devices):
AssertionError: If configurations are not set correctly.
"""

ip_admission_output = commands['show_ip_admission']
config_lines = commands['show_running_config'].splitlines()
ip_admission_output = commands.show_ip_admission
config_lines = commands.show_running_config.splitlines()

# Check SISF-Based Device Tracking is enabled
assert 'device-tracking' in config_lines, \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def rule_321_set_ip_access_list_extended_to_forbid_private_source_addresses_from
other specified ranges.
"""

access_list_output = commands['show_ip_access_list'].splitlines()
access_list_output = commands.show_ip_access_list.splitlines()
required_deny_entries = [
'deny ip 127.0.0.0 0.255.255.255 any log',
'deny ip 10.0.0.0 0.255.255.255 any log',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
)
def rule_3331_set_key_chain(commands, ref):
# Extracting the key chain configuration from the command output
key_chain_config = commands['key_chain_config']
key_chain_config = commands.key_chain_config

# Verifying that a key chain is configured for EIGRP
assert 'key chain' in key_chain_config, ref
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
)
def rule_3332_set_key(commands, ref):
# Extracting the key chain configuration from the command output
key_chain_config = commands['key_chain_config']
key_chain_config = commands.key_chain_config

# Verifying that the key is properly set within a key chain
assert 'key' in key_chain_config, ref
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
)
def rule_3313_set_key_string(commands, ref):
# Extracting the key chain configuration from the command output
key_chain_detail = commands['key_chain_detail']
key_chain_detail = commands.key_chain_detail

# Verifying that the 'key-string' is configured within the key chain
assert 'key-string' in key_chain_detail, ref
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
)
def rule_3314_set_address_family_ipv4_autonomous_system(commands, ref):
# Extracting the EIGRP address family configuration from the command output
eigrp_config = commands['eigrp_config']
eigrp_config = commands.eigrp_config

# Verifying that the 'address-family ipv4 autonomous-system' is configured for EIGRP
assert 'address-family ipv4 autonomous-system' in eigrp_config, ref
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
)
def rule_3315_set_af_interface_default(commands, ref):
# Extracting the EIGRP address family interface configuration from the command output
eigrp_af_config = commands['eigrp_af_config']
eigrp_af_config = commands.eigrp_af_config

# Verifying that 'af-interface default' is configured within the EIGRP address family
assert 'af-interface default' in eigrp_af_config, ref
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
)
def rule_3316_set_authentication_key_chain(commands, ref):
# Extracting the EIGRP address family key chain configuration from the command output
eigrp_key_chain_config = commands['eigrp_key_chain_config']
eigrp_key_chain_config = commands.eigrp_key_chain_config

# Verifying that the 'authentication key-chain' is set within the EIGRP address family configuration
assert 'authentication key-chain' in eigrp_key_chain_config, ref
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
)
def rule_3321_set_authentication_message_digest_for_ospf_area(commands, ref):
# Extracting the OSPF configuration section from the command output
ospf_config = commands['ospf_config']
ospf_config = commands.ospf_config

# Checking if 'authentication message-digest' is configured in the OSPF section
assert 'area' in ospf_config and 'authentication message-digest' in ospf_config, ref
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def rule_3322_set_ip_ospf_message_digest_key_md5(commands, ref):
# modify the rule to iterate through a list of interfaces if needed.

# Extracting the OSPF MD5 key configuration from the command output
interface_config = commands['interface_config']
interface_config = commands.interface_config

# Verifying the presence of the OSPF MD5 key in the interface configuration
assert 'ip ospf message-digest-key' in interface_config and 'md5' in interface_config, ref
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
)
def rule_3331_set_key_chain(commands, ref):
# Extracting the key chain configuration from the command output
key_chain_config = commands['key_chain_config']
key_chain_config = commands.key_chain_config

# Verifying that a key chain is configured for RIPv2
assert 'key chain' in key_chain_config, ref
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
)
def rule_3332_set_key(commands, ref):
# Extracting the key chain configuration from the command output
key_chain_config = commands['key_chain_config']
key_chain_config = commands.key_chain_config

# Verifying that the key is properly set within a key chain
assert 'key' in key_chain_config, ref
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
)
def rule_3333_set_key_string(commands, ref):
# Extracting the key chain configuration from the command output
key_chain_detail = commands['key_chain_detail']
key_chain_detail = commands.key_chain_detail

# Verifying that the 'key-string' is configured within the key chain
assert 'key-string' in key_chain_detail, ref
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def rule_3334_set_ip_rip_authentication_key_chain(commands, ref):
# Replace {interface_name} and {rip_key-chain_name} with the actual interface and key chain names you want to test.

# Extracting the RIP v2 authentication configuration from the command output
interface_rip_config = commands['interface_rip_config']
interface_rip_config = commands.interface_rip_config

# Verifying that the RIP v2 authentication key chain is properly configured on the interface
assert 'ip rip authentication key-chain' in interface_rip_config, ref
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def rule_3335_set_ip_rip_authentication_mode_to_md5(commands, ref):
# Replace {interface_name} with the actual interface you want to test.

# Extracting the RIP v2 MD5 authentication mode configuration from the command output
interface_rip_mode_config = commands['interface_rip_mode_config']
interface_rip_mode_config = commands.interface_rip_mode_config

# Verifying that the RIP v2 authentication mode is set to MD5 on the interface
assert 'ip rip authentication mode md5' in interface_rip_mode_config, ref
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def rule_3341_require_bgp_auth_if_used(commands, ref):

The test checks if BGP is configured and if so, ensures the 'neighbor password' for authentication is present.
"""
bgp_config = commands['bgp_config']
bgp_config = commands.bgp_config
if 'router bgp' not in bgp_config:
return # BGP is not configured; no action needed
assert 'neighbor' in bgp_config and 'password' in bgp_config, ref
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def rule_3341_require_bgp_auth_if_used(commands, ref):

The test checks if BGP is configured and if so, ensures the 'neighbor password' for authentication is present.
"""
bgp_config = commands['bgp_config']
bgp_config = commands.bgp_config
if 'router bgp' not in bgp_config:
return # BGP is not configured; no action needed
assert 'neighbor' in bgp_config and 'password' in bgp_config, ref
Loading