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

Fix authenticate_or_request_with_http_basic check for passed blocks #1478

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/brakeman/checks/check_basic_auth.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ def check_basic_auth_request

# Check if the block of a result contains a comparison of password to string
def include_password_literal? result
return false if result[:block_args].nil?

@password_var = result[:block_args].last
@include_password = false
process result[:block]
Expand Down
10 changes: 10 additions & 0 deletions test/apps/rails3.1/app/controllers/admin_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,14 @@ def make_system_calls
def use_lambda_filter
eval @thing
end

def authenticate_token!
authenticate_token_or_basic do |username, password|
username == "foo"
end
end

def authenticate_token_or_basic(&block)
authenticate_or_request_with_http_basic(&block)
end
end