-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make inclusion to the test case list based on matching tags
Use tags to narrow down test cases to those labeled with strings matching the regex passed as a config parameter.
- Loading branch information
Hubert Siwik
committed
Jun 17, 2024
1 parent
74d760f
commit a22bae5
Showing
11 changed files
with
114 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// Copyright 2023 OWASP ModSecurity Core Rule Set Project | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package utils | ||
|
||
import ( | ||
"regexp" | ||
) | ||
|
||
func MatchSlice(regex *regexp.Regexp, hayStack []string) bool { | ||
for _, str := range hayStack { | ||
if regex.MatchString(str) { | ||
return true | ||
} | ||
} | ||
|
||
return false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// Copyright 2023 OWASP ModSecurity Core Rule Set Project | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package utils | ||
|
||
import ( | ||
"regexp" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/suite" | ||
) | ||
|
||
type sliceTestSuite struct { | ||
suite.Suite | ||
} | ||
|
||
func TestSliceTestSuite(t *testing.T) { | ||
suite.Run(t, new(timeTestSuite)) | ||
} | ||
|
||
func (s *timeTestSuite) TestMatchSlice() { | ||
re := regexp.MustCompile("^cookie$") | ||
|
||
s.False(MatchSlice(re, []string{})) | ||
s.False(MatchSlice(re, []string{""})) | ||
s.False(MatchSlice(re, []string{"cooke", "php"})) | ||
s.False(MatchSlice(re, []string{"cookies", "php"})) | ||
s.True(MatchSlice(re, []string{"cookie", "php"})) | ||
s.True(MatchSlice(re, []string{"js", "cookie"})) | ||
} |