Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Elastic Defend arm64 is not supported on Windows yet #4155

Merged
merged 35 commits into from
Feb 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
42b06d7
Elastic Defend arm64 is not supported on Windows yet
intxgo Jan 26, 2024
030962e
fix lint
intxgo Jan 27, 2024
aed78cf
correct platform condition
intxgo Jan 27, 2024
7e5b325
machine architecture constants from MSDN
intxgo Jan 29, 2024
287a839
fix const declaration
intxgo Jan 29, 2024
12ddaf5
refactoring; test fix
intxgo Jan 30, 2024
69c326d
return fix
intxgo Jan 30, 2024
d441719
refactoring
intxgo Jan 30, 2024
fea0076
Merge branch 'main' of github.com:intxgo/elastic-agent into lesio/arm…
intxgo Jan 30, 2024
e711ac3
refactoring
intxgo Jan 30, 2024
6cd6a74
fix lint errors on legacy code
intxgo Jan 31, 2024
98e1366
remove unnecessary access query mask
intxgo Jan 31, 2024
fd4307b
Merge branch 'main' of github.com:intxgo/elastic-agent into lesio/arm…
intxgo Jan 31, 2024
0e306b7
Merge branch 'elastic:main' into lesio/arm64-not-supported-on-windows
intxgo Jan 31, 2024
47a8211
Merge branch 'main' into lesio/arm64-not-supported-on-windows
michalpristas Feb 9, 2024
618952b
use updated go-sysinfo
intxgo Feb 12, 2024
69ad4a0
fix unit test
intxgo Feb 12, 2024
0768c59
revert accidental change
intxgo Feb 12, 2024
8bb8d76
Merge branch 'main' into lesio/arm64-not-supported-on-windows
intxgo Feb 12, 2024
9e4febb
update go-sysinfo to official release
intxgo Feb 12, 2024
f3aca60
go mod tidy
intxgo Feb 12, 2024
c788a5b
update go-sysinfo
intxgo Feb 13, 2024
73e7039
Merge branch 'main' into lesio/arm64-not-supported-on-windows
intxgo Feb 13, 2024
1a30c8a
go mod tidy
intxgo Feb 13, 2024
39a4ee9
hex edit version
intxgo Feb 13, 2024
93f1086
Revert "hex edit version"
intxgo Feb 13, 2024
6139af4
hex edit
intxgo Feb 13, 2024
a40afc7
Merge branch 'main' into lesio/arm64-not-supported-on-windows
intxgo Feb 13, 2024
5f4b3dd
go-sysinfo HostInfo.Architecture and HostInfo.NativeArchitecture use …
intxgo Feb 13, 2024
eb9dadb
unify amd64 arch in Agent
intxgo Feb 13, 2024
676a2fb
aarch64 to arm64
intxgo Feb 13, 2024
2364e13
lint fix: don't use Yoda ifs
intxgo Feb 13, 2024
9a202b3
try to increase test coverage ratio
intxgo Feb 13, 2024
75dc15e
Merge branch 'main' into lesio/arm64-not-supported-on-windows
intxgo Feb 13, 2024
fc0ee5b
fix goimports
intxgo Feb 13, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions NOTICE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2222,11 +2222,11 @@ Contents of probable licence file $GOMODCACHE/github.com/elastic/go-licenser@v0.

--------------------------------------------------------------------------------
Dependency : github.com/elastic/go-sysinfo
Version: v1.11.2
Version: v1.13.1
Licence type (autodetected): Apache-2.0
--------------------------------------------------------------------------------

Contents of probable licence file $GOMODCACHE/github.com/elastic/go-sysinfo@v1.11.2/LICENSE.txt:
Contents of probable licence file $GOMODCACHE/github.com/elastic/go-sysinfo@v1.13.1/LICENSE.txt:


Apache License
Expand Down
1 change: 1 addition & 0 deletions docs/component-specs.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ The variables that can be accessed by a condition are:

