Skip to content

Commit 757fe18

Browse files
authored
Update expose settings to also mask cache_uri (#1006)
* Update expose settings mask_value to also mask Url type * Bumpversion to 4.2.0rc3
1 parent 3ab3628 commit 757fe18

File tree

5 files changed

+10
-20
lines changed

5 files changed

+10
-20
lines changed

.bumpversion.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[bumpversion]
2-
current_version = 4.2.0rc2
2+
current_version = 4.2.0rc3
33
commit = False
44
tag = False
55
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)(rc(?P<build>\d+))?

orchestrator/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
"""This is the orchestrator workflow engine."""
1515

16-
__version__ = "4.2.0rc2"
16+
__version__ = "4.2.0rc3"
1717

1818
from orchestrator.app import OrchestratorCore
1919
from orchestrator.settings import app_settings

orchestrator/services/settings_env_variables.py

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
from typing import Any, Dict, Type
1515

1616
from pydantic import SecretStr as PydanticSecretStr
17-
from pydantic_core import MultiHostUrl
17+
from pydantic_core import MultiHostUrl, Url
1818
from pydantic_settings import BaseSettings
1919

2020
from orchestrator.utils.expose_settings import SecretStr as OrchSecretStr
@@ -32,21 +32,9 @@ def expose_settings(settings_name: str, base_settings: Type[BaseSettings]) -> Ty
3232

3333
def mask_value(key: str, value: Any) -> Any:
3434
key_lower = key.lower()
35+
is_sensitive_key = "secret" in key_lower or "password" in key_lower
3536

36-
if "secret" in key_lower or "password" in key_lower:
37-
# Mask sensitive information
38-
return MASK
39-
40-
if isinstance(value, PydanticSecretStr):
41-
# Need to convert SecretStr to str for serialization
42-
return str(value)
43-
44-
if isinstance(value, OrchSecretStr):
45-
return MASK
46-
47-
# PostgresDsn is just MultiHostUrl with extra metadata (annotations)
48-
if isinstance(value, MultiHostUrl):
49-
# Convert PostgresDsn to str for serialization
37+
if is_sensitive_key or isinstance(value, (OrchSecretStr, PydanticSecretStr, MultiHostUrl, Url)):
5038
return MASK
5139

5240
return value

orchestrator/settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ class AppSettings(BaseSettings):
7272
TRACING_ENABLED: bool = False
7373
TRACE_HOST: str = "http://localhost:4317"
7474
TRANSLATIONS_DIR: Path | None = None
75-
WEBSOCKET_BROADCASTER_URL: str = "memory://"
75+
WEBSOCKET_BROADCASTER_URL: OrchSecretStr = "memory://" # type: ignore
7676
ENABLE_WEBSOCKETS: bool = True
7777
DISABLE_INSYNC_CHECK: bool = False
7878
DEFAULT_PRODUCT_WORKFLOWS: list[str] = ["modify_note"]

test/unit_tests/services/test_expose_settings.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from pydantic import PostgresDsn
1+
from pydantic import PostgresDsn, RedisDsn
22
from pydantic import SecretStr as PydanticSecretStr
33
from pydantic_settings import BaseSettings
44

@@ -14,6 +14,7 @@ class MySettings(BaseSettings):
1414
debug_mode: bool = True
1515
secret_test: str = "test_secret" # noqa: S105
1616
uri: PostgresDsn = "postgresql://user:password@localhost/dbname"
17+
cache_uri: RedisDsn = "rediss://user:password@localhost/dbname"
1718

1819
my_settings = MySettings()
1920
expose_settings("my_settings", my_settings)
@@ -25,11 +26,12 @@ class MySettings(BaseSettings):
2526

2627
assert exposed_settings[my_settings_index].name == "my_settings"
2728

28-
assert len(exposed_settings[my_settings_index].variables) == 5
29+
assert len(exposed_settings[my_settings_index].variables) == 6
2930

3031
# Assert that sensitive values are masked
3132
assert exposed_settings[my_settings_index].variables[0].env_value == MASK # api_key
3233
assert exposed_settings[my_settings_index].variables[1].env_value == MASK # db_password
3334
assert exposed_settings[my_settings_index].variables[2].env_value is True # debug_mode
3435
assert exposed_settings[my_settings_index].variables[3].env_value == MASK # secret_test
3536
assert exposed_settings[my_settings_index].variables[4].env_value == MASK # uri
37+
assert exposed_settings[my_settings_index].variables[5].env_value == MASK # cache_uri

0 commit comments

Comments
 (0)