-
Notifications
You must be signed in to change notification settings - Fork 571
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,6 @@ | |
import sys | ||
import os | ||
import csv | ||
import glob | ||
import platform | ||
import subprocess | ||
import logging | ||
|
@@ -120,7 +119,7 @@ def get_cves(self, vendor_package_pairs, vers): | |
""" | ||
cves = defaultdict(list) | ||
|
||
for i in range(len(vendor_package_pairs)): | ||
for i, _ in enumerate(vendor_package_pairs): | ||
vendor_package_pairs[i] = tuple(vendor_package_pairs[i])[:2] + ( | ||
"%" + str(vers) + "%", | ||
) | ||
|
@@ -290,8 +289,11 @@ def output_cves(outfile, modules, include_details=False): | |
writer.writerow(row) | ||
|
||
|
||
def main(argv=sys.argv, outfile=sys.stdout): | ||
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 commentThe 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 commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is related to 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 commentThe reason will be displayed to describe this comment to others. Learn more. Ah okay I see what you mean, cool! |
||
|
||
parser = argparse.ArgumentParser( | ||
prog="cve-bin-tool", | ||
description="The CVE Binary Tool scans for a number of common, vulnerable open source components (openssl, libpng, libxml2, expat and a few others) to let you know if a given directory or binary file includes common libraries with known vulnerabilities.", | ||
|
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 docstringThere 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.