17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'app/controllers/onlylogs/logs_controller.rb', line 17
def download
if params[:log_file_path].blank?
return render(plain: "Bad Request: missing required parameter 'log_file_path' (encrypted log file path).", status: :bad_request)
end
file_path = authorized_log_file_path(params[:log_file_path])
send_file file_path, filename: ::File.basename(file_path), disposition: :attachment
rescue Onlylogs::SecureFilePath::SecurityError
render plain: "Bad Request: 'log_file_path' could not be decrypted (tampered or malformed token).", status: :bad_request
rescue Onlylogs::ForbiddenPathError
render plain: "Forbidden: requested log file path is not in the allowed list.", status: :forbidden
rescue ActionController::MissingFile, Errno::ENOENT
render plain: "Not Found: log file is currently unreadable (it may have been rotated, moved, or temporarily unavailable).", status: :not_found
end
|