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

Improve risky-shell-pipe rule matching #1453

Merged
merged 1 commit into from Mar 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/ansiblelint/rules/ShellWithoutPipefail.py
Expand Up @@ -2,6 +2,7 @@
from typing import Any, Dict, Union

from ansiblelint.rules import AnsibleLintRule
from ansiblelint.utils import convert_to_boolean


class ShellWithoutPipefail(AnsibleLintRule):
Expand Down Expand Up @@ -39,4 +40,5 @@ def matchtask(self, task: Dict[str, Any]) -> Union[bool, str]:
return bool(
self._pipe_re.search(unjinjad_cmd)
and not self._pipefail_re.match(unjinjad_cmd)
and not convert_to_boolean(task['action'].get('ignore_errors', False))
)
4 changes: 4 additions & 0 deletions test/TestShellWithoutPipefail.py
Expand Up @@ -65,6 +65,10 @@
- shell: |
set -o pipefail
df | grep '/dev'

- name: should not fail due to ignore_errors being true
shell: false | cat
ignore_errors: true
'''


Expand Down