-
Notifications
You must be signed in to change notification settings - Fork 570
Fix some bug risks and quality issues #243
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
Conversation
Changes: - Fixed mutable default arguments used in `cve_bin_tool/csv2cve.py` and `cve_bin_tool/cli.py` - Removed unused imports in `cve_bin_tool/cli.py`, `cve_bin_tool/checkers/openssh.py` and `cve_bin_tool/NVDAutoUpdate.py` - Use raw strings in `cve_bin_tool/checkers/openssh.py`, `cve_bin_tool/NVDAutoUpdate.py` and `cve_bin_tool/checkers/expat.py` - Replaced `range(len(..))` with `enumerate()` in `cve_bin_tool/cli.py`
def main(argv=None, outfile=sys.stdout): | ||
""" Scan a binary file for certain open source libraries that may have CVEs """ | ||
if argv is None: | ||
argv = sys.argv |
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.
What's the purpose of this change?
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.
I see your comment says this makes it not mutable, what do you mean by this? My understanding is that this changes preserves mutability. If we wished to make changes to argv
not change sys.argv
, we'd have to use copy.deepcopy
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.
This is related to sys.argv
being passed as a default argument in the function definition (on line 292).
def main(argv=sys.argv, outfile=sys.stdout):
...
It's not recommended to pass mutable objects as default values since the latest passed value is preserved on subsequent function calls, and can cause unintended effects. (ref)
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.
Ah okay I see what you mean, cool!
#!/usr/bin/python3 | ||
# pylint: disable=anomalous-backslash-in-string, invalid-name | ||
""" | ||
r""" |
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.
I don't think we want a r
prefix on this docstring
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.
There's an unescaped backslash in the docstring on line 16. Adding another backslash to escape it can change the meaning, which is why we can convert the docstring to a raw string.
Thanks! |
@pdxjohnny Replied to the comments. |
Changes:
cve_bin_tool/csv2cve.py
andcve_bin_tool/cli.py
cve_bin_tool/cli.py
,cve_bin_tool/checkers/openssh.py
andcve_bin_tool/NVDAutoUpdate.py
cve_bin_tool/checkers/openssh.py
,cve_bin_tool/NVDAutoUpdate.py
andcve_bin_tool/checkers/expat.py
range(len(..))
withenumerate()
incve_bin_tool/cli.py
Some more issues on the repo's DeepSource dashboard on my fork here.