prevent data leakage when sending server.data

This commit is contained in:
Nick Krecklow 2020-05-08 16:22:24 -05:00
parent 9cb9e4a062
commit f6780e7a9b
No known key found for this signature in database
GPG Key ID: 5F149FDE156FFA94
2 changed files with 11 additions and 1 deletions

@ -71,7 +71,7 @@ class App {
graphDurationLabel: config.graphDurationLabel || (Math.floor(config.graphDuration / (60 * 60 * 1000)) + 'h'), graphDurationLabel: config.graphDurationLabel || (Math.floor(config.graphDuration / (60 * 60 * 1000)) + 'h'),
graphMaxLength: TimeTracker.getMaxGraphDataLength(), graphMaxLength: TimeTracker.getMaxGraphDataLength(),
serverGraphMaxLength: TimeTracker.getMaxServerGraphDataLength(), serverGraphMaxLength: TimeTracker.getMaxServerGraphDataLength(),
servers: this.serverRegistrations.map(serverRegistration => serverRegistration.data), servers: this.serverRegistrations.map(serverRegistration => serverRegistration.getPublicData()),
minecraftVersions: minecraftVersionNames, minecraftVersions: minecraftVersionNames,
isGraphVisible: config.logToDatabase isGraphVisible: config.logToDatabase
} }

@ -303,6 +303,16 @@ class ServerRegistration {
message: message message: message
} }
} }
getPublicData () {
// Return a custom object instead of data directly to avoid data leakage
return {
name: this.data.name,
ip: this.data.ip,
type: this.data.type,
color: this.data.color
}
}
} }
module.exports = ServerRegistration module.exports = ServerRegistration