Skip to content

Commit

Permalink
cleaning up syntax, removing implementation termination bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Levinson committed Nov 19, 2017
1 parent 2bc65d2 commit 2963b1b
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 103 deletions.
55 changes: 16 additions & 39 deletions builtin_functions.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,11 @@ import (
)

func (e *Engine) VMHalt(call otto.FunctionCall) otto.Value {
e.LogCritf("Function Not Implemented: %s", CalledBy())
e.LogErrorf("Function Not Implemented: %s", CalledBy())
return otto.FalseValue()
}

func (e *Engine) VMDeleteFile(call otto.FunctionCall) otto.Value {
// Arg0 is the string path of the file to delete
filePath := call.Argument(0)
filePathAsString, err := filePath.Export()
if err != nil {
Expand All @@ -33,8 +32,6 @@ func (e *Engine) VMDeleteFile(call otto.FunctionCall) otto.Value {
}

func (e *Engine) VMWriteFile(call otto.FunctionCall) otto.Value {
// Arg0 is the string path of the new file to write
// Arg1 is a byte array of bytes of the file
filePath := call.Argument(0)
fileData := call.Argument(1)
fileBytes := e.ValueToByteSlice(fileData)
Expand All @@ -52,8 +49,6 @@ func (e *Engine) VMWriteFile(call otto.FunctionCall) otto.Value {
}

func (e *Engine) VMCopyFile(call otto.FunctionCall) otto.Value {
// Arg0 is the string path of the first file we read
// Arg1 is the string path of the new file to write
readPath, err := call.ArgumentList[0].ToString()
if err != nil {
e.LogErrorf("Function Error: function=VMCopyFile() error=ARG_NOT_STRINGABLE arg=%s", spew.Sdump(call.ArgumentList[0]))
Expand All @@ -69,27 +64,17 @@ func (e *Engine) VMCopyFile(call otto.FunctionCall) otto.Value {
e.LogErrorf("Function Error: function=VMCopyFile() error='There was an error reading the file to copy'")
return otto.FalseValue()
}
//e.Logger.Errorf("Function Error: function=VMCopyFile() error=Debug; read local file at: %s", spew.Sdump(readPath))
err = LocalFileCreate(writePath, bytes)
if err != nil {
e.LogErrorf("Function Error: function=VMCopyFile() error='There was an error writing the file to that path'")
return otto.FalseValue()
}
// Testing Debug call function //
e.LogInfof("Function: function=%s msg='wrote local file at: %s'", CalledBy(), spew.Sdump(writePath))
//returnString := fmt.Sprintf("File created at: %s", string(writePath))
//var ret = otto.Value{}
//var er error
//ret, er = otto.ToValue(returnString)
//if er != nil {
// e.Logger.Errorf("Function Error: function=VMCopyFile() error='Error returning value to VM'")
// return otto.FalseValue()
//}
return otto.TrueValue()
}

func (e *Engine) VMExecuteFile(call otto.FunctionCall) otto.Value {
e.LogCritf("Function Not Implemented: %s", CalledBy())
e.LogErrorf("Function Not Implemented: %s", CalledBy())
return otto.FalseValue()
}

Expand All @@ -113,8 +98,6 @@ func (e *Engine) VMAsset(call otto.FunctionCall) otto.Value {
}

func (e *Engine) VMAppendFile(call otto.FunctionCall) otto.Value {
// Arg0 is the string path of the new file to write
// Arg1 is a byte array of bytes of the file
filePath := call.Argument(0)
fileData := call.Argument(1)
fileBytes := e.ValueToByteSlice(fileData)
Expand All @@ -132,9 +115,6 @@ func (e *Engine) VMAppendFile(call otto.FunctionCall) otto.Value {
}

func (e *Engine) VMReplaceInFile(call otto.FunctionCall) otto.Value {
// Arg0 is the string path of the file to search / replace
// Arg1 is a string to find / match w/
// Arg2 is a to string to replace w/
filePath := call.Argument(0)
filePathAsString, err := filePath.Export()
if err != nil {
Expand Down Expand Up @@ -162,12 +142,12 @@ func (e *Engine) VMReplaceInFile(call otto.FunctionCall) otto.Value {
}

func (e *Engine) VMSignal(call otto.FunctionCall) otto.Value {
e.LogCritf("Function Not Implemented: %s", CalledBy())
e.LogErrorf("Function Not Implemented: %s", CalledBy())
return otto.FalseValue()
}

func (e *Engine) VMImplode(call otto.FunctionCall) otto.Value {
e.LogCritf("Function Not Implemented: %s", CalledBy())
e.LogErrorf("Function Not Implemented: %s", CalledBy())
return otto.FalseValue()
}

Expand All @@ -190,10 +170,7 @@ func (e *Engine) VMRetrieveFileFromURL(call otto.FunctionCall) otto.Value {
return vmResponse
}

// Uses the native DNS client (including things like host files and resolution)
func (e *Engine) VMDNSQuery(call otto.FunctionCall) otto.Value {
// Arg0 is the target string domain to do a DNS lookup
// Arg1 is string of the TYPE of DNS query
targetDomain := call.Argument(0)
queryType := call.Argument(1)
targetDomainAsString, err := targetDomain.Export()
Expand All @@ -216,7 +193,7 @@ func (e *Engine) VMDNSQuery(call otto.FunctionCall) otto.Value {
}

func (e *Engine) VMHTTPRequest(call otto.FunctionCall) otto.Value {
e.LogCritf("Function Not Implemented: %s", CalledBy())
e.LogErrorf("Function Not Implemented: %s", CalledBy())
return otto.FalseValue()
}

Expand Down Expand Up @@ -421,12 +398,12 @@ func (e *Engine) VMCPUStats(call otto.FunctionCall) otto.Value {
}

func (e *Engine) VMMemStats(call otto.FunctionCall) otto.Value {
e.LogCritf("Function Not Implemented: %s", CalledBy())
e.LogErrorf("Function Not Implemented: %s", CalledBy())
return otto.FalseValue()
}

func (e *Engine) VMSSHCmd(call otto.FunctionCall) otto.Value {
e.LogCritf("Function Not Implemented: %s", CalledBy())
e.LogErrorf("Function Not Implemented: %s", CalledBy())
return otto.FalseValue()
}

Expand All @@ -446,46 +423,46 @@ func (e *Engine) VMSleep(call otto.FunctionCall) otto.Value {
}

func (e *Engine) VMGetTweet(call otto.FunctionCall) otto.Value {
e.LogCritf("Function Not Implemented: %s", CalledBy())
e.LogErrorf("Function Not Implemented: %s", CalledBy())
return otto.FalseValue()
}

func (e *Engine) VMGetDirsInPath(call otto.FunctionCall) otto.Value {
e.LogCritf("Function Not Implemented: %s", CalledBy())
e.LogErrorf("Function Not Implemented: %s", CalledBy())
return otto.FalseValue()
}

func (e *Engine) VMEnvVars(call otto.FunctionCall) otto.Value {
e.LogCritf("Function Not Implemented: %s", CalledBy())
e.LogErrorf("Function Not Implemented: %s", CalledBy())
return otto.FalseValue()
}

func (e *Engine) VMGetEnv(call otto.FunctionCall) otto.Value {
e.LogCritf("Function Not Implemented: %s", CalledBy())
e.LogErrorf("Function Not Implemented: %s", CalledBy())
return otto.FalseValue()
}

func (e *Engine) VMFileCreateTime(call otto.FunctionCall) otto.Value {
e.LogCritf("Function Not Implemented: %s", CalledBy())
e.LogErrorf("Function Not Implemented: %s", CalledBy())
return otto.FalseValue()
}

func (e *Engine) VMFileModifyTime(call otto.FunctionCall) otto.Value {
e.LogCritf("Function Not Implemented: %s", CalledBy())
e.LogErrorf("Function Not Implemented: %s", CalledBy())
return otto.FalseValue()
}

func (e *Engine) VMLoggedInUsers(call otto.FunctionCall) otto.Value {
e.LogCritf("Function Not Implemented: %s", CalledBy())
e.LogErrorf("Function Not Implemented: %s", CalledBy())
return otto.FalseValue()
}

func (e *Engine) VMUsersRunningProcs(call otto.FunctionCall) otto.Value {
e.LogCritf("Function Not Implemented: %s", CalledBy())
e.LogErrorf("Function Not Implemented: %s", CalledBy())
return otto.FalseValue()
}

func (e *Engine) VMServeFileOverHTTP(call otto.FunctionCall) otto.Value {
e.LogCritf("Function Not Implemented: %s", CalledBy())
e.LogErrorf("Function Not Implemented: %s", CalledBy())
return otto.FalseValue()
}
31 changes: 0 additions & 31 deletions cmd/docgen/main.go

This file was deleted.

2 changes: 1 addition & 1 deletion cmd/gscript/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func main() {
app := cli.NewApp()
app.Name = "gscript"
app.Usage = "Interact with the Genesis Scripting Engine (GSE)"
app.Version = "0.0.5"
app.Version = "0.0.6"
app.Authors = []cli.Author{
cli.Author{
Name: "Alex Levinson",
Expand Down
1 change: 0 additions & 1 deletion cmd/gscript/update.go

This file was deleted.

11 changes: 3 additions & 8 deletions compiler.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,9 @@ type VMBundle struct {
}

type Compiler struct {
OS string `json:"os"`
Arch string `json:"arch"`
// ScriptFile string
// PackageName string
OutputFile string `json:"output"`
// AssetFiles []string
// Embeds []EmbeddedFile
OS string `json:"os"`
Arch string `json:"arch"`
OutputFile string `json:"output"`
VMs []*VMBundle `json:"vms"`
BuildDir string `json:"build_dir"`
AssetDir string `json:"asset_dir"`
Expand Down Expand Up @@ -154,7 +150,6 @@ func (c *Compiler) BuildEntryPoint() {

func (c *Compiler) WriteSource() {
if c.OutputSource {
c.Logger.Log("YEP")
quick.Highlight(os.Stdout, string(c.Source), "go", "terminal", "vim")
return
}
Expand Down
46 changes: 23 additions & 23 deletions research_functions.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,116 +3,116 @@ package gscript
import "github.com/robertkrimen/otto"

func (e *Engine) VMLocalUserExists(call otto.FunctionCall) otto.Value {
e.LogCritf("Function Not Implemented: %s", CalledBy())
e.LogErrorf("Function Not Implemented: %s", CalledBy())
return otto.FalseValue()
}

func (e *Engine) VMProcExistsWithName(call otto.FunctionCall) otto.Value {
e.LogCritf("Function Not Implemented: %s", CalledBy())
e.LogErrorf("Function Not Implemented: %s", CalledBy())
return otto.FalseValue()
}

func (e *Engine) VMCanReadFile(call otto.FunctionCall) otto.Value {
e.LogCritf("Function Not Implemented: %s", CalledBy())
e.LogErrorf("Function Not Implemented: %s", CalledBy())
return otto.FalseValue()
}

func (e *Engine) VMCanWriteFile(call otto.FunctionCall) otto.Value {
e.LogCritf("Function Not Implemented: %s", CalledBy())
e.LogErrorf("Function Not Implemented: %s", CalledBy())
return otto.FalseValue()
}

func (e *Engine) VMCanExecFile(call otto.FunctionCall) otto.Value {
e.LogCritf("Function Not Implemented: %s", CalledBy())
e.LogErrorf("Function Not Implemented: %s", CalledBy())
return otto.FalseValue()
}

func (e *Engine) VMFileExists(call otto.FunctionCall) otto.Value {
e.LogCritf("Function Not Implemented: %s", CalledBy())
e.LogErrorf("Function Not Implemented: %s", CalledBy())
return otto.FalseValue()
}

func (e *Engine) VMDirExists(call otto.FunctionCall) otto.Value {
e.LogCritf("Function Not Implemented: %s", CalledBy())
e.LogErrorf("Function Not Implemented: %s", CalledBy())
return otto.FalseValue()
}

func (e *Engine) VMFileContains(call otto.FunctionCall) otto.Value {
e.LogCritf("Function Not Implemented: %s", CalledBy())
e.LogErrorf("Function Not Implemented: %s", CalledBy())
return otto.FalseValue()
}

func (e *Engine) VMIsVM(call otto.FunctionCall) otto.Value {
e.LogCritf("Function Not Implemented: %s", CalledBy())
e.LogErrorf("Function Not Implemented: %s", CalledBy())
return otto.FalseValue()
}

func (e *Engine) VMIsAWS(call otto.FunctionCall) otto.Value {
e.LogCritf("Function Not Implemented: %s", CalledBy())
e.LogErrorf("Function Not Implemented: %s", CalledBy())
return otto.FalseValue()
}

func (e *Engine) VMHasPublicIP(call otto.FunctionCall) otto.Value {
e.LogCritf("Function Not Implemented: %s", CalledBy())
e.LogErrorf("Function Not Implemented: %s", CalledBy())
return otto.FalseValue()
}

func (e *Engine) VMCanMakeTCPConn(call otto.FunctionCall) otto.Value {
e.LogCritf("Function Not Implemented: %s", CalledBy())
e.LogErrorf("Function Not Implemented: %s", CalledBy())
return otto.FalseValue()
}

func (e *Engine) VMExpectedDNS(call otto.FunctionCall) otto.Value {
e.LogCritf("Function Not Implemented: %s", CalledBy())
e.LogErrorf("Function Not Implemented: %s", CalledBy())
return otto.FalseValue()
}

func (e *Engine) VMCanMakeHTTPConn(call otto.FunctionCall) otto.Value {
e.LogCritf("Function Not Implemented: %s", CalledBy())
e.LogErrorf("Function Not Implemented: %s", CalledBy())
return otto.FalseValue()
}

func (e *Engine) VMDetectSSLMITM(call otto.FunctionCall) otto.Value {
e.LogCritf("Function Not Implemented: %s", CalledBy())
e.LogErrorf("Function Not Implemented: %s", CalledBy())
return otto.FalseValue()
}

func (e *Engine) VMCmdSuccessful(call otto.FunctionCall) otto.Value {
e.LogCritf("Function Not Implemented: %s", CalledBy())
e.LogErrorf("Function Not Implemented: %s", CalledBy())
return otto.FalseValue()
}

func (e *Engine) VMCanPing(call otto.FunctionCall) otto.Value {
e.LogCritf("Function Not Implemented: %s", CalledBy())
e.LogErrorf("Function Not Implemented: %s", CalledBy())
return otto.FalseValue()
}

func (e *Engine) VMTCPPortInUse(call otto.FunctionCall) otto.Value {
e.LogCritf("Function Not Implemented: %s", CalledBy())
e.LogErrorf("Function Not Implemented: %s", CalledBy())
return otto.FalseValue()
}

func (e *Engine) VMUDPPortInUse(call otto.FunctionCall) otto.Value {
e.LogCritf("Function Not Implemented: %s", CalledBy())
e.LogErrorf("Function Not Implemented: %s", CalledBy())
return otto.FalseValue()
}

func (e *Engine) VMExistsInPath(call otto.FunctionCall) otto.Value {
e.LogCritf("Function Not Implemented: %s", CalledBy())
e.LogErrorf("Function Not Implemented: %s", CalledBy())
return otto.FalseValue()
}

func (e *Engine) VMCanSudo(call otto.FunctionCall) otto.Value {
e.LogCritf("Function Not Implemented: %s", CalledBy())
e.LogErrorf("Function Not Implemented: %s", CalledBy())
return otto.FalseValue()
}

func (e *Engine) VMMatches(call otto.FunctionCall) otto.Value {
e.LogCritf("Function Not Implemented: %s", CalledBy())
e.LogErrorf("Function Not Implemented: %s", CalledBy())
return otto.FalseValue()
}

func (e *Engine) VMCanSSHLogin(call otto.FunctionCall) otto.Value {
e.LogCritf("Function Not Implemented: %s", CalledBy())
e.LogErrorf("Function Not Implemented: %s", CalledBy())
return otto.FalseValue()
}

0 comments on commit 2963b1b

Please sign in to comment.