forked from MirrorHub/synapse
Reject malformed 3PE query metadata results earlier in AS API handling code
This commit is contained in:
parent
f25d74f69c
commit
ed44c475d8
2 changed files with 15 additions and 11 deletions
|
@ -162,11 +162,19 @@ class ApplicationServiceApi(SimpleHttpClient):
|
||||||
urllib.quote(protocol)
|
urllib.quote(protocol)
|
||||||
)
|
)
|
||||||
try:
|
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:
|
except Exception as ex:
|
||||||
logger.warning("query_3pe_protocol to %s threw exception %s",
|
logger.warning("query_3pe_protocol to %s threw exception %s",
|
||||||
uri, ex)
|
uri, ex)
|
||||||
defer.returnValue({})
|
defer.returnValue(None)
|
||||||
|
|
||||||
key = (service.id, protocol)
|
key = (service.id, protocol)
|
||||||
return self.protocol_meta_cache.get(key) or (
|
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:
|
if only_protocol is not None and p != only_protocol:
|
||||||
continue
|
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:
|
if p not in protocols:
|
||||||
protocols[p] = []
|
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):
|
def _merge_instances(infos):
|
||||||
if not infos:
|
if not infos:
|
||||||
|
|
Loading…
Reference in a new issue