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

@aml-org/amf-custom-validator

Package Overview
Dependencies
Maintainers
11
Versions
116
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@aml-org/amf-custom-validator - npm Package Compare versions

Comparing version 1.2.1 to 1.2.2

31

index.js

@@ -26,2 +26,31 @@ require(__dirname + "/lib/wasm_exec");

}
const runGenerateRego = function(profile) {
const res = __AMF__generateRego(profile);
return res;
}
const generateRego = function(profile, cb) {
if (initialized) {
let res = runGenerateRego(profile);
cb(res,undefined);
} else {
cb(undefined,new Error("WASM/GO not initialized"))
}
}
const runNormalizeInput = function(data) {
const res = __AMF__normalizeInput(data);
return res;
}
const normalizeInput = function(data, cb) {
if (initialized) {
let res = runNormalizeInput(data);
cb(res,undefined);
} else {
cb(undefined,new Error("WASM/GO not initialized"))
}
}
const initialize = function(cb) {

@@ -57,2 +86,4 @@ if (initialized === true) {

module.exports.validate = validateCustomProfile;
module.exports.generateRego = generateRego;
module.exports.normalizeInput = normalizeInput;
module.exports.exit = exit;

64

lib/wasm_exec.js

@@ -1,6 +0,1 @@

// wasm_exec.js obtained from https://github.com/golang/go/blob/758ac371ab930734053ed226ac62681e62ab8eea/misc/wasm/wasm_exec.js
// Log with custom changes (we should keep track if we diverge from original content):
// -
// ---------------------------------------------------
// Copyright 2018 The Go Authors. All rights reserved.

@@ -110,3 +105,3 @@ // Use of this source code is governed by a BSD-style

if (!global.crypto) {
if (!global.crypto && global.require) {
const nodeCrypto = require("crypto");

@@ -119,2 +114,5 @@ global.crypto = {

}
if (!global.crypto) {
throw new Error("global.crypto is not available, polyfill required (getRandomValues only)");
}

@@ -130,9 +128,15 @@ if (!global.performance) {

if (!global.TextEncoder) {
if (!global.TextEncoder && global.require) {
global.TextEncoder = require("util").TextEncoder;
}
if (!global.TextEncoder) {
throw new Error("global.TextEncoder is not available, polyfill required");
}
if (!global.TextDecoder) {
if (!global.TextDecoder && global.require) {
global.TextDecoder = require("util").TextDecoder;
}
if (!global.TextDecoder) {
throw new Error("global.TextDecoder is not available, polyfill required");
}

@@ -266,2 +270,3 @@ // End of polyfills for common API.

"runtime.wasmExit": (sp) => {
sp >>>= 0;
const code = this.mem.getInt32(sp + 8, true);

@@ -279,2 +284,3 @@ this.exited = true;

"runtime.wasmWrite": (sp) => {
sp >>>= 0;
const fd = getInt64(sp + 8);

@@ -288,2 +294,3 @@ const p = getInt64(sp + 16);

"runtime.resetMemoryDataView": (sp) => {
sp >>>= 0;
this.mem = new DataView(this._inst.exports.mem.buffer);

@@ -294,2 +301,3 @@ },

"runtime.nanotime1": (sp) => {
sp >>>= 0;
setInt64(sp + 8, (timeOrigin + performance.now()) * 1000000);

@@ -300,2 +308,3 @@ },

"runtime.walltime1": (sp) => {
sp >>>= 0;
const msec = (new Date).getTime();

@@ -308,2 +317,3 @@ setInt64(sp + 8, msec / 1000);

"runtime.scheduleTimeoutEvent": (sp) => {
sp >>>= 0;
const id = this._nextCallbackTimeoutID;

@@ -328,2 +338,3 @@ this._nextCallbackTimeoutID++;

"runtime.clearTimeoutEvent": (sp) => {
sp >>>= 0;
const id = this.mem.getInt32(sp + 8, true);

@@ -336,2 +347,3 @@ clearTimeout(this._scheduledTimeouts.get(id));

"runtime.getRandomData": (sp) => {
sp >>>= 0;
crypto.getRandomValues(loadSlice(sp + 8));

@@ -342,2 +354,3 @@ },

"syscall/js.finalizeRef": (sp) => {
sp >>>= 0;
const id = this.mem.getUint32(sp + 8, true);

@@ -355,2 +368,3 @@ this._goRefCounts[id]--;

"syscall/js.stringVal": (sp) => {
sp >>>= 0;
storeValue(sp + 24, loadString(sp + 8));

@@ -361,4 +375,5 @@ },

"syscall/js.valueGet": (sp) => {
sp >>>= 0;
const result = Reflect.get(loadValue(sp + 8), loadString(sp + 16));
sp = this._inst.exports.getsp(); // see comment above
sp = this._inst.exports.getsp() >>> 0; // see comment above
storeValue(sp + 32, result);

@@ -369,2 +384,3 @@ },

"syscall/js.valueSet": (sp) => {
sp >>>= 0;
Reflect.set(loadValue(sp + 8), loadString(sp + 16), loadValue(sp + 32));

@@ -375,2 +391,3 @@ },

"syscall/js.valueDelete": (sp) => {
sp >>>= 0;
Reflect.deleteProperty(loadValue(sp + 8), loadString(sp + 16));

@@ -381,2 +398,3 @@ },

"syscall/js.valueIndex": (sp) => {
sp >>>= 0;
storeValue(sp + 24, Reflect.get(loadValue(sp + 8), getInt64(sp + 16)));

@@ -387,2 +405,3 @@ },

"syscall/js.valueSetIndex": (sp) => {
sp >>>= 0;
Reflect.set(loadValue(sp + 8), getInt64(sp + 16), loadValue(sp + 24));

@@ -393,2 +412,3 @@ },

"syscall/js.valueCall": (sp) => {
sp >>>= 0;
try {

@@ -399,3 +419,3 @@ const v = loadValue(sp + 8);

const result = Reflect.apply(m, v, args);
sp = this._inst.exports.getsp(); // see comment above
sp = this._inst.exports.getsp() >>> 0; // see comment above
storeValue(sp + 56, result);

@@ -411,2 +431,3 @@ this.mem.setUint8(sp + 64, 1);

"syscall/js.valueInvoke": (sp) => {
sp >>>= 0;
try {

@@ -416,3 +437,3 @@ const v = loadValue(sp + 8);

const result = Reflect.apply(v, undefined, args);
sp = this._inst.exports.getsp(); // see comment above
sp = this._inst.exports.getsp() >>> 0; // see comment above
storeValue(sp + 40, result);

@@ -428,2 +449,3 @@ this.mem.setUint8(sp + 48, 1);

"syscall/js.valueNew": (sp) => {
sp >>>= 0;
try {

@@ -433,3 +455,3 @@ const v = loadValue(sp + 8);

const result = Reflect.construct(v, args);
sp = this._inst.exports.getsp(); // see comment above
sp = this._inst.exports.getsp() >>> 0; // see comment above
storeValue(sp + 40, result);

@@ -445,2 +467,3 @@ this.mem.setUint8(sp + 48, 1);

"syscall/js.valueLength": (sp) => {
sp >>>= 0;
setInt64(sp + 16, parseInt(loadValue(sp + 8).length));

@@ -451,2 +474,3 @@ },

"syscall/js.valuePrepareString": (sp) => {
sp >>>= 0;
const str = encoder.encode(String(loadValue(sp + 8)));

@@ -459,2 +483,3 @@ storeValue(sp + 16, str);

"syscall/js.valueLoadString": (sp) => {
sp >>>= 0;
const str = loadValue(sp + 8);

@@ -466,2 +491,3 @@ loadSlice(sp + 16).set(str);

"syscall/js.valueInstanceOf": (sp) => {
sp >>>= 0;
this.mem.setUint8(sp + 24, (loadValue(sp + 8) instanceof loadValue(sp + 16)) ? 1 : 0);

@@ -472,2 +498,3 @@ },

"syscall/js.copyBytesToGo": (sp) => {
sp >>>= 0;
const dst = loadSlice(sp + 8);

@@ -487,2 +514,3 @@ const src = loadValue(sp + 32);

"syscall/js.copyBytesToJS": (sp) => {
sp >>>= 0;
const dst = loadValue(sp + 8);

@@ -508,2 +536,5 @@ const src = loadSlice(sp + 16);

async run(instance) {
if (!(instance instanceof WebAssembly.Instance)) {
throw new Error("Go.run: WebAssembly.Instance expected");
}
this._inst = instance;

@@ -567,2 +598,9 @@ this.mem = new DataView(this._inst.exports.mem.buffer);

// The linker guarantees global data starts from at least wasmMinDataAddr.
// Keep in sync with cmd/link/internal/ld/data.go:wasmMinDataAddr.
const wasmMinDataAddr = 4096 + 8192;
if (offset >= wasmMinDataAddr) {
throw new Error("total length of command line and environment variables exceeds limit");
}
this._inst.exports.run(argc, argv);

@@ -627,2 +665,2 @@ if (this.exited) {

}
})();
})();
{
"name": "@aml-org/amf-custom-validator",
"version": "1.2.1",
"version": "1.2.2",
"description": "AMF validator backed by OPA Rego",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -15,5 +15,3 @@ const fs = require("fs");

const data = fs.readFileSync(__dirname + "/../../../test/data/integration/profile10/negative.data.jsonld").toString()
const validator = require(__dirname + "/../index")
validator.initialize(() => {

@@ -40,3 +38,40 @@ validator.validate(profile, data, false, (r, err) => {

});
it ("should generate the Rego code for a profile and exit", (done) => {
const profile = fs.readFileSync(__dirname + "/../../../test/data/integration/profile10/profile.yaml").toString()
const validator = require(__dirname + "/../index")
validator.initialize(() => {
validator.generateRego(profile, (r, err) => {
if (err) {
done(err);
} else {
assert.ok(r.indexOf("package profile_kiali") > -1)
validator.exit();
done();
}
});
})
})
it ("should normalize input data", (done) => {
const data = fs.readFileSync(__dirname + "/../../../test/data/integration/profile10/negative.data.jsonld").toString()
const validator = require(__dirname + "/../index")
validator.initialize(() => {
validator.normalizeInput(data, (r, err) => {
if (err) {
done(err);
} else {
assert.ok(r.indexOf("@ids") > -1)
validator.exit();
done();
}
});
})
})
})
})

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