Check format of data retrieved from hook stdreturn

This commit is contained in:
Alexandre Aubin 2019-03-23 17:31:56 +01:00
parent dd87b9192a
commit 5ac5cc9310

View file

@ -437,6 +437,15 @@ def _build_dns_conf(domain, ttl=3600):
records[hook_name] = []
for record_list in custom_records:
# Check that record_list is indeed a list of dict
# with the required keys
if not isinstance(record_list, list) \
or any(not isinstance(record, dict) for record in record_list) \
or any(key not in record for record in record_list for key in ["name", "ttl", "type", "value"]):
# Display an error, mainly for app packagers trying to implement a hook
logger.warning("Ignored custom record from hook '%s' because the data is not a *list* of dict with keys name, ttl, type and value. Raw data : %s" % (hook_name, record_list))
continue
records[hook_name].extend(record_list)
return records