Repository navigation
fix(vcs): bind GitHub repository links to their installation - #14975
Conversation
Verify on connect that the repository belongs to the installation's owner for installation-scoped providers, and match push and pull request webhooks only against repositories linked through the event's installation.
|
Review complete. 🟡 1 medium 📍 Findings outside the diff (1) — 🟡 1 medium — defects on lines GitHub can't attach comments to🟡 Medium — Reconnect path skips repository ownership validation · Update.php:285–297 · // src/Appwrite/Platform/Modules/Functions/Http/Functions/Update.php
285 if ($isConnected && !empty($providerRepositoryId) && !empty($repositoryId) && !$installation->isEmpty()) {
286 $repository = $dbForPlatform->getDocument('repositories', $repositoryId);
287 if (
288 !$repository->isEmpty()
289 && $repository->getAttribute('providerRepositoryId') === $providerRepositoryId
290 && $repository->getAttribute('installationInternalId') !== $installation->getSequence()
291 ) {
292 $dbForPlatform->updateDocument('repositories', $repository->getId(), new Document([
293 'installationId' => $installation->getId(),
294 'installationInternalId' => $installation->getSequence(),
295 ]));
296 }The new 🧹 Nitpicks (1) — 🟢 1 low
This PR introduces
Reviewed commit: aaefe1d |
🟢 Tier S · Ready to merge
Repository connections for Functions and Sites are resolved through their owning VCS installation, and GitHub webhook events are matched to links from the installation that sent them. The PR adds E2E coverage for rejecting repositories outside an installation and ignoring cross-installation pushes, along with adapter coverage for scanning beyond 1,000 repositories. Latest changes: The latest commits remove the 1,000-repository scan cap in GitHub installation lookup and add a regression test for repositories beyond that boundary and missing repositories.
📂 Walkthrough · 9
✅ Fixed since the last review · 1
Reviewed the commits since |
Security rulesNo new WARNING or ERROR findings from security rules. 6 existing findings tracked in
|
✨ Benchmark resultsComparing
Per-scenario breakdown & investigation detailsMetrics below reflect the current branch (after). Δ P95 compares against the base.
Top API waits (after)
|
|
Responses to the review:
|
The findings that requested changes are resolved. See the summary comment for what is still open.
|
@hansi-codes review |
getInstallationRepository stopped after 1,000 repositories, so a selected repository past that point was reported as not selected.
What does this PR do?
Hardens how Git repositories are bound to VCS installations for installation-scoped providers like GitHub.
provider_repository_not_foundbefore anything is saved. Until now, this lookup ran only for repository-scoped providers.resolveInstallationRepositoryinCompute\Baseis shared by the four connect paths. Those paths now pass its owner and name toRepositoryWebhooks::ensure, which already skips installation-scoped providers.Test Plan
New E2E tests in
VCSGitHubConsoleClientTest:testConnectRepositoryOutsideInstallationRejected: creating a function or site, or updating a function, with a public repository outside the installation returns 404provider_repository_not_found.testGitHubPushFromAnotherInstallationIsIgnored: a signed push for a linked repository from a different installation creates no deployment.Existing VCS tests cover legitimate links and pushes through the same installation.
Locally: Pint, PHPStan and Rector
refactor:checkpass on the changed files.Related PRs and Issues
None
Checklist