From 5ac5cc93107efea4a5855afb686d4f4640d244bf Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Sat, 23 Mar 2019 17:31:56 +0100 Subject: [PATCH] Check format of data retrieved from hook stdreturn --- src/yunohost/domain.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/yunohost/domain.py b/src/yunohost/domain.py index a7141e0b8..70a4ef5c9 100644 --- a/src/yunohost/domain.py +++ b/src/yunohost/domain.py @@ -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