@azure-tools/codegen
Advanced tools
Comparing version 2.1.237 to 2.1.240
@@ -1,2 +0,11 @@ | ||
export declare const safeEval: <T>(expression: string, context?: any) => T; | ||
/** | ||
* A sandboxed eval function | ||
* | ||
* @deprecated consumers should create a local sandbox to reuse. (@see createSandbox ) | ||
* */ | ||
export declare const safeEval: <T>(code: string, context?: any) => T; | ||
/** | ||
* Creates a reusable safe-eval sandbox to execute code in. | ||
*/ | ||
export declare function createSandbox(): <T>(code: string, context?: any) => T; | ||
//# sourceMappingURL=safe-eval.d.ts.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
/*--------------------------------------------------------------------------------------------- | ||
@@ -6,5 +7,33 @@ * Copyright (c) Microsoft Corporation. All rights reserved. | ||
*--------------------------------------------------------------------------------------------*/ | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
/* eslint-disable */ | ||
exports.safeEval = require('safe-eval'); | ||
const vm = require("vm"); | ||
/** | ||
* A sandboxed eval function | ||
* | ||
* @deprecated consumers should create a local sandbox to reuse. (@see createSandbox ) | ||
* */ | ||
exports.safeEval = createSandbox(); | ||
/** | ||
* Creates a reusable safe-eval sandbox to execute code in. | ||
*/ | ||
function createSandbox() { | ||
const sandbox = vm.createContext({}); | ||
return (code, context) => { | ||
var response = 'SAFE_EVAL_' + Math.floor(Math.random() * 1000000); | ||
sandbox[response] = {}; | ||
if (context) { | ||
for (const key of Object.keys(context)) { | ||
sandbox[key] = context[key]; | ||
} | ||
vm.runInContext(`${response} = ${code}`, sandbox); | ||
for (const key of Object.keys(context)) { | ||
delete sandbox[key]; | ||
} | ||
} | ||
else { | ||
vm.runInContext(`${response} = ${code}`, sandbox); | ||
} | ||
return sandbox[response]; | ||
}; | ||
} | ||
exports.createSandbox = createSandbox; | ||
//# sourceMappingURL=safe-eval.js.map |
{ | ||
"name": "@azure-tools/codegen", | ||
"version": "2.1.237", | ||
"version": "2.1.240", | ||
"patchOffset": 100, | ||
@@ -51,8 +51,7 @@ "description": "Autorest Code generator common and base classes", | ||
"dependencies": { | ||
"@azure-tools/async-io": "~3.0.214", | ||
"@azure-tools/linq": "~3.1.222", | ||
"@azure-tools/async-io": "~3.0.215", | ||
"@azure-tools/linq": "~3.1.223", | ||
"js-yaml": "3.13.1", | ||
"semver": "^5.5.1", | ||
"safe-eval": "^0.3.0" | ||
"semver": "^5.5.1" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Debug access
Supply chain riskUses debug, reflection and dynamic code execution features.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
201625
4
2549
9
- Removedsafe-eval@^0.3.0
- Removedsafe-eval@0.3.0(transitive)
Updated@azure-tools/linq@~3.1.223