From 49662b58df2d4ab2d59880f09b4702c2c53e984e Mon Sep 17 00:00:00 2001 From: varunalla Date: Thu, 4 Apr 2024 19:03:15 -0700 Subject: [PATCH 1/3] Support migrated ssh integration --- src/commands/ssh.ts | 12 ++++++------ src/plugins/ssh/types.ts | 8 ++------ 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/src/commands/ssh.ts b/src/commands/ssh.ts index 9c46cb3..41632ea 100644 --- a/src/commands/ssh.ts +++ b/src/commands/ssh.ts @@ -100,12 +100,12 @@ const validateSshInstall = async (authn: Authn) => { const configDoc = await getDoc( doc(`o/${authn.identity.org.tenantId}/integrations/ssh`) ); - const items = configDoc - .data() - ?.workflows?.items.filter( - (i) => i.state === "installed" && i.type === "aws" - ); - if (!items?.length) { + const configItems = configDoc.data()?.["iam-write"]; + + const items = Object.entries(configItems ?? {}).filter( + ([key, value]) => value.state == "installed" && key.startsWith("aws") + ); + if (items.length === 0) { throw "This organization is not configured for SSH access via the P0 CLI"; } }; diff --git a/src/plugins/ssh/types.ts b/src/plugins/ssh/types.ts index 28d43db..8f15181 100644 --- a/src/plugins/ssh/types.ts +++ b/src/plugins/ssh/types.ts @@ -9,14 +9,10 @@ This file is part of @p0security/cli You should have received a copy of the GNU General Public License along with @p0security/cli. If not, see . **/ type SshItemConfig = { - alias?: string; - identifier: string; + label?: string; state: string; - type: "aws" | "gcloud"; }; export type SshConfig = { - workflows?: { - items: SshItemConfig[]; - }; + "iam-write": Record; }; From 55a09cad48d100cea4271b5df56ec06930940492 Mon Sep 17 00:00:00 2001 From: varunalla Date: Thu, 4 Apr 2024 19:14:35 -0700 Subject: [PATCH 2/3] Fix tests --- src/commands/__tests__/ssh.test.ts | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/commands/__tests__/ssh.test.ts b/src/commands/__tests__/ssh.test.ts index f6a849f..624abf0 100644 --- a/src/commands/__tests__/ssh.test.ts +++ b/src/commands/__tests__/ssh.test.ts @@ -29,14 +29,10 @@ const mockPrint1 = print1 as jest.Mock; const mockPrint2 = print2 as jest.Mock; mockGetDoc({ - workflows: { - items: [ - { - state: "installed", - type: "aws", - identifier: "test-account", - }, - ], + "iam-write": { + ["aws:test-account"]: { + state: "installed", + }, }, }); From c7662d8cc1fa31d03add97348478d61799d53c0d Mon Sep 17 00:00:00 2001 From: varunalla Date: Wed, 10 Apr 2024 14:28:31 -0700 Subject: [PATCH 3/3] updated version number --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 3b1a46a..5c09333 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@p0security/cli", - "version": "0.5.0", + "version": "0.5.2", "description": "Execute infra CLI commands with P0 grants", "main": "index.ts", "repository": {