Skip to content

fix(site): validate the site name and quote values in WordPress create commands - #243

Merged
mrrobot47 merged 4 commits into
EasyEngine:developfrom
mrrobot47:fix/site-name-validation
Oct 12, 2026
Merged

mrrobot47 merged 4 commits into
EasyEngine:developfrom
mrrobot47:fix/site-name-validation

Conversation

@mrrobot47

Copy link
Copy Markdown
Member

Calls site-command's site-name validation on create (when available), and quotes the database, admin and cache values passed to wp config, wp core install and the remote database checks. Values with quotes or shell characters, such as a database password or a site title with an apostrophe, now work. The logged install command masks the admin credentials in their quoted form.

Needs the site-command site-name validation (EasyEngine/site-command#509, merged) for the validation itself; without it the create behaves as before.

Validate the site name with site-command's validate_site_name() right after it is lowercased, before anything touches the shell, the file system or docker. Needs the site-command release that adds validate_site_name().
The page cache key prefixes were interpolated unquoted, and the wp core install URL, the wp config create DB name and user, and the remote DB checks used hand-written quotes (nested inside a double-quoted bash -c script for the remote DB checks), so a value containing a quote or shell syntax was not passed through as one argument. Quote each value with escapeshellarg(), nesting it for the sh -c/bash -c scripts.
… check

site-command's create router validates the name as well; the guard keeps site-type-wp working next to an older site-command instead of failing with an undefined function.
The install command now carries the shell-escaped admin values, which differ from the raw values when they contain a quote, so the log masking missed them. Mask the escaped forms first, then the raw ones.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

Remote database names remain vulnerable to SQL injection despite shell escaping.

2 open findings
What changed in this PR

Adds optional site-name validation and safer shell argument handling during WordPress creation.

Changes:

  • Validates site names when supported by site-command.
  • Quotes database, cache, and administrator values.
  • Masks quoted administrator credentials in logs.
File Description
src/​WordPress.php Hardens site creation and database commands.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/WordPress.php
Comment thread src/WordPress.php
@mrrobot47
mrrobot47 merged commit f715a65 into EasyEngine:develop Oct 12, 2026
3 checks passed
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.

2 participants