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.
In rails project, one common scenario is:
One form used to create or update an object can be routed from more than one page, when the object is created or updated, it should be redirected back to wherever it came from.
Rails redirect_back
doesn't work in this case because:
redirect_back
in create/update action will go back to new/edit form.redirect_back
.rails-source-path
can hanlde this by explicily specifying the entry actions and remember the
previous route in session
store, hence can be used later in the whole controller. Also a helper
method is providered so it can be used in view like back
or cancel
button.
Add this line to your application's Gemfile:
gem 'rails_source_path'
And then execute:
$ bundle
Or install it yourself as:
$ gem install rails_source_path
class YourController < ApplicationController
rails_source_path_entry_actions :new, :edit
...
def create
if @object.create
redirect_to_source
else
...
end
end
def update
if @object.save
redirect_to_source
else
...
end
end
end
# in your view/partial
link_to 'Cancel', rails_source_path, class: 'button'
Both redirect_to_source
and rails_source_path
accept an optional argument which is the path when there is no previous route remembered.
def rails_source_path(default_path = root_path)
def redirect_to_source(default_path = root_path)
The gem is available as open source under the terms of the MIT License.
FAQs
Unknown package
We found that rails_source_path demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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.