- Notifications
You must be signed in to change notification settings - Fork33
Gis 8971#215
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Merged
Uh oh!
There was an error while loading.Please reload this page.
Merged
Gis 8971#215
Changes fromall commits
Commits
Show all changes
8 commits Select commitHold shift + click to select a range
0d6b23a gis-8971 add ArcSight query render
nazargesykf1fb03b gis-8971 develop ArcSight query render
nazargesykfd38f39 gis-8971 fixes
nazargesyk642b8b5 gis-8971 fixes
nazargesyk32814a1 gis-8971 fixes
nazargesyk5f4b5b3 gis-8971 fixes
nazargesykd552a97 Merge branch 'main' into gis-8971
nazargesyk413ce50 Merge branch 'main' into gis-8971
nazargesykFile filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
20 changes: 20 additions & 0 deletionsuncoder-core/app/translator/core/mixins/tokens.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| from typing import Union | ||
| from app.translator.core.const import QUERY_TOKEN_TYPE | ||
| from app.translator.core.custom_types.tokens import LogicalOperatorType, OperatorType | ||
| from app.translator.core.mapping import SourceMapping | ||
| from app.translator.core.models.query_tokens.field_value import FieldValue | ||
| from app.translator.core.models.query_tokens.identifier import Identifier | ||
| class ExtraConditionMixin: | ||
| def generate_extra_conditions(self, source_mapping: SourceMapping) -> list[QUERY_TOKEN_TYPE]: | ||
| extra_tokens = [] | ||
| for field, value in source_mapping.conditions.items(): | ||
| extra_tokens.extend( | ||
| [ | ||
| FieldValue(source_name=field, operator=Identifier(token_type=OperatorType.EQ), value=value), | ||
| Identifier(token_type=LogicalOperatorType.AND), | ||
| ] | ||
| ) | ||
| return extra_tokens |
6 changes: 6 additions & 0 deletionsuncoder-core/app/translator/core/render.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletionsuncoder-core/app/translator/mappings/platforms/arcsight/default.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| platform: ArcSight | ||
| source: default | ||
| default_log_source: {} |
9 changes: 9 additions & 0 deletionsuncoder-core/app/translator/mappings/platforms/arcsight/linux_network_connection.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| platform: ArcSight | ||
| source: linux_network_connection | ||
| default_log_source: {} | ||
| field_mapping: | ||
| SourceHostname: sourceHostName |
9 changes: 9 additions & 0 deletionsuncoder-core/app/translator/mappings/platforms/arcsight/macos_network_connection.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| platform: ArcSight | ||
| source: macos_network_connection | ||
| default_log_source: {} | ||
| field_mapping: | ||
| SourceHostname: sourceHostName |
13 changes: 13 additions & 0 deletionsuncoder-core/app/translator/mappings/platforms/arcsight/windows_create_remote_thread.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| platform: ArcSight | ||
| source: windows_create_remote_thread | ||
| default_log_source: {} | ||
| field_mapping: | ||
| SourceImage: sourceProcessName | ||
| TargetImage: destinationProcessName | ||
| StartModule: deviceCustomString3 | ||
| StartAddress: deviceCustomString3 | ||
| StartFunction: deviceCustomString3 |
9 changes: 9 additions & 0 deletionsuncoder-core/app/translator/mappings/platforms/arcsight/windows_network_connection.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| platform: ArcSight | ||
| source: windows_network_connection | ||
| default_log_source: {} | ||
| field_mapping: | ||
| SourceHostname: sourceHostName |
9 changes: 9 additions & 0 deletionsuncoder-core/app/translator/mappings/platforms/arcsight/windows_process_creation.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| platform: ArcSight | ||
| source: windows_process_creation | ||
| default_log_source: {} | ||
| field_mapping: | ||
| OriginalFileName: oldFileName |
54 changes: 54 additions & 0 deletionsuncoder-core/app/translator/mappings/platforms/arcsight/windows_security.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| platform: ArcSight | ||
| source: windows_security | ||
| default_log_source: {} | ||
| conditions: | ||
| deviceVendor: Microsoft | ||
| deviceProduct: Microsoft Windows | ||
| field_mapping: | ||
| EventID: externalId | ||
| AccessMask: deviceCustomString1 | ||
| AccountName: destinationUserName | ||
| AuditPolicyChanges: deviceAction | ||
| AuthenticationPackageName: deviceCustomString5 | ||
| EventType: deviceSeverity | ||
| FailureReason: deviceCustomString4 | ||
| IpAddress: sourceAddress | ||
| IpPort: sourcePort | ||
| LogonProcessName: | ||
| - destinationProcessName | ||
| - sourceProcessName | ||
| LogonType: deviceCustomNumber1 | ||
| MemberName: destinationUserId | ||
| MemberSid: destinationUserName | ||
| NewProcessName: destinationProcessName | ||
| ObjectClass: deviceCustomString5 | ||
| ObjectName: fileName | ||
| ObjectType: fileType | ||
| ObjectValueName: deviceCustomString6 | ||
| CommandLine: deviceCustomString4 | ||
| ProcessName: destinationProcessName | ||
| Properties: deviceCustomString6 | ||
| ServiceFileName: filePath | ||
| ServiceName: destinationServiceName | ||
| ShareName: | ||
| - filePath | ||
| - deviceCustomString6 | ||
| Status: eventOutcome | ||
| SubjectDomainName: destinationNTDomain | ||
| SubjectUserName: destinationUserName | ||
| SubjectUserSid: destinationUserName | ||
| TargetDomainName: destinationNTDomain | ||
| TargetSid: destinationNTDomain | ||
| TargetUserName: destinationUserName | ||
| TargetUserSid: destinationUserName | ||
| TicketEncryptionType: deviceCustomString5 | ||
| TicketOptions: deviceCustomString1 | ||
| WorkstationName: sourceHostName | ||
| ServiceType: fileType | ||
| StartType: deviceCustomString5 | ||
| ParentProcessName: filePath |
50 changes: 50 additions & 0 deletionsuncoder-core/app/translator/mappings/platforms/arcsight/windows_sysmon.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| platform: ArcSight | ||
| source: windows_sysmon | ||
| default_log_source: {} | ||
| conditions: | ||
| deviceVendor: Microsoft | ||
| deviceProduct: Sysmon | ||
| field_mapping: | ||
| CommandLine: deviceCustomString1 | ||
| Image: destinationProcessName | ||
| ParentImage: sourceProcessName | ||
| EventID: externalId | ||
| CallTrace: deviceCustomString3 | ||
| Company: oldFileType | ||
| CurrentDirectory: deviceCustomString3 | ||
| Description: oldFilePermission | ||
| DestinationHostname: destinationHostName | ||
| DestinationIp: destinationAddress | ||
| DestinationPort: destinationPort | ||
| Initiated: deviceCustomString4 | ||
| IntegrityLevel: deviceCustomString5 | ||
| ParentCommandLine: deviceCustomString2 | ||
| Product: destinationServiceName | ||
| Protocol: transportProtocol | ||
| RuleName: deviceFacility | ||
| SourceHostname: sourceHostName | ||
| SourceIp: sourceAddress | ||
| SourcePort: sourcePort | ||
| TargetFilename: fileName | ||
| User: sourceUserName | ||
| OriginalFileName: oldFileName | ||
| Signed: deviceCustomString1 | ||
| Signature: deviceCustomString2 | ||
| SignatureStatus: deviceCustomString3 | ||
| TargetObject: fileName | ||
| Details: deviceCustomString1 | ||
| QueryName: | ||
| - requestUrl | ||
| - destinationHostName | ||
| QueryResults: deviceCustomString1 | ||
| QueryStatus: deviceCustomNumber1 | ||
| PipeName: fileName | ||
| ImageLoaded: destinationProcessName | ||
| SourceImage: sourceProcessName | ||
| StartModule: deviceCustomString3 | ||
| TargetImage: destinationProcessName | ||
| EventType: deviceAction |
1 change: 1 addition & 0 deletionsuncoder-core/app/translator/platforms/arcsight/__init__.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,2 @@ | ||
| from app.translator.platforms.arcsight.renders.arcsight import ArcSightQueryRender # noqa: F401 | ||
| from app.translator.platforms.arcsight.renders.arcsight_cti import ArcsightKeyword # noqa: F401 |
6 changes: 5 additions & 1 deletionuncoder-core/app/translator/platforms/arcsight/const.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,12 @@ | ||
| from app.translator.core.models.platform_details import PlatformDetails | ||
| ARCSIGHT_QUERY_DETAILS = { | ||
| "platform_id": "arcsight-query", | ||
| "name": "ArcSight Query", | ||
| "group_name": "ArcSight", | ||
| "group_id": "arcsight", | ||
| "platform_name": "Query", | ||
| "alt_platform_name": "CEF", | ||
| } | ||
| arcsight_query_details = PlatformDetails(**ARCSIGHT_QUERY_DETAILS) |
14 changes: 14 additions & 0 deletionsuncoder-core/app/translator/platforms/arcsight/escape_manager.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| from typing import ClassVar | ||
| from app.translator.core.custom_types.values import ValueType | ||
| from app.translator.core.escape_manager import EscapeManager | ||
| from app.translator.core.models.escape_details import EscapeDetails | ||
| class ArcSightEscapeManager(EscapeManager): | ||
| escape_map: ClassVar[dict[str, list[EscapeDetails]]] = { | ||
| ValueType.value: [EscapeDetails(pattern='(["\\()])', escape_symbols="\\\\\g<1>")] | ||
| } | ||
| arcsight_escape_manager = ArcSightEscapeManager() |
18 changes: 18 additions & 0 deletionsuncoder-core/app/translator/platforms/arcsight/mapping.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| from app.translator.core.mapping import BaseStrictLogSourcesPlatformMappings, LogSourceSignature | ||
| from app.translator.platforms.arcsight.const import arcsight_query_details | ||
| class ArcSightLogSourceSignature(LogSourceSignature): | ||
| def is_suitable(self) -> bool: | ||
| return True | ||
| def __str__(self) -> str: | ||
| return "" | ||
| class ArcSightMappings(BaseStrictLogSourcesPlatformMappings): | ||
| def prepare_log_source_signature(self, mapping: dict) -> ArcSightLogSourceSignature: # noqa: ARG002 | ||
| return ArcSightLogSourceSignature() | ||
| arcsight_query_mappings = ArcSightMappings(platform_dir="arcsight", platform_details=arcsight_query_details) |
101 changes: 101 additions & 0 deletionsuncoder-core/app/translator/platforms/arcsight/renders/arcsight.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,101 @@ | ||
| from typing import Optional, Union | ||
| from app.translator.const import DEFAULT_VALUE_TYPE | ||
| from app.translator.core.custom_types.values import ValueType | ||
| from app.translator.core.mapping import LogSourceSignature | ||
| from app.translator.core.mixins.tokens import ExtraConditionMixin | ||
| from app.translator.core.models.platform_details import PlatformDetails | ||
| from app.translator.core.render import BaseFieldValueRender, PlatformQueryRender | ||
| from app.translator.core.str_value_manager import StrValue, StrValueManager | ||
| from app.translator.managers import render_manager | ||
| from app.translator.platforms.arcsight.const import arcsight_query_details | ||
| from app.translator.platforms.arcsight.mapping import ArcSightMappings, arcsight_query_mappings | ||
| from app.translator.platforms.arcsight.str_value_manager import arcsight_str_value_manager | ||
| class ArcSightFieldValue(BaseFieldValueRender): | ||
| details: PlatformDetails = arcsight_query_details | ||
| str_value_manager: StrValueManager = arcsight_str_value_manager | ||
| @staticmethod | ||
| def _wrap_str_value(value: str) -> str: | ||
| return f'"{value}"' | ||
| @staticmethod | ||
| def _wrap_int_value(value: int) -> str: | ||
| return f'"{value}"' | ||
| def equal_modifier(self, field: str, value: DEFAULT_VALUE_TYPE) -> str: | ||
| if isinstance(value, list): | ||
| return f"({self.or_token.join(self.equal_modifier(field, val) for val in value)})" | ||
| value = self._pre_process_value(field, value, value_type=ValueType.value, wrap_str=True) | ||
| return f"{field} = {value}" | ||
| def less_modifier(self, field: str, value: Union[int, str, StrValue]) -> str: | ||
| return f"{field} < {self._pre_process_value(field, value, wrap_str=True)}" | ||
| def less_or_equal_modifier(self, field: str, value: Union[int, str, StrValue]) -> str: | ||
| return f"{field} <= {self._pre_process_value(field, value, wrap_str=True)}" | ||
| def greater_modifier(self, field: str, value: Union[int, str, StrValue]) -> str: | ||
| return f"{field} > {self._pre_process_value(field, value, wrap_str=True)}" | ||
| def greater_or_equal_modifier(self, field: str, value: Union[int, str, StrValue]) -> str: | ||
| return f"{field} > {self._pre_process_value(field, value, wrap_str=True)}" | ||
| def not_equal_modifier(self, field: str, value: DEFAULT_VALUE_TYPE) -> str: | ||
| if isinstance(value, list): | ||
| return f"({self.or_token.join(self.not_equal_modifier(field, val) for val in value)})" | ||
| value = self._pre_process_value(field, value, value_type=ValueType.value, wrap_str=True) | ||
| return f"{field} != {value}" | ||
| def is_none(self, field: str, value: DEFAULT_VALUE_TYPE) -> str: | ||
| if isinstance(value, list): | ||
| return f"({self.or_token.join(self.is_none(field=field, value=v) for v in value)})" | ||
| return f"NOT _exists_:{field}" | ||
| def is_not_none(self, field: str, value: DEFAULT_VALUE_TYPE) -> str: | ||
| if isinstance(value, list): | ||
| return f"({self.or_token.join(self.is_not_none(field=field, value=v) for v in value)})" | ||
| return f"_exists_:{field}" | ||
| def contains_modifier(self, field: str, value: DEFAULT_VALUE_TYPE) -> str: | ||
| if isinstance(value, list): | ||
| return f"({self.or_token.join(self.contains_modifier(field, val) for val in value)})" | ||
| value = self._wrap_str_value(value) | ||
| return f"{field} CONTAINS {value}" | ||
| def endswith_modifier(self, field: str, value: DEFAULT_VALUE_TYPE) -> str: | ||
| if isinstance(value, list): | ||
| return f"({self.or_token.join(self.endswith_modifier(field, val) for val in value)})" | ||
| value = self._wrap_str_value(value) | ||
| return f"{field} ENDSWITH {value}" | ||
| def startswith_modifier(self, field: str, value: DEFAULT_VALUE_TYPE) -> str: | ||
| if isinstance(value, list): | ||
| return f"({self.or_token.join(self.startswith_modifier(field, val) for val in value)})" | ||
| value = self._wrap_str_value(value) | ||
| return f"{field} STARTSWITH {value}" | ||
| def regex_modifier(self, field: str, value: DEFAULT_VALUE_TYPE) -> str: | ||
| if isinstance(value, list): | ||
| return f"({self.or_token.join(self.regex_modifier(field, val) for val in value)})" | ||
| value = self._wrap_str_value(value) | ||
| return f"{field} CONTAINS {value}" | ||
| @render_manager.register | ||
| class ArcSightQueryRender(ExtraConditionMixin, PlatformQueryRender): | ||
| details: PlatformDetails = arcsight_query_details | ||
| mappings: ArcSightMappings = arcsight_query_mappings | ||
| or_token = "OR" | ||
| and_token = "AND" | ||
| not_token = "NOT" | ||
| comment_symbol = "//" | ||
| field_value_render = ArcSightFieldValue(or_token=or_token) | ||
| def generate_prefix(self, log_source_signature: Optional[LogSourceSignature], functions_prefix: str = "") -> str: # noqa: ARG002 | ||
| return "" |
4 changes: 2 additions & 2 deletionsuncoder-core/app/translator/platforms/arcsight/renders/arcsight_cti.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Oops, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
Oops, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.