enabled tokens binds and removed primitive constructors overwrites
This commit is contained in:
parent
1bbba7a0ae
commit
0a4fdc17a5
|
@ -260,29 +260,6 @@ func wrapMiddlewares(executors *vmsPool, rawMiddlewares ...goja.Value) ([]echo.M
|
||||||
func baseBinds(vm *goja.Runtime) {
|
func baseBinds(vm *goja.Runtime) {
|
||||||
vm.SetFieldNameMapper(FieldMapper{})
|
vm.SetFieldNameMapper(FieldMapper{})
|
||||||
|
|
||||||
// override primitive class constructors to return pointers
|
|
||||||
// (this is useful when unmarshaling or scaning a db result)
|
|
||||||
vm.Set("__numberPointer", func(arg float64) *float64 {
|
|
||||||
return &arg
|
|
||||||
})
|
|
||||||
vm.Set("__stringPointer", func(arg string) *string {
|
|
||||||
return &arg
|
|
||||||
})
|
|
||||||
vm.Set("__boolPointer", func(arg bool) *bool {
|
|
||||||
return &arg
|
|
||||||
})
|
|
||||||
vm.RunString(`
|
|
||||||
this.Number = function(arg) {
|
|
||||||
return __numberPointer(arg)
|
|
||||||
}
|
|
||||||
this.String = function(arg) {
|
|
||||||
return __stringPointer(arg)
|
|
||||||
}
|
|
||||||
this.Boolean = function(arg) {
|
|
||||||
return __boolPointer(arg)
|
|
||||||
}
|
|
||||||
`)
|
|
||||||
|
|
||||||
vm.Set("arrayOf", func(model any) any {
|
vm.Set("arrayOf", func(model any) any {
|
||||||
mt := reflect.TypeOf(model)
|
mt := reflect.TypeOf(model)
|
||||||
st := reflect.SliceOf(mt)
|
st := reflect.SliceOf(mt)
|
||||||
|
|
|
@ -45,7 +45,7 @@ func TestBaseBindsCount(t *testing.T) {
|
||||||
vm := goja.New()
|
vm := goja.New()
|
||||||
baseBinds(vm)
|
baseBinds(vm)
|
||||||
|
|
||||||
testBindsCount(vm, "this", 16, t)
|
testBindsCount(vm, "this", 13, t)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestBaseBindsRecord(t *testing.T) {
|
func TestBaseBindsRecord(t *testing.T) {
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -143,6 +143,7 @@ func (p *plugin) registerMigrations() error {
|
||||||
process.Enable(vm)
|
process.Enable(vm)
|
||||||
baseBinds(vm)
|
baseBinds(vm)
|
||||||
dbxBinds(vm)
|
dbxBinds(vm)
|
||||||
|
tokensBinds(vm)
|
||||||
securityBinds(vm)
|
securityBinds(vm)
|
||||||
// note: disallow for now and give the authors of custom SaaS offerings
|
// note: disallow for now and give the authors of custom SaaS offerings
|
||||||
// some time to adjust their code to avoid eventual security issues
|
// some time to adjust their code to avoid eventual security issues
|
||||||
|
@ -222,6 +223,7 @@ func (p *plugin) registerHooks() error {
|
||||||
baseBinds(vm)
|
baseBinds(vm)
|
||||||
dbxBinds(vm)
|
dbxBinds(vm)
|
||||||
filesystemBinds(vm)
|
filesystemBinds(vm)
|
||||||
|
tokensBinds(vm)
|
||||||
securityBinds(vm)
|
securityBinds(vm)
|
||||||
osBinds(vm)
|
osBinds(vm)
|
||||||
filepathBinds(vm)
|
filepathBinds(vm)
|
||||||
|
|
Loading…
Reference in New Issue