mirror of
https://github.com/ysoftdevs/odc-analyzer.git
synced 2026-03-18 23:34:34 +01:00
Added new ODC scans for Java libraries. Those can scan even transitive dependencies and can be run before adding a new library to a project.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import com.mohiva.play.silhouette.api.Environment
|
||||
import com.mohiva.play.silhouette.impl.authenticators.CookieAuthenticator
|
||||
import models.{SnoozeInfo, User}
|
||||
import play.api.mvc.Call
|
||||
|
||||
/**
|
||||
* Created by user on 7/15/15.
|
||||
@@ -35,4 +36,30 @@ package object controllers {
|
||||
}*/
|
||||
def friendlyProjectNameString(reportInfo: ReportInfo) = reportInfo.subprojectNameOption.fold(reportInfo.projectName)(reportInfo.projectName+": "+_)
|
||||
|
||||
val severityOrdering: Ordering[GroupedDependency] = Ordering.by((d: GroupedDependency) => (
|
||||
d.maxCvssScore.map(-_).getOrElse(0.0), // maximum CVSS score is the king
|
||||
if(d.maxCvssScore.isEmpty) Some(-d.dependencies.size) else None, // more affected dependencies if no vulnerability has defined severity
|
||||
-d.vulnerabilities.size, // more vulnerabilities
|
||||
-d.projects.size, // more affected projects
|
||||
d.cpeIdentifiers.map(_.toCpeIdentifierOption.get).toSeq.sorted.mkString(" ")) // at least make the order deterministic
|
||||
)
|
||||
|
||||
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)"
|
||||
)
|
||||
}
|
||||
val mavenSearches = groupedDependency.mavenIdentifiers.map(_.name).toSeq.sorted.map{mavenIdentifier =>
|
||||
val Array(groupId, artifactId, version) = mavenIdentifier.split(":", 3)
|
||||
val identifierString = <dependency><groupId>{groupId}</groupId><artifactId>{artifactId}</artifactId><version>{version}</version></dependency>.toString()
|
||||
routes.LibraryAdvisor.index(Some(identifierString)) -> s"Look for Maven dependency $mavenIdentifier"
|
||||
}
|
||||
mavenSearches ++ legacySearchOption
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user