Skip to content

Commit

Permalink
[v17] [web] Include node name or k8s cluster for session started audi…
Browse files Browse the repository at this point in the history
…t entry display (#49832)

* Include node name or k8s cluster for session started audit entry display

* update for order of variable assignment
  • Loading branch information
stevenGravy authored Dec 5, 2024
1 parent f92a739 commit eeeecb4
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
15 changes: 14 additions & 1 deletion web/packages/teleport/src/services/audit/makeEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,20 @@ export const formatters: Formatters = {
[eventCodes.SESSION_START]: {
type: 'session.start',
desc: 'Session Started',
format: ({ user, sid }) => `User [${user}] has started a session [${sid}]`,
format: event => {
const user = event.user || '';

if (event.proto === 'kube') {
if (!event.kubernetes_cluster) {
return `User [${user}] has started a Kubernetes session [${event.sid}]`;
}
return `User [${user}] has started a session [${event.sid}] on Kubernetes cluster [${event.kubernetes_cluster}]`;
}

const node =
event.server_hostname || event.server_addr || event.server_id;
return `User [${user}] has started a session [${event.sid}] on node [${node}] `;
},
},
[eventCodes.SESSION_UPLOAD]: {
type: 'session.upload',
Expand Down
5 changes: 5 additions & 0 deletions web/packages/teleport/src/services/audit/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -530,6 +530,11 @@ export type RawEvents = {
typeof eventCodes.SESSION_START,
{
sid: string;
kubernetes_cluster: string;
proto: string;
server_hostname: string;
server_addr: string;
server_id: string;
}
>;
[eventCodes.SESSION_REJECT]: RawEvent<
Expand Down

0 comments on commit eeeecb4

Please sign in to comment.