Skip to content

Commit

Permalink
Remove restriction on rule file name (#106)
Browse files Browse the repository at this point in the history
  • Loading branch information
sikmir committed Apr 10, 2024
1 parent 615d7f8 commit 090c841
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 11 deletions.
6 changes: 6 additions & 0 deletions debian/changelog
@@ -1,3 +1,9 @@
wb-rules (2.20.4) stable; urgency=medium

* Remove restriction on rule file name

-- Nikolay Korotkiy <nikolay.korotkiy@wirenboard.com> Mon, 09 Apr 2024 11:28:00 +0400

wb-rules (2.20.3) stable; urgency=medium

* Move wbgo.so plugin to /usr/lib, no functional changes
Expand Down
6 changes: 0 additions & 6 deletions wbrules/editor.go
Expand Up @@ -4,14 +4,11 @@ import (
"io/ioutil"
"os"
"path"
"regexp"
"strings"

"github.com/wirenboard/wbgong"
)

var editorPathRx = regexp.MustCompile(`^[\w /-]{0,256}[\w -]{1,253}\.js$`)

type Editor struct {
locFileManager LocFileManager
}
Expand Down Expand Up @@ -44,7 +41,6 @@ const (
EDITOR_ERROR_INVALID_LEN = 1009
)

var invalidPathError = &EditorError{EDITOR_ERROR_INVALID_PATH, "File path should contains only digits, letters, whitespaces, '_' and '-' chars"}
var invalidExtensionError = &EditorError{EDITOR_ERROR_INVALID_EXT, "File name should ends with .js"}
var invalidLenError = &EditorError{EDITOR_ERROR_INVALID_LEN, "File path should be shorter than or equal to 512 chars"}
var listDirError = &EditorError{EDITOR_ERROR_LISTDIR, "Error listing the directory"}
Expand Down Expand Up @@ -85,8 +81,6 @@ func (editor *Editor) Save(args *EditorSaveArgs, reply *EditorSaveResponse) erro
return invalidExtensionError
} else if len(args.Path) > 512 {
return invalidLenError
} else if !editorPathRx.MatchString(pth) {
return invalidPathError
}

*reply = EditorSaveResponse{nil, pth, nil}
Expand Down
4 changes: 0 additions & 4 deletions wbrules/editor_test.go
Expand Up @@ -248,10 +248,6 @@ func (s *EditorSuite) TestSaveFile() {
"sub/sample6.js": "sample6 -- error",
})

s.VerifyRpcError("Save", objx.Map{"path": "../foo/bar.js", "content": "evilfile"},
EDITOR_ERROR_INVALID_PATH, "EditorError", invalidPathError.Error())
s.VerifyRpcError("Save", objx.Map{"path": "qqq/$$$rrr.js", "content": "lamefile"},
EDITOR_ERROR_INVALID_PATH, "EditorError", invalidPathError.Error())
s.verifySources(map[string]string{
"sample1.js": "// sample1 (changed)",
"sample2.js": "// sample2",
Expand Down
2 changes: 1 addition & 1 deletion wbrules/esengine.go
Expand Up @@ -889,7 +889,7 @@ func (engine *ESEngine) LiveWriteScript(virtualPath, content string) error {
// LiveLoadFile for the file, but as the new content
// will be already registered with the contentTracker,
// duplicate reload will not happen
err = ioutil.WriteFile(cleanPath, []byte(content), 0777)
err = ioutil.WriteFile(cleanPath, []byte(content), 0644)
if err != nil {
r <- err
return
Expand Down

0 comments on commit 090c841

Please sign in to comment.