Skip to content

Commit

Permalink
Review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
michel-laterman committed Dec 6, 2024
1 parent bdfc5b3 commit e9439f4
Show file tree
Hide file tree
Showing 5 changed files with 144 additions and 4 deletions.
36 changes: 36 additions & 0 deletions internal/pkg/bulk/main-rw-fix.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
goos: darwin
goarch: arm64
pkg: github.com/elastic/fleet-server/v7/internal/pkg/bulk
cpu: Apple M3 Pro
Benchmark_CreateAndGetBulker/new_remote_bulker-12 25941 48065 ns/op 40253 B/op 1033 allocs/op
Benchmark_CreateAndGetBulker/new_remote_bulker-12 27991 47838 ns/op 40250 B/op 1033 allocs/op
Benchmark_CreateAndGetBulker/new_remote_bulker-12 27492 44356 ns/op 40240 B/op 1033 allocs/op
Benchmark_CreateAndGetBulker/new_remote_bulker-12 27138 43572 ns/op 40280 B/op 1033 allocs/op
Benchmark_CreateAndGetBulker/new_remote_bulker-12 26901 43903 ns/op 40309 B/op 1033 allocs/op
Benchmark_CreateAndGetBulker/new_remote_bulker-12 26010 43864 ns/op 40166 B/op 1033 allocs/op
Benchmark_CreateAndGetBulker/new_remote_bulker-12 26672 44383 ns/op 40171 B/op 1034 allocs/op
Benchmark_CreateAndGetBulker/new_remote_bulker-12 26898 43952 ns/op 40387 B/op 1033 allocs/op
Benchmark_CreateAndGetBulker/new_remote_bulker-12 26626 45326 ns/op 40165 B/op 1033 allocs/op
Benchmark_CreateAndGetBulker/new_remote_bulker-12 26696 44306 ns/op 40438 B/op 1033 allocs/op
Benchmark_CreateAndGetBulker/existing_remote_bulker-12 1805066 662.9 ns/op 591 B/op 11 allocs/op
Benchmark_CreateAndGetBulker/existing_remote_bulker-12 1839223 656.8 ns/op 591 B/op 11 allocs/op
Benchmark_CreateAndGetBulker/existing_remote_bulker-12 1838432 674.9 ns/op 591 B/op 11 allocs/op
Benchmark_CreateAndGetBulker/existing_remote_bulker-12 1831557 649.2 ns/op 591 B/op 11 allocs/op
Benchmark_CreateAndGetBulker/existing_remote_bulker-12 1832120 652.0 ns/op 591 B/op 11 allocs/op
Benchmark_CreateAndGetBulker/existing_remote_bulker-12 1831706 649.5 ns/op 591 B/op 11 allocs/op
Benchmark_CreateAndGetBulker/existing_remote_bulker-12 1829000 648.0 ns/op 591 B/op 11 allocs/op
Benchmark_CreateAndGetBulker/existing_remote_bulker-12 1826839 649.4 ns/op 591 B/op 11 allocs/op
Benchmark_CreateAndGetBulker/existing_remote_bulker-12 1833283 650.8 ns/op 591 B/op 11 allocs/op
Benchmark_CreateAndGetBulker/existing_remote_bulker-12 1828750 651.2 ns/op 591 B/op 11 allocs/op
Benchmark_CreateAndGetBulker/changed_remote_bulker-12 26553 45153 ns/op 39718 B/op 1039 allocs/op
Benchmark_CreateAndGetBulker/changed_remote_bulker-12 24874 47960 ns/op 39714 B/op 1038 allocs/op
Benchmark_CreateAndGetBulker/changed_remote_bulker-12 24280 44834 ns/op 40045 B/op 1038 allocs/op
Benchmark_CreateAndGetBulker/changed_remote_bulker-12 25674 46259 ns/op 39726 B/op 1039 allocs/op
Benchmark_CreateAndGetBulker/changed_remote_bulker-12 25620 46267 ns/op 39702 B/op 1038 allocs/op
Benchmark_CreateAndGetBulker/changed_remote_bulker-12 25525 46039 ns/op 40168 B/op 1038 allocs/op
Benchmark_CreateAndGetBulker/changed_remote_bulker-12 25470 46942 ns/op 39709 B/op 1038 allocs/op
Benchmark_CreateAndGetBulker/changed_remote_bulker-12 24754 46803 ns/op 39710 B/op 1038 allocs/op
Benchmark_CreateAndGetBulker/changed_remote_bulker-12 22600 47309 ns/op 39701 B/op 1038 allocs/op
Benchmark_CreateAndGetBulker/changed_remote_bulker-12 22599 49313 ns/op 40304 B/op 1038 allocs/op
PASS
ok github.com/elastic/fleet-server/v7/internal/pkg/bulk 311.285s
36 changes: 36 additions & 0 deletions internal/pkg/bulk/main.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
goos: darwin
goarch: arm64
pkg: github.com/elastic/fleet-server/v7/internal/pkg/bulk
cpu: Apple M3 Pro
Benchmark_CreateAndGetBulker/new_remote_bulker-12 25165 52129 ns/op 40256 B/op 1033 allocs/op
Benchmark_CreateAndGetBulker/new_remote_bulker-12 26389 47834 ns/op 40264 B/op 1034 allocs/op
Benchmark_CreateAndGetBulker/new_remote_bulker-12 27608 44456 ns/op 40239 B/op 1033 allocs/op
Benchmark_CreateAndGetBulker/new_remote_bulker-12 27332 47049 ns/op 40165 B/op 1033 allocs/op
Benchmark_CreateAndGetBulker/new_remote_bulker-12 26984 43686 ns/op 40166 B/op 1033 allocs/op
Benchmark_CreateAndGetBulker/new_remote_bulker-12 26925 43477 ns/op 40167 B/op 1033 allocs/op
Benchmark_CreateAndGetBulker/new_remote_bulker-12 26182 44774 ns/op 40343 B/op 1033 allocs/op
Benchmark_CreateAndGetBulker/new_remote_bulker-12 26761 44256 ns/op 40384 B/op 1033 allocs/op
Benchmark_CreateAndGetBulker/new_remote_bulker-12 25546 44333 ns/op 40171 B/op 1033 allocs/op
Benchmark_CreateAndGetBulker/new_remote_bulker-12 26368 46800 ns/op 40447 B/op 1033 allocs/op
Benchmark_CreateAndGetBulker/existing_remote_bulker-12 1824036 683.9 ns/op 591 B/op 11 allocs/op
Benchmark_CreateAndGetBulker/existing_remote_bulker-12 1848823 671.0 ns/op 591 B/op 11 allocs/op
Benchmark_CreateAndGetBulker/existing_remote_bulker-12 1839692 645.8 ns/op 591 B/op 11 allocs/op
Benchmark_CreateAndGetBulker/existing_remote_bulker-12 1842247 669.2 ns/op 591 B/op 11 allocs/op
Benchmark_CreateAndGetBulker/existing_remote_bulker-12 1837004 668.4 ns/op 591 B/op 11 allocs/op
Benchmark_CreateAndGetBulker/existing_remote_bulker-12 1830702 647.1 ns/op 591 B/op 11 allocs/op
Benchmark_CreateAndGetBulker/existing_remote_bulker-12 1834053 679.0 ns/op 591 B/op 11 allocs/op
Benchmark_CreateAndGetBulker/existing_remote_bulker-12 1839746 645.2 ns/op 591 B/op 11 allocs/op
Benchmark_CreateAndGetBulker/existing_remote_bulker-12 1808619 648.6 ns/op 591 B/op 11 allocs/op
Benchmark_CreateAndGetBulker/existing_remote_bulker-12 1844908 645.7 ns/op 591 B/op 11 allocs/op
Benchmark_CreateAndGetBulker/changed_remote_bulker-12 26640 44105 ns/op 39719 B/op 1039 allocs/op
Benchmark_CreateAndGetBulker/changed_remote_bulker-12 26028 45552 ns/op 39717 B/op 1038 allocs/op
Benchmark_CreateAndGetBulker/changed_remote_bulker-12 25972 45687 ns/op 40067 B/op 1038 allocs/op
Benchmark_CreateAndGetBulker/changed_remote_bulker-12 25732 45917 ns/op 39717 B/op 1039 allocs/op
Benchmark_CreateAndGetBulker/changed_remote_bulker-12 25776 46629 ns/op 39713 B/op 1038 allocs/op
Benchmark_CreateAndGetBulker/changed_remote_bulker-12 24942 45638 ns/op 40171 B/op 1038 allocs/op
Benchmark_CreateAndGetBulker/changed_remote_bulker-12 25629 48624 ns/op 39705 B/op 1038 allocs/op
Benchmark_CreateAndGetBulker/changed_remote_bulker-12 24576 48907 ns/op 39702 B/op 1038 allocs/op
Benchmark_CreateAndGetBulker/changed_remote_bulker-12 20707 50390 ns/op 39664 B/op 1038 allocs/op
Benchmark_CreateAndGetBulker/changed_remote_bulker-12 18493 56357 ns/op 39608 B/op 1037 allocs/op
PASS
ok github.com/elastic/fleet-server/v7/internal/pkg/bulk 310.337s
36 changes: 36 additions & 0 deletions internal/pkg/bulk/sync.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
goos: darwin
goarch: arm64
pkg: github.com/elastic/fleet-server/v7/internal/pkg/bulk
cpu: Apple M3 Pro
Benchmark_CreateAndGetBulker/new_remote_bulker-12 25536 49924 ns/op 39812 B/op 1039 allocs/op
Benchmark_CreateAndGetBulker/new_remote_bulker-12 25104 51083 ns/op 39811 B/op 1039 allocs/op
Benchmark_CreateAndGetBulker/new_remote_bulker-12 27362 47382 ns/op 39786 B/op 1039 allocs/op
Benchmark_CreateAndGetBulker/new_remote_bulker-12 26697 43802 ns/op 39717 B/op 1039 allocs/op
Benchmark_CreateAndGetBulker/new_remote_bulker-12 26805 43566 ns/op 39718 B/op 1039 allocs/op
Benchmark_CreateAndGetBulker/new_remote_bulker-12 23706 44920 ns/op 39724 B/op 1039 allocs/op
Benchmark_CreateAndGetBulker/new_remote_bulker-12 26589 47365 ns/op 39892 B/op 1039 allocs/op
Benchmark_CreateAndGetBulker/new_remote_bulker-12 26619 44601 ns/op 39723 B/op 1039 allocs/op
Benchmark_CreateAndGetBulker/new_remote_bulker-12 26817 44662 ns/op 39723 B/op 1039 allocs/op
Benchmark_CreateAndGetBulker/new_remote_bulker-12 26355 46193 ns/op 39716 B/op 1039 allocs/op
Benchmark_CreateAndGetBulker/existing_remote_bulker-12 1673110 716.6 ns/op 623 B/op 13 allocs/op
Benchmark_CreateAndGetBulker/existing_remote_bulker-12 1700258 709.8 ns/op 623 B/op 13 allocs/op
Benchmark_CreateAndGetBulker/existing_remote_bulker-12 1693080 701.8 ns/op 623 B/op 13 allocs/op
Benchmark_CreateAndGetBulker/existing_remote_bulker-12 1690299 703.4 ns/op 623 B/op 13 allocs/op
Benchmark_CreateAndGetBulker/existing_remote_bulker-12 1685422 710.7 ns/op 623 B/op 13 allocs/op
Benchmark_CreateAndGetBulker/existing_remote_bulker-12 1677685 759.2 ns/op 623 B/op 13 allocs/op
Benchmark_CreateAndGetBulker/existing_remote_bulker-12 1425019 724.6 ns/op 623 B/op 13 allocs/op
Benchmark_CreateAndGetBulker/existing_remote_bulker-12 1631347 755.3 ns/op 623 B/op 13 allocs/op
Benchmark_CreateAndGetBulker/existing_remote_bulker-12 1699515 703.2 ns/op 623 B/op 13 allocs/op
Benchmark_CreateAndGetBulker/existing_remote_bulker-12 1552597 707.2 ns/op 623 B/op 13 allocs/op
Benchmark_CreateAndGetBulker/changed_remote_bulker-12 26545 46197 ns/op 39708 B/op 1042 allocs/op
Benchmark_CreateAndGetBulker/changed_remote_bulker-12 24967 47356 ns/op 39694 B/op 1042 allocs/op
Benchmark_CreateAndGetBulker/changed_remote_bulker-12 25510 45531 ns/op 40066 B/op 1042 allocs/op
Benchmark_CreateAndGetBulker/changed_remote_bulker-12 25729 45856 ns/op 39711 B/op 1042 allocs/op
Benchmark_CreateAndGetBulker/changed_remote_bulker-12 25489 48470 ns/op 39715 B/op 1042 allocs/op
Benchmark_CreateAndGetBulker/changed_remote_bulker-12 25580 49839 ns/op 40153 B/op 1042 allocs/op
Benchmark_CreateAndGetBulker/changed_remote_bulker-12 25389 46238 ns/op 39704 B/op 1042 allocs/op
Benchmark_CreateAndGetBulker/changed_remote_bulker-12 23331 47771 ns/op 39693 B/op 1042 allocs/op
Benchmark_CreateAndGetBulker/changed_remote_bulker-12 22828 49345 ns/op 39675 B/op 1042 allocs/op
Benchmark_CreateAndGetBulker/changed_remote_bulker-12 24502 60800 ns/op 40156 B/op 1041 allocs/op
PASS
ok github.com/elastic/fleet-server/v7/internal/pkg/bulk 329.143s
9 changes: 8 additions & 1 deletion internal/pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,11 +170,18 @@ func redactOutput(cfg *Config) Output {
}

