Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support migrated ssh integration #70

Merged
merged 5 commits into from
Apr 10, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 4 additions & 8 deletions src/commands/__tests__/ssh.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
},
},
});

Expand Down
12 changes: 6 additions & 6 deletions src/commands/ssh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,12 @@ const validateSshInstall = async (authn: Authn) => {
const configDoc = await getDoc<SshConfig, object>(
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";
}
};
Expand Down
8 changes: 2 additions & 6 deletions src/plugins/ssh/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 <https://www.gnu.org/licenses/>.
**/
type SshItemConfig = {
alias?: string;
identifier: string;
label?: string;
state: string;
type: "aws" | "gcloud";
};

export type SshConfig = {
workflows?: {
items: SshItemConfig[];
};
"iam-write": Record<string, SshItemConfig>;
};
Loading