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

Pull changes from upstream #54

Merged
merged 11 commits into from
Sep 3, 2024
17 changes: 1 addition & 16 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,7 @@ jobs:
- name: Linter
run: |
go version
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.56.2
make lint
make lint TARGET_ARCH=amd64

test:
name: Test
Expand All @@ -79,20 +78,6 @@ jobs:
steps:
- name: Install dependencies
run: sudo apt-get update && sudo apt-get install -y --no-install-recommends gcc make llvm clang-16 dwz cmake curl unzip
- name: Install Zydis
shell: bash
run: |
cd /tmp
git clone --depth 1 --branch v3.1.0 --recursive https://github.com/zyantific/zydis.git
cd zydis
rm -rf build
mkdir build
cd build
cmake -DZYDIS_BUILD_EXAMPLES=OFF ..
make -j$(nproc)
sudo make install
cd zycore
sudo make install
- name: Check out
uses: actions/checkout@v4
- name: Set up Go ${{matrix.go}}
Expand Down
49 changes: 17 additions & 32 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
service:
golangci-lint-version: 1.54.x
golangci-lint-version: 1.60.x

run:
skip-dirs:
issues:
exclude-dirs:
- artifacts
- build-targets
- design
Expand All @@ -23,6 +23,10 @@ run:
- target
- virt-tests
- vm-images
exclude-rules:
- path: hostmetadata/azure/azure.go
linters:
- lll

linters:
enable-all: true
Expand All @@ -31,18 +35,19 @@ linters:
# - too many non-sensical warnings
# - not relevant for us
# - false positives
#
#
# "might be worth fixing" means we should investigate/fix in the mid term
- containedctx # might be worth fixing
- contextcheck # might be worth fixing
- cyclop
- depguard
- dupword
- durationcheck # might be worth fixing
- err113
- errorlint # might be worth fixing
- exhaustive
- exhaustivestruct
- exhaustruct
- forbidigo
- forcetypeassert # might be worth fixing
- funlen
- gci # might be worth fixing
Expand All @@ -53,27 +58,23 @@ linters:
- gocyclo
- godot
- godox # complains about TODO etc
- goerr113
- gofumpt
- gomnd
- gomoddirectives
- ifshort
- inamedparam
- interfacebloat
- ireturn
- maintidx
- makezero
- mnd
- nestif
- nilerr # might be worth fixing
- nilnil
- nlreturn
- noctx # might be worth fixing
- nolintlint
- nonamedreturns
- nosnakecase
- paralleltest
- protogetter
- scopelint # might be worth fixing
- sqlclosecheck # might be worth fixing
- tagalign
- tagliatelle
Expand All @@ -85,18 +86,11 @@ linters:
- wastedassign
- wsl
- wrapcheck
- forbidigo
# the following linters are deprecated
- exhaustivestruct
- scopelint
- nosnakecase
- interfacer
- maligned
- ifshort
- structcheck # might be worth fixing
- deadcode
- golint
- varcheck
- execinquery
# we don't want to change code to Go 1.22+ yet
- intrange
- copyloopvar

linters-settings:
goconst:
Expand All @@ -112,22 +106,13 @@ linters-settings:
disabled-checks:
- dupImport # https://github.com/go-critic/go-critic/issues/845
- ifElseChain
- octalLiteral
- whyNoLint
- wrapperFunc
- sloppyReassign
- uncheckedInlineErr # Experimental rule with high false positive rate.

# Broken with Go 1.18 feature (https://github.com/golangci/golangci-lint/issues/2649):
- hugeParam
- rangeValCopy
- typeDefFirst
- paramTypeCombine
gocyclo:
min-complexity: 15
govet:
enable-all: true
check-shadowing: true
disable:
- fieldalignment
settings:
Expand All @@ -143,7 +128,7 @@ linters-settings:
lll:
line-length: 100
tab-width: 4
maligned:
suggest-new: true
misspell:
locale: US
ignore-words:
- rela
6 changes: 0 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,6 @@ RUN apt-get update -y && apt-get dist-upgrade -y && apt-get install -y \
curl wget cmake dwz lsb-release software-properties-common gnupg git clang-16 llvm \
golang unzip jq sudo && apt-get clean autoclean && apt-get autoremove --yes

