fluidattacks-core 2.16.1__tar.gz → 3.0.0__tar.gz
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-2.16.1 → fluidattacks_core-3.0.0}/PKG-INFO +1 -1
- fluidattacks_core-3.0.0/fluidattacks_core/logging/__init__.py +44 -0
- {fluidattacks_core-2.16.1 → fluidattacks_core-3.0.0}/fluidattacks_core/logging/filters.py +1 -11
- {fluidattacks_core-2.16.1 → fluidattacks_core-3.0.0}/fluidattacks_core/logging/formatters.py +10 -7
- fluidattacks_core-3.0.0/fluidattacks_core/logging/presets.py +29 -0
- {fluidattacks_core-2.16.1 → fluidattacks_core-3.0.0}/fluidattacks_core/logging/utils.py +14 -2
- {fluidattacks_core-2.16.1 → fluidattacks_core-3.0.0}/fluidattacks_core.egg-info/PKG-INFO +1 -1
- {fluidattacks_core-2.16.1 → fluidattacks_core-3.0.0}/pyproject.toml +1 -1
- {fluidattacks_core-2.16.1 → fluidattacks_core-3.0.0}/test/test_logging.py +53 -13
- fluidattacks_core-2.16.1/fluidattacks_core/logging/__init__.py +0 -12
- fluidattacks_core-2.16.1/fluidattacks_core/logging/presets.py +0 -95
- {fluidattacks_core-2.16.1 → fluidattacks_core-3.0.0}/README.md +0 -0
- {fluidattacks_core-2.16.1 → fluidattacks_core-3.0.0}/fluidattacks_core/__init__.py +0 -0
- {fluidattacks_core-2.16.1 → fluidattacks_core-3.0.0}/fluidattacks_core/aio/__init__.py +0 -0
- {fluidattacks_core-2.16.1 → fluidattacks_core-3.0.0}/fluidattacks_core/aio/processes.py +0 -0
- {fluidattacks_core-2.16.1 → fluidattacks_core-3.0.0}/fluidattacks_core/aio/runners.py +0 -0
- {fluidattacks_core-2.16.1 → fluidattacks_core-3.0.0}/fluidattacks_core/aio/tasks.py +0 -0
- {fluidattacks_core-2.16.1 → fluidattacks_core-3.0.0}/fluidattacks_core/aio/threads.py +0 -0
- {fluidattacks_core-2.16.1 → fluidattacks_core-3.0.0}/fluidattacks_core/authz/__init__.py +0 -0
- {fluidattacks_core-2.16.1 → fluidattacks_core-3.0.0}/fluidattacks_core/authz/py.typed +0 -0
- {fluidattacks_core-2.16.1 → fluidattacks_core-3.0.0}/fluidattacks_core/authz/types.py +0 -0
- {fluidattacks_core-2.16.1 → fluidattacks_core-3.0.0}/fluidattacks_core/bugsnag/__init__.py +0 -0
- {fluidattacks_core-2.16.1 → fluidattacks_core-3.0.0}/fluidattacks_core/bugsnag/client.py +0 -0
- {fluidattacks_core-2.16.1 → fluidattacks_core-3.0.0}/fluidattacks_core/cpg/__init__.py +0 -0
- {fluidattacks_core-2.16.1 → fluidattacks_core-3.0.0}/fluidattacks_core/cpg/joern.py +0 -0
- {fluidattacks_core-2.16.1 → fluidattacks_core-3.0.0}/fluidattacks_core/filesystem/__init__.py +0 -0
- {fluidattacks_core-2.16.1 → fluidattacks_core-3.0.0}/fluidattacks_core/filesystem/defaults.py +0 -0
- {fluidattacks_core-2.16.1 → fluidattacks_core-3.0.0}/fluidattacks_core/git/__init__.py +0 -0
- {fluidattacks_core-2.16.1 → fluidattacks_core-3.0.0}/fluidattacks_core/git/classes.py +0 -0
- {fluidattacks_core-2.16.1 → fluidattacks_core-3.0.0}/fluidattacks_core/git/clone.py +0 -0
- {fluidattacks_core-2.16.1 → fluidattacks_core-3.0.0}/fluidattacks_core/git/codecommit_utils.py +0 -0
- {fluidattacks_core-2.16.1 → fluidattacks_core-3.0.0}/fluidattacks_core/git/constants.py +0 -0
- {fluidattacks_core-2.16.1 → fluidattacks_core-3.0.0}/fluidattacks_core/git/delete_files.py +0 -0
- {fluidattacks_core-2.16.1 → fluidattacks_core-3.0.0}/fluidattacks_core/git/download_file.py +0 -0
- {fluidattacks_core-2.16.1 → fluidattacks_core-3.0.0}/fluidattacks_core/git/download_repo.py +0 -0
- {fluidattacks_core-2.16.1 → fluidattacks_core-3.0.0}/fluidattacks_core/git/https_utils.py +0 -0
- {fluidattacks_core-2.16.1 → fluidattacks_core-3.0.0}/fluidattacks_core/git/py.typed +0 -0
- {fluidattacks_core-2.16.1 → fluidattacks_core-3.0.0}/fluidattacks_core/git/remote.py +0 -0
- {fluidattacks_core-2.16.1 → fluidattacks_core-3.0.0}/fluidattacks_core/git/ssh_utils.py +0 -0
- {fluidattacks_core-2.16.1 → fluidattacks_core-3.0.0}/fluidattacks_core/git/utils.py +0 -0
- {fluidattacks_core-2.16.1 → fluidattacks_core-3.0.0}/fluidattacks_core/git/warp.py +0 -0
- {fluidattacks_core-2.16.1 → fluidattacks_core-3.0.0}/fluidattacks_core/http/__init__.py +0 -0
- {fluidattacks_core-2.16.1 → fluidattacks_core-3.0.0}/fluidattacks_core/http/client.py +0 -0
- {fluidattacks_core-2.16.1 → fluidattacks_core-3.0.0}/fluidattacks_core/http/validations.py +0 -0
- {fluidattacks_core-2.16.1 → fluidattacks_core-3.0.0}/fluidattacks_core/logging/handlers.py +0 -0
- {fluidattacks_core-2.16.1 → fluidattacks_core-3.0.0}/fluidattacks_core/logging/types.py +0 -0
- {fluidattacks_core-2.16.1 → fluidattacks_core-3.0.0}/fluidattacks_core/py.typed +0 -0
- {fluidattacks_core-2.16.1 → fluidattacks_core-3.0.0}/fluidattacks_core/sarif/__init__.py +0 -0
- {fluidattacks_core-2.16.1 → fluidattacks_core-3.0.0}/fluidattacks_core/semver/__init__.py +0 -0
- {fluidattacks_core-2.16.1 → fluidattacks_core-3.0.0}/fluidattacks_core/semver/match_versions.py +0 -0
- {fluidattacks_core-2.16.1 → fluidattacks_core-3.0.0}/fluidattacks_core/serializers/__init__.py +0 -0
- {fluidattacks_core-2.16.1 → fluidattacks_core-3.0.0}/fluidattacks_core/serializers/snippet.py +0 -0
- {fluidattacks_core-2.16.1 → fluidattacks_core-3.0.0}/fluidattacks_core/serializers/syntax.py +0 -0
- {fluidattacks_core-2.16.1 → fluidattacks_core-3.0.0}/fluidattacks_core.egg-info/SOURCES.txt +0 -0
- {fluidattacks_core-2.16.1 → fluidattacks_core-3.0.0}/fluidattacks_core.egg-info/dependency_links.txt +0 -0
- {fluidattacks_core-2.16.1 → fluidattacks_core-3.0.0}/fluidattacks_core.egg-info/requires.txt +0 -0
- {fluidattacks_core-2.16.1 → fluidattacks_core-3.0.0}/fluidattacks_core.egg-info/top_level.txt +0 -0
- {fluidattacks_core-2.16.1 → fluidattacks_core-3.0.0}/setup.cfg +0 -0
- {fluidattacks_core-2.16.1 → fluidattacks_core-3.0.0}/test/test_aio_tasks.py +0 -0
- {fluidattacks_core-2.16.1 → fluidattacks_core-3.0.0}/test/test_extract_db.py +0 -0
- {fluidattacks_core-2.16.1 → fluidattacks_core-3.0.0}/test/test_language_detection.py +0 -0
- {fluidattacks_core-2.16.1 → fluidattacks_core-3.0.0}/test/test_make_snippet.py +0 -0
- {fluidattacks_core-2.16.1 → fluidattacks_core-3.0.0}/test/test_match_versions.py +0 -0
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
import logging.config
|
|
3
|
+
import sys
|
|
4
|
+
from types import TracebackType
|
|
5
|
+
|
|
6
|
+
from fluidattacks_core.logging.presets import DATE_FORMAT, PRODUCT_LOGGING
|
|
7
|
+
from fluidattacks_core.logging.types import JobMetadata
|
|
8
|
+
from fluidattacks_core.logging.utils import get_job_metadata, set_telemetry_metadata
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def init_uncaught_exception_logging() -> None:
|
|
12
|
+
logger = logging.getLogger("unhandled")
|
|
13
|
+
|
|
14
|
+
def handle_uncaught_exception(
|
|
15
|
+
exception_type: type[BaseException],
|
|
16
|
+
msg: BaseException,
|
|
17
|
+
traceback: TracebackType | None,
|
|
18
|
+
) -> None:
|
|
19
|
+
if issubclass(exception_type, KeyboardInterrupt):
|
|
20
|
+
sys.__excepthook__(exception_type, msg, traceback)
|
|
21
|
+
return
|
|
22
|
+
|
|
23
|
+
logger.critical(
|
|
24
|
+
"Uncaught exception",
|
|
25
|
+
exc_info=(exception_type, msg, traceback),
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
sys.excepthook = handle_uncaught_exception
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def init_logging() -> None:
|
|
32
|
+
logging.config.dictConfig(PRODUCT_LOGGING)
|
|
33
|
+
init_uncaught_exception_logging()
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
__all__ = [
|
|
37
|
+
"DATE_FORMAT",
|
|
38
|
+
"PRODUCT_LOGGING",
|
|
39
|
+
"JobMetadata",
|
|
40
|
+
"get_job_metadata",
|
|
41
|
+
"init_logging",
|
|
42
|
+
"init_uncaught_exception_logging",
|
|
43
|
+
"set_telemetry_metadata",
|
|
44
|
+
]
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import logging
|
|
2
2
|
|
|
3
|
-
from fluidattacks_core.logging.utils import
|
|
3
|
+
from fluidattacks_core.logging.utils import is_trunk_branch
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
class NoProductionFilter(logging.Filter):
|
|
@@ -15,13 +15,3 @@ class ProductionOnlyFilter(logging.Filter):
|
|
|
15
15
|
|
|
16
16
|
def filter(self, _record: logging.LogRecord) -> bool:
|
|
17
17
|
return is_trunk_branch()
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
class BatchOnlyFilter(logging.Filter):
|
|
21
|
-
def filter(self, _record: logging.LogRecord) -> bool:
|
|
22
|
-
return get_job_metadata().job_id is not None
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
class NoBatchFilter(logging.Filter):
|
|
26
|
-
def filter(self, _record: logging.LogRecord) -> bool:
|
|
27
|
-
return get_job_metadata().job_id is None
|
{fluidattacks_core-2.16.1 → fluidattacks_core-3.0.0}/fluidattacks_core/logging/formatters.py
RENAMED
|
@@ -13,6 +13,8 @@ from fluidattacks_core.logging.utils import (
|
|
|
13
13
|
get_pipeline_environment,
|
|
14
14
|
get_pipeline_metadata,
|
|
15
15
|
get_telemetry_metadata,
|
|
16
|
+
is_in_batch,
|
|
17
|
+
is_in_lambda,
|
|
16
18
|
)
|
|
17
19
|
|
|
18
20
|
# Main formats
|
|
@@ -101,19 +103,20 @@ class CustomJsonFormatter(JsonFormatter):
|
|
|
101
103
|
"""Add service information to the log record.
|
|
102
104
|
|
|
103
105
|
It includes:
|
|
106
|
+
- Source
|
|
107
|
+
- Service
|
|
104
108
|
- Version
|
|
105
|
-
- Product name
|
|
106
109
|
"""
|
|
107
110
|
batch_info = get_job_metadata().job_queue
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
+
source = (
|
|
112
|
+
f"batch/{batch_info}" if is_in_batch() else "lambda" if is_in_lambda() else "python"
|
|
113
|
+
)
|
|
114
|
+
service = get_environment_metadata().product_id
|
|
111
115
|
version = get_environment_metadata().version
|
|
112
116
|
|
|
113
|
-
log_record["
|
|
114
|
-
log_record["service.version"] = version
|
|
117
|
+
log_record["ddsource"] = source
|
|
115
118
|
log_record["dd.service"] = service
|
|
116
|
-
log_record["
|
|
119
|
+
log_record["dd.version"] = version
|
|
117
120
|
|
|
118
121
|
def _add_deployment_fields(self, log_record: dict[str, Any]) -> None:
|
|
119
122
|
"""Add deployment information to the log record.
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
from fluidattacks_core.logging.handlers import DebuggingHandler, ProductionSyncHandler
|
|
2
|
+
|
|
3
|
+
# Main formats
|
|
4
|
+
DATE_FORMAT = "%Y-%m-%dT%H:%M:%S%z"
|
|
5
|
+
"""
|
|
6
|
+
Default date format for logs.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
PRODUCT_LOGGING = {
|
|
11
|
+
"version": 1,
|
|
12
|
+
"disable_existing_loggers": False,
|
|
13
|
+
"handlers": {
|
|
14
|
+
"production_handler": {"()": ProductionSyncHandler},
|
|
15
|
+
"debugging_handler": {"()": DebuggingHandler},
|
|
16
|
+
},
|
|
17
|
+
"root": {
|
|
18
|
+
"handlers": ["production_handler", "debugging_handler"],
|
|
19
|
+
"level": "INFO",
|
|
20
|
+
},
|
|
21
|
+
}
|
|
22
|
+
"""
|
|
23
|
+
Default logging configuration dict for all the products.
|
|
24
|
+
|
|
25
|
+
Required environment variables:
|
|
26
|
+
- `PRODUCT_ID`
|
|
27
|
+
- `CI_COMMIT_REF_NAME`
|
|
28
|
+
- `CI_COMMIT_SHA`
|
|
29
|
+
"""
|
|
@@ -10,10 +10,20 @@ DEFAULT_TELEMETRY_METADATA = {}
|
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
def is_trunk_branch() -> bool:
|
|
13
|
-
"""Check if code is using the trunk branch."""
|
|
13
|
+
"""Check if the code is using the trunk branch."""
|
|
14
14
|
return os.environ.get("CI_COMMIT_REF_NAME", "default") == "trunk"
|
|
15
15
|
|
|
16
16
|
|
|
17
|
+
def is_in_batch() -> bool:
|
|
18
|
+
"""Check if the code is running in a batch environment."""
|
|
19
|
+
return os.environ.get("AWS_BATCH_JOB_ID") is not None
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def is_in_lambda() -> bool:
|
|
23
|
+
"""Check if the code is running in an AWS Lambda function."""
|
|
24
|
+
return os.environ.get("AWS_LAMBDA_FUNCTION_NAME") is not None
|
|
25
|
+
|
|
26
|
+
|
|
17
27
|
def get_job_metadata() -> JobMetadata:
|
|
18
28
|
"""Get the job metadata for applications running in batch environments."""
|
|
19
29
|
return JobMetadata(
|
|
@@ -26,7 +36,9 @@ def get_job_metadata() -> JobMetadata:
|
|
|
26
36
|
def get_environment_metadata() -> EnvironmentMetadata:
|
|
27
37
|
"""Get the environment metadata for applications."""
|
|
28
38
|
environment = "production" if is_trunk_branch() else "development"
|
|
29
|
-
product_id =
|
|
39
|
+
product_id = (
|
|
40
|
+
os.environ.get("AWS_LAMBDA_FUNCTION_NAME") or os.environ.get("PRODUCT_ID") or "universe"
|
|
41
|
+
)
|
|
30
42
|
commit_sha = os.environ.get("CI_COMMIT_SHA", "00000000")
|
|
31
43
|
commit_short_sha = commit_sha[:8]
|
|
32
44
|
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import logging
|
|
2
|
-
import
|
|
2
|
+
import sys
|
|
3
3
|
|
|
4
4
|
import pytest
|
|
5
5
|
import simplejson as json
|
|
6
6
|
|
|
7
|
-
from fluidattacks_core.logging import
|
|
7
|
+
from fluidattacks_core.logging import init_logging
|
|
8
8
|
from fluidattacks_core.logging.utils import set_telemetry_metadata
|
|
9
9
|
|
|
10
10
|
|
|
@@ -17,14 +17,23 @@ def _developer_setup(monkeypatch: pytest.MonkeyPatch) -> None:
|
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
@pytest.mark.parametrize(
|
|
20
|
-
"product_id, job_id, queue_name, expected_service_name", # noqa: PT006
|
|
20
|
+
"product_id, job_id, queue_name, lambda_name, expected_source, expected_service_name", # noqa: PT006
|
|
21
21
|
[
|
|
22
22
|
# Interacts running in EC2
|
|
23
|
-
("interacts", None, None, "interacts"),
|
|
23
|
+
("interacts", None, None, None, "python", "interacts"),
|
|
24
24
|
# Labels running in a Batch Job
|
|
25
|
-
("labels", "111", "skims", "
|
|
25
|
+
("labels", "111", "skims", None, "batch/skims", "labels"),
|
|
26
26
|
# Integrates scheduler running in a Batch Job
|
|
27
|
-
("integrates", "111", "integrates_large", "
|
|
27
|
+
("integrates", "111", "integrates_large", None, "batch/integrates_large", "integrates"),
|
|
28
|
+
# Lambda function
|
|
29
|
+
(
|
|
30
|
+
None,
|
|
31
|
+
None,
|
|
32
|
+
None,
|
|
33
|
+
"integrates_streams_hooks",
|
|
34
|
+
"lambda",
|
|
35
|
+
"integrates_streams_hooks",
|
|
36
|
+
),
|
|
28
37
|
],
|
|
29
38
|
)
|
|
30
39
|
def test_json_formatter_uses_envs_to_fill_keys( # noqa: PLR0913
|
|
@@ -33,16 +42,21 @@ def test_json_formatter_uses_envs_to_fill_keys( # noqa: PLR0913
|
|
|
33
42
|
product_id: str,
|
|
34
43
|
job_id: str,
|
|
35
44
|
queue_name: str,
|
|
45
|
+
lambda_name: str,
|
|
46
|
+
expected_source: str,
|
|
36
47
|
expected_service_name: str,
|
|
37
48
|
) -> None:
|
|
38
49
|
_production_setup(monkeypatch)
|
|
39
|
-
|
|
50
|
+
if product_id is not None:
|
|
51
|
+
monkeypatch.setenv("PRODUCT_ID", product_id)
|
|
40
52
|
if job_id is not None:
|
|
41
53
|
monkeypatch.setenv("AWS_BATCH_JOB_ID", job_id)
|
|
42
54
|
if queue_name is not None:
|
|
43
55
|
monkeypatch.setenv("AWS_BATCH_JQ_NAME", queue_name)
|
|
56
|
+
if lambda_name is not None:
|
|
57
|
+
monkeypatch.setenv("AWS_LAMBDA_FUNCTION_NAME", lambda_name)
|
|
44
58
|
|
|
45
|
-
|
|
59
|
+
init_logging()
|
|
46
60
|
logger = logging.getLogger("product")
|
|
47
61
|
|
|
48
62
|
logger.critical("A critical message")
|
|
@@ -50,17 +64,43 @@ def test_json_formatter_uses_envs_to_fill_keys( # noqa: PLR0913
|
|
|
50
64
|
output = capsys.readouterr()
|
|
51
65
|
log_entry = json.loads(output.err)
|
|
52
66
|
|
|
53
|
-
assert log_entry["
|
|
67
|
+
assert log_entry["ddsource"] == expected_source
|
|
54
68
|
assert log_entry["dd.service"] == expected_service_name
|
|
55
69
|
|
|
56
70
|
|
|
71
|
+
def test_uncaught_exception_logging(
|
|
72
|
+
monkeypatch: pytest.MonkeyPatch,
|
|
73
|
+
capsys: pytest.CaptureFixture[str],
|
|
74
|
+
) -> None:
|
|
75
|
+
_production_setup(monkeypatch)
|
|
76
|
+
monkeypatch.setenv("PRODUCT_ID", "universe")
|
|
77
|
+
|
|
78
|
+
init_logging()
|
|
79
|
+
|
|
80
|
+
error = ValueError("This is an uncaught exception")
|
|
81
|
+
|
|
82
|
+
# Simulate an uncaught exception
|
|
83
|
+
sys.excepthook(error.__class__, error, error.__traceback__)
|
|
84
|
+
|
|
85
|
+
output = capsys.readouterr()
|
|
86
|
+
log_entry = json.loads(output.err)
|
|
87
|
+
|
|
88
|
+
assert log_entry["ddsource"] == "python"
|
|
89
|
+
assert log_entry["dd.service"] == "universe"
|
|
90
|
+
|
|
91
|
+
assert log_entry["name"] == "unhandled"
|
|
92
|
+
assert log_entry["level"] == "CRITICAL"
|
|
93
|
+
assert log_entry["error.type"] == "ValueError"
|
|
94
|
+
assert log_entry["error.message"] == "This is an uncaught exception"
|
|
95
|
+
|
|
96
|
+
|
|
57
97
|
def test_json_formatter_adds_keys_for_exception(
|
|
58
98
|
monkeypatch: pytest.MonkeyPatch,
|
|
59
99
|
capsys: pytest.CaptureFixture[str],
|
|
60
100
|
) -> None:
|
|
61
101
|
_production_setup(monkeypatch)
|
|
62
102
|
|
|
63
|
-
|
|
103
|
+
init_logging()
|
|
64
104
|
logger = logging.getLogger("product")
|
|
65
105
|
|
|
66
106
|
try:
|
|
@@ -86,7 +126,7 @@ def test_json_formatter_adds_keys_with_extra_fields(
|
|
|
86
126
|
) -> None:
|
|
87
127
|
_production_setup(monkeypatch)
|
|
88
128
|
|
|
89
|
-
|
|
129
|
+
init_logging()
|
|
90
130
|
logger = logging.getLogger("product")
|
|
91
131
|
|
|
92
132
|
logger.info("A info message", extra={"trace_id": "111", "span_id": "222", "other.tag": "val"})
|
|
@@ -105,7 +145,7 @@ def test_json_formatter_adds_telemetry_metadata(
|
|
|
105
145
|
) -> None:
|
|
106
146
|
_production_setup(monkeypatch)
|
|
107
147
|
|
|
108
|
-
|
|
148
|
+
init_logging()
|
|
109
149
|
logger = logging.getLogger("product")
|
|
110
150
|
set_telemetry_metadata({"trace_id": "111", "span_id": "222", "other.tag": "val"})
|
|
111
151
|
|
|
@@ -125,7 +165,7 @@ def test_colorful_formatter_uses_colors_for_warning(
|
|
|
125
165
|
) -> None:
|
|
126
166
|
_developer_setup(monkeypatch)
|
|
127
167
|
|
|
128
|
-
|
|
168
|
+
init_logging()
|
|
129
169
|
logger = logging.getLogger("product")
|
|
130
170
|
|
|
131
171
|
logger.warning("A warning message")
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
from fluidattacks_core.logging.presets import BATCH_LOGGING, DATE_FORMAT, PRODUCT_LOGGING
|
|
2
|
-
from fluidattacks_core.logging.types import JobMetadata
|
|
3
|
-
from fluidattacks_core.logging.utils import get_job_metadata, set_telemetry_metadata
|
|
4
|
-
|
|
5
|
-
__all__ = [
|
|
6
|
-
"BATCH_LOGGING",
|
|
7
|
-
"DATE_FORMAT",
|
|
8
|
-
"PRODUCT_LOGGING",
|
|
9
|
-
"JobMetadata",
|
|
10
|
-
"get_job_metadata",
|
|
11
|
-
"set_telemetry_metadata",
|
|
12
|
-
]
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
from fluidattacks_core.logging.filters import BatchOnlyFilter, NoBatchFilter
|
|
2
|
-
from fluidattacks_core.logging.formatters import ColorfulFormatter
|
|
3
|
-
from fluidattacks_core.logging.handlers import DebuggingHandler, ProductionSyncHandler
|
|
4
|
-
from fluidattacks_core.logging.utils import get_environment_metadata, get_job_metadata
|
|
5
|
-
|
|
6
|
-
# Main formats
|
|
7
|
-
DATE_FORMAT = "%Y-%m-%dT%H:%M:%S%z"
|
|
8
|
-
"""
|
|
9
|
-
Default date format for logs.
|
|
10
|
-
"""
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
# Configuration for logging in batch environments
|
|
14
|
-
_JOB_METADATA = get_job_metadata()
|
|
15
|
-
_ENVIRONMENT_METADATA = get_environment_metadata()
|
|
16
|
-
|
|
17
|
-
BATCH_LOGGING = {
|
|
18
|
-
"version": 1,
|
|
19
|
-
"disable_existing_loggers": False,
|
|
20
|
-
"filters": {
|
|
21
|
-
"batch_only": {"()": BatchOnlyFilter},
|
|
22
|
-
"no_batch": {"()": NoBatchFilter},
|
|
23
|
-
},
|
|
24
|
-
"formatters": {
|
|
25
|
-
"one_line_format": {
|
|
26
|
-
"class": "logging.Formatter",
|
|
27
|
-
"format": (
|
|
28
|
-
"{asctime} {levelname} [{name}] [{filename}:{lineno}] "
|
|
29
|
-
"[trace_id=None span_id=None "
|
|
30
|
-
f"service.name=batch/{_JOB_METADATA.job_queue} "
|
|
31
|
-
f"service.version={_ENVIRONMENT_METADATA.version} "
|
|
32
|
-
f"deployment.environment={_ENVIRONMENT_METADATA.environment} "
|
|
33
|
-
"trace_sampled=False]"
|
|
34
|
-
" - {message}, extra=None"
|
|
35
|
-
),
|
|
36
|
-
"datefmt": DATE_FORMAT,
|
|
37
|
-
"style": "{",
|
|
38
|
-
},
|
|
39
|
-
"simple_format": {
|
|
40
|
-
"class": "logging.Formatter",
|
|
41
|
-
"format": "{asctime} [{levelname}] [{name}] {message}",
|
|
42
|
-
"datefmt": DATE_FORMAT,
|
|
43
|
-
"style": "{",
|
|
44
|
-
},
|
|
45
|
-
"colorful_format": {
|
|
46
|
-
"()": ColorfulFormatter,
|
|
47
|
-
"datefmt": DATE_FORMAT,
|
|
48
|
-
"style": "{",
|
|
49
|
-
},
|
|
50
|
-
},
|
|
51
|
-
"handlers": {
|
|
52
|
-
"batch_handler": {
|
|
53
|
-
"class": "logging.StreamHandler",
|
|
54
|
-
"stream": "ext://sys.stdout",
|
|
55
|
-
"formatter": "one_line_format",
|
|
56
|
-
"filters": ["batch_only"],
|
|
57
|
-
},
|
|
58
|
-
"console_handler": {
|
|
59
|
-
"class": "logging.StreamHandler",
|
|
60
|
-
"stream": "ext://sys.stdout",
|
|
61
|
-
"formatter": "colorful_format",
|
|
62
|
-
"filters": ["no_batch"],
|
|
63
|
-
},
|
|
64
|
-
},
|
|
65
|
-
"root": {
|
|
66
|
-
"handlers": ["batch_handler", "console_handler"],
|
|
67
|
-
"level": "INFO",
|
|
68
|
-
},
|
|
69
|
-
}
|
|
70
|
-
"""
|
|
71
|
-
Logging configuration dict for batch environments.
|
|
72
|
-
|
|
73
|
-
Root logger will have two handlers for batch and non-batch environments.
|
|
74
|
-
"""
|
|
75
|
-
|
|
76
|
-
PRODUCT_LOGGING = {
|
|
77
|
-
"version": 1,
|
|
78
|
-
"disable_existing_loggers": False,
|
|
79
|
-
"handlers": {
|
|
80
|
-
"production_handler": {"()": ProductionSyncHandler},
|
|
81
|
-
"debugging_handler": {"()": DebuggingHandler},
|
|
82
|
-
},
|
|
83
|
-
"root": {
|
|
84
|
-
"handlers": ["production_handler", "debugging_handler"],
|
|
85
|
-
"level": "INFO",
|
|
86
|
-
},
|
|
87
|
-
}
|
|
88
|
-
"""
|
|
89
|
-
Default logging configuration dict for all the products.
|
|
90
|
-
|
|
91
|
-
Required environment variables:
|
|
92
|
-
- `PRODUCT_ID`
|
|
93
|
-
- `CI_COMMIT_REF_NAME`
|
|
94
|
-
- `CI_COMMIT_SHA`
|
|
95
|
-
"""
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{fluidattacks_core-2.16.1 → fluidattacks_core-3.0.0}/fluidattacks_core/filesystem/__init__.py
RENAMED
|
File without changes
|
{fluidattacks_core-2.16.1 → fluidattacks_core-3.0.0}/fluidattacks_core/filesystem/defaults.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{fluidattacks_core-2.16.1 → fluidattacks_core-3.0.0}/fluidattacks_core/git/codecommit_utils.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{fluidattacks_core-2.16.1 → fluidattacks_core-3.0.0}/fluidattacks_core/semver/match_versions.py
RENAMED
|
File without changes
|
{fluidattacks_core-2.16.1 → fluidattacks_core-3.0.0}/fluidattacks_core/serializers/__init__.py
RENAMED
|
File without changes
|
{fluidattacks_core-2.16.1 → fluidattacks_core-3.0.0}/fluidattacks_core/serializers/snippet.py
RENAMED
|
File without changes
|
{fluidattacks_core-2.16.1 → fluidattacks_core-3.0.0}/fluidattacks_core/serializers/syntax.py
RENAMED
|
File without changes
|
|
File without changes
|
{fluidattacks_core-2.16.1 → fluidattacks_core-3.0.0}/fluidattacks_core.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
{fluidattacks_core-2.16.1 → fluidattacks_core-3.0.0}/fluidattacks_core.egg-info/requires.txt
RENAMED
|
File without changes
|
{fluidattacks_core-2.16.1 → fluidattacks_core-3.0.0}/fluidattacks_core.egg-info/top_level.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|