mirror of
https://github.com/ysoftdevs/odc-analyzer.git
synced 2026-05-30 19:30:37 +02:00
Adapt for new version of ODC database
This commit is contained in:
@@ -129,35 +129,35 @@ class Statistics @Inject()(
|
||||
private def select(allResults: (Map[String, (Build, ArtifactItem, ArtifactFile)], Map[String, Throwable]), selectorOption: Option[String]): Option[ResultWithSelection] = select(allResults._1, allResults._2, selectorOption)
|
||||
private def select(successfulResults: Map[String, (Build, ArtifactItem, ArtifactFile)], failedResults: Map[String, Throwable], selectorOption: Option[String]): Option[ResultWithSelection] = dependencyCheckReportsParser.parseReports(successfulResults, failedResults).selection(selectorOption)
|
||||
|
||||
def searchVulnerableSoftware(versionlessCpes: Seq[String], versionOption: Option[String]) = ReadAction.async{ implicit req =>
|
||||
if(versionlessCpes.isEmpty){
|
||||
Future.successful(notFound())
|
||||
}else{
|
||||
val now = DateTime.now()
|
||||
val oldDataThreshold = 2.days
|
||||
val lastDbUpdateFuture = odcDbService.loadLastDbUpdate()
|
||||
val isOldFuture = lastDbUpdateFuture.map{ lastUpdate => now - oldDataThreshold > lastUpdate}
|
||||
versionOption match {
|
||||
case Some(version) =>
|
||||
for {
|
||||
res1 <- Future.traverse(versionlessCpes) { versionlessCpe => odcDbService.findRelevantCpes(versionlessCpe, version) }
|
||||
vulnIds = res1.flatten.map(_.vulnerabilityId).toSet
|
||||
vulns <- Future.traverse(vulnIds)(id => odcDbService.getVulnerabilityDetails(id).map(_.get))
|
||||
isOld <- isOldFuture
|
||||
} yield Ok(views.html.statistics.vulnerabilitiesForLibrary(
|
||||
vulnsAndVersionOption = Some((vulns, version)),
|
||||
cpes = versionlessCpes,
|
||||
isDbOld = isOld
|
||||
))
|
||||
case None =>
|
||||
for(isOld <- isOldFuture) yield Ok(views.html.statistics.vulnerabilitiesForLibrary(
|
||||
vulnsAndVersionOption = None,
|
||||
cpes = versionlessCpes,
|
||||
isDbOld = isOld
|
||||
))
|
||||
}
|
||||
}
|
||||
}
|
||||
// def searchVulnerableSoftware(versionlessCpes: Seq[String], versionOption: Option[String]) = ReadAction.async{ implicit req =>
|
||||
// if(versionlessCpes.isEmpty){
|
||||
// Future.successful(notFound())
|
||||
// }else{
|
||||
// val now = DateTime.now()
|
||||
// val oldDataThreshold = 2.days
|
||||
// val lastDbUpdateFuture = odcDbService.loadLastDbUpdate()
|
||||
// val isOldFuture = lastDbUpdateFuture.map{ lastUpdate => now - oldDataThreshold > lastUpdate}
|
||||
// versionOption match {
|
||||
// case Some(version) =>
|
||||
// for {
|
||||
// res1 <- Future.traverse(versionlessCpes) { versionlessCpe => odcDbService.findRelevantCpes(versionlessCpe, version) }
|
||||
// vulnIds = res1.flatten.map(_.vulnerabilityId).toSet
|
||||
// vulns <- Future.traverse(vulnIds)(id => odcDbService.getVulnerabilityDetails(id).map(_.get))
|
||||
// isOld <- isOldFuture
|
||||
// } yield Ok(views.html.statistics.vulnerabilitiesForLibrary(
|
||||
// vulnsAndVersionOption = Some((vulns, version)),
|
||||
// cpes = versionlessCpes,
|
||||
// isDbOld = isOld
|
||||
// ))
|
||||
// case None =>
|
||||
// for(isOld <- isOldFuture) yield Ok(views.html.statistics.vulnerabilitiesForLibrary(
|
||||
// vulnsAndVersionOption = None,
|
||||
// cpes = versionlessCpes,
|
||||
// isDbOld = isOld
|
||||
// ))
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
def basic(selectorOption: Option[String]) = ReadAction.async{ implicit req =>
|
||||
val (lastRefreshTime, resultsFuture) = projectReportsProvider.resultsForVersions(versions)
|
||||
|
||||
@@ -47,11 +47,12 @@ package object controllers {
|
||||
def vulnerableSoftwareSearches(groupedDependency: GroupedDependency): Seq[(Call, String)] = {
|
||||
val legacySearchOption = groupedDependency.cpeIdentifiers match {
|
||||
case Seq() => None
|
||||
case cpeIds => Some(
|
||||
routes.Statistics.searchVulnerableSoftware(
|
||||
cpeIds.map(_.name.split(':').take(4).mkString(":")).toSeq, None
|
||||
) -> "Search by CPE (legacy option)"
|
||||
)
|
||||
case cpeIds => None
|
||||
// Some(
|
||||
// routes.Statistics.searchVulnerableSoftware(
|
||||
// cpeIds.map(_.name.split(':').take(4).mkString(":")).toSeq, None
|
||||
// ) -> "Search by CPE (legacy option)"
|
||||
// )
|
||||
}
|
||||
val mavenSearches = groupedDependency.mavenIdentifiers.map(_.name).toSeq.sorted.map{mavenIdentifier =>
|
||||
val Array(groupId, artifactId, version) = mavenIdentifier.split(":", 3)
|
||||
|
||||
Reference in New Issue
Block a user