- `runtime.os`: the operating system, either `"windows"`, `"darwin"`, `"linux"`, or `"container"`.
- `runtime.arch`: the CPU architecture, either `"amd64"` or `"arm64"`.
- `runtime.native_arch`: the machine CPU architecture, either `"amd64"` or `"arm64"`.
- `runtime.platform`: a string combining the OS and architecture, e.g. `"windows/amd64"`, `"darwin/arm64"`.
- `runtime.family`: OS family, e.g. `"debian"`, `"redhat"`, `"windows"`, `"darwin"`
- `runtime.major`, `runtime.minor`: the operating system version. Note that these are strings not integers, so they must be converted in order to use numeric comparison. For example to check if the OS major version is at most 12, use `number(runtime.major) <= 12`.
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ require (
github.com/elastic/elastic-transport-go/v8 v8.3.0
github.com/elastic/go-elasticsearch/v8 v8.10.1
github.com/elastic/go-licenser v0.4.1
github.com/elastic/go-sysinfo v1.11.2
github.com/elastic/go-sysinfo v1.13.1
github.com/elastic/go-ucfg v0.8.6
github.com/fatih/color v1.15.0
github.com/fsnotify/fsnotify v1.7.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -820,8 +820,8 @@ github.com/elastic/go-structform v0.0.10 h1:oy08o/Ih2hHTkNcRY/1HhaYvIp5z6t8si8gn
github.com/elastic/go-structform v0.0.10/go.mod h1:CZWf9aIRYY5SuKSmOhtXScE5uQiLZNqAFnwKR4OrIM4=
github.com/elastic/go-sysinfo v1.1.1/go.mod h1:i1ZYdU10oLNfRzq4vq62BEwD2fH8KaWh6eh0ikPT9F0=
github.com/elastic/go-sysinfo v1.7.1/go.mod h1:i1ZYdU10oLNfRzq4vq62BEwD2fH8KaWh6eh0ikPT9F0=
github.com/elastic/go-sysinfo v1.11.2 h1:mcm4OSYVMyws6+n2HIVMGkln5HOpo5Ie1ZmbbNn0jg4=
github.com/elastic/go-sysinfo v1.11.2/go.mod h1:GKqR8bbMK/1ITnez9NIsIfXQr25aLhRJa7AfT8HpBFQ=
github.com/elastic/go-sysinfo v1.13.1 h1:U5Jlx6c/rLkR72O8wXXXo1abnGlWGJU/wbzNJ2AfQa4=
github.com/elastic/go-sysinfo v1.13.1/go.mod h1:GKqR8bbMK/1ITnez9NIsIfXQr25aLhRJa7AfT8HpBFQ=
github.com/elastic/go-ucfg v0.8.6 h1:stUeyh2goTgGX+/wb9gzKvTv0YB0231LTpKUgCKj4U0=
github.com/elastic/go-ucfg v0.8.6/go.mod h1:4E8mPOLSUV9hQ7sgLEJ4bvt0KhMuDJa8joDT2QGAEKA=
github.com/elastic/go-windows v1.0.0/go.mod h1:TsU0Nrp7/y3+VwE82FoZF8gC/XFg/Elz6CcloAxnPgU=
Expand Down
9 changes: 9 additions & 0 deletions internal/pkg/agent/application/info/inject_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@ func agentGlobalConfig() (map[string]interface{}, error) {
return nil, err
}

nativeArch := hostInfo.Info().NativeArchitecture
if nativeArch == "x86_64" {
nativeArch = "amd64"
}
if nativeArch == "aarch64" {
nativeArch = "arm64"
}

return map[string]interface{}{
"path": map[string]interface{}{
"data": paths.Data(),
Expand All @@ -47,6 +55,7 @@ func agentGlobalConfig() (map[string]interface{}, error) {
},
"runtime.os": runtime.GOOS,
"runtime.arch": runtime.GOARCH,
"runtime.native_arch": nativeArch,
"runtime.osinfo.type": hostInfo.Info().OS.Type,
"runtime.osinfo.family": hostInfo.Info().OS.Family,
"runtime.osinfo.version": hostInfo.Info().OS.Version,
Expand Down
25 changes: 25 additions & 0 deletions internal/pkg/agent/application/info/inject_config_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
// or more contributor license agreements. Licensed under the Elastic License;
// you may not use this file except in compliance with the Elastic License.

package info

import (
"testing"

"github.com/stretchr/testify/assert"

"github.com/elastic/elastic-agent/internal/pkg/config"
)

func TestInjectAgentConfig(t *testing.T) {
c := config.New()
err := InjectAgentConfig(c)
assert.NoError(t, err)
}

func TestAgentGlobalConfig(t *testing.T) {
c, err := agentGlobalConfig()
assert.NoError(t, err)
assert.NotEmpty(t, c)
}
13 changes: 7 additions & 6 deletions pkg/component/component.go
Original file line number Diff line number Diff line change
Expand Up @@ -867,12 +867,13 @@ func varsForPlatform(platform PlatformDetail) (*transpiler.Vars, error) {
"in_default": paths.ArePathsEqual(paths.Top(), paths.InstallPath(paths.DefaultBasePath)) || pkgmgr.InstalledViaExternalPkgMgr(),
},
"runtime": map[string]interface{}{
"platform": platform.String(),
"os": platform.OS,
"arch": platform.Arch,
"family": platform.Family,
"major": platform.Major,
"minor": platform.Minor,
"platform": platform.String(),
"os": platform.OS,
"arch": platform.Arch,
"native_arch": platform.NativeArch,
"family": platform.Family,
"major": platform.Major,
"minor": platform.Minor,
},
"user": map[string]interface{}{
"root": hasRoot,
Expand Down
13 changes: 7 additions & 6 deletions pkg/component/component_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1980,12 +1980,13 @@ func TestPreventionsAreValid(t *testing.T) {
"in_default": true,
},
"runtime": map[string]interface{}{
"platform": "platform",
"os": "os",
"arch": "arch",
"family": "family",
"major": "major",
"minor": "minor",
"platform": "platform",
"os": "os",
"arch": "arch",
"native_arch": "native_arch",
"family": "family",
"major": "major",
"minor": "minor",
},
"user": map[string]interface{}{
"root": false,
Expand Down
25 changes: 19 additions & 6 deletions pkg/component/platforms.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,10 @@ func (p Platforms) Exists(platform string) bool {
type PlatformDetail struct {
Platform

Family string
Major string
Minor string
NativeArch string
Family string
Major string
Minor string
}

// PlatformModifier can modify the platform details before the runtime specifications are loaded.
Expand All @@ -118,15 +119,27 @@ func LoadPlatformDetail(modifiers ...PlatformModifier) (PlatformDetail, error) {
return PlatformDetail{}, err
}
os := info.Info().OS
nativeArch := info.Info().NativeArchitecture
if nativeArch == "x86_64" {
// go-sysinfo Architecture and NativeArchitecture prefer x64_64
// but GOARCH prefers amd64
nativeArch = "amd64"
}
if nativeArch == "aarch64" {
// go-sysinfo Architecture and NativeArchitecture prefer aarch64
// but GOARCH prefers arm64
nativeArch = "arm64"
}
detail := PlatformDetail{
Platform: Platform{
OS: goruntime.GOOS,
Arch: goruntime.GOARCH,
GOOS: goruntime.GOOS,
},
Family: os.Family,
Major: strconv.Itoa(os.Major),
Minor: strconv.Itoa(os.Minor),
NativeArch: nativeArch,
Family: os.Family,
Major: strconv.Itoa(os.Major),
Minor: strconv.Itoa(os.Minor),
}
for _, modifier := range modifiers {
detail = modifier(detail)
Expand Down
17 changes: 17 additions & 0 deletions pkg/component/platforms_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
// or more contributor license agreements. Licensed under the Elastic License;
// you may not use this file except in compliance with the Elastic License.

package component

import (
"testing"

"github.com/stretchr/testify/assert"
)

func TestLoadPlatformDetail(t *testing.T) {
platformDetail, err := LoadPlatformDetail()
assert.NoError(t, err)
assert.NotEmpty(t, platformDetail)
}
2 changes: 2 additions & 0 deletions specs/endpoint-security.spec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ inputs:
message: "Elastic Defend requires Elastic Agent be running as Administrator or SYSTEM"
- condition: ${install.in_default} == false
message: "Elastic Defend requires Elastic Agent be installed at the default installation path"
- condition: ${runtime.native_arch} != 'amd64'
message: "Elastic Defend cannot be installed on Windows running on non-AMD64 CPU"
service:
cport: 6788
log:
Expand Down
Loading