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
9
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.6.0 to 1.7.0-SNAPSHOT.1

22

index.js

@@ -10,3 +10,3 @@ require(__dirname + "/lib/wasm_exec_node");

const run = function(profile, data, debug) {
const validateKernel = function(profile, data, debug) {
let before = new Date()

@@ -19,5 +19,13 @@ const res = __AMF__validateCustomProfile(profile,data, debug);

const validateWithReportConfigurationKernel = function(profile, data, debug, reportConfig) {
let before = new Date()
const res = __AMF__validateCustomProfileWithConfiguration(profile,data, debug, undefined, reportConfig);
let after = new Date();
if (debug) console.log("Elapsed : " + (after - before))
return res;
}
const validateCustomProfile = function(profile, data, debug, cb) {
if (initialized) {
let res = run(profile, data, debug);
let res = validateKernel(profile, data, debug);
cb(res,undefined);

@@ -29,2 +37,11 @@ } else {

const validateCustomProfileWithReportConfiguration = function(profile, data, debug, reportConfig, cb) {
if (initialized) {
let res = validateWithReportConfigurationKernel(profile, data, debug, reportConfig);
cb(res,undefined);
} else {
cb(undefined,new Error("WASM/GO not initialized"))
}
}
const runGenerateRego = function(profile) {

@@ -88,4 +105,5 @@ const res = __AMF__generateRego(profile);

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

2

package.json
{
"name": "@aml-org/amf-custom-validator",
"version": "1.6.0",
"version": "1.7.0-SNAPSHOT.1",
"description": "AMF validator backed by OPA Rego",

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

@@ -96,2 +96,30 @@ const fs = require("fs");

})
describe('validate with configuration', () => {
it("must match expected report output", (done) => {
const profile = fs.readFileSync(__dirname + "/../../../test/data/integration/profile26/profile.yaml").toString()
const data = fs.readFileSync(__dirname + "/../../../test/data/integration/profile26/negative.data.jsonld").toString()
const validator = require(__dirname + "/../index")
validator.initialize(() => {
const reportConfig = {
"IncludeReportCreationTime": false,
"ReportSchemaIri": "http://a.ml/report",
"LexicalSchemaIri": "http://a.ml/lexical"
}
validator.validateWithReportConfiguration(profile, data, false, reportConfig, (r, err) => {
if (err) {
done(err);
} else {
let report = JSON.parse(r)
assert.ok(report[0]["doc:encodes"][0]["dateCreated"] === undefined)
assert.strictEqual(report[0]["@context"]["reportSchema"], "http://a.ml/report#/declarations/")
assert.strictEqual(report[0]["@context"]["lexicalSchema"], "http://a.ml/lexical#/declarations/")
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