10000 Add pipeline to unfurl affected VERS range in V2 impacts by keshav-space · Pull Request #1995 · aboutcode-org/vulnerablecode · GitHub
[go: up one dir, main page]

Skip to content

Conversation

keshav-space
Copy link
Member

Signed-off-by: Keshav Priyadarshi <git@keshav.space>
Signed-off-by: Keshav Priyadarshi <git@keshav.space>
Signed-off-by: Keshav Priyadarshi <git@keshav.space>
@keshav-space keshav-space requested a review from TG1999 September 9, 2025 12:46

affecting_vers = models.TextField(
blank=True,
null=True,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO, we should have a check that at least one of affecting_vers or fixed_vers should exist while creating/saving an object

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We’re being bit flexible in what we accept to make sure we at least store the base purl, even if we don't get affecting or fixed vers. And if there are no affecting or fixed vers, we will not attempt to unfurl no harm done.


return package, is_created

def bulk_get_or_create_from_purls(self, purls: List[Union[PackageURL, str]]):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shall we have a boolean to mark if an impactd package is unfurled, so we do not unfurl that again

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should not optimize for this right now, as sometimes during run we may not get complete list of versions due to timeout or network issue, and we don't want to skip processing them in our next pass.

for impact in progress.iter(impacted_packages):
purl = PackageURL.from_string(impact.base_purl)
if not impact.affecting_vers or not any(
c in impact.affecting_vers for c in ("<", ">", "!")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Won't this ignore:
vers like this?
=1.0.0 or ^1.2.0

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, this is a vers string, and VERS spec only allows >, <, and ! for comparison.


try:
versions = [version_class(v) for v in versions]
except Exception as e:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this c 8000 omment to others. Learn more.

Let's return an empty list by default, since the calling side expects something to iterate upon

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If no purls are returned, we will skip processing the current impact right away and go no further.

affected_packages_v2 = PackageV2.objects.bulk_get_or_create_from_purls(purls=purls)

relations = [
relation(impactedpackage=impact, packagev2=package) for package in affected_packages_v2
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would there be a chance that duped relations may be created from this ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No duplicate relation can be created, we use ignore_conflicts=True while bulk creating to ignore already existing relations.

Signed-off-by: Keshav Priyadarshi <git@keshav.space>
@keshav-space keshav-space merged commit 06580c7 into main Sep 15, 2025
10 of 25 checks passed
@keshav-space keshav-space deleted the 1967-unfurl-version-range branch September 15, 2025 19:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create pipeline to unfurl version ranges
2 participants
0