Skip to content

Commit

Permalink
Make fields are nullable + added a small test (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
nulls authored Aug 25, 2023
1 parent 513acb8 commit d5862ef
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/commonMain/kotlin/com/saveourtool/osv4k/OsvSchema.kt
Original file line number Diff line number Diff line change
Expand Up @@ -776,7 +776,7 @@ data class Severity(
defaultValue = "",
access = JsonPropertyAccess.AUTO
)
val level: SeverityLevel,
val level: SeverityLevel? = null,
@SerialName("score_num")
@get:JsonProperty(
value = "score_num",
Expand All @@ -794,7 +794,7 @@ data class Severity(
defaultValue = "",
access = JsonPropertyAccess.AUTO
)
val scoreNum: String,
val scoreNum: String? = null,
)

/**
Expand Down
62 changes: 62 additions & 0 deletions src/commonTest/kotlin/com/saveourtool/osv4k/CosvTest.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
@file:Suppress("LONG_LINE", "TOO_LONG_FUNCTION")

package com.saveourtool.osv4k

import com.saveourtool.osv4k.OsvSchemaTestUtil.doEncodeDecodeAndCompare
import kotlin.test.Test

class CosvTest {
@Test
fun `COSV with severity`() {
// language=JSON
doEncodeDecodeAndCompare(
"""
{
"id": "DSA-3029-1",
"modified": "2014-09-20T08:18:07Z",
"published": "2014-09-20T00:00:01Z",
"aliases": [
"CVE-2014-3616"
],
"summary": "nginx - security update",
"details": "\nAntoine Delignat-Lavaud and Karthikeyan Bhargavan discovered that it was\npossible to reuse cached SSL sessions in unrelated contexts, allowing\nvirtual host confusion attacks in some configurations by an attacker in\na privileged network position.\n\n\nFor the stable distribution (wheezy), this problem has been fixed in\nversion 1.2.1-2.2+wheezy3.\n\n\nFor the testing distribution (jessie), this problem has been fixed in\nversion 1.6.2-1.\n\n\nFor the unstable distribution (sid), this problem has been fixed in\nversion 1.6.2-1.\n\n\nWe recommend that you upgrade your nginx packages.\n\n\n",
"severity": [
{
"type": "CVSS_V3",
"score": "some_value",
"level": "None"
}
],
"affected": [
{
"package": {
"ecosystem": "Debian:7",
"name": "nginx"
},
"ranges": [
{
"type": "ECOSYSTEM",
"events": [
{
"introduced": "0"
},
{
"fixed": "1.2.1-2.2+wheezy3"
}
]
}
]
}
],
"references": [
{
"type": "ADVISORY",
"url": "https://www.debian.org/security/2014/dsa-3029"
}
],
"confirm_type": "manual_confirmed"
}
""".trimIndent()
)
}
}

0 comments on commit d5862ef

Please sign in to comment.