Skip to content

Commit

Permalink
Merge pull request #797 from telefonicaid/fix/smtp_conf_auth_tained_a…
Browse files Browse the repository at this point in the history
…fter_error

ensure smtpConfig auth is not tainted for log purposes when error
  • Loading branch information
fgalan authored Jul 30, 2024
2 parents 6971d66 + 18c9359 commit 8d359d4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGES_NEXT_RELEASE
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Fix: smtpConfig after error in emailAction rule (#798)
7 changes: 4 additions & 3 deletions lib/models/emailAction.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,10 @@ function SendMail(action, event, callback) {
smtpConfig = config.smtp;
msgFromConfig = 'from global';
}
var smtpAuth = smtpConfig.auth;
smtpConfig.auth = { user: 'UUU', pass: 'XXX' };
var smtpAuth = Object.assign({}, smtpConfig.auth); // force clone
smtpConfig.auth = { user: 'UUU', pass: 'XXX' }; // fake auth for log purposes
logger.debug('Using smtp transporter %j config: %j', msgFromConfig, smtpConfig);
smtpConfig.auth = smtpAuth;
smtpConfig.auth = smtpAuth; // restore auth
transporter = nodemailer.createTransport(smtpTransport(smtpConfig));
metrics.IncMetrics(event.service, event.subservice, metrics.actionEmail);

Expand All @@ -105,6 +105,7 @@ function SendMail(action, event, callback) {
};
opt2log.smtp.auth = { user: 'UUU', pass: 'XXX' };
myutils.logErrorIf(err, util.format('emailAction.SendMail %j', opt2log));
smtpConfig.auth = smtpAuth; // ensure smtpConfig.auth is not tainted
alarm.raise(alarm.EMAIL);
} else {
metrics.IncMetrics(event.service, event.subservice, metrics.okActionEmail);
Expand Down

0 comments on commit 8d359d4

Please sign in to comment.