[Server/Client/Protocol] Reporting users + moderation queue functionality (#7091)
Some checks are pending
Build Desktop / Configure (push) Waiting to run
Build Desktop / Debian 13 (push) Blocked by required conditions
Build Desktop / Debian 12 (push) Blocked by required conditions
Build Desktop / Fedora 44 (push) Blocked by required conditions
Build Desktop / Fedora 43 (push) Blocked by required conditions
Build Desktop / Servatrice_Debian 12 (push) Blocked by required conditions
Build Desktop / Ubuntu 26.04 (push) Blocked by required conditions
Build Desktop / Ubuntu 24.04 (push) Blocked by required conditions
Build Desktop / Arch (push) Blocked by required conditions
Build Desktop / macOS 15 (push) Blocked by required conditions
Build Desktop / macOS 13 Intel (push) Blocked by required conditions
Build Desktop / macOS 14 (push) Blocked by required conditions
Build Desktop / macOS 15 Debug (push) Blocked by required conditions
Build Desktop / Windows 10 (push) Blocked by required conditions
Build Docker Image / amd64 & arm64 (push) Waiting to run

* [Server/Client/Protocol] Reporting users + moderation queue functionality

Took 6 minutes

Took 3 minutes

Took 8 seconds

Took 11 minutes

Took 12 minutes

Took 7 minutes

Took 15 seconds

Took 2 minutes

Took 1 minute


Took 30 seconds

Took 16 seconds

* CI Fix

Took 6 minutes

* CI Fix

Took 6 minutes

* [Protocol] Add moderation investigation commands

Adds the protocol layer for the moderation investigation suite:
- Command_GetUserSessions/GetUserAlts/GetModeratorLastLogins/ResetUserPassword/RemoveUserAvatar (1013-1017)
- Response extensions 1215-1219 with ServerInfo messages for sessions, alts, and staff logins
- last_login on Response_ReportUserInfo and warning_il on Response_WarnList

Took 2 minutes

* [Utility] Add warning categories parser with infraction levels

Parses the server's 'officialwarnings' setting (comma-separated, optional
'|IL' suffix) into WarningCategory structs so the client can display the
infraction level of each warning category. Includes GTest coverage.

* [Server] Add moderation investigation tools

Implements the server side of the moderation suite:
- getUserSessions/getUserAlts/getModeratorLastLogins/removeUserAvatar DB methods
- Handlers for all five new commands with audit records (PASSWORD_RESET,
  REMOVE_USER_AVATAR); password resets return a generated temporary password
- cmdGetWarnList now reports per-category infraction levels from the
  officialwarnings setting; cmdReportUserInfo reports last_login
- Update servatrice.ini.example with the warning taxonomy
- Password/avatar mutations report RespNameNotFound when the user does not exist

* [Client] Add moderation tab with investigate, password reset, and avatar removal

- New Moderation tab: search a user to show account info, alternate
  accounts, login sessions, and staff last logins; actions to reset the
  user's password (shows the generated temporary password) and remove the
  user's avatar
- 'Investigate user' entry in the user context menu opens the tab pre-loaded
  for that user
- Warning dialog shows the infraction level of each warning category
- Tab wired into TabSupervisor with a moderator-gated menu action, shortcut,
  and tabs.ini persistence (default closed)

* [Server/Client/Protocol] Address PR #7091 review: security, bug, and perf fixes

Security:
- Promote RESET_USER_PASSWORD to admin-only dispatch (was moderator-accessible)
- Reject password reset on users with equal/higher privilege than caller
- Notify affected user via Event_NotifyUser::CUSTOM when password is reset
- Add server-side category whitelist for reports
- Drop reporter name fallback in comment/details authorization (ID-only)
- Force password change: new DB column + login enforcement + client disconnect

Bugs:
- XSS via QTextEdit::append() → insertPlainText() in report tab and utils
- allNotified initialized to true even with empty recipients list
- Warning combo box: use currentData() instead of baked-in display text
- Report resolution now records who resolved (resolved_by column + audit)

