contentctl 4.2.5__py3-none-any.whl → 4.3.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- contentctl/actions/build.py +0 -14
- contentctl/actions/detection_testing/infrastructures/DetectionTestingInfrastructure.py +60 -24
- contentctl/actions/validate.py +0 -1
- contentctl/input/director.py +9 -44
- contentctl/objects/abstract_security_content_objects/detection_abstract.py +61 -74
- contentctl/objects/config.py +0 -2
- contentctl/objects/constants.py +5 -0
- contentctl/objects/observable.py +5 -3
- contentctl/templates/detections/endpoint/anomalous_usage_of_7zip.yml +2 -2
- {contentctl-4.2.5.dist-info → contentctl-4.3.1.dist-info}/METADATA +16 -6
- {contentctl-4.2.5.dist-info → contentctl-4.3.1.dist-info}/RECORD +14 -20
- contentctl/actions/convert.py +0 -25
- contentctl/input/backend_splunk_ba.py +0 -144
- contentctl/input/sigma_converter.py +0 -436
- contentctl/input/ssa_detection_builder.py +0 -169
- contentctl/output/ba_yml_output.py +0 -153
- contentctl/output/finding_report_writer.py +0 -91
- {contentctl-4.2.5.dist-info → contentctl-4.3.1.dist-info}/LICENSE.md +0 -0
- {contentctl-4.2.5.dist-info → contentctl-4.3.1.dist-info}/WHEEL +0 -0
- {contentctl-4.2.5.dist-info → contentctl-4.3.1.dist-info}/entry_points.txt +0 -0
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
contentctl/__init__.py,sha256=IMjkMO3twhQzluVTo8Z6rE7Eg-9U79_LGKMcsWLKBkY,22
|
|
2
|
-
contentctl/actions/build.py,sha256=
|
|
3
|
-
contentctl/actions/convert.py,sha256=0KBWLxvP1hSPXpExePqpOQPRvlQLamvPLyQqeTIWNbk,704
|
|
2
|
+
contentctl/actions/build.py,sha256=FXMub_CAVN4kTks3RLHBm8O9qtFV2EkSSNld7FzCPd0,5035
|
|
4
3
|
contentctl/actions/deploy_acs.py,sha256=mf3uk495H1EU_LNN-TiOsYCo18HMGoEBMb6ojeTr0zw,1418
|
|
5
4
|
contentctl/actions/detection_testing/DetectionTestingManager.py,sha256=zg8JasDjCpSC-yhseEyUwO8qbDJIUJbhlus9Li9ZAnA,8818
|
|
6
5
|
contentctl/actions/detection_testing/GitService.py,sha256=W1vnDDt8JvIL7Z1Lve3D3RS7h8qwMxrW0BMXVGuDZDM,9007
|
|
7
6
|
contentctl/actions/detection_testing/generate_detection_coverage_badge.py,sha256=N5mznaeErVak3mOBwsd0RDBFJO3bku0EZvpayCyU-uk,2259
|
|
8
|
-
contentctl/actions/detection_testing/infrastructures/DetectionTestingInfrastructure.py,sha256=
|
|
7
|
+
contentctl/actions/detection_testing/infrastructures/DetectionTestingInfrastructure.py,sha256=1PxEnhWSFgiOtIlqRD10gRShjB65i9vLiFEnwHSGf4o,55139
|
|
9
8
|
contentctl/actions/detection_testing/infrastructures/DetectionTestingInfrastructureContainer.py,sha256=REM3WB-DQAczeknGAKMzJhnvHgnt-u9yDG2UKGVj2vM,6854
|
|
10
9
|
contentctl/actions/detection_testing/infrastructures/DetectionTestingInfrastructureServer.py,sha256=Q1ZfCYOp54O39bgTScZMInkmZiU-bGAM9Hiwr2mq5ms,370
|
|
11
10
|
contentctl/actions/detection_testing/progress_bar.py,sha256=OK9oRnPlzPAswt9KZNYID-YLHxqaYPY821kIE4-rCeA,3244
|
|
@@ -21,7 +20,7 @@ contentctl/actions/new_content.py,sha256=o5ZYBQ216RN6TnW_wRxVGJybx2SsJ7ht4PAi1dw
|
|
|
21
20
|
contentctl/actions/release_notes.py,sha256=akkFfLhsJuaPUyjsb6dLlKt9cUM-JApAjTFQMbYoXeM,13115
|
|
22
21
|
contentctl/actions/reporting.py,sha256=MJEmvmoA1WnSFZEU9QM6daL_W94oOX0WXAcX1qAM2As,1583
|
|
23
22
|
contentctl/actions/test.py,sha256=dx7f750_MrlvysxOmOdIro1bH0iVKF4K54TSwhvU2MU,5146
|
|
24
|
-
contentctl/actions/validate.py,sha256=
|
|
23
|
+
contentctl/actions/validate.py,sha256=2MQ8yumCKj7zD8iUuA5gfFEMcE-GPRzYqkvuOexn0JA,5633
|
|
25
24
|
contentctl/api.py,sha256=FBOpRhbBCBdjORmwe_8MPQ3PRZ6T0KrrFcfKovVFkug,6343
|
|
26
25
|
contentctl/contentctl.py,sha256=SxWFMYquSYQAATrTBpvfj4j5DRedsOF2xO96ASs74wA,10505
|
|
27
26
|
contentctl/enrichments/attack_enrichment.py,sha256=dVwXcULSeZJuQbeTlPpKDyEB9Y6uCy0UGWI83gPLTI0,6735
|
|
@@ -31,13 +30,10 @@ contentctl/helper/link_validator.py,sha256=-XorhxfGtjLynEL1X4hcpRMiyemogf2JEnvLw
|
|
|
31
30
|
contentctl/helper/logger.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
32
31
|
contentctl/helper/splunk_app.py,sha256=PZf60Z3ALQLJQ6I--cbWTCzvOMPGsjZSns1BFrZu4S4,9549
|
|
33
32
|
contentctl/helper/utils.py,sha256=8ICRvE7DUiNL9BK4Hw71hCLFbd3R2u86OwKeDOdaBTY,19454
|
|
34
|
-
contentctl/input/
|
|
35
|
-
contentctl/input/director.py,sha256=w-3aMrFGmfLb8vRzI-rP6K-JlmqYOwZS7OLjU_cOlck,12598
|
|
33
|
+
contentctl/input/director.py,sha256=kTqdN_rCzRMn4dR32hPaVyx2llhAxyhJgoGjowhsHzs,10887
|
|
36
34
|
contentctl/input/new_content_questions.py,sha256=o4prlBoUhEMxqpZukquI9WKbzfFJfYhEF7a8m2q_BEE,5565
|
|
37
|
-
contentctl/input/sigma_converter.py,sha256=ATFNW7boNngp5dmWM7Gr4rMZrUKjvKW2_qu28--FdiU,19391
|
|
38
|
-
contentctl/input/ssa_detection_builder.py,sha256=4wjgV-WQaJltPHxqd455lNU_8Dn-OlEaqYO8dvIsZ6c,8279
|
|
39
35
|
contentctl/input/yml_reader.py,sha256=hyVUYhx4Ka8C618kP2D_E3sDUKEQGC6ty_QZQArHKd4,1489
|
|
40
|
-
contentctl/objects/abstract_security_content_objects/detection_abstract.py,sha256=
|
|
36
|
+
contentctl/objects/abstract_security_content_objects/detection_abstract.py,sha256=V3pglFS5HYdPURIQFdNlHQfXYYr7-xLClrXiMUsb9rw,34745
|
|
41
37
|
contentctl/objects/abstract_security_content_objects/security_content_object_abstract.py,sha256=7tv-WEiUUOvZkao272J9l1IvL0y12kJ6SWLsMeWv9VE,9820
|
|
42
38
|
contentctl/objects/alert_action.py,sha256=E9gjCn5C31h0sN7k90KNe4agRxFFSnMW_Z-Ri_3YQss,1335
|
|
43
39
|
contentctl/objects/atomic.py,sha256=BP27gP8KHeODp6UazhVFxwDQ64wuJCARGsLfIH34h7U,8768
|
|
@@ -45,8 +41,8 @@ contentctl/objects/base_test.py,sha256=7kAV0njoXaasA-Mt3Zxeq-NFwFF5Z9U85k5cEYW1i
|
|
|
45
41
|
contentctl/objects/base_test_result.py,sha256=ZEAC2IUwUrW_-zHoaS7zp-uBBKIVTS8TcMXjkMByjF4,5006
|
|
46
42
|
contentctl/objects/baseline.py,sha256=Lb1vJKtDdlDrzWgrdkC9oQao_TnRrOxSwOWHf4trtaU,2150
|
|
47
43
|
contentctl/objects/baseline_tags.py,sha256=fVhLF-NmisavybB_idu3N0Con0Ymj8clKfRMkWzBB-k,1762
|
|
48
|
-
contentctl/objects/config.py,sha256=
|
|
49
|
-
contentctl/objects/constants.py,sha256=
|
|
44
|
+
contentctl/objects/config.py,sha256=XpCjYIoU4XTM6RL4Nt-YjMX342FJz4R-ATDXJWexHNs,43615
|
|
45
|
+
contentctl/objects/constants.py,sha256=lfCcr1DsTZvANHj4Ee1_sEV-SebHwAn41-5EvmoEX2E,3537
|
|
50
46
|
contentctl/objects/correlation_search.py,sha256=QZp1u-dwTZl9hkUOlJdHQ9h4Hp2bDHWWCKtrp3mvIUY,48310
|
|
51
47
|
contentctl/objects/data_source.py,sha256=aRr6lHu-EtGmi6J2nXKD7i2ozUPtp7X-vDkQiutvD3I,1545
|
|
52
48
|
contentctl/objects/deployment.py,sha256=Qc6M4yeOvxjqFKR8sfjd4CG06AbVheTOqP1mwqo4t8s,2651
|
|
@@ -70,7 +66,7 @@ contentctl/objects/macro.py,sha256=9nE-bxkFhtaltHOUCr0luU8jCCthmglHjhKs6Q2YzLU,2
|
|
|
70
66
|
contentctl/objects/mitre_attack_enrichment.py,sha256=JqSDnKF0-ZTaxUgvhdYNzIAt-7kNaEBvGr_5Bbfdwr8,1072
|
|
71
67
|
contentctl/objects/notable_action.py,sha256=ValkblBaG-60TF19y_vSnNzoNZ3eg48wIfr0qZxyKTA,1605
|
|
72
68
|
contentctl/objects/notable_event.py,sha256=ITcwLzeatSGpe8267PYN-EhgqOSoWTfciCBVu8zjOXE,682
|
|
73
|
-
contentctl/objects/observable.py,sha256=
|
|
69
|
+
contentctl/objects/observable.py,sha256=pw0Ehi_KMb7nXzw2kuw1FnCknpD8zDkCAqBTa-M_F28,1313
|
|
74
70
|
contentctl/objects/playbook.py,sha256=hSYYpdMhctgpp7uwaPciFqu1yuFI4M1NHy1WBBLyvzM,2469
|
|
75
71
|
contentctl/objects/playbook_tags.py,sha256=NrhTGcgoYSGEZggrfebko0GBOXN9x05IadRUUL_CVfQ,1436
|
|
76
72
|
contentctl/objects/risk_analysis_action.py,sha256=Glzcq99DAqqOJ2eZYCkUI3R5hA5cZGU0ZuCSinFf2R8,4278
|
|
@@ -92,13 +88,11 @@ contentctl/objects/unit_test_ssa.py,sha256=RURqXb3e0CuI5nNX8PvFucxatAvMmGSUDngVb
|
|
|
92
88
|
contentctl/output/api_json_output.py,sha256=n3OTd5z-Vkmsn7ny6QCAar_jSMNuuJfzAQa7xq_9if4,9085
|
|
93
89
|
contentctl/output/attack_nav_output.py,sha256=95iKV8U9BMMgqh6cCOw1S89Ln73xmJGgJPHTYR0L7hA,2304
|
|
94
90
|
contentctl/output/attack_nav_writer.py,sha256=64ILZLmNbh2XLmbopgENkeo6t-4SRRG8xZXBmtpNd4g,2219
|
|
95
|
-
contentctl/output/ba_yml_output.py,sha256=Lrk13Q9-f71i3c0oNrT50G94PxdogG4k4-MI-rTMOAo,5950
|
|
96
91
|
contentctl/output/conf_output.py,sha256=7HcHM9pJLNnan1Kq_7ozvs5iOgfzqdKbO6gwxUZJVnc,9994
|
|
97
92
|
contentctl/output/conf_writer.py,sha256=2TaCAPEtU-bMa7A2m7xOxh93PMpzIdhwiHiPLUCeCB4,8281
|
|
98
93
|
contentctl/output/data_source_writer.py,sha256=ubFjm6XJ4T2d3oqfKwDFasITHeDj3HFmegqVN--5_ME,1635
|
|
99
94
|
contentctl/output/detection_writer.py,sha256=AzxbssNLmsNIOaYKotew5-ONoyq1cQpKSGy3pe191B0,960
|
|
100
95
|
contentctl/output/doc_md_output.py,sha256=gf7osH1uSrC6js3D_I72g4uDe9TaB3tsvtqCHi5znp0,3238
|
|
101
|
-
contentctl/output/finding_report_writer.py,sha256=bjJR7NAxLE8vt8uU3zSDhazQzqzOdtCsUu95lVdzU_w,3939
|
|
102
96
|
contentctl/output/jinja_writer.py,sha256=bdiqr9FaXYxth4wZ1A52zTMAS5stHNGpezTkaS5pres,1119
|
|
103
97
|
contentctl/output/json_writer.py,sha256=Z-iVLnZb8tzYATxbQtXax0dz572lVPFMNVTx-vWbnog,1007
|
|
104
98
|
contentctl/output/new_content_yml_output.py,sha256=ktZ9miHluqkw8jD-pn-62bjVp1sQqqQ7B53xy18DHU8,2321
|
|
@@ -163,14 +157,14 @@ contentctl/templates/deployments/escu_default_configuration_hunting.yml,sha256=h
|
|
|
163
157
|
contentctl/templates/deployments/escu_default_configuration_ttp.yml,sha256=1D-pvzaH1v3_yCZXaY6njmdvV4S2_Ak8uzzCOsnj9XY,548
|
|
164
158
|
contentctl/templates/detections/application/.gitkeep,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
165
159
|
contentctl/templates/detections/cloud/.gitkeep,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
166
|
-
contentctl/templates/detections/endpoint/anomalous_usage_of_7zip.yml,sha256
|
|
160
|
+
contentctl/templates/detections/endpoint/anomalous_usage_of_7zip.yml,sha256=tw5_HVqMyx6itht6v2fz6Uqoy3EoIJ_lzVlrRABrMhY,3311
|
|
167
161
|
contentctl/templates/detections/network/.gitkeep,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
168
162
|
contentctl/templates/detections/web/.gitkeep,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
169
163
|
contentctl/templates/macros/security_content_ctime.yml,sha256=Gg1YNllHVsX_YB716H1SJLWzxXZEfuJlnsgB2fuyoHU,159
|
|
170
164
|
contentctl/templates/macros/security_content_summariesonly.yml,sha256=9BYUxAl2E4Nwh8K19F3AJS8Ka7ceO6ZDBjFiO3l3LY0,162
|
|
171
165
|
contentctl/templates/stories/cobalt_strike.yml,sha256=rlaXxMN-5k8LnKBLPafBoksyMtlmsPMHPJOjTiMiZ-M,3063
|
|
172
|
-
contentctl-4.
|
|
173
|
-
contentctl-4.
|
|
174
|
-
contentctl-4.
|
|
175
|
-
contentctl-4.
|
|
176
|
-
contentctl-4.
|
|
166
|
+
contentctl-4.3.1.dist-info/LICENSE.md,sha256=hQWUayRk-pAiOZbZnuy8djmoZkjKBx8MrCFpW-JiOgo,11344
|
|
167
|
+
contentctl-4.3.1.dist-info/METADATA,sha256=MAmOisMABa1nqU_QRdevnCbhYfgBWH8N3q441doHiTc,20939
|
|
168
|
+
contentctl-4.3.1.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
|
169
|
+
contentctl-4.3.1.dist-info/entry_points.txt,sha256=5bjZ2NkbQfSwK47uOnA77yCtjgXhvgxnmCQiynRF_-U,57
|
|
170
|
+
contentctl-4.3.1.dist-info/RECORD,,
|
contentctl/actions/convert.py
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import sys
|
|
3
|
-
import shutil
|
|
4
|
-
import os
|
|
5
|
-
|
|
6
|
-
from dataclasses import dataclass
|
|
7
|
-
|
|
8
|
-
from contentctl.input.sigma_converter import *
|
|
9
|
-
from contentctl.output.yml_output import YmlOutput
|
|
10
|
-
|
|
11
|
-
@dataclass(frozen=True)
|
|
12
|
-
class ConvertInputDto:
|
|
13
|
-
sigma_converter_input_dto: SigmaConverterInputDto
|
|
14
|
-
output_path : str
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
class Convert:
|
|
18
|
-
|
|
19
|
-
def execute(self, input_dto: ConvertInputDto) -> None:
|
|
20
|
-
sigma_converter_output_dto = SigmaConverterOutputDto([])
|
|
21
|
-
sigma_converter = SigmaConverter(sigma_converter_output_dto)
|
|
22
|
-
sigma_converter.execute(input_dto.sigma_converter_input_dto)
|
|
23
|
-
|
|
24
|
-
yml_output = YmlOutput()
|
|
25
|
-
yml_output.writeDetections(sigma_converter_output_dto.detections, input_dto.output_path)
|
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
import re
|
|
2
|
-
from sigma.conversion.state import ConversionState
|
|
3
|
-
from sigma.rule import SigmaRule
|
|
4
|
-
from sigma.conversion.base import TextQueryBackend
|
|
5
|
-
from sigma.conversion.deferred import DeferredTextQueryExpression
|
|
6
|
-
from sigma.conditions import ConditionFieldEqualsValueExpression, ConditionOR, ConditionAND, ConditionNOT, ConditionItem
|
|
7
|
-
from sigma.types import SigmaCompareExpression
|
|
8
|
-
from sigma.exceptions import SigmaFeatureNotSupportedByBackendError
|
|
9
|
-
from sigma.pipelines.splunk.splunk import splunk_sysmon_process_creation_cim_mapping, splunk_windows_registry_cim_mapping, splunk_windows_file_event_cim_mapping
|
|
10
|
-
|
|
11
|
-
from contentctl.objects.ssa_detection import SSADetection
|
|
12
|
-
|
|
13
|
-
from typing import ClassVar, Dict, List, Optional, Pattern, Tuple
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
class SplunkBABackend(TextQueryBackend):
|
|
17
|
-
"""Splunk SPL backend."""
|
|
18
|
-
precedence: ClassVar[Tuple[ConditionItem, ConditionItem, ConditionItem]] = (ConditionNOT, ConditionOR, ConditionAND)
|
|
19
|
-
group_expression : ClassVar[str] = "({expr})"
|
|
20
|
-
parenthesize : bool = True
|
|
21
|
-
|
|
22
|
-
or_token : ClassVar[str] = "OR"
|
|
23
|
-
and_token : ClassVar[str] = "AND"
|
|
24
|
-
not_token : ClassVar[str] = "NOT"
|
|
25
|
-
eq_token : ClassVar[str] = "="
|
|
26
|
-
|
|
27
|
-
field_quote: ClassVar[str] = '"'
|
|
28
|
-
field_quote_pattern: ClassVar[Pattern] = re.compile("^[\w.]+$")
|
|
29
|
-
|
|
30
|
-
str_quote : ClassVar[str] = '"'
|
|
31
|
-
escape_char : ClassVar[str] = "\\"
|
|
32
|
-
wildcard_multi : ClassVar[str] = "%"
|
|
33
|
-
wildcard_single : ClassVar[str] = "%"
|
|
34
|
-
add_escaped : ClassVar[str] = "\\"
|
|
35
|
-
|
|
36
|
-
re_expression : ClassVar[str] = "match({field}, /(?i){regex}/)=true"
|
|
37
|
-
re_escape_char : ClassVar[str] = ""
|
|
38
|
-
re_escape : ClassVar[Tuple[str]] = ('"',)
|
|
39
|
-
|
|
40
|
-
cidr_expression : ClassVar[str] = "{value}"
|
|
41
|
-
|
|
42
|
-
compare_op_expression : ClassVar[str] = "{field}{operator}{value}"
|
|
43
|
-
compare_operators : ClassVar[Dict[SigmaCompareExpression.CompareOperators, str]] = {
|
|
44
|
-
SigmaCompareExpression.CompareOperators.LT : "<",
|
|
45
|
-
SigmaCompareExpression.CompareOperators.LTE : "<=",
|
|
46
|
-
SigmaCompareExpression.CompareOperators.GT : ">",
|
|
47
|
-
SigmaCompareExpression.CompareOperators.GTE : ">=",
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
field_null_expression : ClassVar[str] = "{field} IS NOT NULL"
|
|
51
|
-
|
|
52
|
-
convert_or_as_in : ClassVar[bool] = True
|
|
53
|
-
convert_and_as_in : ClassVar[bool] = False
|
|
54
|
-
in_expressions_allow_wildcards : ClassVar[bool] = False
|
|
55
|
-
field_in_list_expression : ClassVar[str] = "{field} {op} ({list})"
|
|
56
|
-
or_in_operator : ClassVar[Optional[str]] = "IN"
|
|
57
|
-
list_separator : ClassVar[str] = ", "
|
|
58
|
-
|
|
59
|
-
unbound_value_str_expression : ClassVar[str] = '{value}'
|
|
60
|
-
unbound_value_num_expression : ClassVar[str] = '{value}'
|
|
61
|
-
unbound_value_re_expression : ClassVar[str] = '{value}'
|
|
62
|
-
|
|
63
|
-
deferred_start : ClassVar[str] = " "
|
|
64
|
-
deferred_separator : ClassVar[str] = " OR "
|
|
65
|
-
deferred_only_query : ClassVar[str] = "*"
|
|
66
|
-
|
|
67
|
-
wildcard_match_expression : ClassVar[Optional[str]] = "{field} LIKE {value}"
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
def __init__(self, processing_pipeline: Optional["sigma.processing.pipeline.ProcessingPipeline"] = None, collect_errors: bool = False, min_time : str = "-30d", max_time : str = "now", detection : SSADetection = None, field_mapping: dict = None, **kwargs):
|
|
71
|
-
super().__init__(processing_pipeline, collect_errors, **kwargs)
|
|
72
|
-
self.min_time = min_time or "-30d"
|
|
73
|
-
self.max_time = max_time or "now"
|
|
74
|
-
self.detection = detection
|
|
75
|
-
self.field_mapping = field_mapping
|
|
76
|
-
|
|
77
|
-
def finalize_query_data_model(self, rule: SigmaRule, query: str, index: int, state: ConversionState) -> str:
|
|
78
|
-
|
|
79
|
-
try:
|
|
80
|
-
fields = state.processing_state["fields"]
|
|
81
|
-
except KeyError:
|
|
82
|
-
raise SigmaFeatureNotSupportedByBackendError("No fields specified by processing pipeline")
|
|
83
|
-
|
|
84
|
-
# fields_input_parsing = ''
|
|
85
|
-
# for count, value in enumerate(fields):
|
|
86
|
-
# fields_input_parsing = fields_input_parsing + value + '=ucast(map_get(input_event, "' + value + '"), "string", null)'
|
|
87
|
-
# if not count == len(fields) - 1:
|
|
88
|
-
# fields_input_parsing = fields_input_parsing + ', '
|
|
89
|
-
|
|
90
|
-
detection_str = """
|
|
91
|
-
$main = from source
|
|
92
|
-
| eval timestamp = time
|
|
93
|
-
| eval metadata_uid = metadata.uid
|
|
94
|
-
""".replace("\n", " ")
|
|
95
|
-
|
|
96
|
-
parsed_fields = []
|
|
97
|
-
|
|
98
|
-
for field in self.field_mapping["mapping"].keys():
|
|
99
|
-
mapped_field = self.field_mapping["mapping"][field]
|
|
100
|
-
parent = 'parent'
|
|
101
|
-
i = 1
|
|
102
|
-
values = mapped_field.split('.')
|
|
103
|
-
for val in values:
|
|
104
|
-
if parent == "parent":
|
|
105
|
-
parent = val
|
|
106
|
-
continue
|
|
107
|
-
else:
|
|
108
|
-
new_val = parent + '_' + val
|
|
109
|
-
if new_val in parsed_fields:
|
|
110
|
-
parent = new_val
|
|
111
|
-
i = i + 1
|
|
112
|
-
continue
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
new_val_equals = new_val + "="
|
|
116
|
-
new_val_IN = new_val + " IN"
|
|
117
|
-
if new_val_equals in query or new_val_IN in query:
|
|
118
|
-
parser_str = '| eval ' + new_val + ' = ' + 'lower(' + parent + '.' + val + ') '
|
|
119
|
-
else:
|
|
120
|
-
parser_str = '| eval ' + new_val + ' = ' + parent + '.' + val + ' '
|
|
121
|
-
detection_str = detection_str + parser_str
|
|
122
|
-
parsed_fields.append(new_val)
|
|
123
|
-
parent = new_val
|
|
124
|
-
i = i + 1
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
### Convert sigma values into lower case
|
|
128
|
-
lower_query = ""
|
|
129
|
-
in_quotes = False
|
|
130
|
-
for char in query:
|
|
131
|
-
if char == '"':
|
|
132
|
-
in_quotes = not in_quotes
|
|
133
|
-
if in_quotes:
|
|
134
|
-
lower_query += char.lower()
|
|
135
|
-
else:
|
|
136
|
-
lower_query += char
|
|
137
|
-
|
|
138
|
-
detection_str = detection_str + "| where " + lower_query
|
|
139
|
-
|
|
140
|
-
detection_str = detection_str.replace("\\\\\\\\", "\\\\")
|
|
141
|
-
return detection_str
|
|
142
|
-
|
|
143
|
-
def finalize_output_data_model(self, queries: List[str]) -> List[str]:
|
|
144
|
-
return queries
|