@xynogen/pix-ssh 0.6.2 → 0.6.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/lib.ts +6 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xynogen/pix-ssh",
3
- "version": "0.6.2",
3
+ "version": "0.6.3",
4
4
  "description": "Pi tool \u2014 ssh_run: run remote commands over SSH with password/key auth and remote sudo",
5
5
  "type": "module",
6
6
  "main": "src/index.ts",
package/src/lib.ts CHANGED
@@ -89,6 +89,7 @@ export function parseHost(spec: string): HostSpec {
89
89
  const colons = rest.split(":").length - 1;
90
90
  if (rest.startsWith("[")) {
91
91
  const end = rest.indexOf("]");
92
+ if (end === -1) throw new Error(`Invalid host: ${spec} (missing "]")`);
92
93
  const hostPart = rest.slice(1, end);
93
94
  const tail = rest.slice(end + 1);
94
95
  if (tail.startsWith(":")) port = parsePort(tail.slice(1));
@@ -100,6 +101,11 @@ export function parseHost(spec: string): HostSpec {
100
101
  }
101
102
 
102
103
  if (!rest) throw new Error(`Invalid host: ${spec}`);
104
+ // The target is a positional argv entry; a leading "-" would make ssh/scp
105
+ // read it as an option (e.g. -oProxyCommand=...), which runs a local command.
106
+ if (rest.startsWith("-") || user?.startsWith("-")) {
107
+ throw new Error(`Invalid host: ${spec} (host and user must not start with "-")`);
108
+ }
103
109
  return { user, host: rest, ...(port !== undefined ? { port } : {}) };
104
110
  }
105
111