Skip to content

Commit

Permalink
Added the ability to restrict action execution to a specified OS
Browse files Browse the repository at this point in the history
  • Loading branch information
shibijm committed Mar 3, 2024
1 parent a5c156e commit bbb95c6
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 2 deletions.
2 changes: 1 addition & 1 deletion COPYRIGHT
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2023 Shibi J M
Copyright (c) 2023-2024 Shibi J M

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 3,
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ Config file decrypted successfully
- `print [args]`
- `shiftArgVars`

Append `!W` or `!L` to action names to restrict their execution to Windows or Linux respectively.

### Example

```yml
Expand Down
17 changes: 17 additions & 0 deletions core/services/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"os"
"os/exec"
"regexp"
"runtime"
"sort"
"strconv"
"strings"
Expand Down Expand Up @@ -84,6 +85,22 @@ func (r *runner) runInstruction(instruction string, locals *[]*variable) error {
}
tokens := r.tokenise(instruction, locals)
action := tokens[0]
actionSplit := strings.Split(action, "!")
if len(actionSplit) == 2 {
action = actionSplit[0]
platform := actionSplit[1]
if platform == "W" {
if runtime.GOOS != "windows" {
return nil
}
} else if platform == "L" {
if runtime.GOOS != "linux" {
return nil
}
} else {
return nil
}
}
args := tokens[1:]
var err error
switch action {
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"unicode"
)

const version = "1.0.3"
const version = "1.1.0"

func main() {
crypter := crypto.NewAesGcmCrypter()
Expand Down

0 comments on commit bbb95c6

Please sign in to comment.