mirror of
https://github.com/ysoftdevs/odc-analyzer.git
synced 2026-05-02 05:14:22 +02:00
Initial commit
This commit is contained in:
20
app/models/odc/CpeEntry.scala
Normal file
20
app/models/odc/CpeEntry.scala
Normal file
@@ -0,0 +1,20 @@
|
||||
package models.odc
|
||||
|
||||
import models.odc.profile.api._
|
||||
import slick.lifted.Tag
|
||||
|
||||
final case class CpeEntry(cpe: String, vendor: String, product: String)
|
||||
|
||||
class CpeEntries(tag: Tag) extends Table[(Int, CpeEntry)](tag, "cpeEntry") {
|
||||
|
||||
def id = column[Int]("id", O.PrimaryKey)
|
||||
|
||||
def cpe = column[String]("cpe")
|
||||
def vendor = column[String]("vendor")
|
||||
def product = column[String]("product")
|
||||
|
||||
def base = (cpe, vendor, product) <> (CpeEntry.tupled, CpeEntry.unapply)
|
||||
|
||||
def * = (id, base)
|
||||
|
||||
}
|
||||
11
app/models/odc/OdcProperty.scala
Normal file
11
app/models/odc/OdcProperty.scala
Normal file
@@ -0,0 +1,11 @@
|
||||
package models.odc
|
||||
import models.odc.profile.api._
|
||||
|
||||
final case class OdcProperty (id: String, value: String)
|
||||
|
||||
final class OdcProperties(tag: Tag) extends Table[OdcProperty](tag, "properties"){
|
||||
def id = column[String]("id")
|
||||
def value = column[String]("value")
|
||||
|
||||
def * = (id, value) <> (OdcProperty.tupled, OdcProperty.unapply)
|
||||
}
|
||||
17
app/models/odc/References.scala
Normal file
17
app/models/odc/References.scala
Normal file
@@ -0,0 +1,17 @@
|
||||
package models.odc
|
||||
|
||||
import com.ysoft.odc.Reference
|
||||
import models.odc
|
||||
import models.odc.profile.MappedJdbcType
|
||||
import models.odc.profile.api._
|
||||
import slick.lifted.Tag
|
||||
|
||||
class References (tag: Tag) extends Table[(Int, Reference)](tag, "reference") {
|
||||
def cveId = column[Int]("cveid")
|
||||
def name = column[String]("name")
|
||||
def url = column[String]("url")
|
||||
def source = column[String]("source")
|
||||
|
||||
def base = (source, url, name) <> (Reference.tupled, Reference.unapply)
|
||||
def * = (cveId, base)
|
||||
}
|
||||
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)
|
||||
}
|
||||
26
app/models/odc/Vulnerability.scala
Normal file
26
app/models/odc/Vulnerability.scala
Normal file
@@ -0,0 +1,26 @@
|
||||
package models.odc
|
||||
|
||||
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)
|
||||
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 cvssRating = (cvssScore, authentication, availabilityImpact, accessVector, integrityImpact, cvssAccessComplexity, cvssConfidentialityImpact) <> (CvssRating.tupled, CvssRating.unapply)
|
||||
def cweOptionMapped = cweOption <> ((_: Option[String]).map(CWE.apply), (_: Option[CWE]).map(CWE.unapply))
|
||||
def base = (cve, description, cweOptionMapped, cvssRating) <> (Vulnerability.tupled, Vulnerability.unapply)
|
||||
|
||||
def * = (id, base)
|
||||
}
|
||||
17
app/models/odc/package.scala
Normal file
17
app/models/odc/package.scala
Normal file
@@ -0,0 +1,17 @@
|
||||
package models
|
||||
|
||||
import slick.lifted.TableQuery
|
||||
|
||||
package object odc {
|
||||
|
||||
val profile = slick.driver.MySQLDriver
|
||||
|
||||
object tables {
|
||||
val cpeEntries = TableQuery[CpeEntries]
|
||||
val softwareVulnerabilities = TableQuery[SoftwareVulnerabilities]
|
||||
val vulnerabilities = TableQuery[Vulnerabilities]
|
||||
val references = TableQuery[References]
|
||||
val properties = TableQuery[OdcProperties]
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user