Skip to content

fix: honour console URL scheme in VCS commit statuses and authorize link - #7

Open
anurag6569201 wants to merge 1 commit into
qa/agent-appwrite-appwrite/pr-07-13476/basefrom
qa/agent-appwrite-appwrite/pr-07-13476/head
Open

anurag6569201 wants to merge 1 commit into
qa/agent-appwrite-appwrite/pr-07-13476/basefrom
qa/agent-appwrite-appwrite/pr-07-13476/head

Conversation

@anurag6569201

Copy link
Copy Markdown

What does this PR do?

The VCS PR comment's build-log links already respected _APP_CONSOLE_URL_SCHEME, but two other links generated for the same pull request did not:

  • the commit-status target URLs (GitAction.php, and the "Starting..." status in GitHub/Deployment.php)
  • the external-contributor authorize link (GitHub/Deployment.php)

Both were hardcoded to the legacy /console/project-{region}-{projectId}/... form. On a root-scheme install that meant a single PR carried contradictory links — the comment's "View Logs" pointed at /projects/{id}/... while the commit status next to it pointed at /console/project-....

All three now branch on the same flag. GitAction also reads the hostname from the $platform config it already receives, instead of re-resolving _APP_CONSOLE_DOMAIN / _APP_DOMAIN itself.

Resulting URLs under _APP_CONSOLE_URL_SCHEME=root

Link Path
Site detail (commit status) /projects/{projectId}/sites/{siteId}
Function detail (commit status) /projects/{projectId}/functions/{functionId}
Site build logs /projects/{projectId}/sites/{siteId}/deployments/{deploymentId}
Function build logs /projects/{projectId}/functions/{functionId}/deployments/{deploymentId}
Authorize /git/authorize-contributor?…

The legacy branch is unchanged, so existing installs keep their current links.

Deployment note

Cloud does not currently set _APP_CONSOLE_URL_SCHEME, so production and staging default to legacy and are unaffected by this PR. Moving them to the new console needs _APP_CONSOLE_URL_SCHEME=root plus the matching _APP_CONSOLE_DOMAIN (appwrite.io / staging.appwrite.io) in cloud-applications.

Not changed here, but worth noting: the QR link (/v1/avatars/qr) and the comment's status icons (/images/vcs/*) are also built on the console hostname. They are served by the Appwrite container, so that hostname has to route them to the API and not only to the console app.

Test Plan

  • composer lint on both changed files — passed
  • composer analyze (PHPStan level 4) on both changed files — no errors
  • tests/unit/Vcs/CommentTest.php — 4/4 passing

Related PRs and Issues

n/a

Have you read the Contributing Guidelines on issues?

Yes

🤖 Generated with Claude Code

Source merge-base: 4729c7ba45727a377d32d363e03efe7f7e979324
Source head: 31fbb49352709abb066062117bdc35f8854ca8fe

@shipwright-agent

Copy link
Copy Markdown

✅ Shipwright · Approve

Recommendation: approve PR #7 · Tier T1
Checks: 0 total · 0 needing attention

Next step: ready to merge.

Findings (6)

  • HIGH The URL construction logic is duplicated in three places with subtle differences (GitAction.php and two locations in Deployment.php). · src/Appwrite/Deployment/GitAction.php:57
    • Fix: Review the cited evidence, fix the risk if confirmed, and rerun Shipwright.
  • HIGH The new 'root' URL scheme branch silently drops the region from the target URL. · src/Appwrite/Deployment/GitAction.php:60
    • Fix: Review the cited evidence, fix the risk if confirmed, and rerun Shipwright.
  • HIGH The root-scheme branch changes the resource path from '{$collection}/{$type}-{$resource->getId()}' to '{$collection}/{$resource->getId()}'. · src/Appwrite/Deployment/GitAction.php:60
    • Fix: Review the cited evidence, fix the risk if confirmed, and rerun Shipwright.
  • HIGH The authorize-contributor URL in the root scheme drops the '/console' prefix but still carries sensitive query parameters (projectId, installationId, repositoryId, providerPullRequ · src/Appwrite/Platform/Modules/VCS/Http/GitHub/Deployment.php:168
    • Fix: Review the cited evidence, fix the risk if confirmed, and rerun Shipwright.
  • HIGH The root-scheme authorize URL '/git/authorize-contributor' is a new top-level route. · src/Appwrite/Platform/Modules/VCS/Http/GitHub/Deployment.php:168
    • Fix: Review the cited evidence, fix the risk if confirmed, and rerun Shipwright.
  • LOW The magic string 'legacy' as the default for _APP_CONSOLE_URL_SCHEME is not documented or defined as a constant. · src/Appwrite/Deployment/GitAction.php:57
    • Fix: Review the cited evidence, fix the risk if confirmed, and rerun Shipwright.

Fireworks usage: 6,832 input · 777 output · 7,609 total tokens · $0.0020 · 13s · 0 fix iteration(s)

Open the Shipwright check for full evidence and the audit bundle. Use /shipwright rerun to verify again.

$targetUrl = "{$protocol}://{$hostname}/console/project-{$region}-{$project->getId()}/{$segment}";
$collection = $isSite ? 'sites' : 'functions';
$type = $isSite ? 'site' : 'function';
$targetUrl = System::getEnv('_APP_CONSOLE_URL_SCHEME', 'legacy') !== 'root'

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Shipwright · HIGH

The URL construction logic is duplicated in three places with subtle differences (GitAction.php and two locations in Deployment.php).

Impact: The URL construction logic is duplicated in three places with subtle differences (GitAction.php and two locations in Deployment.php). The 'root' vs 'legacy' scheme check is repeated inline each time. A future maintainer changing one location will likely miss the others, causing inconsistent commit-status URLs across code paths.

Suggested fix: Review the cited evidence, fix the risk if confirmed, and rerun Shipwright.

$hostname = $platform['consoleHostname'] ?? '';

$authorizeUrl = $protocol . '://' . $hostname . "/console/git/authorize-contributor?projectId={$projectId}&installationId={$installationId}&repositoryId={$repositoryId}&providerPullRequestId={$providerPullRequestId}";
$authorizeUrl = System::getEnv('_APP_CONSOLE_URL_SCHEME', 'legacy') !== 'root'

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Shipwright · HIGH

The authorize-contributor URL in the root scheme drops the '/console' prefix but still carries sensitive query parameters (projectId, installationId, repositoryId, providerPullRequ

Impact: The authorize-contributor URL in the root scheme drops the '/console' prefix but still carries sensitive query parameters (projectId, installationId, repositoryId, providerPullRequestId) in a GET URL. If this URL is logged by intermediaries, browsers, or the VCS provider, these identifiers are exposed. The legacy path had the same exposure, but the new root path may bypass any console-level access controls or middle…

Suggested fix: Review the cited evidence, fix the risk if confirmed, and rerun Shipwright.

$hostname = $platform['consoleHostname'] ?? '';

$authorizeUrl = $protocol . '://' . $hostname . "/console/git/authorize-contributor?projectId={$projectId}&installationId={$installationId}&repositoryId={$repositoryId}&providerPullRequestId={$providerPullRequestId}";
$authorizeUrl = System::getEnv('_APP_CONSOLE_URL_SCHEME', 'legacy') !== 'root'

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Shipwright · HIGH

The root-scheme authorize URL '/git/authorize-contributor' is a new top-level route.

Impact: The root-scheme authorize URL '/git/authorize-contributor' is a new top-level route. If the console's routing or middleware previously enforced authentication/CSRF on '/console/' paths, moving this endpoint to '/git/' may expose it without those protections, allowing unauthenticated or cross-site requests to trigger authorization flows.

Suggested fix: Review the cited evidence, fix the risk if confirmed, and rerun Shipwright.

$targetUrl = "{$protocol}://{$hostname}/console/project-{$region}-{$project->getId()}/{$segment}";
$collection = $isSite ? 'sites' : 'functions';
$type = $isSite ? 'site' : 'function';
$targetUrl = System::getEnv('_APP_CONSOLE_URL_SCHEME', 'legacy') !== 'root'

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Shipwright · LOW

The magic string 'legacy' as the default for _APP_CONSOLE_URL_SCHEME is not documented or defined as a constant.

Impact: The magic string 'legacy' as the default for _APP_CONSOLE_URL_SCHEME is not documented or defined as a constant. A reader cannot tell what other values are valid ('root' is the only one checked) or what happens if an unexpected value is set — it silently falls back to legacy behavior.

Suggested fix: Review the cited evidence, fix the risk if confirmed, and rerun Shipwright.

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.

1 participant