From 2717a8b6476a35255d2205c569a53b4285218cf6 Mon Sep 17 00:00:00 2001 From: Ice3man543 Date: Mon, 8 Mar 2021 19:20:40 +0530 Subject: [PATCH] Fixed file protocol bugs --- v2/pkg/protocols/file/file.go | 6 +++--- v2/pkg/protocols/file/file_test.go | 2 +- v2/pkg/protocols/file/find_test.go | 2 +- v2/pkg/protocols/file/request_test.go | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/v2/pkg/protocols/file/file.go b/v2/pkg/protocols/file/file.go index 67e1b704..df362531 100644 --- a/v2/pkg/protocols/file/file.go +++ b/v2/pkg/protocols/file/file.go @@ -66,20 +66,20 @@ func (r *Request) Compile(options *protocols.ExecuterOptions) error { if extension == "all" { r.allExtensions = true } else { - if strings.HasPrefix(extension, ".") { + if !strings.HasPrefix(extension, ".") { extension = "." + extension } r.extensions[extension] = struct{}{} } } for _, extension := range defaultDenylist { - if strings.HasPrefix(extension, ".") { + if !strings.HasPrefix(extension, ".") { extension = "." + extension } r.extensionDenylist[extension] = struct{}{} } for _, extension := range r.ExtensionDenylist { - if strings.HasPrefix(extension, ".") { + if !strings.HasPrefix(extension, ".") { extension = "." + extension } r.extensionDenylist[extension] = struct{}{} diff --git a/v2/pkg/protocols/file/file_test.go b/v2/pkg/protocols/file/file_test.go index 56c4ab3d..9364a9b6 100644 --- a/v2/pkg/protocols/file/file_test.go +++ b/v2/pkg/protocols/file/file_test.go @@ -16,7 +16,7 @@ func TestFileCompile(t *testing.T) { ID: templateID, MaxSize: 1024, NoRecursive: false, - Extensions: []string{"*", ".lock"}, + Extensions: []string{"all", ".lock"}, ExtensionDenylist: []string{".go"}, } executerOpts := testutils.NewMockExecuterOptions(options, &testutils.TemplateInfo{ diff --git a/v2/pkg/protocols/file/find_test.go b/v2/pkg/protocols/file/find_test.go index b6eabdd5..06757bed 100644 --- a/v2/pkg/protocols/file/find_test.go +++ b/v2/pkg/protocols/file/find_test.go @@ -19,7 +19,7 @@ func TestFindInputPaths(t *testing.T) { ID: templateID, MaxSize: 1024, NoRecursive: false, - Extensions: []string{"*", ".lock"}, + Extensions: []string{"all", ".lock"}, ExtensionDenylist: []string{".go"}, } executerOpts := testutils.NewMockExecuterOptions(options, &testutils.TemplateInfo{ diff --git a/v2/pkg/protocols/file/request_test.go b/v2/pkg/protocols/file/request_test.go index dd5282dd..f26e9ba4 100644 --- a/v2/pkg/protocols/file/request_test.go +++ b/v2/pkg/protocols/file/request_test.go @@ -23,7 +23,7 @@ func TestFileExecuteWithResults(t *testing.T) { ID: templateID, MaxSize: 1024, NoRecursive: false, - Extensions: []string{"*"}, + Extensions: []string{"all"}, ExtensionDenylist: []string{".go"}, Operators: operators.Operators{ Matchers: []*matchers.Matcher{{