function sudo(command, promptOptions = { name: 'DDEV UI' }) {
  const bannedCharacters = [';', '|', '&'];
  const whitelistedCommands = ['version'];
  const ddevCommand = `ddev ${command}`;

  if (whitelistedCommands.indexOf(command) !== -1) {
    bannedCharacters.forEach(character => {
      if (command.includes(character)) {
        return Promise.reject(
          new Error(`${character} is not an allowed character in privilege escalation requests.`)
        );
      }
    });
    const promise = new Promise((resolve, reject) => {
      exec(ddevCommand, promptOptions, (error, stdout, stderr) => {
        if (error) {
          console.log(stderr);
          reject(new Error('Unable to escalate permissions.'));
        } else {
          resolve(stdout);
        }
      });
    });

    return promise;
  }
  return Promise.reject(new Error(`${ddevCommand} is not allowed to be run as sudo`));
}
/**
 * priv escalation - only allows whitelisted commands to be run as sudo, and bans dangerous characters
 * @param command {string} - ddev command to run
 * @param promptOptions {object} - sudo prompt options such as application name and prompt icon
 * @returns {promise} - resolves if escalation is successful with stdout text
 */
priv escalation - only allows whitelisted commands to be run as sudo, and bans dangerous characters
@param command {string} - ddev command to run
@param promptOptions {object} - sudo prompt options such as application name and prompt icon
@returns {promise} - resolves if escalation is successful with stdout text
priv escalation - only allows whitelisted commands to be run as sudo and bans dangerous characters @param command { string } - ddev command to run @param promptOptions { object } - sudo prompt options such as application name and prompt icon @returns { promise } - resolves if escalation is successful with stdout text
function sudo(command, promptOptions = { name: 'DDEV UI' }) {
  const bannedCharacters = [';', '|', '&'];
  const whitelistedCommands = ['version'];
  const ddevCommand = `ddev ${command}`;
  if (whitelistedCommands.indexOf(command) !== -1) {
    bannedCharacters.forEach(character => {
      if (command.includes(character)) {
        return Promise.reject(
          new Error(`${character} is not an allowed character in privilege escalation requests.`)
        );
      }
    });
    const promise = new Promise((resolve, reject) => {
      exec(ddevCommand, promptOptions, (error, stdout, stderr) => {
        if (error) {
          console.log(stderr);
          reject(new Error('Unable to escalate permissions.'));
        } else {
          resolve(stdout);
        }
      });
    });
    return promise;
  }
  return Promise.reject(new Error(`${ddevCommand} is not allowed to be run as sudo`));
}
function sudo ( command , promptOptions = { name : 'DDEV UI' } ) { const bannedCharacters = [ ';' , '|' , '&' ] ; const whitelistedCommands = [ 'version' ] ; const ddevCommand = ` ${ command } ` ; if ( whitelistedCommands . indexOf ( command ) !== - 1 ) { bannedCharacters . forEach ( character => { if ( command . includes ( character ) ) { return Promise . reject ( new Error ( ` ${ character } ` ) ) ; } } ) ; const promise = new Promise ( ( resolve , reject ) => { exec ( ddevCommand , promptOptions , ( error , stdout , stderr ) => { if ( error ) { console . log ( stderr ) ; reject ( new Error ( 'Unable to escalate permissions.' ) ) ; } else { resolve ( stdout ) ; } } ) ; } ) ; return promise ; } return Promise . reject ( new Error ( ` ${ ddevCommand } ` ) ) ; }
priv escalation - only allows whitelisted commands to be run as sudo, and bans dangerous characters
 @param command {string} - ddev command to run
 @param promptOptions {object} - sudo prompt options such as application name and prompt icon
 @returns {promise} - resolves if escalation is successful with stdout text
priv escalation - only allows whitelisted commands to be run as sudo and bans dangerous characters @param command { string } - ddev command to run @param promptOptions { object } - sudo prompt options such as application name and prompt icon @returns { promise } - resolves if escalation is successful with stdout text