changed action for arc cluster to use az connectedk8s proxy
This commit is contained in:
4
node_modules/static-eval/.travis.yml
generated
vendored
Normal file
4
node_modules/static-eval/.travis.yml
generated
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- "0.8"
|
||||
- "0.10"
|
18
node_modules/static-eval/LICENSE
generated
vendored
Normal file
18
node_modules/static-eval/LICENSE
generated
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
This software is released under the MIT license:
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
7
node_modules/static-eval/example/eval.js
generated
vendored
Normal file
7
node_modules/static-eval/example/eval.js
generated
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
var evaluate = require('static-eval');
|
||||
var parse = require('esprima').parse;
|
||||
|
||||
var src = process.argv.slice(2).join(' ');
|
||||
var ast = parse(src).body[0].expression;
|
||||
|
||||
console.log(evaluate(ast));
|
11
node_modules/static-eval/example/vars.js
generated
vendored
Normal file
11
node_modules/static-eval/example/vars.js
generated
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
var evaluate = require('../');
|
||||
var parse = require('esprima').parse;
|
||||
|
||||
var src = '[1,2,3+4*10+n,foo(3+5),obj[""+"x"].y]';
|
||||
var ast = parse(src).body[0].expression;
|
||||
|
||||
console.log(evaluate(ast, {
|
||||
n: 6,
|
||||
foo: function (x) { return x * 100 },
|
||||
obj: { x: { y: 555 } }
|
||||
}));
|
178
node_modules/static-eval/index.js
generated
vendored
Normal file
178
node_modules/static-eval/index.js
generated
vendored
Normal file
@ -0,0 +1,178 @@
|
||||
var unparse = require('escodegen').generate;
|
||||
|
||||
module.exports = function (ast, vars) {
|
||||
if (!vars) vars = {};
|
||||
var FAIL = {};
|
||||
|
||||
var result = (function walk (node, scopeVars) {
|
||||
if (node.type === 'Literal') {
|
||||
return node.value;
|
||||
}
|
||||
else if (node.type === 'UnaryExpression'){
|
||||
var val = walk(node.argument)
|
||||
if (node.operator === '+') return +val
|
||||
if (node.operator === '-') return -val
|
||||
if (node.operator === '~') return ~val
|
||||
if (node.operator === '!') return !val
|
||||
return FAIL
|
||||
}
|
||||
else if (node.type === 'ArrayExpression') {
|
||||
var xs = [];
|
||||
for (var i = 0, l = node.elements.length; i < l; i++) {
|
||||
var x = walk(node.elements[i]);
|
||||
if (x === FAIL) return FAIL;
|
||||
xs.push(x);
|
||||
}
|
||||
return xs;
|
||||
}
|
||||
else if (node.type === 'ObjectExpression') {
|
||||
var obj = {};
|
||||
for (var i = 0; i < node.properties.length; i++) {
|
||||
var prop = node.properties[i];
|
||||
var value = prop.value === null
|
||||
? prop.value
|
||||
: walk(prop.value)
|
||||
;
|
||||
if (value === FAIL) return FAIL;
|
||||
obj[prop.key.value || prop.key.name] = value;
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
else if (node.type === 'BinaryExpression' ||
|
||||
node.type === 'LogicalExpression') {
|
||||
var l = walk(node.left);
|
||||
if (l === FAIL) return FAIL;
|
||||
var r = walk(node.right);
|
||||
if (r === FAIL) return FAIL;
|
||||
|
||||
var op = node.operator;
|
||||
if (op === '==') return l == r;
|
||||
if (op === '===') return l === r;
|
||||
if (op === '!=') return l != r;
|
||||
if (op === '!==') return l !== r;
|
||||
if (op === '+') return l + r;
|
||||
if (op === '-') return l - r;
|
||||
if (op === '*') return l * r;
|
||||
if (op === '/') return l / r;
|
||||
if (op === '%') return l % r;
|
||||
if (op === '<') return l < r;
|
||||
if (op === '<=') return l <= r;
|
||||
if (op === '>') return l > r;
|
||||
if (op === '>=') return l >= r;
|
||||
if (op === '|') return l | r;
|
||||
if (op === '&') return l & r;
|
||||
if (op === '^') return l ^ r;
|
||||
if (op === '&&') return l && r;
|
||||
if (op === '||') return l || r;
|
||||
|
||||
return FAIL;
|
||||
}
|
||||
else if (node.type === 'Identifier') {
|
||||
if ({}.hasOwnProperty.call(vars, node.name)) {
|
||||
return vars[node.name];
|
||||
}
|
||||
else return FAIL;
|
||||
}
|
||||
else if (node.type === 'ThisExpression') {
|
||||
if ({}.hasOwnProperty.call(vars, 'this')) {
|
||||
return vars['this'];
|
||||
}
|
||||
else return FAIL;
|
||||
}
|
||||
else if (node.type === 'CallExpression') {
|
||||
var callee = walk(node.callee);
|
||||
if (callee === FAIL) return FAIL;
|
||||
if (typeof callee !== 'function') return FAIL;
|
||||
|
||||
var ctx = node.callee.object ? walk(node.callee.object) : FAIL;
|
||||
if (ctx === FAIL) ctx = null;
|
||||
|
||||
var args = [];
|
||||
for (var i = 0, l = node.arguments.length; i < l; i++) {
|
||||
var x = walk(node.arguments[i]);
|
||||
if (x === FAIL) return FAIL;
|
||||
args.push(x);
|
||||
}
|
||||
return callee.apply(ctx, args);
|
||||
}
|
||||
else if (node.type === 'MemberExpression') {
|
||||
var obj = walk(node.object);
|
||||
// do not allow access to methods on Function
|
||||
if((obj === FAIL) || (typeof obj == 'function')){
|
||||
return FAIL;
|
||||
}
|
||||
if (node.property.type === 'Identifier') {
|
||||
return obj[node.property.name];
|
||||
}
|
||||
var prop = walk(node.property);
|
||||
if (prop === FAIL) return FAIL;
|
||||
return obj[prop];
|
||||
}
|
||||
else if (node.type === 'ConditionalExpression') {
|
||||
var val = walk(node.test)
|
||||
if (val === FAIL) return FAIL;
|
||||
return val ? walk(node.consequent) : walk(node.alternate)
|
||||
}
|
||||
else if (node.type === 'ExpressionStatement') {
|
||||
var val = walk(node.expression)
|
||||
if (val === FAIL) return FAIL;
|
||||
return val;
|
||||
}
|
||||
else if (node.type === 'ReturnStatement') {
|
||||
return walk(node.argument)
|
||||
}
|
||||
else if (node.type === 'FunctionExpression') {
|
||||
|
||||
var bodies = node.body.body;
|
||||
|
||||
// Create a "scope" for our arguments
|
||||
var oldVars = {};
|
||||
Object.keys(vars).forEach(function(element){
|
||||
oldVars[element] = vars[element];
|
||||
})
|
||||
|
||||
for(var i=0; i<node.params.length; i++){
|
||||
var key = node.params[i];
|
||||
if(key.type == 'Identifier'){
|
||||
vars[key.name] = null;
|
||||
}
|
||||
else return FAIL;
|
||||
}
|
||||
for(var i in bodies){
|
||||
if(walk(bodies[i]) === FAIL){
|
||||
return FAIL;
|
||||
}
|
||||
}
|
||||
// restore the vars and scope after we walk
|
||||
vars = oldVars;
|
||||
|
||||
var keys = Object.keys(vars);
|
||||
var vals = keys.map(function(key) {
|
||||
return vars[key];
|
||||
});
|
||||
return Function(keys.join(', '), 'return ' + unparse(node)).apply(null, vals);
|
||||
}
|
||||
else if (node.type === 'TemplateLiteral') {
|
||||
var str = '';
|
||||
for (var i = 0; i < node.expressions.length; i++) {
|
||||
str += walk(node.quasis[i]);
|
||||
str += walk(node.expressions[i]);
|
||||
}
|
||||
str += walk(node.quasis[i]);
|
||||
return str;
|
||||
}
|
||||
else if (node.type === 'TaggedTemplateExpression') {
|
||||
var tag = walk(node.tag);
|
||||
var quasi = node.quasi;
|
||||
var strings = quasi.quasis.map(walk);
|
||||
var values = quasi.expressions.map(walk);
|
||||
return tag.apply(null, [strings].concat(values));
|
||||
}
|
||||
else if (node.type === 'TemplateElement') {
|
||||
return node.value.cooked;
|
||||
}
|
||||
else return FAIL;
|
||||
})(ast);
|
||||
|
||||
return result === FAIL ? undefined : result;
|
||||
};
|
76
node_modules/static-eval/package.json
generated
vendored
Normal file
76
node_modules/static-eval/package.json
generated
vendored
Normal file
@ -0,0 +1,76 @@
|
||||
{
|
||||
"_from": "static-eval@2.0.2",
|
||||
"_id": "static-eval@2.0.2",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-N/D219Hcr2bPjLxPiV+TQE++Tsmrady7TqAJugLy7Xk1EumfDWS/f5dtBbkRCGE7wKKXuYockQoj8Rm2/pVKyg==",
|
||||
"_location": "/static-eval",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "version",
|
||||
"registry": true,
|
||||
"raw": "static-eval@2.0.2",
|
||||
"name": "static-eval",
|
||||
"escapedName": "static-eval",
|
||||
"rawSpec": "2.0.2",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "2.0.2"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/jsonpath"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/static-eval/-/static-eval-2.0.2.tgz",
|
||||
"_shasum": "2d1759306b1befa688938454c546b7871f806a42",
|
||||
"_spec": "static-eval@2.0.2",
|
||||
"_where": "C:\\Users\\atharvam\\repos-main\\k8s-set-context\\node_modules\\jsonpath",
|
||||
"author": {
|
||||
"name": "James Halliday",
|
||||
"email": "mail@substack.net",
|
||||
"url": "http://substack.net"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/substack/static-eval/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"dependencies": {
|
||||
"escodegen": "^1.8.1"
|
||||
},
|
||||
"deprecated": false,
|
||||
"description": "evaluate statically-analyzable expressions",
|
||||
"devDependencies": {
|
||||
"esprima": "^2.7.3",
|
||||
"tape": "^4.6.0"
|
||||
},
|
||||
"homepage": "https://github.com/substack/static-eval",
|
||||
"keywords": [
|
||||
"static",
|
||||
"eval",
|
||||
"expression",
|
||||
"esprima",
|
||||
"ast",
|
||||
"abstract",
|
||||
"syntax",
|
||||
"tree",
|
||||
"analysis"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "index.js",
|
||||
"name": "static-eval",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/substack/static-eval.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "tape test/*.js"
|
||||
},
|
||||
"testling": {
|
||||
"files": "test/*.js",
|
||||
"browsers": [
|
||||
"ie/8..latest",
|
||||
"ff/latest",
|
||||
"chrome/latest",
|
||||
"opera/latest",
|
||||
"safari/latest"
|
||||
]
|
||||
},
|
||||
"version": "2.0.2"
|
||||
}
|
87
node_modules/static-eval/readme.markdown
generated
vendored
Normal file
87
node_modules/static-eval/readme.markdown
generated
vendored
Normal file
@ -0,0 +1,87 @@
|
||||
# static-eval
|
||||
|
||||
evaluate statically-analyzable expressions
|
||||
|
||||
[](https://ci.testling.com/substack/static-eval)
|
||||
|
||||
[](http://travis-ci.org/substack/static-eval)
|
||||
|
||||
# security
|
||||
|
||||
static-eval is like `eval`. It is intended for use in build scripts and code transformations, doing some evaluation at build time—it is **NOT** suitable for handling arbitrary untrusted user input. Malicious user input _can_ execute arbitrary code.
|
||||
|
||||
# example
|
||||
|
||||
``` js
|
||||
var evaluate = require('static-eval');
|
||||
var parse = require('esprima').parse;
|
||||
|
||||
var src = process.argv[2];
|
||||
var ast = parse(src).body[0].expression;
|
||||
|
||||
console.log(evaluate(ast));
|
||||
```
|
||||
|
||||
If you stick to simple expressions, the result is statically analyzable:
|
||||
|
||||
```
|
||||
$ node '7*8+9'
|
||||
65
|
||||
$ node eval.js '[1,2,3+4*5-(5*11)]'
|
||||
[ 1, 2, -32 ]
|
||||
```
|
||||
|
||||
but if you use statements, undeclared identifiers, or syntax, the result is no
|
||||
longer statically analyzable and `evaluate()` returns `undefined`:
|
||||
|
||||
```
|
||||
$ node eval.js '1+2+3*n'
|
||||
undefined
|
||||
$ node eval.js 'x=5; x*2'
|
||||
undefined
|
||||
$ node eval.js '5-4*3'
|
||||
-7
|
||||
```
|
||||
|
||||
You can also declare variables and functions to use in the static evaluation:
|
||||
|
||||
``` js
|
||||
var evaluate = require('static-eval');
|
||||
var parse = require('esprima').parse;
|
||||
|
||||
var src = '[1,2,3+4*10+n,foo(3+5),obj[""+"x"].y]';
|
||||
var ast = parse(src).body[0].expression;
|
||||
|
||||
console.log(evaluate(ast, {
|
||||
n: 6,
|
||||
foo: function (x) { return x * 100 },
|
||||
obj: { x: { y: 555 } }
|
||||
}));
|
||||
```
|
||||
|
||||
# methods
|
||||
|
||||
``` js
|
||||
var evaluate = require('static-eval');
|
||||
```
|
||||
|
||||
## evaluate(ast, vars={})
|
||||
|
||||
Evaluate the [esprima](https://npmjs.org/package/esprima)-parsed abstract syntax
|
||||
tree object `ast` with an optional collection of variables `vars` to use in the
|
||||
static expression resolution.
|
||||
|
||||
If the expression contained in `ast` can't be statically resolved, `evaluate()`
|
||||
returns undefined.
|
||||
|
||||
# install
|
||||
|
||||
With [npm](https://npmjs.org) do:
|
||||
|
||||
```
|
||||
npm install static-eval
|
||||
```
|
||||
|
||||
# license
|
||||
|
||||
MIT
|
82
node_modules/static-eval/test/eval.js
generated
vendored
Normal file
82
node_modules/static-eval/test/eval.js
generated
vendored
Normal file
@ -0,0 +1,82 @@
|
||||
var test = require('tape');
|
||||
var evaluate = require('../');
|
||||
var parse = require('esprima').parse;
|
||||
|
||||
test('resolved', function (t) {
|
||||
t.plan(1);
|
||||
|
||||
var src = '[1,2,3+4*10+(n||6),foo(3+5),obj[""+"x"].y]';
|
||||
var ast = parse(src).body[0].expression;
|
||||
var res = evaluate(ast, {
|
||||
n: false,
|
||||
foo: function (x) { return x * 100 },
|
||||
obj: { x: { y: 555 } }
|
||||
});
|
||||
t.deepEqual(res, [ 1, 2, 49, 800, 555 ]);
|
||||
});
|
||||
|
||||
test('unresolved', function (t) {
|
||||
t.plan(1);
|
||||
|
||||
var src = '[1,2,3+4*10*z+n,foo(3+5),obj[""+"x"].y]';
|
||||
var ast = parse(src).body[0].expression;
|
||||
var res = evaluate(ast, {
|
||||
n: 6,
|
||||
foo: function (x) { return x * 100 },
|
||||
obj: { x: { y: 555 } }
|
||||
});
|
||||
t.equal(res, undefined);
|
||||
});
|
||||
|
||||
test('boolean', function (t) {
|
||||
t.plan(1);
|
||||
|
||||
var src = '[ 1===2+3-16/4, [2]==2, [2]!==2, [2]!==[2] ]';
|
||||
var ast = parse(src).body[0].expression;
|
||||
t.deepEqual(evaluate(ast), [ true, true, true, true ]);
|
||||
});
|
||||
|
||||
test('array methods', function(t) {
|
||||
t.plan(1);
|
||||
|
||||
var src = '[1, 2, 3].map(function(n) { return n * 2 })';
|
||||
var ast = parse(src).body[0].expression;
|
||||
t.deepEqual(evaluate(ast), [2, 4, 6]);
|
||||
});
|
||||
|
||||
test('array methods with vars', function(t) {
|
||||
t.plan(1);
|
||||
|
||||
var src = '[1, 2, 3].map(function(n) { return n * x })';
|
||||
var ast = parse(src).body[0].expression;
|
||||
t.deepEqual(evaluate(ast, {x: 2}), [2, 4, 6]);
|
||||
});
|
||||
|
||||
test('evaluate this', function(t) {
|
||||
t.plan(1);
|
||||
|
||||
var src = 'this.x + this.y.z';
|
||||
var ast = parse(src).body[0].expression;
|
||||
var res = evaluate(ast, {
|
||||
'this': { x: 1, y: { z: 100 } }
|
||||
});
|
||||
t.equal(res, 101);
|
||||
});
|
||||
|
||||
test('FunctionExpression unresolved', function(t) {
|
||||
t.plan(1);
|
||||
|
||||
var src = '(function(){console.log("Not Good")})';
|
||||
var ast = parse(src).body[0].expression;
|
||||
var res = evaluate(ast, {});
|
||||
t.equal(res, undefined);
|
||||
});
|
||||
|
||||
test('MemberExpressions from Functions unresolved', function(t) {
|
||||
t.plan(1);
|
||||
|
||||
var src = '(function () {}).constructor';
|
||||
var ast = parse(src).body[0].expression;
|
||||
var res = evaluate(ast, {});
|
||||
t.equal(res, undefined);
|
||||
});
|
16
node_modules/static-eval/test/prop.js
generated
vendored
Normal file
16
node_modules/static-eval/test/prop.js
generated
vendored
Normal file
@ -0,0 +1,16 @@
|
||||
var test = require('tape');
|
||||
var evaluate = require('../');
|
||||
var parse = require('esprima').parse;
|
||||
|
||||
test('function property', function (t) {
|
||||
t.plan(1);
|
||||
|
||||
var src = '[1,2,3+4*10+n,beep.boop(3+5),obj[""+"x"].y]';
|
||||
var ast = parse(src).body[0].expression;
|
||||
var res = evaluate(ast, {
|
||||
n: 6,
|
||||
beep: { boop: function (x) { return x * 100 } },
|
||||
obj: { x: { y: 555 } }
|
||||
});
|
||||
t.deepEqual(res, [ 1, 2, 49, 800, 555 ]);
|
||||
});
|
33
node_modules/static-eval/test/template-strings.js
generated
vendored
Normal file
33
node_modules/static-eval/test/template-strings.js
generated
vendored
Normal file
@ -0,0 +1,33 @@
|
||||
var test = require('tape');
|
||||
var evaluate = require('../');
|
||||
var parse = require('esprima').parse;
|
||||
|
||||
test('untagged template strings', function (t) {
|
||||
t.plan(1);
|
||||
|
||||
var src = '`${1},${2 + n},${`4,5`}`';
|
||||
var ast = parse(src).body[0].expression;
|
||||
var res = evaluate(ast, {
|
||||
n: 6
|
||||
});
|
||||
t.deepEqual(res, '1,8,4,5');
|
||||
});
|
||||
|
||||
test('tagged template strings', function (t) {
|
||||
t.plan(3);
|
||||
|
||||
var src = 'template`${1},${2 + n},${`4,5`}`';
|
||||
var ast = parse(src).body[0].expression;
|
||||
var res = evaluate(ast, {
|
||||
template: function (strings) {
|
||||
t.deepEqual(strings, ['', ',', ',', '']);
|
||||
|
||||
var values = [].slice.call(arguments, 1);
|
||||
t.deepEqual(values, [1, 8, '4,5']);
|
||||
|
||||
return 'foo';
|
||||
},
|
||||
n: 6
|
||||
});
|
||||
t.deepEqual(res, 'foo');
|
||||
})
|
Reference in New Issue
Block a user