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

Prepare advisor module for supporting multiple advisors in one run #3761

Merged

Conversation

KorSin
Copy link
Contributor

@KorSin KorSin commented Mar 15, 2021

I think it is a good idea to split #3638 into multiple PRs.

This PR is a preparation of allowing multiple advisors during a single run.
I am following the idea of the analyzer: The Analyzer class has a single instance and is
to call all the demanded PackageManagers.

For the advisor, the Advisor class should also be a single instance that calls several providers of vulnerabilities.
Thus, a new class is created called VulnerabilityProvider, from which NexusIq and VulnerablerCode inherit.

The PR implements the basics of such a structure, but does not change the logic of calling only one VulnerabilityProvider so this should not be a breaking change. In a following PR, this should then be extended to multiple providers.

advisor/src/main/kotlin/Advisor.kt Outdated Show resolved Hide resolved
advisor/src/main/kotlin/VulnerabilityProviderFactory.kt Outdated Show resolved Hide resolved
advisor/src/main/kotlin/VulnerabilityProviderFactory.kt Outdated Show resolved Hide resolved
advisor/src/main/kotlin/advisors/NexusIq.kt Outdated Show resolved Hide resolved
).convert { advisorName ->
allAdvisorsByName[advisorName.toUpperCase()]
?: throw BadParameterValue("Advisor '$advisorName' is not one of ${allAdvisorsByName.keys}")
allVulnerabilityProvidersByName[advisorName.toUpperCase()]
Copy link
Member

Choose a reason for hiding this comment

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

There is again some confusion regarding the terms Advisor and Vulnerability provider. Not sure, which ones should be used for the user interface. But I guess, as long as there is only a single provider, we can stick to the term Advisor. Only if the user can enable multiple providers, this term should be used.

Copy link
Member

Choose a reason for hiding this comment

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

To clarify: "Advisor" is supposed to be the umbrella term; a "vulnerability provider" is a source that advises about security issues. But there are plans to also advise about completely different aspects, like the quality of an Open Source project / its community health. Such feedback should still be implemented as an advisor (in my current thinking; if that does not make the data model too heterogeneous).

Copy link
Contributor Author

@KorSin KorSin Mar 16, 2021

Choose a reason for hiding this comment

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

@oheger-bosch Hmm technically the names here should also be changed such as the --advisor option, but I did not want to make this a breaking change. Should we just stick to it for now?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@sschuberth But is this additional "Advisor" task supposed to be done by, e.g, NexusIq as well or other services. If it is the latter should they later also be called in the CLI as advisors ?

Copy link
Member

Choose a reason for hiding this comment

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

@oheger-bosch Hmm technically the names here should also be changed such as the --advisor option, but I did not want to make this a breaking change. Should we just stick to it for now?

Yes, I would say we keep the names for now.

@KorSin KorSin force-pushed the korsin/multiple-advisors branch from 939e51d to 14286dd Compare March 16, 2021 10:11
@KorSin KorSin requested a review from oheger-bosch March 16, 2021 10:16
advisor/src/main/kotlin/VulnerabilityProviderFactory.kt Outdated Show resolved Hide resolved
).convert { advisorName ->
allAdvisorsByName[advisorName.toUpperCase()]
?: throw BadParameterValue("Advisor '$advisorName' is not one of ${allAdvisorsByName.keys}")
allVulnerabilityProvidersByName[advisorName.toUpperCase()]
Copy link
Member

Choose a reason for hiding this comment

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

@oheger-bosch Hmm technically the names here should also be changed such as the --advisor option, but I did not want to make this a breaking change. Should we just stick to it for now?

Yes, I would say we keep the names for now.

Copy link
Member

@oheger-bosch oheger-bosch left a comment

Choose a reason for hiding this comment

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

One minor nit in a comment. Otherwise looks good to me.

I think, some naming changes in the advisor command and its options can be done in a later PR.

cli/src/main/kotlin/commands/AdvisorCommand.kt Outdated Show resolved Hide resolved
cli/src/main/kotlin/commands/AdvisorCommand.kt Outdated Show resolved Hide resolved
@KorSin KorSin force-pushed the korsin/multiple-advisors branch from 14286dd to 4ced35f Compare March 16, 2021 13:50
Use a map to access an advisor directly by its name.

Signed-off-by: Korbinian Singhammer <[email protected]>
@KorSin KorSin force-pushed the korsin/multiple-advisors branch from 4ced35f to 9d76059 Compare March 16, 2021 14:07
@KorSin KorSin force-pushed the korsin/multiple-advisors branch from 9d76059 to 978df32 Compare March 17, 2021 08:16
@KorSin KorSin requested a review from oheger-bosch March 17, 2021 08:16
oheger-bosch
oheger-bosch previously approved these changes Mar 17, 2021
cli/src/main/kotlin/commands/AdvisorCommand.kt Outdated Show resolved Hide resolved
advisor/src/main/kotlin/Advisor.kt Show resolved Hide resolved
advisor/src/main/kotlin/VulnerabilityProvider.kt Outdated Show resolved Hide resolved
advisor/src/main/kotlin/Advisor.kt Show resolved Hide resolved
@sschuberth sschuberth changed the title Prepare advisor module for supporting multiple advisors in one run. Prepare advisor module for supporting multiple advisors in one run Mar 17, 2021
Korbinian Singhammer added 3 commits March 17, 2021 05:32
In the following commit, vulnerability providers, such as NexusIq, are going
to implement the VulnerabilitProvider class instead of the Advisor class. Thus,
rename the factory to match the name.

Signed-off-by: Korbinian Singhammer <[email protected]>
Let vulnerabilty providers, e.g. NexusIq, implement the
VulnerabilityProvider class. Move responsibility to create providers
to the Advisor class, which can then call the provider. This is a
preparation to let the Advisor handle multiple providers.

Signed-off-by: Korbinian Singhammer <[email protected]>
@sschuberth sschuberth enabled auto-merge (rebase) March 17, 2021 09:55
@sschuberth sschuberth merged commit 02b8977 into oss-review-toolkit:master Mar 17, 2021
@sschuberth sschuberth deleted the korsin/multiple-advisors branch March 17, 2021 10:22
@KorSin KorSin self-assigned this Mar 17, 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.

3 participants