Skip to content

Commit 14393ac

Browse files
authored
Fix multiline jinja pattern in schema (#2775)
Fixes: #2772
1 parent 7e98294 commit 14393ac

16 files changed

Lines changed: 64 additions & 55 deletions

src/ansiblelint/schemas/__main__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# pragma: no cover
33
import sys
44

5-
from .main import refresh_schemas
5+
from ansiblelint.schemas.main import refresh_schemas
66

77
if __name__ == "__main__":
88

src/ansiblelint/schemas/ansible.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@
248248
"title": "Environment"
249249
},
250250
"full-jinja": {
251-
"pattern": "^\\{\\{.*\\}\\}$",
251+
"pattern": "^\\{\\{(.|[\r\n])*\\}\\}$",
252252
"type": "string"
253253
},
254254
"ignore_errors": {

src/ansiblelint/schemas/playbook.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@
259259
"title": "Environment"
260260
},
261261
"full-jinja": {
262-
"pattern": "^\\{\\{.*\\}\\}$",
262+
"pattern": "^\\{\\{(.|[\r\n])*\\}\\}$",
263263
"type": "string"
264264
},
265265
"ignore_errors": {

src/ansiblelint/schemas/tasks.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@
211211
"title": "Environment"
212212
},
213213
"full-jinja": {
214-
"pattern": "^\\{\\{.*\\}\\}$",
214+
"pattern": "^\\{\\{(.|[\r\n])*\\}\\}$",
215215
"type": "string"
216216
},
217217
"ignore_errors": {

test/schemas/negative_test/playbooks/environment.yml.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,9 @@
5959
{
6060
"instancePath": "/0/environment",
6161
"keyword": "pattern",
62-
"message": "must match pattern \"^\\{\\{.*\\}\\}$\"",
62+
"message": "must match pattern \"^\\{\\{(.|[\r\n])*\\}\\}$\"",
6363
"params": {
64-
"pattern": "^\\{\\{.*\\}\\}$"
64+
"pattern": "^\\{\\{(.|[\r\n])*\\}\\}$"
6565
},
6666
"schemaPath": "#/$defs/full-jinja/pattern"
6767
},
@@ -128,7 +128,7 @@ stdout:
128128
},
129129
{
130130
"path": "$[0].environment",
131-
"message": "'{{ foo }}-123' does not match '^\\\\{\\\\{.*\\\\}\\\\}$'"
131+
"message": "'{{ foo }}-123' does not match '^\\\\{\\\\{(.|[\\r\\n])*\\\\}\\\\}$'"
132132
}
133133
]
134134
}

test/schemas/negative_test/playbooks/ignore_errors.yml.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,9 @@
5959
{
6060
"instancePath": "/0/tasks/0/ignore_errors",
6161
"keyword": "pattern",
62-
"message": "must match pattern \"^\\{\\{.*\\}\\}$\"",
62+
"message": "must match pattern \"^\\{\\{(.|[\r\n])*\\}\\}$\"",
6363
"params": {
64-
"pattern": "^\\{\\{.*\\}\\}$"
64+
"pattern": "^\\{\\{(.|[\r\n])*\\}\\}$"
6565
},
6666
"schemaPath": "#/$defs/full-jinja/pattern"
6767
},
@@ -95,9 +95,9 @@
9595
{
9696
"instancePath": "/0/tasks/0/ignore_errors",
9797
"keyword": "pattern",
98-
"message": "must match pattern \"^\\{\\{.*\\}\\}$\"",
98+
"message": "must match pattern \"^\\{\\{(.|[\r\n])*\\}\\}$\"",
9999
"params": {
100-
"pattern": "^\\{\\{.*\\}\\}$"
100+
"pattern": "^\\{\\{(.|[\r\n])*\\}\\}$"
101101
},
102102
"schemaPath": "#/$defs/full-jinja/pattern"
103103
},
@@ -177,7 +177,7 @@ stdout:
177177
},
178178
{
179179
"path": "$[0].tasks[0].ignore_errors",
180-
"message": "'should_ignore_errors' does not match '^\\\\{\\\\{.*\\\\}\\\\}$'"
180+
"message": "'should_ignore_errors' does not match '^\\\\{\\\\{(.|[\\r\\n])*\\\\}\\\\}$'"
181181
},
182182
{
183183
"path": "$[0].tasks[0].ignore_errors",
@@ -189,7 +189,7 @@ stdout:
189189
},
190190
{
191191
"path": "$[0].tasks[0].ignore_errors",
192-
"message": "'should_ignore_errors' does not match '^\\\\{\\\\{.*\\\\}\\\\}$'"
192+
"message": "'should_ignore_errors' does not match '^\\\\{\\\\{(.|[\\r\\n])*\\\\}\\\\}$'"
193193
},
194194
{
195195
"path": "$[0].tasks[0]",

test/schemas/negative_test/playbooks/invalid-serial.yml.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,9 @@
6868
{
6969
"instancePath": "/0/serial",
7070
"keyword": "pattern",
71-
"message": "must match pattern \"^\\{\\{.*\\}\\}$\"",
71+
"message": "must match pattern \"^\\{\\{(.|[\r\n])*\\}\\}$\"",
7272
"params": {
73-
"pattern": "^\\{\\{.*\\}\\}$"
73+
"pattern": "^\\{\\{(.|[\r\n])*\\}\\}$"
7474
},
7575
"schemaPath": "#/$defs/full-jinja/pattern"
7676
},
@@ -163,7 +163,7 @@ stdout:
163163
},
164164
{
165165
"path": "$[0].serial",
166-
"message": "'10%BAD' does not match '^\\\\{\\\\{.*\\\\}\\\\}$'"
166+
"message": "'10%BAD' does not match '^\\\\{\\\\{(.|[\\r\\n])*\\\\}\\\\}$'"
167167
},
168168
{
169169
"path": "$[0].serial",

test/schemas/negative_test/playbooks/invalid_become.yml.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,9 @@
5959
{
6060
"instancePath": "/0/become",
6161
"keyword": "pattern",
62-
"message": "must match pattern \"^\\{\\{.*\\}\\}$\"",
62+
"message": "must match pattern \"^\\{\\{(.|[\r\n])*\\}\\}$\"",
6363
"params": {
64-
"pattern": "^\\{\\{.*\\}\\}$"
64+
"pattern": "^\\{\\{(.|[\r\n])*\\}\\}$"
6565
},
6666
"schemaPath": "#/$defs/full-jinja/pattern"
6767
},
@@ -130,7 +130,7 @@ stdout:
130130
},
131131
{
132132
"path": "$[0].become",
133-
"message": "'yes' does not match '^\\\\{\\\\{.*\\\\}\\\\}$'"
133+
"message": "'yes' does not match '^\\\\{\\\\{(.|[\\r\\n])*\\\\}\\\\}$'"
134134
}
135135
]
136136
}

