Skip to content

Commit 4933a83

Browse files
Release OpenProject 11.4.0
2 parents 5be82c4 + 6023150 commit 4933a83

File tree

335 files changed

+5892
-21236
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

335 files changed

+5892
-21236
lines changed

.pkgr.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ targets:
1313
- imagemagick
1414
debian-10:
1515
<<: *debian9
16+
debian-11:
17+
<<: *debian9
1618
ubuntu-16.04:
1719
<<: *debian9
1820
ubuntu-18.04:

Gemfile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ gem 'unicorn'
170170

171171
gem 'puma', '~> 5.3.0' # used for development and optionally for production
172172

173-
gem 'nokogiri', '~> 1.11.0'
173+
gem 'nokogiri', '~> 1.12.5'
174174

175175
gem 'carrierwave', '~> 1.3.1'
176176
gem 'carrierwave_direct', '~> 2.1.0'
@@ -180,7 +180,7 @@ gem 'aws-sdk-core', '~> 3.107'
180180
# File upload via fog + screenshots on travis
181181
gem 'aws-sdk-s3', '~> 1.91'
182182

183-
gem 'openproject-token', '~> 2.1.1'
183+
gem 'openproject-token', '~> 2.2'
184184

185185
gem 'plaintext', '~> 0.3.2'
186186

@@ -295,6 +295,7 @@ gem 'bootsnap', '~> 1.7.0', require: false
295295

296296
# API gems
297297
gem 'grape', '~> 1.5.0'
298+
gem 'grape_logging', '~> 1.8.4'
298299
gem 'roar', '~> 1.1.0'
299300

300301
# CORS for API

