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

Merged
LouisRiverstone merged 1 commit from upstream-pr/42 into main 2026-11-25 20:33:12 +00:00
LouisRiverstone commented 2026-11-25 20:14:21 +00:00 (Migrated from github.com)

Imported from uiliannn/VItoriaBr. Originally posted by LouisRiverstone on 2026-11-25T20:14:21Z.


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

<!-- greyfinch-sync:uiliannn/VItoriaBr:issue:6612874258 --> Imported from [uiliannn/VItoriaBr](https://github.com/uiliannn/VItoriaBr/pull/42). Originally posted by [LouisRiverstone](https://github.com/LouisRiverstone) on 2026-11-25T20:14:21Z. --- 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)
Djei365 commented 2026-11-25 20:33:51 +00:00 (Migrated from github.com)

Imported from uiliannn/VItoriaBr. Originally posted by Djei365 on 2026-11-25T20:33:51Z.


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.

<!-- greyfinch-sync:uiliannn/VItoriaBr:comment:7173857472 --> Imported from [uiliannn/VItoriaBr](https://github.com/uiliannn/VItoriaBr/pull/42#issuecomment-7173857472). Originally posted by [Djei365](https://github.com/Djei365) on 2026-11-25T20:33:51Z. --- 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.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
uiliannn/VItoriaBr!42
No description provided.