chore: compartmentalized sandbox config directory#288
Merged
Conversation
Centralize config directory resolution into a single `daft_config_dir()` function in `src/lib.rs`. When `DAFT_CONFIG_DIR` is set to a non-empty absolute path, all state files (trust DB, hints, caches) use that directory instead of `~/.config/daft/`. - Add non-suppressible security warning to stderr when override is active - Reject relative paths with a clear error - Update sandbox `.envrc` to set `DAFT_CONFIG_DIR`, `DAFT_NO_UPDATE_CHECK`, and `DAFT_NO_TRUST_PRUNE` for full dev isolation - Migrate all 6 call sites from independent `dirs::config_dir()` calls - Update help text to avoid hardcoded `~/.config/daft/` path references Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Release builds (tagged commits, DAFT_BUILD_RELEASE=1, crates.io installs) now ignore DAFT_CONFIG_DIR entirely, preventing trust database hijacking via environment variable injection in production. Dev builds (local git checkout without a release tag) continue to honor the env var for sandbox isolation. - Add `daft_dev_build` cfg flag emitted by build.rs - Gate env var check and startup warning behind `cfg!(daft_dev_build)` - Register custom cfg in Cargo.toml to satisfy `unexpected_cfgs` lint Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.
Summary
DAFT_CONFIG_DIRenv var that redirects all daft state files (trust DB, hints, update cache) to a custom directory, isolating the dev sandbox from the user's real configdaft_config_dir()function, replacing 6 independentdirs::config_dir()calls.envrcgeneration to setDAFT_CONFIG_DIR,DAFT_NO_UPDATE_CHECK, andDAFT_NO_TRUST_PRUNEfor full dev isolationTest plan
mise run fmt— cleanmise run clippy— zero warningsmise run test:unit— 461 tests pass (including 5 new tests fordaft_config_dir())mise run man:verify— man pages up-to-dateDAFT_CONFIG_DIR=/tmp/test daft hooks listuses sandboxed config in dev buildmise run sandboxcreates.envrcwithDAFT_CONFIG_DIRsetDAFT_CONFIG_DIR🤖 Generated with Claude Code