Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove csv in custom data #457

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 1 addition & 15 deletions internal/pkg/dsiem/rule/rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -384,25 +384,11 @@ func isNetAddrMatchCSVRule(rulesInCSV, term string) bool {
return match
}

// matchText match the given term against the subject, if the subject is a comma-separated-values,
// split it into slice of strings, match its value one by one, and returns if one of the value matches.
// otherwose, matchText will do non case-sensitve match for the subject and term.
// matchText will do non case-sensitve match for the subject and term.
func matchText(subject, term string) bool {

if isCSV(subject) {
return isStringMatchCSVRule(subject, term)
}

return matchTextNonSensitive(subject, term)
}

// isCSV determines wether the given term is a comma separated list of strings or not.
// FIXME: this is currently implemented by checking if the term contains comma character ",", which
// can cause misbehave if the term is actually a non-csv long string that contains comma character.
func isCSV(term string) bool {
return strings.Contains(term, ",")
}

func matchTextNonSensitive(term1, term2 string) bool {
var inverse bool
if strings.HasPrefix(term1, "!") {
Expand Down
9 changes: 0 additions & 9 deletions internal/pkg/dsiem/rule/rule_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -513,15 +513,6 @@ func TestCustomDataMatch(t *testing.T) {
{"Network Command Shell", "Network Command Login", false},
{"!Network Command Shell", "Network Command Shell", false},
{"!Network Command Shell", "Network Command Login", true},
{"foo,bar,qux", "foo", true},
{"foo,bar,qux", "bar", true},
{"foo,bar,qux", "qux", true},
{"foo,bar,qux", "baz", false},
{"foo,!bar,qux", "bar", false},
{"foo,bar,!qux", "qux", false},
{"!foo,bar,qux", "foo", false},
{"!foo, foo, bar, qux", "foo", false},
{"foo, !foo, bar, qux", "foo", true},
} {
t.Run(c.ruleCustomData, func(t *testing.T) {
r := DirectiveRule{
Expand Down