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

@datadog/native-iast-rewriter

Package Overview
Dependencies
Maintainers
1
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@datadog/native-iast-rewriter - npm Package Compare versions

Comparing version 1.0.0 to 1.1.0

7

index.d.ts

@@ -6,2 +6,7 @@ /* tslint:disable */

export interface CsiMethod {
src: string
dst?: string | undefined | null
operator?: boolean | undefined | null
}
export interface RewriterConfig {

@@ -11,2 +16,3 @@ chainSourceMap?: boolean

localVarPrefix?: string
csiMethods?: Array<CsiMethod> | undefined | null
}

@@ -16,2 +22,3 @@ export class Rewriter {

rewrite(code: string, file: string): string
csiMethods(): Array<string>
}

14

main.js

@@ -9,4 +9,2 @@ /**

class DummyRewriterConfig {}
class DummyRewriter {

@@ -16,5 +14,8 @@ rewrite (code, file) {

}
csiMethods () {
return []
}
}
let RewriterConfig = DummyRewriterConfig
let NativeRewriter

@@ -35,2 +36,6 @@ class CacheRewriter {

}
csiMethods () {
return this.nativeRewriter.csiMethods()
}
}

@@ -42,4 +47,2 @@

NativeRewriter = iastRewriter.Rewriter
RewriterConfig = iastRewriter.RewriterConfig
return CacheRewriter

@@ -53,4 +56,3 @@ } catch (e) {

Rewriter: getRewriter(),
RewriterConfig,
getPrepareStackTrace: getPrepareStackTrace
}
{
"name": "@datadog/native-iast-rewriter",
"homepage": "https://github.com/DataDog/dd-native-iast-rewriter-js/blob/main/README.md",
"version": "1.0.0",
"version": "1.1.0",
"description": "Datadog IAST instrumentation addon for NodeJS",

@@ -77,10 +77,10 @@ "main": "main.js",

"artifacts:gyp": "node ./scripts/artifacts-gyp.mjs",
"build": "wasm-pack build --scope datadog --out-dir wasm --out-name wasm_iast_rewriter --target nodejs --features \"wasm\"",
"build:napi": "napi build --platform --release && npm run artifacts:gyp",
"build:napi:debug": "napi build --platform && npm run artifacts:gyp",
"build:napi:linux": "napi build --target x86_64-unknown-linux-gnu --platform --release",
"build:napi:alpine": "napi build --target x86_64-unknown-linux-musl --platform --release",
"build:napi:windows": "napi build --target x86_64-pc-windows-msvc --platform --release",
"build:napi:darwin": "napi build --target x86_64-apple-darwin --platform --release",
"build:napi:darwinArm": "napi build --target aarch64-apple-darwin --platform --release",
"build": "wasm-pack build --scope datadog --out-dir wasm --out-name wasm_iast_rewriter --target nodejs",
"build:napi": "napi build --platform --release --features \"napi\" && npm run artifacts:gyp",
"build:napi:debug": "napi build --platform --features \"napi\" && npm run artifacts:gyp",
"build:napi:linux": "napi build --target x86_64-unknown-linux-gnu --platform --release --features \"napi\"",
"build:napi:alpine": "napi build --target x86_64-unknown-linux-musl --platform --release --features \"napi\"",
"build:napi:windows": "napi build --target x86_64-pc-windows-msvc --platform --release --features \"napi\"",
"build:napi:darwin": "napi build --target x86_64-apple-darwin --platform --release --features \"napi\"",
"build:napi:darwinArm": "napi build --target aarch64-apple-darwin --platform --release --features \"napi\"",
"format": "run-p format:prettier format:rs",

@@ -87,0 +87,0 @@ "format:prettier": "prettier . -w",

/* tslint:disable */
/* eslint-disable */
export const memory: WebAssembly.Memory;
export function __wbg_get_rewriterconfig_chainSourceMap(a: number): number;
export function __wbg_set_rewriterconfig_chainSourceMap(a: number, b: number): void;
export function __wbg_get_rewriterconfig_comments(a: number): number;
export function __wbg_set_rewriterconfig_comments(a: number, b: number): void;
export function rewriterconfig_new(): number;
export function rewriterconfig_localVarPrefix(a: number, b: number): void;
export function rewriterconfig_set_localVarPrefix(a: number, b: number, c: number): void;
export function __wbg_rewriter_free(a: number): void;
export function rewriter_new(a: number): number;
export function rewriter_rewrite(a: number, b: number, c: number, d: number, e: number, f: number): void;
export function __wbg_rewriterconfig_free(a: number): void;
export function rewriter_csiMethods(a: number, b: number): void;
export function __wbindgen_malloc(a: number): number;
export function __wbindgen_realloc(a: number, b: number, c: number): number;
export function __wbindgen_add_to_stack_pointer(a: number): number;
export function __wbindgen_free(a: number, b: 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;

@@ -8,5 +8,5 @@ /* tslint:disable */

/**
* @param {RewriterConfig | undefined} config
* @param {any} config_js
*/
constructor(config?: RewriterConfig);
constructor(config_js: any);
/**

@@ -18,19 +18,6 @@ * @param {string} code

rewrite(code: string, file: string): string;
}
/**
* @returns {any}
*/
export class RewriterConfig {
free(): void;
/**
*/
constructor();
/**
*/
chainSourceMap?: boolean;
/**
*/
comments?: boolean;
/**
*/
localVarPrefix?: string;
csiMethods(): any;
}
let imports = {};
imports['__wbindgen_placeholder__'] = module.exports;
let wasm;
const { TextDecoder, TextEncoder } = require(`util`);
const { TextEncoder, TextDecoder } = require(`util`);
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
cachedTextDecoder.decode();
let cachedUint8Memory0 = new Uint8Array();
function getUint8Memory0() {
if (cachedUint8Memory0.byteLength === 0) {
cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer);
}
return cachedUint8Memory0;
}
function getStringFromWasm0(ptr, len) {
return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
}
const heap = new Array(32).fill(undefined);

@@ -27,28 +10,29 @@

function getObject(idx) { return heap[idx]; }
let heap_next = heap.length;
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;
function dropObject(idx) {
if (idx < 36) return;
heap[idx] = heap_next;
heap_next = idx;
}
function isLikeNone(x) {
return x === undefined || x === null;
function takeObject(idx) {
const ret = getObject(idx);
dropObject(idx);
return ret;
}
let cachedInt32Memory0 = new Int32Array();
let WASM_VECTOR_LEN = 0;
function getInt32Memory0() {
if (cachedInt32Memory0.byteLength === 0) {
cachedInt32Memory0 = new Int32Array(wasm.memory.buffer);
let cachedUint8Memory0 = new Uint8Array();
function getUint8Memory0() {
if (cachedUint8Memory0.byteLength === 0) {
cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer);
}
return cachedInt32Memory0;
return cachedUint8Memory0;
}
let WASM_VECTOR_LEN = 0;
let cachedTextEncoder = new TextEncoder('utf-8');

@@ -107,22 +91,113 @@

function _assertClass(instance, klass) {
if (!(instance instanceof klass)) {
throw new Error(`expected instance of ${klass.name}`);
function isLikeNone(x) {
return x === undefined || x === null;
}
let cachedInt32Memory0 = new Int32Array();
function getInt32Memory0() {
if (cachedInt32Memory0.byteLength === 0) {
cachedInt32Memory0 = new Int32Array(wasm.memory.buffer);
}
return instance.ptr;
return cachedInt32Memory0;
}
function getObject(idx) { return heap[idx]; }
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
function dropObject(idx) {
if (idx < 36) return;
heap[idx] = heap_next;
heap_next = idx;
cachedTextDecoder.decode();
function getStringFromWasm0(ptr, len) {
return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
}
function takeObject(idx) {
const ret = getObject(idx);
dropObject(idx);
return ret;
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 = new Float64Array();
function getFloat64Memory0() {
if (cachedFloat64Memory0.byteLength === 0) {
cachedFloat64Memory0 = new Float64Array(wasm.memory.buffer);
}
return cachedFloat64Memory0;
}
function debugString(val) {
// primitive types
const type = typeof val;
if (type == 'number' || type == 'boolean' || val == null) {
return `${val}`;
}
if (type == 'string') {
return `"${val}"`;
}
if (type == 'symbol') {
const description = val.description;
if (description == null) {
return 'Symbol';
} else {
return `Symbol(${description})`;
}
}
if (type == 'function') {
const name = val.name;
if (typeof name == 'string' && name.length > 0) {
return `Function(${name})`;
} else {
return 'Function';
}
}
// objects
if (Array.isArray(val)) {
const length = val.length;
let debug = '[';
if (length > 0) {
debug += debugString(val[0]);
}
for(let i = 1; i < length; i++) {
debug += ', ' + debugString(val[i]);
}
debug += ']';
return debug;
}
// Test for built-in
const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
let className;
if (builtInMatches.length > 1) {
className = builtInMatches[1];
} else {
// Failed to match the standard '[object ClassName]'
return toString.call(val);
}
if (className == 'Object') {
// we're a user defined class or Object
// JSON.stringify avoids problems with cycles, and is generally much
// easier than looping through ownProperties of `val`.
try {
return 'Object(' + JSON.stringify(val) + ')';
} catch (_) {
return 'Object';
}
}
// errors
if (val instanceof Error) {
return `${val.name}: ${val.message}\n${val.stack}`;
}
// TODO we could test for more things here, like `Set`s and `Map`s.
return className;
}
function handleError(f, args) {
try {
return f.apply(this, args);
} catch (e) {
wasm.__wbindgen_exn_store(addHeapObject(e));
}
}
/**

@@ -151,12 +226,6 @@ */

/**
* @param {RewriterConfig | undefined} config
* @param {any} config_js
*/
constructor(config) {
let ptr0 = 0;
if (!isLikeNone(config)) {
_assertClass(config, RewriterConfig);
ptr0 = config.ptr;
config.ptr = 0;
}
const ret = wasm.rewriter_new(ptr0);
constructor(config_js) {
const ret = wasm.rewriter_new(addHeapObject(config_js));
return Rewriter.__wrap(ret);

@@ -193,73 +262,16 @@ }

}
}
module.exports.Rewriter = Rewriter;
/**
*/
class RewriterConfig {
static __wrap(ptr) {
const obj = Object.create(RewriterConfig.prototype);
obj.ptr = ptr;
return obj;
}
__destroy_into_raw() {
const ptr = this.ptr;
this.ptr = 0;
return ptr;
}
free() {
const ptr = this.__destroy_into_raw();
wasm.__wbg_rewriterconfig_free(ptr);
}
/**
* @returns {boolean | undefined}
* @returns {any}
*/
get chainSourceMap() {
const ret = wasm.__wbg_get_rewriterconfig_chainSourceMap(this.ptr);
return ret === 0xFFFFFF ? undefined : ret !== 0;
}
/**
* @param {boolean | undefined} arg0
*/
set chainSourceMap(arg0) {
wasm.__wbg_set_rewriterconfig_chainSourceMap(this.ptr, isLikeNone(arg0) ? 0xFFFFFF : arg0 ? 1 : 0);
}
/**
* @returns {boolean | undefined}
*/
get comments() {
const ret = wasm.__wbg_get_rewriterconfig_comments(this.ptr);
return ret === 0xFFFFFF ? undefined : ret !== 0;
}
/**
* @param {boolean | undefined} arg0
*/
set comments(arg0) {
wasm.__wbg_set_rewriterconfig_comments(this.ptr, isLikeNone(arg0) ? 0xFFFFFF : arg0 ? 1 : 0);
}
/**
*/
constructor() {
const ret = wasm.rewriterconfig_new();
return RewriterConfig.__wrap(ret);
}
/**
* @returns {string | undefined}
*/
get localVarPrefix() {
csiMethods() {
try {
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
wasm.rewriterconfig_localVarPrefix(retptr, this.ptr);
wasm.rewriter_csiMethods(retptr, this.ptr);
var r0 = getInt32Memory0()[retptr / 4 + 0];
var r1 = getInt32Memory0()[retptr / 4 + 1];
let v0;
if (r0 !== 0) {
v0 = getStringFromWasm0(r0, r1).slice();
wasm.__wbindgen_free(r0, r1 * 1);
var r2 = getInt32Memory0()[retptr / 4 + 2];
if (r2) {
throw takeObject(r1);
}
return v0;
return takeObject(r0);
} finally {

@@ -269,13 +281,40 @@ wasm.__wbindgen_add_to_stack_pointer(16);

}
/**
* @param {string | undefined} local_var_prefix
*/
set localVarPrefix(local_var_prefix) {
var ptr0 = isLikeNone(local_var_prefix) ? 0 : passStringToWasm0(local_var_prefix, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
var len0 = WASM_VECTOR_LEN;
wasm.rewriterconfig_set_localVarPrefix(this.ptr, ptr0, len0);
}
}
module.exports.RewriterConfig = RewriterConfig;
module.exports.Rewriter = Rewriter;
module.exports.__wbindgen_object_drop_ref = function(arg0) {
takeObject(arg0);
};
module.exports.__wbindgen_boolean_get = function(arg0) {
const v = getObject(arg0);
const ret = typeof(v) === 'boolean' ? (v ? 1 : 0) : 2;
return ret;
};
module.exports.__wbindgen_string_get = function(arg0, arg1) {
const obj = getObject(arg1);
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;
};
module.exports.__wbindgen_is_object = function(arg0) {
const val = getObject(arg0);
const ret = typeof(val) === 'object' && val !== null;
return ret;
};
module.exports.__wbindgen_is_undefined = function(arg0) {
const ret = getObject(arg0) === undefined;
return ret;
};
module.exports.__wbindgen_in = function(arg0, arg1) {
const ret = getObject(arg0) in getObject(arg1);
return ret;
};
module.exports.__wbindgen_error_new = function(arg0, arg1) {

@@ -286,2 +325,112 @@ const ret = new Error(getStringFromWasm0(arg0, arg1));

module.exports.__wbindgen_object_clone_ref = function(arg0) {
const ret = getObject(arg0);
return addHeapObject(ret);
};
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) {
const ret = getObject(arg0) == getObject(arg1);
return ret;
};
module.exports.__wbindgen_number_get = function(arg0, arg1) {
const obj = getObject(arg1);
const ret = typeof(obj) === 'number' ? obj : undefined;
getFloat64Memory0()[arg0 / 8 + 1] = isLikeNone(ret) ? 0 : ret;
getInt32Memory0()[arg0 / 4 + 0] = !isLikeNone(ret);
};
module.exports.__wbg_String_91fba7ded13ba54c = function(arg0, 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;
};
module.exports.__wbg_getwithrefkey_15c62c2b8546208d = function(arg0, arg1) {
const ret = getObject(arg0)[getObject(arg1)];
return addHeapObject(ret);
};
module.exports.__wbg_get_57245cc7d7c7619d = function(arg0, arg1) {
const ret = getObject(arg0)[arg1 >>> 0];
return addHeapObject(ret);
};
module.exports.__wbg_length_6e3bbe7c8bd4dbd8 = function(arg0) {
const ret = getObject(arg0).length;
return ret;
};
module.exports.__wbg_new_1d9a920c6bfc44a8 = function() {
const ret = new Array();
return addHeapObject(ret);
};
module.exports.__wbindgen_is_function = function(arg0) {
const ret = typeof(getObject(arg0)) === 'function';
return ret;
};
module.exports.__wbg_next_579e583d33566a86 = function(arg0) {
const ret = getObject(arg0).next;
return addHeapObject(ret);
};
module.exports.__wbg_next_aaef7c8aa5e212ac = function() { return handleError(function (arg0) {
const ret = getObject(arg0).next();
return addHeapObject(ret);
}, arguments) };
module.exports.__wbg_done_1b73b0672e15f234 = function(arg0) {
const ret = getObject(arg0).done;
return ret;
};
module.exports.__wbg_value_1ccc36bc03462d71 = function(arg0) {
const ret = getObject(arg0).value;
return addHeapObject(ret);
};
module.exports.__wbg_iterator_6f9d4f28845f426c = function() {
const ret = Symbol.iterator;
return addHeapObject(ret);
};
module.exports.__wbg_get_765201544a2b6869 = function() { return handleError(function (arg0, arg1) {
const ret = Reflect.get(getObject(arg0), getObject(arg1));
return addHeapObject(ret);
}, arguments) };
module.exports.__wbg_call_97ae9d8645dc388b = function() { return handleError(function (arg0, arg1) {
const ret = getObject(arg0).call(getObject(arg1));
return addHeapObject(ret);
}, arguments) };
module.exports.__wbg_set_a68214f35c417fa9 = function(arg0, arg1, arg2) {
getObject(arg0)[arg1 >>> 0] = takeObject(arg2);
};
module.exports.__wbg_isArray_27c46c67f498e15d = function(arg0) {
const ret = Array.isArray(getObject(arg0));
return ret;
};
module.exports.__wbg_instanceof_ArrayBuffer_e5e48f4762c5610b = function(arg0) {
let result;
try {
result = getObject(arg0) instanceof ArrayBuffer;
} catch {
result = false;
}
const ret = result;
return ret;
};
module.exports.__wbg_now_58886682b7e790d7 = function() {

@@ -292,2 +441,40 @@ const ret = Date.now();

module.exports.__wbg_buffer_3f3d764d4747d564 = function(arg0) {
const ret = getObject(arg0).buffer;
return addHeapObject(ret);
};
module.exports.__wbg_new_8c3f0052272a457a = function(arg0) {
const ret = new Uint8Array(getObject(arg0));
return addHeapObject(ret);
};
module.exports.__wbg_set_83db9690f9353e79 = function(arg0, arg1, arg2) {
getObject(arg0).set(getObject(arg1), arg2 >>> 0);
};
module.exports.__wbg_length_9e1ae1900cb0fbd5 = function(arg0) {
const ret = getObject(arg0).length;
return ret;
};
module.exports.__wbg_instanceof_Uint8Array_971eeda69eb75003 = function(arg0) {
let result;
try {
result = getObject(arg0) instanceof Uint8Array;
} catch {
result = false;
}
const ret = result;
return ret;
};
module.exports.__wbindgen_debug_string = function(arg0, arg1) {
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;
};
module.exports.__wbindgen_throw = function(arg0, arg1) {

@@ -297,2 +484,7 @@ throw new Error(getStringFromWasm0(arg0, arg1));

module.exports.__wbindgen_memory = function() {
const ret = wasm.memory;
return addHeapObject(ret);
};
const path = require('path').join(__dirname, 'wasm_iast_rewriter_bg.wasm');

@@ -299,0 +491,0 @@ const bytes = require('fs').readFileSync(path);

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