|
21 | 21 |
|
22 | 22 | from app.translator.const import DEFAULT_VALUE_TYPE
|
23 | 23 | from app.translator.core.custom_types.values import ValueType
|
| 24 | +from app.translator.core.mapping import SourceMapping |
| 25 | +from app.translator.core.models.field import FieldValue, Keyword |
| 26 | +from app.translator.core.models.identifier import Identifier |
24 | 27 | from app.translator.core.models.platform_details import PlatformDetails
|
25 | 28 | from app.translator.core.render import BaseQueryFieldValue, PlatformQueryRender
|
26 | 29 | from app.translator.core.str_value_manager import StrValue
|
|
34 | 37 | )
|
35 | 38 | from app.translator.platforms.palo_alto.str_value_manager import cortex_xql_str_value_manager
|
36 | 39 |
|
| 40 | +SOURCE_MAPPING_TO_FIELD_VALUE_MAP = { |
| 41 | + "windows_registry_event": { |
| 42 | + "EventType": { |
| 43 | + "SetValue": "REGISTRY_SET_VALUE", |
| 44 | + "DeleteValue": "REGISTRY_DELETE_VALUE", |
| 45 | + "CreateKey": "REGISTRY_CREATE_KEY", |
| 46 | + } |
| 47 | + } |
| 48 | +} |
| 49 | + |
37 | 50 |
|
38 | 51 | class CortexXQLFieldValue(BaseQueryFieldValue):
|
39 | 52 | details: PlatformDetails = cortex_xql_query_details
|
@@ -173,6 +186,19 @@ def generate_prefix(self, log_source_signature: CortexXQLLogSourceSignature, fun
|
173 | 186 | functions_prefix = f"{functions_prefix} | " if functions_prefix else ""
|
174 | 187 | return f"{functions_prefix}{log_source_signature}"
|
175 | 188 |
|
| 189 | + def apply_token(self, token: Union[FieldValue, Keyword, Identifier], source_mapping: SourceMapping) -> str: |
| 190 | + if isinstance(token, FieldValue): |
| 191 | + field_name = token.field.source_name |
| 192 | + if values_map := SOURCE_MAPPING_TO_FIELD_VALUE_MAP.get(source_mapping.source_id, {}).get(field_name): |
| 193 | + values_to_update = [] |
| 194 | + for token_value in token.values: |
| 195 | + mapped_value: str = values_map.get(token_value, token_value) |
| 196 | + values_to_update.append( |
| 197 | + StrValue(value=mapped_value, split_value=mapped_value.split()) if mapped_value else token_value |
| 198 | + ) |
| 199 | + token.value = values_to_update |
| 200 | + return super().apply_token(token=token, source_mapping=source_mapping) |
| 201 | + |
176 | 202 | @staticmethod
|
177 | 203 | def _finalize_search_query(query: str) -> str:
|
178 | 204 | return f"| filter {query}" if query else ""
|
0 commit comments