-
Notifications
You must be signed in to change notification settings - Fork 582
Fixes path problem for InputEngine and reduce complexity of CVEScanner #860
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
8bf645e to
deb8273
Compare
Codecov Report
@@ Coverage Diff @@
## master #860 +/- ##
==========================================
- Coverage 87.85% 87.31% -0.55%
==========================================
Files 164 164
Lines 2710 2705 -5
Branches 295 295
==========================================
- Hits 2381 2362 -19
- Misses 258 272 +14
Partials 71 71
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
626fef6 to
96f059f
Compare
| from collections import defaultdict | ||
| from enum import Enum | ||
| from typing import NamedTuple | ||
|
|
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.
Put datastructures for triage and cve_scanner at one place to avoid circular import.
| class ProductInfo(NamedTuple): | ||
| vendor: str | ||
| product: str | ||
| version: str | ||
|
|
||
|
|
||
| class CVEData(defaultdict): | ||
| def __missing__(self, key): | ||
| if key == "cves": | ||
| self[key] = [] | ||
| elif key == "paths": | ||
| self[key] = set() | ||
| else: | ||
| return NotImplemented | ||
| return self[key] |
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.
Issues with old structure:
- Old CVEData was NamedTuple and since newly added path attribute was mutable it can create hard to find bugs.
- To update path we need to scan all_cve_data to find product for which we want to append paths.
Time Complexity: O(n**2)which can be reduced toO(n)using better structure. - Throwing vendor, product, version in different function was decreasing readability. So, ProductInfo would be nice to pack this data together since we don't actually need that alone.
- TriageData structure wasn't syncing with old CVEData. So, csv2cve was breaking.
New structure is addressing all these issues.
| product_info, file_path = scan_info | ||
| list_products.add(product_info.product) | ||
| list_versions.add(product_info.version) | ||
| assert file_path == expected_path |
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.
Test for filepath :)
johnandersen777
left a comment
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 try fetching master and merging in latest HTML report changes. Then run the report and just double check that everything works
Depends on #861
Fixes: #859