Sanitization
provide.foundation.security.sanitization
¶
TODO: Add module docstring.
Functions¶
sanitize_dict
¶
sanitize_dict(
data: dict[str, Any],
sensitive_keys: list[str] | None = None,
redacted: str = REDACTED_VALUE,
recursive: bool = True,
) -> dict[str, Any]
Sanitize sensitive keys in dictionary for safe logging.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
dict[str, Any]
|
Dictionary to sanitize |
required |
sensitive_keys
|
list[str] | None
|
List of keys to redact (case-insensitive) |
None
|
redacted
|
str
|
Replacement value for redacted values |
REDACTED_VALUE
|
recursive
|
bool
|
Whether to recursively sanitize nested dicts |
True
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Sanitized dictionary |
Source code in provide/foundation/security/sanitization.py
sanitize_headers
¶
sanitize_headers(
headers: Mapping[str, Any],
sensitive_headers: list[str] | None = None,
redacted: str = REDACTED_VALUE,
) -> dict[str, Any]
Sanitize sensitive headers for safe logging.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
headers
|
Mapping[str, Any]
|
Headers dictionary to sanitize |
required |
sensitive_headers
|
list[str] | None
|
List of header names to redact (case-insensitive) |
None
|
redacted
|
str
|
Replacement value for redacted headers |
REDACTED_VALUE
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Sanitized headers dictionary |
Source code in provide/foundation/security/sanitization.py
sanitize_uri
¶
sanitize_uri(
uri: str,
sensitive_params: list[str] | None = None,
redacted: str = REDACTED_VALUE,
) -> str
Sanitize sensitive query parameters in URI for safe logging.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
uri
|
str
|
URI to sanitize |
required |
sensitive_params
|
list[str] | None
|
List of parameter names to redact (case-insensitive) |
None
|
redacted
|
str
|
Replacement value for redacted parameters |
REDACTED_VALUE
|
Returns:
| Type | Description |
|---|---|
str
|
Sanitized URI string |
Source code in provide/foundation/security/sanitization.py
should_sanitize_body
¶
Determine if body should be sanitized based on content type.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
content_type
|
str | None
|
Content-Type header value |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if body should be sanitized |