Skip to content

Commit

Permalink
Update dlp structure
Browse files Browse the repository at this point in the history
  • Loading branch information
p4skal committed Jan 9, 2024
1 parent ecd3b04 commit 24a5b5a
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/main/kotlin/io/hawk/service/dlp/DlpFinding.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class DlpFinding {

@Type(JsonBinaryType::class)
@Column(nullable = false, columnDefinition = "jsonb")
lateinit var occurrence: Occurrence
lateinit var occurrences: List<Occurrence>

@Type(JsonBinaryType::class)
@Column(columnDefinition = "jsonb")
Expand Down
10 changes: 6 additions & 4 deletions src/main/kotlin/io/hawk/service/dlp/DlpJob.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@ package io.hawk.service.dlp

import io.hawk.dlp.common.JobStatus
import jakarta.persistence.*
import org.hibernate.annotations.Type
import java.time.LocalDateTime
import java.util.UUID
import java.util.*

@Entity
class DlpJob {
Expand All @@ -16,10 +15,13 @@ class DlpJob {
@Column(nullable = false)
var created: LocalDateTime = LocalDateTime.now()

@Enumerated
@Column(nullable = false)
@Enumerated(EnumType.STRING)
lateinit var status: JobStatus

@Column(length = 2_000)
@Column(columnDefinition = "TEXT")
var error: String? = null

@OneToMany(mappedBy = "job")
lateinit var results: List<out DlpResult>
}
4 changes: 4 additions & 0 deletions src/main/kotlin/io/hawk/service/dlp/DlpResult.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ open class DlpResult {
@Id
open lateinit var id: UUID

@ManyToOne
@JoinColumn(name = "job_id")
var job: DlpJob? = null

@Column(nullable = false)
open lateinit var timestamp: LocalDateTime

Expand Down
11 changes: 11 additions & 0 deletions src/main/kotlin/io/hawk/service/traffic/field/Field.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ import com.vladmihalcea.hibernate.type.array.EnumArrayType
import com.vladmihalcea.hibernate.type.array.internal.AbstractArrayType
import com.vladmihalcea.hibernate.type.json.JsonBinaryType
import io.hawk.dlp.common.InfoType
import io.hawk.service.dlp.DlpFinding
import io.hawk.service.traffic.mapping.MappingField
import jakarta.persistence.*
import org.hibernate.annotations.JoinFormula
import org.hibernate.annotations.Parameter
import org.hibernate.annotations.Type

Expand Down Expand Up @@ -57,4 +59,13 @@ class Field {
@JsonIgnore
@OneToMany(mappedBy = "field", cascade = [CascadeType.REMOVE])
var mappingFields: MutableList<MappingField> = mutableListOf()

@JsonIgnore
@OneToMany(mappedBy = "field")
@JoinFormula(value = """
(SELECT 1 FROM field
WHERE field.id = field_id
AND dlp_finding.info_type = ANY(field.info_types))
""", referencedColumnName = "id")
var findings: MutableList<DlpFinding> = mutableListOf()
}

0 comments on commit 24a5b5a

Please sign in to comment.