Skip to content

Dump importer_yielder in favor of IMPORTER_REGISTRY and drop Etags - #600

Merged
pombredanne merged 10 commits into
aboutcode-org:mainfrom
Hritik14:migration/importer_yielder
Feb 7, 2022
Merged

Dump importer_yielder in favor of IMPORTER_REGISTRY and drop Etags#600
pombredanne merged 10 commits into
aboutcode-org:mainfrom
Hritik14:migration/importer_yielder

Conversation

@Hritik14

@Hritik14Hritik14 commented Jan 26, 2022

Copy link
Copy Markdown
Collaborator

The name DataSource and Importer are majorly used interchangeably. This needs to be fixed in a different PR.

@Hritik14
Hritik14force-pushed the migration/importer_yielder branch from 457c91f to 4a24a14CompareJanuary 26, 2022 23:02
@Hritik14
Hritik14force-pushed the migration/importer_yielder branch from 4a24a14 to 7175362CompareJanuary 26, 2022 23:05

@pombredannepombredanne 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 have a few suggestions and ... Could you add tests?

Comment threadvulnerabilities/data_source.py Outdated
Comment threadvulnerabilities/data_source.py Outdated
Comment threadvulnerabilities/import_runner.py Outdated
Comment threadvulnerabilities/import_runner.py
Comment threadvulnerabilities/import_runner.py Outdated
Comment threadvulnerabilities/management/commands/import.py Outdated
Comment threadvulnerabilities/management/commands/import.py
Comment threadvulnerabilities/management/commands/import.py Outdated
Comment threadvulnerabilities/management/commands/improve.py Outdated
Comment threadvulnerabilities/models.py
@Hritik14Hritik14 added this to the v30.0 milestone Feb 2, 2022
@Hritik14
Hritik14force-pushed the migration/importer_yielder branch 5 times, most recently from 89cdfee to 058b9a8CompareFebruary 5, 2022 21:44
IMPORTER_REGISTRY is neater and does not do any magical string -> object
conversion. The registry looks more in sync with improvers.
Fixes: aboutcode-org#501
Signed-off-by: Hritik Vijay <hritikxx8@gmail.com>
Etags are meant for transient usage in browsers and are not meant for
any long term usage.
Fixes: aboutcode-org#321
Signed-off-by: Hritik Vijay <hritikxx8@gmail.com>
Signed-off-by: Hritik Vijay <hritikxx8@gmail.com>
@Hritik14
Hritik14force-pushed the migration/importer_yielder branch from 058b9a8 to 0c4905eCompareFebruary 5, 2022 21:58
The name DataSource and Importer were majorly used interchangeably
although they represent the same concept.
Also, the importers now require a mandatory ``spdx_license_expression``
to run
Signed-off-by: Hritik Vijay <hritikxx8@gmail.com>
Signed-off-by: Hritik Vijay <hritikxx8@gmail.com>
Same for improvers
IMPROVER_REGISTRY -> IMPROVERS_REGISTRY
Signed-off-by: Hritik Vijay <hritikxx8@gmail.com>
Signed-off-by: Hritik Vijay <hritikxx8@gmail.com>
Tests for:
* manage.py import command
* manage.py improve command
* import_runner
Signed-off-by: Hritik Vijay <hritikxx8@gmail.com>
We can use @classmethod and @Property together in python 3.9. Not so in
3.8
Signed-off-by: Hritik Vijay <hritikxx8@gmail.com>
@Hritik14
Hritik14force-pushed the migration/importer_yielder branch from 0c4905e to c62f81fCompareFebruary 5, 2022 22:04

@pombredannepombredanne 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... see a few final nits for your consideration.

Comment threadvulnerabilities/import_runner.py Outdated
Comment threadvulnerabilities/importer.py Outdated
Comment threadvulnerabilities/importer.py Outdated
Comment threadvulnerabilities/importer.py Outdated
class GitDataSource(DataSource):
CONFIG_CLASS = GitDataSourceConfiguration

# TODO: Needs rewrite

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.

May be an issue to track may work better?

Copy link
Copy Markdown
CollaboratorAuthor

Choose a reason for hiding this comment

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

This will be a part of #597

Comment threadvulnerabilities/improver.py Outdated
assert advisory_datas == ADVISORY_DATAS


def test_ImportRunner_existing_package_and_new_vulnerability(db):

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 this test be kept somehow? to valid that we never will allow twice the same set of imported data?

Copy link
Copy Markdown
CollaboratorAuthor

Choose a reason for hiding this comment

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

assert vuln_refs[0].url == "https://example.com/with/more/info/CVE-2020-13371337"


def test_ImportRunner_new_package_version_affected_by_existing_vulnerability(db):

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.

IMHO this may be need to be kept

assert impacted_package.vulnerability.vulnerability_id == "CVE-2020-13371337"


# def test_ImportRunner_fixed_package_version_is_added(db):

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 this test have been of value? and need to be kept?

# assert resolved_package.vulnerability.vulnerability_id == "CVE-2020-13371337"


def test_ImportRunner_updated_vulnerability(db):

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.

IMHO this may be need to be kept, moved to improvers?

Copy link
Copy Markdown
CollaboratorAuthor

Choose a reason for hiding this comment

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

All of these will be moved to improvers. Importers cannot test relationships. It will be a part of a new PR. Tracked in: #612

Signed-off-by: Hritik Vijay <hritikxx8@gmail.com>
Co-authored-by: Philippe Ombredanne <pombredanne@gmail.com>
@Hritik14
Hritik14force-pushed the migration/importer_yielder branch from 61023e6 to 45cdaf5CompareFebruary 7, 2022 14:18

@pombredannepombredanne 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.

LGTM! 👍

@pombredanne
pombredanne merged commit 4ebaa48 into aboutcode-org:mainFeb 7, 2022
Sign up for freeto 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.

Consistent naming of Importer instead of DataSource refactor importer_yielder.py Disable Etag

2 participants

@Hritik14@pombredanne