Skip to content

fix(repository): validate request remotes before cache access (BUG-001) - #296

Open
sbalabanov wants to merge 1 commit into
mainfrom
sbalabanov/bug-001
Open

fix(repository): validate request remotes before cache access (BUG-001)#296
sbalabanov wants to merge 1 commit into
mainfrom
sbalabanov/bug-001

Conversation

@sbalabanov

@sbalabanov sbalabanov commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Require every repository to define a trusted repository_id that uniquely identifies it across Tango installations.
  • Reject client remotes that do not exactly match a configured repository before cache or workspace access, and include the offending remote in mismatch errors.
  • Use repository_id consistently for metric labels, cache-key namespaces, origin clones, and worker directories.

BUG-001 use case

With remote: "https://github.com/uber/tango.git" and repository_id: "tango", a client request for ../../outside does not match the configured remote and is rejected before any cache lookup or workspace lease. Valid requests use the configured tango namespace instead of deriving paths or cache keys from client input.

Test Plan

  • go test -count=1 ./config ./internal/url ./controller ./core/repomanager ./orchestrator
  • ./tools/bazel test //config:config_test //internal/url:url_test //controller:controller_test //core/repomanager:repomanager_test //orchestrator:orchestrator_test --nocache_test_results --test_output=errors
  • aifx verify --timeout 15 --overall-timeout 30

Revert Plan

Revert the commit.

Issues

T3-BUG-001

@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@sbalabanov
sbalabanov marked this pull request as ready for review August 26, 2026 18:32
@sbalabanov
sbalabanov requested review from a team as code owners August 26, 2026 18:32
@sbalabanov
sbalabanov marked this pull request as draft August 26, 2026 19:17
@sbalabanov sbalabanov changed the title fix(repository): hash canonical remotes for BUG-001 fix(repository): validate configured remotes before cache access Aug 27, 2026
@sbalabanov sbalabanov changed the title fix(repository): validate configured remotes before cache access fix(repository): validate configured remotes before cache access (BUG-001) Aug 27, 2026
@sbalabanov

Copy link
Copy Markdown
Contributor Author

make a PR description relevant to the diff between the latest change and a base revision. Simplify wording. Include use case example showing the bug.

Comment thread core/bazel/query.go Outdated
Comment thread config/config.go Outdated
Comment thread core/repomanager/repo_manager_test.go Outdated
Comment thread internal/url/url.go Outdated
@sbalabanov

Copy link
Copy Markdown
Contributor Author

Updated the PR description for the current diff in 2f5946b. It now uses simpler wording and includes a concrete example where GitHub and GitLab remotes with the same repository path previously collided in cache and workspace namespaces.

[addressed by agent]

@sbalabanov

Copy link
Copy Markdown
Contributor Author

Updated the PR description for the current diff against main and added a concrete BUG-001 example showing an unconfigured relative remote being rejected before cache or workspace access. Final SHA: 2f5946b.

[addressed by agent]

Comment thread config/config_test.go Outdated
Comment thread core/repomanager/repo_manager.go Outdated
@sbalabanov
sbalabanov force-pushed the sbalabanov/bug-001 branch 2 times, most recently from 5c1c266 to 3fc3300 Compare August 28, 2026 20:47

@sbalabanov sbalabanov left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Refactor and simplify implementation. Do not validate configuration remotes. Before making a cache request, validate that remote from the client matches one of the configured remotes. For metrics, infer a safe readable name from the full remote name. For folder / cache key names, use a format of safely inferred name + digest of important parts. Such repository configuration could be made when configuration is loaded so we do not infer these settings on each request.

Comment thread internal/url/url.go Outdated
@sbalabanov sbalabanov changed the title fix(repository): validate configured remotes before cache access (BUG-001) fix(repository): validate request remotes before cache access (BUG-001) Aug 28, 2026
@sbalabanov

Copy link
Copy Markdown
Contributor Author

Addressed in b80d64c. Configuration loading now accepts remote syntax as-is and precomputes a bounded readable metric label plus a safe readable-name-and-digest namespace. Controller, orchestrator, and repository manager exact-match client remotes before cache or workspace access and reuse those precomputed values; credentials, query/fragment data, and unsafe path characters are excluded from derived identities.

[addressed by agent]

@sbalabanov sbalabanov left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Make repositoryID a part of repository configuration. Assume it is always safe for metrics and filesystem and cache keys. Use it in all of them. Make it a mandatory configuration value.
Check if similar configuration setting exists first, if it does, just reply with a comment and do not do changes.

Comment thread config/config_test.go Outdated
Comment thread config/config_test.go Outdated
Comment thread config/config_test.go Outdated
Comment thread controller/controller.go Outdated
Comment thread controller/gettargetgraph_test.go Outdated
@sbalabanov

Copy link
Copy Markdown
Contributor Author

Update PR description according to latest change vs base revision. Do not account for the history of changes in this PR.

@sbalabanov

Copy link
Copy Markdown
Contributor Author

Addressed review 5055212559 in 56e7da4. I searched the configuration schema and repository identity code and found no existing equivalent ID setting. Each repository now requires an operator-provided repository_id, exact client remotes are allowlisted before cache or workspace access, and the configured ID is used for metrics, cache keys, origin clones, and worker directories; URL inference and hashing were removed.

[addressed by agent]

@sbalabanov

Copy link
Copy Markdown
Contributor Author

Updated the PR description for final SHA 56e7da4 using only the current diff against main. It now concisely describes the mandatory repository_id, exact remote allowlisting, namespace usage, and a concrete BUG-001 request for ../../outside that is rejected before cache or workspace access.

[addressed by agent]

Comment thread example/README.md Outdated
Comment thread controller/controller.go Outdated
Comment thread controller/gettargetgraph.go
Comment thread core/repomanager/repo_manager.go Outdated
Comment thread core/repomanager/repo_manager_test.go Outdated
Comment thread orchestrator/native_orchestrator.go Outdated
Comment thread config/config.go Outdated
Comment thread core/repomanager/repo_manager.go Outdated
Comment thread docs/observability/metrics.md Outdated
Comment thread internal/url/url.go Outdated
Comment thread orchestrator/native_orchestrator_test.go Outdated
@sbalabanov

sbalabanov commented Aug 28, 2026

Copy link
Copy Markdown
Contributor Author

Updated the PR description for final SHA fb80317 using only the current diff against main. It now describes the mandatory repository_id, exact remote allowlisting, raw remote mismatch diagnostics, namespace usage, and a concrete BUG-001 request rejected before cache or workspace access.

[addressed by agent]

@sbalabanov
sbalabanov marked this pull request as ready for review August 28, 2026 23:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants