Skip to content

Commit

Permalink
Revert "#23 Use native types as model's field types"
Browse files Browse the repository at this point in the history
This reverts commit 49ca35d.

DefectDojo does not expect id properties in POST request, but instead
of ignoring them it is required toset them to null.

This is only possible with boxed types.

Signed-off-by: Sven Strittmatter <[email protected]>
  • Loading branch information
Weltraumschaf committed Sep 2, 2024
1 parent c92b4a5 commit 1fa25c2
Show file tree
Hide file tree
Showing 30 changed files with 433 additions and 375 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,17 @@
@EqualsAndHashCode
@JsonInclude(JsonInclude.Include.NON_NULL)
public final class Endpoint implements Model, HasId {
/**
* Uniq id of model type
* <p>
* May be {@code null} for newly created objects because in DefectDojo's Open API specification i.
* It is mandatory to use a boxed object type instead of a native type. A native type would result in 0 by
* default which is a valid id for DefectDojo. Thus creating this type via POST request would try to create
* one with id 0. Instead the id must be {@code null}, so that DefectDojo uses a newly generated uniq id.
* </p>
*/
@JsonProperty
private long id;
private Long id;

@JsonProperty
private String protocol;
Expand All @@ -30,7 +39,7 @@ public final class Endpoint implements Model, HasId {
private String fullyQualifiedDomainName;

@JsonProperty
private long port;
private Long port;// FIXME: Use native type here.

@JsonProperty
private String path;
Expand All @@ -42,10 +51,10 @@ public final class Endpoint implements Model, HasId {
private String fragment;

@JsonProperty
private long product;
private Long product;// FIXME: Use native type here.

@JsonProperty
private boolean mitigated;
private Boolean mitigated;// FIXME: Use native type here.

@Override
public boolean equalsQueryString(Map<String, Object> queryParams) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,27 @@
@EqualsAndHashCode
@JsonInclude(JsonInclude.Include.NON_NULL)
public final class Engagement implements Model, HasId, HasName {
@JsonProperty("branch_tag")
@Builder.Default
private String branch = "";

/**
* Uniq id of model type
* <p>
* May be {@code null} for newly created objects because in DefectDojo's Open API specification i.
* It is mandatory to use a boxed object type instead of a native type. A native type would result in 0 by
* default which is a valid id for DefectDojo. Thus creating this type via POST request would try to create
* one with id 0. Instead the id must be {@code null}, so that DefectDojo uses a newly generated uniq id.
* </p>
*/
@JsonProperty
private long id;
private Long id;

@JsonProperty
private String name;

@JsonProperty("branch_tag")
@Builder.Default
private String branch = "";

@JsonProperty
private long product;
private Long product;// FIXME: Use native type here.

@JsonProperty("target_start")
private String targetStart;
Expand All @@ -39,7 +48,7 @@ public final class Engagement implements Model, HasId, HasName {
private String targetEnd;

@JsonProperty
private long lead;
private Long lead;// FIXME: Use native type here.

@JsonProperty("engagement_type")
@Builder.Default
Expand All @@ -66,13 +75,13 @@ public final class Engagement implements Model, HasId, HasName {
private String repo;

@JsonProperty("build_server")
private long buildServer;
private Long buildServer; // FIXME: Use native type here.

@JsonProperty("source_code_management_server")
private long scmServer;
private Long scmServer; // FIXME: Use natvive type here.

@JsonProperty("orchestration_engine")
private long orchestrationEngine;
private Long orchestrationEngine; // FIXME: Use natvive type here.

@JsonProperty
@Builder.Default
Expand All @@ -82,16 +91,20 @@ public final class Engagement implements Model, HasId, HasName {
private boolean deduplicationOnEngagement;

@JsonProperty("threat_model")
private boolean threatModel;
@Builder.Default // FIXME: Use native type here.
private Boolean threatModel = false;

@JsonProperty("api_test")
private boolean apiTest;
@Builder.Default // FIXME: Use native type here.
private Boolean apiTest = false;

@JsonProperty("pen_test")
private boolean penTest;
@Builder.Default // FIXME: Use native type here.
private Boolean penTest = false;

@JsonProperty("check_list")
private boolean checkList;
@Builder.Default // FIXME: Use native type here.
private Boolean checkList = false;

@JsonProperty
@Builder.Default
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,17 @@
@EqualsAndHashCode
@JsonInclude(JsonInclude.Include.NON_NULL)
public final class Finding implements Model, HasId {
/**
* Uniq id of model type
* <p>
* May be {@code null} for newly created objects because in DefectDojo's Open API specification i.
* It is mandatory to use a boxed object type instead of a native type. A native type would result in 0 by
* default which is a valid id for DefectDojo. Thus creating this type via POST request would try to create
* one with id 0. Instead the id must be {@code null}, so that DefectDojo uses a newly generated uniq id.
* </p>
*/
@JsonProperty
private long id;
private Long id;

@JsonProperty
@NonNull
Expand All @@ -44,7 +53,7 @@ public final class Finding implements Model, HasId {

@JsonProperty
@NonNull
private long test;
private Long test;// FIXME: Use native type here.

@JsonProperty
private String mitigation;
Expand All @@ -54,30 +63,37 @@ public final class Finding implements Model, HasId {

@JsonProperty
@NonNull
private boolean active;
@Builder.Default
private Boolean active = true;// FIXME: Use native type here.

@JsonProperty
@NonNull
private boolean verified;
@Builder.Default
private Boolean verified = true;// FIXME: Use native type here.

@JsonProperty("risk_accepted")
@NonNull
private boolean riskAccepted;
@Builder.Default
private Boolean riskAccepted = false;// FIXME: Use native type here.

@JsonProperty("out_of_scope")
@NonNull
private boolean outOfScope;
@Builder.Default
private Boolean outOfScope = false;// FIXME: Use native type here.

@JsonProperty
@NonNull
private boolean duplicate;
@Builder.Default
private Boolean duplicate = false;// FIXME: Use native type here.

@JsonProperty("duplicate_finding")
private long duplicateFinding;
@Builder.Default
private Long duplicateFinding = null;// FIXME: Use native type here.

@JsonProperty("false_p")
@NonNull
private boolean falsePositive;
@Builder.Default
private Boolean falsePositive = false;// FIXME: Use native type here.

@JsonProperty("component_name")
private String componentName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,17 @@
@EqualsAndHashCode
@JsonInclude(JsonInclude.Include.NON_NULL)
public final class Group implements Model, HasId, HasName {
/**
* Uniq id of model type
* <p>
* May be {@code null} for newly created objects because in DefectDojo's Open API specification i.
* It is mandatory to use a boxed object type instead of a native type. A native type would result in 0 by
* default which is a valid id for DefectDojo. Thus creating this type via POST request would try to create
* one with id 0. Instead the id must be {@code null}, so that DefectDojo uses a newly generated uniq id.
* </p>
*/
@JsonProperty
private long id;
private Long id;

@JsonProperty
@NonNull
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,26 @@
@EqualsAndHashCode
@JsonInclude(JsonInclude.Include.NON_NULL)
public final class GroupMember implements Model {
/**
* Uniq id of model type
* <p>
* May be {@code null} for newly created objects because in DefectDojo's Open API specification i.
* It is mandatory to use a boxed object type instead of a native type. A native type would result in 0 by
* default which is a valid id for DefectDojo. Thus creating this type via POST request would try to create
* one with id 0. Instead the id must be {@code null}, so that DefectDojo uses a newly generated uniq id.
* </p>
*/
@JsonProperty
private long id;
private Long id;

@JsonProperty
private long group;
private Long group;// FIXME: Use native type here.

@JsonProperty
private long user;
private Long user;// FIXME: Use native type here.

@JsonProperty
private long role;
private Long role;// FIXME: Use native type here.

@Override
public boolean equalsQueryString(Map<String, Object> queryParams) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* </p>
*/
interface HasId {
long getId();
Long getId();

void setId(long id);
void setId(Long id);
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,17 @@
@EqualsAndHashCode
@JsonInclude(JsonInclude.Include.NON_NULL)
public final class Product implements Model, HasId, HasName {
/**
* Uniq id of model type
* <p>
* May be {@code null} for newly created objects because in DefectDojo's Open API specification i.
* It is mandatory to use a boxed object type instead of a native type. A native type would result in 0 by
* default which is a valid id for DefectDojo. Thus creating this type via POST request would try to create
* one with id 0. Instead the id must be {@code null}, so that DefectDojo uses a newly generated uniq id.
* </p>
*/
@JsonProperty
private long id;
private Long id;

@JsonProperty
private String name;
Expand All @@ -32,19 +41,19 @@ public final class Product implements Model, HasId, HasName {
private String description;

@JsonProperty("findings_count")
private long findingsCount;
private Long findingsCount;// FIXME: Use native type here.

@JsonProperty("authorized_users")
private List<String> authorizedUsers;

@JsonProperty("prod_type")
private long productType;

private Long productType;// FIXME: Use native type here.
@JsonProperty("enable_simple_risk_acceptance")
private boolean enableSimpleRiskAcceptance;

private Boolean enableSimpleRiskAcceptance;// FIXME: Use native type here.
@JsonProperty("enable_full_risk_acceptance")
private boolean enableFullRiskAcceptance;
private Boolean enableFullRiskAcceptance;// FIXME: Use native type here.

@JsonProperty("authorization_groups")
@Builder.Default
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,26 @@
@EqualsAndHashCode
@JsonInclude(JsonInclude.Include.NON_NULL)
public final class ProductGroup implements Model {
/**
* Uniq id of model type
* <p>
* May be {@code null} for newly created objects because in DefectDojo's Open API specification i.
* It is mandatory to use a boxed object type instead of a native type. A native type would result in 0 by
* default which is a valid id for DefectDojo. Thus creating this type via POST request would try to create
* one with id 0. Instead the id must be {@code null}, so that DefectDojo uses a newly generated uniq id.
* </p>
*/
@JsonProperty
private long id;
private Long id;

@JsonProperty
private long product;
private Long product;// FIXME: Use native type here.

@JsonProperty
private long group;
private Long group;// FIXME: Use native type here.

@JsonProperty
private long role;
private Long role;// FIXME: Use native type here.

@Override
public boolean equalsQueryString(Map<String, Object> queryParams) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,17 @@
@JsonInclude(JsonInclude.Include.NON_NULL)
public final class ProductType implements Model, HasId, HasName {
@JsonProperty
private long id;
private Long id;// FIXME: Use native type here.

@JsonProperty
@NonNull
private String name;

@JsonProperty("critical_product")
private boolean criticalProduct;
private Boolean criticalProduct;// FIXME: Use native type here.

@JsonProperty("key_product")
private boolean keyProduct;
private Boolean keyProduct;// FIXME: Use native type here.

@Override
public boolean equalsQueryString(Map<String, Object> queryParams) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,17 @@
@EqualsAndHashCode
@JsonInclude(JsonInclude.Include.NON_NULL)
public final class RiskAcceptance implements Model, HasId {
/**
* Uniq id of model type
* <p>
* May be {@code null} for newly created objects because in DefectDojo's Open API specification i.
* It is mandatory to use a boxed object type instead of a native type. A native type would result in 0 by
* default which is a valid id for DefectDojo. Thus creating this type via POST request would try to create
* one with id 0. Instead the id must be {@code null}, so that DefectDojo uses a newly generated uniq id.
* </p>
*/
@JsonProperty
private long id;
private Long id;

@JsonProperty
private String recommendation;
Expand Down Expand Up @@ -54,7 +63,7 @@ public final class RiskAcceptance implements Model, HasId {
private OffsetDateTime updatedAt;

@JsonProperty
private long owner;
private Long owner;// FIXME: Use native type here.

@Override
public boolean equalsQueryString(Map<String, Object> queryParams) {
Expand Down
Loading

0 comments on commit 1fa25c2

Please sign in to comment.