ValueError: invalid literal for int() with base 10: 'n'
Closed this issue · 1 comments
ericwb commented
Describe the bug
ValueError while scanning cpython code
To Reproduce
Steps to reproduce the behavior:
- git clone https://github.com/python/cpython
- precli --debug ../cpython/Lib/test/test_secrets.py
- See error
Working on file: ../cpython/Lib/test/test_secrets.py
Exception occurred when executing rules against ../cpython/Lib/test/test_secrets.py. Run "precli --debug ../cpython/Lib/test/test_secrets.py" to see the full traceback.
Exception string: invalid literal for int() with base 10: 'n'
Exception traceback: Traceback (most recent call last):
File "/Users/ericwb/.pyenv/versions/3.12.2/lib/python3.12/site-packages/precli/core/run.py", line 141, in parse_file
return parser.parse(artifact)
^^^^^^^^^^^^^^^^^^^^^^
File "/Users/ericwb/.pyenv/versions/3.12.2/lib/python3.12/site-packages/precli/parsers/__init__.py", line 111, in parse
self.visit([tree.root_node])
File "/Users/ericwb/.pyenv/versions/3.12.2/lib/python3.12/site-packages/precli/parsers/__init__.py", line 136, in visit
visitor_fn(node.children)
File "/Users/ericwb/.pyenv/versions/3.12.2/lib/python3.12/site-packages/precli/parsers/python.py", line 31, in visit_module
self.visit(nodes)
File "/Users/ericwb/.pyenv/versions/3.12.2/lib/python3.12/site-packages/precli/parsers/__init__.py", line 136, in visit
visitor_fn(node.children)
File "/Users/ericwb/.pyenv/versions/3.12.2/lib/python3.12/site-packages/precli/parsers/python.py", line 48, in visit_class_definition
self.visit(nodes)
File "/Users/ericwb/.pyenv/versions/3.12.2/lib/python3.12/site-packages/precli/parsers/__init__.py", line 136, in visit
visitor_fn(node.children)
File "/Users/ericwb/.pyenv/versions/3.12.2/lib/python3.12/site-packages/precli/parsers/__init__.py", line 136, in visit
visitor_fn(node.children)
File "/Users/ericwb/.pyenv/versions/3.12.2/lib/python3.12/site-packages/precli/parsers/python.py", line 55, in visit_function_definition
self.visit(nodes)
File "/Users/ericwb/.pyenv/versions/3.12.2/lib/python3.12/site-packages/precli/parsers/__init__.py", line 136, in visit
visitor_fn(node.children)
File "/Users/ericwb/.pyenv/versions/3.12.2/lib/python3.12/site-packages/precli/parsers/__init__.py", line 136, in visit
visitor_fn(node.children)
File "/Users/ericwb/.pyenv/versions/3.12.2/lib/python3.12/site-packages/precli/parsers/__init__.py", line 136, in visit
visitor_fn(node.children)
[Previous line repeated 4 more times]
File "/Users/ericwb/.pyenv/versions/3.12.2/lib/python3.12/site-packages/precli/parsers/python.py", line 219, in visit_call
self.visit(nodes)
File "/Users/ericwb/.pyenv/versions/3.12.2/lib/python3.12/site-packages/precli/parsers/__init__.py", line 136, in visit
visitor_fn(node.children)
File "/Users/ericwb/.pyenv/versions/3.12.2/lib/python3.12/site-packages/precli/parsers/__init__.py", line 136, in visit
visitor_fn(node.children)
File "/Users/ericwb/.pyenv/versions/3.12.2/lib/python3.12/site-packages/precli/parsers/python.py", line 209, in visit_call
self.analyze_node(tokens.CALL, call=call)
File "/Users/ericwb/.pyenv/versions/3.12.2/lib/python3.12/site-packages/precli/parsers/__init__.py", line 223, in analyze_node
result = analyze_fn(self.context, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/ericwb/.pyenv/versions/3.12.2/lib/python3.12/site-packages/precli/rules/python/stdlib/secrets_weak_token.py", line 75, in analyze_call
nbytes = int(arg.value) if arg.value else 32
^^^^^^^^^^^^^^
ValueError: invalid literal for int() with base 10: 'n'
Expected behavior
No exceptions or errors
Version
precli 0.5.4
Copyright 2024 Secure Saurce LLC
License BUSL-1.1: Business Source License 1.1 <https://spdx.org/licenses/BUSL-1.1.html>
Python 3.12.2 (main, May 13 2024, 16:18:42) [Clang 15.0.0 (clang-1500.3.9.4)]
Additional context