Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@blacklane/kiev-js

Package Overview
Dependencies
Maintainers
4
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@blacklane/kiev-js - npm Package Compare versions

Comparing version 2.0.1 to 2.0.2

13

dist/kiev-js.cjs.development.js

@@ -48,5 +48,9 @@ 'use strict';

_proto.recursiveFilter = function recursiveFilter(attrs) {
_proto.recursiveFilter = function recursiveFilter(attrs, visited) {
var _this = this;
if (visited === void 0) {
visited = new Map();
}
var map = new Map();

@@ -58,7 +62,12 @@ Object.entries(attrs).forEach(function (pair) {

if (_this.typeOfObject(value)) {
map.set(key, _this.recursiveFilter(value));
if (!visited.has(key)) {
visited.set(key, value);
map.set(key, _this.recursiveFilter(value, visited));
}
} else if (_this.shouldKeep(key)) {
map.set(key, value);
visited.set(key, value);
} else {
map.set(key, _this.filteredText);
visited.set(key, value);
}

@@ -65,0 +74,0 @@ });

2

dist/kiev-js.cjs.production.min.js

@@ -1,2 +0,2 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("loglevel");function t(){return(t=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var i=arguments[t];for(var n in i)Object.prototype.hasOwnProperty.call(i,n)&&(e[n]=i[n])}return e}).apply(this,arguments)}var i,n=function(){function e(e){void 0===e&&(e=[]),this.filteredText="[FILTERED]",this.filters=e}var t=e.prototype;return t.run=function(e){return this.recursiveFilter(e)},t.recursiveFilter=function(e){var t=this,i=new Map;return Object.entries(e).forEach((function(e){var n=e[0],r=e[1];t.typeOfObject(r)?i.set(n,t.recursiveFilter(r)):t.shouldKeep(n)?i.set(n,r):i.set(n,t.filteredText)})),Object.fromEntries(i)},t.typeOfObject=function(e){return"object"==typeof e&&null!==e},t.shouldKeep=function(e){return!this.filters.includes(e)},e}();(i=exports.LogLevel||(exports.LogLevel={})).TRACE="TRACE",i.DEBUG="DEBUG",i.INFO="INFO",i.WARN="WARN",i.ERROR="ERROR",i.SILENT="SILENT",exports.Logger=function(){function i(e){this.application=e.application,this.environment=e.environment,this.fields=e.initializedFields,this.filter=new n(e.filterFields)}var r=i.prototype;return r.setFields=function(e){this.fields=t({},this.fields,e)},r.extend=function(e){return new i({application:this.application,environment:this.environment,initializedFields:t({},this.fields,e)})},r.setLevel=function(t){e.setLevel(t)},r.getLevel=function(){for(var t=null,i=0,n=Object.entries(e.levels);i<n.length;i++){var r=n[i],o=r[0],l=r[1];if(e.getLevel()===l){t=o;break}}return t},r.debug=function(t,i){void 0===i&&(i={}),e.debug(this._buildPayload(exports.LogLevel.DEBUG,t,i))},r.info=function(t,i){void 0===i&&(i={}),e.info(this._buildPayload(exports.LogLevel.INFO,t,i))},r.warn=function(t,i){void 0===i&&(i={}),e.warn(this._buildPayload(exports.LogLevel.WARN,t,i))},r.error=function(t,i){void 0===i&&(i={}),e.error(this._buildPayload(exports.LogLevel.ERROR,t,i))},r.trace=function(t,i){void 0===i&&(i={}),e.trace(this._buildPayload(exports.LogLevel.TRACE,t,i))},r._buildPayload=function(e,i,n){var r=this.filter.run(n),o=t({application:this.application,environment:this.environment,level:e,message:i,timestamp:(new Date).toISOString()},this.fields,r);return JSON.stringify(t({},o))},i}();
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("loglevel");function t(){return(t=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var i=arguments[t];for(var n in i)Object.prototype.hasOwnProperty.call(i,n)&&(e[n]=i[n])}return e}).apply(this,arguments)}var i,n=function(){function e(e){void 0===e&&(e=[]),this.filteredText="[FILTERED]",this.filters=e}var t=e.prototype;return t.run=function(e){return this.recursiveFilter(e)},t.recursiveFilter=function(e,t){var i=this;void 0===t&&(t=new Map);var n=new Map;return Object.entries(e).forEach((function(e){var r=e[0],o=e[1];i.typeOfObject(o)?t.has(r)||(t.set(r,o),n.set(r,i.recursiveFilter(o,t))):i.shouldKeep(r)?(n.set(r,o),t.set(r,o)):(n.set(r,i.filteredText),t.set(r,o))})),Object.fromEntries(n)},t.typeOfObject=function(e){return"object"==typeof e&&null!==e},t.shouldKeep=function(e){return!this.filters.includes(e)},e}();(i=exports.LogLevel||(exports.LogLevel={})).TRACE="TRACE",i.DEBUG="DEBUG",i.INFO="INFO",i.WARN="WARN",i.ERROR="ERROR",i.SILENT="SILENT",exports.Logger=function(){function i(e){this.application=e.application,this.environment=e.environment,this.fields=e.initializedFields,this.filter=new n(e.filterFields)}var r=i.prototype;return r.setFields=function(e){this.fields=t({},this.fields,e)},r.extend=function(e){return new i({application:this.application,environment:this.environment,initializedFields:t({},this.fields,e)})},r.setLevel=function(t){e.setLevel(t)},r.getLevel=function(){for(var t=null,i=0,n=Object.entries(e.levels);i<n.length;i++){var r=n[i],o=r[0],s=r[1];if(e.getLevel()===s){t=o;break}}return t},r.debug=function(t,i){void 0===i&&(i={}),e.debug(this._buildPayload(exports.LogLevel.DEBUG,t,i))},r.info=function(t,i){void 0===i&&(i={}),e.info(this._buildPayload(exports.LogLevel.INFO,t,i))},r.warn=function(t,i){void 0===i&&(i={}),e.warn(this._buildPayload(exports.LogLevel.WARN,t,i))},r.error=function(t,i){void 0===i&&(i={}),e.error(this._buildPayload(exports.LogLevel.ERROR,t,i))},r.trace=function(t,i){void 0===i&&(i={}),e.trace(this._buildPayload(exports.LogLevel.TRACE,t,i))},r._buildPayload=function(e,i,n){var r=this.filter.run(n),o=t({application:this.application,environment:this.environment,level:e,message:i,timestamp:(new Date).toISOString()},this.fields,r);return JSON.stringify(t({},o))},i}();
//# sourceMappingURL=kiev-js.cjs.production.min.js.map

