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
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
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.rbindex 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::Settingsclass VirusScanningSettingsController < ::Admin::SettingsControllermenu_item :settings_attachments+ before_action :require_eebefore_action :check_clamav, only: %i[update]def default_breadcrumb- t(:'virus_scanning.title')+ t('settings.antivirus.title')enddef av_form@@ -50,6 +51,10 @@ module Admin::Settingsprivate+ def require_ee+ render('upsale') unless EnterpriseToken.allows_to?(:virus_scanning)+ end+def check_clamavreturn if params[:settings].blank?return if params[:settings][:antivirus_scan_mode] == "disabled"diff --git a/app/models/attachment.rb b/app/models/attachment.rbindex 9f5db90bbc8..cd5e932053e 100644--- a/app/models/attachment.rb+++ b/app/models/attachment.rb@@ -133,7 +133,7 @@ class Attachment < ApplicationRecordenddef pending_virus_scan?- status_uploaded? && Setting.antivirus_scan_mode != :disabled+ status_uploaded? && Setting::VirusScanning.enabled?end# images are sent inlinediff --git a/app/models/setting/virus_scanning.rb b/app/models/setting/virus_scanning.rbnew file mode 100644index 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+enddiff --git a/app/services/authorization/enterprise_service.rb b/app/services/authorization/enterprise_service.rbindex 45706430c01..b8c92cd9957 100644--- a/app/services/authorization/enterprise_service.rb+++ b/app/services/authorization/enterprise_service.rb@@ -48,6 +48,7 @@ class Authorization::EnterpriseServicework_package_query_relation_columnswork_package_sharingone_drive_sharepoint_file_storage+ virus_scanning).freezedef 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.erbnew file mode 100644index 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.rbindex 2072275410f..65392f2fb0e 100644--- a/app/workers/attachments/virus_scan_job.rb+++ b/app/workers/attachments/virus_scan_job.rb@@ -36,7 +36,7 @@ module Attachmentsqueue_with_priority :lowdef perform(attachment)- return if Setting.antivirus_scan_mode == :disabled+ return unless Setting::VirusScanning.enabled?return unless attachment.status_uploaded?User.execute_as(User.system) dodiff --git a/config/initializers/menus.rb b/config/initializers/menus.rbindex 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.ymlindex 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.