/usr/lib/ruby/vendor_ruby/web_console/whiny_request.rb is in ruby-web-console 2.2.1-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | module WebConsole
# Noisy wrapper around +Request+.
#
# If any calls to +from_whitelisted_ip?+ and +acceptable_content_type?+
# return false, an info log message will be displayed in users' logs.
class WhinyRequest < SimpleDelegator
def from_whitelited_ip?
whine_unless request.from_whitelited_ip? do
"Cannot render console from #{request.remote_ip}! " \
"Allowed networks: #{request.whitelisted_ips}"
end
end
def acceptable_content_type?
whine_unless request.acceptable_content_type? do
"Cannot render console with content type #{request.content_type}" \
"Allowed content types: #{request.acceptable_content_types}"
end
end
private
def whine_unless(condition)
unless condition
logger.info { yield }
end
condition
end
def logger
env['action_dispatch.logger'] || WebConsole.logger
end
def request
__getobj__
end
end
end
|