Reject malformed 3PE query metadata results earlier in AS API handling code
This commit is contained in:
parent
f25d74f69c
commit
ed44c475d8
|
@ -162,11 +162,19 @@ class ApplicationServiceApi(SimpleHttpClient):
|
|||
urllib.quote(protocol)
|
||||
)
|
||||
try:
|
||||
defer.returnValue((yield self.get_json(uri, {})))
|
||||
info = yield self.get_json(uri, {})
|
||||
|
||||
# Ignore any result that doesn't contain an "instances" list
|
||||
if "instances" not in info:
|
||||
defer.returnValue(None)
|
||||
if not isinstance(info["instances"], list):
|
||||
defer.returnValue(None)
|
||||
|
||||
defer.returnValue(info)
|
||||
except Exception as ex:
|
||||
logger.warning("query_3pe_protocol to %s threw exception %s",
|
||||
uri, ex)
|
||||
defer.returnValue({})
|
||||
defer.returnValue(None)
|
||||
|
||||
key = (service.id, protocol)
|
||||
return self.protocol_meta_cache.get(key) or (
|
||||
|
|
|
@ -186,17 +186,13 @@ class ApplicationServicesHandler(object):
|
|||
if only_protocol is not None and p != only_protocol:
|
||||
continue
|
||||
|
||||
info = yield self.appservice_api.get_3pe_protocol(s, p)
|
||||
|
||||
# Ignore any result that doesn't contain an "instances" list
|
||||
if "instances" not in info:
|
||||
continue
|
||||
if not isinstance(info["instances"], list):
|
||||
continue
|
||||
|
||||
if p not in protocols:
|
||||
protocols[p] = []
|
||||
protocols[p].append(info)
|
||||
|
||||
info = yield self.appservice_api.get_3pe_protocol(s, p)
|
||||
|
||||
if info is not None:
|
||||
protocols[p].append(info)
|
||||
|
||||
def _merge_instances(infos):
|
||||
if not infos:
|
||||
|
|
Loading…
Reference in New Issue