mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-11-02 16:58:52 +01:00
fix(server): scrub hidden issue audit details
Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
1 parent
cd96a89250
commit
0d4979ba44
2 files changed
+30
-4
No files matched your search
@@ -191,16 +191,37 @@ describePostgres("agent action audit routes", () => {
|
||||
authorAgentId: agent.id,
|
||||
body: "Hidden audit comment",
|
||||
}).returning().then((rows) => rows[0]!);
|
||||
const [hiddenActivity, mismatchedActivity] = await db.insert(activityLog).values([
|
||||
const [hiddenActivity, hiddenDocumentActivity, mismatchedActivity] = await db.insert(activityLog).values([
|
||||
{
|
||||
companyId: company.id,
|
||||
actorType: "agent",
|
||||
actorId: agent.id,
|
||||
action: "issue.comment.created",
|
||||
entityType: "issue_comment",
|
||||
entityId: hiddenComment.id,
|
||||
entityType: "issue",
|
||||
entityId: hiddenIssue.id,
|
||||
agentId: agent.id,
|
||||
runId: run.id,
|
||||
details: {
|
||||
commentId: hiddenComment.id,
|
||||
bodySnippet: hiddenComment.body,
|
||||
identifier: hiddenIssue.identifier,
|
||||
issueTitle: hiddenIssue.title,
|
||||
},
|
||||
},
|
||||
{
|
||||
companyId: company.id,
|
||||
actorType: "agent",
|
||||
actorId: agent.id,
|
||||
action: "issue.document_updated",
|
||||
entityType: "issue",
|
||||
entityId: hiddenIssue.id,
|
||||
agentId: agent.id,
|
||||
runId: run.id,
|
||||
details: {
|
||||
documentId: randomUUID(),
|
||||
key: "plan",
|
||||
title: "Hidden document title",
|
||||
},
|
||||
},
|
||||
{
|
||||
companyId: company.id,
|
||||
@@ -223,6 +244,8 @@ describePostgres("agent action audit routes", () => {
|
||||
comment: null,
|
||||
document: null,
|
||||
});
|
||||
expect(response.body.items.find((item: { id: string }) => item.id === hiddenActivity.id)?.details).toBeNull();
|
||||
expect(response.body.items.find((item: { id: string }) => item.id === hiddenDocumentActivity.id)?.details).toBeNull();
|
||||
expect(response.body.items.find((item: { id: string }) => item.id === mismatchedActivity.id)?.entity).toEqual({
|
||||
issue: null,
|
||||
comment: null,
|
||||
|
||||
@@ -151,9 +151,12 @@ export function agentActionAuditService(db: Db) {
|
||||
: document
|
||||
? { id: document.issueId, identifier: document.identifier, title: document.title }
|
||||
: issue ? { id: issue.id, identifier: issue.identifier, title: issue.title } : null;
|
||||
const isIssueDerived = row.entityType === "issue"
|
||||
|| row.entityType === "issue_comment"
|
||||
|| row.entityType === "issue_document";
|
||||
return {
|
||||
...row,
|
||||
details: redactDetails(row.details),
|
||||
details: isIssueDerived && !issueSnippet ? null : redactDetails(row.details),
|
||||
entity: {
|
||||
issue: issueSnippet,
|
||||
comment: comment ? { id: comment.id, excerpt: excerpt(comment.body) } : null,
|
||||
|
||||
Reference in new issue
Block a user