affaan-m/ECC · error · Error

Unknown argument: ${arg}

Error message

Unknown argument: ${arg}

What it means

`parseArgs` in scan-supply-chain-iocs.js accepts only `--help`/`-h`, `--root <dir>`, `--home`, `--home-dir <dir>`, and `--json`. Any other token throws `Unknown argument: <arg>`. This is a fast-fail guard at the top of the IOC scanner's CLI.

Source

Thrown at scripts/ci/scan-supply-chain-iocs.js:787

}

function parseArgs(argv) {
  const options = {};
  for (let i = 0; i < argv.length; i++) {
    const arg = argv[i];
    if (arg === '--help' || arg === '-h') {
      options.help = true;
    } else if (arg === '--root') {
      options.rootDir = argv[++i];
    } else if (arg === '--home') {
      options.home = true;
    } else if (arg === '--home-dir') {
      options.home = true;
      options.homeDir = argv[++i];
    } else if (arg === '--json') {
      options.json = true;
    } else {
      throw new Error(`Unknown argument: ${arg}`);
    }
  }
  return options;
}

function printHelp() {
  console.log(`Usage: node scripts/ci/scan-supply-chain-iocs.js [options]

Scan dependency manifests, lockfiles, installed package payloads, and AI-tool
persistence paths for active supply-chain IOC markers.

Options:
  --root <dir>       Directory to scan (default: repo root)
  --home             Also scan user-level Claude, VS Code, LaunchAgent, systemd,
                     local bin, and /tmp persistence targets
  --home-dir <dir>   Home directory to use with --home
  --json             Emit JSON instead of text
  --help, -h         Show this help

View on GitHub (pinned to 01e15490f0)

Solutions

  1. Run `node scripts/ci/scan-supply-chain-iocs.js --help` to see the allowed flag set (this script does support `--help`).
  2. Use `--root <dir>` to scope the scan, `--home`/`--home-dir` to also scan user-level persistence paths, `--json` for JSON output.
  3. Remove any value-bearing flag not listed above; the scanner does not write a report file.
  4. If you need advisory-source features (--refresh, --write, --timeout-ms), invoke scripts/ci/supply-chain-advisory-sources.js instead.

Example fix

// before — passing --write (not supported by the IOC scanner)
node scripts/ci/scan-supply-chain-iocs.js --write --json
// -> Unknown argument: --write

// after
node scripts/ci/scan-supply-chain-iocs.js --json
// (this scanner prints to stdout; it does not write a file)
Defensive patterns

Strategy: validation

Validate before calling

const allowed = new Set(['--help', '-h', '--root', '--home', '--home-dir', '--json']);
const argv = process.argv.slice(2);
for (let i = 0; i < argv.length; i++) {
  const arg = argv[i];
  if (!allowed.has(arg)) {
    console.error(`Unknown argument: ${arg}. Run --help for usage.`);
    process.exit(2);
  }
  if (arg === '--root' || arg === '--home-dir') i++; // consume value
}

Type guard

function isAllowedScannerArg(arg) {
  return new Set(['--help', '-h', '--root', '--home', '--home-dir', '--json']).has(arg);
}

Try / catch

try {
  parseArgs(argv);
} catch (error) {
  if (/Unknown argument/i.test(error.message)) {
    console.error('Allowed flags: --help, -h, --root <dir>, --home, --home-dir <dir>, --json.');
    console.error('For --refresh/--write/--timeout-ms, use scripts/ci/supply-chain-advisory-sources.js.');
  }
  throw error;
}

Prevention

When it happens

Trigger: Triggered by passing an unsupported flag such as `--write`, `--check`, `--refresh`, `--timeout-ms`, `--output`, positional paths, or a misspelled flag like `--hoem`.

Common situations: Confusing this scanner's flag set with the advisory-sources script (which supports `--refresh`/`--timeout-ms`/`--write`). Assuming `--write` exists for emitting a report file. Passing a positional directory instead of `--root <dir>`. A typo.

Related errors


AI-assisted analysis of affaan-m/ECC@01e15490f0 (2026-08-13). Data as JSON: /api/errors/a241425121c66499. Report an issue: GitHub.