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

Enterprise check for antivirus administration

Oliver Günther6ba79c96ec76
diff --git a/app/controllers/admin/settings/virus_scanning_settings_controller.rb b/app/controllers/admin/settings/virus_scanning_settings_controller.rb
index c8bdebed523..bfb74d7981e 100644
--- a/app/controllers/admin/settings/virus_scanning_settings_controller.rb
+++ b/app/controllers/admin/settings/virus_scanning_settings_controller.rb
@@ -30,10 +30,11 @@ module Admin::Settings
class VirusScanningSettingsController < ::Admin::SettingsController
menu_item :settings_attachments
+ before_action :require_ee
before_action :check_clamav, only: %i[update]
def default_breadcrumb
- t(:'virus_scanning.title')
+ t('settings.antivirus.title')
end
def av_form
@@ -50,6 +51,10 @@ module Admin::Settings
private
+ def require_ee
+ render('upsale') unless EnterpriseToken.allows_to?(:virus_scanning)
+ end
+
def check_clamav
return if params[:settings].blank?
return if params[:settings][:antivirus_scan_mode] == "disabled"
diff --git a/app/models/attachment.rb b/app/models/attachment.rb
index 9f5db90bbc8..cd5e932053e 100644
--- a/app/models/attachment.rb
+++ b/app/models/attachment.rb
@@ -133,7 +133,7 @@ class Attachment < ApplicationRecord
end
def pending_virus_scan?
- status_uploaded? && Setting.antivirus_scan_mode != :disabled
+ status_uploaded? && Setting::VirusScanning.enabled?
end
# images are sent inline
diff --git a/app/models/setting/virus_scanning.rb b/app/models/setting/virus_scanning.rb
new file mode 100644
index 00000000000..91161f54fbf
--- /dev/null
+++ b/app/models/setting/virus_scanning.rb
@@ -0,0 +1,35 @@
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 2012-2024 the OpenProject GmbH
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License version 3.
+#
+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
+# Copyright (C) 2006-2013 Jean-Philippe Lang
+# Copyright (C) 2010-2013 the ChiliProject Team
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# See COPYRIGHT and LICENSE files for more details.
+#++
+
+class Setting
+ module VirusScanning
+ def self.enabled?
+ Setting.antivirus_scan_mode != :disabled && EnterpriseToken.allows_to?(:virus_scanning)
+ end
+ end
+end
diff --git a/app/services/authorization/enterprise_service.rb b/app/services/authorization/enterprise_service.rb
index 45706430c01..b8c92cd9957 100644
--- a/app/services/authorization/enterprise_service.rb
+++ b/app/services/authorization/enterprise_service.rb
@@ -48,6 +48,7 @@ class Authorization::EnterpriseService
work_package_query_relation_columns
work_package_sharing
one_drive_sharepoint_file_storage
+ virus_scanning
).freeze
def initialize(token)
diff --git a/app/views/admin/settings/virus_scanning_settings/upsale.html.erb b/app/views/admin/settings/virus_scanning_settings/upsale.html.erb
new file mode 100644
index 00000000000..afd13680889
--- /dev/null
+++ b/app/views/admin/settings/virus_scanning_settings/upsale.html.erb
@@ -0,0 +1,37 @@
+<%#-- copyright
+OpenProject is an open source project management software.
+Copyright (C) 2012-2024 the OpenProject GmbH
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License version 3.
+
+OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
+Copyright (C) 2006-2013 Jean-Philippe Lang
+Copyright (C) 2010-2013 the ChiliProject Team
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+See COPYRIGHT and LICENSE files for more details.
+
+++#%>
+
+<% html_title t(:label_administration), t('settings.antivirus.title') %>
+
+<%= render template: 'common/upsale',
+ locals: {
+ feature_title: t('settings.antivirus.title'),
+ feature_description: t('settings.antivirus.upsale.description'),
+ feature_reference: 'antivirus_scanning'
+ } %>
diff --git a/app/workers/attachments/virus_scan_job.rb b/app/workers/attachments/virus_scan_job.rb
index 2072275410f..65392f2fb0e 100644
--- a/app/workers/attachments/virus_scan_job.rb
+++ b/app/workers/attachments/virus_scan_job.rb
@@ -36,7 +36,7 @@ module Attachments
queue_with_priority :low
def perform(attachment)
- return if Setting.antivirus_scan_mode == :disabled
+ return unless Setting::VirusScanning.enabled?
return unless attachment.status_uploaded?
User.execute_as(User.system) do
diff --git a/config/initializers/menus.rb b/config/initializers/menus.rb
index cb04a51a569..0f168831f64 100644
--- a/config/initializers/menus.rb
+++ b/config/initializers/menus.rb
@@ -360,6 +360,7 @@ Redmine::MenuManager.map :admin_menu do |menu|
{ controller: '/admin/settings/virus_scanning_settings', action: :show },
caption: :'settings.antivirus.title',
parent: :settings_attachments,
+ enterprise_feature: 'virus_scanning',
if: Proc.new { User.current.admin? }
menu.push :attachment_quarantine,
diff --git a/config/locales/en.yml b/config/locales/en.yml
index d2e7c31e384..de8c49e1149 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -3001,6 +3001,8 @@ en:
antivirus:
title: "Virus scanning"
clamav_ping_failed: "Failed to connect the the ClamAV daemon. Double-check the configuration and try again."
+ upsale:
+ description: "Ensure uploaded files in OpenProject are scanned for viruses before being accessible by other users."
remaining_quarantined_files_html: >
You have successfully disabled virus scanning.
There are however still %{file_count} in quarantine.