@p0security/cli 0.12.0 → 0.13.0

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.
@@ -30,6 +30,7 @@ const firestore_1 = require("../drivers/firestore");
30
30
  const stdio_1 = require("../drivers/stdio");
31
31
  const lodash_1 = require("lodash");
32
32
  const pluralize_1 = __importDefault(require("pluralize"));
33
+ const DEFAULT_RESPONSE_SIZE = 15;
33
34
  const lsArgs = (yargs) => yargs
34
35
  .parserConfiguration({ "unknown-options-as-args": true })
35
36
  .help(false)
@@ -40,9 +41,27 @@ const lsArgs = (yargs) => yargs
40
41
  });
41
42
  const lsCommand = (yargs) => yargs.command("ls [arguments..]", "List request-command arguments", lsArgs, (0, firestore_1.fsShutdownGuard)(ls));
42
43
  exports.lsCommand = lsCommand;
44
+ /**
45
+ * If the user has requested a size, replace it with double the requested size,
46
+ * otherwise request double the default.
47
+ *
48
+ * This is done so that we can give the user a sense of the number of results
49
+ * that are not displayed.
50
+ */
51
+ const convertLsSizeArg = (args) => {
52
+ var _a;
53
+ const convertedArgs = [...args];
54
+ const sizeIndex = convertedArgs.findIndex((a) => a === "--size");
55
+ const requestedSize = +((_a = (sizeIndex >= 0
56
+ ? (0, lodash_1.pullAt)(convertedArgs, sizeIndex, sizeIndex + 1)[1]
57
+ : undefined)) !== null && _a !== void 0 ? _a : DEFAULT_RESPONSE_SIZE);
58
+ convertedArgs.push("--size", String(requestedSize * 2));
59
+ return { convertedArgs, requestedSize };
60
+ };
43
61
  const ls = (args) => __awaiter(void 0, void 0, void 0, function* () {
44
62
  const authn = yield (0, auth_1.authenticate)();
45
- const data = yield (0, stdio_1.spinUntil)("Listing accessible resources", (0, api_1.fetchCommand)(authn, args, ["ls", ...args.arguments]));
63
+ const { convertedArgs, requestedSize } = convertLsSizeArg(args.arguments);
64
+ const data = yield (0, stdio_1.spinUntil)("Listing accessible resources", (0, api_1.fetchCommand)(authn, args, ["ls", ...convertedArgs]));
46
65
  const allArguments = [...args._, ...args.arguments];
47
66
  if (data && "ok" in data && data.ok) {
48
67
  const label = (0, pluralize_1.default)(data.arg);
@@ -50,8 +69,8 @@ const ls = (args) => __awaiter(void 0, void 0, void 0, function* () {
50
69
  (0, stdio_1.print2)(`No ${label}`);
51
70
  return;
52
71
  }
53
- const truncationPart = data.isTruncated
54
- ? ` the first ${data.items.length}`
72
+ const truncationPart = data.items.length > requestedSize
73
+ ? ` the first ${requestedSize} (of ${data.isTruncated ? "many" : data.items.length})`
55
74
  : "";
56
75
  const postfixPart = data.term
57
76
  ? ` matching '${data.term}'`
@@ -59,7 +78,8 @@ const ls = (args) => __awaiter(void 0, void 0, void 0, function* () {
59
78
  ? ` (use \`p0 ${allArguments.join(" ")} <like>\` to narrow results)`
60
79
  : "";
61
80
  (0, stdio_1.print2)(`Showing${truncationPart} ${label}${postfixPart}.\nResources labeled with * are already accessible to you:`);
62
- const sortedItems = (0, lodash_1.orderBy)(data.items, "isPreexisting", "desc");
81
+ const truncated = (0, lodash_1.slice)(data.items, 0, requestedSize);
82
+ const sortedItems = (0, lodash_1.orderBy)(truncated, "isPreexisting", "desc");
63
83
  const isSameValue = sortedItems.every((i) => !i.group && i.key === i.value);
64
84
  const maxLength = (0, lodash_1.max)(sortedItems.map((i) => i.key.length)) || 0;
65
85
  for (const item of sortedItems) {
@@ -1 +1 @@
1
- {"version":3,"file":"ls.js","sourceRoot":"","sources":["../../src/commands/ls.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA;;;;;;;;;GASG;AACH,0CAA0C;AAC1C,wCAA8C;AAC9C,0CAA+C;AAC/C,oDAAuD;AACvD,4CAA6D;AAC7D,mCAAsC;AACtC,0DAAkC;AAgBlC,MAAM,MAAM,GAAG,CAAI,KAAoB,EAAE,EAAE,CACzC,KAAK;KACF,mBAAmB,CAAC,EAAE,yBAAyB,EAAE,IAAI,EAAE,CAAC;KACxD,IAAI,CAAC,KAAK,CAAC;KACX,MAAM,CAAC,WAAW,EAAE;IACn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CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,GAAG,cAAO,CAAC,GAAG,MAAM,OAAO,GAAG,cAAO,CAAC,KAAK,EAChF,EAAE,CACH,CAAC;SACH;KACF;SAAM;QACL,MAAM,IAAI,CAAC;KACZ;AACH,CAAC,CAAA,CAAC"}
@@ -83,6 +83,11 @@ const scpAction = (args) => __awaiter(void 0, void 0, void 0, function* () {
83
83
  ? args["--"].map(String)
84
84
  : [];
85
85
  args.sshOptions = sshOptions;
86
+ // TODO(ENG-3142): Azure SSH currently doesn't support specifying a port; throw an error if one is set.
87
+ if (args.provider === "azure" &&
88
+ sshOptions.some((opt) => opt.startsWith("-P"))) {
89
+ throw "Azure SSH does not currently support specifying a port. SSH on the target VM must be listening on the default port 22.";
90
+ }
86
91
  const host = getHostIdentifier(args.source, args.destination);
87
92
  if (!host) {
88
93
  throw "Could not determine host identifier from source or destination";
@@ -1 +1 @@
1
- {"version":3,"file":"scp.js","sourceRoot":"","sources":["../../src/commands/scp.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;GASG;AACH,0CAA+C;AAC/C,oDAAuD;AACvD,wCAA0C;AAC1C,sCAAiE;AACjE,sCAA8D;AAGvD,MAAM,UAAU,GAAG,CAAC,KAAiB,EAAE,EAAE,CAC9C,KAAK,CAAC,OAAO,CACX,4BAA4B;AAC5B,6DAA6D;AAC7D,mDAAmD,EACnD,CAAC,KAAK,EAAE,EAAE,CACR,KAAK;KACF,UAAU,CAAC,QAAQ,EAAE;IACpB,IAAI,EAAE,QAAQ;IACd,YAAY,EAAE,IAAI;IAClB,WAAW,EAAE,wBAAwB;CACtC,CAAC;KACD,UAAU,CAAC,aAAa,EAAE;IACzB,IAAI,EAAE,QAAQ;IACd,YAAY,EAAE,IAAI;IAClB,WAAW,EAAE,wBAAwB;CACtC,CAAC;KACD,MAAM,CAAC,GAAG,EAAE;IACX,KAAK,EAAE,WAAW;IAClB,IAAI,EAAE,SA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I,CAAC,MAAM,CAAC;IACzB,IAAI,WAAW,GAAG,IAAI,CAAC,WAAW,CAAC;IAEnC,IAAI,kBAAkB,CAAC,MAAM,CAAC,EAAE;QAC9B,MAAM,GAAG,GAAG,MAAM,CAAC,aAAa,IAAI,MAAM,CAAC,EAAE,IAAI,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;KACzE;IAED,IAAI,kBAAkB,CAAC,WAAW,CAAC,EAAE;QACnC,WAAW,GAAG,GAAG,MAAM,CAAC,aAAa,IAAI,MAAM,CAAC,EAAE,IAAI,WAAW,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;KACnF;IAED,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,CAAC;AACjC,CAAC,CAAC"}
@@ -5,7 +5,7 @@ import yargs from "yargs";
5
5
  export type BaseSshCommandArgs = {
6
6
  sudo?: boolean;
7
7
  reason?: string;
8
- account?: string;
8
+ parent?: string;
9
9
  provider?: SupportedSshProvider;
10
10
  debug?: boolean;
11
11
  sshOptions?: string[];
@@ -22,6 +22,16 @@ export type SshCommandArgs = BaseSshCommandArgs & {
22
22
  command?: string;
23
23
  };
24
24
  export type CommandArgs = ScpCommandArgs | SshCommandArgs;
25
+ export type SshAdditionalSetup = {
26
+ /** A list of SSH configuration options, as would be used after '-o' in an SSH command */
27
+ sshOptions: string[];
28
+ /** The path to the private key file to use for the SSH connection, instead of the default P0 CLI managed key */
29
+ identityFile: string;
30
+ /** The port to connect to, overriding the default */
31
+ port: string;
32
+ /** Perform any teardown required after the SSH command exits but before terminating the P0 CLI */
33
+ teardown: () => Promise<void>;
34
+ };
25
35
  export declare const SSH_PROVIDERS: Record<SupportedSshProvider, SshProvider<any, any, any, any>>;
26
36
  export declare const isSudoCommand: (args: {
27
37
  sudo?: boolean;
@@ -66,7 +66,7 @@ const provisionRequest = (authn, args, destination) => __awaiter(void 0, void 0,
66
66
  ...(args.provider ? ["--provider", args.provider] : []),
67
67
  ...((0, exports.isSudoCommand)(args) ? ["--sudo"] : []),
68
68
  ...(args.reason ? ["--reason", args.reason] : []),
69
- ...(args.account ? ["--account", args.account] : []),
69
+ ...(args.parent ? ["--parent", args.parent] : []),
70
70
  ], wait: true }), authn, { message: "approval-required" });
71
71
  if (!response) {
72
72
  (0, stdio_1.print2)("Did not receive access ID from server");
@@ -78,9 +78,6 @@ const provisionRequest = (authn, args, destination) => __awaiter(void 0, void 0,
78
78
  else
79
79
  (0, stdio_1.print2)("Existing access found. Connecting to instance.");
80
80
  const provisionedRequest = yield (0, _1.waitForProvisioning)(authn, id);
81
- if (provisionedRequest.permission.publicKey !== publicKey) {
82
- throw "Public key mismatch. Please revoke the request and try again.";
83
- }
84
81
  return { provisionedRequest, publicKey, privateKey };
85
82
  });
86
83
  exports.provisionRequest = provisionRequest;
@@ -89,8 +86,12 @@ const prepareRequest = (authn, args, destination) => __awaiter(void 0, void 0, v
89
86
  if (!result) {
90
87
  throw "Server did not return a request id. Please contact support@p0.dev for assistance.";
91
88
  }
92
- const { provisionedRequest } = result;
89
+ const { provisionedRequest, publicKey } = result;
93
90
  const sshProvider = exports.SSH_PROVIDERS[provisionedRequest.permission.provider];
91
+ if (sshProvider.validateSshKey &&
92
+ !sshProvider.validateSshKey(provisionedRequest, publicKey)) {
93
+ throw "Public key mismatch. Please revoke the request and try again.";
94
+ }
94
95
  yield sshProvider.ensureInstall();
95
96
  const cliRequest = yield pluginToCliRequest(provisionedRequest, {
96
97
  debug: args.debug,
@@ -1 +1 @@
1
- {"version":3,"file":"ssh.js","sourceRoot":"","sources":["../../../src/commands/shared/ssh.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;GASG;AACH,wBAAwC;AACxC,4CAAkD;AAClD,uDAA8C;AAC9C,+CAA6C;AAC7C,+CAAuD;AACvD,iDAA2D;AAC3D,kDAA0D;AAI1D,yCAMyB;AACzB,uCAAoC;AACpC,kDAA4C;AAC5C,m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c,kBA6BzB"}
@@ -48,14 +48,14 @@ const sshCommand = (yargs) => yargs.command("ssh <destination> [command [argumen
48
48
  describe: "Reason access is needed",
49
49
  type: "string",
50
50
  })
51
- .option("account", {
51
+ .option("parent", {
52
52
  type: "string",
53
- describe: "The account on which the instance is located",
53
+ describe: "The containing parent resource which the instance belongs to (account, project, subscription, etc.)",
54
54
  })
55
55
  .option("provider", {
56
56
  type: "string",
57
57
  describe: "The cloud provider where the instance is hosted",
58
- choices: ["aws", "gcloud"],
58
+ choices: ["aws", "azure", "gcloud"],
59
59
  })
60
60
  .option("debug", {
61
61
  type: "boolean",
@@ -86,6 +86,11 @@ const sshAction = (args) => __awaiter(void 0, void 0, void 0, function* () {
86
86
  ? args["--"].map(String)
87
87
  : [];
88
88
  args.sshOptions = sshOptions;
89
+ // TODO(ENG-3142): Azure SSH currently doesn't support specifying a port; throw an error if one is set.
90
+ if (args.provider === "azure" &&
91
+ sshOptions.some((opt) => opt.startsWith("-p"))) {
92
+ throw "Azure SSH does not currently support specifying a port. SSH on the target VM must be listening on the default port 22.";
93
+ }
89
94
  const { request, privateKey, sshProvider } = yield (0, ssh_2.prepareRequest)(authn, args, args.destination);
90
95
  yield (0, ssh_1.sshOrScp)({
91
96
  authn,
@@ -1 +1 @@
1
- {"version":3,"file":"ssh.js","sourceRoot":"","sources":["../../src/commands/ssh.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;GASG;AACH,0CAA+C;AAC/C,oDAAuD;AACvD,wCAA0C;AAC1C,sCAA8D;AAGvD,MAAM,UAAU,GAAG,CAAC,KAAiB,EAAE,EAAE,CAC9C,KAAK,CAAC,OAAO,CACX,2CAA2C,EAC3C,4BAA4B,EAC5B,CAAC,KAAK,EAAE,EAAE,CACR,KAAK;KACF,UAAU,CAAC,aAAa,EAAE;IACzB,IAAI,EAAE,QAAQ;IACd,YAAY,EAAE,IAAI;CACnB,CAAC;KACD,UAAU,CAAC,SAAS,EAAE;IACrB,IAAI,EAAE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,KAAK;QACL,OAAO;QACP,OAAO,EAAE,IAAI;QACb,UAAU;QACV,WAAW;KACZ,CAAC,CAAC;AACL,CAAC,CAAA,CAAC"}
@@ -55,6 +55,7 @@ exports.awsSshProvider = {
55
55
  ? yield (0, aws_1.assumeRoleWithOktaSaml)(authn, request)
56
56
  : (0, util_1.throwAssertNever)(config.login);
57
57
  }),
58
+ validateSshKey: (request, publicKey) => request.permission.publicKey === publicKey,
58
59
  ensureInstall: () => __awaiter(void 0, void 0, void 0, function* () {
59
60
  if (!(yield (0, install_1.ensureSsmInstall)())) {
60
61
  throw "Please try again after installing the required AWS utilities";
@@ -1 +1 @@
1
- {"version":3,"file":"ssh.js","sourceRoot":"","sources":["../../../src/plugins/aws/ssh.ts"],"names":[],"mappings":";;;;;;;;;;;;AAWA,qCAA8C;AAC9C,qCAAqD;AACrD,qCAAwC;AACxC,+BAA0C;AAC1C,2CAAiD;AASjD,MAAM,4BAA4B,GAAG,EAAE,GAAG,IAAI,CAAC;AAE/C,iGAAiG;AACjG,MAAM,+BAA+B,GAAG,qBAAqB,CAAC;AAE9D;;;;;;GAMG;AACH,MAAM,2BAA2B,GAAG;IAClC,kFAAkF;IAClF,sFAAsF;IACtF;QACE,OAAO,EACL,0RAA0R;KAC7R;IACD;;;;;;OAMG;IACH;QACE,OAAO,EAAE,kEAAkE;KAC5E;CACO,CAAC;AAEE,QAAA,cAAc,GAKvB;IACF,kBAAkB,EAAE,CAAO,KAAK,EAAE,OAAO,EAAE,EAAE;;QAC3C,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,IAAA,qBAAY,EAAC,KAAK,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC;QAChE,IAAI,CAAC,CAAA,MAAA,MAAM,CAAC,KAAK,0CAAE,IAAI,CAAA,IAAI,CAAA,MAAA,MAAM,CAAC,KAAK,0CAAE,IAAI,MAAK,KAAK,EAAE;YACvD,MAAM,8DAA8D,CAAC;SACtE;QAED,OAAO,CAAA,MAAA,MAAM,CA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 };
5
+ export declare const azAccountSetCommand: (subscriptionId: string) => {
6
+ command: string;
7
+ args: string[];
8
+ };
9
+ export declare const azLogin: (subscriptionId: string, options?: {
10
+ debug?: boolean;
11
+ }) => Promise<void>;
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.azLogin = exports.azAccountSetCommand = exports.azLoginCommand = void 0;
13
+ /** Copyright © 2024-present P0 Security
14
+
15
+ This file is part of @p0security/cli
16
+
17
+ @p0security/cli is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 3 of the License.
18
+
19
+ @p0security/cli is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
20
+
21
+ You should have received a copy of the GNU General Public License along with @p0security/cli. If not, see <https://www.gnu.org/licenses/>.
22
+ **/
23
+ const stdio_1 = require("../../drivers/stdio");
24
+ const util_1 = require("../../util");
25
+ const azLoginCommand = () => ({
26
+ command: "az",
27
+ args: ["login"],
28
+ });
29
+ exports.azLoginCommand = azLoginCommand;
30
+ const azAccountSetCommand = (subscriptionId) => ({
31
+ command: "az",
32
+ args: ["account", "set", "--subscription", subscriptionId],
33
+ });
34
+ exports.azAccountSetCommand = azAccountSetCommand;
35
+ const azLogin = (subscriptionId, options = {}) => __awaiter(void 0, void 0, void 0, function* () {
36
+ const { debug } = options;
37
+ if (debug)
38
+ (0, stdio_1.print2)("Logging in to Azure...");
39
+ const { command: azLoginExe, args: azLoginArgs } = (0, exports.azLoginCommand)();
40
+ const loginResult = yield (0, util_1.exec)(azLoginExe, azLoginArgs, { check: true });
41
+ if (debug) {
42
+ (0, stdio_1.print2)(loginResult.stdout);
43
+ (0, stdio_1.print2)(loginResult.stderr);
44
+ (0, stdio_1.print2)(`Setting active Azure subscription to ${subscriptionId}...`);
45
+ }
46
+ const { command: azAccountSetExe, args: azAccountSetArgs } = (0, exports.azAccountSetCommand)(subscriptionId);
47
+ const accountSetResult = yield (0, util_1.exec)(azAccountSetExe, azAccountSetArgs, {
48
+ check: true,
49
+ });
50
+ if (debug) {
51
+ (0, stdio_1.print2)(accountSetResult.stdout);
52
+ (0, stdio_1.print2)(accountSetResult.stderr);
53
+ }
54
+ });
55
+ exports.azLogin = azLogin;
56
+ //# sourceMappingURL=auth.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth.js","sourceRoot":"","sources":["../../../src/plugins/azure/auth.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;GASG;AACH,+CAA6C;AAC7C,qCAAkC;AAE3B,MAAM,cAAc,GAAG,GAAG,EAAE,CAAC,CAAC;IACnC,OAAO,EAAE,IAAI;IACb,IAAI,EAAE,CAAC,OAAO,CAAC;CAChB,CAAC,CAAC;AAHU,QAAA,cAAc,kBAGxB;AAEI,MAAM,mBAAmB,GAAG,CAAC,cAAsB,EAAE,EAAE,CAAC,CAAC;IAC9D,OAAO,EAAE,IAAI;IACb,IAAI,EAAE,CAAC,SAAS,EAAE,KAAK,EAAE,gBAAgB,EAAE,cAAc,CAAC;CAC3D,CAAC,CAAC;AAHU,QAAA,mBAAmB,uBAG7B;AAEI,MAAM,OAAO,GAAG,CACrB,cAAsB,EACtB,UAA+B,EAAE,EACjC,EAAE;IACF,MAAM,EAAE,KAAK,EAAE,GAAG,OAAO,CAAC;IAE1B,IAAI,KAAK;QAAE,IAAA,cAAM,EAAC,wBAAwB,CAAC,CAAC;IAE5C,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,WAAW,EAAE,GAAG,IAAA,sBAAc,GAAE,CAAC;IACpE,MAAM,WAAW,GAAG,MAAM,IAAA,WAAI,EAAC,UAAU,EAAE,WAAW,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IAEzE,IAAI,KAAK,EAAE;QACT,IAAA,cAAM,EAAC,WAAW,CAAC,MAAM,CAAC,CAAC;QAC3B,IAAA,cAAM,EAAC,WAAW,CAAC,MAAM,CAAC,CAAC;QAC3B,IAAA,cAAM,EAAC,wCAAwC,cAAc,KAAK,CAAC,CAAC;KACrE;IAED,MAAM,EAAE,OAAO,EAAE,eAAe,EAAE,IAAI,EAAE,gBAAgB,EAAE,GACxD,IAAA,2BAAmB,EAAC,cAAc,CAAC,CAAC;IACtC,MAAM,gBAAgB,GAAG,MAAM,IAAA,WAAI,EAAC,eAAe,EAAE,gBAAgB,EAAE;QACrE,KAAK,EAAE,IAAI;KACZ,CAAC,CAAC;IAEH,IAAI,KAAK,EAAE;QACT,IAAA,cAAM,EAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC;QAChC,IAAA,cAAM,EAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC;KACjC;AACH,CAAC,CAAA,CAAC;AA3BW,QAAA,OAAO,WA2BlB"}
@@ -0,0 +1,13 @@
1
+ export declare const AD_CERT_FILENAME = "p0cli-azure-ad-ssh-cert.pub";
2
+ export declare const AD_SSH_KEY_PRIVATE = "id_rsa";
3
+ export declare const azSshCertCommand: (keyPath: string) => {
4
+ command: string;
5
+ args: string[];
6
+ };
7
+ export declare const createTempDirectoryForKeys: () => Promise<{
8
+ path: string;
9
+ cleanup: () => Promise<void>;
10
+ }>;
11
+ export declare const generateSshKeyAndAzureAdCert: (keyPath: string, options?: {
12
+ debug?: boolean;
13
+ }) => Promise<void>;
@@ -0,0 +1,69 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.generateSshKeyAndAzureAdCert = exports.createTempDirectoryForKeys = exports.azSshCertCommand = exports.AD_SSH_KEY_PRIVATE = exports.AD_CERT_FILENAME = void 0;
16
+ /** Copyright © 2024-present P0 Security
17
+
18
+ This file is part of @p0security/cli
19
+
20
+ @p0security/cli is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 3 of the License.
21
+
22
+ @p0security/cli is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
23
+
24
+ You should have received a copy of the GNU General Public License along with @p0security/cli. If not, see <https://www.gnu.org/licenses/>.
25
+ **/
26
+ const stdio_1 = require("../../drivers/stdio");
27
+ const util_1 = require("../../util");
28
+ const node_path_1 = __importDefault(require("node:path"));
29
+ const tmp_promise_1 = __importDefault(require("tmp-promise"));
30
+ // We pass in the name of the certificate file to generate
31
+ exports.AD_CERT_FILENAME = "p0cli-azure-ad-ssh-cert.pub";
32
+ // The `az ssh cert` command manages key generation, and generates SSH RSA keys with the standard names
33
+ exports.AD_SSH_KEY_PRIVATE = "id_rsa";
34
+ const azSshCertCommand = (keyPath) => ({
35
+ command: "az",
36
+ args: ["ssh", "cert", "--file", node_path_1.default.join(keyPath, exports.AD_CERT_FILENAME)],
37
+ });
38
+ exports.azSshCertCommand = azSshCertCommand;
39
+ const createTempDirectoryForKeys = () => __awaiter(void 0, void 0, void 0, function* () {
40
+ // unsafeCleanup lets us delete the directory even if there are still files in it, which is fine since the
41
+ // files are no longer needed once we've authenticated to the remote system.
42
+ const { path, cleanup } = yield tmp_promise_1.default.dir({
43
+ mode: 0o700,
44
+ prefix: "p0cli-",
45
+ unsafeCleanup: true,
46
+ });
47
+ return { path, cleanup };
48
+ });
49
+ exports.createTempDirectoryForKeys = createTempDirectoryForKeys;
50
+ const generateSshKeyAndAzureAdCert = (keyPath, options = {}) => __awaiter(void 0, void 0, void 0, function* () {
51
+ const { debug } = options;
52
+ if (debug)
53
+ (0, stdio_1.print2)("Generating Azure AD SSH certificate...");
54
+ try {
55
+ const { command, args } = (0, exports.azSshCertCommand)(keyPath);
56
+ const { stdout, stderr } = yield (0, util_1.exec)(command, args, { check: true });
57
+ if (debug) {
58
+ (0, stdio_1.print2)(stdout);
59
+ (0, stdio_1.print2)(stderr);
60
+ }
61
+ }
62
+ catch (error) {
63
+ (0, stdio_1.print2)(error.stdout);
64
+ (0, stdio_1.print2)(error.stderr);
65
+ throw `Failed to generate Azure AD SSH certificate: ${error}`;
66
+ }
67
+ });
68
+ exports.generateSshKeyAndAzureAdCert = generateSshKeyAndAzureAdCert;
69
+ //# sourceMappingURL=keygen.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"keygen.js","sourceRoot":"","sources":["../../../src/plugins/azure/keygen.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA;;;;;;;;;GASG;AACH,+CAA6C;AAC7C,qCAAkC;AAClC,0DAA6B;AAC7B,8DAA8B;AAE9B,0DAA0D;AAC7C,QAAA,gBAAgB,GAAG,6BAA6B,CAAC;AAE9D,uGAAuG;AAC1F,QAAA,kBAAkB,GAAG,QAAQ,CAAC;AA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K,CAAC,MAAM,CAAC,CAAC;QACrB,MAAM,gDAAgD,KAAK,EAAE,CAAC;KAC/D;AACH,CAAC,CAAA,CAAC;AArBW,QAAA,4BAA4B,gCAqBvC"}
@@ -9,7 +9,5 @@ This file is part of @p0security/cli
9
9
  You should have received a copy of the GNU General Public License along with @p0security/cli. If not, see <https://www.gnu.org/licenses/>.
10
10
  **/
11
11
  import { SshProvider } from "../../types/ssh";
12
- import { AzureSshPermissionSpec, AzureSshRequest } from "./types";
13
- export declare const azureSshProvider: SshProvider<AzureSshPermissionSpec, {
14
- linuxUserName: string;
15
- }, AzureSshRequest>;
12
+ import { AzureLocalData, AzureSshPermissionSpec, AzureSshRequest } from "./types";
13
+ export declare const azureSshProvider: SshProvider<AzureSshPermissionSpec, AzureLocalData, AzureSshRequest>;
@@ -8,19 +8,22 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
9
  });
10
10
  };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
11
14
  Object.defineProperty(exports, "__esModule", { value: true });
12
15
  exports.azureSshProvider = void 0;
13
- const util_1 = require("../../util");
14
- const ssh_key_1 = require("../google/ssh-key");
16
+ const auth_1 = require("./auth");
15
17
  const install_1 = require("./install");
18
+ const keygen_1 = require("./keygen");
19
+ const tunnel_1 = require("./tunnel");
20
+ const node_path_1 = __importDefault(require("node:path"));
16
21
  // TODO: Determine what this value should be for Azure
17
22
  const PROPAGATION_TIMEOUT_LIMIT_MS = 2 * 60 * 1000;
18
23
  exports.azureSshProvider = {
19
24
  // TODO: Natively support Azure login in P0 CLI
20
25
  cloudProviderLogin: () => __awaiter(void 0, void 0, void 0, function* () {
21
- // Always invoke `az login` before each SSH access. This is needed because
22
- // Azure permissions are only updated upon login.
23
- yield (0, util_1.exec)("az", ["login"]);
26
+ // Login is handled as part of setup() below
24
27
  return undefined;
25
28
  }),
26
29
  ensureInstall: () => __awaiter(void 0, void 0, void 0, function* () {
@@ -33,26 +36,89 @@ exports.azureSshProvider = {
33
36
  // TODO: Determine value
34
37
  loginRequiredPattern: undefined,
35
38
  propagationTimeoutMs: PROPAGATION_TIMEOUT_LIMIT_MS,
36
- // TODO: Implement
39
+ // TODO(ENG-3149): Implement sudo access checks here
37
40
  preTestAccessPropagationArgs: () => undefined,
38
- // TODO: Determine if necessary
41
+ // Azure doesn't support ProxyCommand, as nice as that would be. Yet.
39
42
  proxyCommand: () => [],
40
- // TODO: Determine if necessary
41
- reproCommands: () => undefined,
42
- // TODO: Placeholder
43
- requestToSsh: (request) => ({
44
- type: "azure",
45
- id: request.permission.resource.instanceId,
46
- instanceId: request.permission.resource.instanceId,
47
- linuxUserName: request.cliLocalData.linuxUserName,
43
+ reproCommands: (request, additionalData) => {
44
+ var _a;
45
+ const { command: azLoginExe, args: azLoginArgs } = (0, auth_1.azLoginCommand)();
46
+ const { command: azAccountSetExe, args: azAccountSetArgs } = (0, auth_1.azAccountSetCommand)(request.subscriptionId);
47
+ const getKeyPath = () => {
48
+ // Use the same key path as the one generated in setup() so it matches the ssh command that is generated
49
+ // elsewhere. It'll be an annoying long temporary directory name, but it strictly will work for reproduction. If
50
+ // additionalData isn't present (which it always should be for the azureSshProvider), we'll use the user's home
51
+ // directory.
52
+ if (additionalData) {
53
+ return node_path_1.default.dirname(additionalData.identityFile);
54
+ }
55
+ else {
56
+ const basePath = process.env.HOME || process.env.USERPROFILE || "";
57
+ return node_path_1.default.join(basePath, "p0cli-azure-ssh-keys");
58
+ }
59
+ };
60
+ const keyPath = getKeyPath();
61
+ const { command: azCertGenExe, args: azCertGenArgs } = (0, keygen_1.azSshCertCommand)(keyPath);
62
+ // If additionalData is undefined (which, again, should be never), use the default port for Azure Network Bastion
63
+ // tunnels instead of generating a random one
64
+ const { command: azTunnelExe, args: azTunnelArgs } = (0, tunnel_1.azBastionTunnelCommand)(request, (_a = additionalData === null || additionalData === void 0 ? void 0 : additionalData.port) !== null && _a !== void 0 ? _a : "50022", { debug: true } // reproCommands() is only invoked in debug mode, so this is a safe assumption
65
+ );
66
+ return [
67
+ `${azLoginExe} ${azLoginArgs.join(" ")}`,
68
+ `${azAccountSetExe} ${azAccountSetArgs.join(" ")}`,
69
+ `mkdir ${keyPath}`,
70
+ `${azCertGenExe} ${azCertGenArgs.join(" ")}`,
71
+ `${azTunnelExe} ${azTunnelArgs.join(" ")}`,
72
+ ];
73
+ },
74
+ setup: (request, options = {}) => __awaiter(void 0, void 0, void 0, function* () {
75
+ const { debug } = options;
76
+ // The subscription ID here is used to ensure that the user is logged in to the correct tenant/directory.
77
+ // As long as a subscription ID in the correct tenant is provided, this will work; it need not be the same
78
+ // subscription as which contains the Bastion host or the target VM.
79
+ yield (0, auth_1.azLogin)(request.subscriptionId, { debug }); // Always re-login to Azure CLI
80
+ const { path: keyPath, cleanup: sshKeyPathCleanup } = yield (0, keygen_1.createTempDirectoryForKeys)();
81
+ const wrappedCreateCertAndTunnel = () => __awaiter(void 0, void 0, void 0, function* () {
82
+ try {
83
+ yield (0, keygen_1.generateSshKeyAndAzureAdCert)(keyPath, { debug });
84
+ return yield (0, tunnel_1.trySpawnBastionTunnel)(request, { debug });
85
+ }
86
+ catch (error) {
87
+ yield sshKeyPathCleanup();
88
+ throw error;
89
+ }
90
+ });
91
+ const { killTunnel, tunnelLocalPort } = yield wrappedCreateCertAndTunnel();
92
+ const sshPrivateKeyPath = node_path_1.default.join(keyPath, keygen_1.AD_SSH_KEY_PRIVATE);
93
+ const sshCertificateKeyPath = node_path_1.default.join(keyPath, keygen_1.AD_CERT_FILENAME);
94
+ const teardown = () => __awaiter(void 0, void 0, void 0, function* () {
95
+ yield killTunnel();
96
+ yield sshKeyPathCleanup();
97
+ });
98
+ return {
99
+ sshOptions: [
100
+ `CertificateFile=${sshCertificateKeyPath}`,
101
+ // Because we connect to the Azure Network Bastion tunnel via a local port instead of a ProxyCommand, every
102
+ // instance connected to will appear to `ssh` to be the same host but presenting a different host key (i.e.,
103
+ // `ssh` always connects to localhost but each VM will present its own host key), which will trigger MITM attack
104
+ // warnings. We disable host key checking to avoid this. This is ordinarily very dangerous, but in this case,
105
+ // security of the connection is ensured by the Azure Bastion Network tunnel, which utilizes HTTPS and thus has
106
+ // its own MITM protection.
107
+ "StrictHostKeyChecking=no",
108
+ "UserKnownHostsFile=/dev/null",
109
+ ],
110
+ identityFile: sshPrivateKeyPath,
111
+ port: tunnelLocalPort,
112
+ teardown,
113
+ };
48
114
  }),
115
+ requestToSsh: (request) => (Object.assign(Object.assign({ type: "azure", id: "localhost" }, request.cliLocalData), { instanceId: request.permission.resource.instanceId, subscriptionId: request.permission.resource.subscriptionId, instanceResourceGroup: request.permission.resource.resourceGroupId, bastionId: request.permission.bastionHostId })),
49
116
  // TODO: Implement
50
117
  unprovisionedAccessPatterns: [],
51
- // TODO: Placeholder
52
- toCliRequest: (request, options) => __awaiter(void 0, void 0, void 0, function* () {
53
- return (Object.assign(Object.assign({}, request), { cliLocalData: {
54
- linuxUserName: yield (0, ssh_key_1.importSshKey)(request.permission.publicKey, options),
55
- } }));
118
+ toCliRequest: (request) => __awaiter(void 0, void 0, void 0, function* () {
119
+ return Object.assign(Object.assign({}, request), { cliLocalData: {
120
+ linuxUserName: request.principal,
121
+ } });
56
122
  }),
57
123
  };
58
124
  //# sourceMappingURL=ssh.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ssh.js","sourceRoot":"","sources":["../../../src/plugins/azure/ssh.ts"],"names":[],"mappings":";;;;;;;;;;;;AAWA,qCAAkC;AAClC,+CAAiD;AACjD,uCAA4C;AAG5C,sDAAsD;AACtD,MAAM,4BAA4B,GAAG,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC;AAEtC,QAAA,gBAAgB,GAIzB;IACF,+CAA+C;IAC/C,kBAAkB,EAAE,GAAS,EAAE;QAC7B,0EAA0E;QAC1E,iDAAiD;QACjD,MAAM,IAAA,WAAI,EAAC,IAA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Q,CAAC,eAAe,EAClE,SAAS,EAAE,OAAO,CAAC,UAAU,CAAC,aAAa,IAC3C;IAEF,kBAAkB;IAClB,2BAA2B,EAAE,EAAE;IAE/B,YAAY,EAAE,CAAO,OAAO,EAAE,EAAE;QAC9B,uCACK,OAAO,KACV,YAAY,EAAE;gBACZ,aAAa,EAAE,OAAO,CAAC,SAAS;aACjC,IACD;IACJ,CAAC,CAAA;CACF,CAAC"}
@@ -0,0 +1,14 @@
1
+ import { AzureSshRequest } from "./types";
2
+ export type BastionTunnelMeta = {
3
+ killTunnel: () => Promise<void>;
4
+ tunnelLocalPort: string;
5
+ };
6
+ export declare const azBastionTunnelCommand: (request: AzureSshRequest, port: string, options?: {
7
+ debug?: boolean;
8
+ }) => {
9
+ command: string;
10
+ args: string[];
11
+ };
12
+ export declare const trySpawnBastionTunnel: (request: AzureSshRequest, options?: {
13
+ debug?: boolean;
14
+ }) => Promise<BastionTunnelMeta>;
@@ -0,0 +1,160 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.trySpawnBastionTunnel = exports.azBastionTunnelCommand = void 0;
13
+ /** Copyright © 2024-present P0 Security
14
+
15
+ This file is part of @p0security/cli
16
+
17
+ @p0security/cli is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 3 of the License.
18
+
19
+ @p0security/cli is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
20
+
21
+ You should have received a copy of the GNU General Public License along with @p0security/cli. If not, see <https://www.gnu.org/licenses/>.
22
+ **/
23
+ const retry_1 = require("../../common/retry");
24
+ const stdio_1 = require("../../drivers/stdio");
25
+ const util_1 = require("../../util");
26
+ const node_child_process_1 = require("node:child_process");
27
+ const TUNNEL_READY_STRING = "Tunnel is ready";
28
+ const SPAWN_TUNNEL_TRIES = 3;
29
+ // Ignore these debug messages from the tunnel process; they are far too noisy and spam the terminal with useless info
30
+ // anytime the SSH/SCP session has network activity.
31
+ const tunnelDebugOutputIgnorePatterns = [
32
+ /Waiting for (debugger|websocket) data/i,
33
+ /Received (debugger|websocket)/i,
34
+ /Sending to (debugger|websocket)/i,
35
+ ];
36
+ const azBastionTunnelCommand = (request, port, options = {}) => ({
37
+ command: "az",
38
+ args: [
39
+ "network",
40
+ "bastion",
41
+ "tunnel",
42
+ "--ids",
43
+ request.bastionId,
44
+ "--target-resource-id",
45
+ request.instanceId,
46
+ "--resource-port",
47
+ "22",
48
+ "--port",
49
+ port,
50
+ ...(options.debug ? ["--debug"] : []),
51
+ ],
52
+ });
53
+ exports.azBastionTunnelCommand = azBastionTunnelCommand;
54
+ const selectRandomPort = () => {
55
+ // The IANA ephemeral port range is 49152 to 65535, inclusive. Pick a random value in that range.
56
+ // If the port is in use (unlikely but possible), we can just generate a new value and try again.
57
+ // 16384 is 65535 - 49152 + 1, the number of possible ports in the range.
58
+ const port = Math.floor(Math.random() * 16384) + 49152;
59
+ return port.toString();
60
+ };
61
+ const spawnBastionTunnelInBackground = (request, port, options = {}) => {
62
+ const { debug } = options;
63
+ return new Promise((resolve, reject) => {
64
+ let processSignalledToExit = false;
65
+ let processExited = false;
66
+ let stdout = "";
67
+ let stderr = "";
68
+ const { command, args } = (0, exports.azBastionTunnelCommand)(request, port, { debug });
69
+ if (debug)
70
+ (0, stdio_1.print2)("Spawning Azure Bastion tunnel process...");
71
+ // Spawn the process in detached mode so that it is in its own process group; this lets us kill it and all
72
+ // descendent processes together.
73
+ const child = (0, node_child_process_1.spawn)(command, args, { detached: true });
74
+ child.on("exit", (code) => {
75
+ processExited = true;
76
+ if (code === 0) {
77
+ if (debug)
78
+ (0, stdio_1.print2)("Azure Bastion tunnel process exited normally.");
79
+ return;
80
+ }
81
+ if (!debug) {
82
+ // stdout and stderr are printed in real-time when debugging is enabled, so we don't need to print them here
83
+ (0, stdio_1.print2)(stdout);
84
+ (0, stdio_1.print2)(stderr);
85
+ }
86
+ reject(`Error running Azure Network Bastion tunnel; tunnel process ended with status ${code}`);
87
+ });
88
+ child.stdout.on("data", (data) => {
89
+ const str = data.toString("utf-8");
90
+ stdout += str;
91
+ if (debug &&
92
+ !tunnelDebugOutputIgnorePatterns.some((regex) => str.match(regex))) {
93
+ (0, stdio_1.print2)(str);
94
+ }
95
+ });
96
+ child.stderr.on("data", (data) => {
97
+ const str = data.toString("utf-8");
98
+ stderr += str;
99
+ if (debug &&
100
+ !tunnelDebugOutputIgnorePatterns.some((regex) => str.match(regex))) {
101
+ (0, stdio_1.print2)(str);
102
+ }
103
+ if (str.includes(TUNNEL_READY_STRING)) {
104
+ (0, stdio_1.print2)("Azure Bastion tunnel is ready.");
105
+ resolve({
106
+ killTunnel: () => __awaiter(void 0, void 0, void 0, function* () {
107
+ if (processSignalledToExit || processExited)
108
+ return;
109
+ processSignalledToExit = true;
110
+ if (child.pid) {
111
+ // Kill the process and all its descendents via killing the process group; this is only possible
112
+ // because we launched the process with `detached: true` above. This is necessary because `az` is
113
+ // actually a bash script that spawns a Python process, and we need to kill the Python process as well.
114
+ // SIGINT is equivalent to pressing Ctrl-C in the terminal; allows for the tunnel process to perform any
115
+ // necessary cleanup of its own before exiting. The negative PID is what indicates that we want to kill
116
+ // the whole process group.
117
+ try {
118
+ if (debug) {
119
+ (0, stdio_1.print2)(`Sending SIGINT to Azure Bastion tunnel process (${child.pid})...`);
120
+ }
121
+ process.kill(-child.pid, "SIGINT");
122
+ // Give the tunnel a chance to quit gracefully after the SIGINT by waiting at least 250 ms and up to
123
+ // 5 seconds. If the process is still running after that, it's probably hung; SIGKILL it to force it to
124
+ // end immediately.
125
+ const SPIN_WAIT_MS = 250;
126
+ for (let spins = 0; spins < 20; spins++) {
127
+ yield (0, util_1.sleep)(SPIN_WAIT_MS);
128
+ if (processExited) {
129
+ if (debug) {
130
+ (0, stdio_1.print2)(`Azure Bastion tunnel process exited after SIGINT after ${spins * SPIN_WAIT_MS} ms.`);
131
+ }
132
+ return;
133
+ }
134
+ }
135
+ if (debug) {
136
+ (0, stdio_1.print2)(`Azure Bastion tunnel process (${child.pid}) not responding, sending SIGKILL...`);
137
+ }
138
+ process.kill(-child.pid, "SIGKILL");
139
+ }
140
+ catch (error) {
141
+ // Ignore the error and move on; we might as well just exit without waiting since we can't control
142
+ // the child process, for whatever reason
143
+ (0, stdio_1.print2)(`Failed to kill Azure Bastion tunnel process: ${error}`);
144
+ child.unref();
145
+ }
146
+ }
147
+ }),
148
+ tunnelLocalPort: port,
149
+ });
150
+ }
151
+ });
152
+ });
153
+ };
154
+ const trySpawnBastionTunnel = (request, options) => __awaiter(void 0, void 0, void 0, function* () {
155
+ // Attempt to spawn the tunnel SPAWN_TUNNEL_TRIES times, picking a new port each time. If we fail
156
+ // too many times, then the problem is likely not the port, but something else.
157
+ return yield (0, retry_1.retryWithSleep)(() => spawnBastionTunnelInBackground(request, selectRandomPort(), options), () => true, SPAWN_TUNNEL_TRIES, 1000);
158
+ });
159
+ exports.trySpawnBastionTunnel = trySpawnBastionTunnel;
160
+ //# sourceMappingURL=tunnel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tunnel.js","sourceRoot":"","sources":["../../../src/plugins/azure/tunnel.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;GASG;AACH,8CAAoD;AACpD,+CAA6C;AAC7C,qCAAmC;AAEnC,2DAA2C;AAE3C,MAAM,mBAA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C,KAAK,CAAC,GAAG,sCAAsC,CACjF,CAAC;iCACH;gCACD,OAAO,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC;6BACrC;4BAAC,OAAO,KAAU,EAAE;gCACnB,kGAAkG;gCAClG,yCAAyC;gCACzC,IAAA,cAAM,EAAC,gDAAgD,KAAK,EAAE,CAAC,CAAC;gCAChE,KAAK,CAAC,KAAK,EAAE,CAAC;6BACf;yBACF;oBACH,CAAC,CAAA;oBACD,eAAe,EAAE,IAAI;iBACtB,CAAC,CAAC;aACJ;QACH,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AAEK,MAAM,qBAAqB,GAAG,CACnC,OAAwB,EACxB,OAA6B,EACD,EAAE;IAC9B,iGAAiG;IACjG,+EAA+E;IAE/E,OAAO,MAAM,IAAA,sBAAc,EACzB,GAAG,EAAE,CAAC,8BAA8B,CAAC,OAAO,EAAE,gBAAgB,EAAE,EAAE,OAAO,CAAC,EAC1E,GAAG,EAAE,CAAC,IAAI,EACV,kBAAkB,EAClB,IAAI,CACL,CAAC;AACJ,CAAC,CAAA,CAAC;AAbW,QAAA,qBAAqB,yBAahC"}
@@ -12,30 +12,36 @@ import { PermissionSpec } from "../../types/request";
12
12
  import { CliPermissionSpec } from "../../types/ssh";
13
13
  import { CommonSshPermissionSpec } from "../ssh/types";
14
14
  export type AzureSshPermissionSpec = PermissionSpec<"ssh", AzureSshPermission>;
15
- export type AzureSsh = CliPermissionSpec<AzureSshPermissionSpec, {
16
- linuxUserName: string;
17
- }>;
15
+ export type AzureSsh = CliPermissionSpec<AzureSshPermissionSpec, AzureLocalData>;
18
16
  export type AzureSshPermission = CommonSshPermissionSpec & {
19
17
  provider: "azure";
20
18
  destination: string;
21
19
  parent: string | undefined;
22
20
  group: string | undefined;
21
+ bastionHostId: string;
22
+ principal: string;
23
23
  resource: {
24
- instanceName: string;
25
24
  instanceId: string;
26
- subscriptionId: string;
25
+ instanceName: string;
27
26
  subscriptionName: string;
28
27
  resourceGroupId: string;
28
+ subscriptionId: string;
29
29
  region: string;
30
30
  networkInterfaceIds: string[];
31
31
  };
32
32
  };
33
33
  export type AzureNodeSpec = {
34
- type: "azure";
35
34
  instanceId: string;
36
35
  sudo?: boolean;
37
36
  };
38
- export type AzureSshRequest = AzureNodeSpec & {
39
- id: string;
37
+ export type AzureBastionSpec = {
38
+ bastionId: string;
39
+ };
40
+ export type AzureSshRequest = AzureNodeSpec & AzureBastionSpec & AzureLocalData & {
41
+ type: "azure";
42
+ id: "localhost";
43
+ subscriptionId: string;
44
+ };
45
+ export type AzureLocalData = {
40
46
  linuxUserName: string;
41
47
  };
@@ -65,6 +65,7 @@ exports.gcpSshProvider = {
65
65
  throw "Please try again after installing the required GCP utilities";
66
66
  }
67
67
  }),
68
+ validateSshKey: (request, publicKey) => request.permission.publicKey === publicKey,
68
69
  friendlyName: "Google Cloud",
69
70
  loginRequiredMessage: "Please login to Google Cloud CLI with 'gcloud auth login'",
70
71
  loginRequiredPattern: /You do not currently have an active account selected/,
@@ -1 +1 @@
1
- {"version":3,"file":"ssh.js","sourceRoot":"","sources":["../../../src/plugins/google/ssh.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;GASG;AACH,mDAA0D;AAE1D,uCAAgD;AAChD,uCAAyC;AAGzC,oGAAoG;AACpG,MAAM,4BAA4B,GAAG,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC;AAEnD;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,2BAA2B,GAAG;IAClC,EAAE,OAAO,EAAE,iCAAiC,EAAE;IAC9C;QACE,mEAAmE;QACnE,OAAO,EAAE,uCAAuC;KACjD;IACD,EAAE,OAAO,EAAE,mDAAmD,EAAE;IAChE;QACE,OAAO,EAAE,+CAA+C;QACxD,kBAAkB,EAAE,IAAI;KACzB;IACD,EAAE,OAAO,EAAE,4DAA4D,EAAE;CACjE,CAAC;AAEE,QAAA,cA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
- const createCommand = (data, args, proxyCommand) => {
147
- addCommonArgs(args, proxyCommand);
146
+ const createCommand = (data, args, setupData, proxyCommand) => {
147
+ var _a;
148
+ addCommonArgs(args, proxyCommand, setupData);
149
+ const sshOptionsOverrides = (_a = setupData === null || setupData === void 0 ? void 0 : setupData.sshOptions) !== null && _a !== void 0 ? _a : [];
150
+ const port = setupData === null || setupData === void 0 ? void 0 : setupData.port;
151
+ const argsOverride = sshOptionsOverrides.flatMap((opt) => ["-o", opt]);
148
152
  if ("source" in args) {
149
153
  addScpArgs(args);
150
154
  return {
151
155
  command: "scp",
152
156
  args: [
153
157
  ...(args.sshOptions ? args.sshOptions : []),
158
+ ...argsOverride,
159
+ ...(port ? ["-P", port] : []),
154
160
  args.source,
155
161
  args.destination,
156
162
  ],
@@ -160,6 +166,8 @@ const createCommand = (data, args, proxyCommand) => {
160
166
  command: "ssh",
161
167
  args: [
162
168
  ...(args.sshOptions ? args.sshOptions : []),
169
+ ...argsOverride,
170
+ ...(port ? ["-p", port] : []),
163
171
  `${data.linuxUserName}@${data.id}`,
164
172
  ...(args.command ? [args.command] : []),
165
173
  ...args.arguments.map((argument) =>
@@ -173,7 +181,8 @@ const createCommand = (data, args, proxyCommand) => {
173
181
  *
174
182
  * These common args are only added if they have not been explicitly specified by the end user.
175
183
  */
176
- const addCommonArgs = (args, proxyCommand) => {
184
+ const addCommonArgs = (args, sshProviderProxyCommand, setupData) => {
185
+ var _a;
177
186
  const sshOptions = args.sshOptions ? args.sshOptions : [];
178
187
  const identityFileOptionExists = sshOptions.some((opt, idx) => {
179
188
  var _a;
@@ -184,15 +193,15 @@ const addCommonArgs = (args, proxyCommand) => {
184
193
  // Explicitly specify which private key to use to avoid "Too many authentication failures"
185
194
  // error caused by SSH trying every available key
186
195
  if (!identityFileOptionExists) {
187
- sshOptions.push("-i", keys_1.PRIVATE_KEY_PATH);
196
+ sshOptions.push("-i", (_a = setupData === null || setupData === void 0 ? void 0 : setupData.identityFile) !== null && _a !== void 0 ? _a : keys_1.PRIVATE_KEY_PATH);
188
197
  // Only use the authentication identity specified by -i above
189
198
  if (!identitiesOnlyOptionExists) {
190
199
  sshOptions.push("-o", "IdentitiesOnly=yes");
191
200
  }
192
201
  }
193
- const proxyCommandExists = sshOptions.some((opt, idx) => { var _a; return opt === "-o" && ((_a = sshOptions[idx + 1]) === null || _a === void 0 ? void 0 : _a.startsWith("ProxyCommand")); });
194
- if (!proxyCommandExists) {
195
- sshOptions.push("-o", `ProxyCommand=${proxyCommand.join(" ")}`);
202
+ const userSpecifiedProxyCommand = sshOptions.some((opt, idx) => { var _a; return opt === "-o" && ((_a = sshOptions[idx + 1]) === null || _a === void 0 ? void 0 : _a.startsWith("ProxyCommand")); });
203
+ if (!userSpecifiedProxyCommand && sshProviderProxyCommand.length > 0) {
204
+ sshOptions.push("-o", `ProxyCommand=${sshProviderProxyCommand.join(" ")}`);
196
205
  }
197
206
  // Force verbose output from SSH so we can parse the output
198
207
  const verboseOptionExists = sshOptions.some((opt) => opt === "-v");
@@ -234,7 +243,8 @@ const preTestAccessPropagationIfNeeded = (sshProvider, request, cmdArgs, proxyCo
234
243
  // Pre-testing comes at a performance cost because we have to execute another ssh subprocess after
235
244
  // a successful test. Only do when absolutely necessary.
236
245
  if (testCmdArgs) {
237
- const { command, args } = createCommand(request, testCmdArgs, proxyCommand);
246
+ const { command, args } = createCommand(request, testCmdArgs, undefined, // No need to re-apply SSH options from setupData
247
+ proxyCommand);
238
248
  // Assumes that this is a non-interactive ssh command that exits automatically
239
249
  return spawnSshNode({
240
250
  credential,
@@ -251,15 +261,18 @@ const preTestAccessPropagationIfNeeded = (sshProvider, request, cmdArgs, proxyCo
251
261
  return null;
252
262
  });
253
263
  const sshOrScp = (args) => __awaiter(void 0, void 0, void 0, function* () {
264
+ var _a;
254
265
  const { authn, request, cmdArgs, privateKey, sshProvider } = args;
266
+ const { debug } = cmdArgs;
255
267
  if (!privateKey) {
256
268
  throw "Failed to load a private key for this request. Please contact support@p0.dev for assistance.";
257
269
  }
258
270
  const credential = yield sshProvider.cloudProviderLogin(authn, request);
259
271
  const proxyCommand = sshProvider.proxyCommand(request);
260
- const { command, args: commandArgs } = createCommand(request, cmdArgs, proxyCommand);
261
- if (cmdArgs.debug) {
262
- const reproCommands = sshProvider.reproCommands(request);
272
+ const setupData = yield ((_a = sshProvider.setup) === null || _a === void 0 ? void 0 : _a.call(sshProvider, request, { debug }));
273
+ const { command, args: commandArgs } = createCommand(request, cmdArgs, setupData, proxyCommand);
274
+ if (debug) {
275
+ const reproCommands = sshProvider.reproCommands(request, setupData);
263
276
  if (reproCommands) {
264
277
  const repro = [
265
278
  ...reproCommands,
@@ -269,20 +282,27 @@ const sshOrScp = (args) => __awaiter(void 0, void 0, void 0, function* () {
269
282
  }
270
283
  }
271
284
  const endTime = Date.now() + sshProvider.propagationTimeoutMs;
272
- const exitCode = yield preTestAccessPropagationIfNeeded(sshProvider, request, cmdArgs, proxyCommand, credential, endTime);
273
- if (exitCode && exitCode !== 0) {
274
- return exitCode; // Only exit if there was an error when pre-testing
285
+ let sshNodeExit;
286
+ try {
287
+ const exitCode = yield preTestAccessPropagationIfNeeded(sshProvider, request, cmdArgs, proxyCommand, credential, endTime);
288
+ if (exitCode && exitCode !== 0) {
289
+ return exitCode; // Only exit if there was an error when pre-testing
290
+ }
291
+ sshNodeExit = yield spawnSshNode({
292
+ credential,
293
+ abortController: new AbortController(),
294
+ command,
295
+ args: commandArgs,
296
+ stdio: ["inherit", "inherit", "pipe"],
297
+ debug,
298
+ provider: request.type,
299
+ endTime: endTime,
300
+ });
275
301
  }
276
- return spawnSshNode({
277
- credential,
278
- abortController: new AbortController(),
279
- command,
280
- args: commandArgs,
281
- stdio: ["inherit", "inherit", "pipe"],
282
- debug: cmdArgs.debug,
283
- provider: request.type,
284
- endTime: endTime,
285
- });
302
+ finally {
303
+ yield (setupData === null || setupData === void 0 ? void 0 : setupData.teardown());
304
+ }
305
+ return sshNodeExit;
286
306
  });
287
307
  exports.sshOrScp = sshOrScp;
288
308
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/plugins/ssh/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;GASG;AACH,mDAAuE;AACvE,4CAAqD;AACrD,+CAA6C;AAG7C,qCAAmC;AAEnC,2DAK4B;AAG5B;;GAEG;AACH,MAAM,4BAA4B,GAAG,GAAG,CAAC;AAEzC,MAAM,cAAc,GAAG,IAAI,CAAC;AAE5B;;;;;;;;;;;;;;;GAeG;AACH,MAAM,sBAAsB,GAAG,CAC7B,QAAqB,EACrB,KAAgD,EAChD,OAA4B,EAC5B,EAAE;IACF,IAAI,gCAAgC,GAAG,KAAK,CAAC;IAC7C,IAAI,gBAAgB,GAAG,KAAK,CAAC;IAE7B,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE;QAChC,MAAM,WAAW,GAAW,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;QACpD,8BAA8B,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;QAErD,MAAM,KAAK,GAAG,QAAQ,CAAC,2BAA2B,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAClE,WAAW,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,CACnC,CAAC;QAEF,IAAI,KAAK,EAAE;YACT,gCAAgC,GAAG,IAAI,CAAC;SACzC;QAED,IAAI,QAAQ,CAAC,oBAAoB,EAAE;YACjC,MAAM,UAAU,GAAG,WAAW,CAAC,KAAK,CAAC,QAAQ,CAAC,oBAAoB,CAAC,CAAC;YACpE,gBAAgB,GAAG,gBAAgB,IAAI,CAAC,CAAC,UAAU,CAAC,CAAC,yBAAyB;SAC/E;QAED,IAAI,gBAAgB,EAAE;YACpB,gCAAgC,GAAG,KAAK,CAAC,CAAC,yDAAyD;SACpG;IACH,CAAC,CAAC,CAAC;IAEH,OA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,EACP,OAAO,EACP,YAAY,EACZ,UAAU,EACV,OAAO,CACR,CAAC;QACF,IAAI,QAAQ,IAAI,QAAQ,KAAK,CAAC,EAAE;YAC9B,OAAO,QAAQ,CAAC,CAAC,mDAAmD;SACrE;QAED,WAAW,GAAG,MAAM,YAAY,CAAC;YAC/B,UAAU;YACV,eAAe,EAAE,IAAI,eAAe,EAAE;YACtC,OAAO;YACP,IAAI,EAAE,WAAW;YACjB,KAAK,EAAE,CAAC,SAAS,EAAE,SAAS,EAAE,MAAM,CAAC;YACrC,KAAK;YACL,QAAQ,EAAE,OAAO,CAAC,IAAI;YACtB,OAAO,EAAE,OAAO;SACjB,CAAC,CAAC;KACJ;YAAS;QACR,MAAM,CAAA,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,QAAQ,EAAE,CAAA,CAAC;KAC7B;IAED,OAAO,WAAW,CAAC;AACrB,CAAC,CAAA,CAAC;AAzEW,QAAA,QAAQ,YAyEnB"}
@@ -8,7 +8,7 @@ This file is part of @p0security/cli
8
8
 
9
9
  You should have received a copy of the GNU General Public License along with @p0security/cli. If not, see <https://www.gnu.org/licenses/>.
10
10
  **/
11
- import { CommandArgs } from "../commands/shared/ssh";
11
+ import { CommandArgs, SshAdditionalSetup } from "../commands/shared/ssh";
12
12
  import { AwsSsh, AwsSshPermissionSpec, AwsSshRequest } from "../plugins/aws/types";
13
13
  import { AzureSsh, AzureSshPermissionSpec, AzureSshRequest } from "../plugins/azure/types";
14
14
  import { GcpSsh, GcpSshPermissionSpec, GcpSshRequest } from "../plugins/google/types";
@@ -26,6 +26,8 @@ export type SshProvider<PR extends PluginSshRequest = PluginSshRequest, O extend
26
26
  cloudProviderLogin: (authn: Authn, request: SR) => Promise<C>;
27
27
  /** Callback to ensure that this provider's CLI utils are installed */
28
28
  ensureInstall: () => Promise<void>;
29
+ /** Validate the SSH key if necessary; throw an exception if the key is invalid */
30
+ validateSshKey?: (request: Request<PR>, publicKey: string) => boolean;
29
31
  /** A human-readable name for this CSP */
30
32
  friendlyName: string;
31
33
  /** Friendly message to ask the user to log in to the CSP */
@@ -42,11 +44,16 @@ export type SshProvider<PR extends PluginSshRequest = PluginSshRequest, O extend
42
44
  * the actual ssh/scp command.
43
45
  */
44
46
  preTestAccessPropagationArgs: (cmdArgs: CommandArgs) => CommandArgs | undefined;
47
+ /** Perform any setup required before running the SSH command. Returns a list of additional arguments to pass to the
48
+ * SSH command. */
49
+ setup?: (request: SR, options?: {
50
+ debug?: boolean;
51
+ }) => Promise<SshAdditionalSetup>;
45
52
  /** Returns the command and its arguments that are going to be injected as the ssh ProxyCommand option */
46
53
  proxyCommand: (request: SR) => string[];
47
54
  /** Each element in the returned array is a command that can be run to reproduce the
48
55
  * steps of logging in the user to the ssh session. */
49
- reproCommands: (request: SR) => string[] | undefined;
56
+ reproCommands: (request: SR, additionalData?: SshAdditionalSetup) => string[] | undefined;
50
57
  /** Unwraps this provider's types */
51
58
  requestToSsh: (request: CliPermissionSpec<PR, O>) => SR;
52
59
  /** Regex matches for error strings indicating that the provider has not yet fully provisioned node acces */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@p0security/cli",
3
- "version": "0.12.0",
3
+ "version": "0.13.0",
4
4
  "description": "Execute infra CLI commands with P0 grants",
5
5
  "main": "index.ts",
6
6
  "repository": {