Skip to content

Commit

Permalink
fix: Mask sensitive fields when reading container registry via the ma…
Browse files Browse the repository at this point in the history
…nager GQL API (#1627)
  • Loading branch information
achimnol authored Oct 24, 2023
1 parent 5b16305 commit b45ad45
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions changes/1627.fix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Mask sensitive fields when reading the container registry information via the manager GraphQL API
2 changes: 2 additions & 0 deletions src/ai/backend/manager/defs.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
# The default container role name for multi-container sessions
DEFAULT_ROLE: Final = "main"

PASSWORD_PLACEHOLDER: Final = "*****"

_RESERVED_VFOLDER_PATTERNS = [r"^\.[a-z0-9]+rc$", r"^\.[a-z0-9]+_profile$"]
RESERVED_DOTFILES = [".terminfo", ".jupyter", ".ssh", ".ssh/authorized_keys", ".local", ".config"]
RESERVED_VFOLDERS = [
Expand Down
4 changes: 3 additions & 1 deletion src/ai/backend/manager/models/etcd.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

from ai.backend.common.logging import BraceStyleAdapter

from ..defs import PASSWORD_PLACEHOLDER
from . import UserRole
from .base import privileged_mutation, set_if_set

Expand Down Expand Up @@ -67,6 +68,7 @@ class Meta:

@classmethod
def from_row(cls, hostname: str, config: Mapping[str, str | list | None]) -> ContainerRegistry:
password = config.get("password", None)
return cls(
id=hostname,
hostname=hostname,
Expand All @@ -75,7 +77,7 @@ def from_row(cls, hostname: str, config: Mapping[str, str | list | None]) -> Con
type=config.get("type"),
project=config.get("project", None),
username=config.get("username", None),
password=config.get("password", None),
password=PASSWORD_PLACEHOLDER if password is not None else None,
ssl_verify=config.get("ssl_verify", None),
),
)
Expand Down

0 comments on commit b45ad45

Please sign in to comment.