Currently, enabled log drivers are parsed from a comma-separated list and placed in an array of strings. Those strings are then used as property indexes on a LOG_DRIVERS object.
This breaks if there were any spaces in the comma-separated list of drivers, "json-file, none, gets split(",") that results in ["json-file", " none"] which eventually leads to LOG_DRIVERS.hasOwnProperty(" none") and that ultimately leads to assertion failure.
Here's the snippet of code that does the validation of log drivers.
if (config.enabledLogDrivers) {
assert.string(config.enabledLogDrivers, 'config.enabledLogDrivers-raw');
config.enabledLogDrivers = config.enabledLogDrivers.split(',');
} else {
config.enabledLogDrivers = ['json-file'];
}
assert.arrayOfString(config.enabledLogDrivers, 'config.enabledLogDrivers');
config.enabledLogDrivers.forEach(function _checkLogDriver(driver) {
assert.ok(common.LOG_DRIVERS.hasOwnProperty(driver),
'config.enabledLogDrivers.' + driver + ' is not a valid driver');
});
A valid fix is to trim each log driver from the comma-separated list after it's been converted into an array:
Currently, enabled log drivers are parsed from a comma-separated list and placed in an array of strings. Those strings are then used as property indexes on a
LOG_DRIVERS
object.This breaks if there were any spaces in the comma-separated list of drivers,
"json-file, none
, getssplit(",")
that results in["json-file", " none"]
which eventually leads toLOG_DRIVERS.hasOwnProperty(" none")
and that ultimately leads to assertion failure.Here's the snippet of code that does the validation of log drivers.
A valid fix is to trim each log driver from the comma-separated list after it's been converted into an array: