Skip to content

Commit

Permalink
WIP: Fix Suricata Parser Bug
Browse files Browse the repository at this point in the history
Fixed a bug where 2 slashes before ending a string resulted in the parser not recognizing that the string terminated.

Updated "Parentheses in Unquoted Option" test to also test this case.
  • Loading branch information
coreyogburn committed Jan 30, 2024
1 parent 3bd2132 commit a8be9ec
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion server/modules/suricata/suricata_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ func TestValidate(t *testing.T) {
},
{
Name: "Parentheses in Unquoted Option",
Input: `alert http $HOME_NET any -> $EXTERNAL_NET any (msg:"ET ADWARE_PUP WinSoftware.com Spyware User-Agent (WinSoftware)"; flow:to_server,established; http.user_agent; content:"WinSoftware"; nocase; depth:11; reference:url,research.sunbelt-software.com/threatdisplay.aspx?name=WinSoftware%20Corporation%2c%20Inc.%20(v)&threatid=90037; reference:url,doc.emergingthreats.net/2003527; classtype:pup-activity; sid:2003527; rev:12; metadata:attack_target Client_Endpoint, created_at 2010_07_30, deployment Perimeter, former_category ADWARE_PUP, signature_severity Minor, tag Spyware_User_Agent, updated_at 2020_10_13;)`,
Input: `alert http $HOME_NET any -> $EXTERNAL_NET any (msg:"ET ADWARE_PUP WinSoftware.com Spyware User-Agent (WinSoftware)\\"; flow:to_server,established; http.user_agent; content:"WinSoftware"; nocase; depth:11; reference:url,research.sunbelt-software.com/threatdisplay.aspx?name=WinSoftware%20Corporation%2c%20Inc.%20(v)&threatid=90037; reference:url,doc.emergingthreats.net/2003527; classtype:pup-activity; sid:2003527; rev:12; metadata:attack_target Client_Endpoint, created_at 2010_07_30, deployment Perimeter, former_category ADWARE_PUP, signature_severity Minor, tag Spyware_User_Agent, updated_at 2020_10_13;)`,
},
{
Name: "Unescaped Double Quote in PCRE Option",
Expand Down
2 changes: 1 addition & 1 deletion server/modules/suricata/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ func ParseSuricataRule(rule string) (*SuricataRule, error) {
inQuotes = !inQuotes
}
}
} else if ch == '\\' {
} else if ch == '\\' && !isEscaping {
isEscaping = true
buf.WriteRune(ch)
} else {
Expand Down

0 comments on commit a8be9ec

Please sign in to comment.