Skip to content

Commit bfe916a

Browse files
authored
Upgrade to sailor 2.6.18 (#42)
Upgrade to sailor 2.6.18 Delete sensitive data from logs
1 parent 8bfc7c7 commit bfe916a

File tree

9 files changed

+263
-122
lines changed

9 files changed

+263
-122
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## 1.3.3 (October 30, 2020)
2+
3+
* Upgrade to sailor 2.6.18
4+
* Annual audit of the component code to check if it exposes a sensitive data in the logs
5+
16
## 1.3.2 (June 6, 2020)
27

38
* Remove update docs on deploy script

lib/actions/attachmentToJson.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ function checkFileName(self, fileName, pattern) {
1313
}
1414

1515
if (!pattern.test(fileName)) {
16-
self.logger.debug('%s does not match pattern: \'%s\'', fileName, pattern);
16+
self.logger.debug('Filename does not match pattern');
1717
return false;
1818
}
1919

2020
if (fileName.split('.').pop() !== 'xml') {
21-
self.logger.debug('%s is not .xml file: ', fileName);
21+
self.logger.debug('Provided fileName is not .xml file');
2222
return false;
2323
}
2424

@@ -40,14 +40,14 @@ module.exports.process = async function processAction(msg, cfg) {
4040
const fileName = key;
4141
// get file size based attachment object may not be define or be accurate
4242
let fileSize = attachment.size;
43-
self.logger.info('Processing attachment=%s', fileName);
43+
self.logger.info('Processing attachment');
4444

4545
if (checkFileName(self, fileName, pattern)) {
4646
if (fileSize === undefined || fileSize < MAX_FILE_SIZE) {
4747
// eslint-disable-next-line no-await-in-loop
4848
const response = await new AttachmentProcessor().getAttachment(attachment.url, 'arraybuffer');
4949

50-
this.logger.debug(`For filename ${fileName} Response status: ${response.status} Response headers: ${JSON.stringify(response.headers)}`);
50+
this.logger.debug(`For provided filename response status: ${response.status}`);
5151

5252
if (response.status >= 400) {
5353
throw new Error(`Error in making request to ${attachment.url}
@@ -61,12 +61,11 @@ module.exports.process = async function processAction(msg, cfg) {
6161
throw new Error(`Empty attachment received for file ${fileName}`);
6262
}
6363

64-
this.logger.debug(`For filename ${fileName} Response Body string: ${responseBodyString}`);
6564
fileSize = sizeof(responseBodyString);
6665

6766
if (fileSize < MAX_FILE_SIZE) {
6867
const returnMsg = await xml2Json.process(this, responseBodyString);
69-
this.logger.debug(`For filename ${fileName} Result of XML Conversion: ${JSON.stringify(returnMsg)}`);
68+
this.logger.debug('Attachment to XML finished');
7069
foundXML = true;
7170
await self.emit('data', messages.newMessageWithBody(returnMsg.body));
7271
} else {
@@ -80,6 +79,6 @@ module.exports.process = async function processAction(msg, cfg) {
8079
}
8180
}
8281
if (!foundXML) {
83-
self.logger.info(`No XML files that match the pattern found with in attachments. Pattern: ${pattern}`);
82+
self.logger.info('No XML files that match the pattern found within attachments');
8483
}
8584
};

lib/actions/jsonToXml.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ module.exports.process = async function process(msg, cfg) {
5252
const attachmentProcessor = new AttachmentProcessor();
5353
const uploadResult = await attachmentProcessor.uploadAttachment(xmlString);
5454
const attachmentUrl = uploadResult.config.url;
55-
this.logger.info(`Successfully created attachment at ${attachmentUrl}`);
55+
this.logger.info('Attachment created successfully');
5656

5757
const outboundMessage = messages.newEmptyMessage();
5858
outboundMessage.attachments = {

lib/actions/jsonToXmlOld.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/* eslint no-invalid-this: 0 no-console: 0 */
21
const eioUtils = require('elasticio-node').messages;
32
const xml2js = require('xml2js');
43
const _ = require('lodash');
@@ -41,8 +40,9 @@ function validateJsonPropNames(value, key) {
4140
* @param msg incoming message object that contains ``body`` with payload
4241
* @param cfg configuration that is account information and configuration field values
4342
*/
43+
// eslint-disable-next-line no-unused-vars
4444
function processAction(msg, cfg) {
45-
this.logger.debug('Action started, message=%j cfg=%j', msg, cfg);
45+
this.logger.debug('Action started...');
4646
const options = {
4747
trim: false,
4848
normalize: false,
@@ -60,7 +60,7 @@ function processAction(msg, cfg) {
6060
validateJsonPropNames(jsonToTransform);
6161

6262
const result = builder.buildObject(jsonToTransform);
63-
this.logger.debug('Successfully converted body to XML result=%s', result);
63+
this.logger.debug('Successfully converted body to XML');
6464
return eioUtils.newMessageWithBody({
6565
xmlString: result,
6666
});

lib/actions/parse.js

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/* eslint no-invalid-this: 0 no-console: 0 */
21
const elasticio = require('elasticio-node');
32

43
const { messages } = elasticio;
@@ -18,7 +17,7 @@ let unmarshaller;
1817
*/
1918
module.exports.process = function processAction(msg, cfg) {
2019
co(function* gen() {
21-
this.logger.debug('Action started cfg=%j', cfg);
20+
this.logger.debug('Action started...');
2221
// We need to make sure we execute initialization only once
2322
yield lock.acquireAsync();
2423
try {
@@ -31,9 +30,10 @@ module.exports.process = function processAction(msg, cfg) {
3130
-compact \
3231
-logLevel DEBUG \
3332
"${cfg.schemaUri}"`;
34-
this.logger.debug('Starting JAVA process cmd=%s', cmd);
33+
this.logger.debug('Starting JAVA process...');
34+
// eslint-disable-next-line no-unused-vars
3535
const out = yield exec(cmd);
36-
this.logger.debug('%s\nGeneration completed', out);
36+
this.logger.debug('Generation completed');
3737
this.logger.debug('Loading mappings from ./mappings/index.js');
3838
// eslint-disable-next-line global-require, import/no-unresolved
3939
const mappings = require('../../mappings');
@@ -50,18 +50,17 @@ module.exports.process = function processAction(msg, cfg) {
5050
if (msg.body.xml && typeof msg.body.xml === 'string') {
5151
this.logger.info('Found input data in incoming message length of XML is length=%s', msg.body.xml.length);
5252
const result = unmarshaller.unmarshalString(msg.body.xml);
53-
this.logger.debug('Parsed XML to JSON json=%j', result);
53+
this.logger.debug('XML parsed to JSON');
5454
this.emit('data', messages.newMessageWithBody(result));
5555
} else if (msg.attachments && Object.keys(msg.attachments).length > 0) {
56-
this.logger.info('Found attachments in the message keys=%s', Object.keys(msg.attachments));
56+
this.logger.info(`Found attachments in the message keys=${Object.keys(msg.attachments).length}`);
5757
this.emit('data', msg);
5858
} else {
59-
this.logger.debug('No data XML payload found in the incoming message or it\'s attachments, '
60-
+ 'no processing will be done msg=%j', msg);
59+
this.logger.debug('No data XML payload found in the incoming message or it\'s attachments');
6160
}
6261
this.emit('end');
6362
}.bind(this)).catch((err) => {
64-
this.logger.info('Error occurred', err.stack || err);
63+
this.logger.info('Error in parsing occurred');
6564
this.emit('error', err);
6665
this.emit('end');
6766
});

lib/actions/xmlToJson.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/* eslint no-invalid-this: 0 no-console: 0 */
21
const xml2Json = require('../xml2Json.js');
32

43
/**
@@ -7,8 +6,8 @@ const xml2Json = require('../xml2Json.js');
76
* @param msg incoming message object that contains ``body`` with payload
87
* @param cfg configuration that is account information and configuration field values
98
*/
9+
// eslint-disable-next-line no-unused-vars
1010
module.exports.process = function processAction(msg, cfg) {
11-
this.logger.trace('Action started, message=%j cfg=%j', msg, cfg);
1211
if (!msg.body || !msg.body.xmlString) {
1312
this.emit('error', 'Missing XML String as input');
1413
this.emit('end');

lib/xml2Json.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ module.exports.process = async function xml2Json(self, xmlString) {
2525
return new Promise(((resolve, reject) => {
2626
parser.parseString(xmlString, (err, data) => {
2727
if (err) {
28-
self.logger.info('Error occurred', err.stack || err);
28+
self.logger.info('Error in xml2Json occurred');
2929
reject(new Error(invalidXmlMessage));
3030
} else {
3131
self.logger.info('Successfully converted XML to JSON');

0 commit comments

Comments
 (0)