Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
129 changes: 116 additions & 13 deletions src/main/java/org/dependencytrack/model/DependencyMetrics.java
Original file line number Diff line number Diff line change
Expand Up @@ -104,19 +104,59 @@ public class DependencyMetrics implements Serializable {
private double inheritedRiskScore;

@Persistent
@Column(name = "POLICYVIOLATIONS_FAIL", allowsNull = "true") // New column, must allow nulls on existing data bases)
@Column(name = "POLICYVIOLATIONS_FAIL", allowsNull = "true") // New column, must allow nulls on existing databases)
@Deprecated
private Integer policyViolationsFail;

@Persistent
@Column(name = "POLICYVIOLATIONS_WARN", allowsNull = "true") // New column, must allow nulls on existing data bases)
@Column(name = "POLICYVIOLATIONS_FAIL_TOTAL", allowsNull = "true") // New column, must allow nulls on existing databases)
private Integer policyViolationsFailTotal;
Comment on lines 111 to +113
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a breaking change in both the database schema (or rather the data is holds), as well as the REST API. I know it's not pretty, but we should keep using the policyViolationsFail field and column.

We can add a new policyViolationsFailTotal getter that just returns policyViolationsFail - that would make the new field available via REST API without breaking semantics of the old field, and it would not require a migration of existing data.

Alternatively, we need to migrate all data from POLICYVIOLATIONS_FAIL to POLICYVIOLATIONS_FAIL_TOTAL, drop the POLICYVIOLATIONS_FAIL column, and must ensure that policyViolationsFail and policyViolationsFailTotal return the same value in the REST API.


@Persistent
@Column(name = "POLICYVIOLATIONS_FAIL_AUDITED", allowsNull = "true") // New column, must allow nulls on existing databases)
private Integer policyViolationsFailAudited;

@Persistent
@Column(name = "POLICYVIOLATIONS_FAIL_UNAUDITED", allowsNull = "true") // New column, must allow nulls on existing databases)
private Integer policyViolationsFailUnaudited;

@Persistent
@Column(name = "POLICYVIOLATIONS_WARN", allowsNull = "true") // New column, must allow nulls on existing databases)
@Deprecated
private Integer policyViolationsWarn;

@Persistent
@Column(name = "POLICYVIOLATIONS_INFO", allowsNull = "true") // New column, must allow nulls on existing data bases)
@Column(name = "POLICYVIOLATIONS_WARN_TOTAL", allowsNull = "true") // New column, must allow nulls on existing databases)
private Integer policyViolationsWarnTotal;

@Persistent
@Column(name = "POLICYVIOLATIONS_WARN_AUDITED", allowsNull = "true") // New column, must allow nulls on existing databases)
private Integer policyViolationsWarnAudited;

@Persistent
@Column(name = "POLICYVIOLATIONS_WARN_UNAUDITED", allowsNull = "true") // New column, must allow nulls on existing databases)
private Integer policyViolationsWarnUnaudited;

@Persistent
@Column(name = "POLICYVIOLATIONS_INFO", allowsNull = "true") // New column, must allow nulls on existing databases)
@Deprecated
private Integer policyViolationsInfo;

@Persistent
@Column(name = "POLICYVIOLATIONS_TOTAL", allowsNull = "true") // New column, must allow nulls on existing data bases)
@Column(name = "POLICYVIOLATIONS_INFO_TOTAL", allowsNull = "true") // New column, must allow nulls on existing databases)
private Integer policyViolationsInfoTotal;

@Persistent
@Column(name = "POLICYVIOLATIONS_INFO_AUDITED", allowsNull = "true") // New column, must allow nulls on existing databases)
private Integer policyViolationsInfoAudited;

@Persistent
@Column(name = "POLICYVIOLATIONS_INFO_UNAUDITED", allowsNull = "true") // New column, must allow nulls on existing databases)
private Integer policyViolationsInfoUnaudited;


@Persistent
@Column(name = "POLICYVIOLATIONS_TOTAL", allowsNull = "true") // New column, must allow nulls on existing databases)
private Integer policyViolationsTotal;

@Persistent
Expand Down Expand Up @@ -287,28 +327,91 @@ public void setInheritedRiskScore(double inheritedRiskScore) {
this.inheritedRiskScore = inheritedRiskScore;
}

@Deprecated
public int getPolicyViolationsFail() {
return policyViolationsFail;
return policyViolationsFailUnaudited;
}

public int getPolicyViolationsFailTotal() {
return policyViolationsFailTotal;
}

public void setPolicyViolationsFailTotal(int policyViolationsFailTotal) {
this.policyViolationsFailTotal = policyViolationsFailTotal;
}

public int getPolicyViolationsFailAudited() {
return policyViolationsFailAudited;
}

public void setPolicyViolationsFail(int policyViolationsFail) {
this.policyViolationsFail = policyViolationsFail;
public void setPolicyViolationsFailAudited(int policyViolationsFailAudited) {
this.policyViolationsFailAudited = policyViolationsFailAudited;
}

public int getPolicyViolationsFailUnaudited() {
return policyViolationsFailUnaudited;
}

public void setPolicyViolationsFailUnaudited(int policyViolationsFailUnaudited) {
this.policyViolationsFailUnaudited = policyViolationsFailUnaudited;
}

@Deprecated
public int getPolicyViolationsWarn() {
return policyViolationsWarn;
return policyViolationsWarnUnaudited;
}

public int getPolicyViolationsWarnTotal() {
return policyViolationsWarnTotal;
}

public void setPolicyViolationsWarnTotal(int policyViolationsWarnTotal) {
this.policyViolationsWarnTotal = policyViolationsWarnTotal;
}

public int getPolicyViolationsWarnAudited() {
return policyViolationsWarnAudited;
}

public void setPolicyViolationsWarnAudited(int policyViolationsWarnAudited) {
this.policyViolationsWarnAudited = policyViolationsWarnAudited;
}

public void setPolicyViolationsWarn(int policyViolationsWarn) {
this.policyViolationsWarn = policyViolationsWarn;
public int getPolicyViolationsWarnUnaudited() {
return policyViolationsWarnUnaudited;
}

public void setPolicyViolationsWarnUnaudited(int policyViolationsWarnUnaudited) {
this.policyViolationsWarnUnaudited = policyViolationsWarnUnaudited;
}

@Deprecated
public int getPolicyViolationsInfo() {
return policyViolationsInfo;
return policyViolationsInfoUnaudited;
}

public int getPolicyViolationsInfoTotal() {
return policyViolationsInfoTotal;
}

public void setPolicyViolationsInfoTotal(int policyViolationsInfoTotal) {
this.policyViolationsInfoTotal = policyViolationsInfoTotal;
}

public int getPolicyViolationsInfoAudited() {
return policyViolationsInfoAudited;
}

public void setPolicyViolationsInfoAudited(int policyViolationsInfoAudited) {
this.policyViolationsInfoAudited = policyViolationsInfoAudited;
}

public int getPolicyViolationsInfoUnaudited() {
return policyViolationsInfoUnaudited;
}

public void setPolicyViolationsInfo(int policyViolationsInfo) {
this.policyViolationsInfo = policyViolationsInfo;
public void setPolicyViolationsInfoUnaudited(int policyViolationsInfoUnaudited) {
this.policyViolationsInfoUnaudited = policyViolationsInfoUnaudited;
}

public int getPolicyViolationsTotal() {
Expand Down
126 changes: 114 additions & 12 deletions src/main/java/org/dependencytrack/model/PortfolioMetrics.java
Original file line number Diff line number Diff line change
Expand Up @@ -116,17 +116,56 @@ public class PortfolioMetrics implements Serializable {
private double inheritedRiskScore;

@Persistent
@Column(name = "POLICYVIOLATIONS_FAIL", allowsNull = "true") // New column, must allow nulls on existing data bases)
@Column(name = "POLICYVIOLATIONS_FAIL", allowsNull = "true") // New column, must allow nulls on existing databases)
@Deprecated
private Integer policyViolationsFail;

@Persistent
@Column(name = "POLICYVIOLATIONS_WARN", allowsNull = "true") // New column, must allow nulls on existing data bases)
@Column(name = "POLICYVIOLATIONS_FAIL_TOTAL", allowsNull = "true") // New column, must allow nulls on existing databases)
private Integer policyViolationsFailTotal;

@Persistent
@Column(name = "POLICYVIOLATIONS_FAIL_AUDITED", allowsNull = "true") // New column, must allow nulls on existing databases)
private Integer policyViolationsFailAudited;

@Persistent
@Column(name = "POLICYVIOLATIONS_FAIL_UNAUDITED", allowsNull = "true") // New column, must allow nulls on existing databases)
private Integer policyViolationsFailUnaudited;

@Persistent
@Column(name = "POLICYVIOLATIONS_WARN", allowsNull = "true") // New column, must allow nulls on existing databases)
@Deprecated
private Integer policyViolationsWarn;

@Persistent
@Column(name = "POLICYVIOLATIONS_INFO", allowsNull = "true") // New column, must allow nulls on existing data bases)
@Column(name = "POLICYVIOLATIONS_WARN_TOTAL", allowsNull = "true") // New column, must allow nulls on existing databases)
private Integer policyViolationsWarnTotal;

@Persistent
@Column(name = "POLICYVIOLATIONS_WARN_AUDITED", allowsNull = "true") // New column, must allow nulls on existing databases)
private Integer policyViolationsWarnAudited;

@Persistent
@Column(name = "POLICYVIOLATIONS_WARN_UNAUDITED", allowsNull = "true") // New column, must allow nulls on existing databases)
private Integer policyViolationsWarnUnaudited;

@Persistent
@Column(name = "POLICYVIOLATIONS_INFO", allowsNull = "true") // New column, must allow nulls on existing databases)
@Deprecated
private Integer policyViolationsInfo;

@Persistent
@Column(name = "POLICYVIOLATIONS_INFO_TOTAL", allowsNull = "true") // New column, must allow nulls on existing databases)
private Integer policyViolationsInfoTotal;

@Persistent
@Column(name = "POLICYVIOLATIONS_INFO_AUDITED", allowsNull = "true") // New column, must allow nulls on existing databases)
private Integer policyViolationsInfoAudited;

@Persistent
@Column(name = "POLICYVIOLATIONS_INFO_UNAUDITED", allowsNull = "true") // New column, must allow nulls on existing databases)
private Integer policyViolationsInfoUnaudited;

@Persistent
@Column(name = "POLICYVIOLATIONS_TOTAL", allowsNull = "true") // New column, must allow nulls on existing data bases)
private Integer policyViolationsTotal;
Expand Down Expand Up @@ -317,28 +356,91 @@ public void setInheritedRiskScore(double inheritedRiskScore) {
this.inheritedRiskScore = inheritedRiskScore;
}

@Deprecated
public int getPolicyViolationsFail() {
return policyViolationsFail;
return policyViolationsFailUnaudited;
}

public int getPolicyViolationsFailTotal() {
return policyViolationsFailTotal;
}

public void setPolicyViolationsFailTotal(int policyViolationsFailTotal) {
this.policyViolationsFailTotal = policyViolationsFailTotal;
}

public int getPolicyViolationsFailAudited() {
return policyViolationsFailAudited;
}

public void setPolicyViolationsFail(int policyViolationsFail) {
this.policyViolationsFail = policyViolationsFail;
public void setPolicyViolationsFailAudited(int policyViolationsFailAudited) {
this.policyViolationsFailAudited = policyViolationsFailAudited;
}

public int getPolicyViolationsFailUnaudited() {
return policyViolationsFailUnaudited;
}

public void setPolicyViolationsFailUnaudited(int policyViolationsFailUnaudited) {
this.policyViolationsFailUnaudited = policyViolationsFailUnaudited;
}

@Deprecated
public int getPolicyViolationsWarn() {
return policyViolationsWarn;
return policyViolationsWarnUnaudited;
}

public int getPolicyViolationsWarnTotal() {
return policyViolationsWarnTotal;
}

public void setPolicyViolationsWarnTotal(int policyViolationsWarnTotal) {
this.policyViolationsWarnTotal = policyViolationsWarnTotal;
}

public int getPolicyViolationsWarnAudited() {
return policyViolationsWarnAudited;
}

public void setPolicyViolationsWarnAudited(int policyViolationsWarnAudited) {
this.policyViolationsWarnAudited = policyViolationsWarnAudited;
}

public void setPolicyViolationsWarn(int policyViolationsWarn) {
this.policyViolationsWarn = policyViolationsWarn;
public int getPolicyViolationsWarnUnaudited() {
return policyViolationsWarnUnaudited;
}

public void setPolicyViolationsWarnUnaudited(int policyViolationsWarnUnaudited) {
this.policyViolationsWarnUnaudited = policyViolationsWarnUnaudited;
}

@Deprecated
public int getPolicyViolationsInfo() {
return policyViolationsInfo;
return policyViolationsInfoUnaudited;
}

public int getPolicyViolationsInfoTotal() {
return policyViolationsInfoTotal;
}

public void setPolicyViolationsInfoTotal(int policyViolationsInfoTotal) {
this.policyViolationsInfoTotal = policyViolationsInfoTotal;
}

public int getPolicyViolationsInfoAudited() {
return policyViolationsInfoAudited;
}

public void setPolicyViolationsInfoAudited(int policyViolationsInfoAudited) {
this.policyViolationsInfoAudited = policyViolationsInfoAudited;
}

public int getPolicyViolationsInfoUnaudited() {
return policyViolationsInfoUnaudited;
}

public void setPolicyViolationsInfo(int policyViolationsInfo) {
this.policyViolationsInfo = policyViolationsInfo;
public void setPolicyViolationsInfoUnaudited(int policyViolationsInfoUnaudited) {
this.policyViolationsInfoUnaudited = policyViolationsInfoUnaudited;
}

public int getPolicyViolationsTotal() {
Expand Down
Loading