Repository navigation
gitcache: save only the job's own repository - #220
Merged
Merged
Conversation
With git_cache, a trusted job on one repository that fetched another private one (a second checkout, a submodule) stored that pack under its own repository and default ref. A fork PR, which may read the default branch's caches, could then restore it straight from cache-server with the "git/" prefix, without that repository's credentials. Git cache keys now name their repository in clear, "git/<owner>/<name>/<hash>". cache-server refuses to save a git entry whose key names another repository than the job's, and never returns a git entry that does not name the job's own, so entries saved in the old format are not restored either. Signed-off-by: Yi-Ru Lin <deduce@gmail.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.
With
git_cache, a trusted job on one repository that fetched another private repository (a second checkout, a submodule) stored that pack under its own repository and default ref. A fork PR may read the default branch's caches, so it could restore that pack straight from cache-server with thegit/prefix, without the other repository's credentials.Changes:
git/<owner>/<name>/<hash>.gitcache.KeyRepositoryparses them, andgitcache.EntryVersionis the git entry version.Tests:
internal/cacheserver/gitentry_test.gocovers which saves are accepted or refused, and that an old-format entry is not restored by a prefix lookup.internal/gitproxy/cache_test.gouses real keys and adds a cross-repository save test.internal/gitcachehas aKeyRepositorytable.scripts/mutate.shconfirmed that both the save rule and the lookup filter are caught.Review: a fresh reviewer agent reviewed the change. It confirmed that case,
%2F,..and redirects cannot get another repository saved under the job's scope. Its should-fix, that old entries were still readable by a direct client, is fixed here. Its test nits are also addressed.