mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-04 02:26:19 +00:00
Add http events
This commit is contained in:
@@ -7,6 +7,7 @@ import { MySQLSessionCredentialsSchema } from "@app/ee/services/pam-resource/mys
|
|||||||
import { PostgresSessionCredentialsSchema } from "@app/ee/services/pam-resource/postgres/postgres-resource-schemas";
|
import { PostgresSessionCredentialsSchema } from "@app/ee/services/pam-resource/postgres/postgres-resource-schemas";
|
||||||
import { SSHSessionCredentialsSchema } from "@app/ee/services/pam-resource/ssh/ssh-resource-schemas";
|
import { SSHSessionCredentialsSchema } from "@app/ee/services/pam-resource/ssh/ssh-resource-schemas";
|
||||||
import {
|
import {
|
||||||
|
HttpEventSchema,
|
||||||
PamSessionCommandLogSchema,
|
PamSessionCommandLogSchema,
|
||||||
SanitizedSessionSchema,
|
SanitizedSessionSchema,
|
||||||
TerminalEventSchema
|
TerminalEventSchema
|
||||||
@@ -91,7 +92,7 @@ export const registerPamSessionRouter = async (server: FastifyZodProvider) => {
|
|||||||
sessionId: z.string().uuid()
|
sessionId: z.string().uuid()
|
||||||
}),
|
}),
|
||||||
body: z.object({
|
body: z.object({
|
||||||
logs: z.array(z.union([PamSessionCommandLogSchema, TerminalEventSchema]))
|
logs: z.array(z.union([PamSessionCommandLogSchema, TerminalEventSchema, HttpEventSchema]))
|
||||||
}),
|
}),
|
||||||
response: {
|
response: {
|
||||||
200: z.object({
|
200: z.object({
|
||||||
|
|||||||
@@ -11,6 +11,8 @@ export const PamSessionCommandLogSchema = z.object({
|
|||||||
// SSH Terminal Event schemas
|
// SSH Terminal Event schemas
|
||||||
export const TerminalEventTypeSchema = z.enum(["input", "output", "resize", "error"]);
|
export const TerminalEventTypeSchema = z.enum(["input", "output", "resize", "error"]);
|
||||||
|
|
||||||
|
export const HttpEventTypeSchema = z.enum(["request", "response"]);
|
||||||
|
|
||||||
export const TerminalEventSchema = z.object({
|
export const TerminalEventSchema = z.object({
|
||||||
timestamp: z.coerce.date(),
|
timestamp: z.coerce.date(),
|
||||||
eventType: TerminalEventTypeSchema,
|
eventType: TerminalEventTypeSchema,
|
||||||
@@ -18,8 +20,30 @@ export const TerminalEventSchema = z.object({
|
|||||||
elapsedTime: z.number() // Seconds since session start (for replay)
|
elapsedTime: z.number() // Seconds since session start (for replay)
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export const HttpBaseEventSchema = z.object({
|
||||||
|
timestamp: z.coerce.date(),
|
||||||
|
requestId: z.string(),
|
||||||
|
eventType: TerminalEventTypeSchema,
|
||||||
|
headers: z.record(z.string(), z.string())
|
||||||
|
});
|
||||||
|
|
||||||
|
export const HttpRequestEventSchema = HttpBaseEventSchema.extend({
|
||||||
|
eventType: z.literal(HttpEventTypeSchema.Values.request),
|
||||||
|
method: z.string(),
|
||||||
|
url: z.string(),
|
||||||
|
body: z.string()
|
||||||
|
});
|
||||||
|
|
||||||
|
export const HttpResponseEventSchema = HttpBaseEventSchema.extend({
|
||||||
|
eventType: z.literal(HttpEventTypeSchema.Values.response),
|
||||||
|
status: z.string(),
|
||||||
|
body: z.string()
|
||||||
|
});
|
||||||
|
|
||||||
|
export const HttpEventSchema = z.discriminatedUnion("eventType", [HttpRequestEventSchema, HttpResponseEventSchema]);
|
||||||
|
|
||||||
export const SanitizedSessionSchema = PamSessionsSchema.omit({
|
export const SanitizedSessionSchema = PamSessionsSchema.omit({
|
||||||
encryptedLogsBlob: true
|
encryptedLogsBlob: true
|
||||||
}).extend({
|
}).extend({
|
||||||
logs: z.array(z.union([PamSessionCommandLogSchema, TerminalEventSchema]))
|
logs: z.array(z.union([PamSessionCommandLogSchema, TerminalEventSchema, HttpEventSchema]))
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user