@p0security/cli 0.19.14 → 0.19.16
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.
- package/build/dist/commands/index.js +2 -0
- package/build/dist/commands/index.js.map +1 -1
- package/build/dist/commands/rdp.d.ts +2 -0
- package/build/dist/commands/rdp.js +77 -0
- package/build/dist/commands/rdp.js.map +1 -0
- package/build/dist/commands/shared/ssh.js +14 -3
- package/build/dist/commands/shared/ssh.js.map +1 -1
- package/build/dist/plugins/azure/auth.d.ts +6 -1
- package/build/dist/plugins/azure/auth.js +25 -25
- package/build/dist/plugins/azure/auth.js.map +1 -1
- package/build/dist/plugins/azure/rdp.d.ts +13 -0
- package/build/dist/plugins/azure/rdp.js +74 -0
- package/build/dist/plugins/azure/rdp.js.map +1 -0
- package/build/dist/plugins/rdp/index.d.ts +4 -0
- package/build/dist/plugins/rdp/index.js +84 -0
- package/build/dist/plugins/rdp/index.js.map +1 -0
- package/build/dist/types/rdp.d.ts +32 -0
- package/build/dist/types/rdp.js +3 -0
- package/build/dist/types/rdp.js.map +1 -0
- package/build/dist/types/request.d.ts +2 -1
- package/build/dist/types/request.js.map +1 -1
- package/build/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -35,6 +35,7 @@ const login_1 = require("./login");
|
|
|
35
35
|
const logout_1 = require("./logout");
|
|
36
36
|
const ls_1 = require("./ls");
|
|
37
37
|
const print_bearer_token_1 = require("./print-bearer-token");
|
|
38
|
+
const rdp_1 = require("./rdp");
|
|
38
39
|
const request_1 = require("./request");
|
|
39
40
|
const scp_1 = require("./scp");
|
|
40
41
|
const ssh_1 = require("./ssh");
|
|
@@ -55,6 +56,7 @@ const commands = [
|
|
|
55
56
|
ssh_proxy_1.sshProxyCommand,
|
|
56
57
|
ssh_resolve_1.sshResolveCommand,
|
|
57
58
|
scp_1.scpCommand,
|
|
59
|
+
rdp_1.rdpCommand,
|
|
58
60
|
kubeconfig_1.kubeconfigCommand,
|
|
59
61
|
print_bearer_token_1.printBearerTokenCommand,
|
|
60
62
|
];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA;;;;;;;;;GASG;AACH,8CAAmD;AACnD,4CAAkD;AAClD,oDAAsD;AACtD,wCAA2C;AAC3C,mCAAuC;AACvC,+BAAmC;AACnC,mCAAuC;AACvC,6CAAiD;AACjD,mCAAuC;AACvC,qCAAyC;AACzC,6BAAiC;AACjC,6DAA+D;AAC/D,uCAA2C;AAC3C,+BAAmC;AACnC,+BAAmC;AACnC,2CAA8C;AAC9C,+CAAkD;AAClD,2CAAiC;AACjC,kDAA0B;AAC1B,2CAAwC;AAExC,MAAM,QAAQ,GAAG;IACf,gBAAU;IACV,oBAAY;IACZ,oBAAY;IACZ,sBAAa;IACb,cAAS;IACT,wBAAc;IACd,oBAAY;IACZ,gBAAU;IACV,2BAAe;IACf,+BAAiB;IACjB,gBAAU;IACV,8BAAiB;IACjB,4CAAuB;CACxB,CAAC;AAEF,MAAM,SAAS,GAAG,GAAS,EAAE;IAC3B,MAAM,EAAE,OAAO,EAAE,GAAG,uBAAa,CAAC;IAClC,MAAM,IAAI,GAAG,IAAA,eAAK,EAAC,IAAA,iBAAO,EAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IAE3D,6FAA6F;IAC7F,MAAM,gBAAgB,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAClD,IAAI,CAAC,QAAQ,GAAG,CAAC,GAAoC,EAAE,EAAE;QACvD,IAAI,OAAO,GAAG,KAAK,UAAU,EAAE;YAC7B,gBAAgB,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,GAAG,IAAI,GAAG,IAAA,uBAAc,GAAE,CAAC,CAAC,CAAC;SAC3D;aAAM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,CAAC,CAAC,CAAA;EAAA,CAAC;AAfM,QAAA,MAAM,UAeZ"}
|
|
@@ -0,0 +1,77 @@
|
|
|
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.rdpCommand = 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 auth_1 = require("../drivers/auth");
|
|
24
|
+
const stdio_1 = require("../drivers/stdio");
|
|
25
|
+
const rdp_1 = require("../plugins/rdp");
|
|
26
|
+
const util_1 = require("../util");
|
|
27
|
+
const rdpCommand = (yargs) => yargs.command("rdp <destination>", "Connect to a Windows virtual machine via RDP", (yargs) => yargs
|
|
28
|
+
.positional("destination", {
|
|
29
|
+
type: "string",
|
|
30
|
+
demandOption: true,
|
|
31
|
+
})
|
|
32
|
+
.option("reason", {
|
|
33
|
+
describe: "Reason access is needed",
|
|
34
|
+
type: "string",
|
|
35
|
+
})
|
|
36
|
+
.option("debug", {
|
|
37
|
+
type: "boolean",
|
|
38
|
+
describe: "Print debug information.",
|
|
39
|
+
default: false,
|
|
40
|
+
})
|
|
41
|
+
.option("configure", {
|
|
42
|
+
type: "boolean",
|
|
43
|
+
describe: "Configure the RDP session before connecting",
|
|
44
|
+
default: false,
|
|
45
|
+
})
|
|
46
|
+
.usage("$0 rdp <destination>")
|
|
47
|
+
.epilogue(`Connect to a Windows virtual machine via RDP through Azure Bastion Host.
|
|
48
|
+
|
|
49
|
+
Example:
|
|
50
|
+
$ ${(0, util_1.getAppName)()} rdp my-windows-vm --reason "Reason for access"`), rdpAction);
|
|
51
|
+
exports.rdpCommand = rdpCommand;
|
|
52
|
+
/**
|
|
53
|
+
* Connect to a Virtual Machine via RDP
|
|
54
|
+
*
|
|
55
|
+
* Implicitly requests access to the machine if not already granted.
|
|
56
|
+
* Implicitly logs the user into Azure if not already logged in.
|
|
57
|
+
*
|
|
58
|
+
* Supported RDP mechanisms:
|
|
59
|
+
* - Azure VM via Bastion Host with Entra ID authentication
|
|
60
|
+
*/
|
|
61
|
+
const rdpAction = (cmdArgs) => __awaiter(void 0, void 0, void 0, function* () {
|
|
62
|
+
// Entra ID authentication is only supported on Windows client machines.
|
|
63
|
+
// See: https://learn.microsoft.com/en-us/windows/client-management/client-tools/connect-to-remote-aadj-pc#connect-with-microsoft-entra-authentication
|
|
64
|
+
const os = (0, util_1.getOperatingSystem)();
|
|
65
|
+
if (os !== "win") {
|
|
66
|
+
(0, stdio_1.print2)("RDP session connections are only supported on Windows.");
|
|
67
|
+
process.exit(1);
|
|
68
|
+
}
|
|
69
|
+
const authn = yield (0, auth_1.authenticate)(cmdArgs);
|
|
70
|
+
yield (0, rdp_1.rdp)(authn, cmdArgs);
|
|
71
|
+
// Force exit to prevent hanging due to orphaned child processes
|
|
72
|
+
// Skip in tests to avoid killing the test runner
|
|
73
|
+
if (process.env.NODE_ENV !== "unit") {
|
|
74
|
+
process.exit(0);
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
//# sourceMappingURL=rdp.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rdp.js","sourceRoot":"","sources":["../../../src/commands/rdp.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;GASG;AACH,0CAA+C;AAC/C,4CAA0C;AAC1C,wCAAqC;AAErC,kCAAyD;AAGlD,MAAM,UAAU,GAAG,CAAC,KAAiB,EAAE,EAAE,CAC9C,KAAK,CAAC,OAAO,CACX,mBAAmB,EACnB,8CAA8C,EAC9C,CAAC,KAAK,EAAE,EAAE,CACR,KAAK;KACF,UAAU,CAAC,aAAa,EAAE;IACzB,IAAI,EAAE,QAAQ;IACd,YAAY,EAAE,IAAI;CACnB,CAAC;KACD,MAAM,CAAC,QAAQ,EAAE;IAChB,QAAQ,EAAE,yBAAyB;IACnC,IAAI,EAAE,QAAQ;CACf,CAAC;KACD,MAAM,CAAC,OAAO,EAAE;IACf,IAAI,EAAE,SAAS;IACf,QAAQ,EAAE,0BAA0B;IACpC,OAAO,EAAE,KAAK;CACf,CAAC;KACD,MAAM,CAAC,WAAW,EAAE;IACnB,IAAI,EAAE,SAAS;IACf,QAAQ,EAAE,6CAA6C;IACvD,OAAO,EAAE,KAAK;CACf,CAAC;KACD,KAAK,CAAC,sBAAsB,CAAC;KAC7B,QAAQ,CACP;;;MAGJ,IAAA,iBAAU,GAAE,iDAAiD,CAC1D,EAEL,SAAS,CACV,CAAC;AAjCS,QAAA,UAAU,cAiCnB;AAEJ;;;;;;;;GAQG;AACH,MAAM,SAAS,GAAG,CAAO,OAAiD,EAAE,EAAE;IAC5E,wEAAwE;IACxE,sJAAsJ;IACtJ,MAAM,EAAE,GAAG,IAAA,yBAAkB,GAAE,CAAC;IAChC,IAAI,EAAE,KAAK,KAAK,EAAE;QAChB,IAAA,cAAM,EAAC,wDAAwD,CAAC,CAAC;QACjE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;KACjB;IAED,MAAM,KAAK,GAAG,MAAM,IAAA,mBAAY,EAAC,OAAO,CAAC,CAAC;IAC1C,MAAM,IAAA,SAAG,EAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IAE1B,gEAAgE;IAChE,iDAAiD;IACjD,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,MAAM,EAAE;QACnC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;KACjB;AACH,CAAC,CAAA,CAAC"}
|
|
@@ -72,23 +72,34 @@ const provisionRequest = (authn, args, destination, options) => __awaiter(void 0
|
|
|
72
72
|
...(args.parent ? ["--parent", args.parent] : []),
|
|
73
73
|
], wait: true, debug: args.debug }), authn, { message: (options === null || options === void 0 ? void 0 : options.quiet) ? "quiet" : "approval-required" });
|
|
74
74
|
});
|
|
75
|
+
// Always prints the error, but adds a hint if we think a username was included in the instance name by mistake.
|
|
76
|
+
const requestErrorHandler = (err) => {
|
|
77
|
+
if (typeof err === "string") {
|
|
78
|
+
(0, stdio_1.print2)(err);
|
|
79
|
+
if (err.startsWith("Could not find any instances matching") &&
|
|
80
|
+
destination.includes("@")) {
|
|
81
|
+
(0, stdio_1.print2)("Hint: The instance name appears to include a username. The username should be omitted.");
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
typescript_1.sys.exit(1);
|
|
85
|
+
};
|
|
75
86
|
let response;
|
|
76
87
|
if (options === null || options === void 0 ? void 0 : options.approvedOnly) {
|
|
77
88
|
// Try first with sudo
|
|
78
89
|
try {
|
|
79
|
-
response = yield makeRequest({ forceSudo: true });
|
|
90
|
+
response = yield makeRequest({ forceSudo: true }).catch(requestErrorHandler);
|
|
80
91
|
}
|
|
81
92
|
catch (error) {
|
|
82
93
|
// If that fails, try without sudo
|
|
83
94
|
if (args.debug) {
|
|
84
95
|
(0, stdio_1.print2)("Request with sudo failed, retrying without sudo");
|
|
85
96
|
}
|
|
86
|
-
response = yield makeRequest();
|
|
97
|
+
response = yield makeRequest().catch(requestErrorHandler);
|
|
87
98
|
}
|
|
88
99
|
}
|
|
89
100
|
else {
|
|
90
101
|
// Normal behavior when not approvedOnly
|
|
91
|
-
response = yield makeRequest();
|
|
102
|
+
response = yield makeRequest().catch(requestErrorHandler);
|
|
92
103
|
}
|
|
93
104
|
if (!response) {
|
|
94
105
|
if (!(options === null || options === void 0 ? void 0 : options.quiet)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ssh.js","sourceRoot":"","sources":["../../../../src/commands/shared/ssh.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;GASG;AACH,wBAA0C;AAC1C,4CAAkD;AAClD,2CAA2D;AAC3D,iDAAyD;AACzD,+CAA6C;AAC7C,+CAAuD;AACvD,iDAA2D;AAC3D,kDAA0D;AAC1D,uDAAsE;AAItE,yCAMyB;AACzB,uCAAoC;AACpC,mCAA8B;AAC9B,2CAAiC;AA0DpB,QAAA,aAAa,GAGtB;IACF,GAAG,EAAE,oBAAc;IACnB,KAAK,EAAE,sBAAgB;IACvB,MAAM,EAAE,oBAAc;IACtB,aAAa,EAAE,2BAAqB;CACrC,CAAC;AAEF,MAAM,kBAAkB,GAAG,CACzB,KAAY,EACZ,IAAkD,EAClD,EAAE;IACF,MAAM,SAAS,GAAG,MAAM,IAAA,4BAAsB,EAC5C,KAAK,EACL,KAAK,EACL,IAAI,CAAC,KAAK,CACX,CAAC;IACF,MAAM,WAAW,GAAG,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,MAAM,CAAC,WAAW,CAAC,CAAC;IAEnD,MAAM,gBAAgB,GAAG,IAAI,CAAC,QAAQ;QACpC,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC;QACjB,CAAC,CAAC,2BAAqB,CAAC;IAE1B,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AG,MAAM,kBAAkB,CAAC,kBAAkB,kCACzD,IAAI,KACP,SAAS,IACT,CAAC;IAEH,MAAM,OAAO,GAAG,WAAW,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC;IAErD,MAAM,WAAW,GAAG,MAAM,CAAA,MAAA,WAAW,CAAC,YAAY,4DAAG,OAAO,EAAE,IAAI,CAAC,CAAA,CAAC;IAEpE,uCAAY,MAAM,KAAE,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,WAAW,IAAG;AAC9E,CAAC,CAAA,CAAC;AAnCW,QAAA,cAAc,kBAmCzB"}
|
|
@@ -1,8 +1,13 @@
|
|
|
1
|
+
import { AzureRdpRequest } from "../../types/rdp";
|
|
1
2
|
import { AzureSshRequest } from "./types";
|
|
2
3
|
export declare const AUTHORIZATION_FAILED_PATTERN: RegExp;
|
|
3
4
|
export declare const USER_NOT_IN_CACHE_PATTERN: RegExp;
|
|
4
5
|
export declare const NASCENT_ACCESS_GRANT_MESSAGE = "If access was recently granted, please try again in a few minutes.";
|
|
5
6
|
export declare const ABORT_AUTHORIZATION_FAILED_MESSAGE: string;
|
|
7
|
+
export declare const azCommandArgs: (args: string[]) => {
|
|
8
|
+
command: string;
|
|
9
|
+
args: string[];
|
|
10
|
+
};
|
|
6
11
|
export declare const azLoginCommand: (tenantId: string) => {
|
|
7
12
|
command: string;
|
|
8
13
|
args: string[];
|
|
@@ -23,7 +28,7 @@ export declare const azAccountShowUserPrincipalName: () => {
|
|
|
23
28
|
* Attempts to set the Azure subscription for the current ssh session request. If
|
|
24
29
|
* the user is not logged in, this function will attempt to log in.
|
|
25
30
|
*/
|
|
26
|
-
export declare const azSetSubscription: (request: AzureSshRequest, options
|
|
31
|
+
export declare const azSetSubscription: (request: AzureRdpRequest["permission"]["resource"] | AzureSshRequest, options: {
|
|
27
32
|
debug?: boolean;
|
|
28
33
|
forceLogout?: boolean;
|
|
29
34
|
}) => Promise<string>;
|
|
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.azSetSubscription = exports.azAccountShowUserPrincipalName = exports.azAccountSetCommand = exports.azAccountClearCommand = exports.azLoginCommand = exports.ABORT_AUTHORIZATION_FAILED_MESSAGE = exports.NASCENT_ACCESS_GRANT_MESSAGE = exports.USER_NOT_IN_CACHE_PATTERN = exports.AUTHORIZATION_FAILED_PATTERN = void 0;
|
|
12
|
+
exports.azSetSubscription = exports.azAccountShowUserPrincipalName = exports.azAccountSetCommand = exports.azAccountClearCommand = exports.azLoginCommand = exports.azCommandArgs = exports.ABORT_AUTHORIZATION_FAILED_MESSAGE = exports.NASCENT_ACCESS_GRANT_MESSAGE = exports.USER_NOT_IN_CACHE_PATTERN = exports.AUTHORIZATION_FAILED_PATTERN = void 0;
|
|
13
13
|
/** Copyright © 2024-present P0 Security
|
|
14
14
|
|
|
15
15
|
This file is part of @p0security/cli
|
|
@@ -30,31 +30,31 @@ exports.AUTHORIZATION_FAILED_PATTERN = /The client '.+' with object id '.+' does
|
|
|
30
30
|
exports.USER_NOT_IN_CACHE_PATTERN = /Exception in handling client: User '.+' does not exist in MSAL token cache./;
|
|
31
31
|
exports.NASCENT_ACCESS_GRANT_MESSAGE = "If access was recently granted, please try again in a few minutes.";
|
|
32
32
|
exports.ABORT_AUTHORIZATION_FAILED_MESSAGE = `Your Microsoft Token Cache is out of date. Run 'az account clear' and 'az login' to refresh your credentials. ${(0, config_1.getContactMessage)()}`;
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}
|
|
33
|
+
const azCommandArgs = (args) => {
|
|
34
|
+
const isWindows = (0, util_1.getOperatingSystem)() === "win";
|
|
35
|
+
// On Windows, when installing the Azure CLI, the main az file is
|
|
36
|
+
// a .cmd (shell script) file rather than a .exe (binary executable) file,
|
|
37
|
+
// so when calling spawn, it cannot be located except via cmd.exe
|
|
38
|
+
// Unlike in MacOS, the underlying Windows OS API that spawn uses doesn't
|
|
39
|
+
// resolve .CMD files by default
|
|
40
|
+
return isWindows
|
|
41
|
+
? { command: "cmd.exe", args: ["/d", "/s", "/c", "az", ...args] }
|
|
42
|
+
: { command: "az", args };
|
|
43
|
+
};
|
|
44
|
+
exports.azCommandArgs = azCommandArgs;
|
|
45
|
+
const azLoginCommand = (tenantId) => (0, exports.azCommandArgs)([
|
|
46
|
+
"login",
|
|
47
|
+
"--scope",
|
|
48
|
+
"https://management.core.windows.net//.default",
|
|
49
|
+
"--tenant",
|
|
50
|
+
tenantId,
|
|
51
|
+
]);
|
|
43
52
|
exports.azLoginCommand = azLoginCommand;
|
|
44
|
-
const azAccountClearCommand = () => (
|
|
45
|
-
command: "az",
|
|
46
|
-
args: ["account", "clear"],
|
|
47
|
-
});
|
|
53
|
+
const azAccountClearCommand = () => (0, exports.azCommandArgs)(["account", "clear"]);
|
|
48
54
|
exports.azAccountClearCommand = azAccountClearCommand;
|
|
49
|
-
const azAccountSetCommand = (subscriptionId) => (
|
|
50
|
-
command: "az",
|
|
51
|
-
args: ["account", "set", "--subscription", subscriptionId],
|
|
52
|
-
});
|
|
55
|
+
const azAccountSetCommand = (subscriptionId) => (0, exports.azCommandArgs)(["account", "set", "--subscription", subscriptionId]);
|
|
53
56
|
exports.azAccountSetCommand = azAccountSetCommand;
|
|
54
|
-
const azAccountShowUserPrincipalName = () => (
|
|
55
|
-
command: "az",
|
|
56
|
-
args: ["account", "show", "--query", "user.name", "-o", "tsv"],
|
|
57
|
-
});
|
|
57
|
+
const azAccountShowUserPrincipalName = () => (0, exports.azCommandArgs)(["account", "show", "--query", "user.name", "-o", "tsv"]);
|
|
58
58
|
exports.azAccountShowUserPrincipalName = azAccountShowUserPrincipalName;
|
|
59
59
|
const performAccountClear = ({ debug }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
60
60
|
try {
|
|
@@ -151,7 +151,7 @@ const getUserPrincipalName = ({ debug }) => __awaiter(void 0, void 0, void 0, fu
|
|
|
151
151
|
* Attempts to set the Azure subscription for the current ssh session request. If
|
|
152
152
|
* the user is not logged in, this function will attempt to log in.
|
|
153
153
|
*/
|
|
154
|
-
const azSetSubscription = (request, options
|
|
154
|
+
const azSetSubscription = (request, options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
155
155
|
const { debug, forceLogout } = options;
|
|
156
156
|
if (debug)
|
|
157
157
|
(0, stdio_1.print2)("Forming Azure connection...");
|
|
@@ -160,7 +160,7 @@ const azSetSubscription = (request, options = {}) => __awaiter(void 0, void 0, v
|
|
|
160
160
|
if (forceLogout)
|
|
161
161
|
yield performAccountClear({ debug });
|
|
162
162
|
yield performSetAccount(request, Object.assign(Object.assign({}, options), { attempts: 2 }));
|
|
163
|
-
return yield getUserPrincipalName(
|
|
163
|
+
return yield getUserPrincipalName({ debug });
|
|
164
164
|
});
|
|
165
165
|
exports.azSetSubscription = azSetSubscription;
|
|
166
166
|
//# sourceMappingURL=auth.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../../../src/plugins/azure/auth.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;GASG;AACH,iDAAyD;AACzD,+CAA6C;
|
|
1
|
+
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../../../src/plugins/azure/auth.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;GASG;AACH,iDAAyD;AACzD,+CAA6C;AAE7C,qCAAsD;AAGtD,MAAM,8BAA8B,GAClC,+DAA+D,CAAC;AAClE,MAAM,gCAAgC,GAAG,+BAA+B,CAAC;AACzE,MAAM,+BAA+B,GACnC,6FAA6F,CAAC;AACnF,QAAA,4BAA4B,GACvC,iMAAiM,CAAC;AACvL,QAAA,yBAAyB,GACpC,6EAA6E,CAAC;A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,CAC/B,OAAoE,EACpE,OAAmD,EACnD,EAAE;IACF,MAAM,EAAE,KAAK,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC;IACvC,IAAI,KAAK;QAAE,IAAA,cAAM,EAAC,6BAA6B,CAAC,CAAC;IAEjD,qEAAqE;IACrE,kDAAkD;IAClD,IAAI,WAAW;QAAE,MAAM,mBAAmB,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;IAEtD,MAAM,iBAAiB,CAAC,OAAO,kCAAO,OAAO,KAAE,QAAQ,EAAE,CAAC,IAAG,CAAC;IAE9D,OAAO,MAAM,oBAAoB,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;AAC/C,CAAC,CAAA,CAAC;AAdW,QAAA,iBAAiB,qBAc5B"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { AzureRdpRequest } from "../../types/rdp";
|
|
2
|
+
import { PermissionRequest } from "../../types/request";
|
|
3
|
+
export declare const azureRdpProvider: {
|
|
4
|
+
setup: (request: PermissionRequest<AzureRdpRequest>, options: {
|
|
5
|
+
debug?: boolean;
|
|
6
|
+
}) => Promise<{
|
|
7
|
+
entraIdUserEmail: string;
|
|
8
|
+
}>;
|
|
9
|
+
spawnConnection: (request: PermissionRequest<AzureRdpRequest>, options: {
|
|
10
|
+
configure?: boolean;
|
|
11
|
+
debug?: boolean;
|
|
12
|
+
}) => Promise<void>;
|
|
13
|
+
};
|
|
@@ -0,0 +1,74 @@
|
|
|
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.azureRdpProvider = 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 auth_1 = require("./auth");
|
|
26
|
+
const azBastionRdpCommand = (request, options) => {
|
|
27
|
+
const { configure, debug } = options;
|
|
28
|
+
const { bastionName, bastionRg, instanceId } = request.permission.resource;
|
|
29
|
+
return (0, auth_1.azCommandArgs)([
|
|
30
|
+
"network",
|
|
31
|
+
"bastion",
|
|
32
|
+
"rdp",
|
|
33
|
+
"--name",
|
|
34
|
+
bastionName,
|
|
35
|
+
"--resource-group",
|
|
36
|
+
bastionRg,
|
|
37
|
+
"--target-resource-id",
|
|
38
|
+
instanceId,
|
|
39
|
+
"--auth-type",
|
|
40
|
+
"aad",
|
|
41
|
+
...(configure ? ["--configure"] : []),
|
|
42
|
+
...(debug ? ["--debug"] : []),
|
|
43
|
+
]);
|
|
44
|
+
};
|
|
45
|
+
exports.azureRdpProvider = {
|
|
46
|
+
setup: (request, options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
47
|
+
const entraIdUserEmail = yield (0, auth_1.azSetSubscription)(request.permission.resource, options);
|
|
48
|
+
return { entraIdUserEmail };
|
|
49
|
+
}),
|
|
50
|
+
spawnConnection: (request, options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
51
|
+
const { debug } = options;
|
|
52
|
+
if (debug) {
|
|
53
|
+
(0, stdio_1.print2)("Creating Azure Bastion RDP connection...");
|
|
54
|
+
}
|
|
55
|
+
try {
|
|
56
|
+
const { command, args } = azBastionRdpCommand(request, options);
|
|
57
|
+
if (debug) {
|
|
58
|
+
(0, stdio_1.print2)(`Executing: ${command} ${args.join(" ")}`);
|
|
59
|
+
}
|
|
60
|
+
yield (0, util_1.exec)(command, args, { check: true });
|
|
61
|
+
}
|
|
62
|
+
catch (error) {
|
|
63
|
+
if (debug) {
|
|
64
|
+
(0, stdio_1.print2)(`Azure Bastion RDP command failed: ${error.message}`);
|
|
65
|
+
if (error.stderr) {
|
|
66
|
+
(0, stdio_1.print2)("Error details:");
|
|
67
|
+
(0, stdio_1.print2)(error.stderr);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
throw new Error(`Failed to create Azure Bastion RDP connection: ${error.message}`);
|
|
71
|
+
}
|
|
72
|
+
}),
|
|
73
|
+
};
|
|
74
|
+
//# sourceMappingURL=rdp.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rdp.js","sourceRoot":"","sources":["../../../../src/plugins/azure/rdp.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;GASG;AACH,+CAA6C;AAG7C,qCAAkC;AAClC,iCAA0D;AAE1D,MAAM,mBAAmB,GAAG,CAC1B,OAA2C,EAC3C,OAAiD,EACjD,EAAE;IACF,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,GAAG,OAAO,CAAC;IACrC,MAAM,EAAE,WAAW,EAAE,SAAS,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC,UAAU,CAAC,QAAQ,CAAC;IAC3E,OAAO,IAAA,oBAAa,E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AAI,KAAK,CAAC,MAAM,EAAE;oBAChB,IAAA,cAAM,EAAC,gBAAgB,CAAC,CAAC;oBACzB,IAAA,cAAM,EAAC,KAAK,CAAC,MAAM,CAAC,CAAC;iBACtB;aACF;YACD,MAAM,IAAI,KAAK,CACb,kDAAkD,KAAK,CAAC,OAAO,EAAE,CAClE,CAAC;SACH;IACH,CAAC,CAAA;CACF,CAAC"}
|
|
@@ -0,0 +1,84 @@
|
|
|
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.rdp = 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 shared_1 = require("../../commands/shared");
|
|
24
|
+
const request_1 = require("../../commands/shared/request");
|
|
25
|
+
const api_1 = require("../../drivers/api");
|
|
26
|
+
const config_1 = require("../../drivers/config");
|
|
27
|
+
const stdio_1 = require("../../drivers/stdio");
|
|
28
|
+
const rdp_1 = require("../azure/rdp");
|
|
29
|
+
const lodash_1 = require("lodash");
|
|
30
|
+
const validateRdpInstall = (authn, args) => __awaiter(void 0, void 0, void 0, function* () {
|
|
31
|
+
const configDoc = yield (0, api_1.fetchIntegrationConfig)(authn, "rdp", args.debug);
|
|
32
|
+
const configItems = configDoc === null || configDoc === void 0 ? void 0 : configDoc.config["iam-write"];
|
|
33
|
+
const items = Object.entries(configItems !== null && configItems !== void 0 ? configItems : {}).filter(([_key, value]) => value.state === "installed");
|
|
34
|
+
if (items.length === 0) {
|
|
35
|
+
throw "This organization is not configured for RDP access";
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
const provisionRequest = (authn, args) => __awaiter(void 0, void 0, void 0, function* () {
|
|
39
|
+
yield validateRdpInstall(authn, args);
|
|
40
|
+
const { destination } = args;
|
|
41
|
+
const makeRequest = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
42
|
+
return yield (0, request_1.request)("request")(Object.assign(Object.assign({}, (0, lodash_1.pick)(args, "$0", "_")), { arguments: [
|
|
43
|
+
"rdp",
|
|
44
|
+
"session",
|
|
45
|
+
destination,
|
|
46
|
+
...(args.reason ? ["--reason", args.reason] : []),
|
|
47
|
+
], wait: true, debug: args.debug, configure: args.configure }), authn);
|
|
48
|
+
});
|
|
49
|
+
const response = yield makeRequest();
|
|
50
|
+
if (!response) {
|
|
51
|
+
(0, stdio_1.print2)("Did not receive access ID from server");
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
const { isPreexisting } = response;
|
|
55
|
+
const message = isPreexisting
|
|
56
|
+
? "Existing access found. Connecting to instance."
|
|
57
|
+
: "Waiting for access to be provisioned";
|
|
58
|
+
(0, stdio_1.print2)(message);
|
|
59
|
+
const result = yield (0, shared_1.decodeProvisionStatus)(response.request);
|
|
60
|
+
if (!result)
|
|
61
|
+
process.exit(1);
|
|
62
|
+
return {
|
|
63
|
+
provisionedRequest: response.request,
|
|
64
|
+
};
|
|
65
|
+
});
|
|
66
|
+
const prepareRequest = (authn, args) => __awaiter(void 0, void 0, void 0, function* () {
|
|
67
|
+
const result = yield provisionRequest(authn, args);
|
|
68
|
+
if (!result) {
|
|
69
|
+
throw `Server did not return a request id. ${(0, config_1.getContactMessage)()}`;
|
|
70
|
+
}
|
|
71
|
+
const { provisionedRequest } = result;
|
|
72
|
+
return { request: provisionedRequest };
|
|
73
|
+
});
|
|
74
|
+
const rdp = (authn, args) => __awaiter(void 0, void 0, void 0, function* () {
|
|
75
|
+
const { request } = yield prepareRequest(authn, args);
|
|
76
|
+
const { configure, debug } = args;
|
|
77
|
+
yield rdp_1.azureRdpProvider.setup(request, { debug });
|
|
78
|
+
yield rdp_1.azureRdpProvider.spawnConnection(request, {
|
|
79
|
+
configure,
|
|
80
|
+
debug,
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
exports.rdp = rdp;
|
|
84
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/plugins/rdp/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;GASG;AACH,kDAA8D;AAC9D,2DAAwD;AACxD,2CAA2D;AAC3D,iDAAyD;AACzD,+CAA6C;AAI7C,sCAAgD;AAChD,mCAA8B;AAG9B,MAAM,kBAAkB,GAAG,CACzB,KAAY,EACZ,IAA8C,EAC9C,EAAE;IACF,MAAM,SAAS,GAAG,MAAM,IAAA,4BAAsB,EAI3C,KAAK,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;IAC7B,MAAM,WAAW,GAAG,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,MAAM,CAAC,WAAW,CAAC,CAAC;IAEnD,MAAM,KAAK,GAAG,M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cAAM,EAAC,OAAO,CAAC,CAAC;IAEhB,MAAM,MAAM,GAAG,MAAM,IAAA,8BAAqB,EAAkB,QAAQ,CAAC,OAAO,CAAC,CAAC;IAE9E,IAAI,CAAC,MAAM;QAAE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAE7B,OAAO;QACL,kBAAkB,EAAE,QAAQ,CAAC,OAAO;KACrC,CAAC;AACJ,CAAC,CAAA,CAAC;AAEF,MAAM,cAAc,GAAG,CACrB,KAAY,EACZ,IAA8C,EAC9C,EAAE;IACF,MAAM,MAAM,GAAG,MAAM,gBAAgB,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;IACnD,IAAI,CAAC,MAAM,EAAE;QACX,MAAM,uCAAuC,IAAA,0BAAiB,GAAE,EAAE,CAAC;KACpE;IAED,MAAM,EAAE,kBAAkB,EAAE,GAAG,MAAM,CAAC;IACtC,OAAO,EAAE,OAAO,EAAE,kBAAkB,EAAE,CAAC;AACzC,CAAC,CAAA,CAAC;AAEK,MAAM,GAAG,GAAG,CACjB,KAAY,EACZ,IAA8C,EAC9C,EAAE;IACF,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,cAAc,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;IAEtD,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC;IAClC,MAAM,sBAAgB,CAAC,KAAK,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;IAEjD,MAAM,sBAAgB,CAAC,eAAe,CAAC,OAAO,EAAE;QAC9C,SAAS;QACT,KAAK;KACN,CAAC,CAAC;AACL,CAAC,CAAA,CAAC;AAbW,QAAA,GAAG,OAad"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/** Copyright © 2024-present P0 Security
|
|
2
|
+
|
|
3
|
+
This file is part of @p0security/cli
|
|
4
|
+
|
|
5
|
+
@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.
|
|
6
|
+
|
|
7
|
+
@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.
|
|
8
|
+
|
|
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
|
+
**/
|
|
11
|
+
import { PermissionSpec } from "./request";
|
|
12
|
+
export type AzureRdpPermissionSpec = PermissionSpec<"rdp", AzureRdpRequest & {
|
|
13
|
+
type: "azure";
|
|
14
|
+
}, object>;
|
|
15
|
+
export type AzureRdpRequest = {
|
|
16
|
+
principal: string;
|
|
17
|
+
permission: {
|
|
18
|
+
resource: {
|
|
19
|
+
instanceId: string;
|
|
20
|
+
subscriptionId: string;
|
|
21
|
+
bastionName: string;
|
|
22
|
+
bastionRg: string;
|
|
23
|
+
directoryId: string;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
export type RdpCommandArgs = {
|
|
28
|
+
configure?: boolean;
|
|
29
|
+
debug?: boolean;
|
|
30
|
+
destination: string;
|
|
31
|
+
reason?: string;
|
|
32
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rdp.js","sourceRoot":"","sources":["../../../src/types/rdp.ts"],"names":[],"mappings":""}
|
|
@@ -9,6 +9,7 @@ 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 { K8sPermissionSpec } from "../plugins/kubeconfig/types";
|
|
12
|
+
import { AzureRdpRequest } from "./rdp";
|
|
12
13
|
import { PluginSshRequest, SupportedSshProvider } from "./ssh";
|
|
13
14
|
export declare const DONE_STATUSES: readonly ["DONE", "DONE_NOTIFIED"];
|
|
14
15
|
export declare const DENIED_STATUSES: readonly ["DENIED", "DENIED_NOTIFIED"];
|
|
@@ -22,7 +23,7 @@ export type PermissionSpec<K extends string, P extends {
|
|
|
22
23
|
permission: P;
|
|
23
24
|
generated: G;
|
|
24
25
|
};
|
|
25
|
-
export type PluginRequest = K8sPermissionSpec | PluginSshRequest;
|
|
26
|
+
export type PluginRequest = AzureRdpRequest | K8sPermissionSpec | PluginSshRequest;
|
|
26
27
|
export type PermissionRequest<P extends PluginRequest> = P & {
|
|
27
28
|
error?: {
|
|
28
29
|
message: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"request.js","sourceRoot":"","sources":["../../../src/types/request.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"request.js","sourceRoot":"","sources":["../../../src/types/request.ts"],"names":[],"mappings":";;;AAca,QAAA,aAAa,GAAG,CAAC,MAAM,EAAE,eAAe,CAAU,CAAC;AACnD,QAAA,eAAe,GAAG,CAAC,QAAQ,EAAE,iBAAiB,CAAU,CAAC;AACzD,QAAA,cAAc,GAAG;IAC5B,SAAS;IACT,SAAS;IACT,kBAAkB;CACV,CAAC"}
|