Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
http_status_exceptions
Advanced tools
= HTTP status exception
This simple plugin will register exception classes for all HTTP status. These exceptions can then be raised from your controllers, after which a response will be send back to the client with the desired HTTP status, possible with some other content.
You can use this plugin to access control mechanisms. You can simply raise a HTTPStatus::Forbidden if a user is not allowed to perform a certain action. A nice looking error page will be the result. See the project wiki (https://github.com/wvanbergen/http_status_exceptions/wiki) for additional documentation.
This plugin only works with Rails 3. Version 0.2.1 of this plugin is compatible with Rails 2. The code for this version can be found in the rails2 branch: https://github.com/wvanbergen/http_status_exceptions/tree/rails2.
== Installation
Installation is simple. Simply add the gem to the configuration in your Gemfile:
gem 'http_status_exceptions'
Run bundle install to make sure to have the gem included in your bundle.
== Configuration
You can modify where HTTP status exception looks for its template files like so:
class ApplicationController < ActionController::Base ... HTTPStatus::Base.template_path = 'path_to/http_status_templates' end
You can also modify which layout is used when rendering a template by setting the template_layout:
class ApplicationController < ActionController::Base ... HTTPStatus::Base.template_layout = 'exception' end
If you don't set a template_layout the current layout for the requested action will be used.
== Usage
class BlogController < ApplicationController
def destroy
raise HTTPStatus::Forbidden, 'You cannot delete blogs!' unless current_user.can_delete_blogs?
@blog.destroy
end
end
By default, this will return an empty response with the "forbidden" status code (403). If you want to add content to the response as well, create the following view: shared/http_status/forbidden.html.erb. You can use the @exception-object in your view:
<%= h(@exception.message) %>
HTTP status code <%= @exception.status_code %>: <%= @exception.status.to_s.humanize %>
The response will only be sent if the request format is HTML because of the name of the view file. In theory you could make a response for XML requests as well by using shared/http_status/forbidden.xml.builder as filename
FAQs
Unknown package
We found that http_status_exceptions demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.