fluidattacks-core 4.1.0__tar.gz → 4.2.1__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.
Files changed (64) hide show
  1. {fluidattacks_core-4.1.0 → fluidattacks_core-4.2.1}/PKG-INFO +1 -1
  2. {fluidattacks_core-4.1.0 → fluidattacks_core-4.2.1}/fluidattacks_core/logging/__init__.py +4 -0
  3. {fluidattacks_core-4.1.0 → fluidattacks_core-4.2.1}/fluidattacks_core/logging/handlers.py +19 -2
  4. {fluidattacks_core-4.1.0 → fluidattacks_core-4.2.1}/fluidattacks_core/logging/sources/__init__.py +10 -3
  5. fluidattacks_core-4.2.1/fluidattacks_core/logging/sources/utils.py +37 -0
  6. {fluidattacks_core-4.1.0 → fluidattacks_core-4.2.1}/fluidattacks_core.egg-info/PKG-INFO +1 -1
  7. {fluidattacks_core-4.1.0 → fluidattacks_core-4.2.1}/pyproject.toml +1 -1
  8. fluidattacks_core-4.1.0/fluidattacks_core/logging/sources/utils.py +0 -27
  9. {fluidattacks_core-4.1.0 → fluidattacks_core-4.2.1}/README.md +0 -0
  10. {fluidattacks_core-4.1.0 → fluidattacks_core-4.2.1}/fluidattacks_core/__init__.py +0 -0
  11. {fluidattacks_core-4.1.0 → fluidattacks_core-4.2.1}/fluidattacks_core/aio/__init__.py +0 -0
  12. {fluidattacks_core-4.1.0 → fluidattacks_core-4.2.1}/fluidattacks_core/aio/processes.py +0 -0
  13. {fluidattacks_core-4.1.0 → fluidattacks_core-4.2.1}/fluidattacks_core/aio/runners.py +0 -0
  14. {fluidattacks_core-4.1.0 → fluidattacks_core-4.2.1}/fluidattacks_core/aio/tasks.py +0 -0
  15. {fluidattacks_core-4.1.0 → fluidattacks_core-4.2.1}/fluidattacks_core/aio/threads.py +0 -0
  16. {fluidattacks_core-4.1.0 → fluidattacks_core-4.2.1}/fluidattacks_core/authz/__init__.py +0 -0
  17. {fluidattacks_core-4.1.0 → fluidattacks_core-4.2.1}/fluidattacks_core/authz/py.typed +0 -0
  18. {fluidattacks_core-4.1.0 → fluidattacks_core-4.2.1}/fluidattacks_core/authz/types.py +0 -0
  19. {fluidattacks_core-4.1.0 → fluidattacks_core-4.2.1}/fluidattacks_core/bugsnag/__init__.py +0 -0
  20. {fluidattacks_core-4.1.0 → fluidattacks_core-4.2.1}/fluidattacks_core/bugsnag/client.py +0 -0
  21. {fluidattacks_core-4.1.0 → fluidattacks_core-4.2.1}/fluidattacks_core/cpg/__init__.py +0 -0
  22. {fluidattacks_core-4.1.0 → fluidattacks_core-4.2.1}/fluidattacks_core/cpg/joern.py +0 -0
  23. {fluidattacks_core-4.1.0 → fluidattacks_core-4.2.1}/fluidattacks_core/filesystem/__init__.py +0 -0
  24. {fluidattacks_core-4.1.0 → fluidattacks_core-4.2.1}/fluidattacks_core/filesystem/defaults.py +0 -0
  25. {fluidattacks_core-4.1.0 → fluidattacks_core-4.2.1}/fluidattacks_core/git/__init__.py +0 -0
  26. {fluidattacks_core-4.1.0 → fluidattacks_core-4.2.1}/fluidattacks_core/git/classes.py +0 -0
  27. {fluidattacks_core-4.1.0 → fluidattacks_core-4.2.1}/fluidattacks_core/git/clone.py +0 -0
  28. {fluidattacks_core-4.1.0 → fluidattacks_core-4.2.1}/fluidattacks_core/git/codecommit_utils.py +0 -0
  29. {fluidattacks_core-4.1.0 → fluidattacks_core-4.2.1}/fluidattacks_core/git/constants.py +0 -0
  30. {fluidattacks_core-4.1.0 → fluidattacks_core-4.2.1}/fluidattacks_core/git/delete_files.py +0 -0
  31. {fluidattacks_core-4.1.0 → fluidattacks_core-4.2.1}/fluidattacks_core/git/download_file.py +0 -0
  32. {fluidattacks_core-4.1.0 → fluidattacks_core-4.2.1}/fluidattacks_core/git/download_repo.py +0 -0
  33. {fluidattacks_core-4.1.0 → fluidattacks_core-4.2.1}/fluidattacks_core/git/https_utils.py +0 -0
  34. {fluidattacks_core-4.1.0 → fluidattacks_core-4.2.1}/fluidattacks_core/git/py.typed +0 -0
  35. {fluidattacks_core-4.1.0 → fluidattacks_core-4.2.1}/fluidattacks_core/git/remote.py +0 -0
  36. {fluidattacks_core-4.1.0 → fluidattacks_core-4.2.1}/fluidattacks_core/git/ssh_utils.py +0 -0
  37. {fluidattacks_core-4.1.0 → fluidattacks_core-4.2.1}/fluidattacks_core/git/utils.py +0 -0
  38. {fluidattacks_core-4.1.0 → fluidattacks_core-4.2.1}/fluidattacks_core/git/warp.py +0 -0
  39. {fluidattacks_core-4.1.0 → fluidattacks_core-4.2.1}/fluidattacks_core/http/__init__.py +0 -0
  40. {fluidattacks_core-4.1.0 → fluidattacks_core-4.2.1}/fluidattacks_core/http/client.py +0 -0
  41. {fluidattacks_core-4.1.0 → fluidattacks_core-4.2.1}/fluidattacks_core/http/validations.py +0 -0
  42. {fluidattacks_core-4.1.0 → fluidattacks_core-4.2.1}/fluidattacks_core/logging/filters.py +0 -0
  43. {fluidattacks_core-4.1.0 → fluidattacks_core-4.2.1}/fluidattacks_core/logging/formatters.py +0 -0
  44. {fluidattacks_core-4.1.0 → fluidattacks_core-4.2.1}/fluidattacks_core/logging/presets.py +0 -0
  45. {fluidattacks_core-4.1.0 → fluidattacks_core-4.2.1}/fluidattacks_core/logging/sources/types.py +0 -0
  46. {fluidattacks_core-4.1.0 → fluidattacks_core-4.2.1}/fluidattacks_core/logging/utils.py +0 -0
  47. {fluidattacks_core-4.1.0 → fluidattacks_core-4.2.1}/fluidattacks_core/py.typed +0 -0
  48. {fluidattacks_core-4.1.0 → fluidattacks_core-4.2.1}/fluidattacks_core/sarif/__init__.py +0 -0
  49. {fluidattacks_core-4.1.0 → fluidattacks_core-4.2.1}/fluidattacks_core/semver/__init__.py +0 -0
  50. {fluidattacks_core-4.1.0 → fluidattacks_core-4.2.1}/fluidattacks_core/semver/match_versions.py +0 -0
  51. {fluidattacks_core-4.1.0 → fluidattacks_core-4.2.1}/fluidattacks_core/serializers/__init__.py +0 -0
  52. {fluidattacks_core-4.1.0 → fluidattacks_core-4.2.1}/fluidattacks_core/serializers/snippet.py +0 -0
  53. {fluidattacks_core-4.1.0 → fluidattacks_core-4.2.1}/fluidattacks_core/serializers/syntax.py +0 -0
  54. {fluidattacks_core-4.1.0 → fluidattacks_core-4.2.1}/fluidattacks_core.egg-info/SOURCES.txt +0 -0
  55. {fluidattacks_core-4.1.0 → fluidattacks_core-4.2.1}/fluidattacks_core.egg-info/dependency_links.txt +0 -0
  56. {fluidattacks_core-4.1.0 → fluidattacks_core-4.2.1}/fluidattacks_core.egg-info/requires.txt +0 -0
  57. {fluidattacks_core-4.1.0 → fluidattacks_core-4.2.1}/fluidattacks_core.egg-info/top_level.txt +0 -0
  58. {fluidattacks_core-4.1.0 → fluidattacks_core-4.2.1}/setup.cfg +0 -0
  59. {fluidattacks_core-4.1.0 → fluidattacks_core-4.2.1}/test/test_aio_tasks.py +0 -0
  60. {fluidattacks_core-4.1.0 → fluidattacks_core-4.2.1}/test/test_extract_db.py +0 -0
  61. {fluidattacks_core-4.1.0 → fluidattacks_core-4.2.1}/test/test_language_detection.py +0 -0
  62. {fluidattacks_core-4.1.0 → fluidattacks_core-4.2.1}/test/test_logging.py +0 -0
  63. {fluidattacks_core-4.1.0 → fluidattacks_core-4.2.1}/test/test_make_snippet.py +0 -0
  64. {fluidattacks_core-4.1.0 → fluidattacks_core-4.2.1}/test/test_match_versions.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fluidattacks-core
