Skip to content

Commit 364f514

Browse files
committed
Support providing tlsRejectUnauthorized in notificationInfo config
1 parent 1bbbbe4 commit 364f514

File tree

4 files changed

+6
-2
lines changed

4 files changed

+6
-2
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ In order to send an email, users must specify the hostname or IP address of an S
111111
- `port`: (Optional) The port to connect to (defaults to 587)
112112
- `to`: Comma separated list or an array of recipients email addresses that will appear on the _To:_ field
113113
- `from`: (Optional) The email address of the sender. All email addresses can be plain `'sender@server.com'` or formatted `'"Sender Name" sender@server.com'` (defaults to mcode-extraction-errors@mitre.org, which cannot receive reply emails)
114+
- `tlsRejectUnauthorized`: (Optional) A boolean value to set the [node.js TLSSocket option](https://nodejs.org/api/tls.html#tls_class_tls_tlssocket) for rejecting any unauthorized connections, `tls.rejectUnauthorized`. (defaults to `true`)
114115

115116
An example of this object can be found in [`config/csv.config.example.json`](config/csv.config.example.json).
116117

config/csv.config.example.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
"to": [
99
"demo@example.com",
1010
"test@example.com"
11-
]
11+
],
12+
"tlsRejectUnauthorized": true
1213
},
1314
"extractors": [
1415
{

src/cli/emailNotifications.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ async function sendEmailNotification(notificationInfo, errors, debug = false) {
6060
const transporter = nodemailer.createTransport({
6161
host: notificationInfo.host,
6262
...(notificationInfo.port && { port: notificationInfo.port }),
63+
...(notificationInfo.tlsRejectUnauthorized !== undefined && { tls: { rejectUnauthorized: notificationInfo.tlsRejectUnauthorized } }),
6364
});
6465

6566
logger.debug('Sending email with error information');

test/cli/emailNotifications.test.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ describe('sendEmailNotification', () => {
7171
port: 123,
7272
to: ['something@example.com', 'someone@example.com'],
7373
from: 'other@example.com',
74+
tlsRejectUnauthorized: false,
7475
};
7576
const errors = {
7677
0: [],
@@ -79,7 +80,7 @@ describe('sendEmailNotification', () => {
7980
};
8081

8182
await expect(sendEmailNotification(notificationInfo, errors, false)).resolves.not.toThrow();
82-
expect(createTransportSpy).toBeCalledWith({ host: notificationInfo.host, port: notificationInfo.port });
83+
expect(createTransportSpy).toBeCalledWith({ host: notificationInfo.host, port: notificationInfo.port, tls: { rejectUnauthorized: false } });
8384
expect(sendMailMock).toBeCalled();
8485
const sendMailMockArgs = sendMailMock.mock.calls[0][0];
8586
expect(sendMailMockArgs.to).toEqual(notificationInfo.to);

0 commit comments

Comments
 (0)