Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/go_modules/otel-dependencies-0082…
Browse files Browse the repository at this point in the history
…6e177e
  • Loading branch information
pierrehilbert authored Jul 3, 2024
2 parents e21efb4 + 026e3f5 commit b60906c
Show file tree
Hide file tree
Showing 26 changed files with 1,123 additions and 748 deletions.
2 changes: 1 addition & 1 deletion .go-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.21.11
1.22.4
8 changes: 4 additions & 4 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ linters-settings:

gosimple:
# Select the Go version to target. The default is '1.13'.
go: "1.21.11"
go: "1.22.4"

nakedret:
# make an issue if func has more lines of code than this setting and it has naked returns; default is 30
Expand All @@ -136,17 +136,17 @@ linters-settings:

staticcheck:
# Select the Go version to target. The default is '1.13'.
go: "1.21.11"
go: "1.22.4"
checks: ["all"]

stylecheck:
# Select the Go version to target. The default is '1.13'.
go: "1.21.11"
go: "1.22.4"
checks: ["all"]

unused:
# Select the Go version to target. The default is '1.13'.
go: "1.21.11"
go: "1.22.4"

gosec:
excludes:
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ARG GO_VERSION=1.21.11
ARG GO_VERSION=1.22.4
FROM circleci/golang:${GO_VERSION}


Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.skaffold
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ARG GO_VERSION=1.21.11
ARG GO_VERSION=1.22.4
ARG crossbuild_image="docker.elastic.co/beats-dev/golang-crossbuild"
ARG AGENT_VERSION=8.9.0-SNAPSHOT
ARG AGENT_IMAGE="docker.elastic.co/beats/elastic-agent"
Expand Down
58 changes: 30 additions & 28 deletions NOTICE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,39 +42,41 @@ SOFTWARE.


--------------------------------------------------------------------------------
Dependency : github.com/antlr/antlr4/runtime/Go/antlr/v4
Version: v4.0.0-20230321174746-8dcc6526cfb1
Dependency : github.com/antlr4-go/antlr/v4
Version: v4.13.0
Licence type (autodetected): BSD-3-Clause
--------------------------------------------------------------------------------

Contents of probable licence file $GOMODCACHE/github.com/antlr/antlr4/runtime/!go/antlr/v4@v4.0.0-20230321174746-8dcc6526cfb1/LICENSE:
Contents of probable licence file $GOMODCACHE/github.com/antlr4-go/antlr/v4@v4.13.0/LICENSE:

Copyright 2021 The ANTLR Project
Copyright (c) 2012-2023 The ANTLR Project. All rights reserved.

Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:

1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.

3. Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from this
software without specific prior written permission.
3. Neither name of copyright holders nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


--------------------------------------------------------------------------------
Expand Down Expand Up @@ -2668,11 +2670,11 @@ limitations under the License.

--------------------------------------------------------------------------------
Dependency : github.com/elastic/opentelemetry-collector-components/processor/elasticinframetricsprocessor
Version: v0.3.0
Version: v0.4.0
Licence type (autodetected): Apache-2.0
--------------------------------------------------------------------------------

Contents of probable licence file $GOMODCACHE/github.com/elastic/opentelemetry-collector-components/processor/elasticinframetricsprocessor@v0.3.0/LICENSE:
Contents of probable licence file $GOMODCACHE/github.com/elastic/opentelemetry-collector-components/processor/elasticinframetricsprocessor@v0.4.0/LICENSE:

Apache License
Version 2.0, January 2004
Expand Down Expand Up @@ -20089,11 +20091,11 @@ limitations under the License.

--------------------------------------------------------------------------------
Dependency : github.com/elastic/opentelemetry-lib
Version: v0.4.0
Version: v0.5.0
Licence type (autodetected): Apache-2.0
--------------------------------------------------------------------------------

Contents of probable licence file $GOMODCACHE/github.com/elastic/opentelemetry-lib@v0.4.0/LICENSE:
Contents of probable licence file $GOMODCACHE/github.com/elastic/opentelemetry-lib@v0.5.0/LICENSE:

Apache License
Version 2.0, January 2004
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
kind: security

# Change summary; a 80ish characters long description of the change.
summary: Upgrade to Go 1.21.11.
summary: Upgrade to Go 1.22.4.

# Long description; in case the summary is not enough to describe the change
# this field accommodate a description without length limits.
Expand All @@ -25,7 +25,7 @@ component: "elastic-agent"
# If not present is automatically filled by the tooling finding the PR where this changelog fragment has been added.
# NOTE: the tooling supports backports, so it's able to fill the original PR number instead of the backport PR number.
# Please provide it if you are adding a fragment for a different PR.
pr: https://github.com/elastic/elastic-agent/pull/4855
pr: https://github.com/elastic/elastic-agent/pull/5036

# Issue URL; optional; the GitHub issue related to this changeset (either closes or is part of).
# If not present is automatically filled by the tooling with the issue linked to the PR number.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Kind can be one of:
# - breaking-change: a change to previously-documented behavior
# - deprecation: functionality that is being removed in a later release
# - bug-fix: fixes a problem in a previous version
# - enhancement: extends functionality but does not break or fix existing behavior
# - feature: new functionality
# - known-issue: problems that we are aware of in a given version
# - security: impacts on the security of a product or a user’s deployment.
# - upgrade: important information for someone upgrading from a prior version
# - other: does not fit into any of the other categories
kind: enhancement

# Change summary; a 80ish characters long description of the change.
summary: Add ability to escape variables in policy

# Long description; in case the summary is not enough to describe the change
# this field accommodate a description without length limits.
# NOTE: This field will be rendered only for breaking-change and known-issue kinds at the moment.
description: |
Adds the ability to escape variables with prefix of '$' allow variables such as `$${...}` to be escaped and
included in the computed policy as `${...}`.
# Affected component; usually one of "elastic-agent", "fleet-server", "filebeat", "metricbeat", "auditbeat", "all", etc.
component: elastic-agent

# PR URL; optional; the PR number that added the changeset.
# If not present is automatically filled by the tooling finding the PR where this changelog fragment has been added.
# NOTE: the tooling supports backports, so it's able to fill the original PR number instead of the backport PR number.
# Please provide it if you are adding a fragment for a different PR.
pr: https://github.com/elastic/elastic-agent/pull/5035

# Issue URL; optional; the GitHub issue related to this changeset (either closes or is part of).
# If not present is automatically filled by the tooling with the issue linked to the PR number.
issue: https://github.com/elastic/elastic-agent/issues/2177
8 changes: 4 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
module github.com/elastic/elastic-agent

go 1.21.10
go 1.22.4

