aboutsummaryrefslogtreecommitdiff
path: root/awwan.go
diff options
context:
space:
mode:
authorShulhan <ms@kilabit.info>2023-09-27 00:01:22 +0700
committerShulhan <ms@kilabit.info>2023-09-27 00:54:10 +0700
commitd1b393b0d4ca75c8d81d051a332597b7aa3f0ab0 (patch)
tree68adc1e0bfee5c6e2056110dc094cb520a5b969a /awwan.go
parent59968a1665735990187c05547faab3c5310c4be1 (diff)
downloadawwan-d1b393b0d4ca75c8d81d051a332597b7aa3f0ab0.tar.xz
all: make .Vars, .Val, and .Vals panic if values is empty
This is to prevent copying or executing command with value that are not defined or typo which make the result empty and may result in undefined behaviour. For example if we have "app_dir = /data/app" and command in the script that remove that directory recursively, sudo rm -r {{.Val "::app_dir}}/bin will result removing "/bin" entirely.
Diffstat (limited to 'awwan.go')
-rw-r--r--awwan.go4
1 files changed, 2 insertions, 2 deletions
diff --git a/awwan.go b/awwan.go
index 4c20d52..e506ca5 100644
--- a/awwan.go
+++ b/awwan.go
@@ -209,7 +209,7 @@ func (aww *Awwan) Local(req *Request) (err error) {
if len(req.Content) == 0 {
req.script, err = NewScript(ses, req.scriptPath)
} else {
- req.script, err = ParseScript(ses, req.Content)
+ req.script, err = ParseScript(ses, req.scriptPath, req.Content)
}
if err != nil {
return fmt.Errorf("%s: %w", logp, err)
@@ -288,7 +288,7 @@ func (aww *Awwan) Play(req *Request) (err error) {
if len(req.Content) == 0 {
req.script, err = NewScript(ses, req.scriptPath)
} else {
- req.script, err = ParseScript(ses, req.Content)
+ req.script, err = ParseScript(ses, req.scriptPath, req.Content)
}
if err != nil {
return fmt.Errorf("%s: %w", logp, err)