Skip to content

Commit

Permalink
feat: license violation protection (#13285)
Browse files Browse the repository at this point in the history
* spec(frontend): aboutページにリポジトリ・フィードバックのURLを表示させる

Cherry-picked from MisskeyIO#441
Cherry-picked from MisskeyIO#438

* feat: license violation protection

* build: fix typo

* build: fix typo

* fix: farewell to the static type land

* fix: key typo

* fix: import typo

* fix: properly interpret `prominently`

* docs: add disclaimer

* docs: update CHANGELOG

* chore: add gap

---------

Co-authored-by: まっちゃとーにゅ <17376330+u1-liquid@users.noreply.github.com>
Co-authored-by: syuilo <4439005+syuilo@users.noreply.github.com>
  • Loading branch information
3 people committed Feb 17, 2024
1 parent fa24327 commit acba96c
Show file tree
Hide file tree
Showing 19 changed files with 371 additions and 26 deletions.
61 changes: 59 additions & 2 deletions .config/example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,63 @@
# Misskey configuration
#━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

# ┌──────────────────────────────┐
#───┘ a boring but important thing └────────────────────────────

#
# First of all, let me tell you a story that may possibly be
# boring to you and possibly important to you.
#
# Misskey is licensed under the AGPLv3 license. This license is
# known to be often misunderstood. Please read the following
# instructions carefully and select the appropriate option so
# that you do not negligently cause a license violation.
#

# --------
# Option 1: If you host Misskey AS-IS (without any changes to
# the source code. forks are not included).
#
# Step 1: Congratulations! You don't need to do anything.

# --------
# Option 2: If you have made changes to the source code (forks
# are included) and publish a Git repository of source
# code. There should be no access restrictions on
# this repository. Strictly speaking, it doesn't have
# to be a Git repository, but you'll probably use Git!
#
# Step 1: Build and run the Misskey server first.
# Step 2: Open <https://your.misskey.example/admin/settings> in
# your browser with the administrator account.
# Step 3: Enter the URL of your Git repository in the
# "Repository URL" field.

# --------
# Option 3: If neither of the above applies to you.
# (In this case, the source code should be published
# on the Misskey interface. IT IS NOT ENOUGH TO
# DISCLOSE THE SOURCE CODE WEHN A USER REQUESTS IT BY
# E-MAIL OR OTHER MEANS. If you are not satisfied
# with this, it is recommended that you read the
# license again carefully. Anyway, enabling this
# option will automatically generate and publish a
# tarball at build time, protecting you from
# inadvertent license violations. (There is no legal
# guarantee, of course.) The tarball will generated
# from the root directory of your codebase. So it is
# also recommended to check <built/tarball> directory
# once after building and before activating the server
# to avoid ACCIDENTAL LEAKING OF SENSITIVE INFORMATION.
# To prevent certain files from being included in the
# tarball, add a glob pattern after line 15 in
# <scripts/tarball.mjs>. DO NOT FORGET TO BUILD AFTER
# ENABLING THIS OPTION!)
#
# Step 1: Uncomment the following line.
#
# publishTarballInsteadOfProvideRepositoryUrl: true

# ┌─────┐
#───┘ URL └─────────────────────────────────────────────────────

Expand Down Expand Up @@ -118,7 +175,7 @@ redis:
# ┌───────────────────────────┐
#───┘ MeiliSearch configuration └─────────────────────────────

# You can set scope to local (default value) or global
# You can set scope to local (default value) or global
# (include notes from remote).

#meilisearch:
Expand Down Expand Up @@ -214,7 +271,7 @@ proxyRemoteFiles: true
signToActivityPubGet: true

# For security reasons, uploading attachments from the intranet is prohibited,
# but exceptions can be made from the following settings. Default value is "undefined".
# but exceptions can be made from the following settings. Default value is "undefined".
# Read changelog to learn more (Improvements of 12.90.0 (2021/09/04)).
#allowedPrivateNetworks: [
# '127.0.0.1/32'
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
### General
- Feat: [mCaptcha](https://github.com/mCaptcha/mCaptcha)のサポートを追加
- Feat: Add support for TrueMail
- Feat: AGPLv3ライセンスに誤って違反するのを防止する機能を追加
- 管理者がrepositoryUrlを変更したり、またはソースコードを直接頒布することを選択できるようになります
- 本体のソースコードに改変を加えた際に、ライセンスに基づく適切な案内を表示します
- Enhance: モデレーターはすべてのユーザーのリアクション一覧を見られるように
- Fix: リストライムラインの「リノートを表示」が正しく機能しない問題を修正
- Fix: リモートユーザーのリアクション一覧がすべて見えてしまうのを修正
Expand Down
40 changes: 40 additions & 0 deletions locales/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3980,6 +3980,10 @@ export interface Locale extends ILocale {
* Misskeyは{host}が使用している無料のソフトウェアです。これからも開発を続けられるように、ぜひ寄付をお願いします!
*/
"pleaseDonate": ParameterizedString<"host">;
/**
* 対応するソースコードは{anchor}から利用可能です。
*/
"correspondingSourceIsAvailable": ParameterizedString<"anchor">;
/**
* ロール
*/
Expand Down Expand Up @@ -4684,6 +4688,34 @@ export interface Locale extends ILocale {
* 外部サービス
*/
"externalServices": string;
/**
* ソースコード
*/
"sourceCode": string;
/**
* ソースコードはまだ提供されていません。この問題の修正について管理者に問い合わせてください。
*/
"sourceCodeIsNotYetProvided": string;
/**
* リポジトリURL
*/
"repositoryUrl": string;
/**
* ソースコードが公開されているリポジトリがある場合、そのURLを記入します。Misskeyを現状のまま(ソースコードにいかなる変更も加えずに)使用している場合は https://github.com/misskey-dev/misskey と記入します。
*/
"repositoryUrlDescription": string;
/**
* リポジトリを公開していない場合、代わりにtarballを提供する必要があります。詳細は.config/example.ymlを参照してください。
*/
"repositoryUrlOrTarballRequired": string;
/**
* フィードバック
*/
"feedback": string;
/**
* フィードバックURL
*/
"feedbackUrl": string;
/**
* 運営者情報
*/
Expand Down Expand Up @@ -6813,6 +6845,14 @@ export interface Locale extends ILocale {
* ソースコード
*/
"source": string;
/**
* オリジナル
*/
"original": string;
/**
* {name}はオリジナルのMisskeyを改変したバージョンを使用しています。
*/
"thisIsModifiedVersion": ParameterizedString<"name">;
/**
* Misskeyを翻訳
*/
Expand Down
10 changes: 10 additions & 0 deletions locales/ja-JP.yml
Original file line number Diff line number Diff line change
Expand Up @@ -991,6 +991,7 @@ neverShow: "今後表示しない"
remindMeLater: "また後で"
didYouLikeMisskey: "Misskeyを気に入っていただけましたか?"
pleaseDonate: "Misskeyは{host}が使用している無料のソフトウェアです。これからも開発を続けられるように、ぜひ寄付をお願いします!"
correspondingSourceIsAvailable: "対応するソースコードは{anchor}から利用可能です。"
roles: "ロール"
role: "ロール"
noRole: "ロールはありません"
Expand Down Expand Up @@ -1167,6 +1168,13 @@ hideRepliesToOthersInTimelineAll: "TLに現在フォロー中の人全員の返
confirmShowRepliesAll: "この操作は元に戻せません。本当にTLに現在フォロー中の人全員の返信を含めるようにしますか?"
confirmHideRepliesAll: "この操作は元に戻せません。本当にTLに現在フォロー中の人全員の返信を含めないようにしますか?"
externalServices: "外部サービス"
sourceCode: "ソースコード"
sourceCodeIsNotYetProvided: "ソースコードはまだ提供されていません。この問題の修正について管理者に問い合わせてください。"
repositoryUrl: "リポジトリURL"
repositoryUrlDescription: "ソースコードが公開されているリポジトリがある場合、そのURLを記入します。Misskeyを現状のまま(ソースコードにいかなる変更も加えずに)使用している場合は https://github.com/misskey-dev/misskey と記入します。"
repositoryUrlOrTarballRequired: "リポジトリを公開していない場合、代わりにtarballを提供する必要があります。詳細は.config/example.ymlを参照してください。"
feedback: "フィードバック"
feedbackUrl: "フィードバックURL"
impressum: "運営者情報"
impressumUrl: "運営者情報URL"
impressumDescription: "ドイツなどの一部の国と地域では表示が義務付けられています(Impressum)。"
Expand Down Expand Up @@ -1778,6 +1786,8 @@ _aboutMisskey:
contributors: "コントリビューター"
allContributors: "全てのコントリビューター"
source: "ソースコード"
original: "オリジナル"
thisIsModifiedVersion: "{name}はオリジナルのMisskeyを改変したバージョンを使用しています。"
translation: "Misskeyを翻訳"
donate: "Misskeyに寄付"
morePatrons: "他にも多くの方が支援してくれています。ありがとうございます🥰"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
* SPDX-FileCopyrightText: syuilo and misskey-project
* SPDX-License-Identifier: AGPL-3.0-only
*/

export class MakeRepositoryUrlNullable1707808106310 {
name = 'MakeRepositoryUrlNullable1707808106310'

async up(queryRunner) {
await queryRunner.query(`ALTER TABLE "meta" ALTER COLUMN "repositoryUrl" DROP NOT NULL`);
}

async down(queryRunner) {
await queryRunner.query(`ALTER TABLE "meta" ALTER COLUMN "repositoryUrl" SET NOT NULL`);
}
}
4 changes: 4 additions & 0 deletions packages/backend/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ type Source = {
scope?: 'local' | 'global' | string[];
};

publishTarballInsteadOfProvideRepositoryUrl?: boolean;

proxy?: string;
proxySmtp?: string;
proxyBypassHosts?: string[];
Expand Down Expand Up @@ -145,6 +147,7 @@ export type Config = {
signToActivityPubGet: boolean | undefined;

version: string;
publishTarballInsteadOfProvideRepositoryUrl: boolean;
host: string;
hostname: string;
scheme: string;
Expand Down Expand Up @@ -209,6 +212,7 @@ export function loadConfig(): Config {

return {
version,
publishTarballInsteadOfProvideRepositoryUrl: !!config.publishTarballInsteadOfProvideRepositoryUrl,
url: url.origin,
port: config.port ?? parseInt(process.env.PORT ?? '', 10),
socket: config.socket,
Expand Down
4 changes: 2 additions & 2 deletions packages/backend/src/models/Meta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -357,9 +357,9 @@ export class MiMeta {
@Column('varchar', {
length: 1024,
default: 'https://github.com/misskey-dev/misskey',
nullable: false,
nullable: true,
})
public repositoryUrl: string;
public repositoryUrl: string | null;

@Column('varchar', {
length: 1024,
Expand Down
2 changes: 1 addition & 1 deletion packages/backend/src/server/api/endpoints/admin/meta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ export const meta = {
},
repositoryUrl: {
type: 'string',
optional: false, nullable: false,
optional: false, nullable: true,
},
summalyProxy: {
type: 'string',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ export const paramDef = {
swPublicKey: { type: 'string', nullable: true },
swPrivateKey: { type: 'string', nullable: true },
tosUrl: { type: 'string', nullable: true },
repositoryUrl: { type: 'string' },
feedbackUrl: { type: 'string' },
repositoryUrl: { type: 'string', nullable: true },
feedbackUrl: { type: 'string', nullable: true },
impressumUrl: { type: 'string', nullable: true },
privacyPolicyUrl: { type: 'string', nullable: true },
useObjectStorage: { type: 'boolean' },
Expand Down Expand Up @@ -402,7 +402,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
}

if (ps.repositoryUrl !== undefined) {
set.repositoryUrl = ps.repositoryUrl;
set.repositoryUrl = URL.canParse(ps.repositoryUrl!) ? ps.repositoryUrl : null;
}

if (ps.feedbackUrl !== undefined) {
Expand Down
9 changes: 7 additions & 2 deletions packages/backend/src/server/api/endpoints/meta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ export const meta = {
type: 'string',
optional: false, nullable: false,
},
providesTarball: {
type: 'boolean',
optional: false, nullable: false,
},
name: {
type: 'string',
optional: false, nullable: false,
Expand Down Expand Up @@ -69,12 +73,12 @@ export const meta = {
},
repositoryUrl: {
type: 'string',
optional: false, nullable: false,
optional: false, nullable: true,
default: 'https://github.com/misskey-dev/misskey',
},
feedbackUrl: {
type: 'string',
optional: false, nullable: false,
optional: false, nullable: true,
default: 'https://github.com/misskey-dev/misskey/issues/new',
},
defaultDarkTheme: {
Expand Down Expand Up @@ -352,6 +356,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
maintainerEmail: instance.maintainerEmail,

version: this.config.version,
providesTarball: this.config.publishTarballInsteadOfProvideRepositoryUrl,

name: instance.name,
shortName: instance.shortName,
Expand Down
8 changes: 8 additions & 0 deletions packages/frontend/src/boot/main-boot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { alert, confirm, popup, post, toast } from '@/os.js';
import { useStream } from '@/stream.js';
import * as sound from '@/scripts/sound.js';
import { $i, signout, updateAccount } from '@/account.js';
import { fetchInstance, instance } from '@/instance.js';
import { ColdDeviceStorage, defaultStore } from '@/store.js';
import { makeHotkey } from '@/scripts/hotkey.js';
import { reactionPicker } from '@/scripts/reaction-picker.js';
Expand Down Expand Up @@ -234,6 +235,13 @@ export async function mainBoot() {
}
}

fetchInstance().then(() => {
const modifiedVersionMustProminentlyOfferInAgplV3Section13Read = miLocalStorage.getItem('modifiedVersionMustProminentlyOfferInAgplV3Section13Read');
if (modifiedVersionMustProminentlyOfferInAgplV3Section13Read !== 'true' && instance.repositoryUrl !== 'https://github.com/misskey-dev/misskey') {
popup(defineAsyncComponent(() => import('@/components/MkSourceCodeAvailablePopup.vue')), {}, {}, 'closed');
}
});

if ('Notification' in window) {
// 許可を得ていなかったらリクエスト
if (Notification.permission === 'default') {
Expand Down

1 comment on commit acba96c

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

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

Chromatic detects changes. Please review the changes on Chromatic.

Please sign in to comment.