3
- Version: 4.1.0
3
+ Version: 4.2.1
4
4
  Summary: Fluid Attacks Core Library
5
5
  Author-email: Development <development@fluidattacks.com>
6
6
  License: MPL-2.0
@@ -9,7 +9,9 @@ from fluidattacks_core.logging.presets import DATE_FORMAT, PRODUCT_LOGGING
9
9
  from fluidattacks_core.logging.sources.utils import (
10
10
  set_commit_ref_name,
11
11
  set_commit_sha,
12
+ set_product_environment,
12
13
  set_product_id,
14
+ set_product_version,
13
15
  )
14
16
  from fluidattacks_core.logging.utils import set_telemetry_metadata
15
17
 
@@ -50,6 +52,8 @@ __all__ = [
50
52
  "init_uncaught_exception_logging",
51
53
  "set_commit_ref_name",
52
54
  "set_commit_sha",
55
+ "set_product_environment",
53
56
  "set_product_id",
57
+ "set_product_version",
54
58
  "set_telemetry_metadata",
55
59
  ]
@@ -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(QueueHandler):
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(QueueHandler):
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:
@@ -39,10 +39,13 @@ class BatchSource(SourceStrategy):
39
39
 
40
40
  @staticmethod
41
41
  def log_metadata() -> dict[str, str]:
