Open chinskiy opened 4 years ago
A have the same problem with format_html
Error:
Line: 40
bandit: B703 / Potential XSS on mark_safe function.
bandit: B308 / Use of mark_safe() may expose cross-site scripting vulnerabilities and should be reviewed.
example:
from django.utils.html import format_html
class ModelAdmin(admin.ModelAdmin):
def foo(self, obj: Model):
full_name = f"{obj.first_name} {obj.last_name}".strip()
return format_html('<a href="#">{}</a>', full_name) # <--- format_html calls mark_safe and returns SafeString object
Describe the bug According to docs mark_safe can also be used as a decorator.
B703 and B308 checks in this case passed.
To Reproduce
When mark_safe used as a function:
example.py
Output
When as a decorator
example.py
Output
Expected behavior Same issues should be shown.
Bandit version
Additional context I like this tool :)