mirror of
https://github.com/ysoftdevs/odc-analyzer.git
synced 2026-01-15 00:03:59 +01:00
40 lines
1.6 KiB
Scala
40 lines
1.6 KiB
Scala
package models.odc
|
|
|
|
import models.odc.profile.api._
|
|
import models.odc.profile.jdbcTypeFor
|
|
import slick.ast.TypedType
|
|
import models.odc.profile.MappedJdbcType
|
|
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")
|
|
// }
|
|
}
|
|
|
|
/*private class OdcBooleanType(implicit t: JdbcType[Option[String]]) extends MappedJdbcType[Boolean, Option[String]] {
|
|
override def map(t: Boolean): Option[String] = t match {
|
|
case true => Some("1")
|
|
case false => None
|
|
}
|
|
|
|
override def comap(u: Option[String]): Boolean = u match {
|
|
case Some("1") => true
|
|
case None => false
|
|
}
|
|
|
|
}*/
|
|
|
|
class SoftwareVulnerabilities(tag: Tag) extends Table[SoftwareVulnerability](tag, "software") {
|
|
def vulnerabilityId = column[Int]("cveid")
|
|
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)
|
|
} |