Skip to content

Commit 2c7a0f3

Browse files
authored
Merge pull request #2460 from trycompai/main
[comp] Production Deploy
2 parents 1549cd8 + 540b2fc commit 2c7a0f3

32 files changed

+2118
-555
lines changed

apps/api/src/audit/audit-log.interceptor.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import {
2424
type ChangesRecord,
2525
buildChanges,
2626
buildDescription,
27+
extractActionDescription,
2728
extractCommentContext,
2829
extractDownloadDescription,
2930
extractEntityId,
@@ -129,6 +130,10 @@ export class AuditLogInterceptor implements NestInterceptor {
129130
responseBody,
130131
requestBody,
131132
);
133+
const actionDesc = extractActionDescription(
134+
request.url,
135+
method,
136+
);
132137
const downloadDesc = extractDownloadDescription(
133138
request.url,
134139
method,
@@ -145,7 +150,7 @@ export class AuditLogInterceptor implements NestInterceptor {
145150
(request as { userRoles?: string[] }).userRoles,
146151
);
147152
let descriptionOverride: string | null =
148-
versionDesc ?? downloadDesc ?? policyActionDesc ?? findingDesc;
153+
actionDesc ?? versionDesc ?? downloadDesc ?? policyActionDesc ?? findingDesc;
149154

150155
const isAutomationUpdate = policyActionDesc && /automations/.test(request.url) && method === 'PATCH';
151156
const isAttachmentAction = policyActionDesc && /attachments/.test(request.url);

apps/api/src/audit/audit-log.utils.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,25 @@ export function extractCommentContext(
5555
return null;
5656
}
5757

58+
/**
59+
* Detects action sub-endpoints (e.g. trigger-assessment) on resources
60+
* and returns a human-readable description instead of the generic
61+
* "Created <resource>" that the POST method would produce.
62+
*/
63+
export function extractActionDescription(
64+
path: string,
65+
method: string,
66+
): string | null {
67+
if (method !== 'POST') return null;
68+
69+
const pathWithoutQuery = path.split('?')[0]!;
70+
71+
if (/\/vendors\/[^/]+\/trigger-assessment\/?$/.test(pathWithoutQuery))
72+
return 'Triggered vendor risk assessment';
73+
74+
return null;
75+
}
76+
5877
/**
5978
* Detects download/export GET endpoints and returns a human-readable
6079
* description. Returns null for non-download endpoints.

0 commit comments

Comments
 (0)