@datadog/native-iast-rewriter
Advanced tools
Comparing version 2.0.1 to 2.0.2
@@ -20,2 +20,3 @@ /* tslint:disable */ | ||
} | ||
export function init(): void | ||
export class Rewriter { | ||
@@ -22,0 +23,0 @@ constructor(config?: RewriterConfig | undefined | null) |
@@ -59,3 +59,4 @@ 'use strict' | ||
getSourcePathAndLineFromSourceMaps, | ||
cacheRewrittenSourceMap | ||
cacheRewrittenSourceMap, | ||
generateSourceMapFromFileContent | ||
} |
19
main.js
@@ -26,2 +26,3 @@ /** | ||
this.nativeRewriter = new NativeRewriter(config) | ||
this.setLogger(config) | ||
} else { | ||
@@ -41,2 +42,16 @@ this.nativeRewriter = new DummyRewriter() | ||
} | ||
setLogger (config) { | ||
if (config && (config.logger || config.logLevel)) { | ||
const logger = config.logger || console | ||
const logLevel = config.logLevel || 'ERROR' | ||
try { | ||
this.nativeRewriter.setLogger(logger, logLevel) | ||
} catch (e) { | ||
if (logger && logger.error) { | ||
logger.error(e) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
@@ -47,2 +62,4 @@ | ||
const iastRewriter = require('./wasm/wasm_iast_rewriter') | ||
iastRewriter.init() | ||
NativeRewriter = iastRewriter.Rewriter | ||
@@ -58,3 +75,3 @@ return CacheRewriter | ||
DummyRewriter, | ||
getPrepareStackTrace: getPrepareStackTrace | ||
getPrepareStackTrace | ||
} |
{ | ||
"name": "@datadog/native-iast-rewriter", | ||
"homepage": "https://github.com/DataDog/dd-native-iast-rewriter-js/blob/main/README.md", | ||
"version": "2.0.1", | ||
"version": "2.0.2", | ||
"description": "Datadog IAST instrumentation addon for NodeJS", | ||
@@ -90,3 +90,3 @@ "main": "main.js", | ||
"rustfmt": "rustfmt --config imports_granularity=Crate src/*.rs", | ||
"prepublishOnly": "run-p artifacts:prepare artifacts:prepublish", | ||
"prepublishOnly:napi": "run-p artifacts:prepare artifacts:prepublish", | ||
"version": "napi version", | ||
@@ -93,0 +93,0 @@ "test": "mocha --file 'test/setup.js' test/**/*.spec.js", |
/* tslint:disable */ | ||
/* eslint-disable */ | ||
export const memory: WebAssembly.Memory; | ||
export function init(): void; | ||
export function __wbg_rewriter_free(a: number): void; | ||
@@ -8,5 +9,7 @@ export function rewriter_new(a: number): number; | ||
export function rewriter_csiMethods(a: number, b: number): void; | ||
export function rewriter_setLogger(a: number, b: number, c: number, d: number, e: number): void; | ||
export function __wbindgen_malloc(a: number): number; | ||
export function __wbindgen_realloc(a: number, b: number, c: number): number; | ||
export function __wbindgen_exn_store(a: number): void; | ||
export function __wbindgen_add_to_stack_pointer(a: number): number; | ||
export function __wbindgen_exn_store(a: number): void; | ||
export function __wbindgen_free(a: number, b: number): void; |
@@ -5,2 +5,5 @@ /* tslint:disable */ | ||
*/ | ||
export function init(): void; | ||
/** | ||
*/ | ||
export class Rewriter { | ||
@@ -22,2 +25,7 @@ free(): void; | ||
csiMethods(): any; | ||
/** | ||
* @param {any} logger | ||
* @param {string} level | ||
*/ | ||
setLogger(logger: any, level: string): void; | ||
} |
let imports = {}; | ||
imports['__wbindgen_placeholder__'] = module.exports; | ||
let wasm; | ||
const { TextDecoder, TextEncoder } = require(`util`); | ||
const { log, setLogger } = require(String.raw`./snippets/native-iast-rewriter-acbd5d0040d81049/tracer_logger.js`); | ||
const { readFileSync } = require(`fs`); | ||
const { dirname } = require(`path`); | ||
const { TextEncoder, TextDecoder } = require(`util`); | ||
const heap = new Array(32).fill(undefined); | ||
const heap = new Array(128).fill(undefined); | ||
@@ -15,3 +18,3 @@ heap.push(undefined, null, true, false); | ||
function dropObject(idx) { | ||
if (idx < 36) return; | ||
if (idx < 132) return; | ||
heap[idx] = heap_next; | ||
@@ -27,10 +30,8 @@ heap_next = idx; | ||
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }); | ||
let WASM_VECTOR_LEN = 0; | ||
cachedTextDecoder.decode(); | ||
let cachedUint8Memory0 = null; | ||
let cachedUint8Memory0 = new Uint8Array(); | ||
function getUint8Memory0() { | ||
if (cachedUint8Memory0.byteLength === 0) { | ||
if (cachedUint8Memory0 === null || cachedUint8Memory0.byteLength === 0) { | ||
cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer); | ||
@@ -41,17 +42,2 @@ } | ||
function getStringFromWasm0(ptr, len) { | ||
return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len)); | ||
} | ||
function addHeapObject(obj) { | ||
if (heap_next === heap.length) heap.push(heap.length + 1); | ||
const idx = heap_next; | ||
heap_next = heap[idx]; | ||
heap[idx] = obj; | ||
return idx; | ||
} | ||
let WASM_VECTOR_LEN = 0; | ||
let cachedTextEncoder = new TextEncoder('utf-8'); | ||
@@ -76,3 +62,3 @@ | ||
const buf = cachedTextEncoder.encode(arg); | ||
const ptr = malloc(buf.length); | ||
const ptr = malloc(buf.length) >>> 0; | ||
getUint8Memory0().subarray(ptr, ptr + buf.length).set(buf); | ||
@@ -84,3 +70,3 @@ WASM_VECTOR_LEN = buf.length; | ||
let len = arg.length; | ||
let ptr = malloc(len); | ||
let ptr = malloc(len) >>> 0; | ||
@@ -101,3 +87,3 @@ const mem = getUint8Memory0(); | ||
} | ||
ptr = realloc(ptr, len, len = offset + arg.length * 3); | ||
ptr = realloc(ptr, len, len = offset + arg.length * 3) >>> 0; | ||
const view = getUint8Memory0().subarray(ptr + offset, ptr + len); | ||
@@ -117,6 +103,6 @@ const ret = encodeString(arg, view); | ||
let cachedInt32Memory0 = new Int32Array(); | ||
let cachedInt32Memory0 = null; | ||
function getInt32Memory0() { | ||
if (cachedInt32Memory0.byteLength === 0) { | ||
if (cachedInt32Memory0 === null || cachedInt32Memory0.byteLength === 0) { | ||
cachedInt32Memory0 = new Int32Array(wasm.memory.buffer); | ||
@@ -127,6 +113,24 @@ } | ||
let cachedFloat64Memory0 = new Float64Array(); | ||
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }); | ||
cachedTextDecoder.decode(); | ||
function getStringFromWasm0(ptr, len) { | ||
ptr = ptr >>> 0; | ||
return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len)); | ||
} | ||
function addHeapObject(obj) { | ||
if (heap_next === heap.length) heap.push(heap.length + 1); | ||
const idx = heap_next; | ||
heap_next = heap[idx]; | ||
heap[idx] = obj; | ||
return idx; | ||
} | ||
let cachedFloat64Memory0 = null; | ||
function getFloat64Memory0() { | ||
if (cachedFloat64Memory0.byteLength === 0) { | ||
if (cachedFloat64Memory0 === null || cachedFloat64Memory0.byteLength === 0) { | ||
cachedFloat64Memory0 = new Float64Array(wasm.memory.buffer); | ||
@@ -211,7 +215,21 @@ } | ||
*/ | ||
module.exports.init = function() { | ||
wasm.init(); | ||
}; | ||
let stack_pointer = 128; | ||
function addBorrowedObject(obj) { | ||
if (stack_pointer == 1) throw new Error('out of js stack'); | ||
heap[--stack_pointer] = obj; | ||
return stack_pointer; | ||
} | ||
/** | ||
*/ | ||
class Rewriter { | ||
static __wrap(ptr) { | ||
ptr = ptr >>> 0; | ||
const obj = Object.create(Rewriter.prototype); | ||
obj.ptr = ptr; | ||
obj.__wbg_ptr = ptr; | ||
@@ -222,4 +240,4 @@ return obj; | ||
__destroy_into_raw() { | ||
const ptr = this.ptr; | ||
this.ptr = 0; | ||
const ptr = this.__wbg_ptr; | ||
this.__wbg_ptr = 0; | ||
@@ -252,3 +270,3 @@ return ptr; | ||
const len1 = WASM_VECTOR_LEN; | ||
wasm.rewriter_rewrite(retptr, this.ptr, ptr0, len0, ptr1, len1); | ||
wasm.rewriter_rewrite(retptr, this.__wbg_ptr, ptr0, len0, ptr1, len1); | ||
var r0 = getInt32Memory0()[retptr / 4 + 0]; | ||
@@ -271,3 +289,3 @@ var r1 = getInt32Memory0()[retptr / 4 + 1]; | ||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); | ||
wasm.rewriter_csiMethods(retptr, this.ptr); | ||
wasm.rewriter_csiMethods(retptr, this.__wbg_ptr); | ||
var r0 = getInt32Memory0()[retptr / 4 + 0]; | ||
@@ -284,2 +302,22 @@ var r1 = getInt32Memory0()[retptr / 4 + 1]; | ||
} | ||
/** | ||
* @param {any} logger | ||
* @param {string} level | ||
*/ | ||
setLogger(logger, level) { | ||
try { | ||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); | ||
const ptr0 = passStringToWasm0(level, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); | ||
const len0 = WASM_VECTOR_LEN; | ||
wasm.rewriter_setLogger(retptr, this.__wbg_ptr, addBorrowedObject(logger), ptr0, len0); | ||
var r0 = getInt32Memory0()[retptr / 4 + 0]; | ||
var r1 = getInt32Memory0()[retptr / 4 + 1]; | ||
if (r1) { | ||
throw takeObject(r0); | ||
} | ||
} finally { | ||
wasm.__wbindgen_add_to_stack_pointer(16); | ||
heap[stack_pointer++] = undefined; | ||
} | ||
} | ||
} | ||
@@ -292,7 +330,2 @@ module.exports.Rewriter = Rewriter; | ||
module.exports.__wbindgen_error_new = function(arg0, arg1) { | ||
const ret = new Error(getStringFromWasm0(arg0, arg1)); | ||
return addHeapObject(ret); | ||
}; | ||
module.exports.__wbindgen_boolean_get = function(arg0) { | ||
@@ -307,6 +340,6 @@ const v = getObject(arg0); | ||
const ret = typeof(obj) === 'string' ? obj : undefined; | ||
var ptr0 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); | ||
var len0 = WASM_VECTOR_LEN; | ||
getInt32Memory0()[arg0 / 4 + 1] = len0; | ||
getInt32Memory0()[arg0 / 4 + 0] = ptr0; | ||
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); | ||
var len1 = WASM_VECTOR_LEN; | ||
getInt32Memory0()[arg0 / 4 + 1] = len1; | ||
getInt32Memory0()[arg0 / 4 + 0] = ptr1; | ||
}; | ||
@@ -330,2 +363,32 @@ | ||
module.exports.__wbindgen_string_new = function(arg0, arg1) { | ||
const ret = getStringFromWasm0(arg0, arg1); | ||
return addHeapObject(ret); | ||
}; | ||
module.exports.__wbg_log_1e5b8fc0542531be = function() { return handleError(function (arg0, arg1) { | ||
const ret = log(getObject(arg0), getObject(arg1)); | ||
return addHeapObject(ret); | ||
}, arguments) }; | ||
module.exports.__wbg_readFileSync_aa285b429e2cd22b = function() { return handleError(function (arg0, arg1) { | ||
const ret = readFileSync(getStringFromWasm0(arg0, arg1)); | ||
return addHeapObject(ret); | ||
}, arguments) }; | ||
module.exports.__wbg_dirname_58fb94654ffa26ce = function() { return handleError(function (arg0, arg1) { | ||
const ret = dirname(getStringFromWasm0(arg0, arg1)); | ||
return addHeapObject(ret); | ||
}, arguments) }; | ||
module.exports.__wbindgen_error_new = function(arg0, arg1) { | ||
const ret = new Error(getStringFromWasm0(arg0, arg1)); | ||
return addHeapObject(ret); | ||
}; | ||
module.exports.__wbg_setLogger_c5129afd2a443f10 = function() { return handleError(function (arg0) { | ||
const ret = setLogger(getObject(arg0)); | ||
return addHeapObject(ret); | ||
}, arguments) }; | ||
module.exports.__wbindgen_is_string = function(arg0) { | ||
@@ -346,7 +409,2 @@ const ret = typeof(getObject(arg0)) === 'string'; | ||
module.exports.__wbindgen_string_new = function(arg0, arg1) { | ||
const ret = getStringFromWasm0(arg0, arg1); | ||
return addHeapObject(ret); | ||
}; | ||
module.exports.__wbindgen_jsval_loose_eq = function(arg0, arg1) { | ||
@@ -366,6 +424,6 @@ const ret = getObject(arg0) == getObject(arg1); | ||
const ret = String(getObject(arg1)); | ||
const ptr0 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); | ||
const len0 = WASM_VECTOR_LEN; | ||
getInt32Memory0()[arg0 / 4 + 1] = len0; | ||
getInt32Memory0()[arg0 / 4 + 0] = ptr0; | ||
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); | ||
const len1 = WASM_VECTOR_LEN; | ||
getInt32Memory0()[arg0 / 4 + 1] = len1; | ||
getInt32Memory0()[arg0 / 4 + 0] = ptr1; | ||
}; | ||
@@ -382,3 +440,28 @@ | ||
module.exports.__wbg_get_57245cc7d7c7619d = function(arg0, arg1) { | ||
module.exports.__wbg_new_abda76e883ba8a5f = function() { | ||
const ret = new Error(); | ||
return addHeapObject(ret); | ||
}; | ||
module.exports.__wbg_stack_658279fe44541cf6 = function(arg0, arg1) { | ||
const ret = getObject(arg1).stack; | ||
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); | ||
const len1 = WASM_VECTOR_LEN; | ||
getInt32Memory0()[arg0 / 4 + 1] = len1; | ||
getInt32Memory0()[arg0 / 4 + 0] = ptr1; | ||
}; | ||
module.exports.__wbg_error_f851667af71bcfc6 = function(arg0, arg1) { | ||
let deferred0_0; | ||
let deferred0_1; | ||
try { | ||
deferred0_0 = arg0; | ||
deferred0_1 = arg1; | ||
console.error(getStringFromWasm0(arg0, arg1)); | ||
} finally { | ||
wasm.__wbindgen_free(deferred0_0, deferred0_1); | ||
} | ||
}; | ||
module.exports.__wbg_get_7303ed2ef026b2f5 = function(arg0, arg1) { | ||
const ret = getObject(arg0)[arg1 >>> 0]; | ||
@@ -388,3 +471,3 @@ return addHeapObject(ret); | ||
module.exports.__wbg_length_6e3bbe7c8bd4dbd8 = function(arg0) { | ||
module.exports.__wbg_length_820c786973abdd8a = function(arg0) { | ||
const ret = getObject(arg0).length; | ||
@@ -394,3 +477,3 @@ return ret; | ||
module.exports.__wbg_new_1d9a920c6bfc44a8 = function() { | ||
module.exports.__wbg_new_0394642eae39db16 = function() { | ||
const ret = new Array(); | ||
@@ -405,3 +488,3 @@ return addHeapObject(ret); | ||
module.exports.__wbg_new_268f7b7dd3430798 = function() { | ||
module.exports.__wbg_new_0f2b71ca2f2a6029 = function() { | ||
const ret = new Map(); | ||
@@ -411,3 +494,3 @@ return addHeapObject(ret); | ||
module.exports.__wbg_next_579e583d33566a86 = function(arg0) { | ||
module.exports.__wbg_next_f4bc0e96ea67da68 = function(arg0) { | ||
const ret = getObject(arg0).next; | ||
@@ -417,3 +500,3 @@ return addHeapObject(ret); | ||
module.exports.__wbg_next_aaef7c8aa5e212ac = function() { return handleError(function (arg0) { | ||
module.exports.__wbg_next_ec061e48a0e72a96 = function() { return handleError(function (arg0) { | ||
const ret = getObject(arg0).next(); | ||
@@ -423,3 +506,3 @@ return addHeapObject(ret); | ||
module.exports.__wbg_done_1b73b0672e15f234 = function(arg0) { | ||
module.exports.__wbg_done_b6abb27d42b63867 = function(arg0) { | ||
const ret = getObject(arg0).done; | ||
@@ -429,3 +512,3 @@ return ret; | ||
module.exports.__wbg_value_1ccc36bc03462d71 = function(arg0) { | ||
module.exports.__wbg_value_2f4ef2036bfad28e = function(arg0) { | ||
const ret = getObject(arg0).value; | ||
@@ -435,3 +518,3 @@ return addHeapObject(ret); | ||
module.exports.__wbg_iterator_6f9d4f28845f426c = function() { | ||
module.exports.__wbg_iterator_7c7e58f62eb84700 = function() { | ||
const ret = Symbol.iterator; | ||
@@ -441,3 +524,3 @@ return addHeapObject(ret); | ||
module.exports.__wbg_get_765201544a2b6869 = function() { return handleError(function (arg0, arg1) { | ||
module.exports.__wbg_get_f53c921291c381bd = function() { return handleError(function (arg0, arg1) { | ||
const ret = Reflect.get(getObject(arg0), getObject(arg1)); | ||
@@ -447,3 +530,3 @@ return addHeapObject(ret); | ||
module.exports.__wbg_call_97ae9d8645dc388b = function() { return handleError(function (arg0, arg1) { | ||
module.exports.__wbg_call_557a2f2deacc4912 = function() { return handleError(function (arg0, arg1) { | ||
const ret = getObject(arg0).call(getObject(arg1)); | ||
@@ -453,3 +536,3 @@ return addHeapObject(ret); | ||
module.exports.__wbg_new_0b9bfdd97583284e = function() { | ||
module.exports.__wbg_new_2b6fea4ea03b1b95 = function() { | ||
const ret = new Object(); | ||
@@ -459,7 +542,7 @@ return addHeapObject(ret); | ||
module.exports.__wbg_set_a68214f35c417fa9 = function(arg0, arg1, arg2) { | ||
module.exports.__wbg_set_b4da98d504ac6091 = function(arg0, arg1, arg2) { | ||
getObject(arg0)[arg1 >>> 0] = takeObject(arg2); | ||
}; | ||
module.exports.__wbg_isArray_27c46c67f498e15d = function(arg0) { | ||
module.exports.__wbg_isArray_04e59fb73f78ab5b = function(arg0) { | ||
const ret = Array.isArray(getObject(arg0)); | ||
@@ -469,3 +552,3 @@ return ret; | ||
module.exports.__wbg_instanceof_ArrayBuffer_e5e48f4762c5610b = function(arg0) { | ||
module.exports.__wbg_instanceof_ArrayBuffer_ef2632aa0d4bfff8 = function(arg0) { | ||
let result; | ||
@@ -481,3 +564,3 @@ try { | ||
module.exports.__wbg_set_933729cf5b66ac11 = function(arg0, arg1, arg2) { | ||
module.exports.__wbg_set_da7be7bf0e037b14 = function(arg0, arg1, arg2) { | ||
const ret = getObject(arg0).set(getObject(arg1), getObject(arg2)); | ||
@@ -487,3 +570,3 @@ return addHeapObject(ret); | ||
module.exports.__wbg_now_58886682b7e790d7 = function() { | ||
module.exports.__wbg_now_c857fb0367c762cc = function() { | ||
const ret = Date.now(); | ||
@@ -493,3 +576,3 @@ return ret; | ||
module.exports.__wbg_buffer_3f3d764d4747d564 = function(arg0) { | ||
module.exports.__wbg_buffer_55ba7a6b1b92e2ac = function(arg0) { | ||
const ret = getObject(arg0).buffer; | ||
@@ -499,3 +582,3 @@ return addHeapObject(ret); | ||
module.exports.__wbg_new_8c3f0052272a457a = function(arg0) { | ||
module.exports.__wbg_new_09938a7d020f049b = function(arg0) { | ||
const ret = new Uint8Array(getObject(arg0)); | ||
@@ -505,7 +588,7 @@ return addHeapObject(ret); | ||
module.exports.__wbg_set_83db9690f9353e79 = function(arg0, arg1, arg2) { | ||
module.exports.__wbg_set_3698e3ca519b3c3c = function(arg0, arg1, arg2) { | ||
getObject(arg0).set(getObject(arg1), arg2 >>> 0); | ||
}; | ||
module.exports.__wbg_length_9e1ae1900cb0fbd5 = function(arg0) { | ||
module.exports.__wbg_length_0aab7ffd65ad19ed = function(arg0) { | ||
const ret = getObject(arg0).length; | ||
@@ -515,3 +598,3 @@ return ret; | ||
module.exports.__wbg_instanceof_Uint8Array_971eeda69eb75003 = function(arg0) { | ||
module.exports.__wbg_instanceof_Uint8Array_1349640af2da2e88 = function(arg0) { | ||
let result; | ||
@@ -529,6 +612,6 @@ try { | ||
const ret = debugString(getObject(arg1)); | ||
const ptr0 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); | ||
const len0 = WASM_VECTOR_LEN; | ||
getInt32Memory0()[arg0 / 4 + 1] = len0; | ||
getInt32Memory0()[arg0 / 4 + 0] = ptr0; | ||
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); | ||
const len1 = WASM_VECTOR_LEN; | ||
getInt32Memory0()[arg0 / 4 + 1] = len1; | ||
getInt32Memory0()[arg0 / 4 + 0] = ptr1; | ||
}; | ||
@@ -535,0 +618,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2252346
17
1166
6