@p0security/cli 0.19.0 → 0.19.1
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/plugins/google/ssh-key.js +9 -9
- package/build/dist/plugins/google/ssh-key.js.map +1 -1
- package/build/dist/plugins/google/ssh.js +4 -3
- package/build/dist/plugins/google/ssh.js.map +1 -1
- package/build/dist/plugins/google/util.d.ts +9 -0
- package/build/dist/plugins/google/util.js +32 -0
- package/build/dist/plugins/google/util.js.map +1 -0
- package/build/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -22,7 +22,7 @@ You should have received a copy of the GNU General Public License along with @p0
|
|
|
22
22
|
**/
|
|
23
23
|
const subprocess_1 = require("../../common/subprocess");
|
|
24
24
|
const stdio_1 = require("../../drivers/stdio");
|
|
25
|
-
const util_1 = require("
|
|
25
|
+
const util_1 = require("./util");
|
|
26
26
|
/**
|
|
27
27
|
* Adds an ssh public key to the user object's sshPublicKeys array in Google Workspace.
|
|
28
28
|
* GCP OS Login uses these public keys to authenticate the user.
|
|
@@ -37,15 +37,15 @@ const util_1 = require("../../util");
|
|
|
37
37
|
const importSshKey = (publicKey, options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
38
38
|
var _a;
|
|
39
39
|
const debug = (_a = options === null || options === void 0 ? void 0 : options.debug) !== null && _a !== void 0 ? _a : false;
|
|
40
|
-
const isWindows = (0, util_1.getOperatingSystem)() === "win";
|
|
41
|
-
const cmd = isWindows ? "cmd.exe" : "gcloud";
|
|
42
40
|
// Force debug=false otherwise it prints the access token
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
41
|
+
const { command: accessTokenCommand, args: accessTokenArgs } = (0, util_1.gcloudCommandArgs)(["auth", "print-access-token"]);
|
|
42
|
+
const accessToken = yield (0, subprocess_1.asyncSpawn)({ debug: false }, accessTokenCommand, accessTokenArgs);
|
|
43
|
+
const { command: accountCommand, args: accountArgs } = (0, util_1.gcloudCommandArgs)([
|
|
44
|
+
"config",
|
|
45
|
+
"get-value",
|
|
46
|
+
"account",
|
|
47
|
+
]);
|
|
48
|
+
const account = yield (0, subprocess_1.asyncSpawn)({ debug }, accountCommand, accountArgs);
|
|
49
49
|
if (debug) {
|
|
50
50
|
(0, stdio_1.print2)(`Retrieved access token ${accessToken.slice(0, 10)}... for account ${account}`);
|
|
51
51
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ssh-key.js","sourceRoot":"","sources":["../../../../src/plugins/google/ssh-key.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;GASG;AACH,wDAAqD;AACrD,+CAA6C;
|
|
1
|
+
{"version":3,"file":"ssh-key.js","sourceRoot":"","sources":["../../../../src/plugins/google/ssh-key.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;GASG;AACH,wDAAqD;AACrD,+CAA6C;AAE7C,iCAA2C;AAE3C;;;;;;;;;;GAUG;AACI,MAAM,YAAY,GAAG,CAC1B,SAAiB,EACjB,OAA6B,EAC7B,EAAE;;IACF,MAAM,KAAK,GAAG,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,KAAK,mCAAI,KAAK,CAAC;IAEtC,yDAAyD;IACzD,MAAM,EAAE,OAAO,EAAE,kBAAkB,EAAE,IAAI,EAAE,eAAe,EAAE,GAC1D,IAAA,wBAAiB,EAAC,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAAC,CAAC;IACpD,MAAM,WAAW,GAAG,MAAM,IAAA,uBAAU,EAClC,EAAE,KAAK,EAAE,KAAK,EAAE,EAChB,kBAAkB,EAClB,eAAe,CAChB,CAAC;IAEF,MAAM,EAAE,OAAO,EAAE,cAAc,EAAE,IAAI,EAAE,WAAW,EAAE,GAAG,IAAA,wBAAiB,EAAC;QACvE,QAAQ;QACR,WAAW;QACX,SAAS;KACV,CAAC,CAAC;IACH,MAAM,OAA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AY,GAChB,aAAa,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC;QAChD,YAAY,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;IAEhC,IAAI,KAAK,EAAE;QACT,IAAA,cAAM,EAAC,2BAA2B,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,QAAQ,EAAE,CAAC,CAAC;KAC7D;IAED,IAAI,CAAC,YAAY,EAAE;QACjB,MAAM,2HAA2H,CAAC;KACnI;IAED,OAAO,YAAY,CAAC,QAAQ,CAAC;AAC/B,CAAC,CAAA,CAAC;AA/EW,QAAA,YAAY,gBA+EvB"}
|
|
@@ -24,6 +24,7 @@ const ssh_1 = require("../../commands/shared/ssh");
|
|
|
24
24
|
const keys_1 = require("../../common/keys");
|
|
25
25
|
const install_1 = require("./install");
|
|
26
26
|
const ssh_key_1 = require("./ssh-key");
|
|
27
|
+
const util_1 = require("./util");
|
|
27
28
|
// It typically takes < 1 minute for access to propagate on GCP, so set the time limit to 2 minutes.
|
|
28
29
|
const PROPAGATION_TIMEOUT_LIMIT_MS = 2 * 60 * 1000;
|
|
29
30
|
/**
|
|
@@ -86,8 +87,7 @@ exports.gcpSshProvider = {
|
|
|
86
87
|
};
|
|
87
88
|
}),
|
|
88
89
|
proxyCommand: (request, port) => {
|
|
89
|
-
|
|
90
|
-
"gcloud",
|
|
90
|
+
const { command, args } = (0, util_1.gcloudCommandArgs)([
|
|
91
91
|
"compute",
|
|
92
92
|
"start-iap-tunnel",
|
|
93
93
|
request.id,
|
|
@@ -99,7 +99,8 @@ exports.gcpSshProvider = {
|
|
|
99
99
|
"--listen-on-stdin",
|
|
100
100
|
`--zone=${request.zone}`,
|
|
101
101
|
`--project=${request.projectId}`,
|
|
102
|
-
];
|
|
102
|
+
]);
|
|
103
|
+
return [command, ...args];
|
|
103
104
|
},
|
|
104
105
|
reproCommands: () => undefined,
|
|
105
106
|
requestToSsh: (request) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ssh.js","sourceRoot":"","sources":["../../../../src/plugins/google/ssh.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;GASG;AACH,mDAA0D;AAC1D,4CAAqD;AAErD,uCAAgD;AAChD,uCAAyC;
|
|
1
|
+
{"version":3,"file":"ssh.js","sourceRoot":"","sources":["../../../../src/plugins/google/ssh.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;GASG;AACH,mDAA0D;AAC1D,4CAAqD;AAErD,uCAAgD;AAChD,uCAAyC;AAEzC,iCAA2C;AAE3C,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,cAAc,GAIvB;IACF,uCAAuC;IACvC,kBAAkB,EAAE,GAAS,EAAE,kDAAC,OAAA,SAAS,CAAA,GAAA;IAEzC,aAAa,EAAE,GAAS,EAAE;QACxB,IAAI,CAAC,CAAC,MAAM,IAAA,6BAAmB,GAAE,CAAC,EAAE;YAClC,MAAM,8DAA8D,CAAC;SACtE;IACH,CAAC,CAAA;IAED,YAAY,EAAE,cAAc;IAE5B,oBAAoB,EAClB,2DAA2D;IAE7D,oBAAoB,EAAE,sDAAsD;IAE5E,oBAAoB,EAAE,4BAA4B;IAElD,4BAA4B,EAAE,CAAC,OAAO,EAAE,EAAE;QACxC,IAAI,IAAA,mBAAa,EAAC,OAAO,CAAC,EAAE;YAC1B,uCACK,OAAO;gB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BACZ,aAAa,EAAE,MAAM,IAAA,sBAAY,EAAC,OAAO,CAAC,UAAU,CAAC,SAAS,EAAE,OAAO,CAAC;aACzE,IACD,CAAA;MAAA;CACH,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Prepends with the operating-system specific method of
|
|
3
|
+
* running a gcloud command.
|
|
4
|
+
* @param args the arguments to be passed to gcloud (excluding "gcloud" itself)
|
|
5
|
+
*/
|
|
6
|
+
export declare const gcloudCommandArgs: (args: string[]) => {
|
|
7
|
+
command: string;
|
|
8
|
+
args: string[];
|
|
9
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.gcloudCommandArgs = void 0;
|
|
4
|
+
/** Copyright © 2024-present P0 Security
|
|
5
|
+
|
|
6
|
+
This file is part of @p0security/cli
|
|
7
|
+
|
|
8
|
+
@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.
|
|
9
|
+
|
|
10
|
+
@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.
|
|
11
|
+
|
|
12
|
+
You should have received a copy of the GNU General Public License along with @p0security/cli. If not, see <https://www.gnu.org/licenses/>.
|
|
13
|
+
**/
|
|
14
|
+
const util_1 = require("../../util");
|
|
15
|
+
/**
|
|
16
|
+
* Prepends with the operating-system specific method of
|
|
17
|
+
* running a gcloud command.
|
|
18
|
+
* @param args the arguments to be passed to gcloud (excluding "gcloud" itself)
|
|
19
|
+
*/
|
|
20
|
+
const gcloudCommandArgs = (args) => {
|
|
21
|
+
const isWindows = (0, util_1.getOperatingSystem)() === "win";
|
|
22
|
+
// On Windows, when installing the Google Cloud tools, the main gcloud file is
|
|
23
|
+
// a .cmd (shell script) file rather than a .exe (binary executable) file,
|
|
24
|
+
// so when calling spawn, it cannot be located except via cmd.exe
|
|
25
|
+
// Unlike in MacOS, the underlying Windows OS API that spawn uses doesn't
|
|
26
|
+
// resolve .CMD files by default
|
|
27
|
+
return isWindows
|
|
28
|
+
? { command: "cmd.exe", args: ["/d", "/s", "/c", "gcloud", ...args] }
|
|
29
|
+
: { command: "gcloud", args };
|
|
30
|
+
};
|
|
31
|
+
exports.gcloudCommandArgs = gcloudCommandArgs;
|
|
32
|
+
//# sourceMappingURL=util.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"util.js","sourceRoot":"","sources":["../../../../src/plugins/google/util.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;GASG;AACH,qCAAgD;AAEhD;;;;GAIG;AACI,MAAM,iBAAiB,GAAG,CAAC,IAAc,EAAE,EAAE;IAClD,MAAM,SAAS,GAAG,IAAA,yBAAkB,GAAE,KAAK,KAAK,CAAC;IAEjD,8EAA8E;IAC9E,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,QAAQ,EAAE,GAAG,IAAI,CAAC,EAAE;QACrE,CAAC,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;AAClC,CAAC,CAAC;AAXW,QAAA,iBAAiB,qBAW5B"}
|