diff --git a/Dockerfile b/Dockerfile index 48ebee09c9..667571829e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -399,7 +399,7 @@ RUN \ RUN \ # Precompile bootsnap code for faster Rails startup - bundle exec bootsnap precompile --gemfile app/ lib/; + bundle exec bootsnap precompile --gemfile app/ lib/ config/; RUN \ # Pre-create and chown system volume to Mastodon user diff --git a/app/controllers/admin/email_domain_blocks_controller.rb b/app/controllers/admin/email_domain_blocks_controller.rb index d248a04d61..fd810d3f08 100644 --- a/app/controllers/admin/email_domain_blocks_controller.rb +++ b/app/controllers/admin/email_domain_blocks_controller.rb @@ -59,7 +59,7 @@ module Admin def filter_by_domain scope = EmailDomainBlock.parents.includes(:children).order(id: :desc) - scope.merge!(EmailDomainBlock.matches_domain(params[:domain])) if params[:domain].present? + scope.merge!(EmailDomainBlock.matches_domain(params[:by_domain])) if params[:by_domain].present? scope end diff --git a/app/views/admin/email_domain_blocks/index.html.haml b/app/views/admin/email_domain_blocks/index.html.haml index 8ca422c665..ce0d4d993d 100644 --- a/app/views/admin/email_domain_blocks/index.html.haml +++ b/app/views/admin/email_domain_blocks/index.html.haml @@ -7,8 +7,8 @@ = form_with url: admin_email_domain_blocks_path, method: :get, class: :simple_form do |f| .fields-group .input.string.optional - = f.text_field :domain, - value: params[:domain], + = f.text_field :by_domain, + value: params[:by_domain], class: 'string optional', placeholder: t('admin.email_domain_blocks.domain') @@ -20,7 +20,7 @@ = form_with model: @form, url: batch_admin_email_domain_blocks_path do |f| = hidden_field_tag :page, params[:page] || 1 - = hidden_field_tag :domain, params[:domain] if params[:domain].present? + = hidden_field_tag :by_domain, params[:by_domain] if params[:by_domain].present? .batch-table .batch-table__toolbar diff --git a/db/migrate/20260629125939_add_index_account_id_local_fragment_to_keypair.rb b/db/migrate/20260629125939_add_index_account_id_local_fragment_to_keypair.rb index 7e25c6adde..9388b93550 100644 --- a/db/migrate/20260629125939_add_index_account_id_local_fragment_to_keypair.rb +++ b/db/migrate/20260629125939_add_index_account_id_local_fragment_to_keypair.rb @@ -3,7 +3,13 @@ class AddIndexAccountIdLocalFragmentToKeypair < ActiveRecord::Migration[8.1] disable_ddl_transaction! - def change + def up add_index :keypairs, [:account_id, :local_fragment], unique: true, where: 'local_fragment IS NOT NULL', algorithm: :concurrently + rescue ActiveRecord::StatementInvalid + safety_assured { execute 'REINDEX INDEX CONCURRENTLY index_keypairs_on_account_id_and_local_fragment' } + end + + def down + remove_index :keypairs, name: :index_keypairs_on_account_id_and_local_fragment end end diff --git a/db/migrate/20260701161457_add_new_index_account_id_local_fragment_to_keypair.rb b/db/migrate/20260701161457_add_new_index_account_id_local_fragment_to_keypair.rb index 8b5f26ae5a..984e92c2e1 100644 --- a/db/migrate/20260701161457_add_new_index_account_id_local_fragment_to_keypair.rb +++ b/db/migrate/20260701161457_add_new_index_account_id_local_fragment_to_keypair.rb @@ -3,7 +3,13 @@ class AddNewIndexAccountIdLocalFragmentToKeypair < ActiveRecord::Migration[8.1] disable_ddl_transaction! - def change + def up add_index :keypairs, [:account_id, :local_fragment], unique: true, name: :index_keypairs_on_account_id_and_local_fragment, algorithm: :concurrently + rescue ActiveRecord::StatementInvalid + safety_assured { execute 'REINDEX INDEX CONCURRENTLY index_keypairs_on_account_id_and_local_fragment' } + end + + def down + remove_index :keypairs, name: :index_keypairs_on_account_id_and_local_fragment end end diff --git a/lib/tasks/mastodon.rake b/lib/tasks/mastodon.rake index 99615e6b2e..b13708d8d2 100644 --- a/lib/tasks/mastodon.rake +++ b/lib/tasks/mastodon.rake @@ -549,6 +549,12 @@ namespace :mastodon do require_relative '../../config/environment' disable_log_stdout! + ActiveRecord::Encryption.configure( + primary_key: ENV.fetch('ACTIVE_RECORD_ENCRYPTION_PRIMARY_KEY'), + deterministic_key: ENV.fetch('ACTIVE_RECORD_ENCRYPTION_DETERMINISTIC_KEY'), + key_derivation_salt: ENV.fetch('ACTIVE_RECORD_ENCRYPTION_KEY_DERIVATION_SALT') + ) + username = prompt.ask('Username:') do |q| q.required true q.default 'admin' diff --git a/spec/lib/private_address_check_spec.rb b/spec/lib/private_address_check_spec.rb index 20a94983d9..0c02055187 100644 --- a/spec/lib/private_address_check_spec.rb +++ b/spec/lib/private_address_check_spec.rb @@ -4,7 +4,7 @@ require 'rails_helper' RSpec.describe PrivateAddressCheck do describe 'private_address?' do - let(:private_ips) { %w(192.168.1.7 0.0.0.0 127.0.0.1 ::ffff:0.0.0.1) } + let(:private_ips) { %w(192.168.1.7 0.0.0.0 127.0.0.1 ::ffff:0.0.0.1 ::127.0.0.1 ::ffff:127.0.0.1 ::ffff:10.0.0.1 ::ffff:169.254.169.254 ::) } it 'returns true for private addresses' do expect(private_ips) diff --git a/spec/services/activitypub/process_activity_service_spec.rb b/spec/services/activitypub/process_activity_service_spec.rb index 290058efd7..e716571eca 100644 --- a/spec/services/activitypub/process_activity_service_spec.rb +++ b/spec/services/activitypub/process_activity_service_spec.rb @@ -162,6 +162,46 @@ RSpec.describe ActivityPub::ProcessActivityService do expect(ActivityPub::Activity).to_not have_received(:factory) end + context 'when receiving a status with an unsupported JSON-LD keyword' do + let(:payload) do + { + '@context': 'https://www.w3.org/ns/activitystreams', + id: 'foo', + type: 'Announce', + actor: ActivityPub::TagManager.instance.uri_for(actor), + '@reverse': { + object: { + type: 'Undo', + id: 'bar', + actor: ActivityPub::TagManager.instance.uri_for(actor), + }, + }, + object: { + id: 'bar', + type: 'Note', + content: 'Lorem ipsum', + }, + signature: { + type: 'RsaSignature2017', + creator: "#{ActivityPub::TagManager.instance.uri_for(actor)}#foo", + created: '2022-03-09T21:57:25Z', + signatureValue: 'foo', + }, + } + end + + it 'does not process payload' do + signature_double = instance_double(ActivityPub::LinkedDataSignature, verify_actor!: nil) + allow(ActivityPub::LinkedDataSignature).to receive(:new).and_return(signature_double) + allow(ActivityPub::Activity).to receive(:factory) + + subject.call(json, forwarder) + + expect(signature_double).to_not have_received(:verify_actor!) + expect(ActivityPub::Activity).to_not have_received(:factory) + end + end + context 'when receiving a fabricated status' do let!(:actor) do Fabricate(:account, diff --git a/spec/system/admin/email_domain_blocks_spec.rb b/spec/system/admin/email_domain_blocks_spec.rb index 4a54744afd..b86a88a0ff 100644 --- a/spec/system/admin/email_domain_blocks_spec.rb +++ b/spec/system/admin/email_domain_blocks_spec.rb @@ -98,7 +98,7 @@ RSpec.describe 'Admin::EmailDomainBlocks' do end it 'filters by domain' do - fill_in 'domain', with: 'example.com' + fill_in 'by_domain', with: 'example.com' click_on I18n.t('admin.email_domain_blocks.search') expect(page).to have_text('example.com') @@ -106,7 +106,7 @@ RSpec.describe 'Admin::EmailDomainBlocks' do end it 'shows empty page when no such domains are blocked' do - fill_in 'domain', with: 'mydomain.com' + fill_in 'by_domain', with: 'mydomain.com' click_on I18n.t('admin.email_domain_blocks.search') expect(page).to have_no_text('mydomain.com') @@ -114,7 +114,7 @@ RSpec.describe 'Admin::EmailDomainBlocks' do end it 'returns to the list when resetting the search' do - fill_in 'domain', with: 'example.com' + fill_in 'by_domain', with: 'example.com' click_on I18n.t('admin.email_domain_blocks.search') click_on I18n.t('admin.email_domain_blocks.reset') diff --git a/spec/validators/email_address_validator_spec.rb b/spec/validators/email_address_validator_spec.rb new file mode 100644 index 0000000000..1739826909 --- /dev/null +++ b/spec/validators/email_address_validator_spec.rb @@ -0,0 +1,25 @@ +# frozen_string_literal: true + +require 'rails_helper' + +RSpec.describe EmailAddressValidator do + subject { record_class.new } + + context 'with no options' do + let(:record_class) do + Class.new do + include ActiveModel::Validations + + def self.name = 'Record' + + attr_accessor :email + + validates :email, email_address: true + end + end + + it { is_expected.to allow_value('foo@example.com').for(:email) } + it { is_expected.to_not allow_value('foo @ example.com').for(:email) } + it { is_expected.to_not allow_value('foo@example.com%foo.example.com').for(:email) } + end +end