
Security News
Nx npm Packages Compromised in Supply Chain Attack Weaponizing AI CLI Tools
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.
sinatra-advanced-routes
Advanced tools
Makes routes first class objects in Sinatra.
Check out sinatra-contrib you are looking for other fancy Sinatra extensions.
Add to your Gemfile
:
gem 'sinatra-advanced-routes'
If you are extending Sinatra::Base, register the extension manually :
require "sinatra/base"
require "sinatra/advanced_routes"
class Foo < Sinatra::Base
register Sinatra::AdvancedRoutes
end
require "sinatra"
require "sinatra/advanced_routes"
admin_route = get "/admin" do
administrate_stuff
end
before do
# Let's deactivate the route if we have no password file.
if File.exists? "admin_password" then admin_route.activate
else admin_route.deactivate
end
end
first_route = get "/:name" do
# stuff
end
other_route = get "/foo_:name" do
# other stuff
end
# Unfortunatly first_route will catch all the requests other_route would
# have gotten, since it has been defined first. But wait, we can fix this!
other_route.promote
require "some_sinatra_app"
SomeSinatraApp.each_route do |route|
puts "-" * 20
puts route.app.name # "SomeSinatraApp"
puts route.path # that's the path given as argument to get and akin
puts route.verb # get / head / post / put / delete
puts route.file # "some_sinatra_app.rb" or something
puts route.line # the line number of the get/post/... statement
puts route.pattern # that's the pattern internally used by sinatra
puts route.keys # keys given when route was defined
puts route.conditions # conditions given when route was defined
puts route.block # the route's closure
end
Some of that fields (like conditions or pattern) can be changed, which will take immediate effect on the routing.
FAQs
Unknown package
We found that sinatra-advanced-routes demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 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.
Security News
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.
Security News
CISA’s 2025 draft SBOM guidance adds new fields like hashes, licenses, and tool metadata to make software inventories more actionable.
Security News
A clarification on our recent research investigating 60 malicious Ruby gems.