Gemfile.lock

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -511,6 +511,9 @@ GEM
511511
mustermann-grape (~> 1.0.0)
512512
rack (>= 1.3.0)
513513
rack-accept
514+
grape_logging (1.8.4)
515+
grape
516+
rack
514517
gravatar_image_tag (1.2.0)
515518
hashdiff (1.0.1)
516519
hashery (2.1.2)
@@ -587,7 +590,7 @@ GEM
587590
mime-types-data (3.2021.0225)
588591
mini_magick (4.11.0)
589592
mini_mime (1.0.3)
590-
mini_portile2 (2.5.1)
593+
mini_portile2 (2.6.1)
591594
minisyntax (0.2.5)
592595
minitest (5.14.4)
593596
mixlib-shellout (2.1.0)
@@ -604,8 +607,8 @@ GEM
604607
newrelic_rpm (7.0.0)
605608
nio4r (2.5.7)
606609
no_proxy_fix (0.1.2)
607-
nokogiri (1.11.4)
608-
mini_portile2 (~> 2.5.0)
610+
nokogiri (1.12.5)
611+
mini_portile2 (~> 2.6.1)
609612
racc (~> 1.4)
610613
nokogumbo (2.0.5)
611614
nokogiri (~> 1.8, >= 1.8.4)
@@ -628,7 +631,7 @@ GEM
628631
validate_email
629632
validate_url
630633
webfinger (>= 1.0.1)
631-
openproject-token (2.1.3)
634+
openproject-token (2.2.0)
632635
activemodel
633636
parallel (1.20.1)
634637
parallel_tests (3.7.0)
@@ -1003,6 +1006,7 @@ DEPENDENCIES
10031006
fuubar (~> 2.5.0)
10041007
gon (~> 6.4.0)
10051008
grape (~> 1.5.0)
1009+
grape_logging (~> 1.8.4)
10061010
grids!
10071011
html-pipeline (~> 2.14.0)
10081012
htmldiff
@@ -1020,7 +1024,7 @@ DEPENDENCIES
10201024
my_page!
10211025
net-ldap (~> 0.17.0)
10221026
newrelic_rpm
1023-
nokogiri (~> 1.11.0)
1027+
nokogiri (~> 1.12.5)
10241028
oj (~> 3.11.0)
10251029
okcomputer (~> 1.18.1)
10261030
omniauth!
@@ -1042,7 +1046,7 @@ DEPENDENCIES
10421046
openproject-pdf_export!
10431047
openproject-recaptcha!
10441048
openproject-reporting!
1045-
openproject-token (~> 2.1.1)
1049+
openproject-token (~> 2.2)
10461050
openproject-translations!
10471051
openproject-two_factor_authentication!
10481052
openproject-webhooks!
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
#-- encoding: UTF-8
2+
3+
#-- copyright
4+
# OpenProject is an open source project management software.
5+
# Copyright (C) 2012-2021 the OpenProject GmbH
6+
#
7+
# This program is free software; you can redistribute it and/or
8+
# modify it under the terms of the GNU General Public License version 3.
9+
#
10+
# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
11+
# Copyright (C) 2006-2013 Jean-Philippe Lang
12+
# Copyright (C) 2010-2013 the ChiliProject Team
13+
#
14+
# This program is free software; you can redistribute it and/or
15+
# modify it under the terms of the GNU General Public License
16+
# as published by the Free Software Foundation; either version 2
17+
# of the License, or (at your option) any later version.
18+
#
19+
# This program is distributed in the hope that it will be useful,
20+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
21+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22+
# GNU General Public License for more details.
23+
#
24+
# You should have received a copy of the GNU General Public License
25+
# along with this program; if not, write to the Free Software
26+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
27+
#
28+
# See docs/COPYRIGHT.rdoc for more details.
29+
#++
30+
31+
module Attachments
32+
class CreateContract < ::ModelContract
33+
attribute :file
34+
attribute :filename
35+
attribute :filesize
36+
attribute :digest
37+
attribute :description
38+
attribute :content_type
39+
attribute :container
40+
attribute :container_type
41+
attribute :author
42+
43+
validates :filename, presence: true
44+
45+
validate :validate_attachments_addable
46+
validate :validate_container_addable
47+
validate :validate_author
48+
validate :validate_content_type
49+
50+
private
51+
52+
def validate_attachments_addable
53+
return if model.container
54+
55+
if Redmine::Acts::Attachable.attachables.none?(&:attachments_addable?)
56+
errors.add(:base, :error_unauthorized)
57+
end
58+
end
59+
60+
def validate_author
61+
unless model.author == user
62+
errors.add(:author, :invalid)
63+
end
64+
end
65+
66+
def validate_container_addable
67+
return unless model.container
68+
69+
errors.add(:base, :error_unauthorized) unless model.container.attachments_addable?(user)
70+
end
71+
72+
##
73+
# Validates the content type, if a whitelist is set
74+
def validate_content_type
75+
# If the whitelist is empty, assume all files are allowed
76+
# as before
77+
unless matches_whitelist?(attachment_whitelist)
78+
Rails.logger.info { "Uploaded file #{model.filename} with type #{model.content_type} does not match whitelist" }
79+
errors.add :content_type, :not_whitelisted, value: model.content_type
80+
end
81+
end
82+
83+
##
84+
# Get the user-defined whitelist or a custom whitelist
85+
# defined for this invocation
86+
def attachment_whitelist
87+
Array(options.fetch(:whitelist, Setting.attachment_whitelist))
88+
end
89+
90+
##
91+
# Returns whether the attachment matches the whitelist
92+
def matches_whitelist?(whitelist)
93+
return true if whitelist.empty?
94+
95+
whitelist.include?(model.content_type) || whitelist.include?("*#{model.extension}")
96+
end
97+
end
98+
end
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#-- encoding: UTF-8
2+
3+
#-- copyright
4+
# OpenProject is an open source project management software.
5+
# Copyright (C) 2012-2021 the OpenProject GmbH
6+
#
7+
# This program is free software; you can redistribute it and/or
8+
# modify it under the terms of the GNU General Public License version 3.
9+
#
10+
# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
11+
# Copyright (C) 2006-2013 Jean-Philippe Lang
12+
# Copyright (C) 2010-2013 the ChiliProject Team
13+
#
14+
# This program is free software; you can redistribute it and/or
15+
# modify it under the terms of the GNU General Public License
16+
# as published by the Free Software Foundation; either version 2
17+
# of the License, or (at your option) any later version.
18+
#
19+
# This program is distributed in the hope that it will be useful,
20+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
21+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22+
# GNU General Public License for more details.
23+
#
24+
# You should have received a copy of the GNU General Public License
25+
# along with this program; if not, write to the Free Software
26+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
27+
#
28+
# See docs/COPYRIGHT.rdoc for more details.
29+
#++
30+
31+
module Attachments
32+
class PrepareUploadContract < CreateContract
33+
validate :validate_direct_uploads_active
34+
35+
private
36+
37+
def validate_direct_uploads_active
38+
errors.add :base, :not_available unless OpenProject::Configuration.direct_uploads?
39+
end
40+
end
41+
end

app/contracts/base_contract.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def property(name, options = {}, &block)
8282
end
8383

8484
def attribute(attribute, options = {}, &block)
85-
property attribute
85+
property attribute, options.slice(:readable)
8686

