mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-24 06:27:02 +02:00
fix(create-docusaurus): potential security issue with command injection (#7507)
This commit is contained in:
parent
cd7cf781cd
commit
dbd161d67c
7 changed files with 59 additions and 22 deletions
|
@ -13,6 +13,7 @@ import logger from '@docusaurus/logger';
|
|||
import shell from 'shelljs';
|
||||
import prompts, {type Choice} from 'prompts';
|
||||
import supportsColor from 'supports-color';
|
||||
import {escapeShellArg} from '@docusaurus/utils';
|
||||
|
||||
type CLIOptions = {
|
||||
packageManager?: PackageManager;
|
||||
|
@ -463,9 +464,11 @@ export default async function init(
|
|||
logger.info('Creating new Docusaurus project...');
|
||||
|
||||
if (source.type === 'git') {
|
||||
logger.info`Cloning Git template url=${source.url}...`;
|
||||
const command = await getGitCommand(source.strategy);
|
||||
if (shell.exec(`${command} ${source.url} ${dest}`).code !== 0) {
|
||||
const gitCommand = await getGitCommand(source.strategy);
|
||||
const gitCloneCommand = `${gitCommand} ${escapeShellArg(
|
||||
source.url,
|
||||
)} ${escapeShellArg(dest)}`;
|
||||
if (shell.exec(gitCloneCommand).code !== 0) {
|
||||
logger.error`Cloning Git template failed!`;
|
||||
process.exit(1);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue