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

@webassemblyjs/wasm-edit

Package Overview
Dependencies
Maintainers
1
Versions
84
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@webassemblyjs/wasm-edit - npm Package Compare versions

Comparing version 1.2.7 to 1.2.8

16

lib/apply.js

@@ -75,3 +75,4 @@ "use strict";

var newValue = node.metadata.bodySize + bodySizeDeltaBytes;
var newByteArray = (0, _encoder.encodeU32)(newValue); // function body size byte
var newByteArray = (0, _encoder.encodeU32)(newValue);
debug("resize func body newValue=%d", newValue); // function body size byte
// FIXME(sven): only handles one byte u32

@@ -133,3 +134,5 @@

var _deltaBytes = -sectionMetadata.size;
var _deltaBytes = -(sectionMetadata.size.value + 1)
/* section id */
;

@@ -177,7 +180,8 @@ return {

var newByteArray = (0, _wasmGen.encodeNode)(node); // start at the end of the section
var newByteArray = (0, _wasmGen.encodeNode)(node); // The size of the section doesn't include the storage of the size itself
// we need to manually add it here
// FIXME(sven): preprocess it into the AST?
var start = sectionMetadata.startOffset + sectionMetadata.size + 1;
var start = sectionMetadata.startOffset + sectionMetadata.size.value + (sectionMetadata.size.loc.end.column - sectionMetadata.size.loc.start.column);
var end = start;
debug("add node=%s section=%s after=%d", node.type, sectionName, start);
uint8Buffer = (0, _helperBuffer.overrideBytesInBuffer)(uint8Buffer, start, end, newByteArray);

@@ -189,2 +193,3 @@ /**

var deltaBytes = newByteArray.length;
debug("add node=%s section=%s after=%d deltaBytes=%s deltaElements=%s", node.type, sectionName, start, deltaBytes, deltaElements);
return {

@@ -228,2 +233,3 @@ uint8Buffer: uint8Buffer,

ops.forEach(function (op) {
// We don't need to handle add ops, they are positioning independent
switch (op.kind) {

@@ -230,0 +236,0 @@ case "update":

@@ -15,2 +15,4 @@ "use strict";

var _wasmOpt = require("@webassemblyjs/wasm-opt");
var _apply = require("./apply");

@@ -28,4 +30,10 @@

function preprocess(ab) {
var optBin = (0, _wasmOpt.shrinkPaddedLEB128)(new Uint8Array(ab));
return optBin.buffer;
}
function edit(ab, visitors) {
var operations = [];
ab = preprocess(ab);
var ast = (0, _wasmParser.decode)(ab, decoderOpts);

@@ -60,4 +68,6 @@ var uint8Buffer = new Uint8Array(ab);

function add(ab, newNodes) {
ab = preprocess(ab);
var ast = (0, _wasmParser.decode)(ab, decoderOpts);
var uint8Buffer = new Uint8Array(ab);
var uint8Buffer = new Uint8Array(ab); // Map node into operations
var operations = newNodes.map(function (n) {

@@ -64,0 +74,0 @@ return {

{
"name": "@webassemblyjs/wasm-edit",
"version": "1.2.7",
"version": "1.2.8",
"description": "",

@@ -19,11 +19,15 @@ "main": "lib/index.js",

"dependencies": {
"@webassemblyjs/ast": "1.2.7",
"@webassemblyjs/helper-buffer": "1.2.7",
"@webassemblyjs/helper-wasm-bytecode": "1.2.7",
"@webassemblyjs/helper-wasm-section": "1.2.7",
"@webassemblyjs/wasm-gen": "1.2.7",
"@webassemblyjs/wasm-parser": "1.2.7",
"@webassemblyjs/wast-printer": "1.2.7",
"@webassemblyjs/ast": "1.2.8",
"@webassemblyjs/helper-buffer": "1.2.8",
"@webassemblyjs/helper-wasm-bytecode": "1.2.8",
"@webassemblyjs/helper-wasm-section": "1.2.8",
"@webassemblyjs/wasm-gen": "1.2.8",
"@webassemblyjs/wasm-opt": "1.2.8",
"@webassemblyjs/wasm-parser": "1.2.8",
"@webassemblyjs/wast-printer": "1.2.8",
"debug": "^3.1.0"
},
"devDependencies": {
"@webassemblyjs/helper-test-framework": "1.2.8"
}
}

@@ -89,2 +89,4 @@ // @flow

debug("resize func body newValue=%d", newValue);
// function body size byte

@@ -148,3 +150,3 @@ // FIXME(sven): only handles one byte u32

const deltaBytes = -sectionMetadata.size;
const deltaBytes = -(sectionMetadata.size.value + 1) /* section id */;

@@ -196,9 +198,13 @@ return { uint8Buffer, deltaBytes, deltaElements };

// start at the end of the section
const start = sectionMetadata.startOffset + sectionMetadata.size + 1;
// The size of the section doesn't include the storage of the size itself
// we need to manually add it here
// FIXME(sven): preprocess it into the AST?
const start =
sectionMetadata.startOffset +
sectionMetadata.size.value +
(sectionMetadata.size.loc.end.column -
sectionMetadata.size.loc.start.column);
const end = start;
debug("add node=%s section=%s after=%d", node.type, sectionName, start);
uint8Buffer = overrideBytesInBuffer(uint8Buffer, start, end, newByteArray);

@@ -211,2 +217,11 @@

debug(
"add node=%s section=%s after=%d deltaBytes=%s deltaElements=%s",
node.type,
sectionName,
start,
deltaBytes,
deltaElements
);
return { uint8Buffer, deltaBytes, deltaElements };

@@ -249,2 +264,3 @@ }

ops.forEach(op => {
// We don't need to handle add ops, they are positioning independent
switch (op.kind) {

@@ -251,0 +267,0 @@ case "update":

@@ -6,2 +6,4 @@ // @flow

import { cloneNode } from "@webassemblyjs/ast/lib/clone";
import { shrinkPaddedLEB128 } from "@webassemblyjs/wasm-opt";
import { applyOperations } from "./apply";

@@ -19,5 +21,12 @@

function preprocess(ab: ArrayBuffer): ArrayBuffer {
const optBin = shrinkPaddedLEB128(new Uint8Array(ab));
return optBin.buffer;
}
export function edit(ab: ArrayBuffer, visitors: Object): ArrayBuffer {
const operations: Array<Operation> = [];
ab = preprocess(ab);
const ast = decode(ab, decoderOpts);

@@ -57,2 +66,4 @@

export function add(ab: ArrayBuffer, newNodes: Array<Node>): ArrayBuffer {
ab = preprocess(ab);
const ast = decode(ab, decoderOpts);

@@ -62,2 +73,3 @@

// Map node into operations
const operations = newNodes.map(n => ({

@@ -64,0 +76,0 @@ kind: "add",

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