forked from elastic/beats
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
87 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
CEF:0|Elastic|Vaporware|1.0.0-alpha|18|Web request|low|eventId=3457 requestMethod=POST slat=38.915 slong=-77.511 proto=TCP sourceServiceName=httpd requestContext=https://www.google.com src=6.7.8.9 spt=33876 dst=192.168.10.1 dpt=443 request=https://www.example.com/cart | ||
CEF:0|Elastic|Vaporware|1.0.0-alpha|18|Authentication|low|eventId=123 src=6.7.8.9 spt=33876 dst=1.2.3.4 dpt=443 duser=alice suser=bob destinationTranslatedAddress=10.10.10.10 fileHash=bc8bbe52f041fd17318f08a0f73762ce oldFileHash=a9796280592f86b74b27e370662d41eb | ||
CEF:0|Elastic|Vaporware|1.0.0-alpha|18|Authentication|low|spriv=user dpriv=root | ||
CEF:0|Elastic|Vaporware|1.0.0-alpha|18|Authentication|low|message=This event is padded with whitespace dst=192.168.1.2 src=192.168.3.4 |
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 |
---|---|---|
|
@@ -44,6 +44,14 @@ const ( | |
malformedExtensionEscape = `CEF:0|FooBar|Web Gateway|1.2.3.45.67|200|Success|2|rt=Sep 07 2018 14:50:39 cat=Access Log dst=1.1.1.1 dhost=foo.example.com suser=redacted src=2.2.2.2 requestMethod=POST request='https://foo.example.com/bar/bingo/1' requestClientApplication='Foo-Bar/2018.1.7; =Email:[email protected]; Guid:test=' cs1= cs1Label=Foo Bar` | ||
|
||
multipleMalformedExtensionValues = `CEF:0|vendor|product|version|event_id|name|Very-High| msg=Hello World error=Failed because id==old_id user=root angle=106.7<=180` | ||
|
||
paddedMessage = `CEF:0|security|threatmanager|1.0|100|message is padded|10|spt=1232 msg=Trailing space in non-final extensions is preserved src=10.0.0.192 ` | ||
|
||
crlfMessage = "CEF:0|security|threatmanager|1.0|100|message is padded|10|spt=1232 msg=Trailing space in final extensions is not preserved\t \r\n" | ||
|
||
tabMessage = "CEF:0|security|threatmanager|1.0|100|message is padded|10|spt=1232 msg=Tabs\tand\rcontrol\ncharacters are preserved\t src=127.0.0.1" | ||
|
||
tabNoSepMessage = "CEF:0|security|threatmanager|1.0|100|message has tabs|10|spt=1232 msg=Tab is not a separator\tsrc=127.0.0.1" | ||
) | ||
|
||
var testMessages = []string{ | ||
|
@@ -60,6 +68,9 @@ var testMessages = []string{ | |
escapesInExtension, | ||
malformedExtensionEscape, | ||
multipleMalformedExtensionValues, | ||
paddedMessage, | ||
crlfMessage, | ||
tabMessage, | ||
} | ||
|
||
func TestGenerateFuzzCorpus(t *testing.T) { | ||
|
@@ -322,6 +333,47 @@ func TestEventUnpack(t *testing.T) { | |
err := e.Unpack("CEF:0|||||||a=") | ||
assert.NoError(t, err) | ||
}) | ||
|
||
t.Run("padded", func(t *testing.T) { | ||
var e Event | ||
err := e.Unpack(paddedMessage) | ||
assert.NoError(t, err) | ||
assert.Equal(t, map[string]*Field{ | ||
"src": IPField("10.0.0.192"), | ||
"spt": IntegerField(1232), | ||
"msg": StringField("Trailing space in non-final extensions is preserved "), | ||
}, e.Extensions) | ||
}) | ||
|
||
t.Run("padded with extra whitespace chars", func(t *testing.T) { | ||
var e Event | ||
err := e.Unpack(crlfMessage) | ||
assert.NoError(t, err) | ||
assert.Equal(t, map[string]*Field{ | ||
"spt": IntegerField(1232), | ||
"msg": StringField("Trailing space in final extensions is not preserved"), | ||
}, e.Extensions) | ||
}) | ||
|
||
t.Run("internal whitespace chars", func(t *testing.T) { | ||
var e Event | ||
err := e.Unpack(tabMessage) | ||
assert.NoError(t, err) | ||
assert.Equal(t, map[string]*Field{ | ||
"spt": IntegerField(1232), | ||
"src": IPField("127.0.0.1"), | ||
"msg": StringField("Tabs\tand\rcontrol\ncharacters are preserved\t"), | ||
}, e.Extensions) | ||
}) | ||
|
||
t.Run("No tab as separator", func(t *testing.T) { | ||
var e Event | ||
err := e.Unpack(tabNoSepMessage) | ||
assert.Error(t, err) | ||
assert.Equal(t, map[string]*Field{ | ||
"spt": IntegerField(1232), | ||
}, e.Extensions) | ||
}) | ||
} | ||
|
||
func TestEventUnpackWithFullExtensionNames(t *testing.T) { | ||
|