Skip to content

Commit d3efbd6

Browse files
authored
Made it so some sensitive info is actually hidden when LOG_SENSITIVE_INFO is set to false
1 parent 38d86a7 commit d3efbd6

File tree

6 files changed

+13
-13
lines changed

6 files changed

+13
-13
lines changed

backend/docker/dockerstartup.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ async function dockerstartup() {
6161
} else {
6262
console.log("Not running inside a dockers")
6363
}
64-
log("---- Docker Startup ----", "-- ENV --", `TOKEN: ${env.LOG_SENSITIVE_INFO === true ? env.TOKEN : "HIDDEN"}`, `CID: ${env.CLIENTID}`, `GID: ${env.GUILDID}`, `MUDTOKEN: ${env.LOG_SENSITIVE_INFO === true ? env.MUDTOKEN : "HIDDEN"}`, `OVERRIDE: ${env.OVERRIDE === true ? "True" : "False"}`, "-- PATHS --", configPath);
64+
log("---- Docker Startup ----", "-- ENV --", `TOKEN: ${env.LOG_SENSITIVE_INFO ? env.TOKEN : "HIDDEN"}`, `CID: ${env.CLIENTID}`, `GID: ${env.GUILDID}`, `MUDTOKEN: ${env.LOG_SENSITIVE_INFO ? env.MUDTOKEN : "HIDDEN"}`, `OVERRIDE: ${!env.OVERRIDE ? "False" : "True"}`, "-- PATHS --", configPath);
6565
}
6666

6767
module.exports.dockerstartup = dockerstartup;

backend/fetchNewMessages.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ async function fetchNewMessages(client) {
218218
})
219219
// Update the last timestamp
220220
lastTimestamp = NowToRubyTS()+1;
221-
log("---- Fetched Messages ----", payload, result, lastTimestamp);
221+
log("---- Fetched Messages ----", process.env.LOG_SENSITIVE_INFO ? payload : "HIDDEN" , result, lastTimestamp);
222222
} else {
223223
console.error('Hackmud API error:', result.msg || 'Unknown error');
224224
}

