'NoneType' object has no attribute 'id'Traceback in django_mark_safe
See original GitHub issueDescribe the bug While running bandit 1.6.2 I get the following output
[tester] ERROR Bandit internal error running: django_mark_safe on file ./venv/lib/python3.7/site-packages/django/template/base.py at line 738: 'NoneType' object has no attribute 'id'Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/bandit/core/tester.py", line 64, in run_tests
result = test(context)
File "/usr/local/lib/python3.7/site-packages/bandit/plugins/django_xss.py", line 295, in django_mark_safe
return check_risk(context.node)
File "/usr/local/lib/python3.7/site-packages/bandit/plugins/django_xss.py", line 243, in check_risk
secure = evaluate_var(xss_var, parent, node.lineno)
File "/usr/local/lib/python3.7/site-packages/bandit/plugins/django_xss.py", line 123, in evaluate_var
to = analyser.is_assigned(node)
File "/usr/local/lib/python3.7/site-packages/bandit/plugins/django_xss.py", line 89, in is_assigned
assigned.extend(self.is_assigned_in(node.body))
File "/usr/local/lib/python3.7/site-packages/bandit/plugins/django_xss.py", line 33, in is_assigned_in
new_assigned = self.is_assigned(ast_inst)
File "/usr/local/lib/python3.7/site-packages/bandit/plugins/django_xss.py", line 90, in is_assigned
assigned.extend(self.is_assigned_in(node.orelse))
File "/usr/local/lib/python3.7/site-packages/bandit/plugins/django_xss.py", line 33, in is_assigned_in
new_assigned = self.is_assigned(ast_inst)
File "/usr/local/lib/python3.7/site-packages/bandit/plugins/django_xss.py", line 89, in is_assigned
assigned.extend(self.is_assigned_in(node.body))
File "/usr/local/lib/python3.7/site-packages/bandit/plugins/django_xss.py", line 33, in is_assigned_in
new_assigned = self.is_assigned(ast_inst)
File "/usr/local/lib/python3.7/site-packages/bandit/plugins/django_xss.py", line 65, in is_assigned
if withitem.optional_vars.id == self.var_name.id:
AttributeError: 'NoneType' object has no attribute 'id'
Expected behavior Not seeing a stack trace.
Bandit version
bandit 1.6.2
python version = 3.7.6 (default, Dec 30 2019, 19:38:26) [Clang 11.0.0 (clang-1100.0.33.16)]
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Django 'NoneType' object has no attribute 'id' - Stack Overflow
'NoneType' object has no attribute 'id' Traceback: File "C:\Python27\lib\site-packages\django\core\handlers\base.py" in get_response 115.
Read more >'NoneType' object has no attribute '_inc_path' - Google Groups
Basically I am getting this error. > > AttributeError at /admin/pages/new/wagtail_articles/articleindex/3/ > 'NoneType' object has no attribute '_inc_path ...
Read more >'NoneType' object has no attribute 'identify'
I'm trying to run this console script, but it gets me wrong: AttributeError: 'NoneType' object has no 'identify' attribute yet it works well...
Read more >How do I resolve "ERROR Failed to write data to transport with ...
Articles How do I resolve "ERROR Failed to write data to transport with 'NoneType' object has no attribute 'write'" when using the Duo...
Read more >AttributeError: 'NoneType' object has no attribute 'AsValueString
Trying to create a simple script but getting this error. Don't understand why because i can clearly see the value in it.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Fixed with #598
@ehooo I can see this is your code, do you mind taking a look?