require (
github.com/Microsoft/go-winio v0.6.2
github.com/antlr/antlr4/runtime/Go/antlr/v4 v4.0.0-20230321174746-8dcc6526cfb1
github.com/antlr4-go/antlr/v4 v4.13.0
github.com/billgraziano/dpapi v0.4.0
github.com/blakesmith/ar v0.0.0-20150311145944-8bd4349a67f2
github.com/cavaliercoder/go-rpm v0.0.0-20190131055624-7a9c54e3d83e
Expand All @@ -22,7 +22,7 @@ require (
github.com/elastic/go-sysinfo v1.14.0
github.com/elastic/go-ucfg v0.8.8
github.com/elastic/mock-es v0.0.0-20240605193845-b5546a703d6f
github.com/elastic/opentelemetry-collector-components/processor/elasticinframetricsprocessor v0.3.0
github.com/elastic/opentelemetry-collector-components/processor/elasticinframetricsprocessor v0.4.0
github.com/fatih/color v1.16.0
github.com/fsnotify/fsnotify v1.7.0
github.com/gofrs/flock v0.8.1
Expand Down Expand Up @@ -148,7 +148,7 @@ require (
github.com/elastic/go-structform v0.0.10 // indirect
github.com/elastic/go-windows v1.0.1 // indirect
github.com/elastic/gosigar v0.14.3 // indirect
github.com/elastic/opentelemetry-lib v0.4.0 // indirect
github.com/elastic/opentelemetry-lib v0.5.0 // indirect
github.com/elastic/pkcs8 v1.0.0 // indirect
github.com/emicklei/go-restful/v3 v3.11.0 // indirect
github.com/evanphx/json-patch v5.6.0+incompatible // indirect
Expand Down
12 changes: 6 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -499,8 +499,8 @@ github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be/go.mod h1:ySMOLuW
github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY=
github.com/antlr/antlr4/runtime/Go/antlr v0.0.0-20220418222510-f25a4f6275ed/go.mod h1:F7bn7fEU90QkQ3tnmaTx3LTKLEDqnwWODIYppRQ5hnY=
github.com/antlr/antlr4/runtime/Go/antlr v1.4.10/go.mod h1:F7bn7fEU90QkQ3tnmaTx3LTKLEDqnwWODIYppRQ5hnY=
github.com/antlr/antlr4/runtime/Go/antlr/v4 v4.0.0-20230321174746-8dcc6526cfb1 h1:X8MJ0fnN5FPdcGF5Ij2/OW+HgiJrRg3AfHAx1PJtIzM=
github.com/antlr/antlr4/runtime/Go/antlr/v4 v4.0.0-20230321174746-8dcc6526cfb1/go.mod h1:pSwJ0fSY5KhvocuWSx4fz3BA8OrA1bQn+K1Eli3BRwM=
github.com/antlr4-go/antlr/v4 v4.13.0 h1:lxCg3LAv+EUK6t1i0y1V6/SLeUi0eKEKdhQAlS8TVTI=
github.com/antlr4-go/antlr/v4 v4.13.0/go.mod h1:pfChB/xh/Unjila75QW7+VU4TSnWnnk9UTnmpPaOR2g=
github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o=
github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8=
github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY=
Expand Down Expand Up @@ -851,10 +851,10 @@ github.com/elastic/gosigar v0.14.3 h1:xwkKwPia+hSfg9GqrCUKYdId102m9qTJIIr7egmK/u
github.com/elastic/gosigar v0.14.3/go.mod h1:iXRIGg2tLnu7LBdpqzyQfGDEidKCfWcCMS0WKyPWoMs=
github.com/elastic/mock-es v0.0.0-20240605193845-b5546a703d6f h1:qo0Nn9G+p7HbG+CmiWwSoiKJ/cyRq59TRn9Z2PRHTi8=
github.com/elastic/mock-es v0.0.0-20240605193845-b5546a703d6f/go.mod h1:mVdKBYYwt30xRFjCegbcURHh+3LWOCkQM33fgWbUiRI=
github.com/elastic/opentelemetry-collector-components/processor/elasticinframetricsprocessor v0.3.0 h1:iZrOpSv4X7QIOttTYmfJ73JTlqXa5XxgCXUXw9GEfwM=
github.com/elastic/opentelemetry-collector-components/processor/elasticinframetricsprocessor v0.3.0/go.mod h1:Z3Bgi98f9RhBNwlaT0ZLSbXQLzaNELyTJREV+v+2KgE=
github.com/elastic/opentelemetry-lib v0.4.0 h1:e+N00oKXnv8EIXDVjHXPjkxox98JVm1b4kHVMp1NcTA=
github.com/elastic/opentelemetry-lib v0.4.0/go.mod h1:/kKvHbJLVo/NcKMPHI8/RZKL64fushmnRUzn+arQpjg=
github.com/elastic/opentelemetry-collector-components/processor/elasticinframetricsprocessor v0.4.0 h1:jSq7qvh39GCpv0XF7/hys2mJmQaATKkCNVj/SY5S730=
github.com/elastic/opentelemetry-collector-components/processor/elasticinframetricsprocessor v0.4.0/go.mod h1:cbFtO2rPm7o2kAZKwH/SQ7QZVGYt2qdqHjWOw5TTsYg=
github.com/elastic/opentelemetry-lib v0.5.0 h1:BT1Koon6lm0zF554NuPtachBBR+26RS9GlCaaMbGIJ8=
github.com/elastic/opentelemetry-lib v0.5.0/go.mod h1:/kKvHbJLVo/NcKMPHI8/RZKL64fushmnRUzn+arQpjg=
github.com/elastic/package-spec/v2 v2.6.0/go.mod h1:ks9/FaVOS+vCrGRQcDvXAd2FlmB84mrLikbRiO6ACuk=
github.com/elastic/pkcs8 v1.0.0 h1:HhitlUKxhN288kcNcYkjW6/ouvuwJWd9ioxpjnD9jVA=
github.com/elastic/pkcs8 v1.0.0/go.mod h1:ipsZToJfq1MxclVTwpG7U/bgeDtf+0HkUiOxebk95+0=
Expand Down
9 changes: 8 additions & 1 deletion internal/pkg/agent/transpiler/vars.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
"github.com/elastic/elastic-agent/internal/pkg/core/composable"
)

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 Expand Up @@ -53,6 +53,13 @@ func (v *Vars) Replace(value string) (Node, error) {
lastIndex := 0
for _, r := range matchIdxs {
for i := 0; i < len(r); i += 4 {
if value[r[i]+1] == '$' {
// match on an escaped var, append the raw string with the '$' prefix removed
result += value[lastIndex:r[0]] + value[r[i]+1:r[i+1]]
lastIndex = r[1]
continue
}
// match on a non-escaped var
vars, err := extractVars(value[r[i+2]:r[i+3]])
if err != nil {
return nil, fmt.Errorf(`error parsing variable "%s": %w`, value[r[i]:r[i+1]], err)
Expand Down
6 changes: 6 additions & 0 deletions internal/pkg/agent/transpiler/vars_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,12 @@ func TestVars_Replace(t *testing.T) {
false,
true,
},
{
`start $${keep} ${un-der_score.key1} $${un-der_score.key1}`,
NewStrVal(`start ${keep} data1 ${un-der_score.key1}`),
false,
false,
},
}
for _, test := range tests {
t.Run(test.Input, func(t *testing.T) {
Expand Down
2 changes: 2 additions & 0 deletions internal/pkg/eql/Eql.g4
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ LARR: '[';
RARR: ']';
LDICT: '{';
RDICT: '}';
BEGIN_EVARIABLE: '$${';
BEGIN_VARIABLE: '${';
expList: exp EOF;
Expand Down Expand Up @@ -71,6 +72,7 @@ exp
| left=exp AND right=exp # ExpLogicalAnd
| left=exp OR right=exp # ExpLogicalOR
| boolean # ExpBoolean
| BEGIN_EVARIABLE variableExp RDICT # ExpEVariable
| BEGIN_VARIABLE variableExp RDICT # ExpVariable
| NAME LPAR arguments? RPAR # ExpFunction
| LARR array? RARR # ExpArray
Expand Down
13 changes: 12 additions & 1 deletion internal/pkg/eql/eql_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"os"
"testing"

"github.com/antlr/antlr4/runtime/Go/antlr/v4"
"github.com/antlr4-go/antlr/v4"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

Expand Down Expand Up @@ -58,6 +58,10 @@ func TestEql(t *testing.T) {
result bool
err bool
}{
// escaped variables (not allowed)
{expression: "$${env.HOSTNAME|host.name|'fallback'}", err: true},
{expression: "$${env.HOSTNAME}", err: true},

// variables
{expression: "${env.HOSTNAME|host.name|'fallback'} == 'my-hostname'", result: true},
{expression: "${env.MISSING|host.name|'fallback'} == 'host-name'", result: true},
Expand All @@ -72,6 +76,12 @@ func TestEql(t *testing.T) {
{expression: "${'dash-value'} == 'dash-value'", result: true},
{expression: "${data.with/slash} == 'some/path'", result: true},

// constant of variables
{expression: "'${env.HOSTNAME}' == '${env.HOSTNAME}'", result: true},
{expression: "'${env.HOSTNAME}' == '${env.HOSTSAME}'", result: false},
{expression: "'$${env.HOSTNAME}' == '$${env.HOSTNAME}'", result: true},
{expression: "'$${env.HOSTNAME}' == '$${env.HOSTSAME}'", result: false},

// boolean
{expression: "true", result: true},
{expression: "false", result: false},
Expand Down Expand Up @@ -356,6 +366,7 @@ func TestEql(t *testing.T) {
store := &testVarStore{
vars: map[string]interface{}{
"env.HOSTNAME": "my-hostname",
"env.HOSTSAME": "my-hostname",
"host.name": "host-name",
"data.array": []interface{}{"array1", "array2", "array3"},
"data.with-dash": "dash-value",
Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/eql/expression.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"errors"
"fmt"

"github.com/antlr/antlr4/runtime/Go/antlr/v4"
"github.com/antlr4-go/antlr/v4"
"github.com/hashicorp/go-multierror"

"github.com/elastic/elastic-agent/internal/pkg/eql/parser"
Expand Down
Loading

0 comments on commit b60906c

Please sign in to comment.