Reject unknown types from results queue. Fixes #70023 (#71336)

This commit is contained in:
Matt Martz 2020-08-27 12:43:20 -05:00 committed by GitHub
parent 3f41c76564
commit c04a751f0e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 9 deletions

View file

@ -0,0 +1,5 @@
bugfixes:
- Strategy - Ensure we only process expected types from the results queue
and produce warnings for any object we receive from the queue that doesn't
match our expectations.
(https://github.com/ansible/ansible/issues/70023)

View file

@ -100,16 +100,17 @@ def results_thread_main(strategy):
result = strategy._final_q.get()
if isinstance(result, StrategySentinel):
break
elif isinstance(result, TaskResult):
with strategy._results_lock:
# only handlers have the listen attr, so this must be a handler
# we split up the results into two queues here to make sure
# handler and regular result processing don't cross wires
if 'listen' in result._task_fields:
strategy._handler_results.append(result)
else:
strategy._results.append(result)
else:
strategy._results_lock.acquire()
# only handlers have the listen attr, so this must be a handler
# we split up the results into two queues here to make sure
# handler and regular result processing don't cross wires
if 'listen' in result._task_fields:
strategy._handler_results.append(result)
else:
strategy._results.append(result)
strategy._results_lock.release()
display.warning('Received an invalid object (%s) in the result queue: %r' % (type(result), result))
except (IOError, EOFError):
break
except Queue.Empty: