mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2026-11-06 19:01:54 +00:00
test(plugins/dotenv): silence S701 on test-only jinja2 autoescape=False
The mode-aware dotenv_quote test renders the filter through a real jinja2.Environment to exercise the @pass_context branch. The filter produces shell env-file values, not HTML, so autoescape=True would mangle `&`, `<`, `>`, `'`, and `"` into HTML entities and break every assertion. Suppressing bandit S701 here is the correct call -- there is no XSS surface for a test-suite Environment that templates KEY=VALUE pairs.
This commit is contained in:
1 file changed
+4
-1
@@ -72,7 +72,10 @@ class TestDotenvQuoteModeAware(unittest.TestCase):
|
||||
"""
|
||||
|
||||
def setUp(self):
|
||||
env = jinja2.Environment(autoescape=False)
|
||||
# The filter renders shell env-file values, not HTML; autoescape
|
||||
# would replace `&`, `<`, `>`, `'`, `"` with HTML entities and
|
||||
# break every assertion below.
|
||||
env = jinja2.Environment(autoescape=False) # noqa: S701
|
||||
env.filters["dotenv_quote"] = FilterModule().filters()["dotenv_quote"]
|
||||
self.env = env
|
||||
|
||||
|
||||
Reference in new issue
Block a user