test/schemas/negative_test/playbooks/no_log_partial_template.yml.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,9 @@
5959
{
6060
"instancePath": "/0/tasks/0/no_log",
6161
"keyword": "pattern",
62-
"message": "must match pattern \"^\\{\\{.*\\}\\}$\"",
62+
"message": "must match pattern \"^\\{\\{(.|[\r\n])*\\}\\}$\"",
6363
"params": {
64-
"pattern": "^\\{\\{.*\\}\\}$"
64+
"pattern": "^\\{\\{(.|[\r\n])*\\}\\}$"
6565
},
6666
"schemaPath": "#/$defs/full-jinja/pattern"
6767
},
@@ -95,9 +95,9 @@
9595
{
9696
"instancePath": "/0/tasks/0/no_log",
9797
"keyword": "pattern",
98-
"message": "must match pattern \"^\\{\\{.*\\}\\}$\"",
98+
"message": "must match pattern \"^\\{\\{(.|[\r\n])*\\}\\}$\"",
9999
"params": {
100-
"pattern": "^\\{\\{.*\\}\\}$"
100+
"pattern": "^\\{\\{(.|[\r\n])*\\}\\}$"
101101
},
102102
"schemaPath": "#/$defs/full-jinja/pattern"
103103
},
@@ -177,7 +177,7 @@ stdout:
177177
},
178178
{
179179
"path": "$[0].tasks[0].no_log",
180-
"message": "'foo-{{ some_var }}' does not match '^\\\\{\\\\{.*\\\\}\\\\}$'"
180+
"message": "'foo-{{ some_var }}' does not match '^\\\\{\\\\{(.|[\\r\\n])*\\\\}\\\\}$'"
181181
},
182182
{
183183
"path": "$[0].tasks[0].no_log",
@@ -189,7 +189,7 @@ stdout:
189189
},
190190
{
191191
"path": "$[0].tasks[0].no_log",
192-
"message": "'foo-{{ some_var }}' does not match '^\\\\{\\\\{.*\\\\}\\\\}$'"
192+
"message": "'foo-{{ some_var }}' does not match '^\\\\{\\\\{(.|[\\r\\n])*\\\\}\\\\}$'"
193193
},
194194
{
195195
"path": "$[0].tasks[0]",

test/schemas/negative_test/playbooks/no_log_string.yml.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,9 @@
5959
{
6060
"instancePath": "/0/tasks/0/no_log",
6161
"keyword": "pattern",
62-
"message": "must match pattern \"^\\{\\{.*\\}\\}$\"",
62+
"message": "must match pattern \"^\\{\\{(.|[\r\n])*\\}\\}$\"",
6363
"params": {
64-
"pattern": "^\\{\\{.*\\}\\}$"
64+
"pattern": "^\\{\\{(.|[\r\n])*\\}\\}$"
6565
},
6666
"schemaPath": "#/$defs/full-jinja/pattern"
6767
},
@@ -95,9 +95,9 @@
9595
{
9696
"instancePath": "/0/tasks/0/no_log",
9797
"keyword": "pattern",
98-
"message": "must match pattern \"^\\{\\{.*\\}\\}$\"",
98+
"message": "must match pattern \"^\\{\\{(.|[\r\n])*\\}\\}$\"",
9999
"params": {
100-
"pattern": "^\\{\\{.*\\}\\}$"
100+
"pattern": "^\\{\\{(.|[\r\n])*\\}\\}$"
101101
},
102102
"schemaPath": "#/$defs/full-jinja/pattern"
103103
},
@@ -177,7 +177,7 @@ stdout:
177177
},
178178
{
179179
"path": "$[0].tasks[0].no_log",
180-
"message": "'some_var' does not match '^\\\\{\\\\{.*\\\\}\\\\}$'"
180+
"message": "'some_var' does not match '^\\\\{\\\\{(.|[\\r\\n])*\\\\}\\\\}$'"
181181
},
182182
{
183183
"path": "$[0].tasks[0].no_log",
@@ -189,7 +189,7 @@ stdout:
189189
},
190190
{
191191
"path": "$[0].tasks[0].no_log",
192-
"message": "'some_var' does not match '^\\\\{\\\\{.*\\\\}\\\\}$'"
192+
"message": "'some_var' does not match '^\\\\{\\\\{(.|[\\r\\n])*\\\\}\\\\}$'"
193193
},
194194
{
195195
"path": "$[0].tasks[0]",

0 commit comments

Comments
 (0)