Commit Graph

10590 Commits

Author SHA1 Message Date
evazion
020ed7b735 ci: don't tag short commit hash on Docker images.
Tagging both the long and the short commit hash on images creates too
much clutter in the Github UI.
2021-09-18 05:14:36 -05:00
evazion
52cf13dff1 ci: limit workflow permissions.
Make it so pull requests from outside contributors can't edit workflows
under .github/workflows/ without approval. Also limit workflows to the
minimum permissions necessary.
2021-09-18 04:37:00 -05:00
evazion
39fa2fe02d ci: split docker build workflow from test workflow.
Split up the Github workflow. Instead of one workflow with two jobs, one
to build the Docker image and one to test it, split it into two separate
workflows, one to build and one to test. This way if the Docker build
fails it doesn't try to run the tests, and if the tests fail it only
marks the test workflow as failed, not the entire workflow.

This is especially so the workflows page doesn't show everything as
failing just because the tests failed.

https://github.com/danbooru/danbooru/actions
2021-09-18 01:34:07 -05:00
evazion
cfae1d3b35 Merge pull request #4881 from nottalulah/patch-1
Hide posts not visible to anonymous users from Discord slash commands
2021-09-17 19:18:42 -05:00
evazion
1d4e7ba12f Merge pull request #4855 from nottalulah/lock-moderation
Log mod actions for changes to post locks
2021-09-17 19:06:52 -05:00
Lily
22430f2ec1 Update post_embed.rb 2021-09-17 18:39:56 -03:00
evazion
85d70561e5 rake: change docker build task to buildx. 2021-09-16 02:32:02 -05:00
evazion
965dfaffcf docker: fixup build failure in f359d4476
Forgot to install libarchive-zip-perl.
2021-09-16 02:26:05 -05:00
evazion
313257b771 posts: add exif:<value> search metatags.
Examples:

* https://danbooru.donmai.us/posts?tags=exif:File:ColorComponents
* https://danbooru.donmai.us/posts?tags=exif:GIF:GIFVersion
* https://danbooru.donmai.us/posts?tags=exif:PNG:ColorType

* https://danbooru.donmai.us/posts?tags=exif:PNG:ColorType=RGB
* https://danbooru.donmai.us/posts?tags=exif:GIF:GIFVersion=89a
* https://danbooru.donmai.us/posts?tags=exif:File:ColorComponents=3
2021-09-16 02:13:15 -05:00
evazion
c14e3ec902 Remove staging environment.
We never used any of this stuff. The only environments used are
production, development, and test.
2021-09-16 00:44:26 -05:00
evazion
7e3371f758 docker-compose: use images from Github instead of DockerHub.
Use the Danbooru Docker images from the Github Container Registry
instead of the DockerHub registry for the Compose file. Github is now
considered the canonical source for Danbooru's Docker images. DockerHub
is considered a mirror.

* https://github.com/danbooru/danbooru/pkgs/container/danbooru
* https://hub.docker.com/r/evazion/danbooru
2021-09-16 00:35:30 -05:00
evazion
ea6e47125e metadata: add ability to search exif metadata.
Usage:

* https://danbooru.donmai.us/media_metadata?search[has_metadata]=true
* https://danbooru.donmai.us/media_metadata?search[has_metadata]=false
* https://danbooru.donmai.us/media_metadata?search[metadata_has_key]=GIF:GIFVersion
* https://danbooru.donmai.us/media_metadata?search[metadata][GIF:GIFVersion]=89a
* https://danbooru.donmai.us/media_metadata?search[metadata][GIF:GIFVersion]&search[metadata][GIF:BackgroundColor]=0
2021-09-16 00:25:21 -05:00
evazion
9cc8d8aa4a metadata: add CLI script for printing image metadata
Add a utility script for printing image metadata from the command line.

Usage: `bin/lsmetadata 1.jpg 2.jpg`
2021-09-15 21:39:56 -05:00
evazion
822f72387e metadata: record metadata for corrupt files.
Bug: if ExifTool exited with status 1 because it thought the file was
corrupt, then we didn't record any of the metadata, even though it was
able to read most of it. It turns out there are thousands of posts with
minorly corrupt metadata that ExifTool is still able to read, but will
complain about.

Fix: ignore the exit code of ExifTool and always save whatever metadata
ExifTool is able to return. It will return an `ExifTool:Error` tag in
the event of errors.

Note that there are some (many?) files that are considered corrupt by
ExifTool but not by Vips, and vice versa. Probably because ExifTool only
parses the metadata while Vips only parses the image data.
2021-09-15 20:26:35 -05:00
evazion
f359d44763 metadata: fix failure to get exif data for compressed SWF files.
Fix Exiftool not being able to get the metadata for compressed SWF
files. Exiftool requires Compress::Zlib as an optional dependency to
decompress compressed SWF files, but it wasn't in the Docker image.

Archive::Zip is required for Zip files and Digest::MD5 for certain other
metadata (see "DEPENDENCIES" in exiftool README).
2021-09-15 18:39:42 -05:00
evazion
e16aa7b1c5 Add script to backfill MediaMetadata. 2021-09-15 11:05:45 -05:00
evazion
3b55ca81db Update Procfile.
Usage: `gem install foreman` then `foreman start`.
2021-09-15 06:23:20 -05:00
evazion
16dc017d28 git: add .mailmap file.
Consolidate emails in `git shortlog -e -s -n`.
2021-09-14 21:40:39 -05:00
evazion
ff9a520e29 docker: update Ruby to 2.7.4, FFmpeg to 4.4. 2021-09-14 05:39:18 -05:00
evazion
9552b41c0a Update Ruby gems and Yarn packages. 2021-09-14 05:39:18 -05:00
evazion
34de3b4d18 Merge pull request #4879 from nonamethanks/fix-artist-name
Sources: fix artist_name not being caught in skeb and weibo
2021-09-14 05:39:06 -05:00
nonamethanks
a845477cba Sources: fix artist_name not being caught in skeb and weibo 2021-09-14 11:32:24 +02:00
evazion
f5666fb6f1 Merge pull request #4875 from nonamethanks/lofter-timeout
Lofter: raise timeout for file download
2021-09-14 04:09:12 -05:00
evazion
38e814ddff assets: fix permissions for static images.
Remove execute permission for static images in public/images/.
2021-09-12 10:17:38 -05:00
evazion
4cc8dd41ec puma: add rack-timeout gem.
Unlike Unicorn, Puma doesn't have a builtin HTTP request timeout
mechanism, so we have to use Rack::Timeout instead.

See the caveats in the Rack::Timeout documentation [1]. In Unicorn, a
timeout would send a SIGKILL to the worker, immediately killing it. This
would result in a dropped connection and a Cloudflare 502 error to the
user. In Puma, it raises an exception, which we can catch and return a
better error to the user. On the other hand, raising an exception can
potentially corrupt application state if it's sent at the wrong time, or
be delayed indefinitely if the app is stuck in IO or C extension code.

The default request timeout is 65 seconds. 65 seconds is to give things
like HTTP requests on a 60 second timeout enough time to complete. Set
the RACK_REQUEST_TIMEOUT environment variable to change the timeout.

1: https://github.com/sharpstone/rack-timeout#further-documentation
2021-09-12 09:32:12 -05:00
evazion
23b2a37050 puma: add puma worker killer gem. 2021-09-12 05:51:09 -05:00
evazion
1bb7c50858 posts: unredact file_ext field on hidden posts. 2021-09-12 04:27:49 -05:00
evazion
9bee9223ac docker: add openresty to base image.
Include OpenResty in the base Docker image. This is so we can run
OpenResty in front of Danbooru as a reverse proxy to serve static assets
(CSS, JS, and static images living in public/images).

Including the proxy in the same container as the static assets avoids a
lot of problems with trying to share files across separate containers.
2021-09-12 04:10:33 -05:00
evazion
1fa7114685 docker: add busybox
Add busybox to the base image to add some useful debugging utils inside
the container (e.g. ps, ping, nslookup, traceroute, ip).
2021-09-12 01:08:45 -05:00
evazion
8dbeec4788 tests: fix unit tests. 2021-09-11 20:37:18 -05:00
evazion
eab4e165b1 posts: update safe mode help link.
Change this message:

    2 post(s) on this page were hidden by safe mode. Go to Danbooru or
    disable safe mode to view them (learn more).

To link to [[help:safe mode]] instead of [[help:user settings]].
2021-09-11 19:48:15 -05:00
evazion
0aab81440f puma: add Prometheus metrics exporter.
To test it, run `bin/rails server` then do `curl http://localhost:9393`.

https://github.com/harmjanblok/puma-metrics
2021-09-11 10:09:58 -05:00
evazion
ee1c3c9418 puma: update config.
Update the config for the Puma webserver (used by `bin/rails server`).

* Update default settings.
* Prefix all Puma environment variables with `PUMA_`.
* Enable the Puma control app (`bin/pumactl`).
2021-09-11 10:01:25 -05:00
nonamethanks
9a6a6e52ea Lofter: raise timeout for file download 2021-09-10 13:10:29 +02:00
evazion
8772bc78ec Merge pull request #4865 from nonamethanks/fix-upload-form-submitting-early 2021-09-08 20:31:07 -05:00
nonamethanks
7b817b0a30 Uploads: prevent submission of unfinished uploads 2021-09-08 20:26:53 -05:00
evazion
55d00fc40c paginator: fix showing page 5000 when page count is unknown
Fix a bug where if you did a slow search that took too long to calculate
the page count, and you had 200 posts per page, then we would show page
5000 as the last page of the search.

This was because we were artificially returning 1,000,000 as the post
count to signal that the count timed out, but at 200 posts per page this
would show 5000 as the last page of the search.
2021-09-08 18:33:28 -05:00
evazion
668dd50ea8 tests: fix broken tests. 2021-09-08 06:16:59 -05:00
evazion
3d660953d4 Add MediaMetadata model.
Add a model for storing image and video metadata for uploaded files.

Metadata is extracted using ExifTool. You will need to install ExifTool
after this commit. ExifTool 12.22 is the minimum required version
because we use the `--binary` option, which was added in this release.

The MediaMetadata model is separate from the MediaAsset model because
some files contain tons of metadata, and most of it is non-essential.
The MediaAsset model represents an uploaded file and contains essential
metadata, like the file's size and type, while the MediaMetadata model
represents all the other non-essential metadata associated with a file.

Metadata is stored as a JSON column in the database.

ExifTool returns all the file's metadata, not just the EXIF metadata.
EXIF is one of several types of image metadata, hence why we call
it MediaMetadata instead of EXIFMetadata.
2021-09-08 05:00:54 -05:00
evazion
291758ddb7 ci: push docker images to dockerhub too. 2021-09-07 06:49:19 -05:00
evazion
266192c599 ci: fix docker image not including git hash.
Fix the Docker image not including the git hash of the build. On
DockerHub we had to set it with a build hook, but now with Github we
set it as part of the build-push-action.
2021-09-07 06:34:50 -05:00
evazion
29d5a99fca Add test for #4762: VipsIcc: Couldn't link the profiles" for certain pics
This is broken in libvips-8.9.1 but working in libvips-8.10.6. The fix
is to use the Docker image with the newest version of libvips.
2021-09-07 01:15:41 -05:00
evazion
fb5078836e Fix #4612: Input profile error with greyscale jpg images.
Fix a bug where generating thumbnails failed for certain images when
using libvips 8.10. Specifically, it failed for single-channel greyscale
images and four-channel CMYK images without an embedded color profile.
In these cases we specified an sRGB fallback profile, but under libvips
8.10 this failed because the sRGB profile was incompatible with
single-channel and four-channel images. Before libvips 8.10 this worked,
but as of 8.10 it's a hard error.

The way libvips handles fallback color profiles differs across versions,
so we have to use different arguments for different versions. In 8.7,
vips doesn't have builtin color profiles, so we have to specify our own
manually. In 8.9, it has builtin profiles, so we can omit the import
profile, but we're still required to set the export profile to sRGB,
otherwise it will leave CMYK images as CMYK when generating thumbnails.
In 8.10, we have to _not_ to set the import or export profile to sRGB,
otherwise it will fail with an incompatible profile error when it tries
to convert CMYK images to RGB.

The builtin sRGB profile used by libvips[1] is different than the one we
used previously[2]. The builtin one comes from LCMS[3], whereas ours
came from ArgyllCMS.[4] Not all sRGB profiles are created the same[5],
so this may result in some imperceptible differences in thumbnail
output. The ArgyllCMS profile was used before because it seemed to be
the best one[6], but realistically it probably doesn't matter.

1: https://github.com/libvips/libvips/blob/v8.10.6/libvips/colour/profiles/sRGB.icm
2: 906eec190d/config/sRGB.icm
3: https://www.littlecms.com/
4: https://www.argyllcms.com/
5: https://ninedegreesbelow.com/photography/srgb-profile-comparison.html
6: https://ninedegreesbelow.com/photography/srgb-profile-comparison.html#addendum
2021-09-06 23:04:26 -05:00
evazion
906eec190d ci: run tests inside docker
Run the tests using the Docker image we just built, instead of
installing everything manually and running the tests outside of Docker.
Ensures the Docker image we built really works.
2021-09-06 08:53:26 -05:00
evazion
661368bdcf ci: add github actions debugging with tmate
Usage is to run a workflow manually with debug_enabled on.

https://docs.github.com/en/actions/managing-workflow-runs/manually-running-a-workflow#running-a-workflow
https://github.com/marketplace/actions/debugging-with-tmate
2021-09-06 04:19:52 -05:00
evazion
3202ec8b9a tests: fix broken tests. 2021-09-06 03:25:03 -05:00
evazion
bd4665886f replacements: fix updater in replacement comments.
Second try at fixing replacement comments showing the wrong updater (826736caa).
2021-09-06 03:25:03 -05:00
evazion
3c17defc75 users: don't log mod actions for account upgrades.
Account upgrades are now logged on the /user_upgrades page, so they
no longer need to be recorded as mod actions. The mod actions log should
be reserved for privileged actions performed by Builders and above. They
also tended to spam the mod actions log.
2021-09-06 03:25:03 -05:00
evazion
d03b150180 BURs: fix tag nukes not removing antecedent implications.
Fix a bug where if A implied B, and A was nuked, then the A->B
implication wasn't removed.
2021-09-06 03:25:03 -05:00
evazion
4dcfd1d141 aliases/implications: log manual deletions by admins.
Log when an admin manually deletes an alias or implication outside of a
BUR. This is usually only necessary when a BUR is bugged.
2021-09-06 03:25:02 -05:00