Skip to content

audit targetuser fix#38

Merged
dev-banane merged 2 commits intomainfrom
fix
Oct 18, 2025
Merged

audit targetuser fix#38
dev-banane merged 2 commits intomainfrom
fix

Conversation

@dev-banane
Copy link
Copy Markdown
Member

No description provided.

@1ceit 1ceit requested a review from Copilot October 18, 2025 20:07
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Adds target user identification to audit logs so actions can be tied to the affected user.

  • Add targetUserId to the audit log payload
  • Populate from request body with a null fallback

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment thread server/middleware/auditLogger.ts Outdated
adminId: req.user.userId,
adminUsername: req.user.username || 'Unknown',
actionType,
targetUserId: req.body?.userId || null,
Copy link

Copilot AI Oct 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

targetUserId is pulled directly from req.body, which is client-controlled and can be spoofed, leading to misleading audit trails. Derive the target user ID from a trusted source (e.g., route params, server-side resolved entity, or a value placed on res.locals by prior middleware) and validate its type before logging.

Suggested change
targetUserId: req.body?.userId || null,
targetUserId: (typeof res.locals.targetUserId === 'string' || typeof res.locals.targetUserId === 'number') ? res.locals.targetUserId : null,

Copilot uses AI. Check for mistakes.
Comment thread server/middleware/auditLogger.ts Outdated
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Copy Markdown
Collaborator

@1ceit 1ceit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sehr gut

@dev-banane dev-banane merged commit e2d66eb into main Oct 18, 2025
1 check passed
@1ceit 1ceit deleted the fix branch October 20, 2025 14:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants