-
Notifications
You must be signed in to change notification settings - Fork 531
GSoC 2020 Project Idea: Improve CVE Binary Tool Output #267
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
Comments
|
I tried printing output to csv file by passing CSV = 1 argument.
Code (cli.py): if found_cves.keys():
if(os.getenv("CSV") == "1"):
fileOpenMode = 'a'
with open('sample_output.csv', mode= fileOpenMode) as sample_output:
file_handle = csv.writer(sample_output, delimiter=',', quotechar='"')
for i in found_cves:
file_handle.writerow([str(version), str(i), str(found_cves[i])])
else:
self.logger.info("Known CVEs in version " + str(version))
self.logger.info(", ".join(found_cves.keys())) This prints it out into a CSV file Is this the right step towards improvizing Binary Output? |
I think we want an actual command line flag for this rather than an environment variable (as a rule of thumb: environment variables are for developers and test integration, command line flags are for anything a user is likely to want to do) but other than that, yes this is the right direction! I notice that the first column there is just the version -- you're going to want the product name as well. I guess for ideal machine readability it might be best to use the same vendor, product pair that you'd expect in the nvd database. (and we'll have to do some finessing to make that work with checkers that handle more than one vendor/product pair?) |
Thanks for the explanation! |
@SinghHrmn Those are the two big ones since a lot of the smaller issues have been closed. But there's almost certainly other things to be done in this space and this is a great issue to do some brainstorming in. Here's a few off the top of my head:
|
Oh! those were some really great ideas @terriko. I'll try to implement the easy ones before the GSoC period and rest can be added as the stretch goals for the GSoC period. Thank You! |
@terriko I researched on this topic and found out that [String Interpolation / f-Strings (Python 3.6+)] More Information: https://realpython.com/python-string-formatting/ |
I did some quick double-checking to make sure centos 7 handled python 3.6, and it does. I checked Poky and it's on 3.8 (although the yocto build tools still support 3.4+, I think that's not enough reason for us to support the same). So I think we're good with the fstrings plan, now with some relevant data and not just my gut feeling that fstrings would be awesome. Hurrah! |
Went through this issue and marked the completed bugs. So that leaves us with 3 output related issues still open (Plus the new one that @SinghHrmn made and is already working on #374, which will likely be merged today) |
Added a new issue #413 (csv2cve does not output CVE severity) that could potentially be part of an output-related project. |
Added a new thought in #475 |
I think @Niraj-Kamdar and @SinghHrmn safely covered this in gsoc 2020, so I'm going to close the old project idea. |
The CVE Binary tool team is hoping to participate in Google Summer of Code (GSoC) under the Python Software Foundation umbrella. You can read all about what this means at http://python-gsoc.org/. This issue, and any others tagged 'gsoc' are not generally available bugs, but related to project ideas for GSoC.
Project Idea : Improve CVE Binary Tool Output
Project description: The CVE Binary Tool has a couple of issues related to output that could be combined into a single project:
#262 - Machine readable output. Currently the CVE Binary Tool prints information about CVEs found to the console. We'd like it to be easier for machines to parse. That issue talks about doing it in a CSV (comma-separated value) format. Once that works, you might also want to get it working with JSON or even provide prettier HTML reports with colours and additional data.
#332 - Generate full reports with CVE descriptions, etc. We don't currently store these in the database and probably don't want to for speed/space reasons, so you'd have to grab from the json. This was a feature that used to exist in cve-bin-tool before it was open sourced. The idea, I believe, is that you'd have something you could easily attach to an email or send in a meeting agenda so decisions could be made prioritizing fixes. In practice it wasn't getting used much which is why it wound up dropped before release, but it could still be useful for folk who need more info to send to their colleagues.
#413 -The csv2cve utility currently outputs a bare list of CVE numbers, while the main cve-bin-tool outputs
product, version, cve_number, severity
. I think it would be nice if csv2cve did the same or perhaps even better, usevendor, product, version, cve_number, severity
since the vendor information is easily available.Some older output issues that are now resolved (but might be interesting reading for the type of output fixes we want):
#182 - Unify logging vs verbose/quiet flags. Currently the CVE binary tool has both print and log statements. We'd like to switch everything to use the log system.(Solved in #276 -- thanks @PrajwalM2212)#197 - Improve NVD output so error messages go to stderr instead of stdout. Solving #182 will probably solve this one, but as an easier bug, you could start by switching all the print statements containing errors to print to stderr.(Solved in #276 -- thanks @PrajwalM2212)#286 - Bring back the --quiet flag (or make the equivalent --log command work like the --quiet flag did)(Solved in #290 -- thanks @PrajwalM2212)Skills: Python, git, experience with common output formats like json and csv a bonus
Difficulty level: Intermediate
Related Readings/Links: How to add new checkers
Potential mentors: @terriko @pdxjohnny
Getting Started: Python requires that all students submit a code sample as part of your application.
One possible good first pull request for this project: Fixing the "critical" output to be "warning" output in #306
If the bugs above are already resoled, try adding a test! There are two types of easy tests you might want to try first: CVE mapping test and CVE file test. Note: the way we add tests has changed recently, so please make sure to read the instructions!
Here's the file mapping test instructions cut and pasted:
To make the basic test suite run quickly, we use "faked" binary files to test the CVE mappings. However, we want to be able to test real files to test that the signatures work on real-world data.
We have a function that takes a url, and package name and a version, and downloads the file, runs the scanner against it, and makes sure it is the file that you've specified. But we need more tests!
test/
@pytest.mark.parametrize
decorator of test_files testIdeally, we should have at least one such test for each checker, and it would be nice to have some different sources for each as well. For example, for packages available in common Linux distributions, we might want to have one from fedora, one from debian, and one direct from upstream to show that we detect all those versions.
Extra credit: Got your test working and want to try something more? You can also try adding a checker before the project starts. See the related readings above for instructions.
The text was updated successfully, but these errors were encountered: