Skip to content

fix(zsh): harden _radian_version_check against a contaminated version cache - #528

Merged
Data-Wise merged 3 commits into
devfrom
feature/radian-version-check-hardening
Sep 14, 2026
Merged

Data-Wise merged 3 commits into
devfrom
feature/radian-version-check-hardening

Conversation

@Data-Wise

Copy link
Copy Markdown
Owner

Summary

  • _radian_version_check's R-vs-radian version-drift warning compared the cached version to the current R version with no validation of either side
  • If the cache ever held radian's own version string (X.Y.Z shaped, e.g. 0.6.16 — indistinguishable from a real R version by a plain semver regex) instead of R's, the next login produced a nonsensical warning like R changed: 0.6.16 -> 4.6.1 even though nothing was actually wrong
  • Fix requires major version >= 2 on both the freshly-read R version and the cached value before comparing — R has not shipped a major version below 2 in decades, radian has never left major version 0, so this is the actual discriminator (a plain X.Y.Z shape check is not, since radian's own version matches it too)
  • A malformed or contaminated cached value is now silently ignored (and self-heals on the next write) instead of producing a false warning

Test plan

  • zsh -n zsh/.zshrc — syntax clean
  • E2E: extracted the live function, stubbed R, ran it against an isolated HOME/cache in 3 scenarios against the actual shipped code:
    • Contaminated cache (0.6.16 vs real 4.6.1) → no warning, cache self-heals to 4.6.1
    • Genuine version change (4.5.0 vs 4.6.1) → warns correctly
    • No change (4.6.1 vs 4.6.1) → silent
  • First draft of the fix (plain ^[0-9]+\.[0-9]+\.[0-9]+$ regex) was caught by this same E2E process — it still fired on the contaminated-cache case since radian's version also matches that shape — corrected to the major->=2 check before landing

🤖 Generated with Claude Code

Data-Wise and others added 3 commits September 14, 2026 16:35
Worth-it review found real value but user chose to park rather than
start now. Backlog is fully clear: 0 open issues, 0 open PRs, 2 parked
(#487, #517).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
… cache

The R-vs-radian version-drift check compared the cached value to the
current R version with no validation of either side. If the cache ever
held radian's own version string (format "0.6.16" -- indistinguishable
from a real X.Y.Z version by a plain semver regex) instead of R's, the
next login produced a nonsensical warning like "R changed: 0.6.16 ->
4.6.1" even though nothing was actually wrong.

R has not shipped a major version below 2 in decades; radian has never
left major version 0. Require major >= 2 on both the freshly-read R
version and the cached value before comparing -- a malformed or
contaminated value is now silently ignored (and self-heals on write)
instead of producing a false warning.

E2E: extracted the live function, stubbed R, and ran it against an
isolated HOME/cache in 3 scenarios -- contaminated cache (no warning,
cache self-heals), genuine version change (warns correctly), and no
change (silent). All three passed against the actual shipped code.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
The previous commit's ^[2-9][0-9]*\. regex only matched when the
LEADING digit was 2-9, so a future double-digit major like R 10.x
(leading digit 1) would be wrongly rejected as "not a real version"
despite 10 >= 2. Caught in review before merge, not by a user report.

Corrected to ^([1-9][0-9]+|[2-9])\. -- true major >= 2, single or
multi-digit. Re-ran the full E2E suite plus 2 new double-digit-major
cases (10.0.0 vs 9.9.9 must warn, 10.0.0 vs 10.0.0 must not) against
the actual shipped function; all 5 scenarios pass.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@Data-Wise
Data-Wise merged commit d1354ae into dev Sep 14, 2026
3 checks passed
@Data-Wise
Data-Wise deleted the feature/radian-version-check-hardening branch September 14, 2026 22:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant