Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not treat private methods as routable #1876

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/brakeman/processors/controller_alias_processor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ def layout_name
#Returns true if the given method name is also a route
def route? method
if @tracker.routes[:allow_all_actions] or @tracker.options[:assume_all_routes]
true
not @tracker.controllers[@current_class].private? method
else
routes = @tracker.routes[@current_class]
routes and (routes.include? :allow_all_actions or routes.include? method)
Expand Down
4 changes: 4 additions & 0 deletions lib/brakeman/tracker/collection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,10 @@ def methods_public
@methods[:public]
end

def private? name
@methods[:private].has_key? name
end

def get_simple_method_return_value type, name
@simple_methods[type][name]
end
Expand Down