Skip to content

Commit c14c2a3

Browse files
committed
Update script to reomve unwanted fields
1 parent 9bf3ba2 commit c14c2a3

File tree

2 files changed

+4
-12
lines changed

2 files changed

+4
-12
lines changed

packages/ti_google_threat_intelligence/elasticsearch/ingest_pipeline/ti_google_threat_intelligence-correlation_detection_rule-pipeline.yml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,17 +37,13 @@ processors:
3737
// Define the list of fields to retain
3838
def fieldsToKeep = ["@timestamp"];
3939
40-
// Define regex patterns
41-
def gtiPattern = /^temp_fields/; // Matches keys starting with 'temp_fields'
42-
def underscorePattern = /^_/; // Matches keys starting with '_'
43-
4440
// Get a copy of the current document keys
4541
def keys = new ArrayList(ctx.keySet());
4642
4743
// Iterate over the keys
4844
for (def key : keys) {
49-
// If the key is not in fieldsToKeep, does not match any Pattern, remove it
50-
if (!fieldsToKeep.contains(key) && !(key =~ gtiPattern) && !(key =~ underscorePattern)) {
45+
// Keep if the key is in fieldsToKeep, starts with "temp_fields" or starts with "_"
46+
if (!fieldsToKeep.contains(key) && !key.startsWith("temp_fields") && !key.startsWith("_")) {
5147
ctx.remove(key);
5248
}
5349
}

packages/ti_google_threat_intelligence/elasticsearch/ingest_pipeline/ti_google_threat_intelligence-correlation_detection_rule_ioc_st-pipeline.yml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,17 +37,13 @@ processors:
3737
// Define the list of fields to retain
3838
def fieldsToKeep = ["@timestamp"];
3939
40-
// Define regex patterns
41-
def gtiPattern = /^temp_fields/; // Matches keys starting with 'temp_fields'
42-
def underscorePattern = /^_/; // Matches keys starting with '_'
43-
4440
// Get a copy of the current document keys
4541
def keys = new ArrayList(ctx.keySet());
4642
4743
// Iterate over the keys
4844
for (def key : keys) {
49-
// If the key is not in fieldsToKeep, does not match any Pattern, remove it
50-
if (!fieldsToKeep.contains(key) && !(key =~ gtiPattern) && !(key =~ underscorePattern)) {
45+
// Keep if the key is in fieldsToKeep, starts with "temp_fields" or starts with "_"
46+
if (!fieldsToKeep.contains(key) && !key.startsWith("temp_fields") && !key.startsWith("_")) {
5147
ctx.remove(key);
5248
}
5349
}

0 commit comments

Comments
 (0)