@p0security/cli 0.27.2 → 0.27.4
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/claude/mcp.js +24 -13
- package/build/dist/commands/claude/mcp.js.map +1 -1
- package/build/dist/commands/file-transfer.js +57 -8
- package/build/dist/commands/file-transfer.js.map +1 -1
- package/build/dist/plugins/file-transfer/index.d.ts +9 -9
- package/build/dist/plugins/file-transfer/index.js +30 -31
- package/build/dist/plugins/file-transfer/index.js.map +1 -1
- package/build/dist/plugins/file-transfer/types.d.ts +3 -5
- package/build/dist/plugins/google/connection-error.d.ts +39 -0
- package/build/dist/plugins/google/connection-error.js +43 -0
- package/build/dist/plugins/google/connection-error.js.map +1 -0
- package/build/dist/plugins/google/install.d.ts +15 -0
- package/build/dist/plugins/google/install.js +4 -4
- package/build/dist/plugins/google/install.js.map +1 -1
- package/build/dist/plugins/google/ssh.js +2 -0
- package/build/dist/plugins/google/ssh.js.map +1 -1
- package/build/dist/plugins/ssh/index.js +20 -2
- package/build/dist/plugins/ssh/index.js.map +1 -1
- package/build/dist/testing/authn.d.ts +13 -0
- package/build/dist/testing/authn.js +37 -0
- package/build/dist/testing/authn.js.map +1 -0
- package/build/dist/types/ssh.d.ts +6 -0
- package/build/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -161,26 +161,37 @@ const provisionServer = (argv, { client }, { server }) => __awaiter(void 0, void
|
|
|
161
161
|
const claudeFile = yield getClaudeFile();
|
|
162
162
|
(0, node_assert_1.default)(client.secret, "No client secret");
|
|
163
163
|
(0, stdio_1.debug)(argv, "Server", server);
|
|
164
|
+
// Claude Code's `mcp add-json` doesn't accept oauth fields in its JSON
|
|
165
|
+
// schema (verified against claude 2.1.141). Use `claude mcp add` with
|
|
166
|
+
// explicit OAuth flags instead — the resulting `~/.claude.json` shape
|
|
167
|
+
// is the same `{ type: "http", url, oauth: { clientId, callbackPort } }`
|
|
168
|
+
// that the add-json form would have produced, but assembled by claude
|
|
169
|
+
// from the flags rather than parsed from the JSON.
|
|
170
|
+
//
|
|
171
|
+
// The client secret is delivered via the MCP_CLIENT_SECRET env var (+
|
|
172
|
+
// the `--client-secret` flag), so it never lands on disk.
|
|
173
|
+
const callbackPort = Number(client.redirectUri.split(":").at(-1));
|
|
164
174
|
const args = [
|
|
165
175
|
"mcp",
|
|
166
|
-
"add
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
clientSecret: client.secret,
|
|
174
|
-
callbackPort: Number(client.redirectUri.split(":").at(-1)),
|
|
175
|
-
},
|
|
176
|
-
})}'`,
|
|
177
|
-
...(argv.scope ? ["--scope", argv.scope] : []),
|
|
176
|
+
"add",
|
|
177
|
+
"--transport",
|
|
178
|
+
"http",
|
|
179
|
+
"--client-id",
|
|
180
|
+
client.id,
|
|
181
|
+
"--callback-port",
|
|
182
|
+
String(callbackPort),
|
|
178
183
|
"--client-secret",
|
|
184
|
+
...(argv.scope ? ["--scope", argv.scope] : []),
|
|
185
|
+
server.id,
|
|
186
|
+
server.url,
|
|
179
187
|
];
|
|
180
188
|
(0, stdio_1.debug)(argv, "Client secret", client.secret);
|
|
181
189
|
(0, stdio_1.debug)(argv, ["claude", ...args].join(" "));
|
|
190
|
+
// Spread process.env so the spawned `claude` inherits PATH / HOME /
|
|
191
|
+
// NODE_OPTIONS / etc. (`env: { MCP_CLIENT_SECRET }` alone would replace
|
|
192
|
+
// the whole environment).
|
|
182
193
|
yield (0, node_util_1.promisify)(node_child_process_1.spawn)(claudeFile, args, {
|
|
183
|
-
env: { MCP_CLIENT_SECRET: client.secret },
|
|
194
|
+
env: Object.assign(Object.assign({}, process.env), { MCP_CLIENT_SECRET: client.secret }),
|
|
184
195
|
stdio: "inherit",
|
|
185
196
|
});
|
|
186
197
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcp.js","sourceRoot":"","sources":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AC,MAAM,GAAE;QACzD,KAAK,EAAE,SAAS;KACjB,CAAC,CAAC;AACL,CAAC,CAAA,CAAC"}
|
|
@@ -8,6 +8,17 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
12
|
+
var t = {};
|
|
13
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
14
|
+
t[p] = s[p];
|
|
15
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
16
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
17
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
18
|
+
t[p[i]] = s[p[i]];
|
|
19
|
+
}
|
|
20
|
+
return t;
|
|
21
|
+
};
|
|
11
22
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
23
|
exports.fileTransferCommand = void 0;
|
|
13
24
|
/** Copyright © 2024-present P0 Security
|
|
@@ -25,6 +36,8 @@ const auth_1 = require("../drivers/auth");
|
|
|
25
36
|
const stdio_1 = require("../drivers/stdio");
|
|
26
37
|
const otel_helpers_1 = require("../opentelemetry/otel-helpers");
|
|
27
38
|
const file_transfer_1 = require("../plugins/file-transfer");
|
|
39
|
+
const ssh_1 = require("../plugins/ssh");
|
|
40
|
+
const ssh_2 = require("./shared/ssh");
|
|
28
41
|
const lib_storage_1 = require("@aws-sdk/lib-storage");
|
|
29
42
|
const fs_1 = require("fs");
|
|
30
43
|
const node_path_1 = require("node:path");
|
|
@@ -70,11 +83,15 @@ const fileTransferAction = (args) => __awaiter(void 0, void 0, void 0, function*
|
|
|
70
83
|
(0, stdio_1.print2)("Requesting file-transfer access...");
|
|
71
84
|
const target = yield (0, file_transfer_1.provisionTransferRequest)(authn, args);
|
|
72
85
|
(0, stdio_1.print2)(`Access approved for s3://${target.bucket}/${target.prefix}`);
|
|
73
|
-
//
|
|
74
|
-
// local file's basename so the S3 object preserves the original filename.
|
|
86
|
+
// append original basename so the S3 object preserves the original filename.
|
|
75
87
|
const uploadKey = `${target.prefix}${(0, node_path_1.basename)(args.source)}`;
|
|
76
88
|
(0, stdio_1.print2)("Preparing upload credentials...");
|
|
77
89
|
const s3 = (0, file_transfer_1.createTransferClient)(authn, target, args.debug);
|
|
90
|
+
const { signedUrl: deleteUrl, expirySeconds: deleteExpirySeconds } = yield (0, file_transfer_1.generateSignedUrl)(authn, s3, Object.assign(Object.assign({}, target), { key: uploadKey }), "delete", args.debug);
|
|
91
|
+
// TODO: remove logging actual credential but log expiry when we remove the launchdarkly file-transfer flag
|
|
92
|
+
if (args.debug) {
|
|
93
|
+
(0, stdio_1.print2)(`DELETE (${renderDurationSec(deleteExpirySeconds)}): ${deleteUrl}`);
|
|
94
|
+
}
|
|
78
95
|
(0, stdio_1.print2)(`Uploading ${args.source}...`);
|
|
79
96
|
// The backend grants the AWS role permission to write to our prefix, but
|
|
80
97
|
// IAM has eventual consistency — the policy can take several seconds to
|
|
@@ -118,13 +135,45 @@ const fileTransferAction = (args) => __awaiter(void 0, void 0, void 0, function*
|
|
|
118
135
|
throw `Upload failed: ${message}`;
|
|
119
136
|
}
|
|
120
137
|
(0, stdio_1.print2)("Uploaded.");
|
|
121
|
-
//
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
//
|
|
138
|
+
// TODO we need to remove this second request. it should be included in file transfer delegation. Will be removed in future ticket
|
|
139
|
+
(0, stdio_1.print2)(`Requesting download access on ${args.destination}...`);
|
|
140
|
+
// Drop `source` (local file path) before passing to SSH plumbing —
|
|
141
|
+
// `createCommand` uses `"source" in args` to branch between scp and ssh path, and we want the ssh branch here.
|
|
142
|
+
const { source: _source } = args, sshBaseArgs = __rest(args, ["source"]);
|
|
143
|
+
const sshCmdArgs = Object.assign(Object.assign({}, sshBaseArgs), { arguments: [], sshOptions: [] });
|
|
144
|
+
const { request, requestId, privateKey, sshProvider, sshHostKeys } = yield (0, ssh_2.prepareRequest)(authn, sshCmdArgs, args.destination);
|
|
145
|
+
// Sign GET URL now so the 5-min TTL starts after approval clears,
|
|
146
|
+
// not before — otherwise long approval waits could expire the URL.
|
|
147
|
+
const { signedUrl: getUrl, expirySeconds: getExpirySeconds } = yield (0, file_transfer_1.generateSignedUrl)(authn, s3, { bucket: target.bucket, key: uploadKey, awsSpec: target.awsSpec }, "get", args.debug);
|
|
125
148
|
if (args.debug) {
|
|
126
|
-
(0, stdio_1.print2)(`GET (${renderDurationSec(
|
|
127
|
-
|
|
149
|
+
(0, stdio_1.print2)(`GET (${renderDurationSec(getExpirySeconds)}): ${getUrl}`);
|
|
150
|
+
}
|
|
151
|
+
const remotePath = `/home/${request.linuxUserName}/${(0, node_path_1.basename)(args.source)}`;
|
|
152
|
+
(0, stdio_1.print2)(`Downloading to ${request.linuxUserName}@${args.destination}:${remotePath}...`);
|
|
153
|
+
// TODO decide final downloader to use and maybe add fallback downloaders if not present. Using curl for now — universally present on mainstream EC2 AMIs (Amazon Linux, Ubuntu, RHEL, etc.).
|
|
154
|
+
const downloadCmdArgs = Object.assign(Object.assign({}, sshCmdArgs), { command: "curl", arguments: ["-sSfL", getUrl, "-o", remotePath] });
|
|
155
|
+
const exitCode = yield (0, ssh_1.sshOrScp)({
|
|
156
|
+
authn,
|
|
157
|
+
request,
|
|
158
|
+
requestId,
|
|
159
|
+
cmdArgs: downloadCmdArgs,
|
|
160
|
+
privateKey,
|
|
161
|
+
sshProvider,
|
|
162
|
+
sshHostKeys,
|
|
163
|
+
});
|
|
164
|
+
// TODO update comment when we add fallback downloader if needed
|
|
165
|
+
if (exitCode === 127) {
|
|
166
|
+
throw `curl not found on ${args.destination}. The file is in S3 — install curl on the destination instance and re-run file-transfer command`;
|
|
167
|
+
}
|
|
168
|
+
if (exitCode !== null && exitCode !== 0) {
|
|
169
|
+
throw `Remote download exited with code ${exitCode}`;
|
|
170
|
+
}
|
|
171
|
+
(0, stdio_1.print2)(`Downloaded to ${remotePath}.`);
|
|
172
|
+
// Force exit to prevent hanging due to orphaned child processes (e.g.,
|
|
173
|
+
// session-manager-plugin) holding open file descriptors. See:
|
|
174
|
+
// https://github.com/aws/amazon-ssm-agent/issues/173
|
|
175
|
+
if (process.env.NODE_ENV !== "unit") {
|
|
176
|
+
(0, otel_helpers_1.exitProcess)(0);
|
|
128
177
|
}
|
|
129
178
|
}), {
|
|
130
179
|
command: "file-transfer",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file-transfer.js","sourceRoot":"","sources":["../../../src/commands/file-transfer.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"file-transfer.js","sourceRoot":"","sources":["../../../src/commands/file-transfer.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;GASG;AACH,2CAAiD;AACjD,0CAA+C;AAC/C,4CAA0C;AAC1C,gEAAuE;AACvE,4DAIkC;AAClC,wCAA0C;AAC1C,sCAA8C;AAC9C,sDAA8C;AAC9C,2BAAgD;AAChD,yCAAqC;AAUrC,MAAM,iBAAiB,GAAG,CAAC,CAAS,EAAE,EAAE,CACtC,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC;AAE7D,MAAM,mBAAmB,GAAG,CAAC,KAAiB,EAAE,EAAE,CACvD,KAAK,CAAC,OAAO,CACX,sCAAsC,EACtC,uEAAuE,EACvE,CAAC,KAAK,EAAE,EAAE,CACR,KAAK;KACF,UAAU,CAAC,QAAQ,EAAE;IACpB,IAAI,EAAE,QAAQ;IACd,YAAY,EAAE,IAAI;IAClB,WAAW,EAAE,iBAAiB;C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,QAAQ,KAAK,GAAG,EAAE;YACpB,MAAM,qBAAqB,IAAI,CAAC,WAAW,iGAAiG,CAAC;SAC9I;QACD,IAAI,QAAQ,KAAK,IAAI,IAAI,QAAQ,KAAK,CAAC,EAAE;YACvC,MAAM,oCAAoC,QAAQ,EAAE,CAAC;SACtD;QAED,IAAA,cAAM,EAAC,iBAAiB,UAAU,GAAG,CAAC,CAAC;QAEvC,uEAAuE;QACvE,8DAA8D;QAC9D,qDAAqD;QACrD,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,MAAM,EAAE;YACnC,IAAA,0BAAW,EAAC,CAAC,CAAC,CAAC;SAChB;IACH,CAAC,CAAA,EACD;QACE,OAAO,EAAE,eAAe;KACzB,CACF,CAAC;AACJ,CAAC,CAAA,CAAC"}
|
|
@@ -13,6 +13,8 @@ import { Authn } from "../../types/identity";
|
|
|
13
13
|
import { AwsResourcePermissionSpec } from "../aws/types";
|
|
14
14
|
import { S3Client } from "@aws-sdk/client-s3";
|
|
15
15
|
import yargs from "yargs";
|
|
16
|
+
export declare const MAX_SECONDS_TO_EXPIRE_GET_URL: number;
|
|
17
|
+
export declare const MAX_SECONDS_TO_EXPIRE_DELETE_URL: number;
|
|
16
18
|
export declare const provisionTransferRequest: (authn: Authn, args: yargs.ArgumentsCamelCase<FileTransferCommandArgs>) => Promise<{
|
|
17
19
|
bucket: string;
|
|
18
20
|
prefix: string;
|
|
@@ -30,22 +32,20 @@ export declare const createTransferClient: (authn: Authn, target: {
|
|
|
30
32
|
awsSpec: AwsResourcePermissionSpec;
|
|
31
33
|
}, debug?: boolean) => S3Client;
|
|
32
34
|
/**
|
|
33
|
-
* Signs the GET (download)
|
|
35
|
+
* Signs the GET (download) or DELETE (cleanup) URL. Call this AFTER the upload
|
|
34
36
|
* completes: the GET window is finite, and signing before a large upload would
|
|
35
37
|
* burn that window while the file is still uploading.
|
|
36
38
|
*
|
|
37
39
|
* Each expiry is capped to the credentials' remaining lifetime so a URL can
|
|
38
40
|
* never outlive the credentials that signed it.
|
|
39
41
|
*/
|
|
40
|
-
|
|
42
|
+
type SignedUrlCommand = "delete" | "get";
|
|
43
|
+
export declare const generateSignedUrl: (authn: Authn, s3: S3Client, target: {
|
|
41
44
|
bucket: string;
|
|
42
45
|
key: string;
|
|
43
46
|
awsSpec: AwsResourcePermissionSpec;
|
|
44
|
-
}, debug?: boolean) => Promise<{
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
expirySeconds: {
|
|
48
|
-
get: number;
|
|
49
|
-
delete: number;
|
|
50
|
-
};
|
|
47
|
+
}, command: SignedUrlCommand, debug?: boolean) => Promise<{
|
|
48
|
+
signedUrl: string;
|
|
49
|
+
expirySeconds: number;
|
|
51
50
|
}>;
|
|
51
|
+
export {};
|
|
@@ -9,14 +9,15 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.
|
|
12
|
+
exports.generateSignedUrl = exports.createTransferClient = exports.provisionTransferRequest = exports.MAX_SECONDS_TO_EXPIRE_DELETE_URL = exports.MAX_SECONDS_TO_EXPIRE_GET_URL = void 0;
|
|
13
13
|
const request_1 = require("../../commands/shared/request");
|
|
14
|
+
const delegation_1 = require("../../types/delegation");
|
|
14
15
|
const auth_1 = require("../aws/auth");
|
|
15
16
|
const client_s3_1 = require("@aws-sdk/client-s3");
|
|
16
17
|
const s3_request_presigner_1 = require("@aws-sdk/s3-request-presigner");
|
|
17
18
|
const lodash_1 = require("lodash");
|
|
18
|
-
|
|
19
|
-
|
|
19
|
+
exports.MAX_SECONDS_TO_EXPIRE_GET_URL = 5 * 60;
|
|
20
|
+
exports.MAX_SECONDS_TO_EXPIRE_DELETE_URL = 60 * 60;
|
|
20
21
|
const MIN_URL_EXPIRY_THRESHOLD_SECONDS = 60;
|
|
21
22
|
const provisionTransferRequest = (authn, args) => __awaiter(void 0, void 0, void 0, function* () {
|
|
22
23
|
const response = yield (0, request_1.request)("request")(Object.assign(Object.assign({}, (0, lodash_1.pick)(args, "$0", "_")), { arguments: [
|
|
@@ -28,7 +29,7 @@ const provisionTransferRequest = (authn, args) => __awaiter(void 0, void 0, void
|
|
|
28
29
|
if (!response) {
|
|
29
30
|
throw "Did not receive a response from server";
|
|
30
31
|
}
|
|
31
|
-
const awsSpec = response.request.delegation
|
|
32
|
+
const awsSpec = (0, delegation_1.getDelegate)(response.request.delegation, "aws");
|
|
32
33
|
if (!awsSpec) {
|
|
33
34
|
throw "Backend granted file-transfer access, but there was an error getting AWS access details";
|
|
34
35
|
}
|
|
@@ -57,15 +58,7 @@ const createTransferClient = (authn, target, debug) => new client_s3_1.S3Client(
|
|
|
57
58
|
}),
|
|
58
59
|
});
|
|
59
60
|
exports.createTransferClient = createTransferClient;
|
|
60
|
-
|
|
61
|
-
* Signs the GET (download) and DELETE (cleanup) URLs. Call this AFTER the upload
|
|
62
|
-
* completes: the GET window is finite, and signing before a large upload would
|
|
63
|
-
* burn that window while the file is still uploading.
|
|
64
|
-
*
|
|
65
|
-
* Each expiry is capped to the credentials' remaining lifetime so a URL can
|
|
66
|
-
* never outlive the credentials that signed it.
|
|
67
|
-
*/
|
|
68
|
-
const generateTransferUrls = (authn, s3, target, debug) => __awaiter(void 0, void 0, void 0, function* () {
|
|
61
|
+
const generateSignedUrl = (authn, s3, target, command, debug) => __awaiter(void 0, void 0, void 0, function* () {
|
|
69
62
|
const { expiresAt } = yield (0, auth_1.awsCloudAuth)(authn, target.awsSpec, debug);
|
|
70
63
|
const remaining = expiresAt !== undefined
|
|
71
64
|
? Math.floor((expiresAt - Date.now()) / 1000)
|
|
@@ -74,26 +67,32 @@ const generateTransferUrls = (authn, s3, target, debug) => __awaiter(void 0, voi
|
|
|
74
67
|
throw new Error(`AWS credentials expire in ${remaining}s — too soon to sign usable URLs. ` +
|
|
75
68
|
`Check your system clock or re-run the request.`);
|
|
76
69
|
}
|
|
77
|
-
const
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
70
|
+
const URL_CONFIGS = {
|
|
71
|
+
get: {
|
|
72
|
+
maxExpiry: exports.MAX_SECONDS_TO_EXPIRE_GET_URL,
|
|
73
|
+
s3Command: new client_s3_1.GetObjectCommand({
|
|
74
|
+
Bucket: target.bucket,
|
|
75
|
+
Key: target.key,
|
|
76
|
+
}),
|
|
77
|
+
},
|
|
78
|
+
delete: {
|
|
79
|
+
maxExpiry: exports.MAX_SECONDS_TO_EXPIRE_DELETE_URL,
|
|
80
|
+
s3Command: new client_s3_1.DeleteObjectCommand({
|
|
81
|
+
Bucket: target.bucket,
|
|
82
|
+
Key: target.key,
|
|
83
|
+
}),
|
|
84
|
+
},
|
|
85
|
+
};
|
|
86
|
+
const urlConfig = URL_CONFIGS[command];
|
|
87
|
+
const secondsToExpireUrl = Math.min(urlConfig.maxExpiry, remaining);
|
|
88
|
+
const signedUrl = yield (0, s3_request_presigner_1.getSignedUrl)(s3, urlConfig.s3Command, {
|
|
89
|
+
expiresIn: secondsToExpireUrl,
|
|
90
|
+
});
|
|
88
91
|
return {
|
|
89
|
-
|
|
90
|
-
deleteUrl,
|
|
92
|
+
signedUrl,
|
|
91
93
|
// Report the ACTUAL (capped) seconds so debug output is honest.
|
|
92
|
-
expirySeconds:
|
|
93
|
-
get: secondsToExpireGetUrl,
|
|
94
|
-
delete: secondsToExpireDeleteUrl,
|
|
95
|
-
},
|
|
94
|
+
expirySeconds: secondsToExpireUrl,
|
|
96
95
|
};
|
|
97
96
|
});
|
|
98
|
-
exports.
|
|
97
|
+
exports.generateSignedUrl = generateSignedUrl;
|
|
99
98
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/plugins/file-transfer/index.ts"],"names":[],"mapp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,CACnD,CAAC;KACH;IAED,MAAM,WAAW,GAGb;QACF,GAAG,EAAE;YACH,SAAS,EAAE,qCAA6B;YACxC,SAAS,EAAE,IAAI,4BAAgB,CAAC;gBAC9B,MAAM,EAAE,MAAM,CAAC,MAAM;gBACrB,GAAG,EAAE,MAAM,CAAC,GAAG;aAChB,CAAC;SACH;QACD,MAAM,EAAE;YACN,SAAS,EAAE,wCAAgC;YAC3C,SAAS,EAAE,IAAI,+BAAmB,CAAC;gBACjC,MAAM,EAAE,MAAM,CAAC,MAAM;gBACrB,GAAG,EAAE,MAAM,CAAC,GAAG;aAChB,CAAC;SACH;KACF,CAAC;IAEF,MAAM,SAAS,GAAG,WAAW,CAAC,OAAO,CAAC,CAAC;IAEvC,MAAM,kBAAkB,GAAG,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;IAEpE,MAAM,SAAS,GAAG,MAAM,IAAA,mCAAY,EAAC,EAAE,EAAE,SAAS,CAAC,SAAS,EAAE;QAC5D,SAAS,EAAE,kBAAkB;KAC9B,CAAC,CAAC;IAEH,OAAO;QACL,SAAS;QACT,gEAAgE;QAChE,aAAa,EAAE,kBAAkB;KAClC,CAAC;AACJ,CAAC,CAAA,CAAC;AAvDW,QAAA,iBAAiB,qBAuD5B"}
|
|
@@ -24,8 +24,6 @@ export type FileTransferPermission = {
|
|
|
24
24
|
destination: string;
|
|
25
25
|
type: "resource";
|
|
26
26
|
};
|
|
27
|
-
export type FileTransferPermissionSpec = PermissionSpec<"file-transfer", FileTransferPermission, Record<string, never
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
};
|
|
31
|
-
};
|
|
27
|
+
export type FileTransferPermissionSpec = PermissionSpec<"file-transfer", FileTransferPermission, Record<string, never>, {
|
|
28
|
+
aws?: AwsResourcePermissionSpec;
|
|
29
|
+
}>;
|
|
@@ -0,0 +1,39 @@
|
|
|
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 { GcpSshRequest } from "./types";
|
|
12
|
+
/**
|
|
13
|
+
* P0 grants the IAM roles needed for GCP SSH, but OS Login must be enabled in
|
|
14
|
+
* the customer's project — P0 cannot enable it on their behalf. When OS Login is
|
|
15
|
+
* off the IAM grant still succeeds, but the connection fails at SSH
|
|
16
|
+
* authentication: without OS Login the user's key is never provisioned onto the
|
|
17
|
+
* VM (P0's grant does not include permission to write keys to instance
|
|
18
|
+
* metadata), so auth is rejected with `Permission denied (publickey)`.
|
|
19
|
+
*
|
|
20
|
+
* Historically the user saw only that raw, generic rejection and concluded P0
|
|
21
|
+
* was broken. We surface a targeted hint instead. `Permission denied
|
|
22
|
+
* (publickey)` is not exclusively an OS Login problem — it can also be a brief
|
|
23
|
+
* key-propagation delay or a just-granted IAM role — so the message names OS
|
|
24
|
+
* Login as the most likely cause while listing the alternatives, and never
|
|
25
|
+
* claims certainty.
|
|
26
|
+
*
|
|
27
|
+
* We deliberately do NOT try to classify the other GCP prerequisite failure (IAP
|
|
28
|
+
* / firewall not configured, which fails earlier, at the gcloud tunnel rather
|
|
29
|
+
* than at SSH auth). Its `gcloud start-iap-tunnel` error strings vary by gcloud
|
|
30
|
+
* version and are easy to misattribute; since misattributing is worse than the
|
|
31
|
+
* status quo, those failures fall through to the raw error unchanged.
|
|
32
|
+
*/
|
|
33
|
+
export declare const GCP_SSH_PREREQUISITES_DOC = "https://docs.p0.dev/integrations/resource-integrations/ssh#gcp-project-requirements";
|
|
34
|
+
/**
|
|
35
|
+
* Inspects the captured stderr of a failed GCP SSH connection and returns an
|
|
36
|
+
* actionable message when the failure is an SSH auth rejection (most likely OS
|
|
37
|
+
* Login not being enabled), or `undefined` to fall through to the raw error.
|
|
38
|
+
*/
|
|
39
|
+
export declare const classifyGcpConnectionError: (stderr: string, request: Pick<GcpSshRequest, "id">) => string | undefined;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.classifyGcpConnectionError = exports.GCP_SSH_PREREQUISITES_DOC = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* P0 grants the IAM roles needed for GCP SSH, but OS Login must be enabled in
|
|
6
|
+
* the customer's project — P0 cannot enable it on their behalf. When OS Login is
|
|
7
|
+
* off the IAM grant still succeeds, but the connection fails at SSH
|
|
8
|
+
* authentication: without OS Login the user's key is never provisioned onto the
|
|
9
|
+
* VM (P0's grant does not include permission to write keys to instance
|
|
10
|
+
* metadata), so auth is rejected with `Permission denied (publickey)`.
|
|
11
|
+
*
|
|
12
|
+
* Historically the user saw only that raw, generic rejection and concluded P0
|
|
13
|
+
* was broken. We surface a targeted hint instead. `Permission denied
|
|
14
|
+
* (publickey)` is not exclusively an OS Login problem — it can also be a brief
|
|
15
|
+
* key-propagation delay or a just-granted IAM role — so the message names OS
|
|
16
|
+
* Login as the most likely cause while listing the alternatives, and never
|
|
17
|
+
* claims certainty.
|
|
18
|
+
*
|
|
19
|
+
* We deliberately do NOT try to classify the other GCP prerequisite failure (IAP
|
|
20
|
+
* / firewall not configured, which fails earlier, at the gcloud tunnel rather
|
|
21
|
+
* than at SSH auth). Its `gcloud start-iap-tunnel` error strings vary by gcloud
|
|
22
|
+
* version and are easy to misattribute; since misattributing is worse than the
|
|
23
|
+
* status quo, those failures fall through to the raw error unchanged.
|
|
24
|
+
*/
|
|
25
|
+
exports.GCP_SSH_PREREQUISITES_DOC = "https://docs.p0.dev/integrations/resource-integrations/ssh#gcp-project-requirements";
|
|
26
|
+
/** SSH auth was reached and rejected — most likely because OS Login is off. */
|
|
27
|
+
const AUTH_REJECTED_PATTERN = /Permission denied \(publickey\)/;
|
|
28
|
+
// Leads with a newline so it prints with one blank line above the preceding SSH
|
|
29
|
+
// output, for legibility.
|
|
30
|
+
const osLoginMessage = (instance) => `\nConnected to ${instance} but authentication was rejected ` +
|
|
31
|
+
`(Permission denied (publickey)). The most common cause is OS Login not ` +
|
|
32
|
+
`being enabled. Enable it by setting enable-oslogin=TRUE on the project (or ` +
|
|
33
|
+
`instance) metadata, then retry. If OS Login is already enabled, this can ` +
|
|
34
|
+
`also be a brief key-propagation delay or a just-granted IAM role — wait ` +
|
|
35
|
+
`~30s and retry. See ${exports.GCP_SSH_PREREQUISITES_DOC}`;
|
|
36
|
+
/**
|
|
37
|
+
* Inspects the captured stderr of a failed GCP SSH connection and returns an
|
|
38
|
+
* actionable message when the failure is an SSH auth rejection (most likely OS
|
|
39
|
+
* Login not being enabled), or `undefined` to fall through to the raw error.
|
|
40
|
+
*/
|
|
41
|
+
const classifyGcpConnectionError = (stderr, request) => AUTH_REJECTED_PATTERN.test(stderr) ? osLoginMessage(request.id) : undefined;
|
|
42
|
+
exports.classifyGcpConnectionError = classifyGcpConnectionError;
|
|
43
|
+
//# sourceMappingURL=connection-error.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connection-error.js","sourceRoot":"","sources":["../../../../src/plugins/google/connection-error.ts"],"names":[],"mappings":";;;AAYA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEU,QAAA,yBAAyB,GACpC,qFAAqF,CAAC;AAExF,+EAA+E;AAC/E,MAAM,qBAAqB,GAAG,iCAAiC,CAAC;AAEhE,gFAAgF;AAChF,0BAA0B;AAC1B,MAAM,cAAc,GAAG,CAAC,QAAgB,EAAE,EAAE,CAC1C,kBAAkB,QAAQ,mCAAmC;IAC7D,yEAAyE;IACzE,6EAA6E;IAC7E,2EAA2E;IAC3E,0EAA0E;IAC1E,uBAAuB,iCAAyB,EAAE,CAAC;AAErD;;;;GAIG;AACI,MAAM,0BAA0B,GAAG,CACxC,MAAc,EACd,OAAkC,EACd,EAAE,CACtB,qBAAqB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;AAJjE,QAAA,0BAA0B,8BAIuC"}
|
|
@@ -1,2 +1,17 @@
|
|
|
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 { InstallMetadata } from "../../common/install";
|
|
1
12
|
export declare const SupportedPlatforms: readonly ["darwin"];
|
|
13
|
+
declare const GcpSshItems: readonly ["gcloud"];
|
|
14
|
+
type GcpSshItem = (typeof GcpSshItems)[number];
|
|
15
|
+
export declare const GcpSshInstall: Readonly<Record<GcpSshItem, InstallMetadata>>;
|
|
2
16
|
export declare const ensureGcpSshInstall: () => Promise<boolean>;
|
|
17
|
+
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ensureGcpSshInstall = exports.SupportedPlatforms = void 0;
|
|
3
|
+
exports.ensureGcpSshInstall = exports.GcpSshInstall = exports.SupportedPlatforms = void 0;
|
|
4
4
|
/** Copyright © 2024-present P0 Security
|
|
5
5
|
|
|
6
6
|
This file is part of @p0security/cli
|
|
@@ -14,14 +14,14 @@ You should have received a copy of the GNU General Public License along with @p0
|
|
|
14
14
|
const install_1 = require("../../common/install");
|
|
15
15
|
exports.SupportedPlatforms = ["darwin"];
|
|
16
16
|
const GcpSshItems = ["gcloud"];
|
|
17
|
-
|
|
17
|
+
exports.GcpSshInstall = {
|
|
18
18
|
gcloud: {
|
|
19
19
|
label: "GCloud CLI",
|
|
20
20
|
commands: {
|
|
21
21
|
darwin: [
|
|
22
22
|
// See https://cloud.google.com/sdk/docs/install-sdk
|
|
23
23
|
"architecture=$(arch)",
|
|
24
|
-
'package=$([ $architecture = "arm64" ] && echo "https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-cli-darwin-arm.tar.gz" || "https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-cli-darwin-x86_64.tar.gz" )',
|
|
24
|
+
'package=$([ "$architecture" = "arm64" ] && echo "https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-cli-darwin-arm.tar.gz" || echo "https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-cli-darwin-x86_64.tar.gz" )',
|
|
25
25
|
"wget -O ~/google-cloud-cli.tar.gz $package",
|
|
26
26
|
"tar -xzf ~/google-cloud-cli.tar.gz -C ~",
|
|
27
27
|
"~/google-cloud-sdk/install.sh",
|
|
@@ -34,6 +34,6 @@ const GcpSshInstall = {
|
|
|
34
34
|
},
|
|
35
35
|
},
|
|
36
36
|
};
|
|
37
|
-
const ensureGcpSshInstall = () => (0, install_1.ensureInstall)(GcpSshItems, GcpSshInstall);
|
|
37
|
+
const ensureGcpSshInstall = () => (0, install_1.ensureInstall)(GcpSshItems, exports.GcpSshInstall);
|
|
38
38
|
exports.ensureGcpSshInstall = ensureGcpSshInstall;
|
|
39
39
|
//# sourceMappingURL=install.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"install.js","sourceRoot":"","sources":["../../../../src/plugins/google/install.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;GASG;AACH,kDAAsE;AAEzD,QAAA,kBAAkB,GAAG,CAAC,QAAQ,CAAU,CAAC;AAEtD,MAAM,WAAW,GAAG,CAAC,QAAQ,CAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"install.js","sourceRoot":"","sources":["../../../../src/plugins/google/install.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;GASG;AACH,kDAAsE;AAEzD,QAAA,kBAAkB,GAAG,CAAC,QAAQ,CAAU,CAAC;AAEtD,MAAM,WAAW,GAAG,CAAC,QAAQ,CAAU,CAAC;AAG3B,QAAA,aAAa,GAAkD;IAC1E,MAAM,EAAE;QACN,KAAK,EAAE,YAAY;QACnB,QAAQ,EAAE;YACR,MAAM,EAAE;gBACN,oDAAoD;gBACpD,sBAAsB;gBACtB,8PAA8P;gBAC9P,4CAA4C;gBAC5C,yCAAyC;gBACzC,+BAA+B;gBAC/B,kCAAkC;gBAClC,8HAA8H;gBAC9H,8BAA8B;gBAC9B,gEAAgE;gBAChE,wCAAwC;aACzC;SACF;KACF;CACF,CAAC;AAEK,MAAM,mBAAmB,GAAG,GAAG,EAAE,CACtC,IAAA,uBAAa,EAAC,WAAW,EAAE,qBAAa,CAAC,CAAC;AAD/B,QAAA,mBAAmB,uBACY"}
|
|
@@ -23,6 +23,7 @@ You should have received a copy of the GNU General Public License along with @p0
|
|
|
23
23
|
const ssh_1 = require("../../commands/shared/ssh");
|
|
24
24
|
const keys_1 = require("../../common/keys");
|
|
25
25
|
const auth_1 = require("./auth");
|
|
26
|
+
const connection_error_1 = require("./connection-error");
|
|
26
27
|
const install_1 = require("./install");
|
|
27
28
|
const ssh_key_1 = require("./ssh-key");
|
|
28
29
|
const util_1 = require("./util");
|
|
@@ -65,6 +66,7 @@ exports.gcpSshProvider = {
|
|
|
65
66
|
yield (0, auth_1.ensureGcloudLogin)({ debug });
|
|
66
67
|
return undefined;
|
|
67
68
|
}),
|
|
69
|
+
connectionErrorMessage: (stderr, request) => (0, connection_error_1.classifyGcpConnectionError)(stderr, request),
|
|
68
70
|
ensureInstall: () => __awaiter(void 0, void 0, void 0, function* () {
|
|
69
71
|
if (!(yield (0, install_1.ensureGcpSshInstall)())) {
|
|
70
72
|
throw "Please try again after installing the required GCP utilities";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ssh.js","sourceRoot":"","sources":["../../../../src/plugins/google/ssh.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;GASG;AACH,mDAA0D;AAC1D,4CAAqD;AAErD,iCAA2C;AAC3C,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,kBAAkB,EAAE,CAAO,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,EAAE;QACpD,MAAM,IAAA,wBAAiB,EAAC,EAAE,KAAK,EAAE,CAAC,CAAC;QACnC,OAAO,SAAS,CAAC;IACnB,CAAC,CAAA;IAED,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,o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