ruvnet/ruflo · error

Command not allowed: ${cmd.split(' ')[0]}

Error message

Command not allowed: ${cmd.split(' ')[0]}

What it means

Validator only executes commands starting with 'npm run ', 'npm ', 'npx ', or 'git ' (Validator.ALLOWED_COMMAND_PREFIXES). The first token of anything else is reported back in the error. Note this list is narrower than Publisher's: pnpm and yarn are NOT allowed here.

Source

Thrown at v3/@claude-flow/deployment/src/validator.ts:283

    'npx ',
    'git ',
  ];

  /**
   * Execute command safely with validation
   */
  private execCommand(cmd: string, returnOutput = false): string {
    // Validate: check for shell metacharacters
    if (/[;&|`$()<>]/.test(cmd)) {
      throw new Error(`Invalid command: contains shell metacharacters`);
    }

    // Validate: must start with allowed prefix
    const isAllowed = Validator.ALLOWED_COMMAND_PREFIXES.some(
      prefix => cmd.startsWith(prefix)
    );
    if (!isAllowed) {
      throw new Error(`Command not allowed: ${cmd.split(' ')[0]}`);
    }

    try {
      const output = execSync(cmd, {
        cwd: this.cwd,
        encoding: 'utf-8',
        stdio: returnOutput ? 'pipe' : 'inherit',
        timeout: 60000, // 60 second timeout for builds
        maxBuffer: 50 * 1024 * 1024, // 50MB buffer for build output
      });
      return returnOutput ? output : '';
    } catch (error) {
      if (returnOutput && error instanceof Error) {
        throw error;
      }
      throw error;
    }
  }

View on GitHub (pinned to fa13ee4ad6)

Solutions

  1. Use npm-based forms: 'npm test', 'npm run test', 'npx jest', 'npx vitest run'
  2. For non-npm toolchains, run validation outside the Validator class and pass only npm/npx/git strings to it

Example fix

// before
validate({ testCommand: 'pnpm test' }); // throws: Command not allowed: pnpm

// after
validate({ testCommand: 'npx pnpm test' }); // or 'npm test' in a npm-managed repo
Defensive patterns

Strategy: validation

Validate before calling

const ALLOWED = ['npm run ', 'npm ', 'npx ', 'git '];
function isValidatorAllowedCommand(cmd: string): boolean {
  return ALLOWED.some(p => cmd.startsWith(p));
}
// pnpm/yarn are NOT allowed here — normalize first
const test = pkgManager === 'pnpm' ? 'npx pnpm test' : 'npm test';
if (!isValidatorAllowedCommand(test)) throw new Error('validator only runs npm/npx/git');

Prevention

When it happens

Trigger: validate({ testCommand: 'pnpm test' }) or 'yarn test', 'node --test', 'jest', 'vitest run' — none matches an allowed prefix.

Common situations: pnpm/yarn workspaces assumed to work because Publisher's build allowlist accepts them; direct test-runner invocations copied from package.json scripts.

Related errors


AI-assisted analysis of ruvnet/ruflo@fa13ee4ad6 (2026-08-18). Data as JSON: /api/errors/8270703869d66fc0. Report an issue: GitHub.