Skip to content
This repository has been archived by the owner on May 25, 2022. It is now read-only.

Commit

Permalink
Enforce maximum SD-NAME length of 32, per RFC5424 (#439)
Browse files Browse the repository at this point in the history
* Enforce maximum SD-NAME length of 32, per RFC5424

Longer SD-NAMEs were previously allowed in fork of go-syslog
dependency, but it is not clear that this is necessary.
  • Loading branch information
djaglowski authored Mar 24, 2022
1 parent c357827 commit a8ec8d4
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 602 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,15 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.28.0] - 2022-03-17

### Changed
- Switch to original go-syslog library, restoring strict enforcement of SD-NAME length. ([PR439](https://github.com/open-telemetry/opentelemetry-log-collection/pull/439))

## [0.27.2] - 2022-03-17

### Fixed
- Revert version update on syslog-go, which introduced incompatibility with 386 architecture. ([PR348](https://github.com/open-telemetry/opentelemetry-log-collection/pull/348))
- Revert version update on go-syslog, which introduced incompatibility with 386 architecture. ([PR438](https://github.com/open-telemetry/opentelemetry-log-collection/pull/438))

## [0.27.1] - 2022-03-16

Expand Down
6 changes: 4 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ require (
github.com/json-iterator/go v1.1.12
github.com/mitchellh/mapstructure v1.4.3
github.com/observiq/ctimefmt v1.0.0
github.com/observiq/go-syslog/v3 v3.0.2
github.com/observiq/nanojack v0.0.0-20201106172433-343928847ebc
github.com/stretchr/testify v1.7.1
go.opentelemetry.io/collector v0.46.0
Expand All @@ -24,7 +23,10 @@ require (
k8s.io/client-go v0.23.4
)

require go.uber.org/multierr v1.8.0
require (
github.com/influxdata/go-syslog/v3 v3.0.1-0.20210608084020-ac565dc76ba6
go.uber.org/multierr v1.8.0
)

require (
github.com/benbjohnson/clock v1.3.0 // indirect
Expand Down
453 changes: 2 additions & 451 deletions go.sum

Large diffs are not rendered by default.

112 changes: 0 additions & 112 deletions internal/tools/go.sum

Large diffs are not rendered by default.

27 changes: 0 additions & 27 deletions operator/parser/syslog/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,33 +144,6 @@ func CreateCases(basicConfig func() *SyslogParserConfig) ([]Case, error) {
entry.Info,
"info",
},
{
"RFC5424LongSDName",
func() *SyslogParserConfig {
cfg := basicConfig()
cfg.Protocol = RFC5424
return cfg
}(),
`<86>1 2015-08-05T21:58:59.693Z 192.168.2.132 SecureAuth0 23108 ID52020 [verylongsdnamethatisgreaterthan32bytes@12345 UserHostAddress="192.168.2.132"] my message`,
time.Date(2015, 8, 5, 21, 58, 59, 693000000, time.UTC),
map[string]interface{}{
"appname": "SecureAuth0",
"facility": 10,
"hostname": "192.168.2.132",
"message": "my message",
"msg_id": "ID52020",
"priority": 86,
"proc_id": "23108",
"structured_data": map[string]map[string]string{
"verylongsdnamethatisgreaterthan32bytes@12345": {
"UserHostAddress": "192.168.2.132",
},
},
"version": 1,
},
entry.Info,
"info",
},
}

return cases, nil
Expand Down
6 changes: 3 additions & 3 deletions operator/parser/syslog/syslog.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ import (
"fmt"
"time"

sl "github.com/observiq/go-syslog/v3"
"github.com/observiq/go-syslog/v3/rfc3164"
"github.com/observiq/go-syslog/v3/rfc5424"
sl "github.com/influxdata/go-syslog/v3"
"github.com/influxdata/go-syslog/v3/rfc3164"
"github.com/influxdata/go-syslog/v3/rfc5424"
"go.uber.org/zap"

"github.com/open-telemetry/opentelemetry-log-collection/entry"
Expand Down
39 changes: 33 additions & 6 deletions operator/parser/syslog/syslog_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ import (
"github.com/open-telemetry/opentelemetry-log-collection/testutil"
)

func TestSyslogParser(t *testing.T) {
basicConfig := func() *SyslogParserConfig {
cfg := NewSyslogParserConfig("test_operator_id")
cfg.OutputIDs = []string{"fake"}
return cfg
}
func basicConfig() *SyslogParserConfig {
cfg := NewSyslogParserConfig("test_operator_id")
cfg.OutputIDs = []string{"fake"}
return cfg
}

func TestSyslogParser(t *testing.T) {
cases, err := CreateCases(basicConfig)
require.NoError(t, err)

Expand Down Expand Up @@ -67,6 +67,33 @@ func TestSyslogParser(t *testing.T) {
}
}

func TestSyslogParseRFC5424_SDNameTooLong(t *testing.T) {
cfg := basicConfig()
cfg.Protocol = RFC5424

body := `<86>1 2015-08-05T21:58:59.693Z 192.168.2.132 SecureAuth0 23108 ID52020 [verylongsdnamethatisgreaterthan32bytes@12345 UserHostAddress="192.168.2.132"] my message`

op, err := cfg.Build(testutil.Logger(t))
require.NoError(t, err)

fake := testutil.NewFakeOutput(t)
err = op.SetOutputs([]operator.Operator{fake})
require.NoError(t, err)

newEntry := entry.New()
newEntry.Body = body
err = op.Process(context.Background(), newEntry)
require.Error(t, err)
require.Contains(t, err.Error(), "expecting a structured data element id (from 1 to max 32 US-ASCII characters")

select {
case e := <-fake.Received:
require.Equal(t, body, e.Body)
case <-time.After(time.Second):
require.FailNow(t, "Timed out waiting for entry to be processed")
}
}

func TestSyslogParserConfig(t *testing.T) {
expect := NewSyslogParserConfig("test")
expect.Protocol = RFC3164
Expand Down

0 comments on commit a8ec8d4

Please sign in to comment.