8787
add_writable(attribute, options[:writeable])
8888
attribute_permission(attribute, options[:permission])
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#-- copyright
2+
# OpenProject is an open source project management software.
3+
# Copyright (C) 2012-2021 the OpenProject GmbH
4+
#
5+
# This program is free software; you can redistribute it and/or
6+
# modify it under the terms of the GNU General Public License version 3.
7+
#
8+
# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
9+
# Copyright (C) 2006-2013 Jean-Philippe Lang
10+
# Copyright (C) 2010-2013 the ChiliProject Team
11+
#
12+
# This program is free software; you can redistribute it and/or
13+
# modify it under the terms of the GNU General Public License
14+
# as published by the Free Software Foundation; either version 2
15+
# of the License, or (at your option) any later version.
16+
#
17+
# This program is distributed in the hope that it will be useful,
18+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
19+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20+
# GNU General Public License for more details.
21+
#
22+
# You should have received a copy of the GNU General Public License
23+
# along with this program; if not, write to the Free Software
24+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
25+
#
26+
# See docs/COPYRIGHT.rdoc for more details.
27+
#++
28+
29+
module WikiPages
30+
class UpdateContract < BaseContract
31+
end
32+
end

lib/api/v3/attachments/attachment_metadata_representer.rb renamed to app/controllers/admin/settings/attachments_settings_controller.rb

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -28,28 +28,19 @@
2828
# See docs/COPYRIGHT.rdoc for more details.
2929
#++
3030

31-
require 'roar/decorator'
32-
require 'roar/json/hal'
31+
module Admin::Settings
32+
class AttachmentsSettingsController < ::Admin::SettingsController
33+
menu_item :settings_attachments
3334

34-
module API
35-
module V3
36-
module Attachments
37-
class AttachmentMetadataRepresenter < ::API::Decorators::Single
38-
def initialize(attachment)
39-
super(attachment, current_user: nil)
40-
end
35+
def default_breadcrumb
36+
t(:'attributes.attachments')
37+
end
4138

42-
property :file_name
43-
property :description,
44-
getter: ->(*) {
45-
::API::Decorators::Formattable.new(description, plain: true)
46-
},
47-
setter: ->(fragment:, **) { self.description = fragment['raw'] },
48-
render_nil: true
39+
private
4940

50-
property :content_type, render_nil: false
51-
property :file_size, render_nil: false
52-
property :digest, render_nil: false
41+
def settings_params
42+
super.tap do |settings|
43+
settings["attachment_whitelist"] = settings["attachment_whitelist"].split(/\r?\n/)
5344
end
5445
end
5546
end
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
#-- copyright
2+
# OpenProject is an open source project management software.
3+
# Copyright (C) 2012-2021 the OpenProject GmbH
4+
#
5+
# This program is free software; you can redistribute it and/or
6+
# modify it under the terms of the GNU General Public License version 3.
7+
#
8+
# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
9+
# Copyright (C) 2006-2013 Jean-Philippe Lang
10+
# Copyright (C) 2010-2013 the ChiliProject Team
11+
#
12+
# This program is free software; you can redistribute it and/or
13+
# modify it under the terms of the GNU General Public License
14+
# as published by the Free Software Foundation; either version 2
15+
# of the License, or (at your option) any later version.
16+
#
17+
# This program is distributed in the hope that it will be useful,
18+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
19+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20+
# GNU General Public License for more details.
21+
#
22+
# You should have received a copy of the GNU General Public License
23+
# along with this program; if not, write to the Free Software
24+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
25+
#
26+
# See docs/COPYRIGHT.rdoc for more details.
27+
#++
28+
29+
module AttachableServiceCall
30+
##
31+
# Call the presented CreateContract service
32+
# with the given params, merging in any attachment params
33+
#
34+
# @param service_cls the service class instance
35+
# @param args permitted args for the service call
36+
def attachable_create_call(service_cls, args:)
37+
service_cls
38+
.new(user: current_user)
39+
.call(args.merge(attachment_params))
40+
end
41+
42+
##
43+
# Call the presented UpdateContract service
44+
# with the given params, merging in any attachment params
45+
#
46+
# @param service_cls the service class instance
47+
# @param args permitted args for the service call
48+
def attachable_update_call(service_cls, model:, args:)
49+
service_cls
50+
.new(user: current_user, model: model)
51+
.call(args.merge(attachment_params))
52+
end
53+
54+
##
55+
# Attachable parameters mapped to a format the
56+
# SetReplacements service concern
57+
def attachment_params
58+
attachment_params = permitted_params.attachments.to_h
59+
60+
if attachment_params.any?
61+
{ attachment_ids: attachment_params.values.map(&:values).flatten }
62+
else
63+
{}
64+
end
65+
end
66+
end

0 commit comments

Comments
 (0)