Merge remote-tracking branch 'origin/main' into integrate/source-errors

# Conflicts:
#	public/asset-manifest.json
#	public/css/all.min.css
#	public/css/style.css
#	public/partials/anonymize.htm
#	public/script/vendor.min.js
This commit is contained in:
Thomas Durieux committed 2026-11-14 23:20:40 +00:00
commit c014b3c8cf
22 files changed
+444 -92

No files matched your search

+4 -6
View File
@@ -561,12 +561,10 @@ export default class Repository {
await this.markExpired();
}
}
if (
this.status == RepositoryStatus.EXPIRED ||
this.status == RepositoryStatus.EXPIRING ||
this.status == RepositoryStatus.REMOVING ||
this.status == RepositoryStatus.REMOVED
) {
if (this.status == RepositoryStatus.REMOVING || this.status == RepositoryStatus.REMOVED) {
throw new AnonymousError("is_removed", { object: this, httpStatus: 410 });
}
if (this.status == RepositoryStatus.EXPIRED || this.status == RepositoryStatus.EXPIRING) {
throw new AnonymousError("repository_expired", {
object: this,
httpStatus: 410,
+22
View File
@@ -0,0 +1,22 @@
import { octokit } from "./GitHubUtils";
/** One upstream page per request. Search cursors resume within that page. */
export async function repositoryPickerPage(token: string, cursor = 0, query = "") {
const size = query ? 100 : 20;
const page = Math.floor(cursor / size) + 1;
const offset = cursor % size;
const response = await octokit(token).request("GET /user/repos", {
visibility: "all", sort: "full_name", direction: "asc", per_page: size, page,
});
const items: { id: number; fullName: string }[] = [];
let index = offset;
for (; index < response.data.length; index++) {
const repo = response.data[index];
if (!query || repo.full_name.toLowerCase().includes(query.toLowerCase())) {
items.push({ id: repo.id, fullName: repo.full_name });
if (items.length === 20) { index++; break; }
}
}
const hasNext = index < response.data.length || /rel="next"/.test(response.headers.link || "");
return { items, nextCursor: hasNext ? (page - 1) * size + index : null };
}
+31
View File
@@ -0,0 +1,31 @@
import { createPrivateKey, createSign } from "crypto";
import { readFileSync } from "fs";
type AppKeyConfig = {
GITHUB_APP_ENABLED: boolean;
GITHUB_APP_PRIVATE_KEY: string;
GITHUB_APP_PRIVATE_KEY_FILE: string;
};
// Run in each replacement service, with its actual user, environment and mounts.
// Never include the key, its path, or crypto error details in deployment output.
export function checkGitHubAppKey(config: AppKeyConfig): void {
if (!config.GITHUB_APP_ENABLED) return;
try {
const key = createPrivateKey(config.GITHUB_APP_PRIVATE_KEY || readFileSync(config.GITHUB_APP_PRIVATE_KEY_FILE, "utf8"));
if (key.asymmetricKeyType !== "rsa") throw new Error("Not an RSA key");
createSign("RSA-SHA256").update("anonymous-github-deployment-preflight").sign(key);
} catch {
throw new Error("GitHub App signing key is missing, unreadable or invalid. Preserve the GitHub App Compose override and verify the replacement service's key configuration.");
}
}
if (require.main === module) {
try {
checkGitHubAppKey(require("../config").default);
} catch {
// Configuration validation can also fail. Do not echo environment values.
process.stderr.write("GitHub App preflight failed. Check required configuration and the read-only signing-key mount before deploying.\n");
process.exitCode = 1;
}
}
+22
View File
@@ -1,3 +1,6 @@
import { repositoryPickerPage } from "../../core/github-repository-picker";
import { appUserToken } from "../../core/github-app";
import { getCredentialToken } from "../../core/credentials";
import AnonymousError from "../../core/AnonymousError";
import { BillingQuota, BillingDraft } from "../../core/billing/models";
import { cancelAccountBilling } from "../../core/billing/stripe";
@@ -369,6 +372,25 @@ export async function getAllRepositories(user: User, force: boolean) {
};
});
}
router.get("/repository_picker", async (req, res) => {
try {
const user = await getUser(req);
const cursor = req.query.cursor === undefined ? 0 : Number(req.query.cursor);
const query = typeof req.query.q === "string" ? req.query.q.trim() : "";
const connection = req.query.connection;
if (!Number.isSafeInteger(cursor) || cursor < 0 || cursor > 1000000 || query.length > 200
|| (connection !== undefined && connection !== "oauth" && connection !== "github-app")) {
res.status(400).json({ error: "Invalid repository search" });
return;
}
const token = connection === "github-app" ? await appUserToken(user.id)
: connection === "oauth" ? await getCredentialToken(user.id) : await user.getAccessToken();
if (!token) { res.status(401).json({ error: "GitHub connection required" }); return; }
res.set("Cache-Control", "no-store");
res.json(await repositoryPickerPage(token, cursor, query));
} catch (error) { handleError(error, res, req); }
});
router.get(
"/all_repositories",
async (req, res) => {