RUN git clone --depth 1 --branch v3.1.0 --recursive https://github.com/zyantific/zydis.git && \
cd zydis && mkdir build && cd build && \
cmake -DZYDIS_BUILD_EXAMPLES=OFF .. && make -j$(nproc) && make install && \
cd zycore && make install && \
cd ../../.. && rm -rf zydis

RUN wget -qO- https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.56.2


Expand Down
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,12 @@ binary:
ebpf:
$(MAKE) -j$(shell nproc) -C support/ebpf

GOLANGCI_LINT_VERSION = "v1.60.1"
lint: generate
# We don't want to build the tracers here, so we stub them for linting
touch support/ebpf/tracer.ebpf.x86
golangci-lint run --timeout 10m
go run github.com/golangci/golangci-lint/cmd/golangci-lint@$(GOLANGCI_LINT_VERSION) version
go run github.com/golangci/golangci-lint/cmd/golangci-lint@$(GOLANGCI_LINT_VERSION) run --build-tags integration,linux --timeout 10m

test: generate ebpf test-deps
go test ./...
Expand Down
2 changes: 1 addition & 1 deletion config/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func (e EnvironmentType) String() string {
case envAzure:
return "azure"
case envAWS:
// nolint: goconst
//nolint: goconst
return "aws"
default:
return fmt.Sprintf("unknown environment %d", e)
Expand Down
2 changes: 1 addition & 1 deletion containermetadata/containermetadata_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ func BenchmarkGetKubernetesPodMetadata(b *testing.B) {

file, err := os.CreateTemp("", "test_containermetadata_cgroup*")
require.NoError(b, err)
defer os.Remove(file.Name()) // nolint: gocritic
defer os.Remove(file.Name()) //nolint: gocritic

_, err = fmt.Fprintf(file,
"0::/kubepods/besteffort/poda9c80282-3f6b-4d5b-84d5-a137a6668011/"+
Expand Down
16 changes: 8 additions & 8 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,10 @@ require (
golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8
golang.org/x/sync v0.7.0
golang.org/x/sys v0.21.0
google.golang.org/grpc v1.64.0
google.golang.org/protobuf v1.34.1
k8s.io/api v0.30.2
k8s.io/apimachinery v0.30.2
k8s.io/client-go v0.30.2
google.golang.org/grpc v1.64.1
k8s.io/api v0.30.3
k8s.io/apimachinery v0.30.3
k8s.io/client-go v0.30.3
)

require (
Expand Down Expand Up @@ -117,14 +116,15 @@ require (
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.45.0 // indirect
go.opentelemetry.io/otel/metric v1.27.0 // indirect
go.opentelemetry.io/otel/trace v1.27.0 // indirect
golang.org/x/net v0.23.0 // indirect
golang.org/x/net v0.26.0 // indirect
golang.org/x/oauth2 v0.20.0 // indirect
golang.org/x/term v0.18.0 // indirect
golang.org/x/text v0.15.0 // indirect
golang.org/x/term v0.21.0 // indirect
golang.org/x/text v0.16.0 // indirect
golang.org/x/time v0.3.0 // indirect
google.golang.org/genproto v0.0.0-20230920204549-e6e6cdab5c13 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240513163218-0867130af1f8 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240513163218-0867130af1f8 // indirect
google.golang.org/protobuf v1.34.1 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
Expand Down
28 changes: 14 additions & 14 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -310,8 +310,8 @@ golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLL
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
golang.org/x/net v0.23.0 h1:7EYJ93RZ9vYSZAIb2x3lnuvqO5zneoD6IvWjuhfxjTs=
golang.org/x/net v0.23.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg=
golang.org/x/net v0.26.0 h1:soB7SVo0PWrY4vPW/+ay0jKDNScG2X9wFeYlXIvJsOQ=
golang.org/x/net v0.26.0/go.mod h1:5YKkiSynbBIh3p6iOc/vibscux0x38BZDkn8sCUPxHE=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.20.0 h1:4mQdhULixXKP1rwYBW0vAijoXnkTG0BLCDRzfe1idMo=
golang.org/x/oauth2 v0.20.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI=
Expand All @@ -333,12 +333,12 @@ golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws=
golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.18.0 h1:FcHjZXDMxI8mM3nwhX9HlKop4C0YQvCVCdwYl2wOtE8=
golang.org/x/term v0.18.0/go.mod h1:ILwASektA3OnRv7amZ1xhE/KTR+u50pbXfZ03+6Nx58=
golang.org/x/term v0.21.0 h1:WVXCp+/EBEHOj53Rvu+7KiT/iElMrO8ACK16SMZ3jaA=
golang.org/x/term v0.21.0/go.mod h1:ooXLefLobQVslOqselCNF4SxFAaoS6KujMbsGzSDmX0=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.15.0 h1:h1V/4gjBv8v9cjcR6+AR5+/cIYK5N/WAgiv4xlsEtAk=
golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4=
golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI=
golang.org/x/time v0.3.0 h1:rg5rLMjNzMS1RkNLzCG38eapWhnYLFYXDXj2gOlr8j4=
golang.org/x/time v0.3.0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
Expand Down Expand Up @@ -371,8 +371,8 @@ google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyac
google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY=
google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc=
google.golang.org/grpc v1.64.0 h1:KH3VH9y/MgNQg1dE7b3XfVK0GsPSIzJwdF617gUSbvY=
google.golang.org/grpc v1.64.0/go.mod h1:oxjF8E3FBnjp+/gVFYdWacaLDx9na1aqy9oovLpxQYg=
google.golang.org/grpc v1.64.1 h1:LKtvyfbX3UGVPFcGqJ9ItpVWW6oN/2XqTxfAnwRRXiA=
google.golang.org/grpc v1.64.1/go.mod h1:hiQF4LFZelK2WKaP6W0L92zGHtiQdZxk8CrSdvyjeP0=
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
Expand Down Expand Up @@ -401,12 +401,12 @@ gotest.tools/v3 v3.5.1 h1:EENdUnS3pdur5nybKYIh2Vfgc8IUNBjxDPSjtiJcOzU=
gotest.tools/v3 v3.5.1/go.mod h1:isy3WKz7GK6uNw/sbHzfKBLvlvXwUyV06n6brMxxopU=
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
k8s.io/api v0.30.2 h1:+ZhRj+28QT4UOH+BKznu4CBgPWgkXO7XAvMcMl0qKvI=
k8s.io/api v0.30.2/go.mod h1:ULg5g9JvOev2dG0u2hig4Z7tQ2hHIuS+m8MNZ+X6EmI=
k8s.io/apimachinery v0.30.2 h1:fEMcnBj6qkzzPGSVsAZtQThU62SmQ4ZymlXRC5yFSCg=
k8s.io/apimachinery v0.30.2/go.mod h1:iexa2somDaxdnj7bha06bhb43Zpa6eWH8N8dbqVjTUc=
k8s.io/client-go v0.30.2 h1:sBIVJdojUNPDU/jObC+18tXWcTJVcwyqS9diGdWHk50=
k8s.io/client-go v0.30.2/go.mod h1:JglKSWULm9xlJLx4KCkfLLQ7XwtlbflV6uFFSHTMgVs=
k8s.io/api v0.30.3 h1:ImHwK9DCsPA9uoU3rVh4QHAHHK5dTSv1nxJUapx8hoQ=
k8s.io/api v0.30.3/go.mod h1:GPc8jlzoe5JG3pb0KJCSLX5oAFIW3/qNJITlDj8BH04=
k8s.io/apimachinery v0.30.3 h1:q1laaWCmrszyQuSQCfNB8cFgCuDAoPszKY4ucAjDwHc=
k8s.io/apimachinery v0.30.3/go.mod h1:iexa2somDaxdnj7bha06bhb43Zpa6eWH8N8dbqVjTUc=
k8s.io/client-go v0.30.3 h1:bHrJu3xQZNXIi8/MoxYtZBBWQQXwy16zqJwloXXfD3k=
k8s.io/client-go v0.30.3/go.mod h1:8d4pf8vYu665/kUbsxWAQ/JDBNWqfFeZnvFiVdmx89U=
k8s.io/klog/v2 v2.120.1 h1:QXU6cPEOIslTGvZaXvFWiP9VKyeet3sawzTOvdXb4Vw=
k8s.io/klog/v2 v2.120.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE=
k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340 h1:BZqlfIlq5YbRMFko6/PM7FjZpUb45WallggurYhKGag=
Expand Down
1 change: 0 additions & 1 deletion hostmetadata/azure/azure.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ type IMDS struct {
// Failures (missing keys, etc) are logged and ignored.
//
// We extract the Azure metadata according to the information at
// nolint:lll
// https://docs.microsoft.com/en-us/azure/virtual-machines/windows/instance-metadata-service?tabs=linux#endpoint-categories
//
// - 169.254.169.254 is the standard endpoint for the instance metadata service in all clouds.
Expand Down
2 changes: 1 addition & 1 deletion hostmetadata/azure/azure_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
"github.com/stretchr/testify/require"
)

// nolint:lll
//nolint:lll
const fakeAzureAnswer = `{
"compute": {
"azEnvironment": "AzurePublicCloud",
Expand Down
1 change: 1 addition & 0 deletions hostmetadata/host/cpuid_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ func TestCPUID_ParseOnlineCPUCoreIDs(t *testing.T) {
func prepareFakeCPUOnlineFile(t *testing.T, content string) *os.File {
f, err := os.CreateTemp("", "sys_device_cpu_online")
require.NoError(t, err)
//nolint:gosec
_ = os.WriteFile(f.Name(), []byte(content), os.ModePerm)
return f
}
2 changes: 1 addition & 1 deletion hostmetadata/host/cpuinfo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func TestReadCPUInfo(t *testing.T) {
assert.NotEmpty(t, cps)
i, err := strconv.Atoi(cps)
require.NoErrorf(t, err, "%v must be parseable as a number", cps)
assert.Greater(t, i, 0)
assert.Positive(t, i)
},
"OnlineCPUs": func(t *testing.T) {
assert.Contains(t, info[key(keyCPUOnline)], 0)
Expand Down
9 changes: 6 additions & 3 deletions interpreter/apmint/apmint.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,9 @@ var dsoRegex = regexp.MustCompile(`.*/elastic-jvmti-linux-([\w-]*)\.so`)
// apmProcessStorage represents a subset of the information present in the
// APM process storage.
//
// nolint:lll
// https://github.com/elastic/apm/blob/bd5fa9c1/specs/agents/universal-profiling-integration.md#process-storage-layout
//
//nolint:lll
type apmProcessStorage struct {
ServiceName string
TraceSocketPath string
Expand Down Expand Up @@ -186,8 +187,9 @@ func isPotentialAgentLib(path string) bool {

// nextString reads the next `utf8-str` from memory and updates addr accordingly.
//
// nolint:lll
// https://github.com/elastic/apm/blob/bd5fa9c1/specs/agents/universal-profiling-integration.md#general-memory-layout
//
//nolint:lll
func nextString(rm remotememory.RemoteMemory, addr *libpf.Address, maxLen int) (string, error) {
length := int(rm.Uint32(*addr))
*addr += 4
Expand All @@ -211,8 +213,9 @@ func nextString(rm remotememory.RemoteMemory, addr *libpf.Address, maxLen int) (

// readProcStorage reads the APM process storage from memory.
//
// nolint:lll
// https://github.com/elastic/apm/blob/bd5fa9c1/specs/agents/universal-profiling-integration.md#process-storage-layout
//
//nolint:lll
func readProcStorage(
rm remotememory.RemoteMemory,
procStorageAddr libpf.Address,
Expand Down
3 changes: 2 additions & 1 deletion interpreter/apmint/socket.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,9 @@ func (s *apmAgentSocket) SendMessage(msg []byte) error {

// traceCorrMsg represents a trace correlation socket message.
//
// nolint:lll
// https://github.com/elastic/apm/blob/bd5fa9c1/specs/agents/universal-profiling-integration.md#cpu-profiler-trace-correlation-message
//
//nolint:lll
type traceCorrMsg struct {
MessageType uint16
MinorVersion uint16
Expand Down
2 changes: 1 addition & 1 deletion interpreter/dotnet/dotnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ package dotnet
// Microsoft .Net Unwinder support code

// The Microsoft dotnet is formally specified in ECMA-335. For the main references see:
// nolint:lll
//nolint:lll
// sources https://github.com/dotnet/runtime/
// ECMA-335 https://www.ecma-international.org/wp-content/uploads/ECMA-335_6th_edition_june_2012.pdf
// R2RFMT https://github.com/dotnet/runtime/blob/v8.0.0/docs/design/coreclr/botr/readytorun-format.md
Expand Down
Loading
Loading