mirror of
https://github.com/ysoftdevs/odc-analyzer.git
synced 2026-01-16 00:34:18 +01:00
Fixed order of identifiers
This commit is contained in:
@@ -2,6 +2,7 @@ package com.ysoft.odc
|
||||
|
||||
import com.github.nscala_time.time.Imports._
|
||||
import com.ysoft.memory.ObjectPool
|
||||
import com.ysoft.odc.Confidence.Confidence
|
||||
import controllers.ReportInfo
|
||||
import models.{LibraryType, PlainLibraryIdentifier}
|
||||
|
||||
@@ -86,6 +87,18 @@ final case class GroupedDependency(dependencies: Map[Dependency, Set[ReportInfo]
|
||||
def suppressedVulnerabilities: Set[Vulnerability] = dependencies.keySet.flatMap(_.suppressedVulnerabilities)
|
||||
def plainLibraryIdentifiers: Set[PlainLibraryIdentifier] = identifiers.flatMap(_.toLibraryIdentifierOption)
|
||||
def hasCpe: Boolean = cpeIdentifiers.nonEmpty
|
||||
def identifiersWithFilenames(threshold: Confidence) = {
|
||||
def fileNameIdentifiers = fileNames.toIndexedSeq.sorted.map(filename => Identifier(
|
||||
identifierType = "file",
|
||||
name = filename,
|
||||
confidence = Confidence.Highest,
|
||||
url = ""
|
||||
))
|
||||
val identifiersSeq =
|
||||
if(identifiers.exists(_.confidence >= threshold)) identifiers
|
||||
else fileNameIdentifiers ++ identifiers // If we don't know any reliable identifier, add filenames
|
||||
identifiersSeq.toIndexedSeq.sortBy(_.name)
|
||||
}
|
||||
}
|
||||
|
||||
object GroupedDependency{
|
||||
|
||||
@@ -27,18 +27,7 @@ final case class GroupedDependencyIdentifier(hashes: Hashes, identifiers: Seq[Id
|
||||
object GroupedDependencyIdentifier{
|
||||
def fromGroupedDependency(groupedDependency: GroupedDependency): GroupedDependencyIdentifier = GroupedDependencyIdentifier(
|
||||
hashes = groupedDependency.hashes,
|
||||
identifiers = {
|
||||
val identifiers = groupedDependency.identifiers.toIndexedSeq.sortBy(_.name)
|
||||
def fileNameIdentifiers = groupedDependency.fileNames.toIndexedSeq.sorted.map(filename => Identifier(
|
||||
identifierType = "file",
|
||||
name = filename,
|
||||
confidence = Confidence.Highest,
|
||||
url = ""
|
||||
))
|
||||
|
||||
if(identifiers.exists(_.confidence >= Confidence.Medium)) identifiers
|
||||
else fileNameIdentifiers ++ identifiers // If we don't know any reliable identifier, add filenames
|
||||
}
|
||||
identifiers = groupedDependency.identifiersWithFilenames(threshold = Confidence.Highest)
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user