-
Notifications
You must be signed in to change notification settings - Fork 22
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
Ignore suse/suse cvrf. Other performance improvements. #171
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -110,13 +110,15 @@ def is_supported_source(zfname): | |
"oval", | ||
"glad", | ||
"mariner", | ||
f"cvrf{os.sep}suse{os.sep}suse", | ||
): | ||
if distro in zfname: | ||
return False | ||
nvd_start_year = config.NVD_START_YEAR | ||
for year in range(1999, nvd_start_year): | ||
if f"CVE-{year}-" in zfname: | ||
return False | ||
for pat in (f"CVE-{year}-", f"{os.sep}{year}{os.sep}", f"ALAS-{year}-", f"ALAS2-{year}-", f"openSUSE-SU-{year}-"): | ||
if pat in zfname: | ||
return False | ||
if zfname.endswith(".json"): | ||
return True | ||
return False | ||
|
@@ -616,6 +618,8 @@ def product_ref_to_name_version(product_ref): | |
def suse_to_vuln(self, cve_data): | ||
"""Suse Linux""" | ||
ret_data = [] | ||
tracking_id = cve_data.get("Tracking", {}).get("ID", "") | ||
assigner = "opensuse" if "opensuse" in tracking_id.lower() else "suse" | ||
packages = cve_data.get("ProductTree", {}).get("Relationships", []) | ||
if not packages or not len(packages) > 0: | ||
return ret_data | ||
|
@@ -643,64 +647,70 @@ def suse_to_vuln(self, cve_data): | |
references = orjson.dumps(references, option=orjson.OPT_NAIVE_UTC) | ||
if isinstance(references, bytes): | ||
references = references.decode("utf-8", "ignore") | ||
assigner = "suse" | ||
( | ||
score, | ||
severity, | ||
vector_string, | ||
attack_complexity, | ||
) = get_default_cve_data(severity) | ||
done_pkgs = {} | ||
for pref in packages: | ||
pkg_key = pref.get("ProductReference") | ||
if done_pkgs.get(pkg_key): | ||
product_statuses = avuln.get("ProductStatuses", []) | ||
for aps in product_statuses: | ||
if aps.get("Type") != "Fixed": | ||
continue | ||
pkg_name, version = self.product_ref_to_name_version(pkg_key) | ||
version_start_including = "" | ||
version_end_including = "" | ||
version_start_excluding = "" | ||
version_end_excluding = version | ||
fix_version_end_including = "" | ||
fix_version_start_excluding = "" | ||
fix_version_end_excluding = "" | ||
fix_version_start_including = version | ||
if pkg_name and version: | ||
tdata = config.CVE_TPL % dict( | ||
cve_id=cve_id, | ||
cwe_id=cwe_id, | ||
assigner=assigner, | ||
references=references, | ||
description="", | ||
vectorString=vector_string, | ||
vendor="rpm", | ||
product=f"suse/{pkg_name}", | ||
version="*", | ||
edition="*", | ||
version_start_including=version_start_including, | ||
version_end_including=version_end_including, | ||
version_start_excluding=version_start_excluding, | ||
version_end_excluding=version_end_excluding, | ||
fix_version_start_including=fix_version_start_including, | ||
fix_version_end_including=fix_version_end_including, | ||
fix_version_start_excluding=fix_version_start_excluding, | ||
fix_version_end_excluding=fix_version_end_excluding, | ||
severity=severity, | ||
attackComplexity=attack_complexity, | ||
score=score, | ||
userInteraction="REQUIRED", | ||
exploitabilityScore=score, | ||
publishedDate=published_date, | ||
lastModifiedDate=last_modified_date, | ||
) | ||
try: | ||
vuln = NvdSource.convert_vuln(orjson.loads(tdata)) | ||
if vuln is None: | ||
continue | ||
vuln.description = compress_str(description) | ||
ret_data.append(vuln) | ||
done_pkgs[pkg_key] = True | ||
except Exception: | ||
pass | ||
product_ids = aps.get("ProductID") | ||
if not product_ids: | ||
continue | ||
for pkg_key in product_ids: | ||
if done_pkgs.get(pkg_key): | ||
continue | ||
pkg_name, version = self.product_ref_to_name_version(pkg_key) | ||
pkg_name = pkg_name.lower().replace(" ", "-").replace(":", "/") | ||
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. pkg_name will also include edition and product names such as |
||
version_start_including = "" | ||
version_end_including = "" | ||
version_start_excluding = "" | ||
version_end_excluding = version | ||
fix_version_end_including = "" | ||
fix_version_start_excluding = "" | ||
fix_version_end_excluding = "" | ||
fix_version_start_including = version | ||
if pkg_name and version: | ||
tdata = config.CVE_TPL % dict( | ||
cve_id=cve_id, | ||
cwe_id=cwe_id, | ||
assigner=assigner, | ||
references=references, | ||
description="", | ||
vectorString=vector_string, | ||
vendor="rpm", | ||
product=pkg_name, | ||
version="*", | ||
edition="*", | ||
version_start_including=version_start_including, | ||
version_end_including=version_end_including, | ||
version_start_excluding=version_start_excluding, | ||
version_end_excluding=version_end_excluding, | ||
fix_version_start_including=fix_version_start_including, | ||
fix_version_end_including=fix_version_end_including, | ||
fix_version_start_excluding=fix_version_start_excluding, | ||
fix_version_end_excluding=fix_version_end_excluding, | ||
severity=severity, | ||
attackComplexity=attack_complexity, | ||
score=score, | ||
userInteraction="REQUIRED", | ||
exploitabilityScore=score, | ||
publishedDate=published_date, | ||
lastModifiedDate=last_modified_date, | ||
) | ||
try: | ||
vuln = NvdSource.convert_vuln(orjson.loads(tdata)) | ||
if vuln is None: | ||
continue | ||
vuln.description = compress_str(description) | ||
ret_data.append(vuln) | ||
done_pkgs[pkg_key] = True | ||
except Exception: | ||
pass | ||
return ret_data | ||
|
||
@staticmethod | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 removes data belonging suse enterprise version leaving only the opensuse ones, which is probably ok for us.