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

feat: added adapter for osv scanner #35

Merged
merged 3 commits into from
Nov 13, 2024
Merged

feat: added adapter for osv scanner #35

merged 3 commits into from
Nov 13, 2024

Conversation

janniclas
Copy link
Contributor

  • osv scanner adapter generates KPIs by using the existing CveAdapter
  • Additional data models for osv detail results are provided, however they are not parsed by default to keep the parsing logic as small as possible to be robust against changes

Additionally, I extended the data format for VulnerabilityDto to explicitly contain a version string. From what I've seen all vulnerability scanners report this information and it is very important to understand the provided results.

- osv scanner adapter generates KPIs by using the existing CveAdapter
- Additional data models for osv detail results are provided, however they are not parsed by default to keep the parsing logic as small as possible to be robust against changes
@janniclas janniclas self-assigned this Nov 9, 2024
@janniclas janniclas added this to the 0.0.3 milestone Nov 9, 2024
Copy link

github-actions bot commented Nov 9, 2024

TestsPassed ✅Skipped ⏭️Failed ❌
JUnit Test Report72 ran72 passed0 skipped0 failed

Copy link

github-actions bot commented Nov 9, 2024

Code Coverage

Overall Project 78.95% -0.16% 🍏
Files changed 94.06% 🍏

Module Coverage
adapter 75.28% -0.29% 🍏
Files
Module File Coverage
adapter OsvAdapter.kt 98.04% -1.96% 🍏
TrivyAdapter.kt 94.16% 🍏
KpiAdapter.kt 91.04% -5.97%

import kotlinx.serialization.json.decodeFromStream

object OsvAdapter {
private val jsonParser = Json {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this something we can make global for the library, or should this be adapter specific?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it might become adapter specific.
However, as long as the config is the same we could use a global object for that I guess. I'll consider this in a dedicated PR

@@ -91,9 +91,13 @@ object TrivyAdapter {
val cvssData = it.cvss!!.values.map { jsonParser.decodeFromJsonElement<CVSSData>(it) }

val score = getHighestCvssScore(cvssData)
val packageID = "${it.pkgName}@${it.installedVersion}"
Copy link
Collaborator

Choose a reason for hiding this comment

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

that's a good change


@Test
fun testResultDto() {
Files.newInputStream(Path("src/test/resources/osv-scanner.json")).use {
Copy link
Collaborator

Choose a reason for hiding this comment

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

what about the other test files?

@janniclas janniclas merged commit a3f284f into main Nov 13, 2024
2 checks passed
@janniclas janniclas deleted the feature/osv branch November 13, 2024 18:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants