diff --git a/package.json b/package.json index 2aa59dc..5c09333 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@p0security/cli", - "version": "0.5.1", + "version": "0.5.2", "description": "Execute infra CLI commands with P0 grants", "main": "index.ts", "repository": { 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", + }, }, }); diff --git a/src/commands/ssh.ts b/src/commands/ssh.ts index c16ae7b..78933d1 100644 --- a/src/commands/ssh.ts +++ b/src/commands/ssh.ts @@ -105,12 +105,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; };