@p0security/cli 0.19.15 → 0.20.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.
- 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/common/install.js +4 -2
- package/build/dist/common/install.js.map +1 -1
- package/build/dist/common/subprocess.js +2 -2
- package/build/dist/common/subprocess.js.map +1 -1
- package/build/dist/fips-diagnose.d.ts +10 -0
- package/build/dist/fips-diagnose.js +93 -0
- package/build/dist/fips-diagnose.js.map +1 -0
- package/build/dist/index.js +31 -0
- package/build/dist/index.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/azure/tunnel.js +3 -2
- package/build/dist/plugins/azure/tunnel.js.map +1 -1
- 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/plugins/ssh/index.js +1 -1
- package/build/dist/plugins/ssh/index.js.map +1 -1
- 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/dist/util.d.ts +26 -2
- package/build/dist/util.js +18 -3
- package/build/dist/util.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,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,CAAC,CAAC,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE;QAC9B,IAAI,KAAK,EAAE;YACT,IAAA,cAAM,EAAC,KAAK,CAAC,CAAC;SACf;aAAM;YACL,IAAA,cAAM,EAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC;YACrB,IAAA,cAAM,EAAC,KAAK,OAAO,EAAE,CAAC,CAAC;YACvB,IAAA,cAAM,EAAC,KAAK,IAAA,uBAAc,GAAE,EAAE,CAAC,CAAC;SACjC;QACD,gBAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACd,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"}
|
|
@@ -25,8 +25,8 @@ You should have received a copy of the GNU General Public License along with @p0
|
|
|
25
25
|
**/
|
|
26
26
|
const stdio_1 = require("../drivers/stdio");
|
|
27
27
|
const types_1 = require("../types");
|
|
28
|
+
const util_1 = require("../util");
|
|
28
29
|
const lodash_1 = require("lodash");
|
|
29
|
-
const node_child_process_1 = require("node:child_process");
|
|
30
30
|
const node_os_1 = __importDefault(require("node:os"));
|
|
31
31
|
const typescript_1 = require("typescript");
|
|
32
32
|
const which_1 = __importDefault(require("which"));
|
|
@@ -91,7 +91,9 @@ const guidedInstall = (platform, item, installData) => __awaiter(void 0, void 0,
|
|
|
91
91
|
(0, stdio_1.print2)(`Executing:\n${combined}`);
|
|
92
92
|
(0, stdio_1.print2)("");
|
|
93
93
|
yield new Promise((resolve, reject) => {
|
|
94
|
-
const child = (0,
|
|
94
|
+
const child = (0, util_1.spawnWithCleanEnv)("bash", ["-c", combined], {
|
|
95
|
+
stdio: "inherit",
|
|
96
|
+
});
|
|
95
97
|
child.on("exit", (code) => {
|
|
96
98
|
if (code === 0)
|
|
97
99
|
resolve();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"install.js","sourceRoot":"","sources":["../../../src/common/install.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA;;;;;;;;;GASG;AACH,4CAAkD;AAClD,oCAA+B;AAC/B,mCAAiC;AACjC,
|
|
1
|
+
{"version":3,"file":"install.js","sourceRoot":"","sources":["../../../src/common/install.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA;;;;;;;;;GASG;AACH,4CAAkD;AAClD,oCAA+B;AAC/B,kCAA4C;AAC5C,mCAAiC;AACjC,sDAAyB;AACzB,2CAAiC;AACjC,kDAA0B;AAEb,QAAA,kBAAkB,GAAG,CAAC,QAAQ,CAAU,CAAC;AAGzC,QAAA,QAAQ,GAAG,CAAC,KAAK,CAAU,CAAC;AAG5B,QAAA,aAAa,GAAG,CAAC,MAAM,CAAU,CAAC;AAQlC,QAAA,UAAU,GAA+C;IACpE,GAAG,EAAE;QACH,KAAK,EAAE,YAAY;QACnB,QAAQ,EAAE;YACR,MAAM,EAAE;gBACN,oEAAoE;gBACpE,4CAA4C;gBAC5C,mBAAmB;aACpB;SACF;KACF;CACF,CAAC;AAEW,QAAA,eAAe,GAC1B;IACE,IAAI,EAAE;QACJ,KAAK,EAAE,UAAU;QACjB,QAAQ,EAAE;YACR,MAAM,EAAE;gBACN,iGAAiG;aAClG;SACF;KACF;CACF,CAAC;AAEJ,MAAM,cAAc,GAAG,CAIrB,SAAuB,EACvB,eAAkB,EAClB,EAAE;IACF,IAAA,cAAM,EAAC,mEAAmE,CAAC,CAAC;IAC5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,YAAY,CAAC,CAAC;IAEvD,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE;QAC1B,OAAO,IAAI,CAAC;KACb;IAED,MAAM,QAAQ,GAAG,iBAAE,CAAC,QAAQ,EAAE,CAAC;IAE/B,cAAc,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC;IAEvC,IAAI,CAAC,IAAA,WAAG,EAAC,0BAAkB,CAAC,CAAC,QAAQ,CAAC,EAAE;QACtC,MAAM,CACJ,+DAA+D,QAAQ,IAAI;YAC3E,kFAAkF,CACnF,CAAC;KACH;IAED,MAAM,WAAW,GAAG,CAAC,CAAC,CAAA,MAAA,gBAAG,CAAC,gBAAgB,gEAAI,CAAA,IAAI,CAAC,MAAM,gBAAgB,EAAE,CAAC,CAAC;IAE7E,KAAK,MAAM,IAAI,IAAI,SAAS,EAAE;QAC5B,IAAI,WAAW;YAAE,MAAM,IAAA,qBAAa,EAAC,QAAQ,EAAE,IAAI,EAAE,WAAW,CAAC,CAAC;;YAC7D,oBAAoB,CAAC,QAAQ,EAAE,IAAI,EAAE,WAAW,CAAC,CAAC;KACxD;IAED,MAAM,SAAS,GAAG,MAAM,gBAAgB,CAAC,YAAY,CAAC,CAAC;IAEvD,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE;QAC1B,IAAA,cAAM,EAAC,qCAAqC,CAAC,CAAC;QAC9C,OAAO,IAAI,CAAC;KACb;IACD,OAAO,KAAK,CAAC;AACf,CAAC,CAAA,CAAC;AAtCW,QAAA,aAAa,iBAsCxB"}
|
|
@@ -21,7 +21,7 @@ This file is part of @p0security/cli
|
|
|
21
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
22
|
**/
|
|
23
23
|
const stdio_1 = require("../drivers/stdio");
|
|
24
|
-
const
|
|
24
|
+
const util_1 = require("../util");
|
|
25
25
|
/** Spawns a subprocess with given command, args, and options.
|
|
26
26
|
* May write content to its standard input.
|
|
27
27
|
* Stdout and stderr of the subprocess is printed to stderr in debug mode.
|
|
@@ -32,7 +32,7 @@ const node_child_process_1 = require("node:child_process");
|
|
|
32
32
|
const asyncSpawn = ({ debug }, command, args, options, writeStdin) => __awaiter(void 0, void 0, void 0, function* () {
|
|
33
33
|
return new Promise((resolve, reject) => {
|
|
34
34
|
var _a;
|
|
35
|
-
const child = (0,
|
|
35
|
+
const child = (0, util_1.spawnWithCleanEnv)(command, args, options);
|
|
36
36
|
child.on("error", (error) => {
|
|
37
37
|
if (debug) {
|
|
38
38
|
(0, stdio_1.print2)("Process error: " + error.message);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subprocess.js","sourceRoot":"","sources":["../../../src/common/subprocess.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;GASG;AACH,4CAA0C;AAC1C,
|
|
1
|
+
{"version":3,"file":"subprocess.js","sourceRoot":"","sources":["../../../src/common/subprocess.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;GASG;AACH,4CAA0C;AAC1C,kCAA4C;AAO5C;;;;;;+DAM+D;AACxD,MAAM,UAAU,GAAG,CACxB,EAAE,KAAK,EAAkB,EACzB,OAAe,EACf,IAA4B,EAC5B,OAAkC,EAClC,UAAmB,EACnB,EAAE;IACF,OAAA,IAAI,OAAO,CAAS,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;;QACtC,MAAM,KAAK,GAAG,IAAA,wBAAiB,EAAC,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;QAExD,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,KAAY,EAAE,EAAE;YACjC,IAAI,KAAK,EAAE;gBACT,IAAA,cAAM,EAAC,iBAAiB,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC;aAC3C;YACD,OAAO,MAAM,CAAC,kBAAkB,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;QACnD,CAAC,CAAC,CAAC;QAEH,IAAI,UAAU,EAA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,QAAA,UAAU,cAuDlB"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Run comprehensive FIPS diagnostics to test TLS configuration and connectivity
|
|
3
|
+
*
|
|
4
|
+
* This function checks:
|
|
5
|
+
* - Environment variables and Node.js versions
|
|
6
|
+
* - FIPS mode status
|
|
7
|
+
* - Available TLS ciphers with FIPS configuration
|
|
8
|
+
* - Actual HTTPS connectivity using FIPS-compliant settings
|
|
9
|
+
*/
|
|
10
|
+
export declare const runFipsDiagnostics: () => Promise<void>;
|
|
@@ -0,0 +1,93 @@
|
|
|
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.runFipsDiagnostics = 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 node_crypto_1 = __importDefault(require("node:crypto"));
|
|
28
|
+
const node_os_1 = __importDefault(require("node:os"));
|
|
29
|
+
const node_tls_1 = __importDefault(require("node:tls"));
|
|
30
|
+
/**
|
|
31
|
+
* Run comprehensive FIPS diagnostics to test TLS configuration and connectivity
|
|
32
|
+
*
|
|
33
|
+
* This function checks:
|
|
34
|
+
* - Environment variables and Node.js versions
|
|
35
|
+
* - FIPS mode status
|
|
36
|
+
* - Available TLS ciphers with FIPS configuration
|
|
37
|
+
* - Actual HTTPS connectivity using FIPS-compliant settings
|
|
38
|
+
*/
|
|
39
|
+
const runFipsDiagnostics = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
40
|
+
(0, stdio_1.print2)("=== Environment ===");
|
|
41
|
+
(0, stdio_1.print2)(`Node: ${process.versions.node}`);
|
|
42
|
+
(0, stdio_1.print2)(`OpenSSL: ${process.versions.openssl}`);
|
|
43
|
+
const vars = process.config.variables;
|
|
44
|
+
(0, stdio_1.print2)(`openssl_is_fips: ${vars.openssl_is_fips}`);
|
|
45
|
+
(0, stdio_1.print2)(`node_shared_openssl: ${vars.node_shared_openssl}`);
|
|
46
|
+
(0, stdio_1.print2)(`node_use_openssl: ${vars.node_use_openssl}`);
|
|
47
|
+
try {
|
|
48
|
+
(0, stdio_1.print2)(`crypto.getFips(): ${node_crypto_1.default.getFips()}`);
|
|
49
|
+
}
|
|
50
|
+
catch (error) {
|
|
51
|
+
(0, stdio_1.print2)(`crypto.getFips(): Error - ${String(error)}`);
|
|
52
|
+
}
|
|
53
|
+
(0, stdio_1.print2)(`NODE_OPTIONS: ${process.env.NODE_OPTIONS || "(unset)"}`);
|
|
54
|
+
(0, stdio_1.print2)(`OPENSSL_CONF: ${process.env.OPENSSL_CONF || "(unset)"}`);
|
|
55
|
+
(0, stdio_1.print2)(`OPENSSL_MODULES: ${process.env.OPENSSL_MODULES || "(unset)"}`);
|
|
56
|
+
(0, stdio_1.print2)(`Platform: ${node_os_1.default.platform()} ${node_os_1.default.release()}`);
|
|
57
|
+
(0, stdio_1.print2)("\n=== TLS & FIPS Validation ===");
|
|
58
|
+
// Test TLS 1.2 support
|
|
59
|
+
try {
|
|
60
|
+
node_tls_1.default.createSecureContext({
|
|
61
|
+
minVersion: "TLSv1.2",
|
|
62
|
+
maxVersion: "TLSv1.2",
|
|
63
|
+
});
|
|
64
|
+
(0, stdio_1.print2)(`✅ TLS 1.2 context created successfully`);
|
|
65
|
+
}
|
|
66
|
+
catch (e) {
|
|
67
|
+
(0, stdio_1.print2)(`❌ TLS 1.2 context failed: ${(e === null || e === void 0 ? void 0 : e.message) || e}`);
|
|
68
|
+
}
|
|
69
|
+
// Test TLS 1.3 support (cipher suites are handled differently)
|
|
70
|
+
try {
|
|
71
|
+
const _ctx13 = node_tls_1.default.createSecureContext({
|
|
72
|
+
minVersion: "TLSv1.3",
|
|
73
|
+
maxVersion: "TLSv1.3",
|
|
74
|
+
// Note: TLS 1.3 cipher suites can't be controlled via 'ciphers' property
|
|
75
|
+
});
|
|
76
|
+
(0, stdio_1.print2)(`✅ TLS 1.3 context created successfully`);
|
|
77
|
+
}
|
|
78
|
+
catch (e) {
|
|
79
|
+
(0, stdio_1.print2)(`❌ TLS 1.3 context failed: ${(e === null || e === void 0 ? void 0 : e.message) || e}`);
|
|
80
|
+
}
|
|
81
|
+
// Test generic FIPS-enabled context (no version restrictions)
|
|
82
|
+
try {
|
|
83
|
+
const _ctxDefault = node_tls_1.default.createSecureContext({
|
|
84
|
+
// Let FIPS mode handle algorithm selection
|
|
85
|
+
});
|
|
86
|
+
(0, stdio_1.print2)(`✅ Default FIPS context created successfully`);
|
|
87
|
+
}
|
|
88
|
+
catch (e) {
|
|
89
|
+
(0, stdio_1.print2)(`❌ Default FIPS context failed: ${(e === null || e === void 0 ? void 0 : e.message) || e}`);
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
exports.runFipsDiagnostics = runFipsDiagnostics;
|
|
93
|
+
//# sourceMappingURL=fips-diagnose.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fips-diagnose.js","sourceRoot":"","sources":["../../src/fips-diagnose.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA;;;;;;;;;GASG;AACH,2CAAyC;AACzC,8DAAiC;AACjC,sDAAyB;AACzB,wDAA2B;AAE3B;;;;;;;;GAQG;AACI,MAAM,kBAAkB,GAAG,GAAwB,EAAE;IAC1D,IAAA,cAAM,EAAC,qBAAqB,CAAC,CAAC;IAC9B,IAAA,cAAM,EAAC,SAAS,OAAO,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC;IACzC,IAAA,cAAM,EAAC,YAAY,OAAO,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAC;IAE/C,MAAM,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,SAAgB,CAAC;IAC7C,IAAA,cAAM,EAAC,oBAAoB,IAAI,CAAC,eAAe,EAAE,CAAC,CAAC;IACnD,IAAA,cAAM,EAAC,wBAAwB,IAAI,CAAC,mBAAmB,EAAE,CAAC,CAAC;IAC3D,IAAA,cAAM,EAAC,qBAAqB,IAAI,CAAC,gBAAgB,EAAE,CAAC,CAAC;IAErD,IAAI;QACF,IAAA,cAAM,EAAC,qBAAqB,qBAAM,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;KACjD;IAAC,OAAO,KAAK,EAAE;QACd,IAAA,cAAM,EAAC,6BAA6B,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;KACtD;IAED,IAAA,cAAM,EAAC,iBAAiB,OAAO,CAAC,GAAG,CAAC,YAAY,IAAI,SAAS,EAAE,CAAC,CAAC;IACjE,IAAA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BAAD,CAAC,CAAE,OAAO,KAAI,CAAC,EAAE,CAAC,CAAC;KAC7D;AACH,CAAC,CAAA,CAAC;AAvDW,QAAA,kBAAkB,sBAuD7B"}
|
package/build/dist/index.js
CHANGED
|
@@ -18,6 +18,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
18
18
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
19
19
|
});
|
|
20
20
|
};
|
|
21
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
22
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
|
+
};
|
|
21
24
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
25
|
exports.main = void 0;
|
|
23
26
|
// Tracing initialization must happen before any other imports
|
|
@@ -30,6 +33,34 @@ const stdio_1 = require("./drivers/stdio");
|
|
|
30
33
|
const api_1 = require("@opentelemetry/api");
|
|
31
34
|
const node_sea_1 = require("node:sea");
|
|
32
35
|
const lodash_1 = require("lodash");
|
|
36
|
+
const node_crypto_1 = __importDefault(require("node:crypto"));
|
|
37
|
+
const fips_diagnose_1 = require("./fips-diagnose");
|
|
38
|
+
const util_1 = require("./util");
|
|
39
|
+
/**
|
|
40
|
+
* Enable FIPS mode and verify it's working
|
|
41
|
+
*/
|
|
42
|
+
const enableFipsMode = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
43
|
+
try {
|
|
44
|
+
node_crypto_1.default.setFips(true);
|
|
45
|
+
const fipsEnabled = node_crypto_1.default.getFips();
|
|
46
|
+
if (!fipsEnabled) {
|
|
47
|
+
(0, stdio_1.print2)(`Failed to enable FIPS mode`);
|
|
48
|
+
process.exit(1);
|
|
49
|
+
}
|
|
50
|
+
// Run diagnostics if --debug flag is present
|
|
51
|
+
if (process.argv.includes("--debug")) {
|
|
52
|
+
yield (0, fips_diagnose_1.runFipsDiagnostics)();
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
catch (error) {
|
|
56
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
57
|
+
(0, stdio_1.print2)(`Failed to enable FIPS mode: ${errorMessage}`);
|
|
58
|
+
process.exit(1);
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
// Set up FIPS configuration when running as a Single Executable Application
|
|
62
|
+
if ((0, node_sea_1.isSea)() && (0, util_1.getOperatingSystem)() === "mac")
|
|
63
|
+
void enableFipsMode();
|
|
33
64
|
// The tracer version number is the version of the manual P0 CLI instrumentation.
|
|
34
65
|
// It is not the version of the P0 CLI itself or the version of the OpenTelemetry library.
|
|
35
66
|
// Change this when the manual instrumentation adds / removes spans, attributes, etc.
|
package/build/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;;;;;;;;;;;;;;AAEH,8DAA8D;AAC9D,sEAAsE;AACtE,qEAA+D;AAC/D,IAAA,8BAAY,GAAE,CAAC;AAEf,yCAAoC;AACpC,6CAA8C;AAC9C,2CAAyC;AACzC,4CAA2C;AAC3C,uCAAiC;AACjC,mCAA8B;AAC9B,8DAAiC;AACjC,mDAAqD;AACrD,iCAA4C;AAE5C;;GAEG;AACH,MAAM,cAAc,GAAG,GAAS,EAAE;IAChC,IAAI;QACF,qBAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QACrB,MAAM,WAAW,GAAG,qBAAM,CAAC,OAAO,EAAE,CAAC;QACrC,IAAI,CAAC,WAAW,EAAE;YAChB,IAAA,cAAM,EAAC,4BAA4B,CAAC,CAAC;YACrC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;SACjB;QAED,6CAA6C;QAC7C,IAAI,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE;YACp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,CAAC,qBAAqB,CAAC,EAAE;YAC5C,MAAM,KAAK,CAAC;SACb;KACF;IAED,MAAM,GAAG,GAAG,MAAM,IAAA,iBAAM,GAAE,CAAC;IAC3B,gEAAgE;IAChE,KAAM,GAAG,CAAC,KAAK,EAAU,CAAC,KAAK,CAAC,aAAI,CAAC,CAAC;AACxC,CAAC,CAAA,CAAC;AAEF,qGAAqG;AACrG,0DAA0D;AAC1D,OAAO,CAAC,EAAE,CAAC,mBAAmB,EAAE,CAAC,KAAK,EAAE,EAAE;IACxC,IAAA,cAAM,EAAC,sBAAsB,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC;IAC/C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC;AAEH,OAAO,CAAC,EAAE,CAAC,oBAAoB,EAAE,CAAC,MAAM,EAAE,EAAE;IAC1C,IAAA,cAAM,EAAC,uBAAuB,GAAG,CAAC,MAAM,YAAY,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IAC9F,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC;AAEH,IAAI,OAAO,CAAC,IAAI,KAAK,MAAM,IAAI,IAAA,gBAAK,GAAE,EAAE;IACtC,KAAK,IAAA,YAAI,GAAE,CAAC;CACb"}
|
|
@@ -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;AACnE,QAAA,4BAA4B,GACvC,oEAAoE,CAAC;AAC1D,QAAA,kCAAkC,GAAG,iHAAiH,IAAA,0BAAiB,GAAE,EAAE,CAAC;AAElL,MAAM,aAAa,GAAG,CAAC,IAAc,EAAE,EAAE;IAC9C,MAAM,SAAS,GAAG,IAAA,yBAAkB,GAAE,KAAK,KAAK,CAAC;IAEjD,iEAAiE;IACjE,0EAA0E;IAC1E,iEAAiE;IACjE,yEAAyE;IACzE,gCAAgC;IAChC,OAAO,SAAS;QACd,CAAC,CAAC,EAAE,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC,EAAE;QACjE,CAAC,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;AAC9B,CAAC,CAAC;AAXW,QAAA,aAAa,iBAWxB;AAEK,MAAM,cAAc,GAAG,CAAC,QAAgB,EAAE,EAAE,CACjD,IAAA,qBAAa,EAAC;IACZ,OAAO;IACP,SAAS;IACT,+CAA+C;IAC/C,UAAU;IACV,QAAQ;CACT,CAAC,CAAC;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,sCAA8B,GAAE,CAAC;QAC3D,MAAM,iBAAiB,GAAG,MAAM,IAAA,WAAI,EAAC,OAAO,EAAE,IAAI,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;QACrE,IAAI,KAAK,EAAE;YACT,IAAA,cAAM,EAAC,8BAA8B,CAAC,CAAC;YACvC,IAAA,cAAM,EAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC;YACjC,IAAA,cAAM,EAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC;SAClC;QACD,OAAO,iBAAiB,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;KACxC;IAAC,OAAO,KAAU,EAAE;QACnB,MAAM,wCAAwC,KAAK,GAAG,CAAC;KACxD;AACH,CAAC,CAAA,CAAC;AAEF;;;GAGG;AACI,MAAM,iBAAiB,GAAG,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,EAAC;QACnB,SAAS;QACT,SAAS;QACT,KAAK;QACL,QAAQ;QACR,WAAW;QACX,kBAAkB;QAClB,SAAS;QACT,sBAAsB;QACtB,UAAU;QACV,aAAa;QACb,KAAK;QACL,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QACrC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;KAC9B,CAAC,CAAC;AACL,CAAC,CAAC;AAEW,QAAA,gBAAgB,GAAG;IAC9B,KAAK,EAAE,CACL,OAA2C,EAC3C,OAA4B,EAC5B,EAAE;QACF,MAAM,gBAAgB,GAAG,MAAM,IAAA,wBAAiB,EAC9C,OAAO,CAAC,UAAU,CAAC,QAAQ,EAC3B,OAAO,CACR,CAAC;QACF,OAAO,EAAE,gBAAgB,EAAE,CAAC;IAC9B,CAAC,CAAA;IAED,eAAe,EAAE,CACf,OAA2C,EAC3C,OAGC,EACD,EAAE;QACF,MAAM,EAAE,KAAK,EAAE,GAAG,OAAO,CAAC;QAE1B,IAAI,KAAK,EAAE;YACT,IAAA,cAAM,EAAC,0CAA0C,CAAC,CAAC;SACpD;QAED,IAAI;YACF,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,mBAAmB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;YAEhE,IAAI,KAAK,EAAE;gBACT,IAAA,cAAM,EAAC,cAAc,OAAO,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;aACnD;YAED,MAAM,IAAA,WAAI,EAAC,OAAO,EAAE,IAAI,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;SAC5C;QAAC,OAAO,KAAU,EAAE;YACnB,IAAI,KAAK,EAAE;gBACT,IAAA,cAAM,EAAC,qCAAqC,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;gBAC7D,IAAI,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"}
|
|
@@ -24,7 +24,6 @@ const retry_1 = require("../../common/retry");
|
|
|
24
24
|
const stdio_1 = require("../../drivers/stdio");
|
|
25
25
|
const util_1 = require("../../util");
|
|
26
26
|
const auth_1 = require("./auth");
|
|
27
|
-
const node_child_process_1 = require("node:child_process");
|
|
28
27
|
const TUNNEL_READY_STRING = "Tunnel is ready";
|
|
29
28
|
// Ignore these debug messages from the tunnel process; they are far too noisy and spam the terminal with useless info
|
|
30
29
|
// anytime the SSH/SCP session has network activity.
|
|
@@ -73,7 +72,9 @@ const spawnBastionTunnelInBackground = (request, port, options) => {
|
|
|
73
72
|
(0, stdio_1.print2)("Spawning Azure Bastion tunnel process...");
|
|
74
73
|
// Spawn the process in detached mode so that it is in its own process group; this lets us kill it and all
|
|
75
74
|
// descendent processes together.
|
|
76
|
-
const child = (0,
|
|
75
|
+
const child = (0, util_1.spawnWithCleanEnv)(command, args, {
|
|
76
|
+
detached: true,
|
|
77
|
+
});
|
|
77
78
|
child.on("exit", (code) => {
|
|
78
79
|
processExited = true;
|
|
79
80
|
if (code === 0) {
|