Skip to content

Commit c185f57

Browse files
authored
[kogito-apps#2279] Handle detected static code scan problems (apache#2280)
1 parent 0b8dc2d commit c185f57

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

data-audit/data-audit-common/src/main/java/org/kie/kogito/app/audit/api/DataAuditQuery.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,13 @@ public void setQuery(String query) {
5252

5353
@Override
5454
public String toString() {
55-
return "DataAuditQuery [identifier=" + identifier + ", graphQLDefinition=" + graphQLDefinition + ", query=" + query + "]";
55+
return "DataAuditQuery [identifier="
56+
+ identifier.replace('\n', '_').replace('\r', '_')
57+
+ ", graphQLDefinition="
58+
+ graphQLDefinition.replace('\n', '_').replace('\r', '_')
59+
+ ", query="
60+
+ query.replace('\n', '_').replace('\r', '_')
61+
+ "]";
5662
}
5763

5864
}

data-audit/kogito-addons-data-audit-springboot/src/main/java/org/kie/kogito/app/audit/springboot/GraphQLAuditDataRouteMapping.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,6 @@ public String blockingRegistryHandlerGet() {
9595

9696
@ExceptionHandler({ Throwable.class })
9797
public ResponseEntity<String> handleException(Throwable th) {
98-
return ResponseEntity.badRequest().body(th.getLocalizedMessage());
98+
return ResponseEntity.badRequest().body("An Exception occurred processing the request. Please see the logs for more details.");
9999
}
100100
}

trusty/trusty-service/trusty-service-common/src/main/java/org/kie/kogito/trusty/service/common/TrustyServiceImpl.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,9 @@ protected CounterfactualExplainabilityRequest makeCounterfactualRequest(String e
222222
//This is returned as null under Redis, so play safe
223223
Collection<DecisionInput> decisionInputs = Objects.nonNull(decision.getInputs()) ? decision.getInputs() : Collections.emptyList();
224224
if (!isStructureIdentical(decisionInputs, searchDomains)) {
225-
String error = buildCounterfactualErrorMessage(String.format("The structure of the Search Domains do not match the structure of the original Inputs for decision with ID %s.", executionId),
225+
// The replace calls are sanitization of the user input. The executionId has a way to reach here from the user.
226+
String error = buildCounterfactualErrorMessage(
227+
String.format("The structure of the Search Domains do not match the structure of the original Inputs for decision with ID %s.", executionId.replace('\n', '_').replace('\r', '_')),
226228
"Decision inputs:-", decisionInputs,
227229
"Search domains:-", searchDomains);
228230
LOG.error(error);
@@ -232,8 +234,11 @@ protected CounterfactualExplainabilityRequest makeCounterfactualRequest(String e
232234
//This is returned as null under Redis, so play safe
233235
Collection<DecisionOutcome> decisionOutcomes = Objects.nonNull(decision.getOutcomes()) ? decision.getOutcomes() : Collections.emptyList();
234236
if (!isStructureSubset(decisionOutcomes, goals)) {
237+
// The replace calls are sanitization of the user input. The executionId has a way to reach here from the user.
235238
String error =
236-
buildCounterfactualErrorMessage(String.format("The structure of the Goals is not comparable to the structure of the original Outcomes for decision with ID %s.", executionId),
239+
buildCounterfactualErrorMessage(
240+
String.format("The structure of the Goals is not comparable to the structure of the original Outcomes for decision with ID %s.",
241+
executionId.replace('\n', '_').replace('\r', '_')),
237242
"Decision outcomes:-", decisionOutcomes,
238243
"Goals:-", goals);
239244
LOG.error(error);

0 commit comments

Comments
 (0)