Skip to content

Commit 3348d88

Browse files
committed
fix: escape ':' character in FilterType JSON conditions to prevent query parsing issues
1 parent 717da6d commit 3348d88

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
# UTMStack 10.5.16 Release Notes
22
## Bugfix
3-
- False positive alerts displayed in Dashboard Overview
3+
- False positive alerts displayed in Dashboard Overview
4+
- Correct query parsing for filterType conditions with special characters

backend/src/main/java/com/park/utmstack/domain/UtmAlertTagRule.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
import com.fasterxml.jackson.annotation.JsonIgnore;
55
import com.fasterxml.jackson.core.JsonProcessingException;
66
import com.fasterxml.jackson.core.type.TypeReference;
7+
import com.fasterxml.jackson.databind.JsonNode;
78
import com.fasterxml.jackson.databind.ObjectMapper;
9+
import com.fasterxml.jackson.databind.node.ObjectNode;
810
import com.park.utmstack.domain.chart_builder.types.query.FilterType;
911
import com.park.utmstack.web.rest.vm.AlertTagRuleVM;
1012
import org.springframework.util.StringUtils;
@@ -147,8 +149,16 @@ public void setRuleAppliedTags(String ruleAppliedTags) {
147149
public List<FilterType> getConditions() throws JsonProcessingException {
148150
if (StringUtils.hasText(ruleConditions)) {
149151
ObjectMapper om = new ObjectMapper();
150-
conditions = om.readValue(ruleConditions, new TypeReference<>() {
152+
153+
JsonNode rootNode = om.readTree(ruleConditions);
154+
155+
rootNode.forEach(node -> {
156+
JsonNode valueNode = node.get("value");
157+
if (valueNode != null && valueNode.asText().contains(":")) {
158+
((ObjectNode) node).put("value", valueNode.asText().replace(":", "\\:"));
159+
}
151160
});
161+
conditions = om.convertValue(rootNode, new TypeReference<>() {});
152162
}
153163
return conditions;
154164
}

backend/src/main/java/com/park/utmstack/util/AlertUtil.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ public Long countAlertsByStatus(int status) {
3333

3434
List<FilterType> filters = new ArrayList<>();
3535
filters.add(new FilterType(Constants.alertStatus, OperatorType.IS, status));
36-
filters.add(new FilterType(Constants.alertTags, OperatorType.IS_NOT, Constants.FALSE_POSITIVE_TAG));
3736

3837
SearchRequest.Builder srb = new SearchRequest.Builder();
3938
srb.query(SearchUtil.toQuery(filters))

0 commit comments

Comments
 (0)