Skip to content

Commit eb2b614

Browse files
Copilotswissspidy
andcommitted
Security: properly escape command arguments and improve PHPDoc type
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
1 parent 2e05531 commit eb2b614

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/Core_Command.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -945,9 +945,10 @@ public function version( $args = [], $assoc_args = [] ) {
945945
foreach ( $assoc_args as $key => $value ) {
946946
if ( 'actual' !== $key ) {
947947
if ( true === $value ) {
948-
$cmd_args[] = "--{$key}";
948+
$cmd_args[] = '--' . $key;
949949
} elseif ( is_string( $value ) ) {
950-
$cmd_args[] = "--{$key}={$value}";
950+
// Escape the value to prevent command injection
951+
$cmd_args[] = '--' . $key . '=' . escapeshellarg( $value );
951952
}
952953
}
953954
}
@@ -992,7 +993,7 @@ public function version( $args = [], $assoc_args = [] ) {
992993
* @when after_wp_load
993994
*
994995
* @param string[] $args Positional arguments. Unused.
995-
* @param array $assoc_args Associative arguments passed through from version command.
996+
* @param array{extra?: bool} $assoc_args Associative arguments passed through from version command.
996997
*/
997998
public function version_db_actual( $args = [], $assoc_args = [] ) {
998999
$details = self::get_wp_details();

0 commit comments

Comments
 (0)