@@ -44,5 +44,9 @@ import { setLevel, levels, getLevel, debug, info, warn, error, trace } from 'loglevel';

_proto.recursiveFilter = function recursiveFilter(attrs) {
_proto.recursiveFilter = function recursiveFilter(attrs, visited) {
var _this = this;
if (visited === void 0) {
visited = new Map();
}
var map = new Map();

@@ -54,7 +58,12 @@ Object.entries(attrs).forEach(function (pair) {

if (_this.typeOfObject(value)) {
map.set(key, _this.recursiveFilter(value));
if (!visited.has(key)) {
visited.set(key, value);
map.set(key, _this.recursiveFilter(value, visited));
}
} else if (_this.shouldKeep(key)) {
map.set(key, value);
visited.set(key, value);
} else {
map.set(key, _this.filteredText);
visited.set(key, value);
}

@@ -61,0 +70,0 @@ });

{
"version": "2.0.1",
"version": "2.0.2",
"license": "MIT",

@@ -4,0 +4,0 @@ "main": "dist/index.js",

@@ -98,3 +98,45 @@ import { AttributesFilter } from './filter'

})
describe('has circular reference', () => {
beforeEach(() => {
filterConfig = [
'firstName',
'lastName',
'email',
'street',
'clientToken'
]
attributesFilter = new AttributesFilter(filterConfig)
})
it('avoids infinite loop', () => {
expect.assertions(1)
interface Content {
firstName: string
shouldNotBeFiltered: string
itSelf: Content | null
}
const expectedResult = {
firstName: '[FILTERED]',
shouldNotBeFiltered: 'Something Important',
itSelf: {
firstName: '[FILTERED]',
shouldNotBeFiltered: 'Something Important'
}
}
const contentFiltered: Content = {
firstName: 'Mario',
shouldNotBeFiltered: 'Something Important',
itSelf: null
}
contentFiltered.itSelf = contentFiltered
const response = attributesFilter.run(contentFiltered)
expect(response).toStrictEqual(expectedResult)
})
})
})
})

