Skip to content
Merged
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
2 changes: 1 addition & 1 deletion format/rfc6587_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,5 +85,5 @@ func (s *FormatSuite) TestRFC6587_GetSplitBadSplit(c *C) {
c.Assert(r, NotNil)

err := scanner.Err()
c.Assert(err, ErrorMatches, "strconv.ParseInt: parsing \".2\": invalid syntax")
c.Assert(err, ErrorMatches, "strconv.*: parsing \".2\": invalid syntax")
}
4 changes: 3 additions & 1 deletion internal/syslogparser/rfc5424/rfc5424.go
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,7 @@ func parseUpToLen(buff []byte, cursor *int, l int, maxLen int, e error) (string,

max := *cursor + maxLen

for to = *cursor; (to < max) && (to < l); to++ {
for to = *cursor; (to <= max) && (to < l); to++ {
if buff[to] == ' ' {
found = true
break
Expand All @@ -588,6 +588,8 @@ func parseUpToLen(buff []byte, cursor *int, l int, maxLen int, e error) (string,

if found {
result = string(buff[*cursor:to])
} else if (to > max) {
to = max; // don't go past max
}

*cursor = to
Expand Down
16 changes: 15 additions & 1 deletion internal/syslogparser/rfc5424/rfc5424_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ func (s *Rfc5424TestSuite) TestParser_Valid(c *C) {
// no STRUCTURED-DATA
"<34>1 2003-10-11T22:14:15.003Z mymachine.example.com su - ID47 - 'su root' failed for lonvick on /dev/pts/8",
"<165>1 2003-08-24T05:14:15.000003-07:00 192.0.2.1 myproc 8710 - - %% It's time to make the do-nuts.",
"<165>1 2003-08-24T05:14:15.000003-07:00 192.0.2.1 012345678901234567890123456789012345678901234567 8710 - - %% It's time to make the do-nuts.",
// with STRUCTURED-DATA
`<165>1 2003-10-11T22:14:15.003Z mymachine.example.com evntslog - ID47 [exampleSDID@32473 iut="3" eventSource="Application" eventID="1011"] An application event log entry...`,
// STRUCTURED-DATA Only
Expand Down Expand Up @@ -60,6 +61,19 @@ func (s *Rfc5424TestSuite) TestParser_Valid(c *C) {
"structured_data": "-",
"message": "%% It's time to make the do-nuts.",
},
syslogparser.LogParts{
"priority": 165,
"facility": 20,
"severity": 5,
"version": 1,
"timestamp": time.Date(2003, time.August, 24, 5, 14, 15, 3*10e2, tmpTs.Location()),
"hostname": "192.0.2.1",
"app_name": "012345678901234567890123456789012345678901234567",
"proc_id": "8710",
"msg_id": "-",
"structured_data": "-",
"message": "%% It's time to make the do-nuts.",
},
syslogparser.LogParts{
"priority": 165,
"facility": 20,
Expand Down Expand Up @@ -684,7 +698,7 @@ func (s *Rfc5424TestSuite) TestParseMsgId_Valid(c *C) {

func (s *Rfc5424TestSuite) TestParseMsgId_TooLong(c *C) {
// > 32chars
buff := []byte("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ")
buff := []byte("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ")
procId := ""

s.assertParseMsgId(c, procId, buff, 32, ErrInvalidMsgId)
Expand Down