Commit Graph

66 Commits

Author SHA1 Message Date
evazion
98b313f8de Remove NewRelic integration.
Remove the NewRelic integration in preparation for migrating to Elastic APM instead.
2022-04-11 01:46:30 -05:00
evazion
8b5d687b7a rails: add more attributes to filtered params list.
Add more sensitive attributes to the filtered parameters list so that
they aren't shown in exception messages, and aren't logged in log files
or to NewRelic.

Only do this in production so that in testing and development, you can
still see these things when inspecting objects on the console.
2022-02-06 18:09:54 -06:00
evazion
87dfc66073 rails: update framework files and settings to 7.0.
* Update framework files with `bin/rails app:update`.
* Update to use new Rails 7.0 default settings, except for a couple
  things regarding new cookie and cache formats that would prevent us
  from rolling back to Rails 6.1 if necessary.
2022-01-07 21:10:55 -06:00
evazion
346aeca791 rails: remove sprockets references.
Remove a dummy Sprockets config file needed to get `bin/derailed` to
run. This is no longer necessary since Rails 7.0 no longer depends on
Sprockets.
2022-01-07 14:49:14 -06:00
evazion
ad4c75eb1a docs add more docs to app/{jobs,logical}.
These were missed in the last commit.
2021-06-28 05:09:19 -05:00
evazion
0563ca3001 docs: document config/ and some directories in app/.
* Add README files to several directories in app/ giving a brief
  overview of some parts of Danbooru's architecture.
* Add documentation for files in config/.
2021-06-27 05:21:38 -05:00
evazion
0593edaabf config: allow specifying location of Danbooru config file.
Allow specifying the location of the `config/danbooru_local_config.rb`
file with the DANBOORU_CONFIG_FILE environment variable. For example:

    DANBOORU_CONFIG_FILE=/etc/danbooru/danbooru_local_config.rb bin/rails server

This is useful in Kubernetes because it lets us mount a directory
containing the config file without it clobbering everything else in the
config/ directory.
2021-04-30 00:06:36 -05:00
evazion
f3880569e1 rails: update settings to 6.1 defaults.
Most of the new settings aren't relevant to us. We do have to fix some
tests to work around a Rails bug. `assert_enqueued_email_with` uses the
wrong queue, so we have to specify it explicitly. This is fixed in Rails
HEAD but not yet released.
2020-12-21 22:42:50 -06:00
evazion
25cba710bf BURs: don't allow requesting implications that already exist.
Fix it being possible to request duplicate implications.
2020-11-12 20:15:14 -06:00
evazion
aa9d34a3f0 config: make danbooru_local_config.rb optional.
Make it so that if danbooru_local_config.rb doesn't exist, we continue
with the default config instead of failing.
2020-06-05 15:49:51 -05:00
evazion
d7c236b0fc Include git hash in http headers and <meta> tags.
* Add X-Git-Hash http header.
* Add `<meta name="git-hash" content="<hash>">` meta tag.
* Include full hash in development mode.
2020-05-08 17:07:45 -05:00
evazion
15ba2f6cd7 tests: fix email delivery tests.
Setting deliver_later_queue_name inside config/application.rb broke
tests because assert_enqueued_email_with assumes that the deliver_later
queue is called `mailers`.
2020-03-20 18:03:00 -05:00
evazion
e70eb0221e emails: fix deliver_later mails not being sent.
By default, mails sent by deliver_later are added to the `mailers` job
queue. These mails weren't being sent because workers were only
configured to process the `default` queue.
2020-03-18 15:10:59 -05:00
evazion
bd6d896ee0 models: factor out concerns to app/logical/concerns. 2020-02-19 16:37:24 -06:00
evazion
d00308c43d Delegate HSTS to nginx.
Remove the ssl_options config option. Let nginx handle HSTS and
http->https redirects instead. At the rails level, all we need to do is
set the secure cookie flag when https is enabled (which we assume it's
enabled in production).
2020-01-07 11:49:46 -06:00
evazion
309821bf73 rubocop: fix various style issues. 2019-12-22 21:23:37 -06:00
evazion
2320fad139 danbooru logger: fix request parameter filtering. 2019-12-22 17:33:51 -06:00
evazion
ddb0e4d3ce config: refactor secret_key_base initialization. 2019-12-13 04:21:04 -06:00
evazion
6382aec85e config: update to Rails 6.0 defaults. 2019-12-13 04:21:04 -06:00
evazion
ea15b525f8 config: clean up filter_parameters initializer. 2019-12-13 03:05:46 -06:00
evazion
a4e587aa6a config: refactor email settings.
* Add `Danbooru.config.mail_delivery_method` option.
* Remove `Danbooru.config.aws_ses_enabled?` option.
* Replace `Danbooru.config.aws_ses_options` with `Danbooru.config.mail_settings`.
2019-12-13 03:00:12 -06:00
evazion
3e37869768 rails: disable asset pipeline.
Disable the assets pipeline (Sprockets). Sprockets errors out now after
upgrading to Sprockets 4 because of missing config files. We don't use
it any more after switching to Webpack, so we can disable it entirely.

