Skip to content
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

Uniform method to categorize versions #494

Open
Hritik14 opened this issue Jul 3, 2021 · 2 comments
Open

Uniform method to categorize versions #494

Hritik14 opened this issue Jul 3, 2021 · 2 comments

Comments

@Hritik14
Copy link
Collaborator

Hritik14 commented Jul 3, 2021

A function to categorize versions into affected and safe versions is present in multiple importers such as
https://github.com/nexB/vulnerablecode/blob/e9943b014f5f07b970988f910b2aaebcec0a6e58/vulnerabilities/importers/github.py#L320-L338

https://github.com/nexB/vulnerablecode/blob/e9943b014f5f07b970988f910b2aaebcec0a6e58/vulnerabilities/importers/apache_httpd.py#L129-L148

https://github.com/nexB/vulnerablecode/blob/e9943b014f5f07b970988f910b2aaebcec0a6e58/vulnerabilities/importers/istio.py#L66-L83

They are present with different names and sometimes even with different parameters. This is confusing and hard to document.
Imo, we should create an abstract method in the DataSource class with a uniform name and parameters. This would also help me build the small documentation I'm working on for vulnerablecode better.

@sbs2001
Copy link
Collaborator

sbs2001 commented Jul 6, 2021

@Hritik14 agreed wrt duplicate methods.

But creating an abstract method would only solve the naming problem and parameter stuff. Each datasource would need implement the same stuff, hence we would have code duplication.

A better way would be to have a helper function(not tied to any class) which does this. Univers can infer package type using if the parameters are sent using the syntax mentioned in #119 (comment)

@pombredanne
Copy link
Collaborator

This is confusing and hard to document.
Imo, we should create an abstract method in the DataSource class with a uniform name and parameters. This would also help me build the small documentation I'm working on for vulnerablecode better.

I kinda agree there. Abstract methods or just base methods in a base class are a way to document the expectations of the various classes. They may not obey but that's good documentation in all cases IMHO

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants