From f55bd8d99516cf5955ce1745237fb8c52c49a1ff Mon Sep 17 00:00:00 2001 From: Dan Kortschak Date: Fri, 4 Oct 2024 19:25:27 +0930 Subject: [PATCH] packetbeat/module: fix upload of bundled ingest pipelines on Windows (#41110) Detection of data stream identity was using os.PathSeparator which will not match the path separator used by embed.FS which is always "/"[1]. [1]https://pkg.go.dev/embed#hdr-Directives --- CHANGELOG.next.asciidoc | 1 + packetbeat/module/pipeline.go | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.next.asciidoc b/CHANGELOG.next.asciidoc index 3825ab33dd8..92464dcdb0c 100644 --- a/CHANGELOG.next.asciidoc +++ b/CHANGELOG.next.asciidoc @@ -206,6 +206,7 @@ https://github.com/elastic/beats/compare/v8.8.1\...main[Check the HEAD diff] *Packetbeat* +- Fix upload of bundled ingest pipelines on Windows. {pull}41110[41110] *Winlogbeat* diff --git a/packetbeat/module/pipeline.go b/packetbeat/module/pipeline.go index 9e6d2384938..c90f0adda76 100644 --- a/packetbeat/module/pipeline.go +++ b/packetbeat/module/pipeline.go @@ -22,7 +22,6 @@ import ( "encoding/json" "errors" "fmt" - "os" "path" "path/filepath" "strings" @@ -113,7 +112,10 @@ func readFile(filename string, info beat.Info) (p pipeline, err error) { if err != nil { return pipeline{}, err } - ds, _, _ := strings.Cut(filename, string(os.PathSeparator)) + ds, _, ok := strings.Cut(filename, "/") + if !ok { + return pipeline{}, fmt.Errorf("unexpected filename '%s': missing '/' between data stream and 'ingest'", filename) + } p = pipeline{ id: fileset.FormatPipelineID(info.IndexPrefix, "", "", ds, info.Version), contents: updatedContent,