redact snode IP used in logs on production builds

This commit is contained in:
Audric Ackermann 2021-04-12 16:46:20 +10:00
parent 47026b8d5b
commit f12ca66008
No known key found for this signature in database
GPG key ID: 999F434D76324AD4
3 changed files with 17 additions and 7 deletions

View file

@ -154,11 +154,11 @@ class LokiPublicChatFactoryAPI extends EventEmitter {
);
return null;
}
if (window.isDev) {
log.info(
`loki_public_chat::findOrCreateServer - set token ${thisServer.token} for ${serverUrl}`
);
}
// if (window.isDev) {
// log.info(
// `loki_public_chat::findOrCreateServer - set token ${thisServer.token} for ${serverUrl}`
// );
// }
this.servers.push(thisServer);
}

View file

@ -8,6 +8,7 @@ const { escapeRegExp } = require('lodash');
const APP_ROOT_PATH = path.join(__dirname, '..', '..', '..');
const SESSION_ID_PATTERN = /\b(05[0-9a-f]{64})\b/gi;
const SNODE_PATTERN = /^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/;
const GROUP_ID_PATTERN = /(group\()([^)]+)(\))/g;
const REDACTION_PLACEHOLDER = '[REDACTED]';
@ -64,6 +65,14 @@ exports.redactSessionID = text => {
return text.replace(SESSION_ID_PATTERN, REDACTION_PLACEHOLDER);
};
exports.redactSnodeIP = text => {
if (!is.string(text)) {
throw new TypeError("'text' must be a string");
}
return text.replace(SNODE_PATTERN, REDACTION_PLACEHOLDER);
};
// redactGroupIds :: String -> String
exports.redactGroupIds = text => {
if (!is.string(text)) {
@ -84,7 +93,8 @@ exports.redactSensitivePaths = exports._redactPath(APP_ROOT_PATH);
exports.redactAll = compose(
exports.redactSensitivePaths,
exports.redactGroupIds,
exports.redactSessionID
exports.redactSessionID,
exports.redactSnodeIP
);
const removeNewlines = text => text.replace(/\r?\n|\r/g, '');

View file

@ -312,6 +312,6 @@ export class OnionPaths {
this.onionPaths.push({ path, bad: false });
}
log.info(`Built ${this.onionPaths.length} onion paths`, this.onionPaths);
log.info(`Built ${this.onionPaths.length} onion paths`);
}
}