mirror of
https://github.com/ysoftdevs/odc-analyzer.git
synced 2026-03-21 16:50:04 +01:00
Initial commit
This commit is contained in:
39
app/models/odc/SoftwareVulnerability.scala
Normal file
39
app/models/odc/SoftwareVulnerability.scala
Normal file
@@ -0,0 +1,39 @@
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
/*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)
|
||||
}
|
||||
Reference in New Issue
Block a user