Skip to content

Commit b39f4b8

Browse files
committed
feat(scanoss): Add release date to snippet findings
Include releaseDate in snippetFindings additionalData and add a new column to display this information in generated reports. Signed-off-by: Agustin Isasmendi <[email protected]>
1 parent 05bfef5 commit b39f4b8

File tree

4 files changed

+11
-5
lines changed

4 files changed

+11
-5
lines changed

plugins/reporters/scanoss/src/main/resources/templates/asciidoc/scanoss_snippet.ftl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,9 @@ License(s):
7979
[#assign snippetCount = snippetFinding.snippets?size]
8080

8181
[width=100%]
82-
[cols="1,3,4,1"]
82+
[cols="1,3,4,1,2"]
8383
|===
84-
| Source Location | pURL | License | Score
84+
| Source Location | pURL | License | Score | Release Date
8585

8686
.${snippetCount*2}+|
8787
Partial match +
@@ -93,6 +93,7 @@ ${sourceLocation.startLine?c}-${sourceLocation.endLine?c}
9393
| ${snippet.purl!""}
9494
| ${snippet.license!""}
9595
| ${snippet.score!""}
96+
| ${snippet.additionalData['release_date']}
9697

9798
4+a|
9899
.Create a snippet choice for this snippet or mark it as false positive

plugins/scanners/scanoss/src/main/kotlin/ScanOssResultParser.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ internal fun generateSummary(startTime: Instant, endTime: Instant, results: List
8484
licenseFindings = licenseFindings,
8585
copyrightFindings = copyrightFindings,
8686
snippetFindings = snippetFindings
87+
8788
)
8889
}
8990

@@ -154,12 +155,14 @@ private fun getSnippets(details: ScanFileDetails): Set<Snippet> {
154155
val vcsInfo = VcsHost.parseUrl(url.takeUnless { it == "none" }.orEmpty())
155156
val provenance = RepositoryProvenance(vcsInfo, ".")
156157

158+
val additionalData = mapOf("release_date" to details.releaseDate)
159+
157160
return buildSet {
158161
purls.forEach { purl ->
159162
locations.forEach { snippetLocation ->
160163
val license = licenses.andOrNull()?.sorted() ?: SpdxLicenseIdExpression(SpdxConstants.NOASSERTION)
161164

162-
add(Snippet(score, snippetLocation, provenance, purl, license))
165+
add(Snippet(score, snippetLocation, provenance, purl, license, additionalData))
163166
}
164167
}
165168
}

plugins/scanners/scanoss/src/test/kotlin/ScanOssResultParserTest.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,8 @@ class ScanOssResultParserTest : WordSpec({
126126
"."
127127
),
128128
"pkg:github/vdurmont/semver4j",
129-
SpdxExpression.parse("CC-BY-SA-2.0")
129+
SpdxExpression.parse("CC-BY-SA-2.0"),
130+
additionalData = mapOf("release_date" to "2019-09-13")
130131
)
131132
)
132133
)

plugins/scanners/scanoss/src/test/kotlin/ScanOssScannerDirectoryTest.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,8 @@ class ScanOssScannerDirectoryTest : StringSpec({
107107
VcsInfo(VcsType.GIT, "https://github.com/scanoss/ort.git", ""), "."
108108
),
109109
"pkg:github/scanoss/ort",
110-
SpdxExpression.parse("Apache-2.0")
110+
SpdxExpression.parse("Apache-2.0"),
111+
additionalData = mapOf("release_date" to "2021-03-18")
111112
)
112113
)
113114
)

0 commit comments

Comments
 (0)