Commit graph

16 commits

Author SHA1 Message Date
GitLab Bot
b71a496c7a Add latest changes from gitlab-org/gitlab@master 2020-04-15 03:09:11 +00:00
GitLab Bot
76e9fc7b29 Add latest changes from gitlab-org/gitlab@master 2020-03-11 18:09:23 +00:00
Alessio Caiazza
e32069ef6c Process workhorse accelerated wiki uploads
Wiki attachments can be workhorse accelerated.
This commit is backward compatible with older workhorse
2019-09-06 15:53:13 +02:00
dineshpanda
e908e11776 Avoid calling freeze on already frozen strings in lib/gitlab 2019-09-04 09:52:02 +05:30
Stan Hu
7d28e39f58 Fix multipart attachments not uploading
Mixing and matching the use of Rack::Request and ActionDispatch::Request
in Rails 5 is bad, particularly if you have middleware that
manipulates or accesses environment variables.

`Gitlab::Middleware::Multipart` attempts to rewrite request parameters
to the proper values (e.g. replacing `data_file` with
`UploadedFile`). It does this by calling `Rack::Request#update_params`,
which essentially updates `env['rack.request.form_hash']`.

By changing to `ActionDispatch::Request`, the Go middleware was causing
the request parameters to be stored inside
`env['action_dispatch.request.request_parameters']`. Later calls to
`Rack::Request#update_params` would not have any effect because it would
attempt to update `env['rack.request.form_has']` instead of
`env['action_dispatch.request.request_parameters']`. As a result, the
controller still saw the old parameters.

Since the Go middleware appears to be using `ActionDispatch::Request`
for authorization methods, we can switch the multipart middleware to
use it too.

Closes https://gitlab.com/gitlab-org/gitlab-ee/issues/9035
2019-01-05 01:56:47 -08:00
gfyoung
7ec8af5017 Enable even more frozen string for lib/gitlab
Enables frozen string for the following:

* lib/gitlab/hook_data/**/*.rb
* lib/gitlab/i18n/**/*.rb
* lib/gitlab/import/**/*.rb
* lib/gitlab/import_export/**/*.rb
* lib/gitlab/kubernetes/**/*.rb
* lib/gitlab/legacy_github_import/**/*.rb
* lib/gitlab/manifest_import/**/*.rb
* lib/gitlab/metrics/**/*.rb
* lib/gitlab/middleware/**/*.rb

Partially addresses gitlab-org/gitlab-ce#47424.
2018-11-16 17:41:14 -08:00
Andrew Newdigate
647db32396 Fix multipart error on rails reload 2018-09-05 18:00:11 +00:00
Jan Provaznik
4ca9f3b417 Add public/uploads/tmp to allowed upload paths
When direct_upload is enabled and a for file is being uploaded,
then workhorse uses `public/uploads/tmp` path. If `uploads.storage_path`
i sset to a different directory, then upload fails because
`public/uploads/tmp` is not in allowed paths.
2018-08-21 17:39:46 +02:00
Jan Provaznik
e2ec97a92e Add FileUploader.root to allowed upload paths
Currently we check if uploaded file is under
`Gitlab.config.uploads.storage_path`, the problem is that
uploads are placed in `uploads` subdirectory which is symlink.

In allow_path? method we check real (expanded) paths, which causes
that `Gitlab.config.uploads.storage_path` is expaned into symlink
path and there is a mismatch with upload file path.

By adding `Gitlab.config.uploads.storage_path/uploads` into allowed
paths, this path is expaned during path check.

`Gitlab.config.uploads.storage_path` is left there intentionally in case
some uploader wouldn't use `uploads` subdir.
2018-07-08 10:43:57 +02:00
Jan Provaznik
249c24891a Updated multipart to support workhorse direct uploads 2018-06-27 12:54:46 +02:00
Kamil Trzciński
678620cce6 Add direct_upload setting for artifacts 2018-04-05 15:01:14 +02:00
Alessio Caiazza
34c2a59c57
Honour workhorse provided file name
In the attempt to unify file uploading at workhorse level gitlab-org/gitlab-workhorse!230
we moved to a prefix-based tempfile creation in order to avoid upload collisions.

Artifacts and LFS uploads already set original_filename to workhorse provided filename

This commit add the same feature to `Gitlab::Middleware::Multipart`
2018-02-12 17:31:29 +01:00
🙈 jacopo beschi 🙉
729f05f0e3 Adds Rubocop rule for line break around conditionals 2018-01-11 16:34:01 +00:00
Douwe Maan
b7d8df503c Enable Style/MutableConstant 2017-02-23 09:31:56 -06:00
Jacob Vosmaer
4ec259fd36 Inject ::UploadedFile from Multipart middleware
I mistakenly concluded Rack::Multipart injects File instances into the
params. These should be UploadedFile instances. This reuses a mock
UploadedFile class we already had in GitLab.
2016-12-21 13:07:53 +01:00
Jacob Vosmaer
6731ab5d76 Add Gitlab::Middleware::Multipart 2016-12-15 12:26:36 +01:00