Repository navigation
fix: resolve 9 Sonar reliability issues across 5 files - #198
Merged
Merged
Conversation
Replace ES2015-aliased built-ins and one backtracking-flagged regex. All
substitutions are behaviour-preserving, verified over the full reachable
input domain rather than spot-checked.
- navigator.ts L77/L132: isNaN -> Number.isNaN. Both call sites already
pass a number, so the coercion difference is unreachable. The branch
itself stays dead (Number('abc') || 0 is 0, never NaN) - that
pre-existing bug is documented, not fixed here, since making the 400
reachable would change behaviour.
- decode.ts L6/L9: charCodeAt/fromCharCode -> codePointAt/fromCodePoint.
Safe because L6 reads latin1 (all 256 values checked) and L9 reads
Uint16Array code units (all 65536 checked); fromCodePoint only diverges
above 0xFFFF, which a Uint16Array cannot produce.
- profile.ts L63, env.ts L184: parseInt -> Number.parseInt, which is the
same function object per spec.
- assessmentSubmitHelper.ts L167: /<\/?[^>]+(>|$)/g -> /<\/?[^>]+>?/g,
dropping the alternation. Sonar's super-linear claim did not reproduce
under six adversarial input shapes, so this closes the issue with an
identical regex rather than delivering a measurable speedup. Equivalence
proven exhaustively over all 335,922 strings of length <= 7 from the
matching-relevant alphabet.
tsc, lint and build clean; dist output confirmed to carry all five changes.
Full Jest suite passes (224 suites, 3693 tests).
Closes the 4 open Sonar security issues. ES_PASSWORD, USER_CREATE_PASSWORD, DISCUSSION_HUB_DEFAULT_PASSWORD and DISCUSSION_HUB_WRITE_API_KEY had real, live credentials as literal fallbacks, feeding actual auth paths in infyradio.ts, topic.ts, contentHelpers.ts, googleSignInRoutes.ts, user/details.ts and user/admin-users.ts. Each now resolves as env.X || localDefaults.X || '', reusing the gitignored env.local-defaults.json mechanism this repo already established for the clear-text-protocol hotspot rather than adding a second convention. The tracked .example.json gains placeholder entries only. Safe to deploy: the tracked env-file sets none of these four vars, env vars still take priority, and with neither env var nor local file present the module loads without throwing and the credentials resolve to ''. An empty credential fails auth with an attributable error instead of silently authenticating with a password that is public in git history. NOTIFICATION_ENGINE_SOCKET_URL (the L148 http hotspot) is handled differently on purpose: it is an internal service hostname, not a credential, so it moves to a named constant with the runtime value unchanged. It keeps a literal fallback because server.ts passes it into ClientSocket(), and ClientSocket(undefined) silently connects to the process origin rather than failing - a misroute instead of a clear error. Not included: fail-fast startup validation, which would turn a missing secret into a boot crash and needs its own reviewed change. Rotation still required - these values are in history since cf5127a (2021-06-24), so removing them stops future exposure but does not un-leak them. See docs/PROD-VERIFICATION.md CHANGE 50. tsc, lint and build clean. Full Jest suite passes (224 suites, 3693 tests).
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.
Replace ES2015-aliased built-ins and one backtracking-flagged regex. All substitutions are behaviour-preserving, verified over the full reachable input domain rather than spot-checked.
tsc, lint and build clean; dist output confirmed to carry all five changes. Full Jest suite passes (224 suites, 3693 tests).