Skip to content

[Experiment] Store and evaluate package version ranges - #270

Closed
sbs2001 wants to merge 3 commits into
aboutcode-org:mainfrom
sbs2001:version_range_exp
Closed

[Experiment] Store and evaluate package version ranges#270
sbs2001 wants to merge 3 commits into
aboutcode-org:mainfrom
sbs2001:version_range_exp

Conversation

@sbs2001

@sbs2001 sbs2001 commented Oct 23, 2020

Copy link
Copy Markdown
Collaborator
  • Add a table VulnerablePackageVersionRange
  • This table stores version less purl string and a FK of vulnerability
  • Added manager method which on given a purl string which does not exist in the db
    tries to find whether it satisfies a version range, if yes then that vulnerability is returned

Signed-off-by: Shivam Sandbhor shivam.sandbhor@gmail.com

- Add a table VulnerablePackageVersionRange
- This table stores version less purl string and a FK of vulnerability
- Added manager method which on given  a purl string which does not exist in the db
  tries to find whether it satisfies a version  range, if yes then that vulnerability is returned

Signed-off-by: Shivam Sandbhor <shivam.sandbhor@gmail.com>
Signed-off-by: Shivam Sandbhor <shivam.sandbhor@gmail.com>
Signed-off-by: Shivam Sandbhor <shivam.sandbhor@gmail.com>

@pombredanne pombredanne left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks! I reckon this still an experiment and a WIP, but getting some more tests here would be essential. I think we will need this for sure.
I added some other comments for your consideration.

@dataclasses.dataclass
class VulnPkgVersionRange:

# This dataclass is nested inside the `Advisory` class below. It is used

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should this be a docstring instead of a comment?

# dataclass.

purl: str
version_ranges: str

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I called this a requirement in scancode https://github.com/nexB/scancode-toolkit/blob/ba4bbf216c6f44572662d16c76214a08b0a69e7e/src/packagedcode/models.py#L331
I wonder if we should rename it in scancode or here.... but in anycase I would like to keep in a single common name for the same concept.

raise TypeError

@dataclasses.dataclass
class VulnPkgVersionRange:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Could we find a better name?
PackageSpecification may be? what else could be a good one?

impacted_package_urls: Iterable[PackageURL]
resolved_package_urls: Iterable[PackageURL] = dataclasses.field(default_factory=list)
resolved_package_urls: Iterable[PackageURL]
vuln_pkg_version_ranges : Iterable[VulnPkgVersionRange]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I reckon you would want that vuln_pkg_version_ranges be optional? and replace the the impacted_package_urls ?
Or would we keep both?
Could you have both at the same time?
And if we have bot would these be rather names something like impacted_package_urls_specification , or ``impacted_package_urls_requirementsorimpacted_package_urls_version ranges` or ...?`

'data_source_cfg': {
'endpoint': 'https://api.github.com/graphql',
'ecosystems': ['MAVEN', 'NUGET', 'COMPOSER']
'ecosystems': ['MAVEN', 'NUGET']

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why dropping composer from here?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

And actually why even filtering based on "ecosystems" ? Why not get them all?

@sbs2001

sbs2001 commented Nov 18, 2020

Copy link
Copy Markdown
Collaborator Author

@pombredanne Thanks for the review.

What kind of cases should be covered by these tests ?

Re. naming no strong opinions here but IMHO requirement isn't as intuitive as version_ranges .

@pombredanne

Copy link
Copy Markdown
Member

@pombredanne Thanks for the review.
What kind of cases should be covered by these tests ?
Re. naming no strong opinions here but IMHO requirement isn't as intuitive as version_ranges

I am fine with version_ranges. The key is consistency, so if you go with it, we need to adopt that in scancode-toolkit and scancode.io too. Can you also enter tickets there? (and link back here too?)

@sbs2001 sbs2001 closed this Mar 4, 2021
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.

2 participants