fix bandit B704

This commit is contained in:
Mike McLean 2025-05-06 11:19:27 -04:00 committed by Tomas Kopecek
parent 2270a85687
commit 8bc1c1b466
3 changed files with 12 additions and 2 deletions

3
.bandit.yaml Normal file
View file

@ -0,0 +1,3 @@
markupsafe_xss:
allowed_calls:
- _MarkTrustedValue

View file

@ -91,7 +91,7 @@ deps =
bandit
allowlist_externals = bandit
commands =
bandit -ll -s B108,B608 -r \
bandit -c .bandit.yaml -ll -s B108,B608 -r \
builder cli kojihub koji plugins util vm www \
builder/kojid \
cli/koji \

View file

@ -128,7 +128,14 @@ def themePath(path, local=False):
# previously we had a custom SafeValue class here, but the Markup class does the same thing better
def SafeValue(value):
return Markup(value)
"""Mark a value as safe so that the template will not escape it"""
# NOTE: this function should only be used in places where we trust the value
def _MarkTrustedValue(value):
# wrapper to keep Bandit B704 from complaining
return value
return Markup(_MarkTrustedValue(value))
def safe_return(func):