Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/Appwrite/Deployment/GitAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,13 @@ public static function run(
default => $status
};

$hostname = System::getEnv('_APP_CONSOLE_DOMAIN', System::getEnv('_APP_DOMAIN', ''));
$hostname = $platform['consoleHostname'] ?? '';
$region = $project->getAttribute('region', 'default');
$segment = $isSite ? "sites/site-{$resource->getId()}" : "functions/function-{$resource->getId()}";
$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.

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.

? "{$protocol}://{$hostname}/console/project-{$region}-{$project->getId()}/{$collection}/{$type}-{$resource->getId()}"
: "{$protocol}://{$hostname}/projects/{$project->getId()}/{$collection}/{$resource->getId()}";
$name = $resource->getAttribute('name') . ' (' . $project->getAttribute('name') . ')';

$vcs->updateCommitStatus($repositoryName, $commitHash, $owner, $state, $message, $targetUrl, $name);
Expand Down
8 changes: 6 additions & 2 deletions src/Appwrite/Platform/Modules/VCS/Http/GitHub/Deployment.php
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,9 @@ protected function createGitDeployments(
$protocol = System::getEnv('_APP_OPTIONS_FORCE_HTTPS') === 'disabled' ? 'http' : 'https';
$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.

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.

? $protocol . '://' . $hostname . "/console/git/authorize-contributor?projectId={$projectId}&installationId={$installationId}&repositoryId={$repositoryId}&providerPullRequestId={$providerPullRequestId}"
: $protocol . '://' . $hostname . "/git/authorize-contributor?projectId={$projectId}&installationId={$installationId}&repositoryId={$repositoryId}&providerPullRequestId={$providerPullRequestId}";

$action = $isAuthorized ? ['type' => 'logs'] : ['type' => 'authorize', 'url' => $authorizeUrl];

Expand Down Expand Up @@ -565,7 +567,9 @@ protected function createGitDeployments(
}
$owner = $vcs->getOwnerName($providerInstallationId, (int) $providerRepositoryId);

$providerTargetUrl = $protocol . '://' . $hostname . "/console/project-$region-$projectId/$resourceCollection/$resourceType-$resourceId";
$providerTargetUrl = System::getEnv('_APP_CONSOLE_URL_SCHEME', 'legacy') !== 'root'
? $protocol . '://' . $hostname . "/console/project-$region-$projectId/$resourceCollection/$resourceType-$resourceId"
: $protocol . '://' . $hostname . "/projects/$projectId/$resourceCollection/$resourceId";
$vcs->updateCommitStatus($repositoryName, $providerCommitHash, $owner, 'pending', $message, $providerTargetUrl, $name);
}

Expand Down