Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 82c3d89788 | |||
| b8c5b4f10d |
9
LICENSE
Normal file
9
LICENSE
Normal file
@ -0,0 +1,9 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2024 apigo
|
||||
|
||||
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.
|
||||
28
go.mod
28
go.mod
@ -1,27 +1,27 @@
|
||||
module apigo.cc/apigo/runtime
|
||||
module apigo.cc/gojs/runtime
|
||||
|
||||
go 1.23.0
|
||||
go 1.24.0
|
||||
|
||||
require (
|
||||
apigo.cc/gojs v0.0.13
|
||||
apigo.cc/gojs/console v0.0.2
|
||||
apigo.cc/gojs/file v0.0.3
|
||||
github.com/ssgo/u v1.7.18
|
||||
apigo.cc/gojs v0.0.28
|
||||
apigo.cc/gojs/console v0.0.3
|
||||
apigo.cc/gojs/file v0.0.6
|
||||
github.com/ssgo/u v1.7.23
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/dlclark/regexp2 v1.11.4 // indirect
|
||||
github.com/fsnotify/fsnotify v1.8.0 // indirect
|
||||
github.com/dlclark/regexp2 v1.11.5 // indirect
|
||||
github.com/fsnotify/fsnotify v1.9.0 // indirect
|
||||
github.com/go-sourcemap/sourcemap v2.1.4+incompatible // indirect
|
||||
github.com/google/pprof v0.0.0-20250317173921-a4b03ec1a45e // indirect
|
||||
github.com/google/pprof v0.0.0-20250903194437-c28834ac2320 // indirect
|
||||
github.com/kr/pretty v0.3.1 // indirect
|
||||
github.com/rogpeppe/go-internal v1.13.1 // indirect
|
||||
github.com/ssgo/config v1.7.9 // indirect
|
||||
github.com/ssgo/log v1.7.7 // indirect
|
||||
github.com/ssgo/config v1.7.10 // indirect
|
||||
github.com/ssgo/log v1.7.9 // indirect
|
||||
github.com/ssgo/standard v1.7.7 // indirect
|
||||
github.com/ssgo/tool v0.4.28 // indirect
|
||||
golang.org/x/sys v0.33.0 // indirect
|
||||
golang.org/x/text v0.23.0 // indirect
|
||||
github.com/ssgo/tool v0.4.29 // indirect
|
||||
golang.org/x/sys v0.38.0 // indirect
|
||||
golang.org/x/text v0.31.0 // indirect
|
||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
)
|
||||
|
||||
14
plugin.go
14
plugin.go
@ -42,7 +42,7 @@ func (obj *PluginObject) Arch() string {
|
||||
return runtime.GOARCH
|
||||
}
|
||||
|
||||
func (obj *PluginObject) Sleep(timeValue any) error {
|
||||
func (obj *PluginObject) Sleep(timeValue any, vm *goja.Runtime) error {
|
||||
var timeV time.Duration
|
||||
if ms := u.Int64(timeValue); ms > 0 {
|
||||
timeV = time.Duration(ms) * time.Millisecond
|
||||
@ -51,8 +51,11 @@ func (obj *PluginObject) Sleep(timeValue any) error {
|
||||
timeV = v
|
||||
}
|
||||
}
|
||||
if timeV > time.Hour {
|
||||
return errors.New("sleep time too long, max 1h")
|
||||
if timeV > time.Minute {
|
||||
return errors.New("sleep time too long, max 60s")
|
||||
}
|
||||
if timeV > time.Second*5 && u.String(vm.GetData("userPath")) != "" {
|
||||
return errors.New("sleep time too long, max 5s in sandbox")
|
||||
}
|
||||
if timeV > 0 {
|
||||
time.Sleep(timeV)
|
||||
@ -60,7 +63,10 @@ func (obj *PluginObject) Sleep(timeValue any) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (obj *PluginObject) Shell(cmd string, args ...string) ([]string, error) {
|
||||
func (obj *PluginObject) Shell(vm *goja.Runtime, cmd string, args ...string) ([]string, error) {
|
||||
if u.String(vm.GetData("userPath")) != "" {
|
||||
return nil, gojs.Err("shell is not allowed in sandbox")
|
||||
}
|
||||
if len(args) == 0 && strings.ContainsRune(cmd, ' ') {
|
||||
args = u.SplitArgs(cmd)
|
||||
cmd = args[0]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user