Compare commits

...

2 commits

Author SHA1 Message Date
82c80a53a6
continue patching transport layer security
Some checks failed
Lint / pnpm_install (push) Successful in 1m47s
Test (production install and build) / production (22.11.0) (push) Successful in 1m0s
Publish Docker image / Build (push) Successful in 4m34s
Lint / lint (backend) (push) Successful in 2m9s
Lint / lint (frontend) (push) Successful in 2m5s
Lint / lint (frontend-embed) (push) Successful in 1m56s
Test (backend) / unit (22.11.0) (push) Failing after 7m47s
Lint / lint (frontend-shared) (push) Successful in 2m5s
Lint / lint (misskey-bubble-game) (push) Successful in 2m4s
Lint / lint (misskey-js) (push) Successful in 2m2s
Lint / lint (misskey-reversi) (push) Successful in 2m3s
Lint / lint (sw) (push) Successful in 2m9s
Lint / typecheck (backend) (push) Successful in 1m47s
Lint / typecheck (misskey-js) (push) Successful in 1m21s
Lint / typecheck (sw) (push) Successful in 1m25s
Signed-off-by: eternal-flame-AD <yume@yumechi.jp>
2024-11-23 11:47:11 -06:00
4b96e03f54
mark URL mismatch as permanent
Some checks failed
Lint / pnpm_install (push) Successful in 1m47s
Test (production install and build) / production (22.11.0) (push) Successful in 1m3s
Publish Docker image / Build (push) Successful in 4m3s
Lint / lint (backend) (push) Successful in 2m18s
Lint / lint (frontend) (push) Successful in 1m58s
Lint / lint (frontend-embed) (push) Successful in 1m57s
Test (backend) / unit (22.11.0) (push) Failing after 7m23s
Lint / lint (frontend-shared) (push) Successful in 2m15s
Lint / lint (misskey-bubble-game) (push) Successful in 1m59s
Lint / lint (misskey-js) (push) Successful in 2m6s
Lint / lint (misskey-reversi) (push) Successful in 2m5s
Lint / lint (sw) (push) Successful in 2m11s
Lint / typecheck (backend) (push) Successful in 1m58s
Lint / typecheck (misskey-js) (push) Successful in 1m25s
Lint / typecheck (sw) (push) Successful in 1m22s
Signed-off-by: eternal-flame-AD <yume@yumechi.jp>
2024-11-22 14:50:32 -06:00
5 changed files with 27 additions and 10 deletions

View file

@ -44,6 +44,14 @@ export class DownloadService {
const maxSize = this.config.maxFileSize;
const urlObj = new URL(url);
if (urlObj.protocol && urlObj.protocol !== 'https:') {
throw new Error(`Unsupported protocol: ${urlObj.protocol}, only HTTPS is supported`);
}
urlObj.protocol = 'https:';
if (urlObj.port && urlObj.port !== '443') {
throw new Error(`Unsupported port: ${urlObj.port}, only 443 is supported`);
}
let filename = urlObj.pathname.split('/').pop() ?? 'untitled';
const req = got.stream(url, {

View file

@ -171,9 +171,10 @@ export class HttpRequestService {
*/
@bindThis
public getAgentByUrl(url: URL, bypassProxy = false): https.Agent {
if (url.protocol !== 'https:') {
if (url.protocol && url.protocol !== 'https:') {
throw new Error('Invalid protocol');
}
url.protocol = 'https:';
if (url.port && url.port !== '443') {
throw new Error('Invalid port');
}

View file

@ -64,7 +64,7 @@ export class Resolver {
public async resolveCollection(value: string | IObject): Promise<ICollection | IOrderedCollection> {
const collection = typeof value === 'string'
? await this.resolve(value)
: value;
: yumeNormalizeObject(value);
if (isCollectionOrOrderedCollection(collection)) {
return collection;
@ -74,7 +74,7 @@ export class Resolver {
}
@bindThis
public async resolveNotNormalized(value: string | IObject): Promise<IUnsanitizedObject> {
private async resolveNotNormalized(value: string | IObject): Promise<IUnsanitizedObject> {
if (typeof value !== 'string') {
return value;
}

View file

@ -3,6 +3,7 @@
* SPDX-License-Identifier: AGPL-3.0-only
*/
import * as Bull from 'bullmq';
import { forwardRef, Inject, Injectable } from '@nestjs/common';
import { In } from 'typeorm';
import { DI } from '@/di-symbols.js';
@ -164,7 +165,7 @@ export class ApNoteService {
const noteUrl = yumeAssertAcceptableURL(note.id);
if (noteUrl.host !== actUrl.host) {
throw new Error(`note url & uri host mismatch: note url: ${url}, note uri: ${note.id}`);
throw new Bull.UnrecoverableError(`note url & uri host mismatch: note url: ${url}, note uri: ${note.id}`);
}
}

View file

@ -103,26 +103,33 @@ export function yumeNormalizeRecursive<O extends IUnsanitizedObject | string | (
if (object.length > 64) {
throw new bull.UnrecoverableError('array length limit exceeded');
}
return object.flatMap(yumeNormalizeRecursive);
return object.flatMap((x) => yumeNormalizeRecursive(x, depth + (object.length + 3 / 4)));
}
return yumeNormalizeObject(object);
return yumeNormalizeObject(object, depth + 1);
}
export function yumeNormalizeObject(object: IUnsanitizedObject): IObject {
export function yumeNormalizeObject(object: IUnsanitizedObject, depth = 0): IObject {
if (object.cc) {
object.cc = yumeNormalizeRecursive(object.cc);
object.cc = yumeNormalizeRecursive(object.cc, depth + 1);
}
if (object.id) {
object.id = yumeNormalizeURL(object.id);
}
if (object.url) {
object.url = yumeNormalizeRecursive(object.url);
object.url = yumeNormalizeRecursive(object.url, depth + 1);
}
if (object.replies) {
object.replies.first = object.replies.first ?
typeof object.replies.first === 'string' ? yumeNormalizeURL(object.replies.first) : yumeNormalizeObject(object.replies.first, depth + 1) : undefined;
object.replies.items = object.replies.items ?
typeof object.replies.items === 'string' ? yumeNormalizeURL(object.replies.items) : yumeNormalizeRecursive(object.replies.items, depth + 1) : undefined;
}
if (object.inReplyTo) {
object.inReplyTo = yumeNormalizeRecursive(object.inReplyTo);
object.inReplyTo = yumeNormalizeRecursive(object.inReplyTo, depth + 1);
}
return object as IObject;