Skip to content

Commit

Permalink
query_field_names bugfix (#335) (#342)
Browse files Browse the repository at this point in the history
Signed-off-by: Petar Dzepina <[email protected]>
  • Loading branch information
opensearch-trigger-bot[bot] authored Feb 21, 2023
1 parent de48737 commit f7d042c
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ public void onResponse(GetMappingsResponse getMappingsResponse) {

if (appliedAliases.size() == 0) {
actionListener.onFailure(SecurityAnalyticsException.wrap(
new OpenSearchStatusException("No applied aliases not found", RestStatus.NOT_FOUND))
new OpenSearchStatusException("No applied aliases found", RestStatus.NOT_FOUND))
);
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,10 @@ public Map<String, Object> getQueryFields() {
return queryFields;
}

public void resetQueryFields() {
queryFields.clear();
}

public abstract Object convertConditionAsInExpression(Either<ConditionAND, ConditionOR> condition);

public abstract Object convertConditionAnd(ConditionAND condition);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@ private List<Rule> getQueries(QueryBackend backend, String category, List<String
List<Rule> queries = new ArrayList<>();
for (String ruleStr: rules) {
SigmaRule rule = SigmaRule.fromYaml(ruleStr, true);
backend.resetQueryFields();
List<Object> ruleQueries = backend.convertRule(rule);
Set<String> queryFieldNames = backend.getQueryFields().keySet();

Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/mappings/rules.json
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
}
}
},
"query_fields": {
"query_field_names": {
"type": "nested",
"properties": {
"value": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ public void testUpdateAndGetMapping_notFound_Success() throws IOException {
fail();
} catch (ResponseException e) {
assertEquals(HttpStatus.SC_NOT_FOUND, e.getResponse().getStatusLine().getStatusCode());
assertTrue(e.getMessage().contains("No applied aliases not found"));
assertTrue(e.getMessage().contains("No applied aliases found"));
}
}

Expand Down

0 comments on commit f7d042c

Please sign in to comment.