Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
ctx = core.mkCTX({
query: ctx.query,
pico_id: ctx.pico_id,
rid: rs.rid,
scope: rs.scope
})
var val = ctx.scope.get(ctx.query.name)
if (_.isFunction(val)) {
val = await runKRL(function (ctx, args) {
// use ctx.applyFn so it behaves like any other fn call
// i.e. errors on trying defaction like a function
return ctx.applyFn(val, ctx, args)
}, ctx, ctx.query.args)
}
// To ensure we don't leak out functions etc.
return ktypes.decode(ktypes.encode(val))
}
}
if(isBlank(event_orig.domain)){
throw new Error("missing event.domain");
}
if(isBlank(event_orig.type)){
throw new Error("missing event.type");
}
var attrs = {};
if(_.has(event_orig, "attrs")){
//we want to make sure only json-able values are in the attrs
//also want to clone it as to not mutate the original copy
var attrs_json = ktypes.encode(event_orig.attrs);
//only if it's a map or array do we consider it valid
if(attrs_json[0] === "{" || attrs_json[0] === "["){
attrs = ktypes.decode(attrs_json);
}
}
var eid = ktypes.toString(event_orig.eid).trim();
if(eid.length === 0 || eid === "null"){
eid = "none";
}
return {
eci: event_orig.eci.trim(),
eid: eid,
domain: event_orig.domain.trim(),
type: event_orig.type.trim(),
}
if(isBlank(query_orig.rid)){
throw new Error("missing query.rid");
}
if(isBlank(query_orig.name)){
throw new Error("missing query.name");
}
var args = {};
if(_.has(query_orig, "args")){
//we want to make sure only json-able values are in the args
//also want to clone it as to not mutate the original copy
var attrs_json = ktypes.encode(query_orig.args);
//only if it's a map or array do we consider it valid
if(attrs_json[0] === "{" || attrs_json[0] === "["){
args = ktypes.decode(attrs_json);
}
}
return {
eci: query_orig.eci.trim(),
rid: query_orig.rid.trim(),
name: query_orig.name.trim(),
args: args,
};
};