Skip to content

Commit

Permalink
remove length constraint from POLICYCONDITION
Browse files Browse the repository at this point in the history
  • Loading branch information
sahibamittal committed Feb 19, 2024
1 parent 56e635a commit 621ba00
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 8 deletions.
1 change: 0 additions & 1 deletion src/main/java/org/dependencytrack/model/Policy.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
Expand Down
7 changes: 1 addition & 6 deletions src/main/java/org/dependencytrack/model/PolicyCondition.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;
import java.io.Serializable;
import java.util.UUID;

Expand Down Expand Up @@ -100,27 +99,23 @@ public enum Subject {
@Persistent
@Column(name = "OPERATOR", allowsNull = "false")
@NotBlank
@Size(min = 1, max = 255)
@Pattern(regexp = RegexSequence.Definition.PRINTABLE_CHARS, message = "The operator may only contain printable characters")
private Operator operator;

@Persistent
@Column(name = "SUBJECT", allowsNull = "false")
@NotBlank
@Size(min = 1, max = 255)
@Pattern(regexp = RegexSequence.Definition.PRINTABLE_CHARS, message = "The subject may only contain printable characters")
private Subject subject;

@Persistent
@Column(name = "VALUE", allowsNull = "false", jdbcType = "CLOB")
@Column(name = "VALUE", allowsNull = "false")
@NotBlank
@Size(min = 1)
@Pattern(regexp = RegexSequence.Definition.PRINTABLE_CHARS, message = "The value may only contain printable characters")
private String value;

@Persistent
@Column(name = "VIOLATIONTYPE", allowsNull = "true")
@Size(min = 1, max = 255)
@Pattern(regexp = RegexSequence.Definition.PRINTABLE_CHARS, message = "The violation type may only contain printable characters")
private PolicyViolation.Type violationType;

Expand Down
12 changes: 12 additions & 0 deletions src/main/resources/migration/changelog-v5.3.0.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2689,6 +2689,18 @@
ALTER TABLE "POLICY" ADD CONSTRAINT "POLICY_OPERATOR_check"
CHECK ("OPERATOR"::TEXT = ANY(ARRAY['ALL', 'ANY']));

ALTER TABLE "POLICYCONDITION" DROP CONSTRAINT IF EXISTS "POLICYCONDITION_OPERATOR_check";
ALTER TABLE "POLICYCONDITION" ADD CONSTRAINT "POLICYCONDITION_OPERATOR_check"
CHECK ("OPERATOR"::TEXT = ANY(ARRAY['IS', 'IS_NOT', 'MATCHES', 'NO_MATCH', 'NUMERIC_GREATER_THAN', 'NUMERIC_LESS_THAN', 'NUMERIC_EQUAL', 'NUMERIC_NOT_EQUAL', 'NUMERIC_GREATER_THAN_OR_EQUAL', 'NUMERIC_LESSER_THAN_OR_EQUAL', 'CONTAINS_ALL', 'CONTAINS_ANY']));

ALTER TABLE "POLICYCONDITION" DROP CONSTRAINT IF EXISTS "POLICYCONDITION_SUBJECT_check";
ALTER TABLE "POLICYCONDITION" ADD CONSTRAINT "POLICYCONDITION_SUBJECT_check"
CHECK ("SUBJECT"::TEXT = ANY(ARRAY['AGE', 'COORDINATES', 'CPE', 'EXPRESSION', 'LICENSE', 'LICENSE_GROUP', 'PACKAGE_URL', 'SEVERITY', 'SWID_TAGID', 'VERSION', 'COMPONENT_HASH', 'CWE', 'VULNERABILITY_ID', 'VERSION_DISTANCE']));

ALTER TABLE "POLICYCONDITION" DROP CONSTRAINT IF EXISTS "POLICYCONDITION_VIOLATIONTYPE_check";
ALTER TABLE "POLICYCONDITION" ADD CONSTRAINT "POLICYCONDITION_VIOLATIONTYPE_check"
CHECK ("VIOLATIONTYPE"::TEXT = ANY(ARRAY['LICENSE', 'SECURITY', 'OPERATIONAL']));

ALTER TABLE "POLICY" DROP CONSTRAINT IF EXISTS "POLICY_VIOLATIONSTATE_check";
ALTER TABLE "POLICY" ADD CONSTRAINT "POLICY_VIOLATIONSTATE_check"
CHECK ("VIOLATIONSTATE"::TEXT = ANY(ARRAY['INFO', 'WARN', 'FAIL']));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,6 @@ public void informTestWithComponentAlreadyExistsForIntegrityCheck() throws Excep

final var bomUploadEvent = new BomUploadEvent(qm.detach(Project.class, project.getId()), createTempBomFile("bom-1.xml"));
qm.createWorkflowSteps(bomUploadEvent.getChainIdentifier());
PackageURL packageUrl = new PackageURL("pkg:maven/com.example/[email protected]?download_url=https%3A%2F%2Fon-premises.url%2Frepository%2Fnpm%2F%40babel%2Fhelper-split-export-declaration%2Fhelper-split-export-declaration%2Fhelper-split-export-declaration%2Fhelper-split-export-declaration%2Fhelper-split-export-declaration-7.18.6.tgz");
var integrityMeta = new IntegrityMetaComponent();
integrityMeta.setPurl("pkg:maven/com.example/[email protected]?download_url=https%3A%2F%2Fon-premises.url%2Frepository%2Fnpm%2F%40babel%2Fhelper-split-export-declaration%2Fhelper-split-export-declaration%2Fhelper-split-export-declaration%2Fhelper-split-export-declaration%2Fhelper-split-export-declaration-7.18.6.tgz");
integrityMeta.setStatus(FetchStatus.IN_PROGRESS);
Expand Down

0 comments on commit 621ba00

Please sign in to comment.