fix: address bot review findings

- Add codeberg.org to deriveLinkedIssueProvider built-in Gitea check
- Fix Gitea PR review prompt: !N → #N (GitLab vs Gitea syntax)
- Update gitlab.mdx: remove 'read-only' claim (write support ships)
- Gate walkthrough Gitea PR source (server can't fulfill yet)
- Thread per-project API base URL override into walkthrough GitLab diff
- Stop following cross-origin redirects in GitLab/Gitea clients (auth leak prevention)
This commit is contained in:
2026-08-18 20:35:46 +00:00
parent 707991665a
commit 4ce02ee569
7 changed files with 27 additions and 9 deletions
+3
View File
@@ -227,7 +227,9 @@ export function createGiteaClient({ token, baseUrl }) {
// Follow redirects (301/302/308) exactly once. Gitea serves them for moved
// repos/users; a manual redirect keeps our Authorization header across the hop.
// Only follow same-origin redirects to avoid leaking the token to a different host.
let redirects = 0;
const baseHost = new URL(url).host;
while (
(response.status === 301 || response.status === 302 || response.status === 308)
&& headerValue(response.headers, 'location')
@@ -235,6 +237,7 @@ export function createGiteaClient({ token, baseUrl }) {
) {
const location = headerValue(response.headers, 'location');
const nextUrl = new URL(location, url).toString();
if (new URL(nextUrl).host !== baseHost) break;
response = await conditionalFetch(nextUrl, fetchOptions);
redirects += 1;
}
+4 -1
View File
@@ -222,8 +222,10 @@ export function createGitLabClient({ token, baseUrl }) {
// Follow a project-move redirect exactly once. GitLab redirects
// (301/302/308) come with a `Location` for the new project URL; a manual
// redirect keeps our PRIVATE-TOKEN header across the hop.
// redirect keeps our PRIVATE-TOKEN header across the hop. Only follow
// same-origin redirects to avoid leaking the token to a different host.
let redirects = 0;
const baseHost = new URL(url).host;
while (
(response.status === 301 || response.status === 302 || response.status === 308)
&& headerValue(response.headers, 'location')
@@ -231,6 +233,7 @@ export function createGitLabClient({ token, baseUrl }) {
) {
const location = headerValue(response.headers, 'location');
const nextUrl = new URL(location, url).toString();
if (new URL(nextUrl).host !== baseHost) break;
response = await conditionalFetch(nextUrl, fetchOptions);
redirects += 1;
}
@@ -1,6 +1,9 @@
import { getOctokitOrNull } from '../github/octokit.js';
import { resolveGitHubRepoFromDirectory } from '../github/repo/index.js';
import { getGitLabClientOrNull } from '../gitlab/client.js';
import { createGitLabClient } from '../gitlab/client.js';
import { getGitLabAuth, getGitLabDefaultBaseUrl } from '../gitlab/auth.js';
import { getEffectiveProviderApiBaseUrl } from '../git-providers/project-config.js';
import { resolveGitLabRepoFromDirectory } from '../gitlab/repo.js';
// GitLab diff pagination cap: never loop more than 10 pages of 100 files,
@@ -60,7 +63,18 @@ async function getGitHubPullRequestDiff(directory, number) {
* here.
*/
async function getGitLabMergeRequestDiff(repo, number) {
const client = getGitLabClientOrNull();
// Resolve per-project API base override, mirroring getClient() in routes.js.
const auth = getGitLabAuth();
if (!auth?.accessToken) {
throw Object.assign(new Error('Connect a GitLab account to review merge requests'), {
statusCode: 401,
code: 'gitlab-not-connected',
});
}
const effectiveBaseUrl = getEffectiveProviderApiBaseUrl('gitlab', directory) || getGitLabDefaultBaseUrl();
const client = effectiveBaseUrl !== getGitLabDefaultBaseUrl()
? createGitLabClient({ token: auth.accessToken, baseUrl: effectiveBaseUrl })
: getGitLabClientOrNull();
if (!client) {
throw Object.assign(new Error('Connect a GitLab account to review merge requests'), {
statusCode: 401,