Skip to content

Commit 10030cd

Browse files
committed
refactoring in apply_token
1 parent b7893c4 commit 10030cd

File tree

1 file changed

+7
-20
lines changed

1 file changed

+7
-20
lines changed

uncoder-core/app/translator/platforms/palo_alto/renders/cortex_xsiam.py

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -186,29 +186,16 @@ def generate_prefix(self, log_source_signature: CortexXQLLogSourceSignature, fun
186186
return f"{functions_prefix}{log_source_signature}"
187187

188188
def apply_token(self, token: Union[FieldValue, Keyword, Identifier], source_mapping: SourceMapping) -> str:
189-
if (
190-
isinstance(token, FieldValue)
191-
and source_mapping.source_id in SOURCE_MAPPING_TO_FIELD_VALUE_MAP
192-
and token.field.source_name in SOURCE_MAPPING_TO_FIELD_VALUE_MAP[source_mapping.source_id]
193-
):
194-
values_to_update = []
195-
token_values = token.values
196-
for token_value in token_values:
197-
if (
198-
isinstance(token_value, str)
199-
and token_value
200-
in SOURCE_MAPPING_TO_FIELD_VALUE_MAP[source_mapping.source_id][token.field.source_name]
201-
):
189+
if isinstance(token, FieldValue):
190+
field_name = token.field.source_name
191+
if values_map := SOURCE_MAPPING_TO_FIELD_VALUE_MAP.get(source_mapping.source_id, {}).get(field_name):
192+
values_to_update = []
193+
for token_value in token.values:
194+
mapped_value: str = values_map.get(token_value, token_value)
202195
values_to_update.append(
203-
SOURCE_MAPPING_TO_FIELD_VALUE_MAP[source_mapping.source_id][token.field.source_name][
204-
token_value
205-
]
196+
StrValue(value=mapped_value, split_value=mapped_value.split()) if mapped_value else token_value
206197
)
207-
else:
208-
values_to_update.append(token_value)
209-
if values_to_update != token_values:
210198
token.value = values_to_update
211-
212199
return super().apply_token(token=token, source_mapping=source_mapping)
213200

214201
@staticmethod

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy