-
Notifications
You must be signed in to change notification settings - Fork 1.8k
feat(pam): real-time session log sync via incremental batch uploads #5965
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
Merged
Merged
Changes from 6 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
c1faca1
feat(pam): real-time session log sync via incremental batch uploads
bernie-g 705acde
docs(pam): update session recording docs to reflect incremental uploads
bernie-g 1920591
fix(pam): add org-level gateway permission check to uploadEventBatch
bernie-g e05feb7
style(pam): reformat refetchInterval ternary
bernie-g d890840
fix(pam): remove PAM_SESSION_GET audit log from polled read endpoint
bernie-g 74253b6
Merge remote-tracking branch 'origin/main' into feat/pam-session-real…
bernie-g 0ce5cf3
fix(pam): paginate session logs to prevent unbounded memory load
bernie-g f2ce797
fix(pam): remove live refresh from session view, restore PAM_SESSION_…
bernie-g 0305400
fix(pam): validate event batch payload schema before encrypting
bernie-g 8c15154
fix(pam): skip audit log for event batch upserts (retries)
bernie-g 05b16f3
fix(pam): handle invalid JSON in event-batch upload with 400
bernie-g 53ac562
fix(pam): cast xmax result to satisfy TypeScript
bernie-g a684151
feat(pam): replace infinite scroll with cursor-based live log polling
bernie-g 2f4a8e1
feat(pam): live poll for active sessions, load more for completed
bernie-g b1c146f
feat(pam): paginate completed session logs by event count (5000/page)
bernie-g 34d3565
feat(pam): add LIVE indicator to session logs and revert page size to…
bernie-g fd32ef2
feat(pam): move LIVE badge inline next to session logs header
bernie-g f4929d5
feat(pam): animate LIVE badge with pulse
bernie-g File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
backend/src/db/migrations/20260407000001_pam-session-event-batches.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| import { Knex } from "knex"; | ||
|
|
||
| import { TableName } from "../schemas"; | ||
| import { createOnUpdateTrigger, dropOnUpdateTrigger } from "../utils"; | ||
|
|
||
| export async function up(knex: Knex): Promise<void> { | ||
| if (!(await knex.schema.hasTable(TableName.PamSessionEventBatch))) { | ||
| await knex.schema.createTable(TableName.PamSessionEventBatch, (t) => { | ||
| t.uuid("id", { primaryKey: true }).defaultTo(knex.fn.uuid()); | ||
|
|
||
| t.uuid("sessionId").notNullable(); | ||
| t.foreign("sessionId").references("id").inTable(TableName.PamSession).onDelete("CASCADE"); | ||
| t.index("sessionId"); | ||
|
|
||
| t.bigInteger("startOffset").notNullable(); | ||
| t.binary("encryptedEventsBlob").notNullable(); | ||
|
|
||
| t.timestamps(true, true, true); | ||
|
|
||
| t.unique(["sessionId", "startOffset"]); | ||
| }); | ||
|
|
||
| await createOnUpdateTrigger(knex, TableName.PamSessionEventBatch); | ||
| } | ||
| } | ||
|
|
||
| export async function down(knex: Knex): Promise<void> { | ||
| await dropOnUpdateTrigger(knex, TableName.PamSessionEventBatch); | ||
| await knex.schema.dropTableIfExists(TableName.PamSessionEventBatch); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| // Code generated by automation script, DO NOT EDIT. | ||
| // Automated by pulling database and generating zod schema | ||
| // To update. Just run npm run generate:schema | ||
| // Written by akhilmhdh. | ||
|
|
||
| import { z } from "zod"; | ||
|
|
||
| import { zodBuffer } from "@app/lib/zod"; | ||
|
|
||
| import { TImmutableDBKeys } from "./models"; | ||
|
|
||
| export const PamSessionEventBatchesSchema = z.object({ | ||
| id: z.string().uuid(), | ||
| sessionId: z.string().uuid(), | ||
| startOffset: z.coerce.number(), | ||
| encryptedEventsBlob: zodBuffer, | ||
| createdAt: z.date(), | ||
| updatedAt: z.date() | ||
| }); | ||
|
|
||
| export type TPamSessionEventBatches = z.infer<typeof PamSessionEventBatchesSchema>; | ||
| export type TPamSessionEventBatchesInsert = Omit<z.input<typeof PamSessionEventBatchesSchema>, TImmutableDBKeys>; | ||
| export type TPamSessionEventBatchesUpdate = Partial< | ||
| Omit<z.input<typeof PamSessionEventBatchesSchema>, TImmutableDBKeys> | ||
| >; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
backend/src/ee/services/pam-session/pam-session-event-batch-dal.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| import { Knex } from "knex"; | ||
|
|
||
| import { TDbClient } from "@app/db"; | ||
| import { TableName } from "@app/db/schemas"; | ||
| import { ormify } from "@app/lib/knex"; | ||
|
|
||
| export type TPamSessionEventBatchDALFactory = ReturnType<typeof pamSessionEventBatchDALFactory>; | ||
|
|
||
| export const pamSessionEventBatchDALFactory = (db: TDbClient) => { | ||
| const orm = ormify(db, TableName.PamSessionEventBatch); | ||
|
|
||
| const findBySessionId = async (sessionId: string, tx?: Knex) => { | ||
| return (tx || db.replicaNode())(TableName.PamSessionEventBatch) | ||
| .where("sessionId", sessionId) | ||
| .orderBy("startOffset", "asc") | ||
| .select("*"); | ||
| }; | ||
|
|
||
| const upsertBatch = async (sessionId: string, startOffset: number, encryptedEventsBlob: Buffer, tx?: Knex) => { | ||
| return (tx || db)(TableName.PamSessionEventBatch) | ||
| .insert({ sessionId, startOffset, encryptedEventsBlob }) | ||
| .onConflict(["sessionId", "startOffset"]) | ||
| .merge(["encryptedEventsBlob"]); // on re-upload of the same offset, overwrite the blob instead of erroring or skipping | ||
| }; | ||
|
|
||
| return { ...orm, findBySessionId, upsertBatch }; | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.