New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@monokle/validation

Package Overview
Dependencies
Maintainers
5
Versions
91
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@monokle/validation - npm Package Compare versions

Comparing version 0.12.1 to 0.13.0

58

lib/node.js

@@ -0,1 +1,7 @@

import fs from "fs";
import path from "path";
import fetch from 'node-fetch';
import requireFromString from 'require-from-string';
import virtual from '@rollup/plugin-virtual';
import { rollup } from 'rollup';
import { ResourceParser } from "./common/resourceParser.js";

@@ -10,4 +16,2 @@ import { MonokleValidator } from "./MonokleValidator.js";

import { YamlValidator } from "./validators/yaml-syntax/validator.js";
import fs from "fs";
import * as path from "path";
export function createExtensibleNodeMonokleValidator(parser = new ResourceParser(), schemaLoader = new SchemaLoader()) {

@@ -30,12 +34,4 @@ return new MonokleValidator(async (pluginName) => {

try {
const filePath = path.join(process.cwd(), ".monokle-plugins", `${pluginName}-plugin.js`);
if (fs.existsSync(filePath)) {
const customPlugin = await import(/* @vite-ignore */ filePath);
return new SimpleCustomValidator(customPlugin.default, parser);
}
else {
const url = `https://plugins.monokle.com/validation/${pluginName}/latest.js`;
const customPlugin = await importWithDataUrl(url);
return new SimpleCustomValidator(customPlugin.default, parser);
}
const customPlugin = await loadCustomPlugin(pluginName);
return new SimpleCustomValidator(customPlugin, parser);
}

@@ -48,12 +44,30 @@ catch (err) {

}
async function importWithDataUrl(url) {
const response = await fetch(url);
if (!response.ok) {
throw new Error(`Error fetching ${url}: ${response.statusText}`);
}
const source = await response.text();
const buff = Buffer.from(source);
const encodedSource = buff.toString("base64");
const dataUrl = `data:text/javascript;base64,${encodedSource}`;
return await import(/* @vite-ignore */ dataUrl);
async function bundlePluginCode(code) {
const bundle = await rollup({
input: 'pluginCode',
plugins: [
virtual({
pluginCode: code,
}),
],
});
const { output } = await bundle.generate({ format: 'commonjs' });
await bundle.close();
return output[0].code;
}
async function loadCustomPlugin(pluginName) {
const filePath = path.join(process.cwd(), '.monokle-plugins', `${pluginName}-plugin.js`);
const pluginCode = fs.existsSync(filePath)
? fs.readFileSync(filePath, { encoding: 'utf-8' })
: await (async () => {
const url = `https://plugins.monokle.com/validation/${pluginName}/latest.js`;
const response = await fetch(url);
if (!response.ok) {
throw new Error(`Error fetching ${url}: ${response.statusText}`);
}
return response.text();
})();
const code = await bundlePluginCode(pluginCode);
const customPlugin = requireFromString(code, filePath);
return customPlugin;
}
{
"name": "@monokle/validation",
"version": "0.12.1",
"version": "0.13.0",
"description": "Kubernetes resource validation",

@@ -51,12 +51,14 @@ "author": "Kubeshop",

"@types/lodash": "4.14.185",
"@types/require-from-string": "1.2.1",
"rimraf": "3.0.2",
"tiny-glob": "0.2.9",
"type-fest": "3.0.0",
"typescript": "4.8.3",
"uuid": "9.0.0",
"vite": "3.1.2",
"vitest": "0.23.4",
"tiny-glob": "0.2.9",
"uuid": "9.0.0"
"vitest": "0.23.4"
},
"dependencies": {
"@open-policy-agent/opa-wasm": "1.8.0",
"@rollup/plugin-virtual": "3.0.1",
"ajv": "6.12.6",

@@ -66,2 +68,5 @@ "change-case": "4.1.2",

"lodash": "4.17.21",
"node-fetch": "3.3.0",
"require-from-string": "2.0.2",
"rollup": "3.18.0",
"tiny-invariant": "1.2.0",

@@ -68,0 +73,0 @@ "yaml": "2.1.1",

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