我有一堆 django_mark_safe
错误
>> Issue: [B703:django_mark_safe] Potential XSS on mark_safe function.
Severity: Medium Confidence: High
Location: ...
More Info: https://bandit.readthedocs.io/en/latest/plugins/b703_django_mark_safe.html
54 return mark_safe(f'<a href="{url}" target="_blank">{title}</a>')
>> Issue: [B308:blacklist] Use of mark_safe() may expose cross-site scripting vulnerabilities and should be reviewed.
Severity: Medium Confidence: High
Location: ...
More Info: https://bandit.readthedocs.io/en/latest/blacklists/blacklist_calls.html#b308-mark-safe
54 return mark_safe(f'<a href="{url}" target="_blank">{title}</a>')
我很好奇是否有办法跳过或忽略这些行?我知道使用 mark_safe
可能很危险,但如果我想冒险怎么办?例如,此方法是在 Django 管理中显示自定义链接的唯一方法,所以我不知道没有任何其他选项如何做到这一点 mark_safe
原文由 ramusus 发布,翻译遵循 CC BY-SA 4.0 许可协议
我在 这里 得到了答案: