mirror of
https://github.com/ysoftdevs/odc-analyzer.git
synced 2026-03-12 13:22:22 +01:00
Adapt for new version of ODC database
This commit is contained in:
@@ -9,12 +9,12 @@ import slick.jdbc.JdbcType
|
||||
import scala.reflect.ClassTag
|
||||
|
||||
// TODO: consider renaming to CpeEntryVulnerability or something like that
|
||||
final case class SoftwareVulnerability (vulnerabilityId: Int, cpeEntryId: Int, includesAllPreviousVersionsRaw: Option[String]){
|
||||
def includesAllPreviousVersions: Boolean = includesAllPreviousVersionsRaw match {
|
||||
case Some("1") => true
|
||||
case None => false
|
||||
case _ => sys.error("Unexpected value from ODC database")
|
||||
}
|
||||
final case class SoftwareVulnerability (vulnerabilityId: Int, cpeEntryId: Int/*, includesAllPreviousVersionsRaw: Option[String]*/){
|
||||
// def includesAllPreviousVersions: Boolean = includesAllPreviousVersionsRaw match {
|
||||
// case Some("1") => true
|
||||
// case None => false
|
||||
// case _ => sys.error("Unexpected value from ODC database")
|
||||
// }
|
||||
}
|
||||
|
||||
/*private class OdcBooleanType(implicit t: JdbcType[Option[String]]) extends MappedJdbcType[Boolean, Option[String]] {
|
||||
@@ -35,6 +35,6 @@ class SoftwareVulnerabilities(tag: Tag) extends Table[SoftwareVulnerability](tag
|
||||
def cpeEntryId = column[Int]("cpeentryid")
|
||||
//private val bt = new OdcBooleanType()(jdbcTypeFor(implicitly[BaseColumnType[String]].optionType).asInstanceOf[JdbcType[Option[String]]])
|
||||
//MappedJdbcType.base[Boolean, Option[String]](???, ???)(implicitly[ClassTag[Boolean]], )
|
||||
def includesAllPreviousVersionsRaw = column[String]("previousversion").?
|
||||
def * = (vulnerabilityId, cpeEntryId, includesAllPreviousVersionsRaw) <> (SoftwareVulnerability.tupled, SoftwareVulnerability.unapply)
|
||||
//def includesAllPreviousVersionsRaw = column[String]("previousversion").?
|
||||
def * = (vulnerabilityId, cpeEntryId/*, includesAllPreviousVersionsRaw*/) <> (SoftwareVulnerability.tupled, SoftwareVulnerability.unapply)
|
||||
}
|
||||
@@ -4,23 +4,23 @@ import com.ysoft.odc.{CvssRating, CWE}
|
||||
import models.odc.profile.api._
|
||||
import slick.lifted.Tag
|
||||
|
||||
case class Vulnerability (cve: String, description: String, cweOption: Option[CWE], cvss: CvssRating)
|
||||
case class Vulnerability (cve: String, description: String, /*cweOption: Option[CWE],*/ cvss: CvssRating)
|
||||
class Vulnerabilities(tag: Tag) extends Table[(Int, Vulnerability)](tag, "vulnerability") {
|
||||
def id = column[Int]("id")
|
||||
def cve = column[String]("cve")
|
||||
def description = column[String]("description")
|
||||
def cweOption = column[String]("cwe").?
|
||||
def cvssScore = column[Double]("cvssscore").?
|
||||
def authentication = column[String]("cvssauthentication").?
|
||||
def availabilityImpact = column[String]("cvssavailabilityimpact").?
|
||||
def accessVector = column[String]("cvssaccessvector").?
|
||||
def integrityImpact = column[String]("cvssintegrityimpact").?
|
||||
def cvssAccessComplexity = column[String]("cvssaccesscomplexity").?
|
||||
def cvssConfidentialityImpact = column[String]("cvssconfidentialityimpact").?
|
||||
//def cweOption = column[String]("cwe").?
|
||||
def cvssScore = column[Double]("cvssv2score").?
|
||||
def authentication = column[String]("cvssv2authentication").?
|
||||
def availabilityImpact = column[String]("cvssv2availabilityimpact").?
|
||||
def accessVector = column[String]("cvssv2accessvector").?
|
||||
def integrityImpact = column[String]("cvssv2integrityimpact").?
|
||||
def cvssAccessComplexity = column[String]("cvssv2accesscomplexity").?
|
||||
def cvssConfidentialityImpact = column[String]("cvssv2confidentialityimpact").?
|
||||
|
||||
def cvssRating = (cvssScore, authentication, availabilityImpact, accessVector, integrityImpact, cvssAccessComplexity, cvssConfidentialityImpact) <> (CvssRating.tupled, CvssRating.unapply)
|
||||
def cweOptionMapped = cweOption <> ((_: Option[String]).map(CWE.forIdentifierWithDescription), (_: Option[CWE]).map(CWE.unapply))
|
||||
def base = (cve, description, cweOptionMapped, cvssRating) <> (Vulnerability.tupled, Vulnerability.unapply)
|
||||
//def cweOptionMapped = cweOption <> ((_: Option[String]).map(CWE.forIdentifierWithDescription), (_: Option[CWE]).map(CWE.unapply))
|
||||
def base = (cve, description, cvssRating) <> (Vulnerability.tupled, Vulnerability.unapply)
|
||||
|
||||
def * = (id, base)
|
||||
}
|
||||
Reference in New Issue
Block a user