Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ensure smtpConfig auth is not tainted for log purposes when error #797

Merged
merged 4 commits into from
Jul 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading