Commit Graph

25 Commits

Author SHA1 Message Date
Jared Beck bce8b193c5 Ensure YAML safe loading in Rails 6.1, part 2 2022-10-16 01:54:50 -04:00
Tim Connor 172ac1d747 Ensure YAML safe loading in Rails 6.1
As part of the fix for CVE-2022-32224 Rails intruduced safe YAML loading
and the `ActiveRecord.yaml_column_permitted_classes` config.

PaperTrail added support for respecting the new configuration here
https://github.com/paper-trail-gem/paper_trail/pull/1397

The CVE-2022-32224 fix was also backported to Rails versions 5.2.8.1,
6.0.5.1, and, 6.1.6.1, however the name of the confiuration is slightly
different from that in Rails 7.x.

    7.0.3.1 ActiveRecord.yaml_column_permitted_classes
    6.1.6.1 ActiveRecord::Base.yaml_column_permitted_classes
    6.0.5.1 ActiveRecord::Base.yaml_column_permitted_classes
    5.2.8.1 ActiveRecord::Base.yaml_column_permitted_classes

PaperTrail currently doesn't support this alternative configuration
naming, which means it will silent fall back to unsafe YAML loading.

This commit updates `PaperTrail::Serializers::YAML` to be compatible
with safe YAML loading for the Rails 5.2 / 6.0 / 6.1 branches.
2022-10-16 01:41:53 -04:00
Jared Beck 3f0e3aba2e Drop support for Rails 5.2 (reached EoL on 2022-06-01) 2022-10-16 00:54:14 -04:00
Jared Beck d17fdabd29 Default serializer will use YAML.safe_load
Breaking change.

Going forward, PT's default serializer (PaperTrail::Serializers::YAML)
will use `safe_load` unless `ActiveRecord.use_yaml_unsafe_load`.

PT users are required to configure `ActiveRecord.yaml_column_permitted_classes`
correctly for their own application. Users may want to start with the following
safe-list:

```ruby
::ActiveRecord.use_yaml_unsafe_load = false
::ActiveRecord.yaml_column_permitted_classes = [
  ::ActiveRecord::Type::Time::Value,
  ::ActiveSupport::TimeWithZone,
  ::ActiveSupport::TimeZone,
  ::BigDecimal,
  ::Date,
  ::Symbol,
  ::Time
]
```
2022-08-15 21:52:29 -04:00
Jared Beck 6616e13023 Document and make explicit certain "boot" order
- Ensure that the "paper_trail" initializer happens before the
end-user's initializers (in their app's config/initializers)
- Document the boot process of dummy_app and how it differs
from a conventional app.

This is a direct continuation of fc6c5f6, which was a collaboration
between Eric and myself, but I choose to make this a separate
commit, partly for vanity, and partly on the faint hope that it
might make review easier.
2021-03-18 01:49:53 -04:00
Jared Beck 5c95fca5cf Tests: replace TravisCI with GitHub Actions
After years of providing an awesome service for free, which we are very
grateful for, TravisCI will be dropping their free plan on Dec 31. So,
we are switching to GHA.

Drops multi-db (foo/bar) tests. Managing three databases per RDBMS
was turning into a huge hassle, and they needed to be rewritten anyway for
rails 6, per Eileen's talk.
2020-12-15 21:37:05 -05:00
Jared Beck 31862462ce Tests: Remove defunct config: time_zone_aware_types
We started setting this config in rails 5, to preserve the behavior
in rails 4, ie. `time` columns being "zone-unaware".

If we rewrite our `time` column tests to focus on the time only
(and not the date) then we don't need to set time_zone_aware_types.
2020-12-14 17:11:00 -05:00
Jared Beck 329ae89a8f Tests: dummy_app: remove config for old rails versions 2020-12-14 15:54:44 -05:00
Jared Beck b2cb837c81 Tests: use load_defaults in dummy_app
Suggested in
https://github.com/paper-trail-gem/paper_trail/pull/1273#issuecomment-744357944
2020-12-14 15:52:35 -05:00
Jared Beck 6ceaa0d922 Fix deprecation warning re: represent_boolean_as_integer 2020-05-03 01:05:15 -04:00
Jared Beck 24f3fbcd8f PT-AT is now responsible for testing itself
See historical overview in README
2019-08-06 02:45:06 -04:00
Edouard Chin 2b479a7f08 Support rails 6.0.0 (#1172)
* Change update_attributes to update

In Rails 6.0 update_attributes/update_attributes! is considered deprecated. Method update/update! is the replacement.

* CI: Don't use Bundler 1.16.1

- Bundler 1.16.1 has bug where dependencies can't be resolved properly
  when a gem is a release candidate or an alpha version.
  The underlying bundler issue can be found here https://github.com/bundler/bundler/issues/6449

* Disable eager_load in test env:

- In Rails 6.0, rails/rails@3b95478 made a change to eagerly define
  attribute methods of a Model when `eager_load` is enabled.
  This breaks our test suite because of the way we run migration.

  The TL;DR is that doing `People.attribute_names` will return an
  empty array instead of `[:id, time_zone, ...]`.
  You can find a failing build here https://travis-ci.org/paper-trail-gem/paper_trail/jobs/463369634

  Basically what happens is:

  1) The dummy app boot, attribute methods of each model are defined
     but since migration didn't run yet, the tables aren't even
     created resulting in a empty attribute set.
  2) Migration runs, but it's already too late.

  In this commit I disabled eager_loading in test, AFAIT there isn't
  much benefit in eager_loading the dummy app anyway.
  Also renaming the `user.rb` file to `postgres_user.rb` in order for
  rails autoloading to work correctly.
2018-12-04 16:10:35 -05:00
Jared Beck 9f004a60e0 Revert #1108 (lorint's STI fix)
This partially reverts commit 58369e1d8f.
I have kept the specs, skipped.

Per the following, this approach does not seem to be working:

- https://github.com/paper-trail-gem/paper_trail/issues/1135
- https://github.com/paper-trail-gem/paper_trail/pull/1137
- https://github.com/seanlinsley/paper_trail/pull/1
2018-08-21 23:13:34 -04:00
Jared Beck ed4a39141b Do not require PT-AT
[Fixes #1134]
2018-08-14 18:56:46 -04:00
Jared Beck ec2e693907 Remove unnecessary deprecation silencer 2018-08-14 01:49:09 -04:00
lorint 58369e1d8f Fix for issue #594, reifying sub-classed models that use STI (#1108)
See the changes to the changelog and readme for details.
2018-07-30 10:50:32 -04:00
Jared Beck 72d4361a3b Tests: Fix deprecation: represent_boolean_as_integer 2018-06-07 14:43:56 -04:00
Jared Beck 3d4b44d422 Tests: Fix deprecation warning re: secret_key_base 2018-06-07 14:43:56 -04:00
Jared Beck e05eef6ae7 Lint: Style/LineEndConcatenation
I've come around to where I don't mind the backslash.
2018-03-27 18:35:00 -04:00
Jared Beck c0633be405 Lint: Style/ExpandPathArguments 2018-03-27 18:32:52 -04:00
Jared Beck 025ceef943 Ask for help with association tracking 2018-03-24 00:26:28 -04:00
Jared Beck cfbf7a647c Lint: Style/FrozenStringLiteralComment 2017-12-10 23:05:39 -05:00
Jared Beck 408aa74dc6 Drop support for rails 4.0 and 4.1
EoL for both was 2016-06-30
http://weblog.rubyonrails.org/2016/6/30/Rails-5-0-final/

PT continued to support them for 15 months after EoL.
2017-09-20 05:26:13 -04:00
Joel Hayhurst 29623cfa63 Support belongs_to_required_by_default
Since Rails 5.0, belongs_to_required_by_default has been the official ActiveRecord default.
Add the configuration lines necessary to enable this default in both 5.0 and 5.1.
Add "optional: true" where necessary to fix spec failures caused by this change.
Add version-checking conditionals where necessary.
Update the Changelog appropriately.
2017-08-30 14:02:56 -07:00
Jared Beck 94b9306647 Finish the conversion to RSpec
- Convert serializers/mixin_json_test.rb to rspec
- Convert functional/thread_safety_test.rb to rspec
- Convert functional/controller_test.rb to rspec
- Move the dummy app from test to spec, delete test dir
2017-06-10 01:45:46 -04:00