backend/loadvar.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ async function loadConfigVar(key) {
3838
try {
3939
const configRaw = await readFile(configPath, 'utf8');
4040
const config = JSON.parse(configRaw);
41-
log(`LoadConfigVar was called, Input: ${key}, Output: ${config[key]}`);
41+
log(`LoadConfigVar was called, Input: ${key}, Output: ${process.env.LOG_SENSITIVE_INFO ? config[key] : 'HIDDEN'}`);
4242
return config[key] ?? null; // Return null if key doesn't exist
4343
} catch (error) {
4444
console.error(`Error loading config variable "${key}":`, error.message);

commands/mud/settings.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ module.exports = {
137137

138138
fs.writeFileSync(configPath, JSON.stringify(config, null, 4));
139139
console.log('New mudtoken has been set');
140-
log("---- Settings.js - Auth ----", `New mudtoken has been set: ${process.env.LOG_SENSITIVE_INFO === 'true' ? chatToken : "HIDDEN"}`, payload, `${process.env.LOG_SENSITIVE_INFO === true ? result : "HIDDEN"}`, config, configPath);
140+
log("---- Settings.js - Auth ----", `New mudtoken has been set: ${process.env.LOG_SENSITIVE_INFO ? chatToken : "HIDDEN"}`, payload, `${process.env.LOG_SENSITIVE_INFO ? result : "HIDDEN"}`, process.env.LOG_SENSITIVE_INFO ? config : 'HIDDEN', configPath);
141141
await interaction.reply({content: `Config updated successfully! Token has been set.`, flags: MessageFlags.Ephemeral });
142142
} else {
143143
log("---- Settings.js - Auth ----", 'Failed to update mudtoken', payload, result);
@@ -206,10 +206,10 @@ module.exports = {
206206

207207
fs.writeFileSync(mappingsPath, JSON.stringify(channelMapping, null, 4));
208208

209-
log("---- Settings.js - Setup ----", 'Sucessfully ran setup', `${process.env.LOG_SENSITIVE_INFO === true ? payload : "HIDDEN"}`, result, channelMapping, mappingsPath);
209+
log("---- Settings.js - Setup ----", 'Sucessfully ran setup', `${process.env.LOG_SENSITIVE_INFO ? payload : "HIDDEN"}`, result, channelMapping, mappingsPath);
210210
await interaction.reply({content: 'Server has been set up successfully, and user channels have been created or reused under the "chat" category.', flags: MessageFlags.Ephemeral });
211211
} else {
212-
log("---- Settings.js - Setup ----", 'Failed to run setup', `${process.env.LOG_SENSITIVE_INFO === true ? payload : "HIDDEN"}`, result);
212+
log("---- Settings.js - Setup ----", 'Failed to run setup', `${process.env.LOG_SENSITIVE_INFO ? payload : "HIDDEN"}`, result);
213213
console.error(result);
214214
await interaction.reply({content: `Failed to run setup. Server response: ${result.msg || 'Unknown error'}`, flags: MessageFlags.Ephemeral });
215215
}
@@ -242,7 +242,7 @@ module.exports = {
242242

243243
fs.writeFileSync(configPath, JSON.stringify(config, null, 4), 'utf-8');
244244

245-
log("---- Settings.js - Manage Users ----", 'Successfully updated settings', username, pullHistory, config, configPath);
245+
log("---- Settings.js - Manage Users ----", 'Successfully updated settings', username, pullHistory, process.env.LOG_SENSITIVE_INFO ? config : 'HIDDEN', configPath);
246246
await interaction.reply({content: `Successfully updated settings for user **${username}**. Pull history: **${pullHistory ? 'Enabled' : 'Disabled'}**`, flags: MessageFlags.Ephemeral });
247247
} catch (error) {
248248
console.error(error);
@@ -263,7 +263,7 @@ module.exports = {
263263
}
264264

265265
fs.writeFileSync(configPath, JSON.stringify(config, null, 4), 'utf-8');
266-
log("---- Settings.js - Color ----", 'Successfully updated setting', cmdcolorval, config, configPath);
266+
log("---- Settings.js - Color ----", 'Successfully updated setting', cmdcolorval, process.env.LOG_SENSITIVE_INFO ? config : 'HIDDEN', configPath);
267267
} else {
268268
log("---- Settings.js - Color ----", 'Invalid color value', cmdcolorval);
269269
await interaction.reply({content: 'Invalid color value. Please use a single alphanumeric character or "reset"', flags: MessageFlags.Ephemeral });
@@ -277,7 +277,7 @@ module.exports = {
277277
fs.writeFileSync(configPath, JSON.stringify(config, null, 4), 'utf-8');
278278

279279
await interaction.reply({content: `Successfully updated setting. Ping Detection: **${value ? 'Enabled' : 'Disabled'}**`, flags: MessageFlags.Ephemeral });
280-
log("---- Settings.js - Ping Detection ----", 'Successfully updated setting', value, config, configPath);
280+
log("---- Settings.js - Ping Detection ----", 'Successfully updated setting', value, process.env.LOG_SENSITIVE_INFO ? config : 'HIDDEN', configPath);
281281
} catch(error) {
282282
console.error(error);
283283
await interaction.reply({content: 'An error occurred while setting this option. Check console for details.', flags: MessageFlags.Ephemeral });

commands/mud/tell.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ module.exports = {
5151

5252
const result = await response.json();
5353
if (result.ok === true) {
54-
log(`---- tell.js ----`, `TellUsr: ${tellusr}`, `TellMsg: ${tellmsg}`, `ChannelName: ${channelName}`, `ChannelId: ${interaction.channelId}`, `Result: ${result.ok}`, `Msg: ${result.msg}`, channelMappings);
54+
log(`---- tell.js ----`, `TellUsr: ${tellusr}`, `TellMsg: ${tellmsg}`, `ChannelName: ${channelName}`, `ChannelId: ${interaction.channelId}`, `Result: ${result.ok}`, `Msg: ${result.msg}`, channelMappings, process.env.LOG_SENSITIVE_INFO ? payload : 'HIDDEN');
5555
interaction.reply({content: `Message sent to ${tellusr} successfully. Message: ${tellmsg}`, flags: MessageFlags.Ephemeral });
5656
} else {
5757
console.log(`Failed to send message. Server response: ${result.msg || 'Unknown error'}`);

events/messageCreate.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,16 +78,16 @@ module.exports = {
7878
});
7979
const result = await response.json();
8080
if (result.ok === true) {
81-
log(`---- messageCreate.js - Send Message ----`, `${process.env.LOG_SENSITIVE_INFO === true ? payload : "HIDDEN"}`, result);
81+
log(`---- messageCreate.js - Send Message ----`, `${process.env.LOG_SENSITIVE_INFO ? payload : "HIDDEN"}`, result);
8282
message.react('✅');
8383
//console.log(`Message sent to ${setChannel} successfully. Message: ${finalMessage}`);
8484
} else {
85-
log(`---- messageCreate.js - Send Message ----`, `${process.env.LOG_SENSITIVE_INFO === true ? payload : "HIDDEN"}`, result);
85+
log(`---- messageCreate.js - Send Message ----`, `${process.env.LOG_SENSITIVE_INFO ? payload : "HIDDEN"}`, result);
8686
message.react('❌');
8787
console.log(`Failed to send message. Server response: ${result.msg || 'Unknown error'}`);
8888
}
8989
} catch (error) {
90-
log(`---- messageCreate.js - Send Message ----`, `${process.env.LOG_SENSITIVE_INFO === true ? payload : "HIDDEN"}`, error);
90+
log(`---- messageCreate.js - Send Message ----`, `${process.env.LOG_SENSITIVE_INFO ? payload : "HIDDEN"}`, error);
9191
message.react('❌');
9292
console.log(error);
9393
}

0 commit comments

Comments
 (0)