config: reject a data_dir equal to or inside the cache_dir #42

Manually merged
github merged 1 commit from gh-pr/42/head into gh-pr/42/base 2026-11-26 03:42:21 +00:00
Owner

@⁠LouisRiverstone on GitHub · 2026-11-25 20:14 UTC · original
LouisRiverstone:fix/data-dir-inside-cache → main · +48 −1 · 2 files · 1 commits · merged 2026-11-25 20:33 UTC

Closes #38

Why

Config::resolve accepted a data_dir equal to or inside cache_dir. Clearing the cache would then wipe persistent title data.

What changed

  • policy::is_within(path, root): compares resolved paths (symlinks, .., not-yet-existing tails) by whole components, reusing the existing resolve.
  • Config::resolve bails when data_dir is within cache_dir.
  • The reverse (cache_dir inside data_dir) stays allowed: clearing the cache cannot touch the rest of the data.

Verify

cargo test -p victory-core: 14 pass, including new cases for equal, nested, a/../data, sibling cache-old, and cache-inside-data. Clippy and fmt clean.

Note: the author of #38 mentioned a local branch; happy to close this in favor of theirs if they prefer.

🤖 Generated with Claude Code

**@⁠LouisRiverstone** on GitHub · 2026-11-25 20:14 UTC · [original](https://github.com/uiliannn/VItoriaBr/pull/42) `LouisRiverstone:fix/data-dir-inside-cache` → `main` · +48 −1 · 2 files · 1 commits · merged 2026-11-25 20:33 UTC Closes #38 ## Why `Config::resolve` accepted a `data_dir` equal to or inside `cache_dir`. Clearing the cache would then wipe persistent title data. ## What changed - `policy::is_within(path, root)`: compares resolved paths (symlinks, `..`, not-yet-existing tails) by whole components, reusing the existing `resolve`. - `Config::resolve` bails when `data_dir` is within `cache_dir`. - The reverse (`cache_dir` inside `data_dir`) stays allowed: clearing the cache cannot touch the rest of the data. ## Verify `cargo test -p victory-core`: 14 pass, including new cases for equal, nested, `a/../data`, sibling `cache-old`, and cache-inside-data. Clippy and fmt clean. Note: the author of #38 mentioned a local branch; happy to close this in favor of theirs if they prefer. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
The cache may be deleted at any time, so persistent data must not live in it.
The reverse (cache inside data) stays allowed. Paths are compared by resolved
components, so cache-old is not inside cache.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:42:17 +00:00
github manually merged commit c7cf0baafc into gh-pr/42/base 2026-11-26 03:42:21 +00:00
Author
Owner

@⁠Djei365 on GitHub · 2026-11-25 20:33 UTC · original

Fala, Louis! Obrigado pela contribuição e pela consideração em relação à minha branch.

Eu também já implementei uma solução local para a issue #38, atualmente com 19 testes passando, incluindo cenários de caminhos relativos, diretórios inexistentes, diferenças de capitalização no Windows, Unicode e junctions.

Estou finalizando uma revisão independente da implementação para evitar regressões na política existente de proteção do repositório.

Acho que podemos alinhar nossas abordagens e aproveitar os pontos positivos de ambas as implementações, evitando trabalho duplicado.

Não precisa fechar seu PR por enquanto. Podemos aguardar também a orientação dos mantenedores sobre qual abordagem seguir.

**@⁠Djei365** on GitHub · 2026-11-25 20:33 UTC · [original](https://github.com/uiliannn/VItoriaBr/pull/42#issuecomment-7173857472) Fala, Louis! Obrigado pela contribuição e pela consideração em relação à minha branch. Eu também já implementei uma solução local para a issue #38, atualmente com 19 testes passando, incluindo cenários de caminhos relativos, diretórios inexistentes, diferenças de capitalização no Windows, Unicode e junctions. Estou finalizando uma revisão independente da implementação para evitar regressões na política existente de proteção do repositório. Acho que podemos alinhar nossas abordagens e aproveitar os pontos positivos de ambas as implementações, evitando trabalho duplicado. Não precisa fechar seu PR por enquanto. Podemos aguardar também a orientação dos mantenedores sobre qual abordagem seguir.
This discussion has been locked. Commenting is limited to contributors.
No description provided.