miso-client 5.2.2__tar.gz → 5.2.4__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.
- {miso_client-5.2.2 → miso_client-5.2.4}/CHANGELOG.md +28 -0
- {miso_client-5.2.2 → miso_client-5.2.4}/MANIFEST.in +1 -0
- {miso_client-5.2.2/miso_client.egg-info → miso_client-5.2.4}/PKG-INFO +8 -1
- {miso_client-5.2.2 → miso_client-5.2.4}/README.md +7 -0
- {miso_client-5.2.2 → miso_client-5.2.4}/miso_client/__init__.py +1 -1
- {miso_client-5.2.2 → miso_client-5.2.4}/miso_client/models/bootstrap.py +29 -4
- {miso_client-5.2.2 → miso_client-5.2.4}/miso_client/services/encryption.py +15 -10
- {miso_client-5.2.2 → miso_client-5.2.4}/miso_client/utils/bootstrap_transport.py +26 -7
- {miso_client-5.2.2 → miso_client-5.2.4}/miso_client/utils/data_masker.py +12 -0
- {miso_client-5.2.2 → miso_client-5.2.4}/miso_client/utils/http_client_logging.py +19 -5
- {miso_client-5.2.2 → miso_client-5.2.4}/miso_client/utils/http_log_masker.py +11 -0
- miso_client-5.2.4/miso_client/utils/sensitive_fields_config.json +47 -0
- {miso_client-5.2.2 → miso_client-5.2.4/miso_client.egg-info}/PKG-INFO +8 -1
- {miso_client-5.2.2 → miso_client-5.2.4}/miso_client.egg-info/SOURCES.txt +1 -0
- {miso_client-5.2.2 → miso_client-5.2.4}/pyproject.toml +2 -2
- {miso_client-5.2.2 → miso_client-5.2.4}/setup.py +1 -1
- {miso_client-5.2.2 → miso_client-5.2.4}/LICENSE +0 -0
- {miso_client-5.2.2 → miso_client-5.2.4}/miso_client/api/__init__.py +0 -0
- {miso_client-5.2.2 → miso_client-5.2.4}/miso_client/api/applications_api.py +0 -0
- {miso_client-5.2.2 → miso_client-5.2.4}/miso_client/api/auth_api.py +0 -0
- {miso_client-5.2.2 → miso_client-5.2.4}/miso_client/api/logs_api.py +0 -0
- {miso_client-5.2.2 → miso_client-5.2.4}/miso_client/api/logs_stats_api.py +0 -0
- {miso_client-5.2.2 → miso_client-5.2.4}/miso_client/api/logs_stats_delegation_mixin.py +0 -0
- {miso_client-5.2.2 → miso_client-5.2.4}/miso_client/api/permissions_api.py +0 -0
- {miso_client-5.2.2 → miso_client-5.2.4}/miso_client/api/response_utils.py +0 -0
- {miso_client-5.2.2 → miso_client-5.2.4}/miso_client/api/roles_api.py +0 -0
- {miso_client-5.2.2 → miso_client-5.2.4}/miso_client/api/types/__init__.py +0 -0
- {miso_client-5.2.2 → miso_client-5.2.4}/miso_client/api/types/applications_types.py +0 -0
- {miso_client-5.2.2 → miso_client-5.2.4}/miso_client/api/types/auth_types.py +0 -0
- {miso_client-5.2.2 → miso_client-5.2.4}/miso_client/api/types/logs_types.py +0 -0
- {miso_client-5.2.2 → miso_client-5.2.4}/miso_client/api/types/permissions_types.py +0 -0
- {miso_client-5.2.2 → miso_client-5.2.4}/miso_client/api/types/roles_types.py +0 -0
- {miso_client-5.2.2 → miso_client-5.2.4}/miso_client/client.py +0 -0
- {miso_client-5.2.2 → miso_client-5.2.4}/miso_client/errors.py +0 -0
- {miso_client-5.2.2 → miso_client-5.2.4}/miso_client/models/__init__.py +0 -0
- {miso_client-5.2.2 → miso_client-5.2.4}/miso_client/models/config.py +0 -0
- {miso_client-5.2.2 → miso_client-5.2.4}/miso_client/models/encryption.py +0 -0
- {miso_client-5.2.2 → miso_client-5.2.4}/miso_client/models/error_response.py +0 -0
- {miso_client-5.2.2 → miso_client-5.2.4}/miso_client/models/filter.py +0 -0
- {miso_client-5.2.2 → miso_client-5.2.4}/miso_client/models/filter_schema.py +0 -0
- {miso_client-5.2.2 → miso_client-5.2.4}/miso_client/models/pagination.py +0 -0
- {miso_client-5.2.2 → miso_client-5.2.4}/miso_client/models/session_cookie.py +0 -0
- {miso_client-5.2.2 → miso_client-5.2.4}/miso_client/models/sort.py +0 -0
- {miso_client-5.2.2 → miso_client-5.2.4}/miso_client/py.typed +0 -0
- {miso_client-5.2.2 → miso_client-5.2.4}/miso_client/services/__init__.py +0 -0
- {miso_client-5.2.2 → miso_client-5.2.4}/miso_client/services/application_context.py +0 -0
- {miso_client-5.2.2 → miso_client-5.2.4}/miso_client/services/auth.py +0 -0
- {miso_client-5.2.2 → miso_client-5.2.4}/miso_client/services/auth_flow_helpers.py +0 -0
- {miso_client-5.2.2 → miso_client-5.2.4}/miso_client/services/auth_token_cache.py +0 -0
- {miso_client-5.2.2 → miso_client-5.2.4}/miso_client/services/auth_user_cache.py +0 -0
- {miso_client-5.2.2 → miso_client-5.2.4}/miso_client/services/authorization_mixin.py +0 -0
- {miso_client-5.2.2 → miso_client-5.2.4}/miso_client/services/browser_session_refresh.py +0 -0
- {miso_client-5.2.2 → miso_client-5.2.4}/miso_client/services/cache.py +0 -0
- {miso_client-5.2.2 → miso_client-5.2.4}/miso_client/services/logger.py +0 -0
- {miso_client-5.2.2 → miso_client-5.2.4}/miso_client/services/logger_chain.py +0 -0
- {miso_client-5.2.2 → miso_client-5.2.4}/miso_client/services/permission.py +0 -0
- {miso_client-5.2.2 → miso_client-5.2.4}/miso_client/services/redis.py +0 -0
- {miso_client-5.2.2 → miso_client-5.2.4}/miso_client/services/role.py +0 -0
- {miso_client-5.2.2 → miso_client-5.2.4}/miso_client/services/unified_logger.py +0 -0
- {miso_client-5.2.2 → miso_client-5.2.4}/miso_client/utils/__init__.py +0 -0
- {miso_client-5.2.2 → miso_client-5.2.4}/miso_client/utils/application_url_resolver.py +0 -0
- {miso_client-5.2.2 → miso_client-5.2.4}/miso_client/utils/audit_log_queue.py +0 -0
- {miso_client-5.2.2 → miso_client-5.2.4}/miso_client/utils/auth_cache_helpers.py +0 -0
- {miso_client-5.2.2 → miso_client-5.2.4}/miso_client/utils/auth_strategy.py +0 -0
- {miso_client-5.2.2 → miso_client-5.2.4}/miso_client/utils/auth_utils.py +0 -0
- {miso_client-5.2.2 → miso_client-5.2.4}/miso_client/utils/bootstrap.py +0 -0
- {miso_client-5.2.2 → miso_client-5.2.4}/miso_client/utils/bootstrap_auth.py +0 -0
- {miso_client-5.2.2 → miso_client-5.2.4}/miso_client/utils/bootstrap_credentials.py +0 -0
- {miso_client-5.2.2 → miso_client-5.2.4}/miso_client/utils/bootstrap_request_policy.py +0 -0
- {miso_client-5.2.2 → miso_client-5.2.4}/miso_client/utils/bootstrap_runtime.py +0 -0
- {miso_client-5.2.2 → miso_client-5.2.4}/miso_client/utils/bootstrap_snapshot.py +0 -0
- {miso_client-5.2.2 → miso_client-5.2.4}/miso_client/utils/circuit_breaker.py +0 -0
- {miso_client-5.2.2 → miso_client-5.2.4}/miso_client/utils/client_token_manager.py +0 -0
- {miso_client-5.2.2 → miso_client-5.2.4}/miso_client/utils/config_loader.py +0 -0
- {miso_client-5.2.2 → miso_client-5.2.4}/miso_client/utils/controller_url_resolver.py +0 -0
- {miso_client-5.2.2 → miso_client-5.2.4}/miso_client/utils/environment_token.py +0 -0
- {miso_client-5.2.2 → miso_client-5.2.4}/miso_client/utils/error_utils.py +0 -0
- {miso_client-5.2.2 → miso_client-5.2.4}/miso_client/utils/fastapi_endpoints.py +0 -0
- {miso_client-5.2.2 → miso_client-5.2.4}/miso_client/utils/fastapi_logger_middleware.py +0 -0
- {miso_client-5.2.2 → miso_client-5.2.4}/miso_client/utils/filter.py +0 -0
- {miso_client-5.2.2 → miso_client-5.2.4}/miso_client/utils/filter_applier.py +0 -0
- {miso_client-5.2.2 → miso_client-5.2.4}/miso_client/utils/filter_coercion.py +0 -0
- {miso_client-5.2.2 → miso_client-5.2.4}/miso_client/utils/filter_parser.py +0 -0
- {miso_client-5.2.2 → miso_client-5.2.4}/miso_client/utils/filter_schema.py +0 -0
- {miso_client-5.2.2 → miso_client-5.2.4}/miso_client/utils/flask_endpoints.py +0 -0
- {miso_client-5.2.2 → miso_client-5.2.4}/miso_client/utils/flask_logger_middleware.py +0 -0
- {miso_client-5.2.2 → miso_client-5.2.4}/miso_client/utils/http_client.py +0 -0
- {miso_client-5.2.2 → miso_client-5.2.4}/miso_client/utils/http_client_auth_helpers.py +0 -0
- {miso_client-5.2.2 → miso_client-5.2.4}/miso_client/utils/http_client_logging_helpers.py +0 -0
- {miso_client-5.2.2 → miso_client-5.2.4}/miso_client/utils/http_client_query_helpers.py +0 -0
- {miso_client-5.2.2 → miso_client-5.2.4}/miso_client/utils/http_client_runtime_helpers.py +0 -0
- {miso_client-5.2.2 → miso_client-5.2.4}/miso_client/utils/http_error_handler.py +0 -0
- {miso_client-5.2.2 → miso_client-5.2.4}/miso_client/utils/http_error_sanitizer.py +0 -0
- {miso_client-5.2.2 → miso_client-5.2.4}/miso_client/utils/http_log_formatter.py +0 -0
- {miso_client-5.2.2 → miso_client-5.2.4}/miso_client/utils/internal_http_auth_strategy.py +0 -0
- {miso_client-5.2.2 → miso_client-5.2.4}/miso_client/utils/internal_http_client.py +0 -0
- {miso_client-5.2.2 → miso_client-5.2.4}/miso_client/utils/jwt_tools.py +0 -0
- {miso_client-5.2.2 → miso_client-5.2.4}/miso_client/utils/log_request_transformer.py +0 -0
- {miso_client-5.2.2 → miso_client-5.2.4}/miso_client/utils/logger_context_storage.py +0 -0
- {miso_client-5.2.2 → miso_client-5.2.4}/miso_client/utils/logger_helpers.py +0 -0
- {miso_client-5.2.2 → miso_client-5.2.4}/miso_client/utils/logger_request_helpers.py +0 -0
- {miso_client-5.2.2 → miso_client-5.2.4}/miso_client/utils/logging_helpers.py +0 -0
- {miso_client-5.2.2 → miso_client-5.2.4}/miso_client/utils/origin_validator.py +0 -0
- {miso_client-5.2.2 → miso_client-5.2.4}/miso_client/utils/pagination.py +0 -0
- {miso_client-5.2.2 → miso_client-5.2.4}/miso_client/utils/request_context.py +0 -0
- {miso_client-5.2.2 → miso_client-5.2.4}/miso_client/utils/request_target.py +0 -0
- {miso_client-5.2.2 → miso_client-5.2.4}/miso_client/utils/sensitive_fields_loader.py +0 -0
- {miso_client-5.2.2 → miso_client-5.2.4}/miso_client/utils/shared_task.py +0 -0
- {miso_client-5.2.2 → miso_client-5.2.4}/miso_client/utils/sort.py +0 -0
- {miso_client-5.2.2 → miso_client-5.2.4}/miso_client/utils/token_utils.py +0 -0
- {miso_client-5.2.2 → miso_client-5.2.4}/miso_client/utils/unified_logger_factory.py +0 -0
- {miso_client-5.2.2 → miso_client-5.2.4}/miso_client/utils/url_validator.py +0 -0
- {miso_client-5.2.2 → miso_client-5.2.4}/miso_client/utils/user_token_refresh.py +0 -0
- {miso_client-5.2.2 → miso_client-5.2.4}/miso_client.egg-info/dependency_links.txt +0 -0
- {miso_client-5.2.2 → miso_client-5.2.4}/miso_client.egg-info/not-zip-safe +0 -0
- {miso_client-5.2.2 → miso_client-5.2.4}/miso_client.egg-info/requires.txt +0 -0
- {miso_client-5.2.2 → miso_client-5.2.4}/miso_client.egg-info/top_level.txt +0 -0
- {miso_client-5.2.2 → miso_client-5.2.4}/requirements-test.txt +0 -0
- {miso_client-5.2.2 → miso_client-5.2.4}/requirements.txt +0 -0
- {miso_client-5.2.2 → miso_client-5.2.4}/setup.cfg +0 -0
|
@@ -7,6 +7,34 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [5.2.4] - 2026-12-02
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- `BootstrapError.try_outcomes` names each transport try of a failed bootstrap fetch, in
|
|
15
|
+
order (past six, the last six): `http-<status>` or the exception class as
|
|
16
|
+
`<root module>.<ClassName>` (for example `httpx.ConnectError`, `builtins.TimeoutError`). An application can now tell a
|
|
17
|
+
refused connection from a timeout, a TLS failure or an HTTP answer. Only entries matching that
|
|
18
|
+
fixed pattern are kept, so the field never holds a message, a URL or a value; it is `()` for
|
|
19
|
+
errors that made no try.
|
|
20
|
+
|
|
21
|
+
## [5.2.3] - 2026-11-12
|
|
22
|
+
|
|
23
|
+
### Fixed
|
|
24
|
+
|
|
25
|
+
- Prevented HTTP debug and failure diagnostics for `/api/security/` endpoints from
|
|
26
|
+
emitting request bodies, decrypt responses, raw exception text, or parameter names.
|
|
27
|
+
Default and fallback masking now also cover `plaintext`, exact normalized
|
|
28
|
+
`value`, and `encryptionKey` fields while safe audit metadata remains
|
|
29
|
+
available. Composite names such as `totalValue` remain visible unless
|
|
30
|
+
independently sensitive or explicitly configured.
|
|
31
|
+
|
|
32
|
+
### Technical
|
|
33
|
+
|
|
34
|
+
- Included the sensitive-field configuration in wheel and source distributions,
|
|
35
|
+
and expanded regression and live-harness coverage for security-log omission,
|
|
36
|
+
safe encryption diagnostics, and exact normalized `value` matching.
|
|
37
|
+
|
|
10
38
|
## [5.2.2] - 2026-11-10
|
|
11
39
|
|
|
12
40
|
### Changed
|
|
@@ -6,6 +6,7 @@ include requirements-test.txt
|
|
|
6
6
|
# recursive-include docs *.md # docs directory is empty
|
|
7
7
|
recursive-include miso_client *.py
|
|
8
8
|
include miso_client/py.typed
|
|
9
|
+
include miso_client/utils/sensitive_fields_config.json
|
|
9
10
|
recursive-exclude * __pycache__
|
|
10
11
|
recursive-exclude * *.py[co]
|
|
11
12
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: miso-client
|
|
3
|
-
Version: 5.2.
|
|
3
|
+
Version: 5.2.4
|
|
4
4
|
Summary: Python client SDK for AI Fabrix authentication, authorization, and logging
|
|
5
5
|
Home-page: https://github.com/aifabrix/miso-client-python
|
|
6
6
|
Author: AI Fabrix Team
|
|
@@ -682,6 +682,13 @@ The default configuration includes ISO 27001 compliant sensitive fields:
|
|
|
682
682
|
- PII: ssn, creditcard, cc, cvv, pin, otp
|
|
683
683
|
- Security: apikey, accesstoken, refreshtoken, privatekey, secretkey, cookie, session
|
|
684
684
|
|
|
685
|
+
Field-name matching is case-insensitive and ignores `_` and `-`. The sensitive
|
|
686
|
+
token `value` matches only a complete normalized field name, so `VALUE` and
|
|
687
|
+
`v_a_l_u_e` are masked while ordinary composite names such as `totalValue` and
|
|
688
|
+
`defaultValue` remain visible unless they match another sensitive token. Add a
|
|
689
|
+
genuinely sensitive composite name explicitly under `fields` in custom
|
|
690
|
+
configuration. Python `DataMasker` does not currently consume `fieldPatterns`.
|
|
691
|
+
|
|
685
692
|
**Masking JSON documents (for other projects):** Use `DataMasker` to mask sensitive fields in any JSON structure before logging or sending to external systems:
|
|
686
693
|
|
|
687
694
|
```python
|
|
@@ -628,6 +628,13 @@ The default configuration includes ISO 27001 compliant sensitive fields:
|
|
|
628
628
|
- PII: ssn, creditcard, cc, cvv, pin, otp
|
|
629
629
|
- Security: apikey, accesstoken, refreshtoken, privatekey, secretkey, cookie, session
|
|
630
630
|
|
|
631
|
+
Field-name matching is case-insensitive and ignores `_` and `-`. The sensitive
|
|
632
|
+
token `value` matches only a complete normalized field name, so `VALUE` and
|
|
633
|
+
`v_a_l_u_e` are masked while ordinary composite names such as `totalValue` and
|
|
634
|
+
`defaultValue` remain visible unless they match another sensitive token. Add a
|
|
635
|
+
genuinely sensitive composite name explicitly under `fields` in custom
|
|
636
|
+
configuration. Python `DataMasker` does not currently consume `fieldPatterns`.
|
|
637
|
+
|
|
631
638
|
**Masking JSON documents (for other projects):** Use `DataMasker` to mask sensitive fields in any JSON structure before logging or sending to external systems:
|
|
632
639
|
|
|
633
640
|
```python
|
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
|
+
import re
|
|
5
6
|
from abc import ABC, abstractmethod
|
|
6
|
-
from typing import Callable, Literal, Optional, Tuple
|
|
7
|
+
from typing import Callable, Iterable, Literal, Optional, Tuple
|
|
7
8
|
|
|
8
9
|
from pydantic import BaseModel, ConfigDict, Field
|
|
9
10
|
|
|
@@ -37,13 +38,37 @@ SAFE_ERROR_CODES = frozenset(
|
|
|
37
38
|
)
|
|
38
39
|
|
|
39
40
|
|
|
40
|
-
class
|
|
41
|
-
|
|
41
|
+
# One transport try: an HTTP status or an exception class as `<root module>.<ClassName>`.
|
|
42
|
+
TRY_OUTCOME_PATTERN = re.compile(
|
|
43
|
+
r"^(http-[1-5][0-9]{2}|[A-Za-z_][A-Za-z0-9_]*\.[A-Za-z_][A-Za-z0-9_]*)$"
|
|
44
|
+
)
|
|
45
|
+
# A fetch is at most two exchanges (mint, snapshot) of three tries each; the budget running out
|
|
46
|
+
# can name a seventh, so the last six are kept.
|
|
47
|
+
MAX_TRY_OUTCOMES = 6
|
|
42
48
|
|
|
43
|
-
|
|
49
|
+
|
|
50
|
+
class BootstrapError(MisoClientError):
|
|
51
|
+
"""Safe bootstrap failure with a fixed category and no transport payload.
|
|
52
|
+
|
|
53
|
+
`try_outcomes` names each transport try of the failed fetch, in order: `http-<status>` or the
|
|
54
|
+
exception class. Past six tries the last six are kept, so the final cause stays. Only entries
|
|
55
|
+
matching the token pattern are kept, so it never holds a message, a URL or a value.
|
|
56
|
+
"""
|
|
57
|
+
|
|
58
|
+
def __init__(
|
|
59
|
+
self,
|
|
60
|
+
code: str,
|
|
61
|
+
status_code: Optional[int] = None,
|
|
62
|
+
try_outcomes: Iterable[object] = (),
|
|
63
|
+
):
|
|
44
64
|
code = code if code in SAFE_ERROR_CODES else "operation-failed"
|
|
45
65
|
super().__init__("Secret runtime operation failed: " + code, status_code=status_code)
|
|
46
66
|
self.code = code
|
|
67
|
+
self.try_outcomes: Tuple[str, ...] = tuple(
|
|
68
|
+
entry
|
|
69
|
+
for entry in try_outcomes
|
|
70
|
+
if isinstance(entry, str) and TRY_OUTCOME_PATTERN.match(entry)
|
|
71
|
+
)[-MAX_TRY_OUTCOMES:]
|
|
47
72
|
|
|
48
73
|
|
|
49
74
|
class ApplicationTokenProvider(ABC):
|
|
@@ -49,6 +49,17 @@ def _cache_key_decrypt(value: str, parameter_name: str) -> str:
|
|
|
49
49
|
return f"{DECRYPT_CACHE_PREFIX}{h}"
|
|
50
50
|
|
|
51
51
|
|
|
52
|
+
def _safe_error_log_context(error: MisoClientError) -> dict[str, object]:
|
|
53
|
+
"""Return non-secret metadata for encryption failure diagnostics."""
|
|
54
|
+
context: dict[str, object] = {}
|
|
55
|
+
correlation_id = extract_correlation_id_from_error(error)
|
|
56
|
+
if correlation_id:
|
|
57
|
+
context["correlationId"] = correlation_id
|
|
58
|
+
if error.status_code is not None:
|
|
59
|
+
context["statusCode"] = error.status_code
|
|
60
|
+
return context
|
|
61
|
+
|
|
62
|
+
|
|
52
63
|
class EncryptionService:
|
|
53
64
|
"""Encryption service calling miso-controller for server-side encryption.
|
|
54
65
|
|
|
@@ -198,12 +209,9 @@ class EncryptionService:
|
|
|
198
209
|
|
|
199
210
|
def _raise_encrypt_error(self, error: MisoClientError, parameter_name: str) -> NoReturn:
|
|
200
211
|
"""Raise normalized EncryptionError for encrypt failures."""
|
|
201
|
-
correlation_id = extract_correlation_id_from_error(error)
|
|
202
|
-
extra = {"correlationId": correlation_id} if correlation_id else None
|
|
203
212
|
logger.error(
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
extra=extra,
|
|
213
|
+
"Encryption request failed",
|
|
214
|
+
extra=_safe_error_log_context(error),
|
|
207
215
|
)
|
|
208
216
|
raise EncryptionError(
|
|
209
217
|
str(error),
|
|
@@ -224,12 +232,9 @@ class EncryptionService:
|
|
|
224
232
|
code = "PARAMETER_NOT_FOUND"
|
|
225
233
|
elif error.status_code in (401, 403):
|
|
226
234
|
code = "ACCESS_DENIED"
|
|
227
|
-
correlation_id = extract_correlation_id_from_error(error)
|
|
228
|
-
extra = {"correlationId": correlation_id} if correlation_id else None
|
|
229
235
|
logger.error(
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
extra=extra,
|
|
236
|
+
"Decryption request failed",
|
|
237
|
+
extra=_safe_error_log_context(error),
|
|
233
238
|
)
|
|
234
239
|
raise EncryptionError(
|
|
235
240
|
str(error),
|
|
@@ -12,11 +12,21 @@ from typing import Optional
|
|
|
12
12
|
import httpx
|
|
13
13
|
from pydantic import SecretStr
|
|
14
14
|
|
|
15
|
-
from ..models.bootstrap import BootstrapError
|
|
15
|
+
from ..models.bootstrap import TRY_OUTCOME_PATTERN, BootstrapError
|
|
16
16
|
from .bootstrap_credentials import parse_minted_token, validate_credentials, validate_http_client
|
|
17
17
|
from .bootstrap_snapshot import MAX_BODY, SnapshotClock
|
|
18
18
|
|
|
19
19
|
RETRY_STATUS = {429, 502, 503, 504}
|
|
20
|
+
TRY_SECONDS = 5
|
|
21
|
+
FETCH_BUDGET_SECONDS = 30
|
|
22
|
+
_OTHER_TOKEN = "other.Exception"
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def try_outcome_token(error: BaseException) -> str:
|
|
26
|
+
"""Name a failed try by its exception class only: `<root module>.<ClassName>`."""
|
|
27
|
+
kind = type(error)
|
|
28
|
+
token = f"{kind.__module__.split('.')[0]}.{kind.__name__}"
|
|
29
|
+
return token if TRY_OUTCOME_PATTERN.match(token) else _OTHER_TOKEN
|
|
20
30
|
|
|
21
31
|
|
|
22
32
|
def _tls_failure(error: BaseException) -> bool:
|
|
@@ -73,6 +83,7 @@ class BrokerTransport:
|
|
|
73
83
|
self._mint_deadline = 0.0
|
|
74
84
|
self._snapshot_clock: Optional[SnapshotClock] = None
|
|
75
85
|
self._closed = False
|
|
86
|
+
self._outcomes: list[str] = []
|
|
76
87
|
self._owned = http_client is None
|
|
77
88
|
self.client = http_client or httpx.AsyncClient(
|
|
78
89
|
timeout=5, follow_redirects=False, trust_env=False
|
|
@@ -96,12 +107,17 @@ class BrokerTransport:
|
|
|
96
107
|
async def fetch(self) -> bytes:
|
|
97
108
|
"""Fetch within a total budget, sanitizing every transport error."""
|
|
98
109
|
failure: Optional[BootstrapError] = None
|
|
110
|
+
self._outcomes = []
|
|
99
111
|
try:
|
|
100
|
-
return await asyncio.wait_for(self._fetch(), timeout=
|
|
112
|
+
return await asyncio.wait_for(self._fetch(), timeout=FETCH_BUDGET_SECONDS)
|
|
101
113
|
except BootstrapError as error:
|
|
102
|
-
failure = BootstrapError(error.code, error.status_code)
|
|
103
|
-
except Exception:
|
|
104
|
-
|
|
114
|
+
failure = BootstrapError(error.code, error.status_code, self._outcomes)
|
|
115
|
+
except Exception as error:
|
|
116
|
+
# The budget running out, or an error no try caught: named once, by class only.
|
|
117
|
+
token = try_outcome_token(error)
|
|
118
|
+
if not self._outcomes or self._outcomes[-1] != token:
|
|
119
|
+
self._outcomes.append(token)
|
|
120
|
+
failure = BootstrapError("temporarily-unavailable", None, self._outcomes)
|
|
105
121
|
raise failure
|
|
106
122
|
|
|
107
123
|
async def _fetch(self) -> bytes:
|
|
@@ -126,10 +142,12 @@ class BrokerTransport:
|
|
|
126
142
|
async def _attempt(self, mint: bool, attempt: int) -> tuple[Optional[bytes], float]:
|
|
127
143
|
retry = False
|
|
128
144
|
try:
|
|
129
|
-
return await asyncio.wait_for(self._request(mint, attempt), timeout=
|
|
145
|
+
return await asyncio.wait_for(self._request(mint, attempt), timeout=TRY_SECONDS)
|
|
130
146
|
except httpx.NetworkError as error:
|
|
147
|
+
self._outcomes.append(try_outcome_token(error))
|
|
131
148
|
retry = not _tls_failure(error)
|
|
132
|
-
except (httpx.TimeoutException, asyncio.TimeoutError):
|
|
149
|
+
except (httpx.TimeoutException, asyncio.TimeoutError) as error:
|
|
150
|
+
self._outcomes.append(try_outcome_token(error))
|
|
133
151
|
retry = True
|
|
134
152
|
if not retry:
|
|
135
153
|
raise BootstrapError("transport-error")
|
|
@@ -181,6 +199,7 @@ class BrokerTransport:
|
|
|
181
199
|
async def _read_response(
|
|
182
200
|
self, response: httpx.Response, expected: int, attempt: int
|
|
183
201
|
) -> tuple[Optional[bytes], float]:
|
|
202
|
+
self._outcomes.append(f"http-{response.status_code}")
|
|
184
203
|
if response.status_code in (401, 403):
|
|
185
204
|
raise BootstrapError("authorization-denied", response.status_code)
|
|
186
205
|
if response.status_code in RETRY_STATUS:
|
|
@@ -39,6 +39,16 @@ class DataMasker:
|
|
|
39
39
|
"refreshtoken",
|
|
40
40
|
"privatekey",
|
|
41
41
|
"secretkey",
|
|
42
|
+
"encryptionkey",
|
|
43
|
+
"plaintext",
|
|
44
|
+
"value",
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
# Subset of the main hardcoded list for full normalized-name matching only;
|
|
48
|
+
# entries must also remain in the main list. This preserves roleValue,
|
|
49
|
+
# valueCount, dimensionValueId, and dimensionValuesProcessed.
|
|
50
|
+
_exact_match_only_fields_subset: Set[str] = {
|
|
51
|
+
"value",
|
|
42
52
|
}
|
|
43
53
|
|
|
44
54
|
_sensitive_fields: Optional[Set[str]] = None
|
|
@@ -83,6 +93,8 @@ class DataMasker:
|
|
|
83
93
|
if nk in sensitive_fields:
|
|
84
94
|
return True
|
|
85
95
|
for sf in sensitive_fields:
|
|
96
|
+
if sf in cls._exact_match_only_fields_subset:
|
|
97
|
+
continue
|
|
86
98
|
if len(sf) >= substr_min and sf in nk:
|
|
87
99
|
return True
|
|
88
100
|
return False
|
|
@@ -11,11 +11,14 @@ from typing import Any, Dict, Optional, cast
|
|
|
11
11
|
from .http_log_formatter import build_audit_context, build_debug_context
|
|
12
12
|
from .http_log_masker import (
|
|
13
13
|
extract_and_mask_query_params,
|
|
14
|
+
is_security_endpoint,
|
|
14
15
|
mask_error_message,
|
|
15
16
|
mask_request_data,
|
|
16
17
|
mask_response_data,
|
|
17
18
|
)
|
|
18
19
|
|
|
20
|
+
_SECURITY_ERROR_MESSAGE = "Security request failed"
|
|
21
|
+
|
|
19
22
|
|
|
20
23
|
def should_skip_logging(url: str, config: Optional[Any] = None) -> bool:
|
|
21
24
|
"""Check whether request logging should be skipped."""
|
|
@@ -114,7 +117,11 @@ def _prepare_audit_context(
|
|
|
114
117
|
request_size, response_size = _resolve_request_response_sizes(
|
|
115
118
|
audit_level, request_data, response
|
|
116
119
|
)
|
|
117
|
-
error_message =
|
|
120
|
+
error_message = None
|
|
121
|
+
if error is not None:
|
|
122
|
+
error_message = (
|
|
123
|
+
_SECURITY_ERROR_MESSAGE if is_security_endpoint(url) else mask_error_message(error)
|
|
124
|
+
)
|
|
118
125
|
return build_audit_context(
|
|
119
126
|
method=method,
|
|
120
127
|
url=url,
|
|
@@ -189,7 +196,7 @@ def _build_minimal_audit_context(
|
|
|
189
196
|
if user_id:
|
|
190
197
|
context["userId"] = user_id
|
|
191
198
|
if error:
|
|
192
|
-
context["error"] = str(error)
|
|
199
|
+
context["error"] = _SECURITY_ERROR_MESSAGE if is_security_endpoint(url) else str(error)
|
|
193
200
|
if correlation_id:
|
|
194
201
|
context["correlationId"] = correlation_id
|
|
195
202
|
return context
|
|
@@ -352,6 +359,13 @@ def _prepare_debug_context(
|
|
|
352
359
|
correlation_id: Optional[str] = None,
|
|
353
360
|
) -> Dict[str, Any]:
|
|
354
361
|
"""Prepare debug context for logging."""
|
|
362
|
+
if is_security_endpoint(url):
|
|
363
|
+
masked_headers, _ = mask_request_data(request_headers, None)
|
|
364
|
+
masked_body = None
|
|
365
|
+
masked_response = None
|
|
366
|
+
else:
|
|
367
|
+
masked_headers, masked_body = mask_request_data(request_headers, request_data)
|
|
368
|
+
masked_response = mask_response_data(response, max_size=max_response_size)
|
|
355
369
|
return build_debug_context(
|
|
356
370
|
method=method,
|
|
357
371
|
url=url,
|
|
@@ -359,9 +373,9 @@ def _prepare_debug_context(
|
|
|
359
373
|
duration_ms=duration_ms,
|
|
360
374
|
base_url=base_url,
|
|
361
375
|
user_id=user_id,
|
|
362
|
-
masked_headers=
|
|
363
|
-
masked_body=
|
|
364
|
-
masked_response=
|
|
376
|
+
masked_headers=masked_headers,
|
|
377
|
+
masked_body=masked_body,
|
|
378
|
+
masked_response=masked_response,
|
|
365
379
|
query_params=extract_and_mask_query_params(url),
|
|
366
380
|
correlation_id=correlation_id,
|
|
367
381
|
)
|
|
@@ -10,6 +10,17 @@ from urllib.parse import parse_qs, urlparse
|
|
|
10
10
|
from .data_masker import DataMasker
|
|
11
11
|
|
|
12
12
|
|
|
13
|
+
def is_security_endpoint(url: str) -> bool:
|
|
14
|
+
"""Return whether the URL path contains the bounded ``/api/security`` route."""
|
|
15
|
+
try:
|
|
16
|
+
segments = [segment.lower() for segment in urlparse(url).path.split("/") if segment]
|
|
17
|
+
except Exception:
|
|
18
|
+
return False
|
|
19
|
+
return any(
|
|
20
|
+
segments[index : index + 2] == ["api", "security"] for index in range(len(segments) - 1)
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
|
|
13
24
|
def mask_error_message(error: Optional[Exception]) -> Optional[str]:
|
|
14
25
|
"""Mask sensitive data in error message.
|
|
15
26
|
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"mergeWithHardcodedDefaults": true,
|
|
3
|
+
"substringMinLength": 4,
|
|
4
|
+
"neverMaskFields": [
|
|
5
|
+
"success",
|
|
6
|
+
"key",
|
|
7
|
+
"message",
|
|
8
|
+
"status",
|
|
9
|
+
"error",
|
|
10
|
+
"hint",
|
|
11
|
+
"code",
|
|
12
|
+
"name",
|
|
13
|
+
"id"
|
|
14
|
+
],
|
|
15
|
+
"fields": {
|
|
16
|
+
"authentication": [
|
|
17
|
+
"password",
|
|
18
|
+
"passwd",
|
|
19
|
+
"pwd",
|
|
20
|
+
"token",
|
|
21
|
+
"secret",
|
|
22
|
+
"auth",
|
|
23
|
+
"authorization"
|
|
24
|
+
],
|
|
25
|
+
"pii": [
|
|
26
|
+
"ssn",
|
|
27
|
+
"creditcard",
|
|
28
|
+
"cvv",
|
|
29
|
+
"pin",
|
|
30
|
+
"otp"
|
|
31
|
+
],
|
|
32
|
+
"security": [
|
|
33
|
+
"apikey",
|
|
34
|
+
"accesstoken",
|
|
35
|
+
"refreshtoken",
|
|
36
|
+
"privatekey",
|
|
37
|
+
"secretkey",
|
|
38
|
+
"cookie",
|
|
39
|
+
"session",
|
|
40
|
+
"encryptionkey",
|
|
41
|
+
"encryptionKey",
|
|
42
|
+
"plaintext",
|
|
43
|
+
"value"
|
|
44
|
+
]
|
|
45
|
+
},
|
|
46
|
+
"fieldPatterns": []
|
|
47
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: miso-client
|
|
3
|
-
Version: 5.2.
|
|
3
|
+
Version: 5.2.4
|
|
4
4
|
Summary: Python client SDK for AI Fabrix authentication, authorization, and logging
|
|
5
5
|
Home-page: https://github.com/aifabrix/miso-client-python
|
|
6
6
|
Author: AI Fabrix Team
|
|
@@ -682,6 +682,13 @@ The default configuration includes ISO 27001 compliant sensitive fields:
|
|
|
682
682
|
- PII: ssn, creditcard, cc, cvv, pin, otp
|
|
683
683
|
- Security: apikey, accesstoken, refreshtoken, privatekey, secretkey, cookie, session
|
|
684
684
|
|
|
685
|
+
Field-name matching is case-insensitive and ignores `_` and `-`. The sensitive
|
|
686
|
+
token `value` matches only a complete normalized field name, so `VALUE` and
|
|
687
|
+
`v_a_l_u_e` are masked while ordinary composite names such as `totalValue` and
|
|
688
|
+
`defaultValue` remain visible unless they match another sensitive token. Add a
|
|
689
|
+
genuinely sensitive composite name explicitly under `fields` in custom
|
|
690
|
+
configuration. Python `DataMasker` does not currently consume `fieldPatterns`.
|
|
691
|
+
|
|
685
692
|
**Masking JSON documents (for other projects):** Use `DataMasker` to mask sensitive fields in any JSON structure before logging or sending to external systems:
|
|
686
693
|
|
|
687
694
|
```python
|
|
@@ -108,6 +108,7 @@ miso_client/utils/origin_validator.py
|
|
|
108
108
|
miso_client/utils/pagination.py
|
|
109
109
|
miso_client/utils/request_context.py
|
|
110
110
|
miso_client/utils/request_target.py
|
|
111
|
+
miso_client/utils/sensitive_fields_config.json
|
|
111
112
|
miso_client/utils/sensitive_fields_loader.py
|
|
112
113
|
miso_client/utils/shared_task.py
|
|
113
114
|
miso_client/utils/sort.py
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "miso-client"
|
|
7
|
-
version = "5.2.
|
|
7
|
+
version = "5.2.4"
|
|
8
8
|
description = "Python client SDK for AI Fabrix authentication, authorization, and logging"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.11"
|
|
@@ -76,7 +76,7 @@ packages = [
|
|
|
76
76
|
]
|
|
77
77
|
|
|
78
78
|
[tool.setuptools.package-data]
|
|
79
|
-
miso_client = ["py.typed"]
|
|
79
|
+
miso_client = ["py.typed", "utils/sensitive_fields_config.json"]
|
|
80
80
|
|
|
81
81
|
[tool.pytest.ini_options]
|
|
82
82
|
testpaths = ["tests/unit"]
|
|
@@ -8,7 +8,7 @@ with open("README.md", "r", encoding="utf-8") as fh:
|
|
|
8
8
|
|
|
9
9
|
setup(
|
|
10
10
|
name="miso-client",
|
|
11
|
-
version="5.2.
|
|
11
|
+
version="5.2.4",
|
|
12
12
|
author="AI Fabrix Team",
|
|
13
13
|
author_email="team@aifabrix.ai",
|
|
14
14
|
description="Python client SDK for AI Fabrix authentication, authorization, and logging",
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|