Skip to content

Commit

Permalink
Sanitize theme code input in BuildThemesCommand for static content de…
Browse files Browse the repository at this point in the history
…ployment and improve success/error messaging
  • Loading branch information
dermatz committed Dec 20, 2024
1 parent 0c25f3d commit f549144
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/Console/Command/BuildThemesCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,13 @@ protected function execute(InputInterface $input, OutputInterface $output): int

// Run static content deploy
$io->section("Running 'magento setup:static-content:deploy -t $themeCode -f'... Please wait.");
exec("php bin/magento setup:static-content:deploy -t $themeCode -f", $outputLines, $resultCode);
$sanitizedThemeCode = escapeshellarg($themeCode);

Check warning on line 99 in src/Console/Command/BuildThemesCommand.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

src/Console/Command/BuildThemesCommand.php#L99

The use of function escapeshellarg() is discouraged
exec("php bin/magento setup:static-content:deploy -t $sanitizedThemeCode -f", $outputLines, $resultCode);

Check failure on line 100 in src/Console/Command/BuildThemesCommand.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

src/Console/Command/BuildThemesCommand.php#L100

System program execution function exec() detected with dynamic parameter
$io->writeln($outputLines);
if ($resultCode === 0) {
$io->success("'magento setup:static-content:deploy -t $themeCode -f' has been successfully executed.");
$io->success("'magento setup:static-content:deploy -t $sanitizedThemeCode -f' has been successfully executed.");
} else {
$io->error("'magento setup:static-content:deploy -t $themeCode -f' failed. Please check the output for more details.");
$io->error("'magento setup:static-content:deploy -t $sanitizedThemeCode -f' failed. Please check the output for more details.");
}

// Clean the output before the next theme is running
Expand Down

0 comments on commit f549144

Please sign in to comment.