Skip to content
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
10 changes: 7 additions & 3 deletions modules/test/ntp/conf/module_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
},
{
"name": "ntp.network.ntp_dhcp",
"test_description": "Accept NTP address over DHCP",
"expected_behavior": "Device can accept NTP server address, provided by the DHCP server (DHCP OFFER PACKET)",
"test_description": "Accept NTP address over DHCP or from public trusted sources",
"expected_behavior": "Device can accept NTP server address, provided by the DHCP server (DHCP OFFER PACKET) or from public trusted sources.",
"config": {
"pools_with_subdomains": [
"pool.ntp.org",
Expand Down Expand Up @@ -101,7 +101,11 @@
]
},
"recommendations": [
"Install an NTP client that supports fetching the NTP servers from DHCP options"
"Install an NTP client that supports fetching the NTP servers from DHCP options",
"Verify that the device is configured to accept DHCP Option 42",
"Delete any hardcoded public IPs",
"Change the NTP setting from 'Static/Manual' to 'Authomatic/DCHP'",
"Restart the NTP daemon"
]
}
]
Expand Down
29 changes: 21 additions & 8 deletions modules/test/ntp/python/src/ntp_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,31 +365,44 @@ def _ntp_network_ntp_dhcp(self, config):
ntp_whitelist_resolver.is_ip_whitelisted(ip) for ip in ntp_to_remote_ips
)

result_details = [f'NTP request to {self._ntp_server}']

for ip in ntp_to_remote_ips:
if ntp_whitelist_resolver.is_ip_whitelisted(ip):
LOGGER.info(f'NTP server {ip} is in the trusted whitelist')
else:
LOGGER.info(f'NTP server {ip} is NOT in the trusted whitelist')
result_details.append(f'NTP request to {ip}')

result_state = 'Feature Not Detected'
result_message = 'Device has not sent any NTP requests'

result = 'Feature Not Detected', 'Device has not sent any NTP requests'

if device_sends_ntp:
if ntp_to_local and ntp_to_remote:
if ntp_to_remote_trusted:
result = True, ('Device sent NTP request to DHCP provided ' +
result_state = True
result_message = ('Device sent NTP request to DHCP provided ' +
'server and trusted non-DHCP provided servers')
else:
result = False, ('Device sent NTP request to DHCP provided ' +
result_state = False
result_message = ('Device sent NTP request to DHCP provided ' +
'server and to untrusted non-DHCP provided server')
elif ntp_to_remote:
if ntp_to_remote_trusted:
result = False, ('Device sent NTP request to trusted ' +
result_state = False
result_message = ('Device sent NTP request to trusted ' +
'non-DHCP provided server')
else:
result = False, ('Device sent NTP request to untrusted ' +
result_state = False
result_message = ('Device sent NTP request to untrusted ' +
'non-DHCP provided server')
elif ntp_to_local:
result = True, 'Device sent NTP request to DHCP provided server'
result_state = True
result_message ='Device sent NTP request to DHCP provided server'

LOGGER.info(result[1])
return result
if not ntp_to_local:
result_details.pop(0)

LOGGER.info(result_state)
return result_state, result_message, result_details
Loading