Minor hashes refactoring

This commit is contained in:
Šesták Vít
2017-06-19 13:09:17 +02:00
parent e732e2fbb9
commit 2d0651cfc7
4 changed files with 7 additions and 6 deletions

View File

@@ -26,7 +26,7 @@ object QueryBinders {
str => str.split('-') match {
case Array(sha1, md5) => Hashes(sha1 = sha1, md5 = md5)
},
hashes => s"${hashes.sha1}-${hashes.md5}"
hashes => hashes.serialized
)
implicit object MapStringIntJavascriptLiteral extends JavascriptLiteral[Map[String, Int]] {

View File

@@ -30,6 +30,7 @@ final case class Analysis(scanInfo: SerializableXml, name: String, reportDate: D
final case class Hashes(sha1: String, md5: String){
override def toString: String = s"Hashes(sha1=$sha1, md5=$md5)"
def serialized = s"$sha1-$md5"
}
final case class Exclusion(sha1: String) extends AnyVal {
@@ -76,8 +77,8 @@ final case class GroupedDependency(dependencies: Map[Dependency, Set[ReportInfo]
def descriptions = dependencies.keySet.map(_.description)
def projects = dependencies.values.flatten.toSet
def fileNames = dependencies.keySet.map(_.fileName)
def hashes = dependencies.keys.head.hashes // valid since all deps in a group have the same hashes
val sha1 = hashes.sha1
val hashes: Hashes = dependencies.keys.head.hashes // valid since all deps in a group have the same hashes
def sha1: String = hashes.sha1
def identifiers: Set[Identifier] = dependencies.keySet.flatMap(_.identifiers)
def evidenceCollected: Set[Evidence] = dependencies.keySet.flatMap(_.evidenceCollected)
def suppressedIdentifiers: Set[Identifier] = dependencies.keySet.flatMap(_.suppressedIdentifiers)

View File

@@ -48,7 +48,7 @@ object Statistics{
// TODO: Move this to a better place
implicit val hashesWrites = Writes[Hashes](h => JsString(s"${h.sha1}-${h.md5}"))
implicit val hashesWrites = Writes[Hashes](h => JsString(h.serialized))
implicit val confidenceWrites = Writes[Confidence](c => JsString(c.toString))
implicit val identifierWrites = Json.writes[Identifier]
implicit val evidenceWrites = Json.writes[Evidence]

View File

@@ -12,7 +12,7 @@
<th class="actions"></th>
</tr>
</thead>
@for(dep <- list; depPrefix = s"$idPrefix-${dep.sha1}"){
@for(dep <- list; depPrefix = s"$idPrefix-${dep.hashes.serialized}"){
<tr>
<td class="severity">
@for(s <- dep.maxCvssScore) {
@@ -23,7 +23,7 @@
}
</td>
<td class="identifiers">
@libraryIdentificationList(dep, Some(cpe => s"$idPrefix-${dep.sha1}-suppression-cpe-${cpeHtmlId(cpe)}"), addLink = false, addButtons = addButtons)
@libraryIdentificationList(dep, Some(cpe => s"$idPrefix-${dep.hashes.serialized}-suppression-cpe-${cpeHtmlId(cpe)}"), addLink = false, addButtons = addButtons)
</td>
<td class="vulns">@for(s <- dep.maxCvssScore) {@dep.vulnerabilities.size}</td>
<td class="actions">