-
-
Notifications
You must be signed in to change notification settings - Fork 628
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix 'get_code' method if issue is generated from dict #568
base: main
Are you sure you want to change the base?
Conversation
If issue is generated from dict 'get_code' method doesn't return code source. This patch fixes this by returning self.code property.
Is there a related issue to this to help us get some insight into what this fixes or how to test the change? |
@lukehinds It was an issue with serialization-deserialization of bandit issues. We do some automation on top of bandit and to_dict/from_dict are regular operations. I can provide an example of how to reproduce the issue if needed. |
yes please @e0ne |
here is a code to reproduce the bug:
Output:
As I understood, it's reproducible only when linecache can't load the file. |
@lukehinds as you can see, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a unit test
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The get_code() and issue_from_dict() functions are really there for internal calls of Bandit itself and not designed to be external interfaces to use more generally. We do have some interfaces for 3rd parties to create formatters and plugins, but the example given would not be a generally be necessary I would think.
If issue is generated from dict 'get_code' method doesn't return
code source. This patch fixes this by returning self.code property.