Performance:
- IP-correlation subquery: add 6-month window + LIMIT 200
- getUserSessions: clamp limit to 500

Non-blocking:
- Palette-aware colors in report_utils.cpp (dark/light mode)
- Report list pagination: offset/limit fields + total_count in response
- SessionCommand enum gap comment for reserved values 1201-1203

Schema: 36→37 (force_password_change), 37→38 (resolved_by)

Took 12 minutes


Took 16 seconds

* Fix macOs pedantry

Took 5 minutes

---------

Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
This commit is contained in:
BruebachL 2026-08-21 15:00:13 +02:00 committed by GitHub
parent 9eafd90a91
commit ed4eb1cb31
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
83 changed files with 4768 additions and 43 deletions

View file

@ -35,10 +35,20 @@ set(PROTO_FILES
command_ready_start.proto
command_replay_delete_match.proto
command_replay_download.proto
command_replay_download_by_game_id.proto
command_replay_get_code.proto
command_replay_list.proto
command_replay_modify_match.proto
command_replay_submit_code.proto
command_report.proto
command_report_add_comment.proto
command_report_assign.proto
command_report_details.proto
command_report_list.proto
command_report_my_list.proto
command_report_resolve.proto
command_report_stats.proto
command_report_user_info.proto
command_reveal_cards.proto
command_reverse_turn.proto
command_roll_die.proto
@ -138,8 +148,19 @@ set(PROTO_FILES
response_password_salt.proto
response_register.proto
response_replay_download.proto
response_replay_download_by_game_id.proto
response_replay_get_code.proto
response_replay_list.proto
response_report_details.proto
response_report_list.proto
response_report_my_list.proto
response_report_stats.proto
response_report_user_info.proto
response_moderator_last_logins.proto
response_remove_user_avatar.proto
response_reset_user_password.proto
response_user_alts.proto
response_user_sessions.proto
response_viewlog_history.proto
response_warn_history.proto
response_warn_list.proto
@ -155,13 +176,17 @@ set(PROTO_FILES
serverinfo_deckstorage.proto
serverinfo_game.proto
serverinfo_gametype.proto
serverinfo_moderator_login.proto
serverinfo_player.proto
serverinfo_playerping.proto
serverinfo_playerproperties.proto
serverinfo_replay.proto
serverinfo_replay_match.proto
serverinfo_report.proto
serverinfo_room.proto
serverinfo_user.proto
serverinfo_user_alt.proto
serverinfo_user_session.proto
serverinfo_warning.proto
serverinfo_zone.proto
session_commands.proto

View file

@ -5,6 +5,7 @@ message AdminCommand {
SHUTDOWN_SERVER = 1001;
RELOAD_CONFIG = 1002;
ADJUST_MOD = 1003;
RESET_USER_PASSWORD = 1016;
}
extensions 100 to max;
}
@ -37,3 +38,10 @@ message Command_AdjustMod {
optional bool should_be_mod = 2;
optional bool should_be_judge = 3;
}
message Command_ResetUserPassword {
extend AdminCommand {
optional Command_ResetUserPassword ext = 1016;
}
optional string user_name = 1;
}

View file

@ -0,0 +1,9 @@
syntax = "proto2";
import "moderator_commands.proto";
message Command_ReplayDownloadByGameId {
extend ModeratorCommand {
optional Command_ReplayDownloadByGameId ext = 1203;
}
required sint32 game_id = 1;
}

View file

@ -0,0 +1,13 @@
syntax = "proto2";
import "session_commands.proto";
message Command_Report {
extend SessionCommand {
optional Command_Report ext = 1200;
}
optional string reported_user = 1;
optional int32 game_id = 2;
optional string category = 3;
optional string description = 4;
optional string chat_log = 5;
}

View file

@ -0,0 +1,10 @@
syntax = "proto2";
import "session_commands.proto";
message Command_ReportAddComment {
extend SessionCommand {
optional Command_ReportAddComment ext = 1205;
}
required int32 report_id = 1;
required string comment = 2;
}

View file

@ -0,0 +1,9 @@
syntax = "proto2";
import "moderator_commands.proto";
message Command_ReportAssign {
extend ModeratorCommand {
optional Command_ReportAssign ext = 1201;
}
required int32 report_id = 1;
}

View file

@ -0,0 +1,9 @@
syntax = "proto2";
import "session_commands.proto";
message Command_ReportDetails {
extend SessionCommand {
optional Command_ReportDetails ext = 1206;
}
required int32 report_id = 1;
}

View file

@ -0,0 +1,11 @@
syntax = "proto2";
import "moderator_commands.proto";
message Command_ReportList {
extend ModeratorCommand {
optional Command_ReportList ext = 1200;
}
optional bool unresolved_only = 1;
optional uint32 offset = 2 [default = 0];
optional uint32 limit = 3 [default = 100];
}

View file

@ -0,0 +1,8 @@
syntax = "proto2";
import "session_commands.proto";
message Command_ReportMyList {
extend SessionCommand {
optional Command_ReportMyList ext = 1204;
}
}

View file

@ -0,0 +1,11 @@
syntax = "proto2";
import "moderator_commands.proto";
message Command_ReportResolve {
extend ModeratorCommand {
optional Command_ReportResolve ext = 1202;
}
required int32 report_id = 1;
optional string resolution_note = 2;
optional bool dismissed = 3;
}

View file

@ -0,0 +1,8 @@
syntax = "proto2";
import "moderator_commands.proto";
message Command_ReportStats {
extend ModeratorCommand {
optional Command_ReportStats ext = 1205;
}
}

View file

@ -0,0 +1,9 @@
syntax = "proto2";
import "moderator_commands.proto";
message Command_ReportUserInfo {
extend ModeratorCommand {
optional Command_ReportUserInfo ext = 1204;
}
optional string user_name = 1;
}

View file

@ -9,6 +9,8 @@ message Event_NotifyUser {
WARNING = 2;
IDLEWARNING = 3;
CUSTOM = 4;
REPORT_RESOLVED = 5;
REPORT_COMMENT = 6;
}
extend SessionEvent {

View file

@ -14,6 +14,17 @@ message ModeratorCommand {
ADD_CARD_ART_RULE = 1010;
REMOVE_CARD_ART_RULE = 1011;
LIST_CARD_ART_RULES = 1012;
GET_USER_SESSIONS = 1013;
GET_USER_ALTS = 1014;
GET_MODERATOR_LAST_LOGINS = 1015;
RESET_USER_PASSWORD = 1016;
REMOVE_USER_AVATAR = 1017;
REPORT_LIST = 1200;
REPORT_ASSIGN = 1201;
REPORT_RESOLVE = 1202;
REPLAY_DOWNLOAD_BY_GAME_ID = 1203;
REPORT_USER_INFO = 1204;
REPORT_STATS = 1205;
}
extensions 100 to max;
}
@ -135,3 +146,31 @@ message Command_ListCardArtRules {
optional Command_ListCardArtRules ext = 1012;
}
}
message Command_GetUserSessions {
extend ModeratorCommand {
optional Command_GetUserSessions ext = 1013;
}
optional string user_name = 1;
optional uint32 limit = 2 [default = 110];
}
message Command_GetUserAlts {
extend ModeratorCommand {
optional Command_GetUserAlts ext = 1014;
}
optional string user_name = 1;
}
message Command_GetModeratorLastLogins {
extend ModeratorCommand {
optional Command_GetModeratorLastLogins ext = 1015;
}
}
message Command_RemoveUserAvatar {
extend ModeratorCommand {
optional Command_RemoveUserAvatar ext = 1017;
}
optional string user_name = 1;
}

View file

@ -53,6 +53,7 @@ message Response {
RespClientUpdateRequired = 35; // Client is missing features that the server is requiring
RespServerFull = 36; // Server user limit reached
RespEmailBlackListed = 37; // Server has blocked the email address provided for registration for some reason
RespPasswordChangeRequired = 38; // Server requires the user to change their password before proceeding
}
// Type of response, used to route handling on the client

View file

@ -0,0 +1,10 @@
syntax = "proto2";
import "response.proto";
import "serverinfo_moderator_login.proto";
message Response_ModeratorLastLogins {
extend Response {
optional Response_ModeratorLastLogins ext = 1217;
}
repeated ServerInfo_ModeratorLogin logins = 1;
}

View file

@ -0,0 +1,9 @@
syntax = "proto2";
import "response.proto";
message Response_RemoveUserAvatar {
extend Response {
optional Response_RemoveUserAvatar ext = 1219;
}
optional string user_name = 1;
}

View file

@ -0,0 +1,10 @@
syntax = "proto2";
import "response.proto";
message Response_ReplayDownloadByGameId {
extend Response {
optional Response_ReplayDownloadByGameId ext = 1203;
}
optional bytes replay_data = 1;
optional sint32 replay_id = 2;
}

View file

@ -0,0 +1,10 @@
syntax = "proto2";
import "response.proto";
import "serverinfo_report.proto";
message Response_ReportDetails {
extend Response {
optional Response_ReportDetails ext = 1214;
}
optional ServerInfo_Report report = 1;
}

View file

@ -0,0 +1,11 @@
syntax = "proto2";
import "response.proto";
import "serverinfo_report.proto";
message Response_ReportList {
extend Response {
optional Response_ReportList ext = 1210;
}
repeated ServerInfo_Report reports = 1;
optional uint32 total_count = 2;
}

View file

@ -0,0 +1,10 @@
syntax = "proto2";
import "response.proto";
import "serverinfo_report.proto";
message Response_ReportMyList {
extend Response {
optional Response_ReportMyList ext = 1213;
}
repeated ServerInfo_Report reports = 1;
}

View file

@ -0,0 +1,36 @@
syntax = "proto2";
import "response.proto";
message Response_ReportStats {
extend Response {
optional Response_ReportStats ext = 1212;
}
optional int32 total_reports = 1;
optional int32 total_pending = 2;
optional int32 total_assigned = 3;
optional int32 total_resolved = 4;
optional int32 reports_last_24h = 5;
optional int32 reports_last_7d = 6;
optional int32 reports_last_30d = 7;
optional double avg_resolution_hours = 8;
optional int32 reports_this_week = 9;
optional int32 reports_last_week = 10;
repeated ReportCategoryCount category_counts = 11;
repeated ReportTopUser top_reported_users = 12;
repeated ReportTopUser top_reporters = 13;
}
message ReportCategoryCount {
optional string category = 1;
optional int32 count = 2;
}
message ReportTopUser {
optional string user_name = 1;
optional int32 count = 2;
}

View file

@ -0,0 +1,21 @@
syntax = "proto2";
import "response.proto";
import "serverinfo_report.proto";
message Response_ReportUserInfo {
extend Response {
optional Response_ReportUserInfo ext = 1211;
}
optional string user_name = 1;
optional int32 total_reports = 2;
optional int32 total_bans = 3;
optional int32 total_warns = 4;
optional int64 registration_time = 5;
optional bool is_admin = 6;
optional bool is_active = 7;
optional string admin_notes = 8;
repeated ServerInfo_Report recent_reports = 9;
// Last known login of the user, epoch seconds; 0 = unknown.
optional int64 last_login = 10;
}

View file

@ -0,0 +1,12 @@
syntax = "proto2";
import "response.proto";
message Response_ResetUserPassword {
extend Response {
optional Response_ResetUserPassword ext = 1218;
}
optional string user_name = 1;
// The generated temporary password, shown to the moderator who
// requested the reset. The affected user must change it on first login.
optional string temporary_password = 2;
}

View file

@ -0,0 +1,10 @@
syntax = "proto2";
import "response.proto";
import "serverinfo_user_alt.proto";
message Response_UserAlts {
extend Response {
optional Response_UserAlts ext = 1216;
}
repeated ServerInfo_UserAlt alts = 1;
}

View file

@ -0,0 +1,10 @@
syntax = "proto2";
import "response.proto";
import "serverinfo_user_session.proto";
message Response_UserSessions {
extend Response {
optional Response_UserSessions ext = 1215;
}
repeated ServerInfo_UserSession sessions = 1;
}

View file

@ -8,4 +8,7 @@ message Response_WarnList {
repeated string warning = 1;
optional string user_name = 2;
optional string user_clientid = 3;
// Recommended starting intervention level per warning category,
// aligned by index with `warning`. Absent or shorter lists default to 1.
repeated uint32 warning_il = 4;
}

View file

@ -0,0 +1,11 @@
syntax = "proto2";
/**
* The last login date of a staff member (moderator/judge/admin).
* Used by the moderation "Moderator Last Logins" tool.
*/
message ServerInfo_ModeratorLogin {
optional string user_name = 1; // staff account name
optional uint64 last_login = 2; // last known login, epoch seconds; 0 = unknown
optional uint32 user_level = 3; // ServerInfo_User::UserLevelFlag mask (moderator/judge/admin)
}

View file

@ -0,0 +1,36 @@
syntax = "proto2";
message ServerInfo_ReportComment {
optional string author_name = 1;
optional string comment_text = 2;
optional int64 comment_time = 3;
optional bool is_moderator = 4;
}
message ServerInfo_Report {
optional int32 report_id = 1;
optional string reporter_name = 2;
optional string reported_user_name = 3;
optional int32 game_id = 4;
optional int32 replay_id = 5;
optional int32 room_id = 6;
optional string category = 7;
optional string status = 8;
optional string description = 9;
optional int64 report_time = 10;
optional string assigned_mod_name = 11;
optional int64 resolution_time = 12;
repeated ServerInfo_ReportComment comments = 13;
optional string chat_log = 14;
optional string resolution_note = 15;
}

View file

@ -0,0 +1,16 @@
syntax = "proto2";
/**
* An account that shares an IP address, client id or eMail address with
* the account being investigated. Used by the moderation "Get User Alts" tool.
*/
message ServerInfo_UserAlt {
optional string user_name = 1; // account name
optional string email = 2; // registration eMail
optional string clientid = 3; // client id
optional uint64 registration_time = 4; // account registration, epoch seconds
optional uint64 last_login = 5; // last known login, epoch seconds; 0 = unknown
optional uint32 warn_count = 6; // number of warnings on record
optional uint32 ban_count = 7; // number of bans on record
optional bool is_active = 8; // account is not deactivated/banned
}

View file

@ -0,0 +1,14 @@
syntax = "proto2";
/**
* A single login session of a user on the server, as stored in the
* sessions table. Used by the moderation "Get User Sessions" tool.
*/
message ServerInfo_UserSession {
optional string user_name = 1; // account that was logged in
optional string ip_address = 2; // IP address used for the session
optional string clientid = 3; // client id used for the session
optional uint64 start_time = 4; // session start, epoch seconds
optional uint64 end_time = 5; // session end, epoch seconds; 0 = still active
optional string connection_type = 6; // "tcp" or "websocket"
}

View file

@ -34,6 +34,11 @@ message SessionCommand {
REPLAY_DELETE_MATCH = 1103;
REPLAY_GET_CODE = 1104;
REPLAY_SUBMIT_CODE = 1105;
REPORT = 1200;
// 1201-1203 reserved: removed during squash
REPORT_MY_LIST = 1204;
REPORT_ADD_COMMENT = 1205;
REPORT_DETAILS = 1206;
}
extensions 100 to max;
}