Extra spaces added by bandit.code.utils.concat_string
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 8.3k
- Forks
- 836
- Avg merge
- 5d 3h
- Merged PRs (30d)
- 1
Description
Describe the bug
When calling bandit.code.utils.concat_string extra spaces are added between the strings which are concatenated.
Reproduction steps
import ast
from bandit.core import utils
# Create a simple string concatenation
bin_op = ast.parse('"Hello" + "World"').body[0].value
# Manually fix-up the node
bin_op._bandit_parent = None
node, string = utils.concat_string(bin_op)
assert string == "HelloWorld", 'Got %r' % (string, )
Expected behavior
Extra spaces should not be added.
Remove the space used to .join() the strings on https://github.com/PyCQA/bandit/blob/72fa5a7496caa89f21ace353d038754dbddf9a91/bandit/core/utils.py#L305
Bandit version
1.7.5 (Default)
Python version
3.9
Additional context
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in bandit/core/utils.py at concat_string(), especially the join operation referenced in the issue. Reproduce the behavior with the provided Python snippet and add or update a focused test for concatenating "Hello" and "World". Done means the returned string is "HelloWorld" without an inserted space.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 55/100