-
-
Notifications
You must be signed in to change notification settings - Fork 272
Add V2 Importer for Tuxcare advisories #2104
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
base: main
Are you sure you want to change the base?
Conversation
ziadhany
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.
@Samk1710 Thanks , see feedback and suggestions below
vulnerabilities/tests/pipelines/v2_importers/test_tuxcare_importer_v2.py
Outdated
Show resolved
Hide resolved
|
@ziadhany Thanks for your review. |
|
@Samk1710, could you please also fix the CI ? |
|
Hey @ziadhany |
|
Hey @ziadhany |
ziadhany
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.
@Samk1710 , The code looks good. I think we just need some refinement of the package URL and the affected and fixed versions.
|
Hey @ziadhany I have rectified the PURL. Also added more data to test each OS type with their respective PURLs. Kindly review the changes when you have time. Thanks. |
| try: | ||
| version_range = GenericVersionRange.from_versions([version]) | ||
| except ValueError as e: | ||
| logger.warning(f"Failed to parse version {version} for {cve_id}: {e}") | ||
| continue |
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.
VersionRange should also be mapped correctly.
see:
https://github.com/aboutcode-org/univers/blob/main/src/univers/version_range.py#L1429
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.
VersionRange should also be mapped correctly.
see: https://github.com/aboutcode-org/univers/blob/main/src/univers/version_range.py#L1429
Implemented
|
Hey @ziadhany |
Signed-off-by: Sampurna Pyne <sampurnapyne1710@gmail.com>
Signed-off-by: Sampurna Pyne <sampurnapyne1710@gmail.com>
Signed-off-by: Sampurna Pyne <sampurnapyne1710@gmail.com>
Signed-off-by: Sampurna Pyne <sampurnapyne1710@gmail.com>
Signed-off-by: Sampurna Pyne <sampurnapyne1710@gmail.com>
Signed-off-by: Sampurna Pyne <sampurnapyne1710@gmail.com>
Signed-off-by: Sampurna Pyne <sampurnapyne1710@gmail.com>
Signed-off-by: Sampurna Pyne <sampurnapyne1710@gmail.com>
0f27746 to
7d47d46
Compare
ziadhany
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.
The code looks good, just a few nits.
| "deb": DebianVersionRange, | ||
| "apk": AlpineLinuxVersionRange, | ||
| "generic": GenericVersionRange, | ||
| } |
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 avoid code duplication, you can import this from the univers library.
from univers.version_range import RANGE_CLASS_BY_SCHEMES
| self.response = response.json() if response else [] | ||
| self._grouped = self._group_records_by_cve() | ||
|
|
||
| def _group_records_by_cve(self) -> dict: |
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 add some docs
|
|
||
| for record in self.response: | ||
| cve_id = record.get("cve", "").strip() | ||
| if not cve_id or not cve_id.startswith("CVE-"): |
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.
Do we have an example of a cve field that doesn’t start with CVE? We shouldn’t consider this invalid.
| ) | ||
| ) | ||
|
|
||
| if severity and score and not severity_added: |
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 is the use of the severity_added variable? Why aren’t severity and score enough to add severity if it exists?
| from vulnerabilities.severity_systems import GENERIC | ||
| from vulnerabilities.utils import fetch_response | ||
|
|
||
| logger = logging.getLogger(__name__) |
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.
| logger = logging.getLogger(__name__) |
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.
we can use the pipeline logger
| for record in self.response: | ||
| cve_id = record.get("cve", "").strip() | ||
| if not cve_id or not cve_id.startswith("CVE-"): | ||
| logger.warning(f"Skipping invalid CVE ID: {cve_id}") |
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.
| logger.warning(f"Skipping invalid CVE ID: {cve_id}") | |
| self.log(f"Skipping invalid CVE ID: {cve_id}") |
| continue | ||
|
|
||
| if status not in AFFECTED_STATUSES and status not in FIXED_STATUSES: | ||
| logger.warning(f"Skipping {cve_id}: unrecognized status '{status}'") |
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.
| logger.warning(f"Skipping {cve_id}: unrecognized status '{status}'") | |
| self.log(f"Skipping {cve_id}: unrecognized status '{status}'") |
| status = record.get("status", "").strip() | ||
|
|
||
| if not all([os_name, project_name, version, status]): | ||
| logger.warning(f"Skipping {cve_id}: missing required fields") |
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.
| logger.warning(f"Skipping {cve_id}: missing required fields") | |
| self.log(f"Skipping {cve_id}: missing required fields") |
Addresses Issue:
Data Source: https://cve.tuxcare.com/els/download-json?orderBy=updated-desc
Importer Log Excerpt: