fix: correct base64 fallback decoding and use crypto random for padding#68
Open
drago1520 wants to merge 1 commit intodraphy:masterfrom
Open
fix: correct base64 fallback decoding and use crypto random for padding#68drago1520 wants to merge 1 commit intodraphy:masterfrom
drago1520 wants to merge 1 commit intodraphy:masterfrom
Conversation
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.
What changed
Three small hardening changes in
@pushforge/builder:Math.random()padding-size selection with crypto RNG.1. Base64 decode fix
File:
Old Node fallback did this:
Problem:
Bufferis often view into larger backingArrayBuffer..bufferreturns whole backing memory, not exact decoded bytes.So caller could get wrong
ArrayBuffer.byteLength.New code slices exact region:
Also tightened runtime checks:
typeof globalThis.atob === 'function'typeof globalThis.btoa === 'function'This avoids entering browser path when property exists but is not callable.
2. Regression tests
File:
Added tests for:
These tests protect against future regressions in base64 decode behavior.
3. Crypto RNG for padding size
File:
Old code used:
New code uses:
Why:
Verification
Ran locally:
pnpm build pnpm -C packages/builder exec vitest run test/unit.test.tsResults:
48/48