From 8a43e8914a7a384205e8ccc241724758bbbc541c Mon Sep 17 00:00:00 2001 From: BrunoQuaresma Date: Tue, 25 Feb 2025 19:29:28 +0000 Subject: [PATCH 1/3] feat: support session audit log --- .../AuditLogDescription.tsx | 25 ++++++++++-- .../AuditLogRow/AuditLogRow.stories.tsx | 39 +++++++++++++++++++ .../AuditPage/AuditLogRow/AuditLogRow.tsx | 26 ++++++++----- 3 files changed, 78 insertions(+), 12 deletions(-) diff --git a/site/src/pages/AuditPage/AuditLogRow/AuditLogDescription/AuditLogDescription.tsx b/site/src/pages/AuditPage/AuditLogRow/AuditLogDescription/AuditLogDescription.tsx index 51d4e8ec910d9..d6b225a9d640f 100644 --- a/site/src/pages/AuditPage/AuditLogRow/AuditLogDescription/AuditLogDescription.tsx +++ b/site/src/pages/AuditPage/AuditLogRow/AuditLogDescription/AuditLogDescription.tsx @@ -11,12 +11,15 @@ interface AuditLogDescriptionProps { export const AuditLogDescription: FC = ({ auditLog, }) => { - let target = auditLog.resource_target.trim(); - let user = auditLog.user?.username.trim(); - if (auditLog.resource_type === "workspace_build") { return ; } + if (auditLog.additional_fields?.connection_type) { + return ; + } + + let target = auditLog.resource_target.trim(); + let user = auditLog.user?.username.trim(); // SSH key entries have no links if (auditLog.resource_type === "git_ssh_key") { @@ -57,3 +60,19 @@ export const AuditLogDescription: FC = ({ ); }; + +function AppSessionAuditLogDescription({ auditLog }: AuditLogDescriptionProps) { + const { connection_type, workspace_owner, workspace_name } = + auditLog.additional_fields; + + return ( + <> + {connection_type} session to {workspace_owner}'s{" "} + + {workspace_name} + {" "} + workspace{" "} + {auditLog.action === "disconnect" ? "closed" : "opened"} + + ); +} diff --git a/site/src/pages/AuditPage/AuditLogRow/AuditLogRow.stories.tsx b/site/src/pages/AuditPage/AuditLogRow/AuditLogRow.stories.tsx index 12d57b63047e8..863493019f17d 100644 --- a/site/src/pages/AuditPage/AuditLogRow/AuditLogRow.stories.tsx +++ b/site/src/pages/AuditPage/AuditLogRow/AuditLogRow.stories.tsx @@ -159,3 +159,42 @@ export const NoUserAgent: Story = { }, }, }; + +export const WithConnectionType: Story = { + args: { + showOrgDetails: true, + auditLog: { + id: "a26a8a29-9453-455c-8fdc-ce69d4e2c07b", + request_id: "0d649adb-016d-4d8f-8448-875bbdf30c74", + time: "2025-02-21T14:18:39.198013Z", + ip: "fd7a:115c:a1e0:4955:8019:f5d3:e126:b422", + user_agent: "", + resource_type: "workspace_agent", + resource_id: "a146c7e1-514b-4534-8f98-3f097fb83b11", + resource_target: "main", + resource_icon: "", + action: "disconnect", + diff: {}, + status_code: 0, + additional_fields: { + build_number: "5", + build_reason: "initiator", + workspace_id: "d28295ae-a2dc-4aa0-af3c-79a2d4c44c55", + workspace_name: "test", + connection_type: "VS Code", + workspace_owner: "admin", + }, + description: "{user} disconnected workspace agent {target}", + resource_link: "", + is_deleted: false, + organization_id: "0e6fa63f-b625-4a6f-ab5b-a8217f8c80b3", + organization: { + id: "0e6fa63f-b625-4a6f-ab5b-a8217f8c80b3", + name: "coder", + display_name: "Coder", + icon: "", + }, + user: null, + }, + }, +}; diff --git a/site/src/pages/AuditPage/AuditLogRow/AuditLogRow.tsx b/site/src/pages/AuditPage/AuditLogRow/AuditLogRow.tsx index 909fb7cf5646e..932cc3cd4efb4 100644 --- a/site/src/pages/AuditPage/AuditLogRow/AuditLogRow.tsx +++ b/site/src/pages/AuditPage/AuditLogRow/AuditLogRow.tsx @@ -128,6 +128,8 @@ export const AuditLogRow: FC = ({ + + {/* With multi-org, there is not enough space so show everything in a tooltip. */} {showOrgDetails ? ( @@ -203,13 +205,6 @@ export const AuditLogRow: FC = ({ )} )} - - - {auditLog.status_code.toString()} - @@ -218,7 +213,7 @@ export const AuditLogRow: FC = ({ {shouldDisplayDiff ? (
{}
) : ( -
+
)} @@ -232,6 +227,19 @@ export const AuditLogRow: FC = ({ ); }; +function StatusPill({ code }: { code: number }) { + const isHttp = code >= 100; + + return ( + + {code.toString()} + + ); +} + const styles = { auditLogCell: { padding: "0 !important", @@ -287,7 +295,7 @@ const styles = { width: "100%", }, - httpStatusPill: { + statusCodePill: { fontSize: 10, height: 20, paddingLeft: 10, From c30b2992de7a8ef927a97ea1b0af3ba1478eab7c Mon Sep 17 00:00:00 2001 From: Bruno Quaresma Date: Wed, 26 Feb 2025 13:58:34 -0300 Subject: [PATCH 2/3] Update site/src/pages/AuditPage/AuditLogRow/AuditLogDescription/AuditLogDescription.tsx Co-authored-by: Mathias Fredriksson --- .../AuditLogRow/AuditLogDescription/AuditLogDescription.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/site/src/pages/AuditPage/AuditLogRow/AuditLogDescription/AuditLogDescription.tsx b/site/src/pages/AuditPage/AuditLogRow/AuditLogDescription/AuditLogDescription.tsx index d6b225a9d640f..4b2a9b4df4df7 100644 --- a/site/src/pages/AuditPage/AuditLogRow/AuditLogDescription/AuditLogDescription.tsx +++ b/site/src/pages/AuditPage/AuditLogRow/AuditLogDescription/AuditLogDescription.tsx @@ -68,7 +68,7 @@ function AppSessionAuditLogDescription({ auditLog }: AuditLogDescriptionProps) { return ( <> {connection_type} session to {workspace_owner}'s{" "} - + {workspace_name} {" "} workspace{" "} From 773dd2b4e7526fe671620e61a01d379b4117e8f4 Mon Sep 17 00:00:00 2001 From: BrunoQuaresma Date: Wed, 26 Feb 2025 17:01:21 +0000 Subject: [PATCH 3/3] Show reason --- .../AuditLogRow/AuditLogRow.stories.tsx | 21 ++++++++++--------- .../AuditPage/AuditLogRow/AuditLogRow.tsx | 6 ++++++ 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/site/src/pages/AuditPage/AuditLogRow/AuditLogRow.stories.tsx b/site/src/pages/AuditPage/AuditLogRow/AuditLogRow.stories.tsx index 863493019f17d..8bb45aa39378b 100644 --- a/site/src/pages/AuditPage/AuditLogRow/AuditLogRow.stories.tsx +++ b/site/src/pages/AuditPage/AuditLogRow/AuditLogRow.stories.tsx @@ -164,24 +164,25 @@ export const WithConnectionType: Story = { args: { showOrgDetails: true, auditLog: { - id: "a26a8a29-9453-455c-8fdc-ce69d4e2c07b", - request_id: "0d649adb-016d-4d8f-8448-875bbdf30c74", - time: "2025-02-21T14:18:39.198013Z", - ip: "fd7a:115c:a1e0:4955:8019:f5d3:e126:b422", + id: "725ea2f2-faae-4bdd-a821-c2384a67d89c", + request_id: "a486c1cb-6acb-41c9-9bce-1f4f24a2e8ff", + time: "2025-02-24T10:20:08.054072Z", + ip: "fd7a:115c:a1e0:4fa5:9ccd:27e4:5d72:c66a", user_agent: "", resource_type: "workspace_agent", - resource_id: "a146c7e1-514b-4534-8f98-3f097fb83b11", + resource_id: "813311fb-bad3-4a92-98cd-09ee57e73d6e", resource_target: "main", resource_icon: "", action: "disconnect", diff: {}, - status_code: 0, + status_code: 255, additional_fields: { - build_number: "5", + reason: "process exited with error status: -1", + build_number: "1", build_reason: "initiator", - workspace_id: "d28295ae-a2dc-4aa0-af3c-79a2d4c44c55", - workspace_name: "test", - connection_type: "VS Code", + workspace_id: "6a7cfb32-d208-47bb-91d0-ec54b69912b6", + workspace_name: "test2", + connection_type: "SSH", workspace_owner: "admin", }, description: "{user} disconnected workspace agent {target}", diff --git a/site/src/pages/AuditPage/AuditLogRow/AuditLogRow.tsx b/site/src/pages/AuditPage/AuditLogRow/AuditLogRow.tsx index 932cc3cd4efb4..e5145ea86c966 100644 --- a/site/src/pages/AuditPage/AuditLogRow/AuditLogRow.tsx +++ b/site/src/pages/AuditPage/AuditLogRow/AuditLogRow.tsx @@ -171,6 +171,12 @@ export const AuditLogRow: FC = ({
)} + {auditLog.additional_fields?.reason && ( +
+

Reason:

+
{auditLog.additional_fields?.reason}
+
+ )} } > pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy