Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion workflows/run_docker_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -437,14 +437,35 @@ def format_docker_command(docker_command):
f"{shlex.quote(docker_command[0])} {shlex.quote(docker_command[1])}"
)
i = 2

sensitive_env_keys = {"API_KEY", "OPENAI_API_KEY"}

def _redact_env_arg(env_assignment: str) -> str:
if "=" not in env_assignment:
return env_assignment
key, value = env_assignment.split("=", 1)
key_upper = key.upper()
if (
key_upper in sensitive_env_keys
or "TOKEN" in key_upper

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we narrow the token matching? "TOKEN" in key_upper also redacts ordinary settings such as VLLM__MAX_NUM_BATCHED_TOKENS=3072, which our embedding model specs use, and TOKENIZERS_PARALLELISM=false. This hides useful debugging information and makes copied commands pass ***REDACTED*** where a number or boolean is expected. Known credential names plus narrower patterns such as _TOKEN, _SECRET, and _PASSWORD would avoid these false positives. A regression test for an ordinary token-count setting would be useful.

or "SECRET" in key_upper
or "PASSWORD" in key_upper
or key_upper.endswith("_KEY")
):
return f"{key}=***REDACTED***"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The placeholder is appropriate for diagnostic logs, but copying the printed command now sets the container API key to the literal ***REDACTED***. That changes authentication behavior, so the PR description’s promise to preserve runnable commands needs qualification. Could we label this output as requiring credential substitution, or handle --print-docker-cmd separately? For manual execution, -e API_KEY can inherit the value without printing it, provided the variable is exported in the environment where Docker runs. Please also test that formatting leaves the original execution arguments unchanged.

return f"{key}={value}"

while i < len(docker_command):
quoted = shlex.quote(docker_command[i])
if (
docker_command[i].startswith("-")
and i + 1 < len(docker_command)
and not docker_command[i + 1].startswith("-")
):
next_quoted = shlex.quote(docker_command[i + 1])
next_arg = docker_command[i + 1]
if docker_command[i] in ("-e", "--env"):

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Smaller completeness point: this catches separate -e KEY=value and --env KEY=value arguments, but inline forms such as --env=API_KEY=... and -eAPI_KEY=... still expose the value. Current command generation uses separate arguments, so this does not block the immediate fix. Could we either document that input assumption or cover the inline forms with redaction and focused tests?

next_arg = _redact_env_arg(next_arg)
next_quoted = shlex.quote(next_arg)
lines.append(f"{quoted} {next_quoted}")
i += 2
else:
Expand Down
Loading