for k := range redacted.Elasticsearch.Headers {
if strings.Contains(strings.ToLower(k), "auth") || strings.Contains(strings.ToLower(k), "token") || strings.Contains(strings.ToLower(k), "key") { // best-effort scan to redact sensitive headers
lk := strings.ToLower(k)
if strings.Contains(lk, "auth") || strings.Contains(lk, "token") || strings.Contains(lk, "key") || strings.Contains(lk, "bearer") { // best-effort scan to redact sensitive headers
redacted.Elasticsearch.Headers[k] = kRedacted
}
}

for k := range redacted.Elasticsearch.ProxyHeaders {
lk := strings.ToLower(k)
if strings.Contains(lk, "auth") || strings.Contains(lk, "token") || strings.Contains(lk, "key") || strings.Contains(lk, "bearer") { // best-effort scan to redact sensitive headers
redacted.Elasticsearch.ProxyHeaders[k] = kRedacted
}
}
return redacted
}

Expand Down
31 changes: 28 additions & 3 deletions internal/pkg/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -427,14 +427,14 @@ func TestConfigRedact(t *testing.T) {
},
},
{
name: "Redact custom authorization output header",
name: "Redact custom output headers",
inputCfg: &Config{
Inputs: []Input{{}},
Output: Output{
Elasticsearch: Elasticsearch{
Protocol: "https",
Hosts: []string{"localhost:9200"},
Headers: map[string]string{"X-Authorization": "secretValue", "X-Custom": "value"},
Headers: map[string]string{"X-Authorization": "secretValue", "X-Custom": "value", "X-App-Token": "customToken", "X-App-Key": "secretKey", "X-Custom-Bearer": "secretBearer"},
ServiceTokenPath: "path/to/file",
},
},
Expand All @@ -445,7 +445,32 @@ func TestConfigRedact(t *testing.T) {
Elasticsearch: Elasticsearch{
Protocol: "https",
Hosts: []string{"localhost:9200"},
Headers: map[string]string{"X-Authorization": kRedacted, "X-Custom": "value"},
Headers: map[string]string{"X-Authorization": kRedacted, "X-Custom": "value", "X-App-Token": kRedacted, "X-App-Key": kRedacted, "X-Custom-Bearer": kRedacted},
ServiceTokenPath: "path/to/file",
},
},
},
},
{
name: "Redact proxy authorization output header",
inputCfg: &Config{
Inputs: []Input{{}},
Output: Output{
Elasticsearch: Elasticsearch{
Protocol: "https",
Hosts: []string{"localhost:9200"},
ProxyHeaders: map[string]string{"X-Proxy-Authorization": "secretValue"},
ServiceTokenPath: "path/to/file",
},
},
},
redactedCfg: &Config{
Inputs: []Input{{}},
Output: Output{
Elasticsearch: Elasticsearch{
Protocol: "https",
Hosts: []string{"localhost:9200"},
ProxyHeaders: map[string]string{"X-Proxy-Authorization": kRedacted},
ServiceTokenPath: "path/to/file",
},
},
Expand Down

0 comments on commit e9439f4

Please sign in to comment.