From 6a7d84f05295f746261948d73cc567a03a8cea46 Mon Sep 17 00:00:00 2001 From: x032205 Date: Thu, 2 Oct 2025 18:57:47 -0400 Subject: [PATCH] greptile review fixes + schema generate --- backend/src/db/schemas/pam-resources.ts | 2 +- backend/src/db/schemas/pam-sessions.ts | 2 +- backend/src/ee/routes/v1/pam-session-router.ts | 3 ++- backend/src/ee/services/audit-log/audit-log-types.ts | 1 + backend/src/ee/services/pam-account/pam-account-service.ts | 1 + backend/src/ee/services/pam-resource/pam-resource-schemas.ts | 2 +- .../pam-resource/postgres/postgres-resource-schemas.ts | 4 ++-- 7 files changed, 9 insertions(+), 6 deletions(-) diff --git a/backend/src/db/schemas/pam-resources.ts b/backend/src/db/schemas/pam-resources.ts index bc3d45fcb..d34017d0f 100644 --- a/backend/src/db/schemas/pam-resources.ts +++ b/backend/src/db/schemas/pam-resources.ts @@ -13,7 +13,7 @@ export const PamResourcesSchema = z.object({ id: z.string().uuid(), projectId: z.string(), name: z.string(), - gatewayId: z.string(), + gatewayId: z.string().uuid(), resourceType: z.string(), encryptedConnectionDetails: zodBuffer, createdAt: z.date(), diff --git a/backend/src/db/schemas/pam-sessions.ts b/backend/src/db/schemas/pam-sessions.ts index a35f01eaf..12e4adfcf 100644 --- a/backend/src/db/schemas/pam-sessions.ts +++ b/backend/src/db/schemas/pam-sessions.ts @@ -23,7 +23,7 @@ export const PamSessionsSchema = z.object({ actorUserAgent: z.string(), status: z.string(), encryptedLogsBlob: zodBuffer.nullable().optional(), - expiresAt: z.date().nullable().optional(), + expiresAt: z.date(), startedAt: z.date().nullable().optional(), endedAt: z.date().nullable().optional(), createdAt: z.date(), diff --git a/backend/src/ee/routes/v1/pam-session-router.ts b/backend/src/ee/routes/v1/pam-session-router.ts index ac888b436..6e60704da 100644 --- a/backend/src/ee/routes/v1/pam-session-router.ts +++ b/backend/src/ee/routes/v1/pam-session-router.ts @@ -138,7 +138,8 @@ export const registerPamSessionRouter = async (server: FastifyZodProvider) => { event: { type: EventType.PAM_SESSION_END, metadata: { - sessionId: req.params.sessionId + sessionId: req.params.sessionId, + accountName: session.accountName } } }); diff --git a/backend/src/ee/services/audit-log/audit-log-types.ts b/backend/src/ee/services/audit-log/audit-log-types.ts index 6f46a4947..bc50283d4 100644 --- a/backend/src/ee/services/audit-log/audit-log-types.ts +++ b/backend/src/ee/services/audit-log/audit-log-types.ts @@ -3726,6 +3726,7 @@ interface PamSessionEndEvent { type: EventType.PAM_SESSION_END; metadata: { sessionId: string; + accountName: string; }; } diff --git a/backend/src/ee/services/pam-account/pam-account-service.ts b/backend/src/ee/services/pam-account/pam-account-service.ts index 2b2335281..76fcfdd54 100644 --- a/backend/src/ee/services/pam-account/pam-account-service.ts +++ b/backend/src/ee/services/pam-account/pam-account-service.ts @@ -405,6 +405,7 @@ export const pamAccountServiceFactory = ({ ); const user = await userDAL.findById(actor.id); + if (!user) throw new NotFoundError({ message: `User with ID '${actor.id}' not found` }); const gatewayConnectionDetails = await gatewayV2Service.getPAMConnectionDetails({ gatewayId, diff --git a/backend/src/ee/services/pam-resource/pam-resource-schemas.ts b/backend/src/ee/services/pam-resource/pam-resource-schemas.ts index b0f93110c..80a50a9a4 100644 --- a/backend/src/ee/services/pam-resource/pam-resource-schemas.ts +++ b/backend/src/ee/services/pam-resource/pam-resource-schemas.ts @@ -4,7 +4,7 @@ import { PamAccountsSchema, PamResourcesSchema } from "@app/db/schemas"; import { slugSchema } from "@app/server/lib/schemas"; // Resources -export const BasePamResoureSchema = PamResourcesSchema.omit({ +export const BasePamResourceSchema = PamResourcesSchema.omit({ encryptedConnectionDetails: true, resourceType: true }); diff --git a/backend/src/ee/services/pam-resource/postgres/postgres-resource-schemas.ts b/backend/src/ee/services/pam-resource/postgres/postgres-resource-schemas.ts index 520443248..a97e3f2e7 100644 --- a/backend/src/ee/services/pam-resource/postgres/postgres-resource-schemas.ts +++ b/backend/src/ee/services/pam-resource/postgres/postgres-resource-schemas.ts @@ -6,7 +6,7 @@ import { BaseCreatePamResourceSchema, BasePamAccountSchema, BasePamAccountSchemaWithResource, - BasePamResoureSchema, + BasePamResourceSchema, BaseUpdatePamAccountSchema, BaseUpdatePamResourceSchema } from "../pam-resource-schemas"; @@ -18,7 +18,7 @@ import { // Resources export const PostgresResourceConnectionDetailsSchema = BaseSqlResourceConnectionDetailsSchema; -const BasePostgresResourceSchema = BasePamResoureSchema.extend({ resourceType: z.literal(PamResource.Postgres) }); +const BasePostgresResourceSchema = BasePamResourceSchema.extend({ resourceType: z.literal(PamResource.Postgres) }); export const PostgresResourceSchema = BasePostgresResourceSchema.extend({ connectionDetails: PostgresResourceConnectionDetailsSchema