Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
1 change: 1 addition & 0 deletions CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,7 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha2...master[Check the HEAD d
- Fix a connection error in httpjson input. {pull}16123[16123]
- Fix integer overflow in S3 offsets when collecting very large files. {pull}22523[22523]
- Fix CredentialsJSON unpacking for `gcp-pubsub` and `httpjson` inputs. {pull}23277[23277]
- Strip Azure Eventhub connection string in debug logs. {pulll}[]

*Filebeat*

Expand Down
15 changes: 14 additions & 1 deletion x-pack/filebeat/input/azureeventhub/input.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"context"
"encoding/json"
"fmt"
"strings"
"sync"
"time"

Expand Down Expand Up @@ -80,7 +81,7 @@ func NewInput(

in := &azureInput{
config: config,
log: logp.NewLogger(fmt.Sprintf("%s input", inputName)).With("connection string", config.ConnectionString),
log: logp.NewLogger(fmt.Sprintf("%s input", inputName)).With("connection string", stripConnectionString(config.ConnectionString)),
context: inputContext,
workerCtx: workerCtx,
workerCancel: workerCancel,
Expand Down Expand Up @@ -235,3 +236,15 @@ func (a *azureInput) parseMultipleMessages(bMessage []byte) []string {
}
return messages
}

// Strip connection string to remove sensitive information
// A connection string should look like this:
// Endpoint=sb://dummynamespace.servicebus.windows.net/;SharedAccessKeyName=DummyAccessKeyName;SharedAccessKey=5dOntTRytoC24opYThisAsit3is2B+OGY1US/fuL3ly=
// This code will remove everything after ';' so key information is stripped
func stripConnectionString(c string) string {
if parts := strings.SplitN(c, ";", 2); len(parts) == 2 {
return parts[0]
}

return "(redacted)"
Comment thread
jsoriano marked this conversation as resolved.
}
24 changes: 24 additions & 0 deletions x-pack/filebeat/input/azureeventhub/input_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,30 @@ func TestNewInputDone(t *testing.T) {
inputtest.AssertNotStartedInputCanBeDone(t, NewInput, &config)
}

func TestStripConnectionString(t *testing.T) {
tests := []struct {
connectionString, expected string
}{
{
"Endpoint=sb://something",
"(redacted)",
Comment thread
jsoriano marked this conversation as resolved.
},
{
"Endpoint=sb://dummynamespace.servicebus.windows.net/;SharedAccessKeyName=DummyAccessKeyName;SharedAccessKey=5dOntTRytoC24opYThisAsit3is2B+OGY1US/fuL3ly=",
"Endpoint=sb://dummynamespace.servicebus.windows.net/",
},
{
"Endpoint=sb://dummynamespace.servicebus.windows.net/;SharedAccessKey=5dOntTRytoC24opYThisAsit3is2B+OGY1US/fuL3ly=",
"Endpoint=sb://dummynamespace.servicebus.windows.net/",
},
}

for _, tt := range tests {
res := stripConnectionString(tt.connectionString)
assert.Equal(t, res, tt.expected)
}
}

type stubOutleter struct {
sync.Mutex
cond *sync.Cond
Expand Down