Commit graph

20 commits

Author SHA1 Message Date
Nick Thomas
5b075413d9
Verify that LFS upload requests are genuine
LFS uploads are handled in concert by workhorse and rails. In normal
use, workhorse:

* Authorizes the request with rails (upload_authorize)
* Handles the upload of the file to a tempfile - disk or object storage
* Validates the file size and contents
* Hands off to rails to complete the upload (upload_finalize)

In `upload_finalize`, the LFS object is linked to the project. As LFS
objects are deduplicated across all projects, it may already exist. If
not, the temporary file is copied to the correct place, and will be
used by all future LFS objects with the same OID.

Workhorse uses the Content-Type of the request to decide to follow this
routine, as the URLs are ambiguous. If the Content-Type is anything but
"application/octet-stream", the request is proxied directly to rails,
on the assumption that this is a normal file edit request. If it's an
actual LFS request with a different content-type, however, it is routed
to the Rails `upload_finalize` action, which treats it as an LFS upload
just as it would a workhorse-modified request.

The outcome is that users can upload LFS objects that don't match the
declared size or OID. They can also create links to LFS objects they
don't really own, allowing them to read the contents of files if they
know just the size or OID.

We can close this hole by requiring requests to `upload_finalize` to be
sourced from Workhorse. The mechanism to do this already exists.
2019-01-31 16:52:48 +01:00
gfyoung
12ee2753c1 Enable even more frozen string in app/controllers
Enables frozen string for some vestigial files as
well as the following:

* app/controllers/projects/**/*.rb
* app/controllers/sherlock/**/*.rb
* app/controllers/snippets/**/*.rb
* app/controllers/users/**/*.rb

Partially addresses #47424.
2018-09-25 22:43:49 -07:00
Yorick Peterse
2039c8280d
Disable existing offenses for the CodeReuse cops
This whitelists all existing offenses for the various CodeReuse cops, of
which most are triggered by the CodeReuse/ActiveRecord cop.
2018-09-11 17:32:00 +02:00
Lin Jen-Shin
4ee08b77bc Updates from rubocop -a 2018-07-09 21:13:08 +08:00
Kamil Trzciński
b8370c9f55 Support presigned multipart uploads 2018-06-04 13:04:29 +02:00
Kamil Trzciński
9bb7abedf5 Fix file_store for artifacts and lfs when saving 2018-05-01 22:27:54 +02:00
Kamil Trzciński
678620cce6 Add direct_upload setting for artifacts 2018-04-05 15:01:14 +02:00
Alessio Caiazza
04c5e637f8
Port LFS direct_upload from EE 2018-03-27 10:32:48 +02:00
Micaël Bergeron
b03b31659b fixing some broken merges 2018-03-02 16:19:17 -05:00
Sean McGivern
a7dae52e9d Merge branch '4163-move-uploads-to-object-storage' into 'master'
Move uploads to object storage

Closes #4163

See merge request gitlab-org/gitlab-ee!3867
2018-02-28 20:58:15 +01:00
Kamil Trzciński
965dc28691 Merge commit '7fabc892f251740dbd9a4755baede662e6854870' into object-storage-ee-to-ce-backport 2018-02-28 20:36:55 +01:00
Douwe Maan
bc76062774 Merge branch 'jej/lfs-object-storage' into 'master'
Can migrate LFS objects to S3 style object storage

Closes #2841

See merge request !2760
2018-02-28 20:29:37 +01:00
Jacopo
181cd299f9 Adds Rubocop rule for line break after guard clause
Adds a rubocop rule (with autocorrect) to ensure line break after guard clauses.
2017-11-16 17:58:29 +01:00
Rémy Coutable
4b3c1e56ae
Move LfsHelper to a new LfsRequest concern
Also create a new WorkhorseRequest concern

Signed-off-by: Rémy Coutable <remy@rymai.me>
2016-11-23 17:28:11 +01:00
Jacob Vosmaer
c87540ed46 Verify JWT messages from gitlab-workhorse 2016-09-05 15:05:31 +02:00
Jacob Vosmaer
26b98bfff8 Improve validation of X-Gitlab-Lfs-Tmp header 2016-08-10 17:40:20 +02:00
Jacob Vosmaer
f817eecb22 Use && and || instead of if 2016-08-10 16:49:23 +02:00
Jacob Vosmaer
0012de8c8a Rename lfs_enabled helper method 2016-08-10 16:48:21 +02:00
Jacob Vosmaer
23425401d1 Rubocop 2016-07-22 17:54:04 +02:00
Jacob Vosmaer
0d9752446d Add LFS controllers 2016-07-22 17:54:04 +02:00