Fix SSH billing count read for values beginning with '4'#32015
Open
danilobuerger wants to merge 1 commit into
Open
Fix SSH billing count read for values beginning with '4'#32015danilobuerger wants to merge 1 commit into
danilobuerger wants to merge 1 commit into
Conversation
The monthly SSH duration-adjusted certificate count and SSH OTP count were written to storage as plain JSON (jsonutil.EncodeJSON) but read back via the canary-aware jsonutil.DecodeJSON. These are not inverses: DecodeJSON treats the first stored byte as a compression canary, and the LZ4 canary is the ASCII digit '4' (0x34). Any count whose decimal representation began with '4' (e.g. 4, 4.1096, 42) was misread as LZ4 data, failing with "lz4: bad magic number" and returning a 500 from sys/billing/overview. Align the SSH counters with the existing PKI and OIDC counters, which store and read these scalar float64 values via strconv. Reads use strings.TrimSpace so values previously written as JSON (with a trailing newline) remain readable, including the '4'-leading values that the old reader could not decode. Add regression tests for the new-format round-trip and for reading the legacy JSON format. Fixes hashicorp#32013
|
Deployment failed with the following error: Learn More: https://vercel.com/docs/concepts/projects/project-configuration |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The monthly SSH duration-adjusted certificate count and SSH OTP count were written to storage as plain JSON (jsonutil.EncodeJSON) but read back via the canary-aware jsonutil.DecodeJSON. These are not inverses: DecodeJSON treats the first stored byte as a compression canary, and the LZ4 canary is the ASCII digit '4' (0x34). Any count whose decimal representation began with '4' (e.g. 4, 4.1096, 42) was misread as LZ4 data, failing with "lz4: bad magic number" and returning a 500 from sys/billing/overview.
Align the SSH counters with the existing PKI and OIDC counters, which store and read these scalar float64 values via strconv. Reads use strings.TrimSpace so values previously written as JSON (with a trailing newline) remain readable, including the '4'-leading values that the old reader could not decode.
Add regression tests for the new-format round-trip and for reading the legacy JSON format.
Fixes #32013
Description
What does this PR do?
TODO only if you're a HashiCorp employee
backport/label that matches the desired release branch.PCI review checklist
Examples of changes to security controls include using new access control methods, adding or removing logging pipelines, etc.