From 2a7e3b9c514e9cbb3e15551fba0d01280ebdc2e7 Mon Sep 17 00:00:00 2001 From: MeiMei <30769358+mei23@users.noreply.github.com> Date: Thu, 11 Apr 2019 03:09:12 +0900 Subject: [PATCH] =?UTF-8?q?Fix:=20AP=20actor=20Service=20=E3=81=AE?= =?UTF-8?q?=E3=82=B5=E3=83=9D=E3=83=BC=E3=83=88=E3=81=8C=E4=B8=8D=E5=AE=8C?= =?UTF-8?q?=E5=85=A8=20(v11)=20(#4662)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/queue/processors/inbox.ts | 3 ++- src/remote/activitypub/models/person.ts | 3 ++- src/remote/activitypub/type.ts | 2 ++ src/server/api/endpoints/ap/show.ts | 3 ++- 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/queue/processors/inbox.ts b/src/queue/processors/inbox.ts index 481bcbb1c4..35b0ce5386 100644 --- a/src/queue/processors/inbox.ts +++ b/src/queue/processors/inbox.ts @@ -13,6 +13,7 @@ import { instanceChart } from '../../services/chart'; import { UserPublickey } from '../../models/entities/user-publickey'; import fetchMeta from '../../misc/fetch-meta'; import { toPuny } from '../../misc/convert-host'; +import { validActor } from '../../remote/activitypub/type'; const logger = new Logger('inbox'); @@ -93,7 +94,7 @@ export default async (job: Bull.Job): Promise => { // Update Person activityの場合は、ここで署名検証/更新処理まで実施して終了 if (activity.type === 'Update') { - if (activity.object && activity.object.type === 'Person') { + if (activity.object && validActor.includes(activity.object.type)) { if (user == null) { logger.warn('Update activity received, but user not registed.'); } else if (!httpSignature.verifySignature(signature, key.keyPem)) { diff --git a/src/remote/activitypub/models/person.ts b/src/remote/activitypub/models/person.ts index e13ef21ebd..b2edf39734 100644 --- a/src/remote/activitypub/models/person.ts +++ b/src/remote/activitypub/models/person.ts @@ -24,6 +24,7 @@ import { UserPublickey } from '../../../models/entities/user-publickey'; import { isDuplicateKeyValueError } from '../../../misc/is-duplicate-key-value-error'; import { toPuny } from '../../../misc/convert-host'; import { UserProfile } from '../../../models/entities/user-profile'; +import { validActor } from '../../../remote/activitypub/type'; const logger = apLogger; /** @@ -38,7 +39,7 @@ function validatePerson(x: any, uri: string) { return new Error('invalid person: object is null'); } - if (x.type != 'Person' && x.type != 'Service') { + if (!validActor.includes(x.type)) { return new Error(`invalid person: object is not a person or service '${x.type}'`); } diff --git a/src/remote/activitypub/type.ts b/src/remote/activitypub/type.ts index c381e63507..7e81a7cc4c 100644 --- a/src/remote/activitypub/type.ts +++ b/src/remote/activitypub/type.ts @@ -65,6 +65,8 @@ interface IQuestionChoice { _misskey_votes?: number; } +export const validActor = ['Person', 'Service']; + export interface IPerson extends IObject { type: 'Person'; name: string; diff --git a/src/server/api/endpoints/ap/show.ts b/src/server/api/endpoints/ap/show.ts index 7378e3edc2..35c5dd318d 100644 --- a/src/server/api/endpoints/ap/show.ts +++ b/src/server/api/endpoints/ap/show.ts @@ -10,6 +10,7 @@ import { Users, Notes } from '../../../../models'; import { Note } from '../../../../models/entities/note'; import { User } from '../../../../models/entities/user'; import fetchMeta from '../../../../misc/fetch-meta'; +import { validActor } from '../../../../remote/activitypub/type'; export const meta = { tags: ['federation'], @@ -110,7 +111,7 @@ async function fetchAny(uri: string) { } // それでもみつからなければ新規であるため登録 - if (object.type === 'Person') { + if (validActor.includes(object.type)) { const user = await createPerson(object.id); return { type: 'User',