diff --git a/libbeat/common/capabilities/capabilities_linux.go b/libbeat/common/capabilities/capabilities_linux.go index 59cf21920e1..715b86d9bc7 100644 --- a/libbeat/common/capabilities/capabilities_linux.go +++ b/libbeat/common/capabilities/capabilities_linux.go @@ -31,11 +31,6 @@ import ( var ( // errInvalidCapability expresses an invalid capability ID: x < 0 || x >= 64. errInvalidCapability = errors.New("invalid capability") - - // ErrUnsupported is returned for all public functions on "not - // linux". There is a generic errors.ErrUnsupported present in - // golang 1.21, but we still support 1.20. - ErrUnsupported = errors.New("capabilities are only supported in linux") ) // The capability set flag/vector, re-exported from @@ -53,7 +48,7 @@ const ( // Fetch the capabilities of pid for a given flag/vector and convert // it to the representation used in ECS. cap.GetPID() fetches it with // SYS_CAPGET. -// Returns ErrUnsupported on "not linux". +// Returns errors.ErrUnsupported on "not linux". func FromPid(flag Flag, pid int) ([]string, error) { set, err := cap.GetPID(pid) if err != nil { @@ -89,7 +84,7 @@ func FromPid(flag Flag, pid int) ([]string, error) { } // Convert a uint64 to the capabilities representation used in ECS. -// Returns ErrUnsupported on "not linux". +// Returns errors.ErrUnsupported on "not linux". func FromUint64(w uint64) ([]string, error) { sl := make([]string, 0, bits.OnesCount64(w)) for i := 0; w != 0; i++ { @@ -109,7 +104,7 @@ func FromUint64(w uint64) ([]string, error) { // Convert a string to the capabilities representation used in // ECS. Example input: "1ffffffffff", 16. -// Returns ErrUnsupported on "not linux". +// Returns errors.ErrUnsupported on "not linux". func FromString(s string, base int) ([]string, error) { w, err := strconv.ParseUint(s, 16, 64) if err != nil { diff --git a/libbeat/common/capabilities/capabilities_other.go b/libbeat/common/capabilities/capabilities_other.go index 55b494c4497..fbd7e879772 100644 --- a/libbeat/common/capabilities/capabilities_other.go +++ b/libbeat/common/capabilities/capabilities_other.go @@ -21,9 +21,6 @@ package capabilities import "errors" -// ErrUnsupported is returned for all public functions on "not linux". -var ErrUnsupported = errors.New("capabilities are only supported in linux") - // Dummy value on "not linux". type Flag = uint @@ -34,17 +31,17 @@ const ( Permitted = Flag(1) ) -// ErrUnsupported on "not linux". +// Returns errors.ErrUnsupported on "not linux". func FromPid(flag Flag, pid int) ([]string, error) { - return nil, ErrUnsupported + return nil, errors.ErrUnsupported } -// ErrUnsupported on "not linux". +// Returns errors.ErrUnsupported on "not linux". func FromUint64(w uint64) ([]string, error) { - return nil, ErrUnsupported + return nil, errors.ErrUnsupported } -// ErrUnsupported on "not linux". +// Returns errors.ErrUnsupported on "not linux". func FromString(s string, base int) ([]string, error) { - return nil, ErrUnsupported + return nil, errors.ErrUnsupported } diff --git a/x-pack/auditbeat/module/system/process/process.go b/x-pack/auditbeat/module/system/process/process.go index c389476615b..fca218eec41 100644 --- a/x-pack/auditbeat/module/system/process/process.go +++ b/x-pack/auditbeat/module/system/process/process.go @@ -500,11 +500,11 @@ func (ms *MetricSet) getProcesses() ([]*Process, error) { } process.CapEffective, err = capabilities.FromPid(capabilities.Effective, pInfo.PID) - if err != nil && !errors.Is(err, capabilities.ErrUnsupported) && process.Error == nil { + if err != nil && !errors.Is(err, errors.ErrUnsupported) && process.Error == nil { process.Error = err } process.CapPermitted, err = capabilities.FromPid(capabilities.Permitted, pInfo.PID) - if err != nil && !errors.Is(err, capabilities.ErrUnsupported) && process.Error == nil { + if err != nil && !errors.Is(err, errors.ErrUnsupported) && process.Error == nil { process.Error = err } // Exclude Linux kernel processes, they are not very interesting.