Skip to content

Commit 711b22b

Browse files
authored
Merge pull request #15 from wurstbrot/feat/newModels
WIP: add RiskAcceptance and DojoGroup
2 parents 472aef1 + 86d6632 commit 711b22b

File tree

7 files changed

+253
-0
lines changed

7 files changed

+253
-0
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package io.securecodebox.persistence.defectdojo.models;
2+
3+
import com.fasterxml.jackson.annotation.JsonInclude;
4+
import com.fasterxml.jackson.annotation.JsonProperty;
5+
import lombok.*;
6+
7+
import java.util.List;
8+
import java.util.Map;
9+
10+
@Data
11+
@Builder
12+
@NoArgsConstructor
13+
@AllArgsConstructor
14+
@EqualsAndHashCode(callSuper = true)
15+
@JsonInclude(JsonInclude.Include.NON_NULL)
16+
public class DojoGroup extends DefectDojoModel {
17+
@JsonProperty
18+
Long id;
19+
20+
@JsonProperty
21+
@NonNull
22+
String name;
23+
24+
@JsonProperty
25+
String description;
26+
27+
@JsonProperty
28+
List<Long> users;
29+
30+
@Override
31+
public boolean equalsQueryString(Map<String, Object> queryParams) {
32+
if (queryParams.containsKey("id") && queryParams.get("id").equals(this.id)) {
33+
return true;
34+
}
35+
return false;
36+
}
37+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package io.securecodebox.persistence.defectdojo.models;
2+
3+
import com.fasterxml.jackson.annotation.JsonInclude;
4+
import com.fasterxml.jackson.annotation.JsonProperty;
5+
import lombok.*;
6+
7+
import java.util.Map;
8+
9+
@Data
10+
@Builder
11+
@NoArgsConstructor
12+
@AllArgsConstructor
13+
@EqualsAndHashCode(callSuper = true)
14+
@JsonInclude(JsonInclude.Include.NON_NULL)
15+
public class DojoGroupMember extends DefectDojoModel {
16+
@JsonProperty
17+
Long id;
18+
19+
@JsonProperty("group_id")
20+
Long group;
21+
22+
@JsonProperty("user_id")
23+
Long user;
24+
25+
@JsonProperty
26+
Long role;
27+
28+
@Override
29+
public boolean equalsQueryString(Map<String, Object> queryParams) {
30+
if (queryParams.containsKey("id") && queryParams.get("id").equals(this.id)) {
31+
return true;
32+
}
33+
return false;
34+
}
35+
}

src/main/java/io/securecodebox/persistence/defectdojo/models/Finding.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,9 @@ public class Finding extends DefectDojoModel {
109109
@JsonProperty("mitigated")
110110
LocalDateTime mitigatedAt;
111111

112+
@JsonProperty("accepted_risks")
113+
List<RiskAcceptance> acceptedRisks;
114+
112115
@JsonProperty("numerical_severity")
113116
public String getNumericalSeverity() {
114117
switch (this.severity) {

src/main/java/io/securecodebox/persistence/defectdojo/models/Product.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ public class Product extends DefectDojoModel {
5858
@JsonProperty("enable_full_risk_acceptance")
5959
Boolean enableFullRiskAcceptance;
6060

61+
@JsonProperty("authorization_groups")
62+
List<Long> authorizationGroups;
63+
6164
@Override
6265
public boolean equalsQueryString(Map<String, Object> queryParams) {
6366
if (queryParams.containsKey("id") && queryParams.get("id").equals(this.id)) {
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
/*
2+
* secureCodeBox (SCB)
3+
* Copyright 2021 iteratec GmbH
4+
* https://www.iteratec.com
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
package io.securecodebox.persistence.defectdojo.models;
19+
20+
import com.fasterxml.jackson.annotation.JsonInclude;
21+
import com.fasterxml.jackson.annotation.JsonProperty;
22+
import lombok.*;
23+
24+
import java.time.LocalDateTime;
25+
import java.util.Map;
26+
27+
@Data
28+
@Builder
29+
@NoArgsConstructor
30+
@AllArgsConstructor
31+
@EqualsAndHashCode(callSuper = true)
32+
@JsonInclude(JsonInclude.Include.NON_NULL)
33+
public class RiskAcceptance extends DefectDojoModel {
34+
@JsonProperty
35+
Long id;
36+
37+
@JsonProperty
38+
String recommendation;
39+
40+
@JsonProperty("recommendation_details")
41+
String recommendationDetails;
42+
43+
String decision;
44+
45+
@JsonProperty("decision_details")
46+
String decision_details;
47+
48+
@JsonProperty
49+
String path;
50+
51+
@JsonProperty
52+
String accepted_by;
53+
54+
@JsonProperty
55+
String expiration_date;
56+
57+
@JsonProperty
58+
Long expiration_date_warned;
59+
60+
@JsonProperty
61+
Boolean expiration_date_handled;
62+
63+
@JsonProperty("created")
64+
LocalDateTime createdAt;
65+
66+
@JsonProperty("updated")
67+
LocalDateTime updatedAt;
68+
69+
@JsonProperty
70+
Long owner;
71+
72+
@JsonProperty
73+
String notes;
74+
75+
@Override
76+
public boolean equalsQueryString(Map<String, Object> queryParams) {
77+
if (queryParams.containsKey("id") && queryParams.get("id").equals(this.id)) {
78+
return true;
79+
}
80+
return false;
81+
}
82+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/*
2+
* secureCodeBox (SCB)
3+
* Copyright 2021 iteratec GmbH
4+
* https://www.iteratec.com
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
package io.securecodebox.persistence.defectdojo.service;
19+
20+
import com.fasterxml.jackson.core.JsonProcessingException;
21+
import com.fasterxml.jackson.core.type.TypeReference;
22+
import io.securecodebox.persistence.defectdojo.config.DefectDojoConfig;
23+
import io.securecodebox.persistence.defectdojo.models.DefectDojoResponse;
24+
import io.securecodebox.persistence.defectdojo.models.DojoGroupMember;
25+
26+
public class DojoGroupMemberService extends GenericDefectDojoService<DojoGroupMember> {
27+
public DojoGroupMemberService(DefectDojoConfig config) {
28+
super(config);
29+
}
30+
31+
@Override
32+
protected String getUrlPath() {
33+
return "dojo_group_members";
34+
}
35+
36+
@Override
37+
protected Class<DojoGroupMember> getModelClass() {
38+
return DojoGroupMember.class;
39+
}
40+
41+
@Override
42+
protected DefectDojoResponse<DojoGroupMember> deserializeList(String response) throws JsonProcessingException {
43+
return this.objectMapper.readValue(response, new TypeReference<>() {
44+
});
45+
}
46+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/*
2+
* secureCodeBox (SCB)
3+
* Copyright 2021 iteratec GmbH
4+
* https://www.iteratec.com
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
package io.securecodebox.persistence.defectdojo.service;
19+
20+
import com.fasterxml.jackson.core.JsonProcessingException;
21+
import com.fasterxml.jackson.core.type.TypeReference;
22+
import io.securecodebox.persistence.defectdojo.config.DefectDojoConfig;
23+
import io.securecodebox.persistence.defectdojo.models.DefectDojoResponse;
24+
import io.securecodebox.persistence.defectdojo.models.DojoGroup;
25+
import io.securecodebox.persistence.defectdojo.models.Test;
26+
27+
public class DojoGroupService extends GenericDefectDojoService<DojoGroup> {
28+
public DojoGroupService(DefectDojoConfig config) {
29+
super(config);
30+
}
31+
32+
@Override
33+
protected String getUrlPath() {
34+
return "dojo_groups";
35+
}
36+
37+
@Override
38+
protected Class<DojoGroup> getModelClass() {
39+
return DojoGroup.class;
40+
}
41+
42+
@Override
43+
protected DefectDojoResponse<DojoGroup> deserializeList(String response) throws JsonProcessingException {
44+
return this.objectMapper.readValue(response, new TypeReference<>() {
45+
});
46+
}
47+
}

0 commit comments

Comments
 (0)