Skip to content

Commit

Permalink
reading category and subCategory from info
Browse files Browse the repository at this point in the history
  • Loading branch information
ag060 committed Jan 20, 2025
1 parent 58de2db commit c14bc11
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,8 @@ private void generateAndPushMaliciousEventRequest(
.setLatestApiPayload(maliciousReq.getPayload())
.setLatestApiMethod(maliciousReq.getMethod())
.setDetectedAt(responseParam.getTime())
.setCategory(apiFilter.getInfo().getCategory().getName())
.setSubCategory(apiFilter.getInfo().getSubCategory())
.build();
MaliciousEventKafkaEnvelope envelope =
MaliciousEventKafkaEnvelope.newBuilder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@

import com.akto.dao.api_protection_parse_layer.AggregationLayerParser;
import com.akto.dao.test_editor.filter.ConfigParser;
import com.akto.dao.test_editor.info.InfoParser;
import com.akto.dto.api_protection_parse_layer.AggregationRules;
import com.akto.dto.monitoring.FilterConfig;
import com.akto.dto.test_editor.ConfigParserResult;
import com.akto.dto.test_editor.ExecutorConfigParserResult;
import com.akto.dto.test_editor.Info;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
Expand Down Expand Up @@ -84,6 +86,14 @@ public static FilterConfig parseConfig(Map<String, Object> config,boolean should
filterConfig.setAggregationRules(aggRules);
}

InfoParser infoParser = new InfoParser();
if (config.containsKey("info")) {
Info info = infoParser.parse(config.get("info"));
if (filterConfig != null) {
filterConfig.setInfo(info);
}
}

return filterConfig;
}

Expand Down
13 changes: 11 additions & 2 deletions libs/dao/src/main/java/com/akto/dto/monitoring/FilterConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import com.akto.dto.api_protection_parse_layer.AggregationRules;
import com.akto.dto.test_editor.ConfigParserResult;
import com.akto.dto.test_editor.ExecutorConfigParserResult;
import com.akto.dto.test_editor.Info;

public class FilterConfig {
private String id;
Expand All @@ -24,7 +25,7 @@ public class FilterConfig {
public static final String _CONTENT = "content";
private String content;
private AggregationRules aggregationRules;

private Info info;
public static final String DEFAULT_ALLOW_FILTER = "DEFAULT_ALLOW_FILTER";
public static final String DEFAULT_BLOCK_FILTER = "DEFAULT_BLOCK_FILTER";

Expand Down Expand Up @@ -125,4 +126,12 @@ public AggregationRules getAggregationRules() {
public void setAggregationRules(AggregationRules aggregationRules) {
this.aggregationRules = aggregationRules;
}
}

public Info getInfo() {
return info;
}

public void setInfo(Info info) {
this.info = info;
}
}

0 comments on commit c14bc11

Please sign in to comment.