Skip to content

Fix TestHardenConfigDir on macOS: resolve TMPDIR symlinks in test dirs#536

Merged
jeremy merged 1 commit into
mainfrom
harden-test-darwin
Jul 17, 2026
Merged

Fix TestHardenConfigDir on macOS: resolve TMPDIR symlinks in test dirs#536
jeremy merged 1 commit into
mainfrom
harden-test-darwin

Conversation

@jeremy

@jeremy jeremy commented Jul 17, 2026

Copy link
Copy Markdown
Member

Problem

make test (and therefore make releaserelease-check) fails on macOS: every positive-case subtest of TestHardenConfigDir reports the dir stayed 0755 when 0700 was expected.

On darwin, t.TempDir() lives under /var → private/var. hardenConfigDir's per-component O_NOFOLLOW descent correctly refuses the symlinked ancestor and silently aborts — so the positive cases never chmod, and the negative cases pass vacuously. Linux CI never sees this because its TMPDIR has no symlinked ancestors (CI is ubuntu-only across the matrix).

Fix

Route all TestHardenConfigDir temp dirs through a hardenTempDir helper that EvalSymlinks-resolves t.TempDir() — the same thing the symlinked-final-component subtest already did inline. Test-only change; no production code touched. The production feature is unaffected for real config paths (~/.config/... has no symlinked ancestors).

Testing

  • GOWORK=off go test ./internal/cli -run 'TestHardenConfigDir|TestOwnedByUID' green on macOS (previously 6 subtests failing)
  • Full GOWORK=off make test on darwin (arm64) green
  • No behavior change on Linux — the resolved path is identical there

Context

Found while prepping the v0.8.0 release (73 commits unreleased since v0.7.2; the release is wanted for the completed-todos fix in #456, T2 card BC-9988776161). This unblocks running make release from a Mac.

https://claude.ai/code/session_01CSpm1M4ZQwmurqqNb5uQx8


Summary by cubic

Fixes macOS failures in TestHardenConfigDir by resolving symlinks in temp test dirs. This makes the hardening assertions run correctly and unblocks make release on macOS.

  • Bug Fixes
    • Added hardenTempDir(t) that EvalSymlinks the result of t.TempDir() and used it across TestHardenConfigDir subtests to avoid TMPDIR symlink ancestors.
    • Test-only change; Linux behavior unchanged; make test/release-check now pass on macOS.

Written for commit fddb1d4. Summary will update on new commits.

Review in cubic

Copilot AI review requested due to automatic review settings July 17, 2026 04:38
@github-actions github-actions Bot added the tests Tests (unit and e2e) label Jul 17, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a macOS-only unit test failure in TestHardenConfigDir by ensuring test temp directories don’t include symlinked ancestors (notably /var -> /private/var on darwin), so hardenConfigDir’s O_NOFOLLOW descent actually reaches and hardens the intended directories during positive-case assertions.

Tip

If you aren't ready for review, convert to a draft PR.
Click "Convert to draft" or run gh pr ready --undo.
Click "Ready for review" or run gh pr ready to reengage.

Changes:

  • Add a hardenTempDir(t) test helper that filepath.EvalSymlinks-resolves t.TempDir().
  • Route all TestHardenConfigDir temp-dir usage through hardenTempDir to avoid symlinked TMPDIR ancestors on macOS.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 1 file

Re-trigger cubic

On darwin, t.TempDir() lives under /var -> private/var. hardenConfigDir's
per-component O_NOFOLLOW descent correctly refuses the symlinked ancestor,
so every positive-case subtest silently no-op'd (dir stayed 0755, expected
0700) and the negative cases passed vacuously. Linux CI never sees this
because its TMPDIR has no symlinked ancestors.

Route all TestHardenConfigDir temp dirs through a hardenTempDir helper
that EvalSymlinks-resolves t.TempDir(), matching what the symlinked-final-
component subtest already did inline. No production code change; unblocks
make release (release-check -> make test) on macOS.

Claude-Session: https://claude.ai/code/session_01CSpm1M4ZQwmurqqNb5uQx8
Copilot AI review requested due to automatic review settings July 17, 2026 15:40
@jeremy
jeremy force-pushed the harden-test-darwin branch from 3db8c86 to fddb1d4 Compare July 17, 2026 15:40
@github-actions github-actions Bot added the bug Something isn't working label Jul 17, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

@jeremy
jeremy enabled auto-merge (squash) July 17, 2026 15:43
@jeremy
jeremy merged commit 6ec1a07 into main Jul 17, 2026
27 checks passed
@jeremy
jeremy deleted the harden-test-darwin branch July 17, 2026 15:44
jeremy added a commit to yigitkonur/basecamp-cli that referenced this pull request Jul 20, 2026
…e-codex-plugin

* origin/main:
  Bump SDK to d15f023f and collapse todos update onto TodosService.Edit (basecamp#543)
  Fix agent-help hidden-flag leak; make check-surface a real drift gate (basecamp#542)
  Fix todos update silently clearing completion subscribers (basecamp#540)
  Fix TestHardenConfigDir on macOS: resolve TMPDIR symlinks in test dirs (basecamp#536)
  Bump golang.org/x/net to v0.56.0 for CVE-2026-46600 (basecamp#537)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working tests Tests (unit and e2e)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants