Skip to content

Commit

Permalink
Remove Tags From Bro Log Types (Recognize Security Onion http log) (#439
Browse files Browse the repository at this point in the history
)
  • Loading branch information
Zalgo2462 authored and ethack committed Apr 16, 2019
1 parent a10b061 commit 5fdb5f1
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 6 deletions.
14 changes: 9 additions & 5 deletions parser/parsetypes/parsetypes.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package parsetypes

import (
"github.com/activecm/rita/config"
"strings"
)

//BroData holds a line of a bro log
Expand All @@ -13,20 +14,23 @@ type BroData interface {
//NewBroDataFactory creates a new BroData based on the string
//which appears in that log's objType field
func NewBroDataFactory(fileType string) func() BroData {
switch fileType {
case "conn":
//Note: we use HasPrefix rather than equality for the checks
//in order to support configurations which tag the log types.
//For instance, Security Onion splits the http log out by
//interface producing http_eth0, http_eth1, etc.
if strings.HasPrefix(fileType, "conn") {
return func() BroData {
return &Conn{}
}
case "dns":
} else if strings.HasPrefix(fileType, "dns") {
return func() BroData {
return &DNS{}
}
case "http":
} else if strings.HasPrefix(fileType, "http") {
return func() BroData {
return &HTTP{}
}
case "ssl":
} else if strings.HasPrefix(fileType, "ssl") {
return func() BroData {
return &SSL{}
}
Expand Down
20 changes: 20 additions & 0 deletions parser/parsetypes/parsetypes_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package parsetypes

import (
"github.com/stretchr/testify/require"
"testing"
)

func TestNewBroDataFactory(t *testing.T) {

testCasesIn := []string{"conn", "http", "dns", "httpa", "http_a", "http_eth0", "httpasdf12345=-ASDF?", "ASDF"}
testCasesOut := []BroData{&Conn{}, &HTTP{}, &DNS{}, &HTTP{}, &HTTP{}, &HTTP{}, &HTTP{}, nil}
for i := range testCasesIn {
factory := NewBroDataFactory(testCasesIn[i])
if factory == nil {
require.Nil(t, testCasesOut[i])
} else {
require.Equal(t, testCasesOut[i], factory())
}
}
}
2 changes: 1 addition & 1 deletion pkg/useragent/mongodb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ var testRepo Repository

var testUserAgent = map[string]*Input{
"Debian APT-HTTP/1.3 (1.2.24)": &Input{
Ips: []string{"1.2.3.4", "1.1.1.1"},
OrigIps: []string{"1.2.3.4", "1.1.1.1"},
Seen: 123,
},
}
Expand Down

0 comments on commit 5fdb5f1

Please sign in to comment.