Skip to content

Commit 50631d4

Browse files
committed
fix: Address Gemini code review security and quality issues
Security fixes (HIGH): - Remove NOPASSWD sudo access in Dockerfile - Require secure passwords in docker-compose.yml (no weak defaults) - Replace libboost-all-dev with specific runtime libs in araxia_docs/Dockerfile Code quality fixes (MEDIUM): - Remove weak default password from .env.example - Fix AMS_Server.lua: vendor Smallfolk dependency, add CHAT_CHANNEL_WHISPER constant - Fix AMS_Client.lua: correct misleading comments about channel selection Fixes issues identified by Gemini Code Assist review.
1 parent 8c83692 commit 50631d4

File tree

9 files changed

+33
-18
lines changed

9 files changed

+33
-18
lines changed

AGENTS.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,3 +111,6 @@ Monitor events with: `python /opt/trinitycore/TrinityCore/src/araxiaonline/tools
111111
- Always use the max number of threads when building the server
112112
- Always use @araxiaonline/cmake_setup.sh to setup the build environment. Modify it if needed.
113113
- Please fix all compile warnings before marking a task as complete.
114+
115+
### Pushing changes
116+
- Our working branch is `araxia-main` and all branches and PRs should be based on this branch.

araxiaonline/.env.example

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
DB_HOST=host.docker.internal
1010
DB_PORT=3306
1111
DB_USER=trinity
12-
DB_PASSWORD=trinity
12+
DB_PASSWORD=<YOUR_SECURE_PASSWORD_HERE>
1313
DB_AUTH=auth
1414
DB_CHARACTERS=characters
1515
DB_WORLD=world

araxiaonline/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,9 @@ ENV LC_ALL=en_US.UTF-8
6060
RUN update-alternatives --install /usr/bin/cc cc /usr/bin/clang 100 && \
6161
update-alternatives --install /usr/bin/c++ c++ /usr/bin/clang++ 100
6262

63-
# Create trinitycore user with sudo privileges
63+
# Create trinitycore user with sudo privileges (requires password)
6464
RUN useradd -m -s /bin/bash -G sudo trinitycore && \
65-
echo "trinitycore ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
65+
echo "trinitycore ALL=(ALL) ALL" >> /etc/sudoers
6666

6767
# Create necessary directories
6868
RUN mkdir -p \

araxiaonline/ams/AMS_Client/AMS_Client.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ local function SendAddonMessage(message)
119119
if #message <= AMS_MAX_MSG_LENGTH then
120120
-- Prefix with marker for short message (ID = 0000, parts = 0000, partID = 0000)
121121
local packet = NumberToHex(0) .. NumberToHex(0) .. NumberToHex(0) .. message
122-
-- Use PARTY channel for solo players, fallback to WHISPER if in party
122+
-- Use WHISPER channel for solo players, PARTY if in a group
123123
local channel = IsInGroup() and "PARTY" or "WHISPER"
124124
local target = channel == "WHISPER" and UnitName("player") or nil
125125
Debug("Sending via channel:", channel, "target:", target or "none", "prefix:", AMS_PREFIX)
@@ -134,7 +134,7 @@ local function SendAddonMessage(message)
134134

135135
Debug("Splitting message ID", msgID, "into", totalParts, "parts")
136136

137-
-- Use PARTY channel for solo players, fallback to WHISPER if in party
137+
-- Use WHISPER channel for solo players, PARTY if in a group
138138
local channel = IsInGroup() and "PARTY" or "WHISPER"
139139
local target = channel == "WHISPER" and UnitName("player") or nil
140140

araxiaonline/ams/AMS_Server.lua

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,11 @@ local AMS_MSG_MAX_ID = 65535 -- 16-bit ID
4242
-- Dependencies
4343
-- ============================================================================
4444

45-
-- Smallfolk for serialization (already in AIO deps)
46-
local Smallfolk = require("AIO_Server.Dep_Smallfolk.smallfolk")
45+
-- Smallfolk for serialization (vendored in AMS_Server directory)
46+
local Smallfolk = require("AMS_Server.smallfolk")
47+
48+
-- Chat channel constants for clarity
49+
local CHAT_CHANNEL_WHISPER = 7 -- CHAT_MSG_WHISPER
4750

4851
-- ============================================================================
4952
-- Core AMS Table
@@ -120,7 +123,7 @@ local function SendAddonMessage(player, message)
120123
if #message <= AMS_MAX_MSG_LENGTH then
121124
-- Prefix with marker for short message (ID = 0000, parts = 0000, partID = 0000)
122125
local packet = NumberToHex(0) .. NumberToHex(0) .. NumberToHex(0) .. message
123-
player:SendAddonMessage(AMS_PREFIX, packet, 7, player)
126+
player:SendAddonMessage(AMS_PREFIX, packet, CHAT_CHANNEL_WHISPER, player)
124127
return
125128
end
126129

@@ -142,7 +145,7 @@ local function SendAddonMessage(player, message)
142145
NumberToHex(partID)
143146

144147
local packet = header .. chunk
145-
player:SendAddonMessage(AMS_PREFIX, packet, 7, player)
148+
player:SendAddonMessage(AMS_PREFIX, packet, CHAT_CHANNEL_WHISPER, player)
146149
end
147150
end
148151

araxiaonline/araxia_docs/Dockerfile

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,13 @@ RUN apt-get update && apt-get install -y \
7474
libbz2-1.0 \
7575
libreadline8t64 \
7676
libncurses6 \
77-
libboost-all-dev \
77+
libboost-system1.83.0 \
78+
libboost-filesystem1.83.0 \
79+
libboost-thread1.83.0 \
80+
libboost-program-options1.83.0 \
81+
libboost-iostreams1.83.0 \
82+
libboost-regex1.83.0 \
83+
libboost-locale1.83.0 \
7884
ca-certificates \
7985
&& rm -rf /var/lib/apt/lists/*
8086

araxiaonline/araxia_docs/docker-compose.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ services:
66
image: mysql:8.0
77
container_name: trinitycore-mysql
88
environment:
9-
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD:-trinity}
9+
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD:?Please set MYSQL_ROOT_PASSWORD in .env}
1010
MYSQL_DATABASE: ${MYSQL_AUTH_DATABASE:-auth}
1111
MYSQL_USER: ${MYSQL_USER:-trinity}
12-
MYSQL_PASSWORD: ${MYSQL_PASSWORD:-trinity}
12+
MYSQL_PASSWORD: ${MYSQL_PASSWORD:?Please set MYSQL_PASSWORD in .env}
1313
volumes:
1414
- mysql-data:/var/lib/mysql
1515
- ./sql:/docker-entrypoint-initdb.d:ro
@@ -19,7 +19,7 @@ services:
1919
- trinitycore
2020
command: --default-authentication-plugin=mysql_native_password --max_allowed_packet=512M
2121
healthcheck:
22-
test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-u", "root", "-p${MYSQL_ROOT_PASSWORD:-trinity}"]
22+
test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-u", "root", "-p${MYSQL_ROOT_PASSWORD}"]
2323
interval: 10s
2424
timeout: 5s
2525
retries: 5

araxiaonline/client_addons/AMS_Client/AMS_Client.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ local function SendAddonMessage(message)
119119
if #message <= AMS_MAX_MSG_LENGTH then
120120
-- Prefix with marker for short message (ID = 0000, parts = 0000, partID = 0000)
121121
local packet = NumberToHex(0) .. NumberToHex(0) .. NumberToHex(0) .. message
122-
-- Use PARTY channel for solo players, fallback to WHISPER if in party
122+
-- Use WHISPER channel for solo players, PARTY if in a group
123123
local channel = IsInGroup() and "PARTY" or "WHISPER"
124124
local target = channel == "WHISPER" and UnitName("player") or nil
125125
Debug("Sending via channel:", channel, "target:", target or "none", "prefix:", AMS_PREFIX)
@@ -134,7 +134,7 @@ local function SendAddonMessage(message)
134134

135135
Debug("Splitting message ID", msgID, "into", totalParts, "parts")
136136

137-
-- Use PARTY channel for solo players, fallback to WHISPER if in party
137+
-- Use WHISPER channel for solo players, PARTY if in a group
138138
local channel = IsInGroup() and "PARTY" or "WHISPER"
139139
local target = channel == "WHISPER" and UnitName("player") or nil
140140

araxiaonline/lua_scripts/AMS_Server/AMS_Server.lua

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,12 @@ local AMS_MSG_MAX_ID = 65535 -- 16-bit ID
4242
-- Dependencies
4343
-- ============================================================================
4444

45-
-- Smallfolk for serialization
45+
-- Smallfolk for serialization (vendored in AMS_Server directory)
4646
local Smallfolk = require("AMS_Server.smallfolk")
4747

48+
-- Chat channel constants for clarity
49+
local CHAT_CHANNEL_WHISPER = 7 -- CHAT_MSG_WHISPER
50+
4851
-- ============================================================================
4952
-- Core AMS Table
5053
-- ============================================================================
@@ -124,7 +127,7 @@ local function SendAddonMessage(player, message)
124127
if #message <= AMS_MAX_MSG_LENGTH then
125128
-- Prefix with marker for short message (ID = 0000, parts = 0000, partID = 0000)
126129
local packet = NumberToHex(0) .. NumberToHex(0) .. NumberToHex(0) .. message
127-
player:SendAddonMessage(AMS_PREFIX, packet, 7, player)
130+
player:SendAddonMessage(AMS_PREFIX, packet, CHAT_CHANNEL_WHISPER, player)
128131
return
129132
end
130133

@@ -146,7 +149,7 @@ local function SendAddonMessage(player, message)
146149
NumberToHex(partID)
147150

148151
local packet = header .. chunk
149-
player:SendAddonMessage(AMS_PREFIX, packet, 7, player)
152+
player:SendAddonMessage(AMS_PREFIX, packet, CHAT_CHANNEL_WHISPER, player)
150153
end
151154
end
152155

0 commit comments

Comments
 (0)