-
Notifications
You must be signed in to change notification settings - Fork 0
fix: honour console URL scheme in VCS commit statuses and authorize link #7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: qa/agent-appwrite-appwrite/pr-07-13476/base
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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' | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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' | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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]; | ||
|
|
||
|
|
@@ -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); | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
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.