{"record":{"id":"1588f95e0e2776f7","repo":"Hmbown/CodeWhale","slug":"invalid-user","errorCode":"invalid_user","errorMessage":"user must be a plain name","messagePattern":"user must be a plain name","errorType":"validation","errorClass":"RegistryError","httpStatus":null,"severity":"error","filePath":"crates/tui/plugins/computer-use/src/registry.mjs","lineNumber":94,"sourceCode":"\n/** Register or update a computer. Returns the entry. */\nexport function register({ id, transport, label, ...rest }) {\n  if (!id || !ID_RE.test(id)) throw new RegistryError(\"invalid_id\", \"computer id must match \" + ID_RE);\n  if (![\"local\", \"ssh\", \"hdc\", \"docker\"].includes(transport)) {\n    throw new RegistryError(\"invalid_transport\", \"transport must be one of: local, ssh, hdc, docker\");\n  }\n  if (id === \"local\" && transport !== \"local\") {\n    throw new RegistryError(\"reserved_id\", '\"local\" is reserved for this machine');\n  }\n  if (transport === \"ssh\") {\n    if (!rest.host || !/^[A-Za-z0-9._-]+$/.test(rest.host)) {\n      throw new RegistryError(\"invalid_host\", \"ssh computers need a valid host (letters, digits, dot, dash, underscore)\");\n    }\n    if (rest.port != null && (!Number.isInteger(rest.port) || rest.port < 1 || rest.port > 65535)) {\n      throw new RegistryError(\"invalid_port\", \"port must be an integer in 1..65535\");\n    }\n    if (rest.user != null && !/^[a-zA-Z0-9._-]+$/.test(rest.user)) {\n      throw new RegistryError(\"invalid_user\", \"user must be a plain name\");\n    }\n  }\n  if (transport === \"hdc\") {\n    if (rest.target != null && !/^[A-Za-z0-9._-]*$/.test(rest.target)) {\n      throw new RegistryError(\"invalid_target\", \"hdc target key contains invalid characters\");\n    }\n    rest.platform = \"harmonyos\";\n  }\n  if (transport === \"docker\") {\n    if (!rest.container || !/^[A-Za-z0-9][A-Za-z0-9_.-]{0,127}$/.test(rest.container)) {\n      throw new RegistryError(\"invalid_container\", \"docker computers need a valid container name\");\n    }\n    // Spawned containers always run the Linux desktop image.\n    rest.platform = rest.platform ?? \"linux\";\n  }\n  const reg = load();\n  const prev = reg.computers[id];\n  reg.computers[id] = {","sourceCodeStart":76,"sourceCodeEnd":112,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/plugins/computer-use/src/registry.mjs#L76-L112","documentation":"RegistryError \"invalid_user\": for ssh transports, an optional rest.user must match ^[a-zA-Z0-9._-]+$ — a plain login name. The user string is interpolated into an ssh command line, so values containing spaces, @, /, or shell metacharacters are rejected to prevent argument injection and broken ssh invocations.","triggerScenarios":"register({ id: \"x\", transport: \"ssh\", host: \"h\", user: \"alice dev\" }); user: \"alice; rm -rf /\"; user: \"domain\\\\alice\"; user: \"\" (empty string fails the regex).","commonSituations":"Copy-pasting a full identity like \"alice@example.com\" or \"DOMAIN\\\\alice\" from Windows environments; accidentally leaving an empty user key from a template; shell-quoted strings from scripts.","solutions":["Use only the bare login name, e.g. user: \"alice\".","Strip domain prefixes/backslashes and everything after @ or space before registering.","Omit rest.user entirely to rely on the machine's default ssh identity/ssh-config user.","Escape or sanitize any programmatically derived user value against ^[a-zA-Z0-9._-]+$."],"exampleFix":"// before\nregister({ id: \"lab\", transport: \"ssh\", host: \"10.0.0.5\", user: \"alice@example.com\" });\n// after\nregister({ id: \"lab\", transport: \"ssh\", host: \"10.0.0.5\", user: \"alice\" });","handlingStrategy":"validation","validationCode":"const USER_RE = /^[a-zA-Z0-9._-]+$/;\nif (user != null && (typeof user !== \"string\" || !USER_RE.test(user))) throw new Error(\"user must be a plain login name\");","typeGuard":"const isPlainUser = (u) => typeof u === \"string\" && /^[a-zA-Z0-9._-]+$/.test(u);","tryCatchPattern":"try {\n  register(cfg);\n} catch (e) {\n  if (e?.code === \"invalid_user\") throw new Error(`User \"${cfg.user}\" rejected; use the bare login name`);\n  throw e;\n}","preventionTips":["Strip domain prefixes (DOMAIN\\\\user) and @realm suffixes","Omit user to use ssh's default identity","Never pass shell-quoted or spaced identities","Treat user as an opaque plain token, not a connection string"],"tags":["validation","ssh","injection-prevention","registry"],"backgroundTag":"invalid-argument-value","analyzedSha":"73e0f67d83c59909b571efdfc88c4bc28c309cb1","analyzedAt":"2026-09-22T01:30:00.501Z","contentChangedAt":"2026-09-22T01:30:00.501Z","schemaVersion":2},"datasetVersion":"2026-09-22T11:17:16.035Z"}