diff --git a/go.mod b/go.mod index ae985b17..efa3bba2 100644 --- a/go.mod +++ b/go.mod @@ -10,7 +10,7 @@ module github.com/atc0005/check-vmware go 1.22 require ( - github.com/atc0005/go-nagios v0.17.0-rc.1 + github.com/atc0005/go-nagios v0.17.1 github.com/google/go-cmp v0.6.0 github.com/rs/zerolog v1.33.0 github.com/vmware/govmomi v0.45.1 diff --git a/go.sum b/go.sum index d3bb09f4..d489d2db 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,5 @@ -github.com/atc0005/go-nagios v0.17.0-rc.1 h1:fyYmetY4RUJxM0GN1KdoTu+Ywq0qbF5MJ9nCgpDs4mI= -github.com/atc0005/go-nagios v0.17.0-rc.1/go.mod h1:n2RHhsrgI8xiapqkJ240dKLwMXWbWvkOPLE92x0IGaM= +github.com/atc0005/go-nagios v0.17.1 h1:VdI70UPm7WuAZWePBuuJETdX0maFX3evylSzDoTtkxc= +github.com/atc0005/go-nagios v0.17.1/go.mod h1:n2RHhsrgI8xiapqkJ240dKLwMXWbWvkOPLE92x0IGaM= github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= diff --git a/vendor/github.com/atc0005/go-nagios/CHANGELOG.md b/vendor/github.com/atc0005/go-nagios/CHANGELOG.md index 98a2762a..51ac9d14 100644 --- a/vendor/github.com/atc0005/go-nagios/CHANGELOG.md +++ b/vendor/github.com/atc0005/go-nagios/CHANGELOG.md @@ -26,6 +26,30 @@ The following types of changes will be recorded in this file: - placeholder +## [v0.17.1] - 2024-11-08 + +### Changed + +- (GH-296) Unescape encoded Ascii85 payload before decoding + +## [v0.17.0] - 2024-11-06 + +### Added + +- (GH-288) Add support for embedded/encoded payloads +- (GH-289) Add support for (internal) debug logging output + +### Changed + +- (GH-291) Clarify handling of empty payload input +- (GH-292) Enable LongServiceOutput header/label for payloads + +### Fixed + +- (GH-268) Fix `Plugin.SetOutputTarget` method +- (GH-273) Fix test case validity check +- (GH-290) Minor refactoring of Range and Thresholds support + ## [v0.16.2] - 2024-10-10 ### Changed @@ -543,7 +567,9 @@ Initial package state - Nagios state map -[Unreleased]: https://github.com/atc0005/go-nagios/compare/v0.16.2...HEAD +[Unreleased]: https://github.com/atc0005/go-nagios/compare/v0.17.1...HEAD +[v0.17.1]: https://github.com/atc0005/go-nagios/releases/tag/v0.17.1 +[v0.17.0]: https://github.com/atc0005/go-nagios/releases/tag/v0.17.0 [v0.16.2]: https://github.com/atc0005/go-nagios/releases/tag/v0.16.2 [v0.16.1]: https://github.com/atc0005/go-nagios/releases/tag/v0.16.1 [v0.16.0]: https://github.com/atc0005/go-nagios/releases/tag/v0.16.0 diff --git a/vendor/github.com/atc0005/go-nagios/payload.go b/vendor/github.com/atc0005/go-nagios/payload.go index b09aa9e8..f11cd844 100644 --- a/vendor/github.com/atc0005/go-nagios/payload.go +++ b/vendor/github.com/atc0005/go-nagios/payload.go @@ -57,13 +57,31 @@ func EncodeASCII85Payload(data []byte, leftDelimiter string, rightDelimiter stri return leftDelimiter + string(encoded) + rightDelimiter } +// unescapeASCII85 unescapes an Ascii85 input payload by removing escape +// patterns added to the payload as it passes through a monitoring system +// (e.g., for inclusion in a JSON API response). +func unescapeASCII85(encodedInput []byte) ([]byte, error) { + if len(encodedInput) == 0 { + return nil, fmt.Errorf( + "failed to unescape empty payload: %w", + ErrMissingValue, + ) + } + + // Based on initial testing this is sufficient to unescape an Ascii85 + // payload that passes through the Nagios XI API. + encodedInput = bytes.ReplaceAll(encodedInput, []byte(`\\`), []byte(`\`)) + + return encodedInput, nil +} + // decodeASCII85 decodes given Ascii85 encoded input or an error if one occurs // during decoding. // // The caller is expected to remove any delimiters from the input before // calling this function. // -// This function is also not intended for extraction of an Ascii encoded +// This function is also not intended for extraction of an Ascii85 encoded // payload from surrounding text. func decodeASCII85(encodedInput []byte) ([]byte, error) { if len(encodedInput) == 0 { @@ -73,10 +91,15 @@ func decodeASCII85(encodedInput []byte) ([]byte, error) { ) } - decoded := make([]byte, len(encodedInput)) - n, _, err := ascii85.Decode(decoded, encodedInput, true) - if err != nil { - return nil, err + unescapedInput, unescapeErr := unescapeASCII85(encodedInput) + if unescapeErr != nil { + return nil, unescapeErr + } + + decoded := make([]byte, len(unescapedInput)) + n, _, decodeErr := ascii85.Decode(decoded, unescapedInput, true) + if decodeErr != nil { + return nil, decodeErr } decodedBytes := decoded[:n] @@ -94,7 +117,7 @@ func decodeASCII85(encodedInput []byte) ([]byte, error) { // occurs during decoding. If provided, the left and right delimiters are // trimmed from the given input before decoding is performed. // -// This function is not intended to extract an Ascii encoded payload from +// This function is not intended to extract an Ascii85 encoded payload from // surrounding text. func DecodeASCII85Payload(encodedInput []byte, leftDelimiter string, rightDelimiter string) ([]byte, error) { if len(encodedInput) == 0 { diff --git a/vendor/modules.txt b/vendor/modules.txt index 8ea19b57..8214d143 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -1,4 +1,4 @@ -# github.com/atc0005/go-nagios v0.17.0-rc.1 +# github.com/atc0005/go-nagios v0.17.1 ## explicit; go 1.19 github.com/atc0005/go-nagios # github.com/google/go-cmp v0.6.0