-
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #462 from DependencyTrack/create-table-for-vulnera…
…bility-policy Create table for vulnerability policy
- Loading branch information
Showing
8 changed files
with
565 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
175 changes: 175 additions & 0 deletions
175
src/main/java/org/dependencytrack/model/VulnerabilityPolicy.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,175 @@ | ||
package org.dependencytrack.model; | ||
|
||
import alpine.common.validation.RegexSequence; | ||
import alpine.server.json.TrimmedStringDeserializer; | ||
import com.fasterxml.jackson.annotation.JsonIgnore; | ||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; | ||
import com.fasterxml.jackson.annotation.JsonInclude; | ||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize; | ||
import org.cyclonedx.model.vulnerability.Vulnerability; | ||
import org.dependencytrack.model.vulnerabilitypolicy.VulnerabilityPolicyAnalysis; | ||
|
||
import javax.jdo.annotations.Column; | ||
import javax.jdo.annotations.IdGeneratorStrategy; | ||
import javax.jdo.annotations.Index; | ||
import javax.jdo.annotations.PersistenceCapable; | ||
import javax.jdo.annotations.Persistent; | ||
import javax.jdo.annotations.PrimaryKey; | ||
import javax.jdo.annotations.Serialized; | ||
import javax.jdo.annotations.Unique; | ||
import javax.validation.constraints.NotBlank; | ||
import javax.validation.constraints.Pattern; | ||
import javax.validation.constraints.Size; | ||
import java.io.Serializable; | ||
import java.util.Date; | ||
import java.util.List; | ||
|
||
@PersistenceCapable(table= "VULNERABILITY_POLICY") | ||
@JsonInclude(JsonInclude.Include.NON_NULL) | ||
@JsonIgnoreProperties(ignoreUnknown = true) | ||
public class VulnerabilityPolicy implements Serializable { | ||
|
||
@PrimaryKey | ||
@Persistent(valueStrategy = IdGeneratorStrategy.NATIVE) | ||
@JsonIgnore | ||
private long id; | ||
|
||
@Persistent | ||
@Column(name = "NAME", allowsNull = "false") | ||
@Index(name = "VULNERABILITY_POLICY_NAME_IDX" , unique = "true") | ||
@NotBlank | ||
@Size(min = 1, max = 255) | ||
@Pattern(regexp = RegexSequence.Definition.PRINTABLE_CHARS, message = "The name may only contain printable characters") | ||
private String name; | ||
|
||
@Persistent | ||
@Column(name = "DESCRIPTION", allowsNull = "true") | ||
@Size(max = 4096) | ||
@Pattern(regexp = RegexSequence.Definition.PRINTABLE_CHARS, message = "The description may only contain printable characters") | ||
private String description; | ||
|
||
@Persistent | ||
@Column(name = "AUTHOR", allowsNull = "true", jdbcType = "VARCHAR") | ||
@Pattern(regexp = RegexSequence.Definition.PRINTABLE_CHARS, message = "The author may only contain printable characters") | ||
private String author; | ||
|
||
@Persistent | ||
@Column(name = "CREATED", allowsNull = "true") | ||
private Date created; | ||
|
||
@Persistent | ||
@Column(name = "UPDATED", allowsNull = "true") | ||
private Date updated; | ||
|
||
@Persistent | ||
@Column(name = "VALID_FROM", allowsNull = "true") | ||
private Date validFrom; | ||
|
||
@Persistent | ||
@Column(name = "VALID_UNTIL", allowsNull = "true") | ||
private Date validUntil; | ||
|
||
@Persistent(defaultFetchGroup = "true") | ||
@JsonDeserialize(using = TrimmedStringDeserializer.class) | ||
@Column(name = "CONDITIONS", allowsNull = "false") | ||
private String[] conditions; | ||
|
||
@Column(name = "ANALYSIS", allowsNull = "false") | ||
@Persistent(defaultFetchGroup = "true") | ||
@JsonDeserialize(using = TrimmedStringDeserializer.class) | ||
private VulnerabilityPolicyAnalysis analysis; | ||
|
||
@Column(name = "RATINGS", allowsNull = "true") | ||
@Persistent(defaultFetchGroup = "true") | ||
@JsonDeserialize(using = TrimmedStringDeserializer.class) | ||
private List<Vulnerability.Rating> ratings; | ||
|
||
public long getId() { | ||
return id; | ||
} | ||
|
||
public void setId(long id) { | ||
this.id = id; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
|
||
public String getDescription() { | ||
return description; | ||
} | ||
|
||
public void setDescription(String description) { | ||
this.description = description; | ||
} | ||
|
||
public String getAuthor() { | ||
return author; | ||
} | ||
|
||
public void setAuthor(String author) { | ||
this.author = author; | ||
} | ||
|
||
public Date getCreated() { | ||
return created; | ||
} | ||
|
||
public void setCreated(Date created) { | ||
this.created = created; | ||
} | ||
|
||
public Date getUpdated() { | ||
return updated; | ||
} | ||
|
||
public void setUpdated(Date updated) { | ||
this.updated = updated; | ||
} | ||
|
||
public Date getValidFrom() { | ||
return validFrom; | ||
} | ||
|
||
public void setValidFrom(Date validFrom) { | ||
this.validFrom = validFrom; | ||
} | ||
|
||
public Date getValidUntil() { | ||
return validUntil; | ||
} | ||
|
||
public void setValidUntil(Date validUntil) { | ||
this.validUntil = validUntil; | ||
} | ||
|
||
public String[] getConditions() { | ||
return conditions; | ||
} | ||
|
||
public void setConditions(String[] conditions) { | ||
this.conditions = conditions; | ||
} | ||
|
||
public VulnerabilityPolicyAnalysis getAnalysis() { | ||
return analysis; | ||
} | ||
|
||
public void setAnalysis(VulnerabilityPolicyAnalysis vulnerabilityPolicyAnalysis) { | ||
this.analysis = vulnerabilityPolicyAnalysis; | ||
} | ||
|
||
public List<Vulnerability.Rating> getRatings() { | ||
return ratings; | ||
} | ||
|
||
public void setRatings(List<Vulnerability.Rating> ratings) { | ||
this.ratings = ratings; | ||
} | ||
} | ||
|
7 changes: 7 additions & 0 deletions
7
src/main/java/org/dependencytrack/model/vulnerabilitypolicy/VulnerabilityPolicyAnalysis.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package org.dependencytrack.model.vulnerabilitypolicy; | ||
|
||
import org.dependencytrack.model.AnalysisJustification; | ||
import org.dependencytrack.model.AnalysisState; | ||
|
||
public record VulnerabilityPolicyAnalysis(AnalysisState state, AnalysisJustification justification, String details, boolean suppress) { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.