Skip to content

Commit

Permalink
Merge branch '8.10' into update-version-next-8.10.3
Browse files Browse the repository at this point in the history
  • Loading branch information
pierrehilbert authored Sep 22, 2023
2 parents 70f327f + 369a99f commit 1b129e0
Show file tree
Hide file tree
Showing 17 changed files with 451 additions and 77 deletions.
2 changes: 1 addition & 1 deletion .buildkite/scripts/steps/integration_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ DEV=true EXTERNAL=true SNAPSHOT=true PLATFORMS=linux/amd64,linux/arm64 PACKAGES=
# Run integration tests
set +e
# Use 8.10.2-SNAPSHOT until the first 8.10.3-SNAPSHOT is produced.
AGENT_STACK_VERSION="8.10.2-SNAPSHOT" TEST_INTEG_CLEAN_ON_EXIT=true SNAPSHOT=true mage integration:test
AGENT_STACK_VERSION="8.10.2-SNAPSHOT" TEST_INTEG_AUTH_ESS_REGION=azure-eastus2 TEST_INTEG_CLEAN_ON_EXIT=true SNAPSHOT=true mage integration:test
TESTS_EXIT_STATUS=$?
set -e

Expand Down
4 changes: 2 additions & 2 deletions NOTICE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17274,11 +17274,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

--------------------------------------------------------------------------------
Dependency : golang.org/x/oauth2
Version: v0.4.0
Version: v0.7.0
Licence type (autodetected): BSD-3-Clause
--------------------------------------------------------------------------------

Contents of probable licence file $GOMODCACHE/golang.org/x/oauth2@v0.4.0/LICENSE:
Contents of probable licence file $GOMODCACHE/golang.org/x/oauth2@v0.7.0/LICENSE:

Copyright (c) 2009 The Go Authors. All rights reserved.

Expand Down
31 changes: 31 additions & 0 deletions changelog/8.10.2.asciidoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// begin 8.10.2 relnotes

[[release-notes-8.10.2]]
== 8.10.2

Review important information about the 8.10.2 release.

[discrete]
[[security-updates-8.10.2]]
=== Security updates


elastic-agent::

* Upgrade Go version to 1.20.8. {elastic-agent-pull}https://github.com/elastic/elastic-agent/pull/3393[#https://github.com/elastic/elastic-agent/pull/3393]















// end 8.10.2 relnotes
13 changes: 13 additions & 0 deletions changelog/8.10.2.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
version: 8.10.2
entries:
- kind: security
summary: Upgrade Go version to 1.20.8.
description: ""
component: elastic-agent
pr:
- https://github.com/elastic/elastic-agent/pull/3393
issue: []
timestamp: 1694700200
file:
name: 1694700200-Upgrade-to-Go-1.20.8.yaml
checksum: f9a337cf39abbf93f66c393e52c66053ea700d09
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,24 @@
# - 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: security
kind: bug-fix

# Change summary; a 80ish characters long description of the change.
summary: Upgrade to Go 1.20.8.
summary: Resilient handling of air gapped PGP checks

# 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:
description: Elastic Agent should not fail when remote PGP is specified (or official Elastic fallback PGP used) and remote is not available

# Affected component; usually one of "elastic-agent", "fleet-server", "filebeat", "metricbeat", "auditbeat", "all", etc.
component: "elastic-agent"
# Affected component; a word indicating the component this changeset affects.
component: elastic-agent

# PR URL; optional; the PR number that added the changeset.
# PR number; 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/3393
pr: 3427

