{"record":{"id":"a241425121c66499","repo":"affaan-m/ECC","slug":"unknown-argument-arg-a24142","errorCode":null,"errorMessage":"Unknown argument: ${arg}","messagePattern":"Unknown argument: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/ci/scan-supply-chain-iocs.js","lineNumber":787,"sourceCode":"}\n\nfunction parseArgs(argv) {\n  const options = {};\n  for (let i = 0; i < argv.length; i++) {\n    const arg = argv[i];\n    if (arg === '--help' || arg === '-h') {\n      options.help = true;\n    } else if (arg === '--root') {\n      options.rootDir = argv[++i];\n    } else if (arg === '--home') {\n      options.home = true;\n    } else if (arg === '--home-dir') {\n      options.home = true;\n      options.homeDir = argv[++i];\n    } else if (arg === '--json') {\n      options.json = true;\n    } else {\n      throw new Error(`Unknown argument: ${arg}`);\n    }\n  }\n  return options;\n}\n\nfunction printHelp() {\n  console.log(`Usage: node scripts/ci/scan-supply-chain-iocs.js [options]\n\nScan dependency manifests, lockfiles, installed package payloads, and AI-tool\npersistence paths for active supply-chain IOC markers.\n\nOptions:\n  --root <dir>       Directory to scan (default: repo root)\n  --home             Also scan user-level Claude, VS Code, LaunchAgent, systemd,\n                     local bin, and /tmp persistence targets\n  --home-dir <dir>   Home directory to use with --home\n  --json             Emit JSON instead of text\n  --help, -h         Show this help","sourceCodeStart":769,"sourceCodeEnd":805,"githubUrl":"https://github.com/affaan-m/ECC/blob/01e15490f04e29cfefe3896951f43db46994d8ee/scripts/ci/scan-supply-chain-iocs.js#L769-L805","documentation":"`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.","triggerScenarios":"Triggered by passing an unsupported flag such as `--write`, `--check`, `--refresh`, `--timeout-ms`, `--output`, positional paths, or a misspelled flag like `--hoem`.","commonSituations":"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.","solutions":["Run `node scripts/ci/scan-supply-chain-iocs.js --help` to see the allowed flag set (this script does support `--help`).","Use `--root <dir>` to scope the scan, `--home`/`--home-dir` to also scan user-level persistence paths, `--json` for JSON output.","Remove any value-bearing flag not listed above; the scanner does not write a report file.","If you need advisory-source features (--refresh, --write, --timeout-ms), invoke scripts/ci/supply-chain-advisory-sources.js instead."],"exampleFix":"// before — passing --write (not supported by the IOC scanner)\nnode scripts/ci/scan-supply-chain-iocs.js --write --json\n// -> Unknown argument: --write\n\n// after\nnode scripts/ci/scan-supply-chain-iocs.js --json\n// (this scanner prints to stdout; it does not write a file)","handlingStrategy":"validation","validationCode":"const allowed = new Set(['--help', '-h', '--root', '--home', '--home-dir', '--json']);\nconst argv = process.argv.slice(2);\nfor (let i = 0; i < argv.length; i++) {\n  const arg = argv[i];\n  if (!allowed.has(arg)) {\n    console.error(`Unknown argument: ${arg}. Run --help for usage.`);\n    process.exit(2);\n  }\n  if (arg === '--root' || arg === '--home-dir') i++; // consume value\n}","typeGuard":"function isAllowedScannerArg(arg) {\n  return new Set(['--help', '-h', '--root', '--home', '--home-dir', '--json']).has(arg);\n}","tryCatchPattern":"try {\n  parseArgs(argv);\n} catch (error) {\n  if (/Unknown argument/i.test(error.message)) {\n    console.error('Allowed flags: --help, -h, --root <dir>, --home, --home-dir <dir>, --json.');\n    console.error('For --refresh/--write/--timeout-ms, use scripts/ci/supply-chain-advisory-sources.js.');\n  }\n  throw error;\n}","preventionTips":["This scanner does not write files — do not pass --write.","Run `--help` to see the supported flag set.","Do not confuse with the advisory-sources script, which has a different flag set.","Pass directories via --root <dir>, not as positional args."],"tags":["ci","supply-chain","security","cli","argument-validation"],"backgroundTag":null,"analyzedSha":"01e15490f04e29cfefe3896951f43db46994d8ee","analyzedAt":"2026-08-13T00:31:08.655Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}