Commit Graph

30 Commits

Author SHA1 Message Date
Kim Burgestrand 44cfa73d72 Require users to explicitly define Scope#resolve
Closes https://github.com/varvet/pundit/pull/711 (original issue and pull request)

> A01:2021-Broken Access Control is the category with the most serious web
application security risk.
>
> Using scope.all in templates violates the principle of least privilege
or deny by default, where access should only be granted for particular
capabilities, roles, or users.
>
> This change improves the security of default templates
>
> Ref: https://owasp.org/Top10/A01_2021-Broken_Access_Control/
— by @tagliala (github.com/tagliala)

Co-authored-by: Duncan Stuart <dgmstuart@gmail.com>
2022-02-11 12:52:24 +01:00
Marcelo Guimarães 4bb0c7d637 Removing ruby 2.6 as required version because JRuby jruby-9.2 considers itself to be compliant with MRI 2.5 so if we add 2.6 as required minimum version for ruby it will causes conflict errors on bundler 2022-01-15 13:17:51 -03:00
Marcelo Guimarães 5a5df7894d improve syntax according rubocop 1.24 rules 2022-01-14 11:05:30 -03:00
Marcelo Guimarães 05bc3c3dcc update rubocop to 1.24 2022-01-12 21:39:41 -03:00
Duncan Stuart 8ffa4fe866 Report test coverage to CodeClimate
Coverage gets generated on every build, but we only need to send it for
one build. Send it on the first one, otherwise we get eg:

    ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
    time="2019-08-22T12:37:01Z" level=warning msg="Conflict when uploading: A test report for commit 6dabaaa6cd7e4c5c51dc538e4fbb7861ca433d8e already exists, skipping upload"

I guess this is because the test reporter assumes that if coverage
exists, then it has been sent?

Config from here:

https://docs.codeclimate.com/docs/travis-ci-test-coverage#section-travis-ci-single-test-suite-non-parallel-builds
2019-11-12 10:02:12 +01:00
Duncan Stuart f252293a02 Drop support for RSpec 2
I couldn't work out if it's officially unsupported, but RSpec3 came out
around 5 years ago and we had a fair amount of code which seemed to
only be there to support it.
2019-08-22 15:36:05 +02:00
Duncan Stuart 28dd15074e Upgrade Rubocop to latest version (0.74)
Now that we don't need to support Ruby 2.1 or 2.2, we can use the latest
version of Rubocop (which dropped support for those versions).

Also remove things from Rubocop which are now defaults:

- FrozenStringLiteralComment is now on by default
- DisplayCopNames used to be off by default but now seems to be on
- This project doesn't seem to have ever had gemfiles or vendor
  directories - my guess is that this was a copy-paste from another
  project.
2019-08-14 18:12:36 +02:00
Duncan Stuart 19b2613e7a Rubocop: re-enable SpecialGlobalVars cop
This seems like a reasonable thing to fix: in my opinion the fewer
exceptions to the default config, the better
2019-08-12 15:02:15 +02:00
Duncan Stuart f13c28d854 Add frozen string literal magic comment
This is enabled by default in later versions of Rubocop. Making this
change now removes this conflict for people running later versions.

Automatically fixed with `rubocop -a`
2019-08-12 15:02:15 +02:00
Duncan Stuart 21d6301f4f Specify development dependencies in gemspec
This commit does two things:

1. Move development dependencies back to gemspec
2. Restrict versions of some gems

It should also be noted that the recommendation is to commit
Gemfile.lock, however in this case it is not possible to do so:

3. Why we don't commit Gemfile.lock

Each of these requires a more detailed discussion:

1. Move development dependencies back to gemspec

9691355 originally moved all these dependencies into the Gemfile:

https://github.com/varvet/pundit/pull/435

The recommendation in the docs seems to be to use the gemspec for
development dependencies:

https://bundler.io/guides/creating_gem.html#getting-started

2. Restrict versions of some gems

While we want to be as flexible as possible with the gem's production
dependencies, we need to be more specific with our development
dependencies. In particular gems developed against one version of
Rubocop cannot be expected to work with later versions, since Rubocop
adds and renames cops in new versions.

In particular version 0.70.0 renames a cop which we are specifying,
resulting in the following errors.

    .rubocop.yml:81: `Style/TrivialAccessors` is concealed by line 96
    Error: The `Layout/IndentHash` cop has been renamed to `Layout/IndentFirstHashElement`.
    (obsolete configuration found in .rubocop.yml, please update it)

Rubocop version 0.67.2 passes without issues on the latest ruby version,
but is incompatible with 2.2.x and earlier. 0.57.2 is the latest version
which works everywhere.

