Skip to content

Commit 6552b3a

Browse files
Copilotswissspidy
andcommitted
Add security comments clarifying safe shell command usage
Added comments explaining that null device paths are hardcoded constants and safe to use in shell commands, addressing static analysis concerns. Co-authored-by: swissspidy <[email protected]>
1 parent e8a6f23 commit 6552b3a

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/WP_CLI/PackageValidator.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ private static function is_unzip_available() {
7676
if ( null === $is_available ) {
7777
// Check if unzip is in PATH by trying to get its version.
7878
// Suppress output to avoid cluttering the console.
79+
// Note: Redirection to null device is safe as the device path is a hardcoded constant.
7980
$null_device = '\\' === DIRECTORY_SEPARATOR ? 'NUL' : '/dev/null';
8081
$result = WP_CLI::launch(
8182
'unzip -v > ' . escapeshellarg( $null_device ) . ' 2>&1',
@@ -96,6 +97,7 @@ private static function is_unzip_available() {
9697
*/
9798
private static function validate_with_unzip( $file_path ) {
9899
// Suppress output - use platform-appropriate null device.
100+
// Note: Null device path is a hardcoded constant, safe to use in shell commands.
99101
$null_device = '\\' === DIRECTORY_SEPARATOR ? 'NUL' : '/dev/null';
100102
$command = 'unzip -t ' . escapeshellarg( $file_path ) . ' > ' . escapeshellarg( $null_device ) . ' 2>&1';
101103

0 commit comments

Comments
 (0)