# Issue URL; optional; the GitHub issue related to this changeset (either closes or is part of).
# Issue number; 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/owner/repo/1234
issue: 3368
2 changes: 1 addition & 1 deletion deploy/kubernetes/elastic-agent-managed-kubernetes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ spec:
dnsPolicy: ClusterFirstWithHostNet
containers:
- name: elastic-agent
image: docker.elastic.co/beats/elastic-agent:8.10.1
image: docker.elastic.co/beats/elastic-agent:8.10.2
env:
# Set to 1 for enrollment into Fleet server. If not set, Elastic Agent is run in standalone mode
- name: FLEET_ENROLL
Expand Down
4 changes: 2 additions & 2 deletions deploy/kubernetes/elastic-agent-standalone-kubernetes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -683,13 +683,13 @@ spec:
# - -c
# - >-
# mkdir -p /etc/elastic-agent/inputs.d &&
# wget -O - https://github.com/elastic/elastic-agent/archive/8.10.1.tar.gz | tar xz -C /etc/elastic-agent/inputs.d --strip=5 "elastic-agent-8.10.1/deploy/kubernetes/elastic-agent-standalone/templates.d"
# wget -O - https://github.com/elastic/elastic-agent/archive/8.10.2.tar.gz | tar xz -C /etc/elastic-agent/inputs.d --strip=5 "elastic-agent-8.10.2/deploy/kubernetes/elastic-agent-standalone/templates.d"
# volumeMounts:
# - name: external-inputs
# mountPath: /etc/elastic-agent/inputs.d
containers:
- name: elastic-agent-standalone
image: docker.elastic.co/beats/elastic-agent:8.10.1
image: docker.elastic.co/beats/elastic-agent:8.10.2
args: ["-c", "/etc/elastic-agent/agent.yml", "-e"]
env:
# The basic authentication username used to connect to Elasticsearch
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ require (
golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e // indirect
golang.org/x/mod v0.9.0 // indirect
golang.org/x/net v0.9.0 // indirect
golang.org/x/oauth2 v0.4.0 // indirect
golang.org/x/oauth2 v0.7.0 // indirect
golang.org/x/term v0.7.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20230110181048-76db0878b65f // indirect
Expand Down
3 changes: 2 additions & 1 deletion go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -2059,8 +2059,9 @@ golang.org/x/oauth2 v0.0.0-20220822191816-0ebed06d0094/go.mod h1:h4gKUeWbJ4rQPri
golang.org/x/oauth2 v0.0.0-20220909003341-f21342109be1/go.mod h1:h4gKUeWbJ4rQPri7E0u6Gs4e9Ri2zaLxzw5DI5XGrYg=
golang.org/x/oauth2 v0.0.0-20221006150949-b44042a4b9c1/go.mod h1:h4gKUeWbJ4rQPri7E0u6Gs4e9Ri2zaLxzw5DI5XGrYg=
golang.org/x/oauth2 v0.0.0-20221014153046-6fdb5e3db783/go.mod h1:h4gKUeWbJ4rQPri7E0u6Gs4e9Ri2zaLxzw5DI5XGrYg=
golang.org/x/oauth2 v0.4.0 h1:NF0gk8LVPg1Ml7SSbGyySuoxdsXitj7TvgvuRxIMc/M=
golang.org/x/oauth2 v0.4.0/go.mod h1:RznEsdpjGAINPTOF0UH/t+xJ75L18YO3Ho6Pyn+uRec=
golang.org/x/oauth2 v0.7.0 h1:qe6s0zUXlPX80/dITx3440hWZ7GwMwgDDyrSGTPJG/g=
golang.org/x/oauth2 v0.7.0/go.mod h1:hPLQkd9LyjfXTiRohC/41GhcFqxisoUQ99sCUOHO9x4=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,11 @@ func (v *Verifier) verifyAsc(fullPath string, skipDefaultPgp bool, pgpSources ..
if len(check) == 0 {
continue
}
raw, err := download.PgpBytesFromSource(check, v.client)
raw, err := download.PgpBytesFromSource(v.log, check, v.client)
if err != nil {
return err
}

if len(raw) == 0 {
continue
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,50 +173,60 @@ func prepareFetchVerifyTests(dropPath, targetDir, targetFilePath, hashTargetFile
}

func TestVerify(t *testing.T) {
log, _ := logger.New("", false)
targetDir, err := ioutil.TempDir(os.TempDir(), "")
if err != nil {
t.Fatal(err)
tt := []struct {
Name string
RemotePGPUris []string
UnreachableCount int
}{
{"default", nil, 0},
{"unreachable local path", []string{download.PgpSourceURIPrefix + "https://127.0.0.1:2874/path/does/not/exist"}, 1},
}

timeout := 30 * time.Second

config := &artifact.Config{
TargetDirectory: targetDir,
DropPath: filepath.Join(targetDir, "drop"),
OperatingSystem: "linux",
Architecture: "32",
HTTPTransportSettings: httpcommon.HTTPTransportSettings{
Timeout: timeout,
},
for _, tc := range tt {
t.Run(tc.Name, func(t *testing.T) {
log, obs := logger.NewTesting("TestVerify")
targetDir, err := ioutil.TempDir(os.TempDir(), "")
require.NoError(t, err)

timeout := 30 * time.Second

config := &artifact.Config{
TargetDirectory: targetDir,
DropPath: filepath.Join(targetDir, "drop"),
OperatingSystem: "linux",
Architecture: "32",
HTTPTransportSettings: httpcommon.HTTPTransportSettings{
Timeout: timeout,
},
}

err = prepareTestCase(beatSpec, version, config)
require.NoError(t, err)

testClient := NewDownloader(config)
artifact, err := testClient.Download(context.Background(), beatSpec, version)
require.NoError(t, err)

t.Cleanup(func() {
os.Remove(artifact)
os.Remove(artifact + ".sha512")
os.RemoveAll(config.DropPath)
})

_, err = os.Stat(artifact)
require.NoError(t, err)

testVerifier, err := NewVerifier(log, config, true, nil)
require.NoError(t, err)

err = testVerifier.Verify(beatSpec, version, false, tc.RemotePGPUris...)
require.NoError(t, err)

// log message informing remote PGP was skipped
logs := obs.FilterMessageSnippet("Skipped remote PGP located at")
require.Equal(t, tc.UnreachableCount, logs.Len())
})
}

if err := prepareTestCase(beatSpec, version, config); err != nil {
t.Fatal(err)
}

testClient := NewDownloader(config)
artifact, err := testClient.Download(context.Background(), beatSpec, version)
if err != nil {
t.Fatal(err)
}

_, err = os.Stat(artifact)
if err != nil {
t.Fatal(err)
}

testVerifier, err := NewVerifier(log, config, true, nil)
if err != nil {
t.Fatal(err)
}

err = testVerifier.Verify(beatSpec, version, false)
require.NoError(t, err)

os.Remove(artifact)
os.Remove(artifact + ".sha512")
os.RemoveAll(config.DropPath)
}

func prepareTestCase(a artifact.Artifact, version string, cfg *artifact.Config) error {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,11 @@ func (v *Verifier) verifyAsc(a artifact.Artifact, version string, skipDefaultPgp
if len(check) == 0 {
continue
}
raw, err := download.PgpBytesFromSource(check, v.client)
raw, err := download.PgpBytesFromSource(v.log, check, v.client)
if err != nil {
return err
}

if len(raw) == 0 {
continue
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,11 @@ import (
"strings"
"time"

"github.com/elastic/elastic-agent/internal/pkg/agent/application/upgrade/artifact"
"github.com/hashicorp/go-multierror"

"golang.org/x/crypto/openpgp" //nolint:staticcheck // crypto/openpgp is only receiving security updates.

"github.com/elastic/elastic-agent/internal/pkg/agent/application/upgrade/artifact"
"github.com/elastic/elastic-agent/internal/pkg/agent/errors"
)

Expand All @@ -32,6 +33,17 @@ const (
PgpSourceURIPrefix = "pgp_uri:"
)

var (
ErrRemotePGPDownloadFailed = errors.New("Remote PGP download failed")
ErrInvalidLocation = errors.New("Remote PGP location is invalid")
)

// warnLogger is a logger that only needs to implement Warnf, as that is the only functions
// that the downloadProgressReporter uses.
type warnLogger interface {
Warnf(format string, args ...interface{})
}

// ChecksumMismatchError indicates the expected checksum for a file does not
// match the computed checksum.
type ChecksumMismatchError struct {
Expand Down Expand Up @@ -168,13 +180,17 @@ func VerifyGPGSignature(file string, asciiArmorSignature, publicKey []byte) erro
return nil
}

func PgpBytesFromSource(source string, client http.Client) ([]byte, error) {
func PgpBytesFromSource(log warnLogger, source string, client http.Client) ([]byte, error) {
if strings.HasPrefix(source, PgpSourceRawPrefix) {
return []byte(strings.TrimPrefix(source, PgpSourceRawPrefix)), nil
}

if strings.HasPrefix(source, PgpSourceURIPrefix) {
return fetchPgpFromURI(strings.TrimPrefix(source, PgpSourceURIPrefix), client)
pgpBytes, err := fetchPgpFromURI(strings.TrimPrefix(source, PgpSourceURIPrefix), client)
if errors.Is(err, ErrRemotePGPDownloadFailed) || errors.Is(err, ErrInvalidLocation) {
log.Warnf("Skipped remote PGP located at %q because it's unavailable: %v", strings.TrimPrefix(source, PgpSourceURIPrefix), err)
}
return pgpBytes, nil
}

return nil, errors.New("unknown pgp source")
Expand All @@ -187,7 +203,7 @@ func CheckValidDownloadUri(rawURI string) error {
}

if !strings.EqualFold(uri.Scheme, "https") {
return fmt.Errorf("failed to check URI %q: HTTPS is required", rawURI)
return multierror.Append(fmt.Errorf("failed to check URI %q: HTTPS is required", rawURI), ErrInvalidLocation)
}

return nil
Expand All @@ -207,7 +223,7 @@ func fetchPgpFromURI(uri string, client http.Client) ([]byte, error) {
}
resp, err := http.DefaultClient.Do(req)
if err != nil {
return nil, err
return nil, multierror.Append(err, ErrRemotePGPDownloadFailed)
}
defer resp.Body.Close()

Expand Down
3 changes: 3 additions & 0 deletions magefile.go
Original file line number Diff line number Diff line change
Expand Up @@ -1728,10 +1728,13 @@ func createTestRunner(matrix bool, singleTest string, goTestFlags string, batche
if datacenter == "" {
datacenter = "us-central1-a"
}

// Valid values are gcp-us-central1 (default), azure-eastus2
essRegion := os.Getenv("TEST_INTEG_AUTH_ESS_REGION")
if essRegion == "" {
essRegion = "gcp-us-central1"
}

instanceProvisionerMode := os.Getenv("INSTANCE_PROVISIONER")
if instanceProvisionerMode == "" {
instanceProvisionerMode = "ogc"
Expand Down
Loading

0 comments on commit 1b129e0

Please sign in to comment.