42
- job_name = get_env_var("JOB_DEFINITION_NAME")
42
+ job_name = get_env_var("JOB_NAME")
43
+ job_definition_name = get_env_var("JOB_DEFINITION_NAME")
43
44
  job_queue = get_env_var("AWS_BATCH_JQ_NAME")
44
45
  product_id = get_env_var("PRODUCT_ID")
45
- service = job_name or (f"from-{job_queue}" if job_queue else product_id)
46
+ service = (
47
+ job_name or job_definition_name or (f"from-{job_queue}" if job_queue else product_id)
48
+ )
46
49
  return {
47
50
  "ddsource": "batch",
48
51
  "dd.service": service or "unknown",
@@ -126,7 +129,11 @@ class PipelineSource(SourceStrategy):
126
129
  class ContainerSource(SourceStrategy):
127
130
  @staticmethod
128
131
  def detect() -> bool:
129
- return get_env_var("CONTAINER_IMAGE") is not None
132
+ return (
133
+ get_env_var("CONTAINER_IMAGE") is not None
134
+ or get_env_var("CONTAINER_NAME") is not None
135
+ or get_env_var("CONTAINER_IMAGE_PATH") is not None
136
+ )
130
137
 
131
138
  @staticmethod
132
139
  def log_metadata() -> dict[str, str]:
@@ -0,0 +1,37 @@
1
+ import os
2
+
3
+
4
+ def get_env_var(key: str) -> str | None:
5
+ return os.environ.get(key)
6
+
7
+
8
+ def get_environment() -> str:
9
+ product_environment = os.environ.get("PRODUCT_ENVIRONMENT")
10
+ branch = os.environ.get("CI_COMMIT_REF_NAME", "default")
11
+ return product_environment or ("production" if branch == "trunk" else "development")
12
+
13
+
14
+ def get_version() -> str:
15
+ product_version = os.environ.get("PRODUCT_VERSION")
16
+ short_commit_sha = os.environ["CI_COMMIT_SHA"][:8] if os.environ.get("CI_COMMIT_SHA") else None
17
+ return product_version or short_commit_sha or "00000000"
18
+
19
+
20
+ def set_product_id(product_id: str) -> None:
21
+ os.environ["PRODUCT_ID"] = product_id
22
+
23
+
24
+ def set_product_environment(product_environment: str) -> None:
25
+ os.environ["PRODUCT_ENVIRONMENT"] = product_environment
26
+
27
+
28
+ def set_product_version(product_version: str) -> None:
29
+ os.environ["PRODUCT_VERSION"] = product_version
30
+
31
+
32
+ def set_commit_sha(commit_sha: str) -> None:
33
+ os.environ["CI_COMMIT_SHA"] = commit_sha
34
+
35
+
36
+ def set_commit_ref_name(commit_ref_name: str) -> None:
37
+ os.environ["CI_COMMIT_REF_NAME"] = commit_ref_name
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fluidattacks-core
3
- Version: 4.1.0
3
+ Version: 4.2.1
4
4
  Summary: Fluid Attacks Core Library
5
5
  Author-email: Development <development@fluidattacks.com>
6
6
  License: MPL-2.0
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "fluidattacks-core"
3
- version = "4.1.0"
3
+ version = "4.2.1"
4
4
  description = "Fluid Attacks Core Library"
5
5
  authors = [{ name = "Development", email = "development@fluidattacks.com" }]
6
6
  license = { text = "MPL-2.0" }
@@ -1,27 +0,0 @@
1
- import os
2
- from typing import Literal
3
-
4
-
5
- def get_env_var(key: str) -> str | None:
6
- return os.environ.get(key)
7
-
8
-
9
- def get_environment() -> Literal["development", "production"]:
10
- branch = os.environ.get("CI_COMMIT_REF_NAME", "default")
11
- return "production" if branch == "trunk" else "development"
12
-
13
-
14
- def get_version() -> str:
15
- return os.environ.get("CI_COMMIT_SHA", "00000000")[:8]
16
-
17
-
18
- def set_product_id(product_id: str) -> None:
19
- os.environ["PRODUCT_ID"] = product_id
20
-
21
-
22
- def set_commit_sha(commit_sha: str) -> None:
23
- os.environ["CI_COMMIT_SHA"] = commit_sha
24
-
25
-
26
- def set_commit_ref_name(commit_ref_name: str) -> None:
27
- os.environ["CI_COMMIT_REF_NAME"] = commit_ref_name