Skip to content

Commit

Permalink
protect against plugins using verify incorrectly
Browse files Browse the repository at this point in the history
assume false on any errors

(cherry picked from commit ef40e5e)

backport of #36591
  • Loading branch information
bcoca committed Apr 30, 2018
1 parent 27b1044 commit 8048609
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 2 additions & 0 deletions changelogs/fragments/protect_bad_verify.yml
@@ -0,0 +1,2 @@
bugfixes:
- protect against bad plugin verify method https://github.com/ansible/ansible/pull/36591
9 changes: 7 additions & 2 deletions lib/ansible/inventory/manager.py
Expand Up @@ -257,8 +257,13 @@ def parse_source(self, source, cache=False):
plugin_name = to_native(getattr(plugin, '_load_name', getattr(plugin, '_original_path', '')))
display.debug(u'Attempting to use plugin %s (%s)' % (plugin_name, plugin._original_path))

# initialize
if plugin.verify_file(source):
# initialize and figure out if plugin wants to attempt parsing this file
try:
plugin_wants = bool(plugin.verify_file(source))
except Exception:
plugin_wants = False

if plugin_wants:
try:
# in case plugin fails 1/2 way we dont want partial inventory
plugin.parse(self._inventory, self._loader, source, cache=cache)
Expand Down

0 comments on commit 8048609

Please sign in to comment.