debian-mirror-gitlab/doc/administration/raketasks/uploads/sanitize.md

76 lines
3.5 KiB
Markdown
Raw Normal View History

2021-01-29 00:20:46 +05:30
---
2022-07-23 23:45:48 +05:30
stage: Systems
2021-02-22 17:27:13 +05:30
group: Distribution
info: To determine the technical writer assigned to the Stage/Group associated with this page, see https://about.gitlab.com/handbook/engineering/ux/technical-writing/#assignments
2021-01-29 00:20:46 +05:30
---
2021-03-11 19:13:27 +05:30
# Uploads sanitize Rake tasks **(FREE SELF)**
2020-05-24 23:13:21 +05:30
2021-01-03 14:25:43 +05:30
In GitLab 11.9 and later, EXIF data is automatically stripped from JPG or TIFF image uploads.
2020-05-24 23:13:21 +05:30
EXIF data may contain sensitive information (for example, GPS location), so you
can remove EXIF data from existing images that were uploaded to an earlier version of GitLab.
2019-04-03 18:18:56 +05:30
## Requirements
2020-05-24 23:13:21 +05:30
To run this Rake task, you need `exiftool` installed on your system. If you installed GitLab:
2019-04-03 18:18:56 +05:30
2019-09-30 21:07:59 +05:30
- Using the Omnibus package, you're all set.
- From source, make sure `exiftool` is installed:
2019-04-03 18:18:56 +05:30
2020-03-13 15:44:24 +05:30
```shell
2019-09-30 21:07:59 +05:30
# Debian/Ubuntu
sudo apt-get install libimage-exiftool-perl
2019-04-03 18:18:56 +05:30
2019-09-30 21:07:59 +05:30
# RHEL/CentOS
sudo yum install perl-Image-ExifTool
```
2019-04-03 18:18:56 +05:30
## Remove EXIF data from existing uploads
2020-05-24 23:13:21 +05:30
To remove EXIF data from existing uploads, run the following command:
2019-04-03 18:18:56 +05:30
2020-03-13 15:44:24 +05:30
```shell
2019-04-03 18:18:56 +05:30
sudo RAILS_ENV=production -u git -H bundle exec rake gitlab:uploads:sanitize:remove_exif
```
2020-05-24 23:13:21 +05:30
By default, this command runs in "dry run" mode and doesn't remove EXIF data. It can be used for
2019-04-03 18:18:56 +05:30
checking if (and how many) images should be sanitized.
2020-04-22 19:07:51 +05:30
The Rake task accepts following parameters.
2019-04-03 18:18:56 +05:30
2020-05-24 23:13:21 +05:30
| Parameter | Type | Description |
|:-------------|:--------|:----------------------------------------------------------------------------------------------------------------------------|
2021-02-22 17:27:13 +05:30
| `start_id` | integer | Only uploads with equal or greater ID are processed |
| `stop_id` | integer | Only uploads with equal or smaller ID are processed |
2020-05-24 23:13:21 +05:30
| `dry_run` | boolean | Do not remove EXIF data, only check if EXIF data are present or not. Defaults to `true` |
| `sleep_time` | float | Pause for number of seconds after processing each image. Defaults to 0.3 seconds |
| `uploader` | string | Run sanitization only for uploads of the given uploader: `FileUploader`, `PersonalFileUploader`, or `NamespaceFileUploader` |
| `since` | date | Run sanitization only for uploads newer than given date. For example, `2019-05-01` |
2019-04-03 18:18:56 +05:30
2020-05-24 23:13:21 +05:30
If you have too many uploads, you can speed up sanitization by:
2019-04-03 18:18:56 +05:30
2020-05-24 23:13:21 +05:30
- Setting `sleep_time` to a lower value.
- Running multiple Rake tasks in parallel, each with a separate range of upload IDs (by setting
`start_id` and `stop_id`).
To remove EXIF data from all uploads, use:
2019-04-03 18:18:56 +05:30
2020-03-13 15:44:24 +05:30
```shell
2019-04-03 18:18:56 +05:30
sudo RAILS_ENV=production -u git -H bundle exec rake gitlab:uploads:sanitize:remove_exif[,,false,] 2>&1 | tee exif.log
```
2020-05-24 23:13:21 +05:30
To remove EXIF data on uploads with an ID between 100 and 5000 and pause for 0.1 second after each file, use:
2019-04-03 18:18:56 +05:30
2020-03-13 15:44:24 +05:30
```shell
2019-04-03 18:18:56 +05:30
sudo RAILS_ENV=production -u git -H bundle exec rake gitlab:uploads:sanitize:remove_exif[100,5000,false,0.1] 2>&1 | tee exif.log
```
2021-02-22 17:27:13 +05:30
The output is written into an `exif.log` file because it is often long.
2020-05-24 23:13:21 +05:30
If sanitization fails for an upload, an error message should be in the output of the Rake task.
Typical reasons include that the file is missing in the storage or it's not a valid image.
2019-04-03 18:18:56 +05:30
2020-06-23 00:09:42 +05:30
[Report](https://gitlab.com/gitlab-org/gitlab/-/issues/new) any issues and use the prefix 'EXIF' in
2020-05-24 23:13:21 +05:30
the issue title with the error output and (if possible) the image.