Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 2 additions & 1 deletion api/npipe/listener_windows_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@ import (
"net/http"
"testing"

"github.com/elastic/elastic-agent-libs/transport/httpcommon"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/elastic/elastic-agent-libs/transport/httpcommon"
)

func TestHTTPOverNamedPipe(t *testing.T) {
Expand Down
3 changes: 2 additions & 1 deletion dev-tools/mage/benchmark.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,10 @@ import (
"strconv"
"strings"

"github.com/elastic/elastic-agent-libs/dev-tools/mage/gotool"
"github.com/magefile/mage/mg"
"github.com/magefile/mage/sh"

"github.com/elastic/elastic-agent-libs/dev-tools/mage/gotool"
)

const (
Expand Down
2 changes: 1 addition & 1 deletion dev-tools/mage/fmt.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import (

const (
// GoImportsImportPath controls the import path used to install goimports.
GoImportsImportPath = "golang.org/x/tools/cmd/goimports"
GoImportsImportPath = "golang.org/x/tools/cmd/goimports@latest"

// GoImportsLocalPrefix is a string prefix matching imports that should be
// grouped after third-party packages.
Expand Down
13 changes: 6 additions & 7 deletions helpers/windows/pdh/zpdh_windows.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion logp/configure/logging_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@ package configure
import (
"testing"

"github.com/stretchr/testify/require"

"github.com/elastic/elastic-agent-libs/config"
"github.com/elastic/elastic-agent-libs/logp"
"github.com/stretchr/testify/require"
)

func TestLoggerOutputEnvironment(t *testing.T) {
Expand Down
3 changes: 2 additions & 1 deletion logp/logptest/logptest.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@ package logptest
import (
"testing"

"github.com/elastic/elastic-agent-libs/logp"
"go.uber.org/zap"
"go.uber.org/zap/zapcore"
"go.uber.org/zap/zaptest"
"go.uber.org/zap/zaptest/observer"

"github.com/elastic/elastic-agent-libs/logp"
)

// NewTestingLogger returns a testing suitable logp.Logger.
Expand Down
2 changes: 1 addition & 1 deletion monitoring/metrics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ func TestSafeVars(t *testing.T) {
})
wg.Wait()
})

t.Run("NewTimestamp", func(t *testing.T) {
reg := NewRegistry()
name := "foo"
Expand Down
3 changes: 2 additions & 1 deletion periodic/ratelimited_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@ import (
"testing"
"time"

"github.com/elastic/elastic-agent-libs/iobuf"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/elastic/elastic-agent-libs/iobuf"
)

type syncBuffer struct {
Expand Down
2 changes: 1 addition & 1 deletion processors/dissect/delimiter.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"strings"
)

//delimiter represents a text section after or before a key, it keeps track of the needle and allows
// delimiter represents a text section after or before a key, it keeps track of the needle and allows
// to retrieve the position where it starts from a haystack.
type delimiter interface {
// IndexOf receives the haystack and a offset position and will return the absolute position where
Expand Down
6 changes: 6 additions & 0 deletions processors/dissect/field.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ func (f baseField) String() string {
// dissect: %{key}
// message: hello
// result:
//
// key: hello
type normalField struct {
baseField
Expand All @@ -129,6 +130,7 @@ func (f normalField) Apply(b string, m Map) {
// dissect: %{} %{key}
// message: hello world
// result:
//
// key: world
type skipField struct {
baseField
Expand All @@ -147,6 +149,7 @@ func (f skipField) IsSaveable() bool {
// dissect: %{?key} %{&key}
// message: hello world
// result:
//
// hello: world
//
// Deprecated: see pointerField
Expand Down Expand Up @@ -182,6 +185,7 @@ func (f pointerField) IsSaveable() bool {
// dissect: %{?key} %{&key}
// message: hello world
// result:
//
// hello: world
type indirectField struct {
baseField
Expand All @@ -201,11 +205,13 @@ func (f indirectField) Apply(b string, m Map) {
// dissect: %{+key} %{+key}
// message: hello world
// result:
//
// key: hello world
//
// dissect: %{+key/2} %{+key/1}
// message: hello world
// result:
//
// key: world hello
type appendField struct {
baseField
Expand Down
8 changes: 4 additions & 4 deletions safemapstr/safemapstr.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ const alternativeKey = "value"
// Put This method implements a way to put dotted keys into a M while
// ensuring they don't override each other. For example:
//
// a := M{}
// safemapstr.Put(a, "com.docker.swarm.task", "x")
// safemapstr.Put(a, "com.docker.swarm.task.id", 1)
// safemapstr.Put(a, "com.docker.swarm.task.name", "foobar")
// a := M{}
// safemapstr.Put(a, "com.docker.swarm.task", "x")
// safemapstr.Put(a, "com.docker.swarm.task.id", 1)
// safemapstr.Put(a, "com.docker.swarm.task.name", "foobar")
//
// Will result in `{"com":{"docker":{"swarm":{"task":{"id":1,"name":"foobar","value":"x"}}}}}`
//
Expand Down
11 changes: 6 additions & 5 deletions transform/typeconv/typeconv.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,12 @@
// Go structures can influence the transformation via tags using the `struct` namespace.
// If the tag is missing, the structs field names are used. Additional options are separates by `,`.
// options:
// `squash`, `inline`: The fields in the child struct/map are assumed to be inlined, without reporting a sub-oject.
// `omitempty`: The field is not converted if it is "empty". For example an
// empty string, array or `nil` pointers are assumed to be empty. In either case the original value
// in `to` will not be overwritten.
// `omit`, `-`: Do not convert the field.
//
// `squash`, `inline`: The fields in the child struct/map are assumed to be inlined, without reporting a sub-oject.
// `omitempty`: The field is not converted if it is "empty". For example an
// empty string, array or `nil` pointers are assumed to be empty. In either case the original value
// in `to` will not be overwritten.
// `omit`, `-`: Do not convert the field.
func Convert(to, from interface{}) (err error) {
c, _ := convPool.Get().(*Converter)
defer convPool.Put(c)
Expand Down Expand Up @@ -177,7 +178,7 @@
}

func (u *timeUnfolder) OnInt(ctx gotype.UnfoldCtx, in int64) error {
return u.OnUint(ctx, uint64(in))

Check failure on line 181 in transform/typeconv/typeconv.go

View workflow job for this annotation

GitHub Actions / lint (ubuntu-latest)

G115: integer overflow conversion int64 -> uint64 (gosec)
}
func (u *timeUnfolder) OnFloat(ctx gotype.UnfoldCtx, f float64) error {
return u.OnUint(ctx, uint64(f))
Expand Down Expand Up @@ -230,13 +231,13 @@
if offset < -32768 || offset == -1 || offset > 32767 {
offset = 0 // Note: best effort. Ignore offset if it becomes an unexpected value
}
off = int16(offset)

Check failure on line 234 in transform/typeconv/typeconv.go

View workflow job for this annotation

GitHub Actions / lint (ubuntu-latest)

G115: integer overflow conversion int -> int16 (gosec)
}

sec := uint64(ts.Unix())

Check failure on line 237 in transform/typeconv/typeconv.go

View workflow job for this annotation

GitHub Actions / lint (ubuntu-latest)

G115: integer overflow conversion int64 -> uint64 (gosec)
extra := (uint64(encodingVersion) << 56) |
(uint64(uint16(off)) << 32) |

Check failure on line 239 in transform/typeconv/typeconv.go

View workflow job for this annotation

GitHub Actions / lint (ubuntu-latest)

G115: integer overflow conversion int16 -> uint16 (gosec)
uint64(ts.Nanosecond())

Check failure on line 240 in transform/typeconv/typeconv.go

View workflow job for this annotation

GitHub Actions / lint (ubuntu-latest)

G115: integer overflow conversion int -> uint64 (gosec)

return extra, sec
}
Expand All @@ -249,9 +250,9 @@
return ts, fmt.Errorf("invalid timestamp [%x, %x]", extra, sec)
}

nsec := uint32(extra)

Check failure on line 253 in transform/typeconv/typeconv.go

View workflow job for this annotation

GitHub Actions / lint (ubuntu-latest)

G115: integer overflow conversion uint64 -> uint32 (gosec)
off := int16(extra >> 32)

Check failure on line 254 in transform/typeconv/typeconv.go

View workflow job for this annotation

GitHub Actions / lint (ubuntu-latest)

G115: integer overflow conversion uint64 -> int16 (gosec)
ts = time.Unix(int64(sec), int64(nsec))

Check failure on line 255 in transform/typeconv/typeconv.go

View workflow job for this annotation

GitHub Actions / lint (ubuntu-latest)

G115: integer overflow conversion uint64 -> int64 (gosec)

// adjust location by offset. time.Unix creates a timestamp in the local zone
// by default. Only change this if off does not match the local zone it's offset.
Expand All @@ -259,7 +260,7 @@
ts = ts.UTC()
} else if off != 0 {
_, locOff := ts.Zone()
if off != int16(locOff/60) {

Check failure on line 263 in transform/typeconv/typeconv.go

View workflow job for this annotation

GitHub Actions / lint (ubuntu-latest)

G115: integer overflow conversion int -> int16 (gosec)
ts = ts.In(time.FixedZone("", int(off*60)))
}
}
Expand Down
3 changes: 2 additions & 1 deletion transport/httpcommon/diag_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@ import (
"testing"
"time"

"github.com/elastic/elastic-agent-libs/transport/tlscommon"
"github.com/stretchr/testify/require"

"github.com/elastic/elastic-agent-libs/transport/tlscommon"
)

var ser int64 = 1
Expand Down
3 changes: 2 additions & 1 deletion transport/tlscommon/tls_fips_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@ import (
"path/filepath"
"testing"

"github.com/elastic/elastic-agent-libs/logp/logptest"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/elastic/elastic-agent-libs/logp/logptest"
)

// TestFIPSCertifacteAndKeys tests that encrypted private keys fail in FIPS mode
Expand Down
3 changes: 2 additions & 1 deletion transport/tlscommon/tls_nofips_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@ import (
"path/filepath"
"testing"

"github.com/elastic/elastic-agent-libs/logp/logptest"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/elastic/elastic-agent-libs/logp/logptest"
)

// TestNoFIPSCertificateAndKeys tests that encrypted private keys are supported in none FIPS mode
Expand Down
Loading