Skip to content

Commit

Permalink
[7.17] (backport elastic-agent#680) Fix transpiler to allow : in dyna…
Browse files Browse the repository at this point in the history
…mic (elastic#32407)

variables.
  • Loading branch information
michel-laterman authored Jul 27, 2022
1 parent 659e0ef commit 2cf7076
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
1 change: 1 addition & 0 deletions x-pack/elastic-agent/CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@
- Allow HTTP metrics to run in bootstrap mode. Add ability to adjust timeouts for Fleet Server. {pull}28260[28260]
- Increase the download artifact timeout to 10mins and add log download statistics. {pull}31461[31461]
- Add filemod times to files in diagnostics collect bundle. {pull}31986[31986]
- Allow ':' characters in dynamic variables. {pull}32407[32407]
- Allow the - char to appear as part of variable names in eql expressions. {pull}32350[32350]

==== New features
Expand Down
2 changes: 1 addition & 1 deletion x-pack/elastic-agent/pkg/agent/transpiler/vars.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
"github.com/elastic/beats/v7/libbeat/common"
)

var varsRegex = regexp.MustCompile(`\${([\p{L}\d\s\\\-_|.'"]*)}`)
var varsRegex = regexp.MustCompile(`\${([\p{L}\d\s\\\-_|.'":]*)}`)

// ErrNoMatch is return when the replace didn't fail, just that no vars match to perform the replace.
var ErrNoMatch = fmt.Errorf("no matching vars")
Expand Down
12 changes: 12 additions & 0 deletions x-pack/elastic-agent/pkg/agent/transpiler/vars_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,24 @@ func TestVars_Replace(t *testing.T) {
false,
false,
},
{
`${"with:colon"}`,
NewStrVal("with:colon"),
false,
false,
},
{
`${un-der_score.}`,
NewStrVal(""),
true,
false,
},
{
`${un-der_score.missing|'with:colon'}`,
NewStrVal("with:colon"),
false,
false,
},
{
`${un-der_score.missing|"oth}`,
NewStrVal(""),
Expand Down

0 comments on commit 2cf7076

Please sign in to comment.