zabbix-utils
Version:
TypeScript port of zabbix-utils - Python library for working with Zabbix API, Sender, and Getter protocols
56 lines • 2.31 kB
JavaScript
;
// zabbix_utils
//
// Copyright (C) 2001-2023 Zabbix SIA (Original Python library)
// Copyright (C) 2024-2025 Han Yong Lim <hanyong.lim@gmail.com> (TypeScript adaptation)
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the "Software"), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify,
// merge, publish, distribute, sublicense, and/or sell copies
// of the Software, and to permit persons to whom the Software
// is furnished to do so, subject to the following conditions:
Object.defineProperty(exports, "__esModule", { value: true });
exports.SensitiveFilter = exports.EmptyHandler = void 0;
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
// OTHER DEALINGS IN THE SOFTWARE.
const common_1 = require("./common");
class EmptyHandler {
/**
* Empty logging handler.
*/
emit(...args) {
// Do nothing
}
}
exports.EmptyHandler = EmptyHandler;
class SensitiveFilter {
/**
* Filter to hide sensitive Zabbix info (password, auth) in logs
*/
hideData(rawData) {
return JSON.stringify(common_1.ModuleUtils.hidePrivate(rawData), null, 4);
}
filter(record) {
if (Array.isArray(record.args)) {
record.args = record.args.map((arg) => typeof arg === 'object' && arg !== null && !Array.isArray(arg)
? this.hideData(arg)
: arg);
}
if (typeof record.args === 'object' && record.args !== null && !Array.isArray(record.args)) {
record.args = this.hideData(record.args);
}
return true;
}
}
exports.SensitiveFilter = SensitiveFilter;
//# sourceMappingURL=logger.js.map