
Security News
Risky Biz Podcast: Making Reachability Analysis Work in Real-World Codebases
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
Rewritten is a lookup-based rewriting engine that rewrites requested URLs on the fly. The URL manipulations depend on translations found in a redis database. URLs without translations are passed through while URLs with translations result in a either redirection or ultimatively in a modification of path and request parameters. The gem is compromised of several parts:
Part 1. and 2. are based heavily on parts from the Resque codebase.
gem install rewritten
On Rails add Rewritten to your Gemfile:
gem 'rewritten'
Rewritten works completely transparent and decoupled as Rack middleware. Add it to your rack stack.
# config.ru
require 'rewritten'
Rewritten.redis = Redis.new(host: 'host', port: 'port', password: 'password' )
map "/" do
use Rack::Rewritten::Url
use Rack::Rewritten::Html
run MyApp::Application
end
This will translate pretty/SEO requests to the language that MyApp speaks and translate the HTML-Output of MyApp to the desired pretty/SEO language.
On Rails the HTML translation can also be achieved by including the following to your application_controller.rb:
require 'rewritten/rails'
class ApplicationController < Action:Controller::Base
include Rewritten::Rails::UrlHelper
# ....
#
end
This way all routes helpers will be translated.
To manage the vocabulary from within your Rack app you need to establish a connection to the same redis db (on Rails put this into an initializer).
include 'rewritten'
Rewritten.redis = Redis.new(host: 'host', port: 'port', password: 'password' )
The ruby library allows you to successively add and remove vocabulary:
Rewritten.add_translation('/apple-computer/newton', '/products/4e4d3c6a1d41c811e8000009')
Rewritten.add_translation('/apple/ipad', '/products/4e4d3c6a1d41c811e8000009')
Rewritten.remove_translation('/failed-computer/newton', '/products/4e4d3c6a1d41c811e8000009')
To query for the current "trade language" use:
Rewritten.get_current_translation('/products/4e4d3c6a1d41c811e8000009') # => "/apple/ipad"
Rewritten comes with a Sinatra-based front end for dislaying and managing your URL translations (layout taken from Resque). Include it in your Rack stack with:
require 'rewritten/server'
map "/rewritten" do
use Rack::Auth::Basic do |username, password|
username == 'user' and password == 'password'
end
run Rewritten::Server
end
Running the gem in standalone mode is easy as well:
$ rewritten-web
It's based on Vegas, a thin layer around rackup, and as such configurable as well:
$ rewritten-web -p 8282
FAQs
Unknown package
We found that rewritten 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.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
Security News
/Research
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.