Note that when running `gem build pundit.gemspec` we get warnings about
some open-ended dependencies:

    WARNING:  open-ended dependency on activesupport (>= 3.0.0) is not recommended
    if activesupport is semantically versioned, use:
      add_runtime_dependency 'activesupport', '~> 3.0', '>= 3.0.0'

However, I feel OK about these being loose, and since this gem is not so
often maintained, I'd prefer not to place an upper limit on the
runtime_dependency. The other gems with open-ended dependencies are also
part of Rails, so I believe they'll need to be the same version as
activesupport, which is why they have the same version constraint.

For the gems where we don't specify any version constraint we also get
this warning. For most of these (eg. pry) we genuinely don't care what
version is used.

3. Why we don't commit Gemfile.lock

When this gem was created the standard practice was to gitignore the
Gemfile.lock, but the guidance has changed:

> When Bundler first shipped, the Gemfile.lock was included in the
> .gitignore file included with generated gems. Over time, however, it
> became clear that this practice forces the pain of broken dependencies
> onto new contributors, while leaving existing contributors potentially
> unaware of the problem. Since bundle install is usually the first step
> towards a contribution, the pain of broken dependencies would
> discourage new contributors from contributing. As a result, we have
> revised our guidance for gem authors to now recommend checking in the
> lock for gems.

https://bundler.io/man/bundle-install.1.html#THE-GEMFILE-LOCK

The intention is that by committing the Gemfile.lock we ensure that all
developers of this gem have the same dependencies.

HOWEVER, we are currently supporting ruby 2.1 and 2.2. Newer versions of
some gems (eg. i18n, which is required by activesupport) are only
compatible with ruby 2.3 and up, so a lockfile compatible with the
latest version of activesupport (which is a runtime dependency) will not
be compatible with these versions.

The impact of this is that we can't commit the lockfile without also
dropping support for versions 2.1 and 2.2.
2019-08-07 14:52:27 +02:00
Linus Marton 290536f71e
Update gemspec authors 2018-10-02 13:23:17 +02:00
Linus Marton f6bf57b1b6
elabs => varvet 2018-07-04 20:30:06 +02:00
Linus Marton 70935c5e93
Fix rubocop issues
This makes rubocop work with newer versions.
2018-04-27 12:40:42 +02:00
284km 4c488be943 CI against Ruby 2.2.8/2.3.5/2.4.2 (#489)
* CI against Ruby 2.2.8/2.3.5/2.4.2

* Remove unnecessary magic comments with ruby 2.0 or later

* Change `TargetRubyVersion` to 2.0

ruby 1.9.3 has already been dropped by 0569b065d7

* Change `TargetRubyVersion` to 2.1

* Drop jruby1.7 on Travis
2017-12-05 10:46:03 +01:00
Olle Jonsson ac2a25d93c Rubocop -a for 2.4.1 sake 2017-05-11 14:53:16 +02:00
Olle Jonsson f60d059df9 Travis build change: Fix build, use latest JRuby
- Lint only 1 time, on modern Ruby
2017-05-11 14:53:16 +02:00
Jonas Nicklas d079c86ebb Add Rubocop. 2016-01-14 15:30:03 +01:00
Jonas Nicklas 68372c9c17 Add permitted attributes helper, closes #141
See discussion in #141. This provides a convenient helper which aids in permitting attributes in the controller.
2015-03-30 09:20:03 +02:00
Jonas Nicklas b01cc67fca Make it possible to run pundit specs against different versions of RSpec 2014-07-18 16:07:49 +02:00
Thomas Klemm 32089ce9cf Update RSpec dependency to ~> 3.0.0 2014-07-13 10:50:06 +02:00
Thom Mahoney 7080ffd04c require activemodel instead of activerecord 2014-05-20 14:49:14 -07:00
Chris Legault 0e85e0cdb7 - Updated gemspec to use RSpec 3
- Updated tests to match new expect syntax
2014-02-08 08:19:24 -04:00
Thomas Klemm 38640c7016 Add bundler rake tasks for releasing gem 2014-02-07 18:15:05 +01:00
Jonas Nicklas 7b9415cfe5 Document project license in gemspec 2013-10-04 13:36:35 +02:00
Thomas Klemm df735d14cb Lifting Rails dependency 2013-06-18 01:11:15 +02:00
Andy Lindeman 98b6ce8817 Supports Rails 4 2013-01-08 11:05:16 -05:00
Jonas Nicklas 27e7a93c13 Add Rakefile to make Travis happy 2012-11-19 13:47:38 +01:00
Jonas Nicklas cf5828f3e8 Update gemspec 2012-11-19 13:04:07 +01:00
Jonas Nicklas b8fd37110a Add specs and dependencies 2012-11-19 13:02:42 +01:00
Jonas Nicklas 1cad0b598a initial 2012-11-04 10:20:45 +01:00