Skip to content

vmm-cli: sync APP_LAUNCH_TOKEN metadata#11

Closed
kvinwang wants to merge 1 commit intomasterfrom
kvin/auto-sync-app-launch-token
Closed

vmm-cli: sync APP_LAUNCH_TOKEN metadata#11
kvinwang wants to merge 1 commit intomasterfrom
kvin/auto-sync-app-launch-token

Conversation

@kvinwang
Copy link
Copy Markdown
Collaborator

Summary

  • add a shared helper to sync allowed_envs and launch_token_hash from encrypted env vars
  • apply the helper in compose, deploy, update, and update-env so the APP_LAUNCH_TOKEN pattern works consistently
  • document the CLI behavior in the security best practices doc

Validation

  • python3 -m py_compile vmm/src/vmm-cli.py
  • manual compose check for generated launch_token_hash
  • fake-RPC deploy flow check for updated compose/app_id behavior

Comment thread vmm/src/vmm-cli.py
Comment on lines 1095 to 1101
app_compose = json.loads(compose_file_content)
except json.JSONDecodeError:
app_compose = {}
compose_changed = False
allowed_envs = list(envs.keys())
if app_compose.get("allowed_envs") != allowed_envs:
app_compose["allowed_envs"] = allowed_envs
compose_changed = True
launch_token_value = envs.get("APP_LAUNCH_TOKEN")
if launch_token_value is not None:
launch_token_hash = hashlib.sha256(
launch_token_value.encode("utf-8")
).hexdigest()
if app_compose.get("launch_token_hash") != launch_token_hash:
app_compose["launch_token_hash"] = launch_token_hash
compose_changed = True
compose_changed = apply_env_metadata_to_compose(app_compose, envs)
if compose_changed:
upgrade_params["compose_file"] = json.dumps(
app_compose, indent=4, ensure_ascii=False
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Bug: When update_vm is called with both compose-modifying options and --env-file, the compose changes are overwritten and silently discarded due to re-loading stale data.
Severity: HIGH

Suggested Fix

The code path handling --env-file should not independently re-load the compose file from the server. Instead, it should operate on the potentially modified app_compose object from the preceding logic block to ensure that all updates are layered correctly before being finalized.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.

Location: vmm/src/vmm-cli.py#L1095-L1101

Potential issue: In the `update_vm` method, when a user provides both compose-modifying
options (e.g., `--compose`, `--prelaunch-script`) and an `--env-file` in the same
command, the changes from the compose-modifying options are silently discarded. This
occurs because the code path handling `--env-file` independently re-loads the original
compose file from the server, applies its own metadata, and then overwrites the
`upgrade_params["compose_file"]` variable, which may have already been updated by the
first code path. This results in the loss of the user's intended compose file
modifications.

Did we get this right? 👍 / 👎 to inform future reviews.

@kvinwang kvinwang closed this Apr 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant