Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enhance: Judge instance block by endsWith #9263

Merged
merged 20 commits into from
Jan 13, 2023

Conversation

tamaina
Copy link
Contributor

@tamaina tamaina commented Dec 3, 2022

Fix #9258

What

インスタンスブロックはendsWithで評価する

Why

嫌がらせなどのためにサブドメインをいくつも作られるのは困る

Additional info (optional)

https://github.com/tamaina/misskey/blob/181ca6bcfcdb6ddcd02beab8c5945b9ce5c3d3ac/packages/backend/src/core/chart/charts/federation.ts#L63 などのSQLを変更する必要がある(チャートなので考えなくてもあまり酷いことにはならない)

@github-actions github-actions bot added the packages/backend Server side specific issue/PR label Dec 3, 2022
@tamaina
Copy link
Contributor Author

tamaina commented Dec 8, 2022

SQLどうしよう(得意な人にバシッと書いてもらいたい)

@syuilo
Copy link
Member

syuilo commented Dec 8, 2022

LIKE使うとか?

@tamaina
Copy link
Contributor Author

tamaina commented Dec 8, 2022

SIMILAR TOを使えばいいかも?

@tamaina
Copy link
Contributor Author

tamaina commented Dec 8, 2022

いやNOT LIKE ANYでいいのか

@tamaina
Copy link
Contributor Author

tamaina commented Dec 8, 2022

\deploy sha=e028466

@tamaina
Copy link
Contributor Author

tamaina commented Dec 8, 2022

/deploy sha=e028466

@syuilo
Copy link
Member

syuilo commented Dec 8, 2022

LIKEのパフォーマンスが気になるところではある

@github-actions
Copy link
Contributor

github-actions bot commented Dec 8, 2022

Your preview environment pr-9263-syuilo has been deployed.

Preview environment endpoint is available here

@tamaina
Copy link
Contributor Author

tamaina commented Dec 8, 2022

blockedHosts増えるとめちゃくちゃパフォーマンス悪そう

@syuilo
Copy link
Member

syuilo commented Dec 8, 2022

blockedHostsの数というよりはinstanceレコードの数が多いと遅くなりそう
インデックスあるけどLIKEで使ってくれるのか不明

@tamaina
Copy link
Contributor Author

tamaina commented Dec 8, 2022

/deploy sha=d27dc2c

@tamaina
Copy link
Contributor Author

tamaina commented Dec 8, 2022

データベース初期化されるのか

tamaina and others added 3 commits December 8, 2022 23:56
Co-authored-by: Acid Chicken (硫酸鶏) <root@acid-chicken.com>
@tamaina tamaina marked this pull request as ready for review December 9, 2022 05:46
Co-authored-by: syuilo <Syuilotan@yahoo.co.jp>
@tamaina tamaina requested a review from syuilo December 9, 2022 05:47
tamaina and others added 2 commits December 9, 2022 15:08
Co-authored-by: Acid Chicken (硫酸鶏) <root@acid-chicken.com>
@tamaina tamaina requested a review from syuilo December 9, 2022 06:16
Copy link
Member

@acid-chicken acid-chicken left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

一応確認

packages/backend/src/core/chart/charts/federation.ts Outdated Show resolved Hide resolved
@tamaina tamaina requested a review from acid-chicken December 17, 2022 12:14
@tamaina
Copy link
Contributor Author

tamaina commented Dec 25, 2022

⬆️

1 similar comment
@tamaina
Copy link
Contributor Author

tamaina commented Dec 30, 2022

⬆️

@codecov
Copy link

codecov bot commented Jan 3, 2023

Codecov Report

Merging #9263 (8bb8a49) into develop (3e415e7) will increase coverage by 0.00%.
The diff coverage is 26.08%.

@@           Coverage Diff            @@
##           develop    #9263   +/-   ##
========================================
  Coverage    22.57%   22.58%           
========================================
  Files          731      731           
  Lines        68099    68107    +8     
  Branches      2212     2213    +1     
========================================
+ Hits         15375    15380    +5     
- Misses       52724    52727    +3     
Impacted Files Coverage Δ
...ges/backend/src/core/activitypub/ApInboxService.ts 18.48% <0.00%> (ø)
.../backend/src/core/activitypub/ApResolverService.ts 32.38% <0.00%> (ø)
...ckend/src/core/activitypub/models/ApNoteService.ts 24.93% <0.00%> (ø)
...ckages/backend/src/core/chart/charts/federation.ts 34.12% <0.00%> (ø)
...nd/src/queue/processors/DeliverProcessorService.ts 0.00% <0.00%> (ø)
...kend/src/queue/processors/InboxProcessorService.ts 0.00% <0.00%> (ø)
...kend/src/server/api/endpoints/admin/update-meta.ts 0.00% <0.00%> (ø)
...ckages/backend/src/server/api/endpoints/ap/show.ts 0.00% <0.00%> (ø)
packages/backend/src/core/UtilityService.ts 67.34% <50.00%> (-2.43%) ⬇️
...backend/src/core/entities/InstanceEntityService.ts 47.54% <75.00%> (+1.77%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@tamaina
Copy link
Contributor Author

tamaina commented Jan 12, 2023

QueryFailedError: syntax error at or near "{"
(略)
query: 'SELECT COUNT(DISTINCT "following"."followeeHost") FROM "following" "following" WHERE "following"."followeeHost" IS NOT NULL AND "following"."followeeHost" NOT LIKE ANY({$1, $2, $3, $4, $5, $6, $7, $8, $9, $10}) AND "following"."followeeHost" NOT IN (SELECT "instance"."host" AS "instance_host" FROM "instance" "instance" WHERE "instance"."isSuspended" = true)',
parameters: [
'activitypub-troll.cf',
'%.activitypub-troll.cf',
...
],

みたいに言われる

@tamaina

This comment was marked as abuse.

@tamaina
Copy link
Contributor Author

tamaina commented Jan 12, 2023

Jan 12 06:57:51 instance-20211023-1036 p1.a9z.dev[771719]: query: 'SELECT COUNT(DISTINCT "following"."followeeHost") FROM "following" "following" WHERE "following"."followeeHost" IS NOT NULL AND "following"."followeeHost" NOT LIKE ANY($1, $2, $3, $4, $5, $6, $7, $8, $9, $10) AND "following"."followeeHost" NOT IN (SELECT "instance"."host" AS "instance_host" FROM "instance" "instance" WHERE "instance"."isSuspended" = true) AND "following"."followeeHost" IN (SELECT "f"."followerHost" AS "f_followerHost" FROM "following" "f" WHERE "f"."followerHost" IS NOT NULL)',

ですよね

@tamaina
Copy link
Contributor Author

tamaina commented Jan 12, 2023

  • 使い方合ってるかわからないけどARRAY[:...blocked]と書くようにした
  • 大文字小文字を区別しないのを徹底するようにした

@syuilo syuilo merged commit 303519a into misskey-dev:develop Jan 13, 2023
@syuilo
Copy link
Member

syuilo commented Jan 13, 2023

🙏🏻

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
packages/backend Server side specific issue/PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make instances block more lenient
3 participants