Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Remove option to override virus decision

Oliver Günther8ab91f8e745f
diff --git a/app/components/admin/quarantined_attachments/row_component.rb b/app/components/admin/quarantined_attachments/row_component.rb
index efe85f946bf..00290d837ba 100644
--- a/app/components/admin/quarantined_attachments/row_component.rb
+++ b/app/components/admin/quarantined_attachments/row_component.rb
@@ -56,20 +56,7 @@ module Admin
end
def button_links
- [
- override_link,
- delete_link
- ].compact
- end
-
- def override_link
- helpers.link_to(
- helpers.op_icon('icon icon-unlocked'),
- { controller: '/admin/attachments/quarantined_attachments', action: :override, id: model },
- title: I18n.t('antivirus_scan.quarantined_attachments.override'),
- method: :patch,
- data: { confirm: I18n.t(:text_are_you_sure), disable_with: I18n.t(:label_loading) },
- )
+ [delete_link]
end
def delete_link
diff --git a/app/controllers/admin/attachments/quarantined_attachments_controller.rb b/app/controllers/admin/attachments/quarantined_attachments_controller.rb
index f1fd4b6a5dc..758a303814d 100644
--- a/app/controllers/admin/attachments/quarantined_attachments_controller.rb
+++ b/app/controllers/admin/attachments/quarantined_attachments_controller.rb
@@ -33,25 +33,12 @@ module Admin
before_action :require_admin
before_action :find_quarantined_attachments
- before_action :find_attachment, only: %i[override destroy]
+ before_action :find_attachment, only: %i[destroy]
menu_item :attachment_quarantine
def index; end
- def override
- @attachment.status_scanned!
-
- create_journal(@attachment.container,
- current_user,
- I18n.t('antivirus_scan.overridden_by_admin',
- user: current_user.name,
- filename: @attachment.filename))
-
- flash[:notice] = t(:notice_successful_update)
- redirect_to action: :index
- end
-
def destroy
container = @attachment.container
@attachment.destroy!
diff --git a/config/locales/en.yml b/config/locales/en.yml
index 8204eca0370..6f59fc4b91b 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -109,7 +109,6 @@ en:
overridden_by_admin: "The quarantine for file '%{filename}' has been removed by %{user}. The file can now be acccessed."
quarantined_attachments:
container: "Container"
- override: "Override the virus scan and allow downloading the file"
delete: "Delete the quarantined file"
title: "Quarantined attachments"
error_cannot_act_self: "Cannot perform actions on your own uploaded files."
@@ -3019,7 +3018,7 @@ en:
Select the action to perform for files on which a virus has been detected:
<br/>
<ul>
- <li><strong>%{quarantine_option}</strong>: Quarantine the file, preventing users from accessing it. Administrators can manually override the decision or delete the file in the administration.</li>
+ <li><strong>%{quarantine_option}</strong>: Quarantine the file, preventing users from accessing it. Administrators can review and delete quarantined files in the administration.</li>
<li><strong>%{delete_option}</strong>: Delete the file immediately.</li>
</ul>
modes:
diff --git a/config/routes.rb b/config/routes.rb
index 09126987668..e9f8407f52e 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -451,11 +451,7 @@ Rails.application.routes.draw do
resources :quarantined_attachments,
controller: '/admin/attachments/quarantined_attachments',
- only: %i[index destroy] do
- member do
- patch :override
- end
- end
+ only: %i[index destroy]
resource :backups, controller: '/admin/backups', only: %i[show] do
collection do
diff --git a/spec/features/admin/attachments/quarantined_attachments_spec.rb b/spec/features/admin/attachments/quarantined_attachments_spec.rb
index c60fcb218cb..e0058c993aa 100644
--- a/spec/features/admin/attachments/quarantined_attachments_spec.rb
+++ b/spec/features/admin/attachments/quarantined_attachments_spec.rb
@@ -33,9 +33,7 @@ RSpec.describe 'Quarantined attachments', :js, :with_cuprite do
shared_let(:admin) { create(:admin) }
shared_let(:container) { create(:work_package) }
- shared_let(:own_quarantined_attachment) do
- create(:attachment, container:, status: :quarantined, author: admin, filename: 'my-own.txt')
- end
+
shared_let(:quarantined_attachment) do
create(:attachment, container:, status: :quarantined, author: other_author, filename: 'other-1.txt')
end
@@ -50,17 +48,10 @@ RSpec.describe 'Quarantined attachments', :js, :with_cuprite do
it 'allows management other attachments' do
visit admin_quarantined_attachments_path
- expect(page).to have_text 'my-own.txt'
expect(page).to have_text 'other-1.txt'
expect(page).to have_text 'other-2.txt'
- page.within("#quarantined_attachment_#{own_quarantined_attachment.id}") do
- expect(page).to have_no_link I18n.t('antivirus_scan.quarantined_attachments.override')
- expect(page).to have_link I18n.t('antivirus_scan.quarantined_attachments.delete')
- end
-
page.within("#quarantined_attachment_#{quarantined_attachment.id}") do
- expect(page).to have_link I18n.t('antivirus_scan.quarantined_attachments.override')
expect(page).to have_link I18n.t('antivirus_scan.quarantined_attachments.delete')
accept_confirm do
@@ -70,17 +61,7 @@ RSpec.describe 'Quarantined attachments', :js, :with_cuprite do
expect { quarantined_attachment.reload }.to raise_error(ActiveRecord::RecordNotFound)
end
- page.within("#quarantined_attachment_#{other_quarantined_attachment.id}") do
- expect(page).to have_link I18n.t('antivirus_scan.quarantined_attachments.override')
- expect(page).to have_link I18n.t('antivirus_scan.quarantined_attachments.delete')
-
- accept_confirm do
- click_link I18n.t('antivirus_scan.quarantined_attachments.override')
- end
- end
-
- expect(page).to have_text 'my-own.txt'
expect(page).not_to have_text 'other-1.txt'
- expect(page).not_to have_text 'other-2.txt'
+ expect(page).to have_text 'other-2.txt'
end
end
diff --git a/spec/requests/admin/attachments/quarantined_attachments_spec.rb b/spec/requests/admin/attachments/quarantined_attachments_spec.rb
index 3856cb20e2d..c880048050e 100644
--- a/spec/requests/admin/attachments/quarantined_attachments_spec.rb
+++ b/spec/requests/admin/attachments/quarantined_attachments_spec.rb
@@ -61,19 +61,4 @@ RSpec.describe 'Quarantined attachments',
expect(response).to have_http_status :not_found
end
end
-
- describe 'PATCH /admin/quarantined_attachments/:id/override' do
- it 'allows management of attachments' do
- patch override_admin_quarantined_attachment_path(quarantined_attachment)
- expect(response).to be_redirect
-
- quarantined_attachment.reload
- expect(quarantined_attachment).to be_status_scanned
- end
-
- it 'fails to find if not quarantined' do
- patch override_admin_quarantined_attachment_path(scanned_attachment)
- expect(response).to have_http_status :not_found
- end
- end
end