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

Extend vulnerability model to support multiple sources #3823

Conversation

oheger-bosch
Copy link
Member

This PR prepares the full integration of VulnerableCode as an advisor.

VulnerableCode supports multiple sources of vulnerability information. Each vulnerability has a list of references to the sources from which information has been drawn. To represent this, the PR extends the data model accordingly.

Note that this is only a change of the data model, but the VulnerableCode advisor implementation is not yet updated to actually populate this data model.

@oheger-bosch oheger-bosch marked this pull request as ready for review March 29, 2021 11:00
@oheger-bosch oheger-bosch force-pushed the oheger-bosch/advisor/vulnerable_code_bulk_api branch from 6242747 to ad01500 Compare March 29, 2021 12:49
model/src/main/kotlin/VulnerabilityReference.kt Outdated Show resolved Hide resolved
model/src/main/kotlin/Vulnerability.kt Outdated Show resolved Hide resolved
@oheger-bosch oheger-bosch force-pushed the oheger-bosch/advisor/vulnerable_code_bulk_api branch from ad01500 to 6e792b6 Compare March 30, 2021 05:20
@oheger-bosch oheger-bosch requested a review from a team as a code owner March 30, 2021 05:20
@oheger-bosch oheger-bosch force-pushed the oheger-bosch/advisor/vulnerable_code_bulk_api branch from 6e792b6 to c8cc47d Compare March 30, 2021 06:29
clients/nexus-iq/src/main/kotlin/NexusIqService.kt Outdated Show resolved Hide resolved
clients/nexus-iq/src/main/kotlin/NexusIqService.kt Outdated Show resolved Hide resolved
advisor/src/main/kotlin/advisors/VulnerableCode.kt Outdated Show resolved Hide resolved
@oheger-bosch oheger-bosch force-pushed the oheger-bosch/advisor/vulnerable_code_bulk_api branch from c8cc47d to 055aa8f Compare March 30, 2021 09:42
.map {
Vulnerability(
it.cveId.orEmpty(),
listOf(VulnerabilityReference(URI(it.url), null, (it.cvss ?: SEVERITY_UNDEFINED).toString()))
Copy link
Member

Choose a reason for hiding this comment

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

I believe what we really should do here instead of

(it.cvss ?: SEVERITY_UNDEFINED).toString())

is

it.cvss?.toString() ?: UNKNOWN_SEVERITY

and introduce const UNKNOWN_SEVERITY = "Unknown" to VulnerabilityReference. But that can be done later when touching this code anyway for the bulk-fetch implementation.

sschuberth
sschuberth previously approved these changes Mar 30, 2021
@oheger-bosch
Copy link
Member Author

I have added one more commit to add a custom deserializer for the Vulnerability class that can handle the old and the new format. With this change, older ORT result files can still be loaded.

KorSin
KorSin previously approved these changes Mar 31, 2021
Copy link
Contributor

@KorSin KorSin left a comment

Choose a reason for hiding this comment

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

Looks good to me.
As for the deserialisation, I think it is good to be able to use our old advisor results.
Just keep in mind that this should be removed at some point in the future.

advisor/src/test/kotlin/advisors/VulnerableCodeTest.kt Outdated Show resolved Hide resolved
advisor/src/test/kotlin/advisors/VulnerableCodeTest.kt Outdated Show resolved Hide resolved
model/src/main/kotlin/Vulnerability.kt Outdated Show resolved Hide resolved
model/src/test/kotlin/AdvisorResultContainerTest.kt Outdated Show resolved Hide resolved
model/src/test/kotlin/AdvisorResultContainerTest.kt Outdated Show resolved Hide resolved
@oheger-bosch
Copy link
Member Author

Removed breaking-change label. With the custom deserializer for vulnerabilities, this is no longer a breaking change.

@oheger-bosch oheger-bosch force-pushed the oheger-bosch/advisor/vulnerable_code_bulk_api branch from 67af3a4 to 25fa967 Compare April 8, 2021 07:16
When querying vulnerability information from multiple providers
information about a single vulnerability can be found at different
sources. To represent such a source and the information it contains,
introduce a new data class.

In a later commit, the Vulnerability class will be given a list of
these references.

Signed-off-by: Oliver Heger <[email protected]>
@oheger-bosch oheger-bosch force-pushed the oheger-bosch/advisor/vulnerable_code_bulk_api branch from 25fa967 to ee6a225 Compare April 8, 2021 10:02
According to the NexusIQ documentation [1], the scoring system used by
vulnerabilities is either CVSS2 or CVSS3; the concrete one is
determined by the prefix of the reference of a vulnerability. Add a
function to obtain the scoring system based on this reference.

This information is needed to provide additional data for
vulnerabilities as supported by the extended data model of the
advisor.

[1] https://guides.sonatype.com/iqserver/technical-guides/sonatype-vuln-data/#how-is-a-vulnerability-score-severity-calculated

Signed-off-by: Oliver Heger <[email protected]>
The Vulnerability data class now stores a list of
VulnerabilityReferences containing the information from different
sources.

Adapt the existing advisor implementations accordingly. Note that at
this stage, there is no implementation that actually returns multiple
references for a single vulnerability; but this is going to change for
VulnerableCode.

Signed-off-by: Oliver Heger <[email protected]>
With the changes on the data structures to store vulnerabilities,
older ORT results can no longer be deserialized. To fix this, add a
custom deserializer, which can handle both the old and the new format
of vulnerability information.

Signed-off-by: Oliver Heger <[email protected]>
@oheger-bosch oheger-bosch force-pushed the oheger-bosch/advisor/vulnerable_code_bulk_api branch from ee6a225 to 778a44d Compare April 8, 2021 10:26
@sschuberth sschuberth enabled auto-merge (rebase) April 8, 2021 10:33
@sschuberth sschuberth merged commit 993ba81 into oss-review-toolkit:master Apr 8, 2021
@sschuberth sschuberth deleted the oheger-bosch/advisor/vulnerable_code_bulk_api branch April 8, 2021 11:09
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