Skip to content

Commit f2a78b5

Browse files
committed
Manual cherry-pick of opensearch-project#873
Signed-off-by: Chase Engelbrecht <[email protected]>
1 parent 82f97a5 commit f2a78b5

File tree

3 files changed

+372
-150
lines changed

3 files changed

+372
-150
lines changed

src/main/java/org/opensearch/securityanalytics/mapper/MapperService.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,11 @@ public void createMappingAction(String indexName, String ruleTopic, String alias
7171
// since you can't update documents in non-write indices
7272
String index = indexName;
7373
boolean shouldUpsertIndexTemplate = IndexUtils.isConcreteIndex(indexName, this.clusterService.state()) == false;
74-
if (IndexUtils.isDataStream(indexName, this.clusterService.state())) {
74+
if (IndexUtils.isDataStream(indexName, this.clusterService.state()) || IndexUtils.isAlias(indexName, this.clusterService.state())) {
75+
log.debug("{} is an alias or datastream. Fetching write index for create mapping action.", indexName);
7576
String writeIndex = IndexUtils.getWriteIndex(indexName, this.clusterService.state());
7677
if (writeIndex != null) {
78+
log.debug("Write index for {} is {}", indexName, writeIndex);
7779
index = writeIndex;
7880
}
7981
}
@@ -85,6 +87,7 @@ public void onResponse(GetMappingsResponse getMappingsResponse) {
8587
applyAliasMappings(getMappingsResponse.getMappings(), ruleTopic, aliasMappings, partial, new ActionListener<>() {
8688
@Override
8789
public void onResponse(Collection<CreateMappingResult> createMappingResponse) {
90+
log.debug("Completed create mappings for {}", indexName);
8891
// We will return ack==false if one of the requests returned that
8992
// else return ack==true
9093
Optional<AcknowledgedResponse> notAckd = createMappingResponse.stream()
@@ -103,6 +106,7 @@ public void onResponse(Collection<CreateMappingResult> createMappingResponse) {
103106

104107
@Override
105108
public void onFailure(Exception e) {
109+
log.debug("Failed to create mappings for {}", indexName );
106110
actionListener.onFailure(e);
107111
}
108112
});

src/main/java/org/opensearch/securityanalytics/rules/backend/OSQueryBackend.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,8 @@ public Object convertConditionFieldEqValQueryExpr(ConditionFieldEqualsValueExpre
331331

332332
@Override
333333
public Object convertConditionValStr(ConditionValueExpression condition) throws SigmaValueError {
334+
String field = getFinalValueField();
335+
ruleQueryFields.put(field, Map.of("type", "text", "analyzer", "rule_analyzer"));
334336
SigmaString value = (SigmaString) condition.getValue();
335337
boolean containsWildcard = value.containsWildcard();
336338
return String.format(Locale.getDefault(), (containsWildcard? this.unboundWildcardExpression: this.unboundValueStrExpression), this.convertValueStr((SigmaString) condition.getValue()));

0 commit comments

Comments
 (0)