Clear all 4 CodeQL alerts (insecure randomness + unanchored regexes)#30
Merged
Conversation
- session id: drop the Math.random() v4-UUID fallback (js/insecure-randomness). Prefer crypto.randomUUID, then crypto.getRandomValues (secure, near-universal support); only a non-random monotonic id remains for the rare runtime with no Web Crypto at all. The session id is UX telemetry, not a security token. - e2e: anchor the jsonplaceholder waitForResponse regexes (^https://jsonplaceholder.typicode.com/) so they cannot match the host as a substring elsewhere in a URL (js/regex/missing-regexp-anchor x3).
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.
Resolves the 4 open high-severity CodeQL alerts on
main.#1
js/insecure-randomness—packages/core/src/session.tsThe v4-UUID fallback used
Math.random()whencrypto.randomUUIDwas unavailable. Replaced with acrypto.getRandomValues-based UUID (cryptographically secure, andgetRandomValueshas much wider runtime support thanrandomUUID).Math.randomis gone; a non-random monotonic id (bs-<ts>-<n>) remains only as a last resort for runtimes with no Web Crypto at all. (The session id is a UX-telemetry marker, not a security token — but there's no reason to leave weak randomness in.)#2-4
js/regex/missing-regexp-anchor—e2e/tests/{next,react,vue}.spec.tspage.waitForResponse(/jsonplaceholder\.typicode\.com/)was unanchored, so it could match the host appearing anywhere in a URL. Anchored to/^https:\/\/jsonplaceholder\.typicode\.com\//. Test-only, but it clears the alerts cleanly.tsc --noEmitclean; all 62 core unit tests pass.