Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.
TypeScript acmeagentsai-agentscertificate-managementdevsecopsenvironment-variableskubernetesopen-sourcepampkipostgresprivate-caprivileged-access-managementsecret-managementsecret-managersecretssecrets-managementsecuritysecurity-toolsvault
feat: added query size validation for audit log
=b52ec37f76ea
diff --git a/backend/src/ee/routes/v1/project-router.ts b/backend/src/ee/routes/v1/project-router.tsindex f8b0770eec..c7b7e50f57 100644--- a/backend/src/ee/routes/v1/project-router.ts+++ b/backend/src/ee/routes/v1/project-router.ts@@ -111,15 +111,38 @@ export const registerProjectRouter = async (server: FastifyZodProvider) => {params: z.object({workspaceId: z.string().trim().describe(AUDIT_LOGS.EXPORT.projectId)}),- querystring: z.object({- eventType: z.nativeEnum(EventType).optional().describe(AUDIT_LOGS.EXPORT.eventType),- userAgentType: z.nativeEnum(UserAgentType).optional().describe(AUDIT_LOGS.EXPORT.userAgentType),- startDate: z.string().datetime().optional().describe(AUDIT_LOGS.EXPORT.startDate),- endDate: z.string().datetime().default(new Date().toISOString()).describe(AUDIT_LOGS.EXPORT.endDate),- offset: z.coerce.number().default(0).describe(AUDIT_LOGS.EXPORT.offset),- limit: z.coerce.number().default(20).describe(AUDIT_LOGS.EXPORT.limit),- actor: z.string().optional().describe(AUDIT_LOGS.EXPORT.actor)- }),+ querystring: z+ .object({+ eventType: z.nativeEnum(EventType).optional().describe(AUDIT_LOGS.EXPORT.eventType),+ userAgentType: z.nativeEnum(UserAgentType).optional().describe(AUDIT_LOGS.EXPORT.userAgentType),+ startDate: z.string().datetime().optional().describe(AUDIT_LOGS.EXPORT.startDate),+ endDate: z.string().datetime().default(new Date().toISOString()).describe(AUDIT_LOGS.EXPORT.endDate),+ offset: z.coerce.number().default(0).describe(AUDIT_LOGS.EXPORT.offset),+ limit: z.coerce.number().max(1000).default(20).describe(AUDIT_LOGS.EXPORT.limit),+ actor: z.string().optional().describe(AUDIT_LOGS.EXPORT.actor)+ })+ .superRefine((el, ctx) => {+ if (el.endDate && el.startDate) {+ const startDate = new Date(el.startDate);+ const endDate = new Date(el.endDate);+ const maxAllowedDate = new Date(startDate);+ maxAllowedDate.setMonth(maxAllowedDate.getMonth() + 3);+ if (endDate < startDate) {+ ctx.addIssue({+ code: z.ZodIssueCode.custom,+ path: ["endDate"],+ message: "End date cannot be before start date"+ });+ }+ if (endDate > maxAllowedDate) {+ ctx.addIssue({+ code: z.ZodIssueCode.custom,+ path: ["endDate"],+ message: "Dates must be within 3 months"+ });+ }+ }+ }),response: {200: z.object({auditLogs: AuditLogsSchema.omit({diff --git a/backend/src/server/routes/v1/organization-router.ts b/backend/src/server/routes/v1/organization-router.tsindex 3d900b403d..f58f20af2e 100644--- a/backend/src/server/routes/v1/organization-router.ts+++ b/backend/src/server/routes/v1/organization-router.ts@@ -113,51 +113,73 @@ export const registerOrgRouter = async (server: FastifyZodProvider) => {hide: false,tags: [ApiDocsTags.AuditLogs],description: "Get all audit logs for an organization",- querystring: z.object({- projectId: z.string().optional().describe(AUDIT_LOGS.EXPORT.projectId),- environment: z.string().optional().describe(AUDIT_LOGS.EXPORT.environment),- actorType: z.nativeEnum(ActorType).optional(),- secretPath: z- .string()- .optional()- .transform((val) => (!val ? val : removeTrailingSlash(val)))- .describe(AUDIT_LOGS.EXPORT.secretPath),- secretKey: z.string().optional().describe(AUDIT_LOGS.EXPORT.secretKey),-- // eventType is split with , for multiple values, we need to transform it to array- eventType: z- .string()- .optional()- .transform((val) => (val ? val.split(",") : undefined)),- userAgentType: z.nativeEnum(UserAgentType).optional().describe(AUDIT_LOGS.EXPORT.userAgentType),- eventMetadata: z- .string()- .optional()- .transform((val) => {- if (!val) {- return undefined;- }+ querystring: z+ .object({+ projectId: z.string().optional().describe(AUDIT_LOGS.EXPORT.projectId),+ environment: z.string().optional().describe(AUDIT_LOGS.EXPORT.environment),+ actorType: z.nativeEnum(ActorType).optional(),+ secretPath: z+ .string()+ .optional()+ .transform((val) => (!val ? val : removeTrailingSlash(val)))+ .describe(AUDIT_LOGS.EXPORT.secretPath),+ secretKey: z.string().optional().describe(AUDIT_LOGS.EXPORT.secretKey),+ // eventType is split with , for multiple values, we need to transform it to array+ eventType: z+ .string()+ .optional()+ .transform((val) => (val ? val.split(",") : undefined)),+ userAgentType: z.nativeEnum(UserAgentType).optional().describe(AUDIT_LOGS.EXPORT.userAgentType),+ eventMetadata: z+ .string()+ .optional()+ .transform((val) => {+ if (!val) {+ return undefined;+ }- const pairs = val.split(",");+ const pairs = val.split(",");- return pairs.reduce(- (acc, pair) => {- const [key, value] = pair.split("=");- if (key && value) {- acc[key] = value;- }- return acc;- },- {} as Record<string, string>- );- })- .describe(AUDIT_LOGS.EXPORT.eventMetadata),- startDate: z.string().datetime().optional().describe(AUDIT_LOGS.EXPORT.startDate),- endDate: z.string().datetime().default(new Date().toISOString()).describe(AUDIT_LOGS.EXPORT.endDate),- offset: z.coerce.number().default(0).describe(AUDIT_LOGS.EXPORT.offset),- limit: z.coerce.number().default(20).describe(AUDIT_LOGS.EXPORT.limit),- actor: z.string().optional().describe(AUDIT_LOGS.EXPORT.actor)- }),+ return pairs.reduce(+ (acc, pair) => {+ const [key, value] = pair.split("=");+ if (key && value) {+ acc[key] = value;+ }+ return acc;+ },+ {} as Record<string, string>+ );+ })+ .describe(AUDIT_LOGS.EXPORT.eventMetadata),+ startDate: z.string().datetime().optional().describe(AUDIT_LOGS.EXPORT.startDate),+ endDate: z.string().datetime().default(new Date().toISOString()).describe(AUDIT_LOGS.EXPORT.endDate),+ offset: z.coerce.number().default(0).describe(AUDIT_LOGS.EXPORT.offset),+ limit: z.coerce.number().max(1000).default(20).describe(AUDIT_LOGS.EXPORT.limit),+ actor: z.string().optional().describe(AUDIT_LOGS.EXPORT.actor)+ })+ .superRefine((el, ctx) => {+ if (el.endDate && el.startDate) {+ const startDate = new Date(el.startDate);+ const endDate = new Date(el.endDate);+ const maxAllowedDate = new Date(startDate);+ maxAllowedDate.setMonth(maxAllowedDate.getMonth() + 3);+ if (endDate < startDate) {+ ctx.addIssue({+ code: z.ZodIssueCode.custom,+ path: ["endDate"],+ message: "End date cannot be before start date"+ });+ }+ if (endDate > maxAllowedDate) {+ ctx.addIssue({+ code: z.ZodIssueCode.custom,+ path: ["endDate"],+ message: "Dates must be within 3 months"+ });+ }+ }+ }),response: {200: z.object({auditLogs: AuditLogsSchema.omit({