fix: prevent folder downloads from exposing GitHub metadata

This commit is contained in:
Codex committed 2026-11-09 10:45:24 +00:00
1 parent 4834289c8e
commit 7c7caa845c
6 files changed
+115 -8

No files matched your search

+11
View File
@@ -362,7 +362,16 @@ export default class AnonymizedFile {
return true;
}
/** Tree entries have no size; zero-byte files are still valid files. */
async assertContentFile(): Promise<void> {
const file = await this.getFileInfo();
if (file.size == null || file.submodule) {
throw new AnonymousError("folder_not_supported", { httpStatus: 404 });
}
}
async content(): Promise<Readable> {
await this.assertContentFile();
if (this.anonymizedPath.includes(config.ANONYMIZATION_MASK)) {
await this.originalPath();
}
@@ -388,6 +397,7 @@ export default class AnonymizedFile {
}
async anonymizedContent() {
await this.assertContentFile();
const anonymizer = this.repository.generateAnonymizeTransformer(
await this.originalPath()
);
@@ -439,6 +449,7 @@ export default class AnonymizedFile {
}
async send(res: Response): Promise<void> {
await this.assertContentFile();
const anonymizer = this.repository.generateAnonymizeTransformer(
await this.originalPath()
);