@@ -5,3 +5,3 @@ export class AttributesFilter {

constructor (filters: string[] = []) {
constructor(filters: string[] = []) {
this.filters = filters

@@ -16,7 +16,7 @@ }

*/
public run (attrs: Object): Object {
public run(attrs: Object): Object {
return this.recursiveFilter(attrs)
}
private recursiveFilter (attrs: Object) {
private recursiveFilter(attrs: Object, visited = new Map()) {
const map = new Map()

@@ -28,7 +28,12 @@

if (this.typeOfObject(value)) {
map.set(key, this.recursiveFilter(value))
if (!visited.has(key)) {
visited.set(key, value)
map.set(key, this.recursiveFilter(value, visited))
}
} else if (this.shouldKeep(key)) {
map.set(key, value)
visited.set(key, value)
} else {
map.set(key, this.filteredText)
visited.set(key, value)
}

@@ -40,9 +45,9 @@ })

private typeOfObject (value: any): boolean {
private typeOfObject(value: any): boolean {
return typeof value === 'object' && value !== null
}
private shouldKeep (key: string): boolean {
private shouldKeep(key: string): boolean {
return !this.filters.includes(key)
}
}

@@ -197,5 +197,16 @@ import * as logLevel from 'loglevel'

const loggedData = JSON.parse(mockLogLevel.debug.mock.calls[0][0])
expect(loggedData.message).toStrictEqual(logMessage)
})
it('logs an object with cycle without any problem', () => {
expect.hasAssertions()
const obj = { parent: {} }
obj.parent = obj
const expected = 'Whatever'
logger.debug(expected, obj)
const loggedData = JSON.parse(mockLogLevel.debug.mock.calls[0][0])
expect(loggedData.message).toStrictEqual(expected)
})
})

@@ -202,0 +213,0 @@

@@ -26,3 +26,3 @@ import * as logger from 'loglevel'

constructor (config: LoggerConfig) {
constructor(config: LoggerConfig) {
this.application = config.application

@@ -40,3 +40,3 @@ this.environment = config.environment

*/
public setFields (fields: Object) {
public setFields(fields: Object) {
this.fields = { ...this.fields, ...fields }

@@ -50,3 +50,3 @@ }

*/
public extend (fields: Object): Logger {
public extend(fields: Object): Logger {
const config: LoggerConfig = {

@@ -68,3 +68,3 @@ application: this.application,

*/
public setLevel (level: LogLevel): void {
public setLevel(level: LogLevel): void {
logger.setLevel(level)

@@ -76,3 +76,3 @@ }

*/
public getLevel () {
public getLevel() {
let level: LogLevel | null = null

@@ -96,3 +96,3 @@

*/
public debug (message: string, payload: Object = {}): void {
public debug(message: string, payload: Object = {}): void {
logger.debug(this._buildPayload(LogLevel.DEBUG, message, payload))

@@ -108,3 +108,3 @@ }

*/
public info (message: string, payload: Object = {}): void {
public info(message: string, payload: Object = {}): void {
logger.info(this._buildPayload(LogLevel.INFO, message, payload))

@@ -120,3 +120,3 @@ }

*/
public warn (message: string, payload: Object = {}): void {
public warn(message: string, payload: Object = {}): void {
logger.warn(this._buildPayload(LogLevel.WARN, message, payload))

@@ -132,3 +132,3 @@ }

*/
public error (message: string, payload: Object = {}): void {
public error(message: string, payload: Object = {}): void {
logger.error(this._buildPayload(LogLevel.ERROR, message, payload))

@@ -144,3 +144,3 @@ }

*/
public trace (message: string, payload: Object = {}): void {
public trace(message: string, payload: Object = {}): void {
logger.trace(this._buildPayload(LogLevel.TRACE, message, payload))

@@ -156,3 +156,3 @@ }

*/
private _buildPayload (
private _buildPayload(
severity: string,

@@ -159,0 +159,0 @@ message: string,

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc