Skip to content

Commit

Permalink
Made it so some sensitive info is actually hidden when LOG_SENSITIVE_…
Browse files Browse the repository at this point in the history
…INFO is set to false
  • Loading branch information
Slingexe authored Feb 14, 2025
1 parent 38d86a7 commit d3efbd6
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion backend/docker/dockerstartup.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ async function dockerstartup() {
} else {
console.log("Not running inside a dockers")
}
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);
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);
}

module.exports.dockerstartup = dockerstartup;
2 changes: 1 addition & 1 deletion backend/fetchNewMessages.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ async function fetchNewMessages(client) {
})
// Update the last timestamp
lastTimestamp = NowToRubyTS()+1;
log("---- Fetched Messages ----", payload, result, lastTimestamp);
log("---- Fetched Messages ----", process.env.LOG_SENSITIVE_INFO ? payload : "HIDDEN" , result, lastTimestamp);
} else {
console.error('Hackmud API error:', result.msg || 'Unknown error');
}
Expand Down
2 changes: 1 addition & 1 deletion backend/loadvar.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ async function loadConfigVar(key) {
try {
const configRaw = await readFile(configPath, 'utf8');
const config = JSON.parse(configRaw);
log(`LoadConfigVar was called, Input: ${key}, Output: ${config[key]}`);
log(`LoadConfigVar was called, Input: ${key}, Output: ${process.env.LOG_SENSITIVE_INFO ? config[key] : 'HIDDEN'}`);
return config[key] ?? null; // Return null if key doesn't exist
} catch (error) {
console.error(`Error loading config variable "${key}":`, error.message);
Expand Down
12 changes: 6 additions & 6 deletions commands/mud/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ module.exports = {

fs.writeFileSync(configPath, JSON.stringify(config, null, 4));
console.log('New mudtoken has been set');
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);
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);
await interaction.reply({content: `Config updated successfully! Token has been set.`, flags: MessageFlags.Ephemeral });
} else {
log("---- Settings.js - Auth ----", 'Failed to update mudtoken', payload, result);
Expand Down Expand Up @@ -206,10 +206,10 @@ module.exports = {

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

log("---- Settings.js - Setup ----", 'Sucessfully ran setup', `${process.env.LOG_SENSITIVE_INFO === true ? payload : "HIDDEN"}`, result, channelMapping, mappingsPath);
log("---- Settings.js - Setup ----", 'Sucessfully ran setup', `${process.env.LOG_SENSITIVE_INFO ? payload : "HIDDEN"}`, result, channelMapping, mappingsPath);
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 });
} else {
log("---- Settings.js - Setup ----", 'Failed to run setup', `${process.env.LOG_SENSITIVE_INFO === true ? payload : "HIDDEN"}`, result);
log("---- Settings.js - Setup ----", 'Failed to run setup', `${process.env.LOG_SENSITIVE_INFO ? payload : "HIDDEN"}`, result);
console.error(result);
await interaction.reply({content: `Failed to run setup. Server response: ${result.msg || 'Unknown error'}`, flags: MessageFlags.Ephemeral });
}
Expand Down Expand Up @@ -242,7 +242,7 @@ module.exports = {

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

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

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

await interaction.reply({content: `Successfully updated setting. Ping Detection: **${value ? 'Enabled' : 'Disabled'}**`, flags: MessageFlags.Ephemeral });
log("---- Settings.js - Ping Detection ----", 'Successfully updated setting', value, config, configPath);
log("---- Settings.js - Ping Detection ----", 'Successfully updated setting', value, process.env.LOG_SENSITIVE_INFO ? config : 'HIDDEN', configPath);
} catch(error) {
console.error(error);
await interaction.reply({content: 'An error occurred while setting this option. Check console for details.', flags: MessageFlags.Ephemeral });
Expand Down
2 changes: 1 addition & 1 deletion commands/mud/tell.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ module.exports = {

const result = await response.json();
if (result.ok === true) {
log(`---- tell.js ----`, `TellUsr: ${tellusr}`, `TellMsg: ${tellmsg}`, `ChannelName: ${channelName}`, `ChannelId: ${interaction.channelId}`, `Result: ${result.ok}`, `Msg: ${result.msg}`, channelMappings);
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');
interaction.reply({content: `Message sent to ${tellusr} successfully. Message: ${tellmsg}`, flags: MessageFlags.Ephemeral });
} else {
console.log(`Failed to send message. Server response: ${result.msg || 'Unknown error'}`);
Expand Down
6 changes: 3 additions & 3 deletions events/messageCreate.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,16 +78,16 @@ module.exports = {
});
const result = await response.json();
if (result.ok === true) {
log(`---- messageCreate.js - Send Message ----`, `${process.env.LOG_SENSITIVE_INFO === true ? payload : "HIDDEN"}`, result);
log(`---- messageCreate.js - Send Message ----`, `${process.env.LOG_SENSITIVE_INFO ? payload : "HIDDEN"}`, result);
message.react('✅');
//console.log(`Message sent to ${setChannel} successfully. Message: ${finalMessage}`);
} else {
log(`---- messageCreate.js - Send Message ----`, `${process.env.LOG_SENSITIVE_INFO === true ? payload : "HIDDEN"}`, result);
log(`---- messageCreate.js - Send Message ----`, `${process.env.LOG_SENSITIVE_INFO ? payload : "HIDDEN"}`, result);
message.react('❌');
console.log(`Failed to send message. Server response: ${result.msg || 'Unknown error'}`);
}
} catch (error) {
log(`---- messageCreate.js - Send Message ----`, `${process.env.LOG_SENSITIVE_INFO === true ? payload : "HIDDEN"}`, error);
log(`---- messageCreate.js - Send Message ----`, `${process.env.LOG_SENSITIVE_INFO ? payload : "HIDDEN"}`, error);
message.react('❌');
console.log(error);
}
Expand Down

0 comments on commit d3efbd6

Please sign in to comment.