Skip to content

Add support for --env-mysql-* flags for secure credential passing#284

Open
TheVaibhaw wants to merge 1 commit into
WordPress:trunkfrom
TheVaibhaw:feature/env-db-password
Open

Add support for --env-mysql-* flags for secure credential passing#284
TheVaibhaw wants to merge 1 commit into
WordPress:trunkfrom
TheVaibhaw:feature/env-db-password

Conversation

@TheVaibhaw

Copy link
Copy Markdown

Implements feature requested in issue #24:

  • Add --env-mysql-password=VAR_NAME support
  • Add --env-mysql-user=VAR_NAME support
  • Add --env-mysql-host=VAR_NAME support
  • Add --env-mysql-database=VAR_NAME support

These flags allow credentials to be sourced from environment variables specified by the user, avoiding password visibility in 'ps aux' output.

Maintains backward compatibility with existing --mysql-* flags. Falls back to hardcoded MYSQL_PASSWORD env var if no flag specified.

Changes:

  • Add CLI option definitions for all 4 new flags
  • Update credential parsing logic to check env flags first
  • Only persist non-password credentials in state

Fixes #24

Implements feature requested in issue WordPress#24:
- Add --env-mysql-password=VAR_NAME support
- Add --env-mysql-user=VAR_NAME support
- Add --env-mysql-host=VAR_NAME support
- Add --env-mysql-database=VAR_NAME support

These flags allow credentials to be sourced from environment variables
specified by the user, avoiding password visibility in 'ps aux' output.

Maintains backward compatibility with existing --mysql-* flags.
Falls back to hardcoded MYSQL_PASSWORD env var if no flag specified.

Changes:
- Add CLI option definitions for all 4 new flags
- Update credential parsing logic to check env flags first
- Only persist non-password credentials in state

Fixes WordPress#24
if (isset($options["env_mysql_host"])) {
$env_var_name = $options["env_mysql_host"];
$this->mysql_host = getenv($env_var_name) ?: '';
if (!empty($this->mysql_host)) {

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.

I'd remove this check. If we're telling the tool to use a specific ENV, let it use specific ENV. We're not checking for non-empty values in other branches. Other than that, this PR looks good!

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.

Support --env-db-password=DB_PASSWORD

2 participants