Skip to content

Commit

Permalink
Merge pull request #3399 from semgrep/merge-develop-to-release
Browse files Browse the repository at this point in the history
Merge Develop into Release
  • Loading branch information
p4p3r authored Jun 12, 2024
2 parents 2420678 + ad49c15 commit 7dd4e43
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 9 additions & 1 deletion ruby/rails/security/brakeman/check-before-filter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,13 @@ class BadController < ApplicationController
# ruleid: check-before-filter
skip_before_filter :login_required, :except => :do_admin_stuff
# ruleid: check-before-filter
skip_before_action :login_required, :except => :do_admin_stuff
# ruleid: check-before-filter
skip_filter :authenticate_user!, :except => :do_admin_stuff
# ruleid: check-before-filter
skip_before_filter :require_user, :except => [:do_admin_stuff, :do_other_stuff]
# ruleid: check-before-filter
skip_before_action :require_user, :except => [:do_admin_stuff, :do_other_stuff]

def do_admin_stuff
#do some stuff
Expand All @@ -21,9 +25,13 @@ class GoodController < ApplicationController
# ok: check-before-filter
skip_before_filter :login_required, :only => :do_anonymous_stuff
# ok: check-before-filter
skip_before_action :login_required, :only => :do_anonymous_stuff
# ok: check-before-filter
skip_filter :authenticate_user!, :only => :do_anonymous_stuff
# ok: check-before-filter
skip_before_filter :require_user, :only => [:do_anonymous_stuff, :do_nocontext_stuff]
# ok: check-before-filter
skip_before_action :require_user, :only => [:do_anonymous_stuff, :do_nocontext_stuff]

def do_admin_stuff
#do some stuff
Expand All @@ -36,4 +44,4 @@ def do_anonymous_stuff
def do_nocontext_stuff
# do some stuff
end
end
end
2 changes: 2 additions & 0 deletions ruby/rails/security/brakeman/check-before-filter.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ rules:
skip_filter ..., :except => $ARGS
- pattern: |
skip_before_filter ..., :except => $ARGS
- pattern: |
skip_before_action ..., :except => $ARGS
message: 'Disabled-by-default Rails controller checks make it much easier to introduce access control
mistakes. Prefer an allowlist approach with `:only => [...]` rather than `except: => [...]`'
languages:
Expand Down

0 comments on commit 7dd4e43

Please sign in to comment.