Skip to content

Commit 1be1871

Browse files
authored
Improve risky-shell-pipe rule matching (#1453)
Removes one false positive case where user set ignore_errors: true, case in which the rule does not make much sense. Fixes: #1250
1 parent 857626b commit 1be1871

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

src/ansiblelint/rules/ShellWithoutPipefail.py

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from typing import Any, Dict, Union
33

44
from ansiblelint.rules import AnsibleLintRule
5+
from ansiblelint.utils import convert_to_boolean
56

67

78
class ShellWithoutPipefail(AnsibleLintRule):
@@ -39,4 +40,5 @@ def matchtask(self, task: Dict[str, Any]) -> Union[bool, str]:
3940
return bool(
4041
self._pipe_re.search(unjinjad_cmd)
4142
and not self._pipefail_re.match(unjinjad_cmd)
43+
and not convert_to_boolean(task['action'].get('ignore_errors', False))
4244
)

test/TestShellWithoutPipefail.py

+4
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,10 @@
6565
- shell: |
6666
set -o pipefail
6767
df | grep '/dev'
68+
69+
- name: should not fail due to ignore_errors being true
70+
shell: false | cat
71+
ignore_errors: true
6872
'''
6973

7074

0 commit comments

Comments
 (0)