@p0security/cli 0.27.1 → 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/aws/rds.js +12 -8
- package/build/dist/commands/aws/rds.js.map +1 -1
- package/build/dist/commands/aws/util.js +6 -4
- package/build/dist/commands/aws/util.js.map +1 -1
- 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 +59 -7
- package/build/dist/commands/file-transfer.js.map +1 -1
- package/build/dist/commands/login.js +2 -3
- package/build/dist/commands/login.js.map +1 -1
- package/build/dist/commands/logout.js +4 -3
- package/build/dist/commands/logout.js.map +1 -1
- package/build/dist/drivers/auth/index.d.ts +1 -3
- package/build/dist/drivers/auth/index.js +2 -44
- package/build/dist/drivers/auth/index.js.map +1 -1
- package/build/dist/plugins/aws/assumeRole.js +7 -0
- package/build/dist/plugins/aws/assumeRole.js.map +1 -1
- package/build/dist/plugins/aws/ssh.js +2 -3
- package/build/dist/plugins/aws/ssh.js.map +1 -1
- package/build/dist/plugins/aws/types.d.ts +4 -1
- package/build/dist/plugins/file-transfer/index.d.ts +26 -10
- package/build/dist/plugins/file-transfer/index.js +54 -30
- 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/login.d.ts +1 -3
- package/build/dist/plugins/login.js +2 -2
- package/build/dist/plugins/login.js.map +1 -1
- package/build/dist/plugins/okta/login.d.ts +2 -10
- package/build/dist/plugins/okta/login.js +12 -38
- package/build/dist/plugins/okta/login.js.map +1 -1
- package/build/dist/plugins/ssh/index.js +36 -5
- 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/dist/util.d.ts +28 -0
- package/build/dist/util.js +31 -1
- package/build/dist/util.js.map +1 -1
- package/build/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -3
- package/build/dist/drivers/auth/lock.d.ts +0 -11
- package/build/dist/drivers/auth/lock.js +0 -70
- package/build/dist/drivers/auth/lock.js.map +0 -1
- package/build/dist/drivers/auth/refresh.d.ts +0 -31
- package/build/dist/drivers/auth/refresh.js +0 -130
- package/build/dist/drivers/auth/refresh.js.map +0 -1
|
@@ -13,23 +13,39 @@ 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;
|
|
19
21
|
region: string;
|
|
20
22
|
awsSpec: AwsResourcePermissionSpec;
|
|
21
23
|
}>;
|
|
22
|
-
|
|
24
|
+
/**
|
|
25
|
+
* Builds an S3 client whose credentials refresh automatically. A large upload
|
|
26
|
+
* can run longer than the temporary credentials live; passing a provider
|
|
27
|
+
* function (that returns `expiration`) lets the SDK re-fetch fresh credentials
|
|
28
|
+
* mid-upload instead of failing the in-flight parts with ExpiredToken.
|
|
29
|
+
*/
|
|
30
|
+
export declare const createTransferClient: (authn: Authn, target: {
|
|
31
|
+
region: string;
|
|
32
|
+
awsSpec: AwsResourcePermissionSpec;
|
|
33
|
+
}, debug?: boolean) => S3Client;
|
|
34
|
+
/**
|
|
35
|
+
* Signs the GET (download) or DELETE (cleanup) URL. Call this AFTER the upload
|
|
36
|
+
* completes: the GET window is finite, and signing before a large upload would
|
|
37
|
+
* burn that window while the file is still uploading.
|
|
38
|
+
*
|
|
39
|
+
* Each expiry is capped to the credentials' remaining lifetime so a URL can
|
|
40
|
+
* never outlive the credentials that signed it.
|
|
41
|
+
*/
|
|
42
|
+
type SignedUrlCommand = "delete" | "get";
|
|
43
|
+
export declare const generateSignedUrl: (authn: Authn, s3: S3Client, target: {
|
|
23
44
|
bucket: string;
|
|
24
45
|
key: string;
|
|
25
|
-
region: string;
|
|
26
46
|
awsSpec: AwsResourcePermissionSpec;
|
|
27
|
-
}, debug?: boolean) => Promise<{
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
deleteUrl: string;
|
|
31
|
-
expirySeconds: {
|
|
32
|
-
get: number;
|
|
33
|
-
delete: number;
|
|
34
|
-
};
|
|
47
|
+
}, command: SignedUrlCommand, debug?: boolean) => Promise<{
|
|
48
|
+
signedUrl: string;
|
|
49
|
+
expirySeconds: number;
|
|
35
50
|
}>;
|
|
51
|
+
export {};
|
|
@@ -9,14 +9,16 @@ 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;
|
|
21
|
+
const MIN_URL_EXPIRY_THRESHOLD_SECONDS = 60;
|
|
20
22
|
const provisionTransferRequest = (authn, args) => __awaiter(void 0, void 0, void 0, function* () {
|
|
21
23
|
const response = yield (0, request_1.request)("request")(Object.assign(Object.assign({}, (0, lodash_1.pick)(args, "$0", "_")), { arguments: [
|
|
22
24
|
"file-transfer",
|
|
@@ -27,7 +29,7 @@ const provisionTransferRequest = (authn, args) => __awaiter(void 0, void 0, void
|
|
|
27
29
|
if (!response) {
|
|
28
30
|
throw "Did not receive a response from server";
|
|
29
31
|
}
|
|
30
|
-
const awsSpec = response.request.delegation
|
|
32
|
+
const awsSpec = (0, delegation_1.getDelegate)(response.request.delegation, "aws");
|
|
31
33
|
if (!awsSpec) {
|
|
32
34
|
throw "Backend granted file-transfer access, but there was an error getting AWS access details";
|
|
33
35
|
}
|
|
@@ -40,35 +42,57 @@ const provisionTransferRequest = (authn, args) => __awaiter(void 0, void 0, void
|
|
|
40
42
|
};
|
|
41
43
|
});
|
|
42
44
|
exports.provisionTransferRequest = provisionTransferRequest;
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
45
|
+
/**
|
|
46
|
+
* Builds an S3 client whose credentials refresh automatically. A large upload
|
|
47
|
+
* can run longer than the temporary credentials live; passing a provider
|
|
48
|
+
* function (that returns `expiration`) lets the SDK re-fetch fresh credentials
|
|
49
|
+
* mid-upload instead of failing the in-flight parts with ExpiredToken.
|
|
50
|
+
*/
|
|
51
|
+
const createTransferClient = (authn, target, debug) => new client_s3_1.S3Client({
|
|
52
|
+
region: target.region,
|
|
53
|
+
credentials: () => __awaiter(void 0, void 0, void 0, function* () {
|
|
54
|
+
const credentials = yield (0, auth_1.awsCloudAuth)(authn, target.awsSpec, debug);
|
|
55
|
+
return Object.assign({ accessKeyId: credentials.AWS_ACCESS_KEY_ID, secretAccessKey: credentials.AWS_SECRET_ACCESS_KEY, sessionToken: credentials.AWS_SESSION_TOKEN }, (credentials.expiresAt !== undefined
|
|
56
|
+
? { expiration: new Date(credentials.expiresAt) }
|
|
57
|
+
: {}));
|
|
58
|
+
}),
|
|
59
|
+
});
|
|
60
|
+
exports.createTransferClient = createTransferClient;
|
|
61
|
+
const generateSignedUrl = (authn, s3, target, command, debug) => __awaiter(void 0, void 0, void 0, function* () {
|
|
62
|
+
const { expiresAt } = yield (0, auth_1.awsCloudAuth)(authn, target.awsSpec, debug);
|
|
63
|
+
const remaining = expiresAt !== undefined
|
|
64
|
+
? Math.floor((expiresAt - Date.now()) / 1000)
|
|
65
|
+
: Infinity;
|
|
66
|
+
if (remaining < MIN_URL_EXPIRY_THRESHOLD_SECONDS) {
|
|
67
|
+
throw new Error(`AWS credentials expire in ${remaining}s — too soon to sign usable URLs. ` +
|
|
68
|
+
`Check your system clock or re-run the request.`);
|
|
69
|
+
}
|
|
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
|
+
},
|
|
49
85
|
};
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
|
|
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,
|
|
53
90
|
});
|
|
54
|
-
const objectArgs = { Bucket: target.bucket, Key: target.key };
|
|
55
|
-
const [getUrl, deleteUrl] = yield Promise.all([
|
|
56
|
-
(0, s3_request_presigner_1.getSignedUrl)(s3, new client_s3_1.GetObjectCommand(objectArgs), {
|
|
57
|
-
expiresIn: GET_EXPIRES_SECONDS,
|
|
58
|
-
}),
|
|
59
|
-
(0, s3_request_presigner_1.getSignedUrl)(s3, new client_s3_1.DeleteObjectCommand(objectArgs), {
|
|
60
|
-
expiresIn: DELETE_EXPIRES_SECONDS,
|
|
61
|
-
}),
|
|
62
|
-
]);
|
|
63
91
|
return {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
expirySeconds: {
|
|
68
|
-
get: GET_EXPIRES_SECONDS,
|
|
69
|
-
delete: DELETE_EXPIRES_SECONDS,
|
|
70
|
-
},
|
|
92
|
+
signedUrl,
|
|
93
|
+
// Report the ACTUAL (capped) seconds so debug output is honest.
|
|
94
|
+
expirySeconds: secondsToExpireUrl,
|
|
71
95
|
};
|
|
72
96
|
});
|
|
73
|
-
exports.
|
|
97
|
+
exports.generateSignedUrl = generateSignedUrl;
|
|
74
98
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/plugins/file-transfer/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAWA,2DAAwD;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/plugins/file-transfer/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAWA,2DAAwD;AACxD,uDAAqD;AAGrD,sCAA2C;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AAE,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,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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O,CAAC,YAAY,CAAC,aAAa;YACjD,IAAI,EAAE,QAAQ;SACf,CAAC;IACJ,CAAC;IAED,2BAA2B;IAE3B,YAAY,EAAE,CAAO,OAAO,EAAE,OAAO,EAAE,EAAE;QAAC,OAAA,iCACrC,OAAO,KACV,YAAY,EAAE;gBACZ,aAAa,EAAE,MAAM,IAAA,sBAAY,EAAC,OAAO,CAAC,SAAS,EAAE,OAAO,CAAC;aAC9D,IACD,CAAA;MAAA;CACH,CAAC"}
|
|
@@ -2,7 +2,5 @@ import { TokenResponse } from "../types/oidc";
|
|
|
2
2
|
import { OrgData } from "../types/org";
|
|
3
3
|
declare const loginPlugins: readonly ["google", "okta", "ping", "oidc-pkce", "microsoft", "azure-oidc", "google-oidc", "aws-oidc"];
|
|
4
4
|
export type LoginPluginType = (typeof loginPlugins)[number];
|
|
5
|
-
export declare const pluginLoginMap: Record<string, (org: OrgData
|
|
6
|
-
debug?: boolean;
|
|
7
|
-
}) => Promise<TokenResponse>>;
|
|
5
|
+
export declare const pluginLoginMap: Record<string, (org: OrgData) => Promise<TokenResponse>>;
|
|
8
6
|
export {};
|
|
@@ -41,12 +41,12 @@ exports.pluginLoginMap = {
|
|
|
41
41
|
okta: login_4.oktaLogin,
|
|
42
42
|
ping: login_5.pingLogin,
|
|
43
43
|
"google-oidc": login_3.googleLogin,
|
|
44
|
-
"oidc-pkce": (org
|
|
44
|
+
"oidc-pkce": (org) => __awaiter(void 0, void 0, void 0, function* () {
|
|
45
45
|
const providerType = (0, authUtils_1.getProviderType)(org);
|
|
46
46
|
if (!providerType) {
|
|
47
47
|
throw "Missing provider type for OIDC PKCE login";
|
|
48
48
|
}
|
|
49
|
-
return yield exports.pluginLoginMap[providerType](org
|
|
49
|
+
return yield exports.pluginLoginMap[providerType](org);
|
|
50
50
|
}),
|
|
51
51
|
password: login_2.emailPasswordLogin,
|
|
52
52
|
"azure-oidc": login_1.azureLogin,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"login.js","sourceRoot":"","sources":["../../../src/plugins/login.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;GASG;AACH,kDAAqD;AAGrD,yCAA2C;AAC3C,yCAAmD;AACnD,0CAA6C;AAC7C,wCAAyC;AACzC,wCAAyC;AAEzC,MAAM,YAAY,GAAG;IACnB,QAAQ;IACR,MAAM;IACN,MAAM;IACN,WAAW;IACX,WAAW;IACX,YAAY;IACZ,aAAa;IACb,UAAU;CACF,CAAC;AAIE,QAAA,cAAc,GAGvB;IACF,MAAM,EAAE,mBAAW;IACnB,IAAI,EAAE,iBAAS;IACf,IAAI,EAAE,iBAAS;IACf,aAAa,EAAE,mBAAW;IAC1B,WAAW,EAAE,CAAO,GAAG,EAAE,
|
|
1
|
+
{"version":3,"file":"login.js","sourceRoot":"","sources":["../../../src/plugins/login.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;GASG;AACH,kDAAqD;AAGrD,yCAA2C;AAC3C,yCAAmD;AACnD,0CAA6C;AAC7C,wCAAyC;AACzC,wCAAyC;AAEzC,MAAM,YAAY,GAAG;IACnB,QAAQ;IACR,MAAM;IACN,MAAM;IACN,WAAW;IACX,WAAW;IACX,YAAY;IACZ,aAAa;IACb,UAAU;CACF,CAAC;AAIE,QAAA,cAAc,GAGvB;IACF,MAAM,EAAE,mBAAW;IACnB,IAAI,EAAE,iBAAS;IACf,IAAI,EAAE,iBAAS;IACf,aAAa,EAAE,mBAAW;IAC1B,WAAW,EAAE,CAAO,GAAG,EAAE,EAAE;QACzB,MAAM,YAAY,GAAG,IAAA,2BAAe,EAAC,GAAG,CAAC,CAAC;QAC1C,IAAI,CAAC,YAAY,EAAE;YACjB,MAAM,2CAA2C,CAAC;SACnD;QACD,OAAO,MAAM,sBAAc,CAAC,YAAY,CAAE,CAAC,GAAG,CAAC,CAAC;IAClD,CAAC,CAAA;IACD,QAAQ,EAAE,0BAAkB;IAC5B,YAAY,EAAE,kBAAU;CACzB,CAAC"}
|
|
@@ -2,16 +2,8 @@ import { Identity } from "../../types/identity";
|
|
|
2
2
|
import { TokenResponse } from "../../types/oidc";
|
|
3
3
|
import { OrgData } from "../../types/org";
|
|
4
4
|
import { AwsFederatedLogin } from "../aws/types";
|
|
5
|
-
/** Logs in to Okta via OIDC
|
|
6
|
-
|
|
7
|
-
* Requests `offline_access` so we can silently refresh the access token at TTL.
|
|
8
|
-
* Some Okta tenants disallow this scope at the app config — in that case
|
|
9
|
-
* `/device/authorize` returns `invalid_scope`; we retry once without it and
|
|
10
|
-
* proceed with the legacy device-only flow.
|
|
11
|
-
*/
|
|
12
|
-
export declare const oktaLogin: (org: OrgData, options?: {
|
|
13
|
-
debug?: boolean;
|
|
14
|
-
}) => Promise<TokenResponse>;
|
|
5
|
+
/** Logs in to Okta via OIDC */
|
|
6
|
+
export declare const oktaLogin: (org: OrgData) => Promise<TokenResponse>;
|
|
15
7
|
/**
|
|
16
8
|
* Converts OIDC tokens into a SAML assertion for AWS federated authentication.
|
|
17
9
|
*
|
|
@@ -140,44 +140,18 @@ const fetchSamlResponse = (org, { access_token }) => __awaiter(void 0, void 0, v
|
|
|
140
140
|
const samlInputValue = $('input[name="SAMLResponse"]').val();
|
|
141
141
|
return typeof samlInputValue === "string" ? samlInputValue : undefined;
|
|
142
142
|
});
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
const OKTA_OFFLINE_SCOPE = `${OKTA_BASE_SCOPE} offline_access`;
|
|
156
|
-
/** Logs in to Okta via OIDC.
|
|
157
|
-
*
|
|
158
|
-
* Requests `offline_access` so we can silently refresh the access token at TTL.
|
|
159
|
-
* Some Okta tenants disallow this scope at the app config — in that case
|
|
160
|
-
* `/device/authorize` returns `invalid_scope`; we retry once without it and
|
|
161
|
-
* proceed with the legacy device-only flow.
|
|
162
|
-
*/
|
|
163
|
-
const oktaLogin = (org, options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
164
|
-
const urls = oktaOidcUrls(org);
|
|
165
|
-
try {
|
|
166
|
-
const tokenResponse = yield (0, login_1.oidcLogin)((0, login_1.oidcLoginSteps)(org, OKTA_OFFLINE_SCOPE, urls));
|
|
167
|
-
if (!tokenResponse.refresh_token && (options === null || options === void 0 ? void 0 : options.debug)) {
|
|
168
|
-
(0, stdio_1.print2)("Okta token response omitted refresh_token; CLI will re-prompt for auth at session TTL.");
|
|
169
|
-
}
|
|
170
|
-
return tokenResponse;
|
|
171
|
-
}
|
|
172
|
-
catch (e) {
|
|
173
|
-
const message = e instanceof Error ? e.message : String(e);
|
|
174
|
-
if (!message.includes("invalid_scope"))
|
|
175
|
-
throw e;
|
|
176
|
-
if (options === null || options === void 0 ? void 0 : options.debug) {
|
|
177
|
-
(0, stdio_1.print2)("Okta tenant rejected offline_access; retrying without it.");
|
|
178
|
-
}
|
|
179
|
-
return yield (0, login_1.oidcLogin)((0, login_1.oidcLoginSteps)(org, OKTA_BROWSER_SCOPE, urls));
|
|
180
|
-
}
|
|
143
|
+
/** Logs in to Okta via OIDC */
|
|
144
|
+
const oktaLogin = (org) => __awaiter(void 0, void 0, void 0, function* () {
|
|
145
|
+
return (0, login_1.oidcLogin)((0, login_1.oidcLoginSteps)(org, "openid email profile okta.apps.sso", () => {
|
|
146
|
+
const providerType = (0, authUtils_1.getProviderType)(org);
|
|
147
|
+
const providerDomain = (0, authUtils_1.getProviderDomain)(org);
|
|
148
|
+
(0, node_assert_1.default)(providerType === "okta", "Invalid provider configuration (expected okta OIDC provider)");
|
|
149
|
+
(0, node_assert_1.default)(providerDomain, "Invalid provider configuration (missing Okta domain)");
|
|
150
|
+
return {
|
|
151
|
+
deviceAuthorizationUrl: `https://${providerDomain}/oauth2/v1/device/authorize`,
|
|
152
|
+
tokenUrl: `https://${providerDomain}/oauth2/v1/token`,
|
|
153
|
+
};
|
|
154
|
+
}));
|
|
181
155
|
});
|
|
182
156
|
exports.oktaLogin = oktaLogin;
|
|
183
157
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"login.js","sourceRoot":"","sources":["../../../../src/plugins/okta/login.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;GASG;AACH,iDAAsD;AACtD,8CAI4B;AAC5B,6CAAoD;AACpD,+CAA6C;AAC7C,qDAI+B;AAK/B,yCAIuB;AACvB,iDAAmC;AACnC,mCAA8B;AAC9B,8DAAiC;AAEjC,MAAM,iBAAiB,GAAG,+CAA+C,CAAC;AAC1E,MAAM,aAAa,GAAG,2CAA2C,CAAC;AAClE,MAAM,mBAAmB,GAAG,iDAAiD,CAAC;AAC9E,MAAM,kBAAkB,GAAG,yCAAyC,CAAC;AAErE,MAAM,uBAAuB,GAAG;IAC9B,8EAA8E;IAC9E,8FAA8F;CAC/F,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,gBAAgB,GAAG,CACvB,KAAa,EACb,EAAE,GAAG,EAAE,UAAU,EAAY,EAC7B,KAAe,EACf,EAAE;IACF,MAAM,YAAY,GAAG,IAAA,2BAAe,EAAC,GAAG,CAAC,CAAC;IAC1C,MAAM,cAAc,GAAG,IAAA,6BAAiB,EAAC,GAAG,CAAC,CAAC;IAC9C,MAAM,QAAQ,GAAG,IAAA,uBAAW,EAAC,GAAG,CAAC,CAAC;IAElC,IAAI,YAAY,KAAK,MAAM,IAAI,CAAC,cAAc,IAAI,CAAC,QAAQ,EAAE;QAC3D,MAAM,wDAAwD,CAAC;KAChE;IAED,MAAM,IAAI,GAAG;QACX,MAAM,EAAE,MAAM;QACd,OAAO,EAAE,mBAAY;QACrB,IAAI,EAAE,IAAA,iBAAS,EAAC;YACd,QAAQ,EAAE,iBAAiB,KAAK,EAAE;YAClC,SAAS,EAAE,QAAQ;YACnB,WAAW,EAAE,UAAU,CAAC,YAAY;YACpC,gBAAg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