-
Notifications
You must be signed in to change notification settings - Fork 201
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
migrate current alpine importer to alpine importer-improver model #623
Conversation
for issue #620 |
@TG1999 As the development in this branch is going on and we wanted to move ahead with #476, rebasing/merging this with/from main will likely cause merge conflicts. Please accept the incoming changes for the import statements. |
7baa3d2
to
cad46c2
Compare
@Hritik14 Resolved merge conflicts |
b68f076
to
3360eb3
Compare
50ba90a
to
5ff44fe
Compare
@pombredanne @Hritik14 @sbs2001 Please check my current approach for the importer, if this looks good I will proceed with writing tests for this |
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.
Here are a few nits for your review!
vulnerabilities/importer.py
Outdated
fixed_version: Optional[Version] = None | ||
|
||
def __post_init__(self): | ||
if self.package.version: | ||
if self.package.version or not (self.affected_version_range or self.fixed_version): | ||
raise ValueError |
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 a message
return advisories | ||
# TODO: Handle the CVE-????-????? case | ||
yield AdvisoryData( | ||
summary="", |
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.
Why an empty summary? Is is mandatory?
), | ||
fixed_version=AlpineLinuxVersion(version), | ||
) | ||
for arch in archs |
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 if here is no archs?
yield AdvisoryData( | ||
summary="", | ||
references=references, | ||
affected_packages=[ |
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.
Create this before in a separate easier to read loop
) | ||
for arch in archs | ||
], | ||
aliases=[vuln_ids[0] if is_cve(vuln_ids[0]) else ""], |
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 not return a list of aliases with an empty string in it.
vulnerabilities/improvers/default.py
Outdated
@@ -38,7 +39,7 @@ def get_inferences(self, advisory_data: AdvisoryData) -> Iterable[Inference]: | |||
) | |||
|
|||
|
|||
def get_exact_purls(affected_package: AffectedPackage) -> (List[PackageURL], PackageURL): | |||
def get_exact_purls(affected_package: AffectedPackage) -> Tuple[List[PackageURL], PackageURL]: |
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.
Move these changes in a separate PR.
a9172e4
to
7233a37
Compare
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.
Thank you. LGTM... just a few cosmetic nits for your consideration. Could you also add some tests?
630e608
to
cb83cee
Compare
7bdea4c
to
4d9b13a
Compare
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.
Thanks for the PR! I've marked a few things that I'd like you to consider.
Also, In general, there are a lot of asserts. IMO a loud logging mechanism should serve for those asserts than failing entirely and much of the asserts should make their place in the tests.
4d9b13a
to
5d1952e
Compare
7171d02
to
a3ade32
Compare
Current alpine importer models need to be refactored to give AdvisoryData instead of Advisory, also add some validation to parse license expression and make affected_version_range optional Add tests to test scraping of webpages and parsing of data Signed-off-by: Tushar Goel <[email protected]>
a3ade32
to
a69c886
Compare
Signed-off-by: Tushar Goel <[email protected]>
1fdd165
to
104c760
Compare
Signed-off-by: Tushar Goel [email protected]