fluidattacks-core 4.2.0__py3-none-any.whl → 4.3.0__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.
- fluidattacks_core/logging/handlers.py +19 -2
- fluidattacks_core/logging/sources/__init__.py +41 -15
- {fluidattacks_core-4.2.0.dist-info → fluidattacks_core-4.3.0.dist-info}/METADATA +9 -8
- {fluidattacks_core-4.2.0.dist-info → fluidattacks_core-4.3.0.dist-info}/RECORD +6 -6
- {fluidattacks_core-4.2.0.dist-info → fluidattacks_core-4.3.0.dist-info}/WHEEL +0 -0
- {fluidattacks_core-4.2.0.dist-info → fluidattacks_core-4.3.0.dist-info}/top_level.txt +0 -0
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import copy
|
|
1
2
|
import logging
|
|
2
3
|
import sys
|
|
3
4
|
from logging.handlers import HTTPHandler, QueueHandler, QueueListener
|
|
@@ -10,6 +11,22 @@ from fluidattacks_core.logging.filters import NoProductionFilter, ProductionOnly
|
|
|
10
11
|
from fluidattacks_core.logging.formatters import ColorfulFormatter, CustomJsonFormatter
|
|
11
12
|
|
|
12
13
|
|
|
14
|
+
class CustomQueueHandler(QueueHandler):
|
|
15
|
+
"""Class to fix QueueHandler missing exc_info field."""
|
|
16
|
+
|
|
17
|
+
def prepare(self, record: logging.LogRecord) -> logging.LogRecord:
|
|
18
|
+
original_exc_info = record.exc_info
|
|
19
|
+
|
|
20
|
+
# Avoid duplicate exc_text in the log message
|
|
21
|
+
no_exc_record = copy.copy(record)
|
|
22
|
+
no_exc_record.exc_info = None
|
|
23
|
+
prepared = super().prepare(no_exc_record)
|
|
24
|
+
|
|
25
|
+
prepared.exc_info = original_exc_info
|
|
26
|
+
|
|
27
|
+
return prepared
|
|
28
|
+
|
|
29
|
+
|
|
13
30
|
class DebuggingHandler(logging.StreamHandler[TextIO]):
|
|
14
31
|
"""Logging handler for console environments implemented with `QueueHandler`.
|
|
15
32
|
|
|
@@ -38,7 +55,7 @@ class ProductionSyncHandler(logging.StreamHandler[TextIO]):
|
|
|
38
55
|
self.setFormatter(CustomJsonFormatter())
|
|
39
56
|
|
|
40
57
|
|
|
41
|
-
class ProductionAsyncHandler(
|
|
58
|
+
class ProductionAsyncHandler(CustomQueueHandler):
|
|
42
59
|
"""Logging handler for production environments implemented with `QueueHandler`.
|
|
43
60
|
|
|
44
61
|
Includes:
|
|
@@ -96,7 +113,7 @@ class DatadogLogsHandler(HTTPHandler):
|
|
|
96
113
|
self.handleError(record)
|
|
97
114
|
|
|
98
115
|
|
|
99
|
-
class TelemetryAsyncHandler(
|
|
116
|
+
class TelemetryAsyncHandler(CustomQueueHandler):
|
|
100
117
|
"""Logging handler for sending logs to telemetry services asynchronously."""
|
|
101
118
|
|
|
102
119
|
def __init__(self, service: str, source: str, dd_client_token: str) -> None:
|
|
@@ -24,11 +24,19 @@ class LambdaSource(SourceStrategy):
|
|
|
24
24
|
|
|
25
25
|
@staticmethod
|
|
26
26
|
def log_metadata() -> dict[str, str]:
|
|
27
|
+
product_id = get_env_var("PRODUCT_ID")
|
|
28
|
+
function_name = get_env_var("AWS_LAMBDA_FUNCTION_NAME")
|
|
29
|
+
service = product_id or function_name or "unknown"
|
|
30
|
+
|
|
31
|
+
trace_header = get_env_var("_X_AMZN_TRACE_ID")
|
|
32
|
+
|
|
27
33
|
return {
|
|
28
34
|
"ddsource": "lambda",
|
|
29
|
-
"dd.service":
|
|
35
|
+
"dd.service": service,
|
|
30
36
|
"dd.version": get_version(),
|
|
31
37
|
"deployment.environment": get_environment(),
|
|
38
|
+
"lambda_metadata.function_name": function_name or "unknown",
|
|
39
|
+
"lambda_metadata.trace_header": trace_header or "unknown",
|
|
32
40
|
}
|
|
33
41
|
|
|
34
42
|
|
|
@@ -39,18 +47,31 @@ class BatchSource(SourceStrategy):
|
|
|
39
47
|
|
|
40
48
|
@staticmethod
|
|
41
49
|
def log_metadata() -> dict[str, str]:
|
|
42
|
-
|
|
50
|
+
job_id = get_env_var("AWS_BATCH_JOB_ID")
|
|
51
|
+
attempt = get_env_var("AWS_BATCH_JOB_ATTEMPT")
|
|
52
|
+
compute_environment = get_env_var("AWS_BATCH_CE_NAME")
|
|
53
|
+
|
|
54
|
+
product_id = get_env_var("PRODUCT_ID")
|
|
43
55
|
job_definition_name = get_env_var("JOB_DEFINITION_NAME")
|
|
56
|
+
job_name = get_env_var("JOB_NAME")
|
|
44
57
|
job_queue = get_env_var("AWS_BATCH_JQ_NAME")
|
|
45
|
-
product_id = get_env_var("PRODUCT_ID")
|
|
46
58
|
service = (
|
|
47
|
-
|
|
59
|
+
product_id
|
|
60
|
+
or job_definition_name
|
|
61
|
+
or job_name
|
|
62
|
+
or (f"from-{job_queue}" if job_queue else "unknown")
|
|
48
63
|
)
|
|
64
|
+
|
|
49
65
|
return {
|
|
50
66
|
"ddsource": "batch",
|
|
51
|
-
"dd.service": service
|
|
67
|
+
"dd.service": service,
|
|
52
68
|
"dd.version": get_version(),
|
|
53
69
|
"deployment.environment": get_environment(),
|
|
70
|
+
"job_metadata.id": job_id or "unknown",
|
|
71
|
+
"job_metadata.queue": job_queue or "unknown",
|
|
72
|
+
"job_metadata.definition_name": job_definition_name or "unknown",
|
|
73
|
+
"job_metadata.attempt": attempt or "unknown",
|
|
74
|
+
"job_metadata.compute_environment": compute_environment or "unknown",
|
|
54
75
|
}
|
|
55
76
|
|
|
56
77
|
|
|
@@ -88,20 +109,20 @@ class PipelineSource(SourceStrategy):
|
|
|
88
109
|
|
|
89
110
|
return {
|
|
90
111
|
"ddsource": f"ci/{pipeline}",
|
|
91
|
-
"
|
|
112
|
+
"pipeline_metadata.type": pipeline,
|
|
92
113
|
**(
|
|
93
114
|
{
|
|
94
|
-
"
|
|
95
|
-
"
|
|
115
|
+
"pipeline_metadata.CI_JOB_ID": get_env_var("CI_JOB_ID") or "unknown",
|
|
116
|
+
"pipeline_metadata.CI_JOB_URL": get_env_var("CI_JOB_URL") or "unknown",
|
|
96
117
|
}
|
|
97
118
|
if pipeline == "gitlab_ci"
|
|
98
119
|
else {}
|
|
99
120
|
),
|
|
100
121
|
**(
|
|
101
122
|
{
|
|
102
|
-
"
|
|
123
|
+
"pipeline_metadata.CIRCLE_BUILD_NUM": get_env_var("CIRCLE_BUILD_NUM")
|
|
103
124
|
or "unknown",
|
|
104
|
-
"
|
|
125
|
+
"pipeline_metadata.CIRCLE_BUILD_URL": get_env_var("CIRCLE_BUILD_URL")
|
|
105
126
|
or "unknown",
|
|
106
127
|
}
|
|
107
128
|
if pipeline == "circleci"
|
|
@@ -109,16 +130,16 @@ class PipelineSource(SourceStrategy):
|
|
|
109
130
|
),
|
|
110
131
|
**(
|
|
111
132
|
{
|
|
112
|
-
"
|
|
133
|
+
"pipeline_metadata.System.JobId": get_env_var("System.JobId") or "unknown",
|
|
113
134
|
}
|
|
114
135
|
if pipeline == "azure_devops"
|
|
115
136
|
else {}
|
|
116
137
|
),
|
|
117
138
|
**(
|
|
118
139
|
{
|
|
119
|
-
"
|
|
120
|
-
"
|
|
121
|
-
"
|
|
140
|
+
"pipeline_metadata.BUILD_NUMBER": get_env_var("BUILD_NUMBER") or "unknown",
|
|
141
|
+
"pipeline_metadata.BUILD_ID": get_env_var("BUILD_ID") or "unknown",
|
|
142
|
+
"pipeline_metadata.BUILD_URL": get_env_var("BUILD_URL") or "unknown",
|
|
122
143
|
}
|
|
123
144
|
if pipeline == "jenkins"
|
|
124
145
|
else {}
|
|
@@ -137,11 +158,16 @@ class ContainerSource(SourceStrategy):
|
|
|
137
158
|
|
|
138
159
|
@staticmethod
|
|
139
160
|
def log_metadata() -> dict[str, str]:
|
|
161
|
+
product_id = get_env_var("PRODUCT_ID")
|
|
162
|
+
container_image = get_env_var("CONTAINER_IMAGE")
|
|
163
|
+
service = product_id or container_image or "unknown"
|
|
164
|
+
|
|
140
165
|
return {
|
|
141
166
|
"ddsource": "container",
|
|
142
|
-
"dd.service":
|
|
167
|
+
"dd.service": service,
|
|
143
168
|
"dd.version": get_version(),
|
|
144
169
|
"deployment.environment": get_environment(),
|
|
170
|
+
"container_metadata.image": container_image or "unknown",
|
|
145
171
|
}
|
|
146
172
|
|
|
147
173
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: fluidattacks-core
|
|
3
|
-
Version: 4.
|
|
3
|
+
Version: 4.3.0
|
|
4
4
|
Summary: Fluid Attacks Core Library
|
|
5
5
|
Author-email: Development <development@fluidattacks.com>
|
|
6
6
|
License: MPL-2.0
|
|
@@ -25,24 +25,25 @@ Requires-Dist: bugsnag>=4.7.1; extra == "bugsnag"
|
|
|
25
25
|
Provides-Extra: git
|
|
26
26
|
Requires-Dist: aiofiles>=23.2.1; extra == "git"
|
|
27
27
|
Requires-Dist: boto3>=1.34; extra == "git"
|
|
28
|
+
Requires-Dist: botocore>=1.40.18; extra == "git"
|
|
28
29
|
Requires-Dist: GitPython>=3.1.41; extra == "git"
|
|
29
30
|
Requires-Dist: pathspec>=0.12.1; extra == "git"
|
|
30
31
|
Provides-Extra: http
|
|
31
32
|
Provides-Extra: serializers
|
|
32
|
-
Requires-Dist: tree-sitter>=0.25.2; extra == "serializers"
|
|
33
33
|
Requires-Dist: more-itertools>=10.0.0; extra == "serializers"
|
|
34
34
|
Requires-Dist: tree-sitter-c-sharp>=0.23.1; extra == "serializers"
|
|
35
35
|
Requires-Dist: tree-sitter-go>=0.23.4; extra == "serializers"
|
|
36
|
+
Requires-Dist: tree-sitter-html>=0.23.2; extra == "serializers"
|
|
36
37
|
Requires-Dist: tree-sitter-java>=0.23.4; extra == "serializers"
|
|
37
38
|
Requires-Dist: tree-sitter-javascript>=0.23.1; extra == "serializers"
|
|
38
39
|
Requires-Dist: tree-sitter-json>=0.24.8; extra == "serializers"
|
|
39
40
|
Requires-Dist: tree-sitter-kotlin>=1.0.1; extra == "serializers"
|
|
40
|
-
Requires-Dist: tree-sitter-python>=0.23.4; extra == "serializers"
|
|
41
41
|
Requires-Dist: tree-sitter-php==0.23.11; extra == "serializers"
|
|
42
|
+
Requires-Dist: tree-sitter-python>=0.23.4; extra == "serializers"
|
|
42
43
|
Requires-Dist: tree-sitter-typescript>=0.23.2; extra == "serializers"
|
|
43
|
-
Requires-Dist: tree-sitter-yaml>=0.7.0; extra == "serializers"
|
|
44
|
-
Requires-Dist: tree-sitter-html>=0.23.2; extra == "serializers"
|
|
45
44
|
Requires-Dist: tree-sitter-xml>=0.7.0; extra == "serializers"
|
|
45
|
+
Requires-Dist: tree-sitter-yaml>=0.7.0; extra == "serializers"
|
|
46
|
+
Requires-Dist: tree-sitter>=0.25.2; extra == "serializers"
|
|
46
47
|
Provides-Extra: cpg
|
|
47
48
|
Requires-Dist: aioboto3>=13.3.0; extra == "cpg"
|
|
48
49
|
Requires-Dist: platformdirs>=4.3.8; extra == "cpg"
|
|
@@ -54,13 +55,13 @@ Provides-Extra: all
|
|
|
54
55
|
Requires-Dist: fluidattacks-core[aio]; extra == "all"
|
|
55
56
|
Requires-Dist: fluidattacks-core[authz]; extra == "all"
|
|
56
57
|
Requires-Dist: fluidattacks-core[bugsnag]; extra == "all"
|
|
58
|
+
Requires-Dist: fluidattacks-core[cpg]; extra == "all"
|
|
59
|
+
Requires-Dist: fluidattacks-core[filesystem]; extra == "all"
|
|
57
60
|
Requires-Dist: fluidattacks-core[git]; extra == "all"
|
|
58
61
|
Requires-Dist: fluidattacks-core[http]; extra == "all"
|
|
59
|
-
Requires-Dist: fluidattacks-core[serializers]; extra == "all"
|
|
60
|
-
Requires-Dist: fluidattacks-core[filesystem]; extra == "all"
|
|
61
|
-
Requires-Dist: fluidattacks-core[cpg]; extra == "all"
|
|
62
62
|
Requires-Dist: fluidattacks-core[sarif]; extra == "all"
|
|
63
63
|
Requires-Dist: fluidattacks-core[semver]; extra == "all"
|
|
64
|
+
Requires-Dist: fluidattacks-core[serializers]; extra == "all"
|
|
64
65
|
|
|
65
66
|
# Fluid Attacks Core Library
|
|
66
67
|
|
|
@@ -34,10 +34,10 @@ fluidattacks_core/http/validations.py,sha256=h10Hr906KJqda1rJJb8eOqk1Xyyz81lAJ1g
|
|
|
34
34
|
fluidattacks_core/logging/__init__.py,sha256=y6D12LrvrsMwaveQn5C4Em3RyeS6mP6E9fRpq7gqS4o,1546
|
|
35
35
|
fluidattacks_core/logging/filters.py,sha256=v03EWIbCGLKc6sdSQnO7ealxMdPzcJhd20rGr1PBZrE,388
|
|
36
36
|
fluidattacks_core/logging/formatters.py,sha256=SCA4k9XvHJknmkTv63uiCBU31VrWOsgA7llEXYYj1uQ,6063
|
|
37
|
-
fluidattacks_core/logging/handlers.py,sha256=
|
|
37
|
+
fluidattacks_core/logging/handlers.py,sha256=7fjCG0AqwlF0PRmH6MwkYRO1qdVoRjyYAAwML3A5lXY,4658
|
|
38
38
|
fluidattacks_core/logging/presets.py,sha256=KU6d6PI61kklJ_o7NgAzU1DahEPM0KwwjTYHo2naHv8,939
|
|
39
39
|
fluidattacks_core/logging/utils.py,sha256=jbAcwr0L6iPsId3dYEp-vAbtFex2UUU2l2iIk1F60BE,1115
|
|
40
|
-
fluidattacks_core/logging/sources/__init__.py,sha256=
|
|
40
|
+
fluidattacks_core/logging/sources/__init__.py,sha256=bUOsNhmBq9WHLvPxCW3G0Az4D8Wunp0mCCqEYlCsjsI,5937
|
|
41
41
|
fluidattacks_core/logging/sources/types.py,sha256=ial-ASN6e0EV7XeetDknjcMx_HjqL6ilFwzNwqw5YyY,338
|
|
42
42
|
fluidattacks_core/logging/sources/utils.py,sha256=tMoEVqrkVtqMuYtjgG6ih0HOjHyN3tn9G7nZhNoo6IU,1102
|
|
43
43
|
fluidattacks_core/sarif/__init__.py,sha256=vZkbzafVeqRPEc_dzq6oevZuNp50NNyNGa_eS0oNXnc,101519
|
|
@@ -46,7 +46,7 @@ fluidattacks_core/semver/match_versions.py,sha256=3L3C0TIVH0AtDpISvk5HHBXFSbJh5V
|
|
|
46
46
|
fluidattacks_core/serializers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
47
47
|
fluidattacks_core/serializers/snippet.py,sha256=e520pZHC-fsNuYVNY30A7TcSugvUlFL6xdr74j5aCDM,12780
|
|
48
48
|
fluidattacks_core/serializers/syntax.py,sha256=DkRsdMyMNrL0pRfsOSVAx79K8F0AmjBk676_d_v7PjM,15908
|
|
49
|
-
fluidattacks_core-4.
|
|
50
|
-
fluidattacks_core-4.
|
|
51
|
-
fluidattacks_core-4.
|
|
52
|
-
fluidattacks_core-4.
|
|
49
|
+
fluidattacks_core-4.3.0.dist-info/METADATA,sha256=g4N-6VQpds-l5_k99tEPNc5toW78Htw7gxmNtkdtbIQ,3248
|
|
50
|
+
fluidattacks_core-4.3.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
51
|
+
fluidattacks_core-4.3.0.dist-info/top_level.txt,sha256=m49ZyZ2zPQmDBxkSpjb20wr-ZbGVXdOMFBZrDiP5Lb8,18
|
|
52
|
+
fluidattacks_core-4.3.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|