mirror of
https://github.com/ysoftdevs/odc-analyzer.git
synced 2026-03-24 10:02:00 +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.github.nscala_time.time.Imports._
|
||||||
import com.ysoft.memory.ObjectPool
|
import com.ysoft.memory.ObjectPool
|
||||||
|
import com.ysoft.odc.Confidence.Confidence
|
||||||
import controllers.ReportInfo
|
import controllers.ReportInfo
|
||||||
import models.{LibraryType, PlainLibraryIdentifier}
|
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 suppressedVulnerabilities: Set[Vulnerability] = dependencies.keySet.flatMap(_.suppressedVulnerabilities)
|
||||||
def plainLibraryIdentifiers: Set[PlainLibraryIdentifier] = identifiers.flatMap(_.toLibraryIdentifierOption)
|
def plainLibraryIdentifiers: Set[PlainLibraryIdentifier] = identifiers.flatMap(_.toLibraryIdentifierOption)
|
||||||
def hasCpe: Boolean = cpeIdentifiers.nonEmpty
|
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{
|
object GroupedDependency{
|
||||||
|
|||||||
@@ -27,18 +27,7 @@ final case class GroupedDependencyIdentifier(hashes: Hashes, identifiers: Seq[Id
|
|||||||
object GroupedDependencyIdentifier{
|
object GroupedDependencyIdentifier{
|
||||||
def fromGroupedDependency(groupedDependency: GroupedDependency): GroupedDependencyIdentifier = GroupedDependencyIdentifier(
|
def fromGroupedDependency(groupedDependency: GroupedDependency): GroupedDependencyIdentifier = GroupedDependencyIdentifier(
|
||||||
hashes = groupedDependency.hashes,
|
hashes = groupedDependency.hashes,
|
||||||
identifiers = {
|
identifiers = groupedDependency.identifiersWithFilenames(threshold = Confidence.Highest)
|
||||||
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
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user