Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[controller ansiballz] escape directory regex #74270

Merged
merged 4 commits into from
Apr 15, 2021

Conversation

relrod
Copy link
Member

@relrod relrod commented Apr 14, 2021

SUMMARY

Change:

  • We were passing a directory name directly to re.compile().
    If the directory isn't valid regex (or is) this can have odd side
    effects, such as crashing.

Test Plan:

  • None yet, how do I test this?

Signed-off-by: Rick Elrod rick@elrod.me

Without this:

ERROR! Unexpected Exception, this is probably a bug: unterminated character set at position 31
the full traceback was:

Traceback (most recent call last):
  File "/Users/rick/dev/ansible/ansible[devel/bin/ansible", line 123, in <module>
    exit_code = cli.run()
  File "/Users/rick/dev/ansible/ansible[devel/lib/ansible/cli/adhoc.py", line 166, in run
    result = self._tqm.run(play)
  File "/Users/rick/dev/ansible/ansible[devel/lib/ansible/executor/task_queue_manager.py", line 261, in run
    strategy = strategy_loader.get(new_play.strategy, self)
  File "/Users/rick/dev/ansible/ansible[devel/lib/ansible/plugins/loader.py", line 547, in get
    name, path = self.find_plugin_with_name(name, collection_list=collection_list)
  File "/Users/rick/dev/ansible/ansible[devel/lib/ansible/plugins/loader.py", line 414, in find_plugin_with_name
    return name, self._find_plugin_legacy(name, ignore_deprecated, check_aliases, suffix)
  File "/Users/rick/dev/ansible/ansible[devel/lib/ansible/plugins/loader.py", line 439, in _find_plugin_legacy
    for path in (p for p in self._get_paths() if p not in self._searched_paths and os.path.isdir(p)):
  File "/Users/rick/dev/ansible/ansible[devel/lib/ansible/plugins/loader.py", line 255, in _get_paths
    ret.extend(self._get_package_paths(subdirs=subdirs))
  File "/Users/rick/dev/ansible/ansible[devel/lib/ansible/plugins/loader.py", line 220, in _get_package_paths
    m = __import__(self.package)
  File "/Users/rick/dev/ansible/ansible[devel/lib/ansible/plugins/strategy/__init__.py", line 38, in <module>
    from ansible.executor.process.worker import WorkerProcess
  File "/Users/rick/dev/ansible/ansible[devel/lib/ansible/executor/process/worker.py", line 39, in <module>
    from ansible.executor.task_executor import TaskExecutor
  File "/Users/rick/dev/ansible/ansible[devel/lib/ansible/executor/task_executor.py", line 20, in <module>
    from ansible.executor.module_common import get_action_args_with_defaults
  File "/Users/rick/dev/ansible/ansible[devel/lib/ansible/executor/module_common.py", line 417, in <module>
    CORE_LIBRARY_PATH_RE = re.compile(r'%s/(?P<path>ansible/modules/.*)\.py$' % site_packages)
  File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/re.py", line 250, in compile
    return _compile(pattern, flags)
  File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/re.py", line 302, in _compile
    p = sre_compile.compile(pattern, flags)
  File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/sre_compile.py", line 764, in compile
    p = sre_parse.parse(p, flags)
  File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/sre_parse.py", line 948, in parse
    p = _parse_sub(source, state, flags & SRE_FLAG_VERBOSE, 0)
  File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/sre_parse.py", line 443, in _parse_sub
    itemsappend(_parse(source, state, verbose, nested + 1,
  File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/sre_parse.py", line 549, in _parse
    raise source.error("unterminated character set",
re.error: unterminated character set at position 31
ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME

ansiballz but controller side

Change:
- We were passing a directory name directly to re.compile().
  If the directory isn't valid regex (or is) this can have odd side
  effects, such as crashing.

Test Plan:
- None yet, how do I test this?

Signed-off-by: Rick Elrod <rick@elrod.me>
@ansibot ansibot added affects_2.12 bug This issue/PR relates to a bug. core_review In order to be merged, this PR must follow the core review workflow. needs_triage Needs a first human triage before being processed. python3 support:core This issue/PR relates to code supported by the Ansible Engineering Team. traceback This issue/PR includes a traceback. labels Apr 14, 2021
@bcoca
Copy link
Member

bcoca commented Apr 14, 2021

do you have a test case to trigger this?

@relrod
Copy link
Member Author

relrod commented Apr 14, 2021

I am able to trigger it locally (moving my clone of the repo to ansible[foo will trigger it). I don't know if it's possible to write a test case that does that, I need to discuss with mattclay.

Signed-off-by: Rick Elrod <rick@elrod.me>
Signed-off-by: Rick Elrod <rick@elrod.me>
@ansibot ansibot added support:community This issue/PR relates to code supported by the Ansible community. needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. and removed core_review In order to be merged, this PR must follow the core review workflow. labels Apr 15, 2021
@jborean93 jborean93 removed the needs_triage Needs a first human triage before being processed. label Apr 15, 2021
Signed-off-by: Rick Elrod <rick@elrod.me>
@ansibot ansibot added core_review In order to be merged, this PR must follow the core review workflow. needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. and removed needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. core_review In order to be merged, this PR must follow the core review workflow. labels Apr 15, 2021
@relrod relrod merged commit 7ef3dc2 into ansible:devel Apr 15, 2021
@ansible ansible locked and limited conversation to collaborators May 13, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.12 bug This issue/PR relates to a bug. core_review In order to be merged, this PR must follow the core review workflow. python3 support:community This issue/PR relates to code supported by the Ansible community. support:core This issue/PR relates to code supported by the Ansible Engineering Team. traceback This issue/PR includes a traceback.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants