Commit Graph

114 Commits

Author SHA1 Message Date
evazion
2e407fa476 rails: update defaults from 5.1 to 5.2.
protect_from_forgery removed from because it's now on by default.

ref: https://edgeguides.rubyonrails.org/configuring.html
2019-08-22 22:09:05 -05:00
evazion
1292e73931 Fix errors on HEAD requests to various index pages.
Various search forms try to do `params[:search][:blah]`, which failed
for HEAD requests because we didn't normalize the `search` param.
2019-08-21 23:37:46 -05:00
evazion
d657624a80 Revert "application controller: fix errors in normalize_search."
This reverts commit 28a88cfa85.
2019-08-14 01:46:43 -05:00
evazion
00239c4901 favorites: fix error handling.
* Return HTTP 422 instead of HTTP 500 on "You have already favorited
  this post" errors.

* Log unexpected errors in Ajax requests to the console.
2019-08-13 21:30:20 -05:00
evazion
28a88cfa85 application controller: fix errors in normalize_search.
Fix exceptions in `normalize_search` on e.g. `https://danbooru.donmai.us/users?search=blah`.
Caused when the `search` param is not a hash.
2019-08-13 21:30:20 -05:00
evazion
d7fce22ee5 application controller: rescue Post::SearchError.
Raised when a member does a >2 tag search.
2019-08-13 21:30:20 -05:00
evazion
e70cae457d application controller: clean up exception handling.
* Simplify code.
* Show backtraces for all users, not just builders.
* Show backtraces only for unexpected server errors (status 5xx), not
  for normal client errors (status 4xx).
* Log expected errors at info level (reduce noise in production logs).
2019-08-13 21:30:20 -05:00
evazion
48a4f3c26c application controller: catch more common exceptions. 2019-08-08 22:16:39 -05:00
evazion
9a6add9730 newrelic: refactor error logging.
* Factor out New Relic logging to DanbooruLogger class.
* Log all exceptions to New Relic, not just statement timeouts.
2019-08-08 22:16:39 -05:00
evazion
35dfc704bc application controller: fix bad file extension errors.
Fix requests with bad file extensions not always returning errors correctly:

* https://danbooru.donmai.us/posts.jpg
* https://danbooru.donmai.us/posts.blah
* https://danbooru.donmai.us/posts/bad.jpg
* https://danbooru.donmai.us/posts/bad.blah
2019-08-08 22:16:39 -05:00
evazion
083283906e application controller: remove unused secure_cookies_check. 2019-08-08 14:00:46 -05:00
evazion
06ad1cbbc1 Fix #3685: Bare layout for error pages. 2019-08-05 11:03:10 -05:00
Albert Yi
a12f6badde add RequestStore gem, support universal only param for api endpoints (fixes #4068) 2019-04-17 12:00:42 -07:00
evazion
6148cb39a2 Fix nested blank search params not being stripped from searches.
From https://danbooru.donmai.us/forum_topics/9127?page=258#forum_post_151308:

    When you do a user search (from https://danbooru.donmai.us/users/search)
    the results only include those with someone in the inviter field.

The bug was that nested blank search params (/users?search[inviter][name_matches]=)
didn't get stripped from the search.
2018-10-17 16:11:44 -05:00
evazion
de10ea66a1 <role>_only: fix role checking logic to check ip bans last.
Make <role>_only methods check the role first and ip bans last. This
avoids hitting the database for anonymous users, since they'll always
fail the is_<role>? check before the ip check.
2018-09-09 21:53:24 -05:00
evazion
05ad112831 Fix #3835: Related tags update vulnerability.
Also fixes deprecated call to `render :text`.
2018-08-24 12:16:23 -05:00
Albert Yi
0314dc9751 more consistent behavior of CurrentUser.root_url 2018-08-15 16:08:10 -07:00
Albert Yi
df6e86551a tweaks to similar posts 2018-07-20 15:05:51 -07:00
Albert Yi
6fb20fca89 bug fixes with storage manager 2018-07-20 14:47:58 -07:00
Albert Yi
dd6848912c change render nothing calls to head ok 2018-06-04 10:18:52 -07:00
Albert Yi
72f319ccf3 rename lambda references to use shorthand syntax 2018-05-10 11:18:02 -07:00
evazion
6b4a345378 rails 5: replace redirect_to :back with redirect_back
ref: https://blog.bigbinary.com/2016/02/29/rails-5-improves-redirect_to_back-with-redirect-back.html
2018-04-28 12:24:36 -05:00
Albert Yi
f2b525a6d2 Implement forum topic voting and tag change pruning (#3580) 2018-04-26 15:31:06 -07:00
Albert Yi
eddc789df2 fix js bugs 2018-04-26 15:01:57 -07:00
evazion
e772de40a7 posts: add /posts/{id}.html?variant=tooltip template. 2018-04-25 22:12:26 -05:00
evazion
d70a0a64bd Remove controller-level force_ssl checks.
Obsoleted by force_ssl being globally enabled by default.
2018-04-19 00:49:50 -05:00
Albert Yi
d9d98f05c2 Merge branch 'rails-5.1' 2018-04-11 11:40:36 -07:00
evazion
1b14545d0d Fix #3603: Unable to view images on Hijiribe/Sonohara when Danbooru domain is blocked. 2018-04-06 21:25:14 -05:00
r888888888
abce4d2551 Raise error on unpermitted params.
Fail loudly if we forget to whitelist a param instead of silently
ignoring it.

misc models: convert to strong params.

artist commentaries: convert to strong params.

* Disallow changing or setting post_id to a nonexistent post.

artists: convert to strong params.

* Disallow setting `is_banned` in create/update actions. Changing it
  this way instead of with the ban/unban actions would leave the artist in
  a partially banned state.

bans: convert to strong params.

* Disallow changing the user_id after the ban has been created.

comments: convert to strong params.

favorite groups: convert to strong params.

news updates: convert to strong params.

post appeals: convert to strong params.

post flags: convert to strong params.

* Disallow users from setting the `is_deleted` / `is_resolved` flags.

ip bans: convert to strong params.

user feedbacks: convert to strong params.

* Disallow users from setting `disable_dmail_notification` when creating feedbacks.
* Disallow changing the user_id after the feedback has been created.

notes: convert to strong params.

wiki pages: convert to strong params.

* Also fix non-Builders being able to delete wiki pages.

saved searches: convert to strong params.

pools: convert to strong params.

* Disallow setting `post_count` or `is_deleted` in create/update actions.

janitor trials: convert to strong params.

post disapprovals: convert to strong params.

* Factor out quick-mod bar to shared partial.
* Fix quick-mod bar to use `Post#is_approvable?` to determine visibility
  of Approve button.

dmail filters: convert to strong params.

password resets: convert to strong params.

user name change requests: convert to strong params.

posts: convert to strong params.

users: convert to strong params.

* Disallow setting password_hash, last_logged_in_at, last_forum_read_at,
  has_mail, and dmail_filter_attributes[user_id].

* Remove initialize_default_image_size (dead code).

uploads: convert to strong params.

* Remove `initialize_status` because status already defaults to pending
  in the database.

tag aliases/implications: convert to strong params.

tags: convert to strong params.

forum posts: convert to strong params.

* Disallow changing the topic_id after creating the post.
* Disallow setting is_deleted (destroy/undelete actions should be used instead).
* Remove is_sticky / is_locked (nonexistent attributes).

forum topics: convert to strong params.

* merges https://github.com/evazion/danbooru/tree/wip-rails-5.1
* lock pg gem to 0.21 (1.0.0 is incompatible with rails 5.1.4)
* switch to factorybot and change all references

Co-authored-by: r888888888 <r888888888@gmail.com>
Co-authored-by: evazion <noizave@gmail.com>

add diffs
2018-04-06 18:09:57 -07:00
evazion
8a012d4c91 Remove unused mobile mode code (#3206).
Mobile mode was removed in 31e36cf.
2018-03-20 02:29:06 -05:00
evazion
84a0a89f4b Fix #3539: Open redirect vulnerabilities. 2018-02-07 19:52:52 -06:00
r888888888
308e3670df gracefully handle unavailable pg connection errors 2018-02-05 12:38:01 -08:00
evazion
5975152ddc Fix double render error in /blah.js. 2017-12-23 00:45:07 -06:00
r888888888
c0ddf266fc move save search button to sidebar 2017-11-17 16:51:38 -08:00
r888888888
d0ccce6985 fixes #3350 2017-11-07 11:56:26 -08:00
r888888888
169fdfb745 re-enable exception rescuefrom 2017-10-03 13:47:50 -07:00
r888888888
014b9af5f8 fetch ugoiras for batch action #3317 2017-10-03 13:36:56 -07:00
r888888888
ba1399abef desktop mode redirects back to original page 2017-04-24 15:54:04 -07:00
r888888888
9718c6e107 fixes to mobile responsive view 2017-04-20 14:29:11 -07:00
evazion
3f35a9ab64 Handle failure gracefully for unconfigured services. 2017-04-05 01:17:03 -05:00
r888888888
c74b1d532a adjust interval for mod queue notice 2017-03-27 15:53:59 -07:00
Albert Yi
5445b341bc fixes #2822: Post vote API: returns 200 for both success and failure; fixes bug with x-api-limit header 2017-01-09 17:31:14 -08:00
Albert Yi
f2a5d45db0 implement token bucket rate limiting 2017-01-09 17:31:14 -08:00
Albert Yi
e7907e0e14 rename some config keys to clarify what they are 2016-11-28 17:31:01 -08:00
Albert Yi
2424f24fcd return 429 for too many requests instead of 421 2016-10-18 13:33:04 -07:00
Albert Yi
87447a51c3 work on #2693 Separate API Limits by Writes/Reads 2016-10-17 16:37:11 -07:00
evazion
bd6ebceda3 Refactor post_approvers_only to approver_only.
Don't duplicate code with post_approvers_only; use the approver_only?
method dynamically defined in `User::Roles.each do ... end`.
2016-10-14 05:04:40 +00:00
evazion
d84184b5f1 Prevent anon/banned/member users from voting (fix #2719).
There was a regression in 6d6d00b; `before_filter :voter_only` was a
no-op in the post vote controller because it merely returned false,
which does not halt the request. The fix is to arrange for a voter_only
method to be defined that properly redirects to the access denied page.
2016-10-14 04:47:51 +00:00
r888888888
800f7d9e5f fix invalid reference to request.request_uri 2016-09-23 15:30:17 -07:00
r888888888
2c80d7b82e more intelligent notice for mod queue 2016-09-09 15:08:23 -07:00