@p0security/cli 0.11.1 → 0.11.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commands/__tests__/login.test.js +17 -0
- package/dist/commands/__tests__/login.test.js.map +1 -1
- package/dist/commands/__tests__/ls.test.js +4 -3
- package/dist/commands/__tests__/ls.test.js.map +1 -1
- package/dist/commands/__tests__/ssh.test.js +10 -5
- package/dist/commands/__tests__/ssh.test.js.map +1 -1
- package/dist/commands/kubeconfig.js +11 -15
- package/dist/commands/kubeconfig.js.map +1 -1
- package/dist/commands/login.js +11 -0
- package/dist/commands/login.js.map +1 -1
- package/dist/commands/ls.js +4 -6
- package/dist/commands/ls.js.map +1 -1
- package/dist/commands/shared/request.js +2 -2
- package/dist/commands/shared/request.js.map +1 -1
- package/dist/drivers/__mocks__/stdio.d.ts +14 -0
- package/dist/drivers/__mocks__/stdio.js +26 -0
- package/dist/drivers/__mocks__/stdio.js.map +1 -0
- package/dist/drivers/ansi.d.ts +8 -0
- package/dist/drivers/ansi.js +25 -0
- package/dist/drivers/ansi.js.map +1 -0
- package/dist/drivers/auth.d.ts +1 -0
- package/dist/drivers/auth.js +8 -4
- package/dist/drivers/auth.js.map +1 -1
- package/dist/drivers/stdio.d.ts +6 -5
- package/dist/drivers/stdio.js +50 -7
- package/dist/drivers/stdio.js.map +1 -1
- package/dist/plugins/aws/__tests__/utils.test.d.ts +1 -0
- package/dist/plugins/aws/__tests__/utils.test.js +82 -0
- package/dist/plugins/aws/__tests__/utils.test.js.map +1 -0
- package/dist/plugins/aws/ssh.js +45 -23
- package/dist/plugins/aws/ssh.js.map +1 -1
- package/dist/plugins/aws/types.d.ts +6 -4
- package/dist/plugins/aws/utils.d.ts +20 -0
- package/dist/plugins/aws/utils.js +54 -0
- package/dist/plugins/aws/utils.js.map +1 -0
- package/dist/plugins/google/ssh-key.js +9 -1
- package/dist/plugins/google/ssh-key.js.map +1 -1
- package/dist/plugins/google/ssh.js +61 -28
- package/dist/plugins/google/ssh.js.map +1 -1
- package/dist/plugins/kubeconfig/index.d.ts +2 -2
- package/dist/plugins/kubeconfig/index.js +17 -14
- package/dist/plugins/kubeconfig/index.js.map +1 -1
- package/dist/plugins/kubeconfig/types.d.ts +9 -8
- package/dist/plugins/ssh/index.js +55 -86
- package/dist/plugins/ssh/index.js.map +1 -1
- package/dist/types/ssh.d.ts +28 -13
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/plugins/kubeconfig/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAWA,kDAA4D;AAC5D,2DAAwD;AACxD,uDAA8C;AAC9C,+
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/plugins/kubeconfig/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAWA,kDAA4D;AAC5D,2DAAwD;AACxD,uDAA8C;AAC9C,+CAAgD;AAGhD,qCAAyC;AACzC,0CAA6C;AAC7C,oCAA+C;AAE/C,wCAAwC;AACxC,qCAAqD;AAErD,kDAA4C;AAC5C,mCAA8B;AAGvB,MAAM,4BAA4B,GAAG,CAC1C,KAAY,EACZ,SAAiB,EAQhB,EAAE;;IACH,MAAM,SAAS,GAAG,MAAM,IAAA,kBAAM,EAC5B,IAAA,eAAG,EAAC,KAAK,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,mBAAmB,CAAC,CACzD,CAAC;IAEF,kHAAkH;IAClH,MAAM,MAAM,GAAG,MAAA,MAAA,SAAS,CAAC,IAAI,EAAE,0CAAG,WAAW,CAAC,0CAAG,SAAS,CAAC,CAAC;IAC5D,IAAI,CAAC,MAAM,EAAE;QACX,MAAM,mBAAmB,SAAS,YAAY,CAAC;KAChD;IAED,IAAI,MAAM,CAAC,KAAK,KAAK,WAAW,EAAE;QAChC,MAAM,mBAAmB,SAAS,mBAAmB,CAAC;KACvD;IAED,MAAM,EAAE,OAAO,EAAE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C;aACvG;YAED,OAAO,MAAM,IAAA,uBAAiB,EAAC;gBAC7B,SAAS,EAAE,YAAY;gBACvB,aAAa,EAAE,IAAI;gBACnB,GAAG,EAAE,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE;aACtC,CAAC,CAAC;SACJ;QACD,KAAK,WAAW;YACd,OAAO,MAAM,IAAA,4BAAsB,EAAC,KAAK,EAAE;gBACzC,SAAS,EAAE,YAAY;gBACvB,IAAI,EAAE,IAAI;aACX,CAAC,CAAC;QACL;YACE,MAAM,IAAA,kBAAW,EAAC,SAAS,CAAC,CAAC;KAChC;AACH,CAAC,CAAA,CAAC;AAhCW,QAAA,YAAY,gBAgCvB"}
|
|
@@ -16,12 +16,13 @@ export type K8sClusterConfig = {
|
|
|
16
16
|
isProxy: boolean;
|
|
17
17
|
token: string;
|
|
18
18
|
publicJwk?: string;
|
|
19
|
-
|
|
19
|
+
hosting: {
|
|
20
20
|
type: "aws";
|
|
21
|
-
|
|
22
|
-
accountId: string;
|
|
21
|
+
arn: string;
|
|
23
22
|
} | {
|
|
24
|
-
type: "
|
|
23
|
+
type: "azure";
|
|
24
|
+
} | {
|
|
25
|
+
type: "gcp";
|
|
25
26
|
};
|
|
26
27
|
state: string;
|
|
27
28
|
};
|
|
@@ -38,14 +39,14 @@ export type K8sResourcePermission = {
|
|
|
38
39
|
role: string;
|
|
39
40
|
clusterId: string;
|
|
40
41
|
type: "resource";
|
|
42
|
+
awsResourcePermission?: {
|
|
43
|
+
idcRegion?: string;
|
|
44
|
+
idcId?: string;
|
|
45
|
+
};
|
|
41
46
|
};
|
|
42
47
|
export type K8sGenerated = {
|
|
43
48
|
eksGenerated: {
|
|
44
49
|
name: string;
|
|
45
|
-
idc?: {
|
|
46
|
-
id: string;
|
|
47
|
-
region: string;
|
|
48
|
-
};
|
|
49
50
|
};
|
|
50
51
|
role: string;
|
|
51
52
|
};
|
|
@@ -25,65 +25,11 @@ const keys_1 = require("../../common/keys");
|
|
|
25
25
|
const stdio_1 = require("../../drivers/stdio");
|
|
26
26
|
const util_1 = require("../../util");
|
|
27
27
|
const node_child_process_1 = require("node:child_process");
|
|
28
|
-
/** Matches the error message that AWS SSM print1 when access is not propagated */
|
|
29
|
-
// Note that the resource will randomly be either the SSM document or the EC2 instance
|
|
30
|
-
const UNAUTHORIZED_START_SESSION_MESSAGE = /An error occurred \(AccessDeniedException\) when calling the StartSession operation: User: arn:aws:sts::.*:assumed-role\/P0GrantsRole.* is not authorized to perform: ssm:StartSession on resource: arn:aws:.*:.*:.* because no identity-based policy allows the ssm:StartSession action/;
|
|
31
|
-
/**
|
|
32
|
-
* Matches the following error messages that AWS SSM print1 when ssh authorized
|
|
33
|
-
* key access hasn't propagated to the instance yet.
|
|
34
|
-
* - Connection closed by UNKNOWN port 65535
|
|
35
|
-
* - scp: Connection closed
|
|
36
|
-
* - kex_exchange_identification: Connection closed by remote host
|
|
37
|
-
*/
|
|
38
|
-
const CONNECTION_CLOSED_MESSAGE = /\bConnection closed\b.*\b(?:by UNKNOWN port \d+|by remote host)?/;
|
|
39
|
-
const PUBLIC_KEY_DENIED_MESSAGE = /Permission denied \(publickey\)/;
|
|
40
|
-
const UNAUTHORIZED_TUNNEL_USER_MESSAGE = /Error while connecting \[4033: 'not authorized'\]/;
|
|
41
|
-
const UNAUTHORIZED_INSTANCES_GET_MESSAGE = /Required 'compute\.instances\.get' permission/;
|
|
42
|
-
const DESTINATION_READ_ERROR = /Error while connecting \[4010: 'destination read failed'\]/;
|
|
43
|
-
const GOOGLE_LOGIN_MESSAGE = /You do not currently have an active account selected/;
|
|
44
|
-
const SUDO_MESSAGE = /Sorry, user .+ may not run sudo on .+/; // The output of `sudo -v` when the user is not allowed to run sudo
|
|
45
28
|
/** Maximum amount of time after SSH subprocess starts to check for {@link UNPROVISIONED_ACCESS_MESSAGES}
|
|
46
29
|
* in the process's stderr
|
|
47
30
|
*/
|
|
48
31
|
const DEFAULT_VALIDATION_WINDOW_MS = 5e3;
|
|
49
|
-
const RETRY_DELAY_MS =
|
|
50
|
-
/**
|
|
51
|
-
* AWS
|
|
52
|
-
* There are 2 cases of unprovisioned access in AWS
|
|
53
|
-
* 1. SSM:StartSession action is missing either on the SSM document (AWS-StartSSHSession) or the EC2 instance
|
|
54
|
-
* 2. Temporary error when issuing an SCP command
|
|
55
|
-
*
|
|
56
|
-
* 1: results in UNAUTHORIZED_START_SESSION_MESSAGE
|
|
57
|
-
* 2: results in CONNECTION_CLOSED_MESSAGE
|
|
58
|
-
*
|
|
59
|
-
* Google Cloud
|
|
60
|
-
* There are 7 cases of unprovisioned access in Google Cloud.
|
|
61
|
-
* These are all potentially subject to propagation delays.
|
|
62
|
-
* 1. The linux user name is not present in the user's Google Workspace profile `posixAccounts` attribute
|
|
63
|
-
* 2. The public key is not present in the user's Google Workspace profile `sshPublicKeys` attribute
|
|
64
|
-
* 3. The user cannot act as the service account of the compute instance
|
|
65
|
-
* 4. The user cannot tunnel through the IAP tunnel to the instance
|
|
66
|
-
* 5. The user doesn't have osLogin or osAdminLogin role to the instance
|
|
67
|
-
* 5.a. compute.instances.get permission is missing
|
|
68
|
-
* 5.b. compute.instances.osLogin permission is missing
|
|
69
|
-
* 6. compute.instances.osAdminLogin is not provisioned but compute.instances.osLogin is - happens when a user upgrades existing access to sudo
|
|
70
|
-
* 7: Rare occurrence, the exact conditions so far undetermined (together with CONNECTION_CLOSED_MESSAGE)
|
|
71
|
-
*
|
|
72
|
-
* 1, 2, 3 (yes!), 5b: result in PUBLIC_KEY_DENIED_MESSAGE
|
|
73
|
-
* 4: results in UNAUTHORIZED_TUNNEL_USER_MESSAGE and also CONNECTION_CLOSED_MESSAGE
|
|
74
|
-
* 5a: results in UNAUTHORIZED_INSTANCES_GET_MESSAGE
|
|
75
|
-
* 6: results in SUDO_MESSAGE
|
|
76
|
-
* 7: results in DESTINATION_READ_ERROR and also CONNECTION_CLOSED_MESSAGE
|
|
77
|
-
*/
|
|
78
|
-
const UNPROVISIONED_ACCESS_MESSAGES = [
|
|
79
|
-
{ pattern: UNAUTHORIZED_START_SESSION_MESSAGE },
|
|
80
|
-
{ pattern: CONNECTION_CLOSED_MESSAGE },
|
|
81
|
-
{ pattern: PUBLIC_KEY_DENIED_MESSAGE },
|
|
82
|
-
{ pattern: SUDO_MESSAGE },
|
|
83
|
-
{ pattern: UNAUTHORIZED_TUNNEL_USER_MESSAGE },
|
|
84
|
-
{ pattern: UNAUTHORIZED_INSTANCES_GET_MESSAGE, validationWindowMs: 30e3 },
|
|
85
|
-
{ pattern: DESTINATION_READ_ERROR },
|
|
86
|
-
];
|
|
32
|
+
const RETRY_DELAY_MS = 5000;
|
|
87
33
|
/** Checks if access has propagated through AWS to the SSM agent
|
|
88
34
|
*
|
|
89
35
|
* AWS takes about 8 minutes, GCP takes under 1 minute
|
|
@@ -100,75 +46,96 @@ const UNPROVISIONED_ACCESS_MESSAGES = [
|
|
|
100
46
|
* This works because AWS SSM wraps the session in a single-stream pty, so we
|
|
101
47
|
* do not capture stderr emitted from the wrapped shell session.
|
|
102
48
|
*/
|
|
103
|
-
const accessPropagationGuard = (child,
|
|
49
|
+
const accessPropagationGuard = (provider, child, options) => {
|
|
104
50
|
let isEphemeralAccessDeniedException = false;
|
|
105
|
-
let
|
|
106
|
-
const beforeStart = Date.now();
|
|
51
|
+
let isLoginException = false;
|
|
107
52
|
child.stderr.on("data", (chunk) => {
|
|
108
53
|
const chunkString = chunk.toString("utf-8");
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
if (match &&
|
|
113
|
-
Date.now() <=
|
|
114
|
-
beforeStart + (match.validationWindowMs || DEFAULT_VALIDATION_WINDOW_MS)) {
|
|
54
|
+
parseAndPrintSshOutputToStderr(chunkString, options);
|
|
55
|
+
const match = provider.unprovisionedAccessPatterns.find((message) => chunkString.match(message.pattern));
|
|
56
|
+
if (match) {
|
|
115
57
|
isEphemeralAccessDeniedException = true;
|
|
116
58
|
}
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
59
|
+
if (provider.loginRequiredPattern) {
|
|
60
|
+
const loginMatch = chunkString.match(provider.loginRequiredPattern);
|
|
61
|
+
isLoginException = isLoginException || !!loginMatch; // once true, always true
|
|
62
|
+
}
|
|
63
|
+
if (isLoginException) {
|
|
120
64
|
isEphemeralAccessDeniedException = false; // always overwrite to false so we don't retry the access
|
|
121
65
|
}
|
|
122
66
|
});
|
|
123
67
|
return {
|
|
124
68
|
isAccessPropagated: () => !isEphemeralAccessDeniedException,
|
|
125
|
-
|
|
69
|
+
isLoginException: () => isLoginException,
|
|
126
70
|
};
|
|
127
71
|
};
|
|
72
|
+
/**
|
|
73
|
+
* Parses and prints a chunk of SSH output to stderr.
|
|
74
|
+
*
|
|
75
|
+
* If debug is enabled, all output is printed. Otherwise, only selected messages are printed.
|
|
76
|
+
*
|
|
77
|
+
* @param chunkString the chunk to print
|
|
78
|
+
* @param options SSH spawn options
|
|
79
|
+
*/
|
|
80
|
+
const parseAndPrintSshOutputToStderr = (chunkString, options) => {
|
|
81
|
+
const lines = chunkString.split("\n");
|
|
82
|
+
const isPreTest = options.isAccessPropagationPreTest;
|
|
83
|
+
for (const line of lines) {
|
|
84
|
+
if (options.debug) {
|
|
85
|
+
(0, stdio_1.print2)(line);
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
if (!isPreTest && line.includes("Authenticated to")) {
|
|
89
|
+
// We want to let the user know that they successfully authenticated
|
|
90
|
+
(0, stdio_1.print2)(line);
|
|
91
|
+
}
|
|
92
|
+
else if (!isPreTest && line.includes("port forwarding failed")) {
|
|
93
|
+
// We also want to let the user know if port forwarding failed
|
|
94
|
+
(0, stdio_1.print2)(line);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
};
|
|
128
99
|
const spawnChildProcess = (credential, command, args, stdio) => (0, node_child_process_1.spawn)(command, args, {
|
|
129
100
|
env: Object.assign(Object.assign({}, process.env), credential),
|
|
130
101
|
stdio,
|
|
131
102
|
shell: false,
|
|
132
103
|
});
|
|
133
|
-
/** Starts an SSM session in the terminal by spawning `aws ssm` as a subprocess
|
|
134
|
-
*
|
|
135
|
-
* Requires `aws ssm` to be installed on the client machine.
|
|
136
|
-
*/
|
|
137
104
|
function spawnSshNode(options) {
|
|
138
105
|
return __awaiter(this, void 0, void 0, function* () {
|
|
139
106
|
return new Promise((resolve, reject) => {
|
|
140
107
|
const provider = ssh_1.SSH_PROVIDERS[options.provider];
|
|
141
|
-
const attemptsRemaining = options.attemptsRemaining;
|
|
142
108
|
if (options.debug) {
|
|
143
109
|
const gerund = options.isAccessPropagationPreTest
|
|
144
110
|
? "Pre-testing"
|
|
145
111
|
: "Trying";
|
|
146
|
-
|
|
112
|
+
const remainingSeconds = ((options.endTime - Date.now()) / 1e3).toFixed(1);
|
|
113
|
+
(0, stdio_1.print2)(`Waiting for access to propagate. ${gerund} SSH session... (will wait up to ${remainingSeconds} seconds)`);
|
|
147
114
|
}
|
|
148
115
|
const child = spawnChildProcess(options.credential, options.command, options.args, options.stdio);
|
|
149
116
|
// TODO ENG-2284 support login with Google Cloud: currently return a boolean to indicate if the exception was a Google login error.
|
|
150
|
-
const { isAccessPropagated,
|
|
117
|
+
const { isAccessPropagated, isLoginException } = accessPropagationGuard(provider, child, options);
|
|
151
118
|
const exitListener = child.on("exit", (code) => {
|
|
152
|
-
var _a;
|
|
119
|
+
var _a, _b;
|
|
153
120
|
exitListener.unref();
|
|
154
121
|
// In the case of ephemeral AccessDenied exceptions due to unpropagated
|
|
155
122
|
// permissions, continually retry access until success
|
|
156
123
|
if (!isAccessPropagated()) {
|
|
157
|
-
if (
|
|
158
|
-
reject(`Access did not propagate through ${provider.friendlyName}
|
|
124
|
+
if (options.endTime < Date.now()) {
|
|
125
|
+
reject(`Access did not propagate through ${provider.friendlyName} in time. Please contact support@p0.dev for assistance.`);
|
|
159
126
|
return;
|
|
160
127
|
}
|
|
161
128
|
(0, util_1.delay)(RETRY_DELAY_MS)
|
|
162
|
-
.then(() => spawnSshNode(
|
|
129
|
+
.then(() => spawnSshNode(options))
|
|
163
130
|
.then((code) => resolve(code))
|
|
164
131
|
.catch(reject);
|
|
165
132
|
return;
|
|
166
133
|
}
|
|
167
|
-
else if (
|
|
168
|
-
reject(`Please
|
|
134
|
+
else if (isLoginException()) {
|
|
135
|
+
reject((_a = provider.loginRequiredMessage) !== null && _a !== void 0 ? _a : `Please log in to the ${provider.friendlyName} CLI to SSH`);
|
|
169
136
|
return;
|
|
170
137
|
}
|
|
171
|
-
(
|
|
138
|
+
(_b = options.abortController) === null || _b === void 0 ? void 0 : _b.abort(code);
|
|
172
139
|
if (!options.isAccessPropagationPreTest)
|
|
173
140
|
(0, stdio_1.print2)(`SSH session terminated`);
|
|
174
141
|
resolve(code);
|
|
@@ -227,6 +194,7 @@ const addCommonArgs = (args, proxyCommand) => {
|
|
|
227
194
|
if (!proxyCommandExists) {
|
|
228
195
|
sshOptions.push("-o", `ProxyCommand=${proxyCommand.join(" ")}`);
|
|
229
196
|
}
|
|
197
|
+
// Force verbose output from SSH so we can parse the output
|
|
230
198
|
const verboseOptionExists = sshOptions.some((opt) => opt === "-v");
|
|
231
199
|
if (!verboseOptionExists) {
|
|
232
200
|
sshOptions.push("-v");
|
|
@@ -261,7 +229,7 @@ const transformForShell = (args) => {
|
|
|
261
229
|
});
|
|
262
230
|
};
|
|
263
231
|
/** Construct another command to use for testing access propagation prior to actually logging in the user to the ssh session */
|
|
264
|
-
const preTestAccessPropagationIfNeeded = (sshProvider, request, cmdArgs, proxyCommand, credential) => __awaiter(void 0, void 0, void 0, function* () {
|
|
232
|
+
const preTestAccessPropagationIfNeeded = (sshProvider, request, cmdArgs, proxyCommand, credential, endTime) => __awaiter(void 0, void 0, void 0, function* () {
|
|
265
233
|
const testCmdArgs = sshProvider.preTestAccessPropagationArgs(cmdArgs);
|
|
266
234
|
// Pre-testing comes at a performance cost because we have to execute another ssh subprocess after
|
|
267
235
|
// a successful test. Only do when absolutely necessary.
|
|
@@ -276,7 +244,7 @@ const preTestAccessPropagationIfNeeded = (sshProvider, request, cmdArgs, proxyCo
|
|
|
276
244
|
stdio: ["inherit", "inherit", "pipe"],
|
|
277
245
|
debug: cmdArgs.debug,
|
|
278
246
|
provider: request.type,
|
|
279
|
-
|
|
247
|
+
endTime: endTime,
|
|
280
248
|
isAccessPropagationPreTest: true,
|
|
281
249
|
});
|
|
282
250
|
}
|
|
@@ -300,7 +268,8 @@ const sshOrScp = (args) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
300
268
|
(0, stdio_1.print2)(`Execute the following commands to create a similar SSH/SCP session:\n*** COMMANDS BEGIN ***\n${repro}\n*** COMMANDS END ***"\n`);
|
|
301
269
|
}
|
|
302
270
|
}
|
|
303
|
-
const
|
|
271
|
+
const endTime = Date.now() + sshProvider.propagationTimeoutMs;
|
|
272
|
+
const exitCode = yield preTestAccessPropagationIfNeeded(sshProvider, request, cmdArgs, proxyCommand, credential, endTime);
|
|
304
273
|
if (exitCode && exitCode !== 0) {
|
|
305
274
|
return exitCode; // Only exit if there was an error when pre-testing
|
|
306
275
|
}
|
|
@@ -312,7 +281,7 @@ const sshOrScp = (args) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
312
281
|
stdio: ["inherit", "inherit", "pipe"],
|
|
313
282
|
debug: cmdArgs.debug,
|
|
314
283
|
provider: request.type,
|
|
315
|
-
|
|
284
|
+
endTime: endTime,
|
|
316
285
|
});
|
|
317
286
|
});
|
|
318
287
|
exports.sshOrScp = sshOrScp;
|
|
@@ -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
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/plugins/ssh/index.ts"],"names":[],"mappings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UAAU;QACV,eAAe,EAAE,IAAI,eAAe,EAAE;QACtC,OAAO;QACP,IAAI,EAAE,WAAW;QACjB,KAAK,EAAE,CAAC,SAAS,EAAE,SAAS,EAAE,MAAM,CAAC;QACrC,KAAK,EAAE,OAAO,CAAC,KAAK;QACpB,QAAQ,EAAE,OAAO,CAAC,IAAI;QACtB,OAAO,EAAE,OAAO;KACjB,CAAC,CAAC;AACL,CAAC,CAAA,CAAC;AA7DW,QAAA,QAAQ,YA6DnB"}
|
package/dist/types/ssh.d.ts
CHANGED
|
@@ -21,19 +21,18 @@ export type CliPermissionSpec<P extends PluginSshRequest, C extends object | und
|
|
|
21
21
|
export declare const SupportedSshProviders: readonly ["aws", "gcloud"];
|
|
22
22
|
export type SupportedSshProvider = (typeof SupportedSshProviders)[number];
|
|
23
23
|
export type SshProvider<PR extends PluginSshRequest = PluginSshRequest, O extends object | undefined = undefined, SR extends SshRequest = SshRequest, C extends object | undefined = undefined> = {
|
|
24
|
-
requestToSsh: (request: CliPermissionSpec<PR, O>) => SR;
|
|
25
|
-
/** Converts a backend request to a CLI request */
|
|
26
|
-
toCliRequest: (request: Request<PR>, options?: {
|
|
27
|
-
debug?: boolean;
|
|
28
|
-
}) => Promise<Request<CliSshRequest>>;
|
|
29
|
-
ensureInstall: () => Promise<void>;
|
|
30
24
|
/** Logs in the user to the cloud provider */
|
|
31
25
|
cloudProviderLogin: (authn: Authn, request: SR) => Promise<C>;
|
|
32
|
-
/**
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
|
|
36
|
-
|
|
26
|
+
/** Callback to ensure that this provider's CLI utils are installed */
|
|
27
|
+
ensureInstall: () => Promise<void>;
|
|
28
|
+
/** A human-readable name for this CSP */
|
|
29
|
+
friendlyName: string;
|
|
30
|
+
/** Friendly message to ask the user to log in to the CSP */
|
|
31
|
+
loginRequiredMessage?: string;
|
|
32
|
+
/** Regex match for error string indicating that CSP login is required */
|
|
33
|
+
loginRequiredPattern?: RegExp;
|
|
34
|
+
/** Amount of time, in ms, to wait between granting access and giving up on attempting an SSH connection */
|
|
35
|
+
propagationTimeoutMs: number;
|
|
37
36
|
/** Arguments for a pre-test command to verify access propagation prior
|
|
38
37
|
* to actually logging in the user to the ssh session.
|
|
39
38
|
* This must return arguments for a non-interactive command - meaning the `command`
|
|
@@ -42,7 +41,23 @@ export type SshProvider<PR extends PluginSshRequest = PluginSshRequest, O extend
|
|
|
42
41
|
* the actual ssh/scp command.
|
|
43
42
|
*/
|
|
44
43
|
preTestAccessPropagationArgs: (cmdArgs: CommandArgs) => CommandArgs | undefined;
|
|
45
|
-
|
|
46
|
-
|
|
44
|
+
/** Returns the command and its arguments that are going to be injected as the ssh ProxyCommand option */
|
|
45
|
+
proxyCommand: (request: SR) => string[];
|
|
46
|
+
/** Each element in the returned array is a command that can be run to reproduce the
|
|
47
|
+
* steps of logging in the user to the ssh session. */
|
|
48
|
+
reproCommands: (request: SR) => string[] | undefined;
|
|
49
|
+
/** Unwraps this provider's types */
|
|
50
|
+
requestToSsh: (request: CliPermissionSpec<PR, O>) => SR;
|
|
51
|
+
/** Regex matches for error strings indicating that the provider has not yet fully provisioned node acces */
|
|
52
|
+
unprovisionedAccessPatterns: readonly {
|
|
53
|
+
/** If the error matches this string, indicates that access is not provisioned */
|
|
54
|
+
readonly pattern: RegExp;
|
|
55
|
+
/** Maximum amount of time to wait for provisioning after encountering this error */
|
|
56
|
+
readonly validationWindowMs?: number;
|
|
57
|
+
}[];
|
|
58
|
+
/** Converts a backend request to a CLI request */
|
|
59
|
+
toCliRequest: (request: Request<PR>, options?: {
|
|
60
|
+
debug?: boolean;
|
|
61
|
+
}) => Promise<Request<CliSshRequest>>;
|
|
47
62
|
};
|
|
48
63
|
export type SshRequest = AwsSshRequest | GcpSshRequest;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@p0security/cli",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.3",
|
|
4
4
|
"description": "Execute infra CLI commands with P0 grants",
|
|
5
5
|
"main": "index.ts",
|
|
6
6
|
"repository": {
|
|
@@ -65,8 +65,8 @@
|
|
|
65
65
|
"eslint-plugin-promise": "^6.1.1",
|
|
66
66
|
"jest": "^29.7.0",
|
|
67
67
|
"prettier": "^3.2.4",
|
|
68
|
-
"ts-
|
|
69
|
-
"ts-
|
|
68
|
+
"ts-jest": "^29.1.2",
|
|
69
|
+
"ts-node": "^10.9.2"
|
|
70
70
|
},
|
|
71
71
|
"scripts": {
|
|
72
72
|
"build": "tsc && cp -r public dist/",
|