Also disable a few more Rails features that we don't use (ActiveStorage,
ActionCable, ActionMailbox, ActionText).
2019-10-14 13:50:31 -05:00
evazion
3f7e05316d api: refactor default options for xml responses.
In xml responses, if the result is an empty array we want the response
to look like this:

   <posts type="array"/>

not like this (the default):

   <nil-classes type="array"/>

This refactors controllers so that this is done automatically instead of
having to manually call `@things.to_xml(root: "things")` everywhere. We
do this by overriding the behavior of `respond_with` in `ApplicationResponder`
to set the `root` option by default in xml responses.
2019-09-08 15:32:31 -05:00
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
Albert Yi
72f319ccf3 rename lambda references to use shorthand syntax 2018-05-10 11:18:02 -07:00
Albert Yi
664a3f02e2 fixes for failed cron maintenance tasks
* update rails scripts for 5.2
* system dmails should be scoped to system
* fix broken url generator in forum notices
2018-04-27 15:01:40 -07:00
evazion
09462aefeb Fix #3522: Enable HSTS. 2018-04-19 01:39:46 -05:00
evazion
2fd91bfa20 Load danbooru_default_config.rb earlier.
Load danbooru_default_config.rb inside application.rb instead of in an
initializer so that it's available as soon as possible.
2018-04-19 00:49:50 -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
127e4e385b Fix dmail failures when akismet isn't configured. 2017-11-25 21:46:32 -06:00
r888888888
b944b642b8 akismet integration 2017-09-14 13:37:36 -07:00
evazion
ebff8d04f7 config/application.rb: set hostname so root_url works. 2017-02-18 03:10:42 -06:00
evazion
f8d5add0cc Silence git messages to stdout during app boot.
Caused this to be printed every time tests were run:

    git is /usr/bin/git
    /home/user/src/danbooru
2016-12-03 20:09:58 -06:00
evazion
58ef469a76 Link current commit if running inside a git repo.
Useful when running `rails server` straight from a dev repo.
2016-10-24 19:07:08 -05:00
r888888888
06ddb16843 better mechanism for determining release revision 2016-09-07 18:54:24 -07:00
r888888888
af60ed7763 include git hash in footer 2016-09-07 18:45:21 -07:00
r888888888
c8f38350c3 update rails default files 2015-08-18 17:50:27 -07:00
r888888888
341b29ce41 fix tests 2015-08-18 17:40:53 -07:00
r888888888
53844af8dc Merge branch 'ruby-2.1'
This reverts commit 616aef4394.
2014-12-10 16:23:58 -08:00
r888888888
616aef4394 Revert "Merge branch 'ruby-2.1'"
This reverts commit 18dd5acca7, reversing
changes made to 55fef2f7c6.
2014-04-24 16:12:30 -07:00
r888888888
18dd5acca7 Merge branch 'ruby-2.1'
Conflicts:
	app/assets/javascripts/comments.js
	app/helpers/delayed_jobs_helper.rb
2014-04-23 18:05:31 -07:00
r888888888
fad0ab7c93 fixes #2133 2014-04-16 17:43:34 -07:00
r888888888
ec0280bcde upgrade to ruby 2.0.0 2014-02-26 13:16:34 -08:00
小太
cba839ba76 Kill trailing whitespace in ruby files 2013-03-19 23:10:10 +11:00
albert
f52181db94 Major revamp of security. Passwords are first SHA1 hashed and then
that hash is bcrypted.  Bcrypted hashes are stored in a new column on
users.  This separate column is only to allow for rollbacks,
eventually the old SHA1 hash column will be removed.  Sensitive cookie
details are now encrypted to prevent user tampering and more stringent
checks on secret_token and session_secret_key are enforced.
2013-03-04 22:55:41 -05:00
albert
a3658f6811 tweak logger 2013-02-17 18:14:12 -05:00
albert
963bb18de2 fix 2013-02-17 17:55:21 -05:00
albert
48d4673935 add memorylogic 2013-02-17 17:50:00 -05:00
albert
fdff706336 add tagged logging 2013-02-17 17:33:09 -05:00
albert
4cc04d395a fix 2012-02-10 17:51:34 -05:00