-
Notifications
You must be signed in to change notification settings - Fork 320
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
Osv: Add a fallback for the severity #5545
Conversation
71d2fc0
to
fdd9d5d
Compare
Codecov Report
@@ Coverage Diff @@
## main #5545 +/- ##
=========================================
Coverage 70.42% 70.42%
Complexity 2121 2121
=========================================
Files 270 270
Lines 14859 14859
Branches 2407 2407
=========================================
Hits 10465 10465
Misses 3294 3294
Partials 1100 1100
Flags with carried forward coverage won't be shown. Click here to find out more. Continue to review full report at Codecov.
|
clients/osv/src/main/kotlin/Model.kt
Outdated
@@ -25,6 +25,15 @@ import kotlinx.serialization.SerialName | |||
import kotlinx.serialization.Serializable | |||
import kotlinx.serialization.json.JsonObject | |||
|
|||
// FIXME: Remove all JsonElement subtypes as property types from the model in favor of raw strings holding JSON. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't you simply use a custom deserializer as outlined here that calls encodeToString()
on the JsonElement
? Performance should not be an issue here, as I do not expect these model element to be large.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've read this comment in the link you provided already before and have tried to write code based on it. I haven't figured it out though. As you say "simply", maybe you know how to use it to reach the goal. In particular, it was unclear what this polymorphicSerlializer
variable is and how to modify BaseClass
in that code snippet to make it compile. Do you have a hint?
fdd9d5d
to
50c94cf
Compare
50c94cf
to
988a35e
Compare
988a35e
to
1686110
Compare
@@ -49,5 +49,32 @@ | |||
"severity" : "7.5" | |||
} ] | |||
} ] | |||
} ], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if this was a misunderstanding of one of my earlier comments, but IMO this commit should be squashed with the next one, so test data and implementation are added in the same commit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My intention was to make the effect of the parsing obvious in the commits. Your proposal would defeat that idea. But I do actually like it and prefer to not squash. Ok?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense, let's keep it as-is.
Signed-off-by: Frank Viernau <[email protected]>
Signed-off-by: Frank Viernau <[email protected]>
The vulnerability lacks a severity in its dedicataed property, but has a 'severity' property in the `databaseSpecific: JSONObject?` property. This prepares for adding a fallback solution. Signed-off-by: Frank Viernau <[email protected]>
The server does return vulnerabilities which do not have a severity value in the dedicated property. The unspecified `databaseSpecific` property often times holds a primitive `severity` property with values such as `[HIGH, MEDIUM, LOW]`. Make use of these values as a fallback as these to provide more indication than a `null` value. Note: The data model of 'osv/client' currently uses subtypes of JsonElement to expose a couple of unspecified JSON objects as properties. Accessing these requires the client code to add 'kotlinx.serialization' as dependency which is not nice. A solution to that would be to use "raw" string values containing the JSON, which is unfortunately not yet possible but may become so in the future, see [1][2][3]. So, for now add 'kotlinx.serialization' as dependency to the advisor in order to access the property and leave a FIXME comment as reminder. [1] Kotlin/kotlinx.serialization#1298 [2] Kotlin/kotlinx.serialization#1405 [3] Kotlin/kotlinx.serialization#1058 Signed-off-by: Frank Viernau <[email protected]>
Signed-off-by: Frank Viernau <[email protected]>
1686110
to
6ad8550
Compare
Merge despite the bogus webapp build falure |
Please see the individual commits.
Part of #3599.