<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Brightbox Blog &#187; Rahoul Baruah</title>
	<atom:link href="http://blog.brightbox.co.uk/posts/author/baz/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.brightbox.co.uk</link>
	<description></description>
	<lastBuildDate>Fri, 02 Dec 2011 12:56:25 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Queues and Callbacks</title>
		<link>http://blog.brightbox.co.uk/posts/queues-and-callbacks</link>
		<comments>http://blog.brightbox.co.uk/posts/queues-and-callbacks#comments</comments>
		<pubDate>Tue, 03 Nov 2009 09:00:49 +0000</pubDate>
		<dc:creator>Rahoul Baruah</dc:creator>
				<category><![CDATA[tech]]></category>
		<category><![CDATA[AMQP]]></category>
		<category><![CDATA[bigwig]]></category>
		<category><![CDATA[bunny]]></category>
		<category><![CDATA[RabbitMQ]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby on rails]]></category>
		<category><![CDATA[warren]]></category>

		<guid isPermaLink="false">http://blog.brightbox.co.uk/?p=755</guid>
		<description><![CDATA[A major part of our work behind the scenes is about improving our internal processes and, whenever possible, automating tasks. To this end we have a number of systems that need to communicate with each other. The Control Panel that you may be familiar with uses Delayed Job. This is a Rails-specific gem that uses [...]]]></description>
			<content:encoded><![CDATA[<p>A major part of our work behind the scenes is about improving our internal processes and, whenever possible, automating tasks.  To this end we have a number of systems that need to communicate with each other.</p>
<p>The Control Panel that you may be familiar with uses <a href="http://github.com/tobi/delayed_job">Delayed Job</a>.  This is a Rails-specific gem that uses the database as a queue, with a nicely packaged worker process that handles messages as they arrive.  Because the Control Panel only ever talks to Rails from Rails, this worked extremely well.</p>
<p>However, our other systems were not homogenous &#8211; there are a number of different interfaces that needed to be instructed at various times and across various machines, and Delayed Job didn&#8217;t really fit the bill.  In particular, there were some tasks that could only happen on certain servers &#8211; while Delayed Job let us have multiple worker processes on different boxes, it essentially managed a single queue, so it could not differentiate between messages for one worker and messages for another.<br />
<span id="more-755"></span></p>
<h2>AMQP to the rescue</h2>
<p>Because of this, we looked elsewhere for our central work queue.  We decided to use the <a href="http://en.wikipedia.org/wiki/Advanced_Message_Queuing_Protocol">AMQP</a> protocol,  with <a href="http://www.rabbitmq.com/">RabbitMQ</a> as our implementation.  AMQP is a protocol for taking incoming messages, placing them on one of many queues and routing them to a destination reliably; RabbitMQ is a server, built in Erlang, that is pretty lightweight and has some nice clustering features built-in.</p>
<h2>Into the Warren</h2>
<p>When it came to getting our Rails applications to talk to RabbitMQ, we had a couple of choices.</p>
<p>There is an <a href="http://github.com/tmm1/amqp/">AMQP gem</a> which looked great.  Unfortunately, as it uses EventMachine internally, it caused a few problems with our Passenger-based deployments &#8211; EventMachine opens a background thread which can cause issues to the web-server controlled Passenger processes.</p>
<p><img class="content_image left size-medium wp-image-765" title="Rabbit on the run" src="http://blog.brightbox.co.uk/wp-content/uploads/2009/09/rabbit-225x300.jpg" alt="Rabbit on the run" width="225" height="300" /></p>
<p>There was also a gem called <a href="http://github.com/celldee/bunny/">bunny</a>.  This works synchronously, thus avoiding the EventMachine issues &#8211; you connect and bunny either says &#8220;here&#8217;s the next message&#8221; or &#8220;the queue is empty&#8221; and then you disconnect.</p>
<p>It looked like bunny was perfect for our Passenger-based apps, with the AMQP gem being used in the non-Passenger side of things (actually in the end, we went with bunny on both sides, but for other reasons).  But there was still a couple of things that we wanted to do with the messages.</p>
<p>Firstly, we are Rubyists and AMQP (the protocol) is language agnostic.  In particular, we wanted to put a hash of data onto the queue and have a hash of data presented to us at the other end.  Secondly, security is important to us &#8211; especially when it comes to tasks like rebooting or reconfiguring a server &#8211; so we wanted to ensure that the contents of the message were not tampered with in transit.</p>
<p>For these reasons, we built <a href="http://github.com/brightbox/warren">Warren</a>.  This adds filters over the AQMP layer.  In our case, we had one filter that automatically marshalls the data to and from YAML as it is put onto and taken off the queue and a second HMAC filter that, with one line of configuration, ensures that the data was not altered on its journey.</p>
<p>Warren itself has an adapter layer, so it can quite happily use either the AMQP gem or bunny to actually talk to the queue.  Adding new adapters, or filters, is as simple as creating a new subclass &#8211; Warren detects it and adds it to its stack.</p>
<h2>Bigwig</h2>
<p>With Warren it is pretty simple to put a message on to the queue:</p>
<pre><code>
Warren::Queue.publish(@queue_name, @hash_of_data)
</code></pre>
<p>It is just as easy to pull the messages off the other end:</p>
<pre><code>
Warren::Queue.subscribe(@queue_name) do | hash_of_data |
  do_something_with hash_of_data
end
</code></pre>
<p>But how do we implement this mysterious <tt>do_something_with(hash_of_data)</tt> call?</p>
<p>For our purposes, the endpoint needs to do different things depending upon which machine we are on and which queue we are listening to.  The key one is our &#8220;builder&#8221; system which handles reboots, migrations and deployments, but there are several others, which while not yet live, will be coming onstream soon.</p>
<p>So effectively, we needed a set of daemon processes that listen to given queues and handle the messages that they receive.  This splits into two components &#8211; the daemon framework and the workers themselves &#8211; which lead to <a href="http://github.com/brightbox/bigwig">Bigwig</a> (keeping the rabbit theme going, Bigwig was a character in <a href="http://en.wikipedia.org/wiki/List_of_characters_in_Watership_Down">Watership Down</a>).</p>
<p>Bigwig expects a configuration file, telling it how to connect to the AMQP server and a folder full of plugins.  Each plugin is a simple Ruby class that performs a given action.  Bigwig takes the incoming messages, looks for a parameter within the Hash called &#8220;method&#8221; and then uses that to find a plugin.  The plugin is then invoked and can perform whatever tasks it needs to, using any data from the incoming message.</p>
<p>For monitoring purposes, Bigwig automatically deals with any incoming messages with a method of &#8220;ping&#8221; &#8211; these simply write a message to the log file.  We can then send ping messages to the queue at set intervals and monitor that the log file is updated when expected &#8211; if we don&#8217;t see the update then we trigger an alert, in case the queue, or Bigwig, is down.</p>
<p>If the queue itself goes down, for whatever reason, then Bigwig uses an intelligent reconnect pattern.  At first, it retries often, to minimise the downtime, but if the queue stays down, it reconnects less frequently, giving the queue a chance to restart before being swamped with connections.  Of course, if the queue fails, then the ping messages won&#8217;t make it through and our monitor should alert us.</p>
<h2>Calling back</h2>
<p>Our primary internal application creates a Task object, with a unique identifier when dispatching tasks across the queue.  This ID is then passed onto the queue and each Bigwig plugin is told of it when it is invoked.  The application itself makes the Tasks available over ActiveResource.</p>
<p><img src="http://blog.brightbox.co.uk/wp-content/uploads/2009/09/3410902-400x300.jpg" alt="3410902" title="3410902" width="400" height="300" class="content_image right alignright size-medium wp-image-773" />This means that the Bigwig plugins themselves don&#8217;t actually need data passing over the queue.  Instead, when they are invoked, they call back into the primary application, using the Task ID as the key to their ActiveResource call.  They can then extract the data they need from the Task object and use that to do whatever they need to do.  When completed, they call the <tt>complete!</tt> method on the ActiveResource object and our application knows that the job has been done (alternatively, they can call <tt>error!</tt> and our app knows that something went wrong).  All of these appear in an event feed on the application&#8217;s homepage &#8211; so we know at a glance what activity is happening across our systems and, more importantly, what has failed.</p>
<p>We could have implemented this using AMQP again &#8211; a &#8216;responses&#8217; queue that our primary application listens to, with each worker putting a message back when it was done.  But we chose to use ActiveResource, partly because it is so simple (Rails makes it super-easy to expose your objects as XML and ActiveResource makes it equally easy for other Ruby programs to call back to them), and partly for philosophical reasons.  When the primary application places a message onto the queue, it doesn&#8217;t necessarily know how it will be handled.  AMQP dispatches it and a listener deals with it &#8211; in our case the listener is <em>likely</em> to be a Bigwig instance, but doesn&#8217;t <em>have</em> to be.  But when the callback is made, it is <em>always</em> made into our application, which is already geared up for completing tasks or marking them as having an error.  As we know that it is a Rails app at the other end, we chose to follow the path of least-resistance and use the &#8220;Rails way&#8221;.</p>
<p>However, we did have one issue with ActiveResource.  Most of our plugins actually shell out to invoke Ruby scripts, with the plugin unpacking the information from the Task and generating command line arguments.  This is a slight security risk, just because it is feasible that someone could inject a malicious command into the command line parameters (although as this is all internal it should never be an issue and Ruby&#8217;s system command does escape any supplied parameters).  So we are switching the scripts to accept environment variables, thus bypassing the shell and eliminating a whole category of potential attacks.  Secondly, using ActiveResource in a non-Rails application caused some weird errors &#8211; but only when you tried to POST back to the ActiveResource object.  It turns out that ActiveSupport was causing some shifting to occur in the background and that was knocking out some of our own code.  The solution was simple &#8211; we had to ensure that the <tt>require 'activeresource'</tt> statement was the first thing in each script.</p>
<p>So that&#8217;s a quick peek into the workings of some of our internal systems.  We put a lot of thought into how these different components should work together, as their reliability is fundamental to our success as a business.  And while they are not infallible (nothing ever is) I think you will agree that they show that using Ruby and AMQP as the &#8220;glue&#8221; to tie different systems together is not only feasible, it&#8217;s actually quite easy.</p>]]></content:encoded>
			<wfw:commentRss>http://blog.brightbox.co.uk/posts/queues-and-callbacks/feed</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Free software and Brightbox</title>
		<link>http://blog.brightbox.co.uk/posts/free-software-and-brightbox</link>
		<comments>http://blog.brightbox.co.uk/posts/free-software-and-brightbox#comments</comments>
		<pubDate>Mon, 09 Mar 2009 11:19:46 +0000</pubDate>
		<dc:creator>Rahoul Baruah</dc:creator>
				<category><![CDATA[tech]]></category>
		<category><![CDATA[altered beast]]></category>
		<category><![CDATA[bigwig]]></category>
		<category><![CDATA[brightbox]]></category>
		<category><![CDATA[flashing rails]]></category>
		<category><![CDATA[free-software]]></category>
		<category><![CDATA[gem]]></category>
		<category><![CDATA[github]]></category>
		<category><![CDATA[isitruby19]]></category>
		<category><![CDATA[object factory]]></category>
		<category><![CDATA[passenger]]></category>
		<category><![CDATA[redmine]]></category>
		<category><![CDATA[rspec-rails extensions]]></category>
		<category><![CDATA[ruby-enterprise-edition]]></category>
		<category><![CDATA[rubyforge]]></category>
		<category><![CDATA[rujitsu]]></category>
		<category><![CDATA[warren]]></category>

		<guid isPermaLink="false">http://blog.brightbox.co.uk/?p=495</guid>
		<description><![CDATA[At Brightbox we like free and open source software. Every Brightbox runs Ubuntu, which is an operating system built on top of the GPL Linux kernel. Our infrastructure is built upon Xen, Apache, Nginx, MySQL, Nagios and many other open source software projects; not least of which are Ruby and Rails themselves. But whilst we [...]]]></description>
			<content:encoded><![CDATA[<p>At Brightbox we like free and open source software.</p>
<p>Every Brightbox runs Ubuntu, which is an operating system built on top of the GPL Linux kernel.  Our infrastructure is built upon Xen, Apache, Nginx, MySQL, Nagios and many other open source software projects; not least of which are Ruby and Rails themselves.</p>
<p>But whilst we benefit from this software, without contribution, free software is nothing, so we contribute anything we can.  The most obvious of these are the <a href="http://rubyforge.org/projects/brightbox/">Brightbox deployment gem</a> and its associated server-side tools.  These are extensions to Capistrano that help you get your application onto your Brightbox as quickly and easily as possible.</p>
<p>We also have our <tt>apt</tt> repository where we repackage a number of free software projects to make configuring your Brightbox as easy as possible.  More details on the repository are available <a href="http://wiki.brightbox.co.uk/docs:brightboxaptrepository:packages">on the wiki</a>, but the most notable are our <a href="http://wiki.brightbox.co.uk/docs:phusion-passenger">Passenger</a> and <a href="http://wiki.brightbox.co.uk/docs:ruby-enterprise">Ruby Enterprise Edition</a> packages.</p>
<p>However, nowadays, the real place for sharing your code is on <a href="http://github.com/brightbox">Github</a>.  We have a number of projects available there, ranging from the <a href="http://github.com/brightbox/flashing-rails/tree/master">tiny</a> to the <a href="http://github.com/brightbox/redmine/tree/master">large</a>.</p>
<p>These include:</p>
<ul>
<li> <a href="http://github.com/brightbox/flashing-rails/tree">Flashing rails</a>
<p>A rails plugin that makes it simple to display flash messages in your views in a consistent manner.</li>
<li> <a href="http://github.com/brightbox/rujitsu/tree">Rujitsu</a>
<p>A simple gem that collects together a number of convenience methods and various helpers.</li>
<li> <a href="http://github.com/brightbox/rspec-rails-extensions/tree">RSpec-rails extensions</a>
<p>A gem that tidies up specifying your code with <a href="http://github.com/dchelimsky/rspec-rails/tree/master">RSpec-Rails</a>.</li>
<li> <a href="http://github.com/brightbox/object-factory/tree">Object Factory</a>
<p>Brightbox&#8217;s very own answer to <a href="http://github.com/thoughtbot/factory_girl/tree/master">Factory Girl</a> or <a href="http://github.com/notahat/machinist/tree/master">Machinist</a> that lets you build your test data with minimal configuration and no fixtures.</li>
<li> <a href="http://github.com/davidsmalley/altered_beast/tree/master">Altered Beast</a> and <a href="http://github.com/brightbox/redmine/tree">Redmine</a>.
<p>We have taken our own forks of two popular Rails applications.  David&#8217;s version of Altered Beast handles the <a href="http://forum.brightbox.co.uk">Brightbox forums</a> and Redmine handles our internal bug tracking and task lists.</li>
<li> <a href="http://github.com/brightbox/warren/tree">Warren and Bigwig</a>
<p>Last, but by no means least, we have Warren and Bigwig.  These are our wrappers to AMQP and <a href="http://www.rabbitmq.com/">RabbitMQ</a>.</p>
<p>We use RabbitMQ internally to deliver messages across our various infrastructure systems and needed a simple way to interface our ruby code to Rabbit (which is implemented in Erlang).</p>
<p>This led to Warren, our wrapper over the AMQP protocol that make it simple to post messages onto the queue.</p>
<p>In order to receive and act on those messages, we also built Bigwig (no prizes for spotting the rabbit references there), which takes those messages and responds.  Bigwig matches each incoming message against a set of plugins, each plugin being small and focused on a particular task.  Unrecognised messages are discarded, ensuring that rogue commands can&#8217;t wreak havoc upon our network. <br/><strong>UPDATE</strong>: It turns out that Bigwig isn&#8217;t <em>quite</em> ready yet, as a big chunk has been rewritten.  We&#8217;ll get it out there as soon as we can.
</li>
</ul>
<p>As these are all free software projects, please take a look inside and poke around.  Any suggestions, improvements, patches or forks will be gratefully received.  Also, stay tuned for an announcement on a major project we are looking to start in the next couple of weeks.</p>
<p><strong>Update 2</strong>: We&#8217;ve also put the code for <a href="http://isitruby19.com">Isitruby19.com</a> onto <a href="http://github.com/brightbox/isitruby19/tree/master">Github</a>, under an MIT licence.  Please go to the <a href="http://forum.brightbox.co.uk/forums/isitruby19-com/topics/isitruby19-on-github">forum</a> if you have any questions.  </p>]]></content:encoded>
			<wfw:commentRss>http://blog.brightbox.co.uk/posts/free-software-and-brightbox/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Announcing isitruby19.com: tracking gem compatibility for ruby 1.9</title>
		<link>http://blog.brightbox.co.uk/posts/announcing-isitruby19com-tracking-gem-compatibility-for-ruby-19</link>
		<comments>http://blog.brightbox.co.uk/posts/announcing-isitruby19com-tracking-gem-compatibility-for-ruby-19#comments</comments>
		<pubDate>Thu, 05 Feb 2009 15:49:25 +0000</pubDate>
		<dc:creator>Rahoul Baruah</dc:creator>
				<category><![CDATA[Misc]]></category>
		<category><![CDATA[gems]]></category>
		<category><![CDATA[isitruby19]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[ruby1.9]]></category>
		<category><![CDATA[rubygems]]></category>

		<guid isPermaLink="false">http://blog.brightbox.co.uk/?p=453</guid>
		<description><![CDATA[By now you will all have heard of the release of Ruby 1.9.1 &#8211; the first, stable, production-ready release of the next-generation Ruby interpreter.  This has a number of enhancements; RubyGems is bundled with the interpreter, native threads are used instead of green threads and we have a general performance boost all round (amongst many [...]]]></description>
			<content:encoded><![CDATA[<p>By now you will all have heard of the <a title="Ruby 1.9.1 release" href="http://www.ruby-lang.org/en/news/2009/01/30/ruby-1-9-1-released/" target="_blank">release of Ruby 1.9.1</a> &#8211; the first, stable, production-ready release of the next-generation Ruby interpreter.  This has a number of enhancements; RubyGems is bundled with the interpreter, native threads are used instead of green threads and we have a general performance boost all round (amongst many others).  </p>
<p>However, there is a significant barrier to Ruby 1.9 adoption; the compatibility of the gems that we have all come to depend on.  </p>
<p>Which is why we&#8217;ve launched <a title="Is it Ruby 1.9?" href="http://isitruby19.com" target="_self">isitruby19.com</a> - a site that tracks gems and lists whether they are 1.9 compatible.  Each time you come across a gem that works for you, drop by and leave a comment, so we all get a feel for which gems need some work and which are ready today.</p>
<p><a href="http://isitruby19.com"><img class="alignnone content_image" src="http://farm4.static.flickr.com/3265/3255198111_e0157b414f.jpg" alt="" width="500" height="344" /></a></p>]]></content:encoded>
			<wfw:commentRss>http://blog.brightbox.co.uk/posts/announcing-isitruby19com-tracking-gem-compatibility-for-ruby-19/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Using RSpec, Cucumber and User stories to build our internal systems</title>
		<link>http://blog.brightbox.co.uk/posts/using-rspec-cucumber-and-user-stories-to-build-our-internal-systems</link>
		<comments>http://blog.brightbox.co.uk/posts/using-rspec-cucumber-and-user-stories-to-build-our-internal-systems#comments</comments>
		<pubDate>Fri, 21 Nov 2008 17:43:47 +0000</pubDate>
		<dc:creator>Rahoul Baruah</dc:creator>
				<category><![CDATA[Misc]]></category>
		<category><![CDATA[behaviour driven development]]></category>
		<category><![CDATA[cucumber]]></category>
		<category><![CDATA[features]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[rspec]]></category>
		<category><![CDATA[software development]]></category>
		<category><![CDATA[test driven development]]></category>
		<category><![CDATA[user stories]]></category>

		<guid isPermaLink="false">http://blog.brightbox.co.uk/?p=234</guid>
		<description><![CDATA[Here at Brightbox we are making heavy use of RSpec and Cucumber as we develop our next generation internal systems. These let us write specifications, in English and in code, for how the systems should behave. The specifications document the system for future reference and provide an automated test suite to prove that things are [...]]]></description>
			<content:encoded><![CDATA[<p>Here at Brightbox we are making heavy use of <a href="http://rspec.info/" target="_blank">RSpec</a> and <a href="http://github.com/aslakhellesoy/cucumber/tree/master" target="_blank">Cucumber</a> as we develop our next generation internal systems.  These let us write specifications, in English and in code, for how the systems should behave.  The specifications document the system for future reference and provide an automated test suite to prove that things are working as they should.</p>
<p>We chose RSpec because of its philosophy of &#8220;getting the words right&#8221;; code is often easier to write than it is read.  As these specifications are also our internal documentation they <em>must</em> be easy to read as well.</p>
<p>However, as some of this Behaviour-Driven and Story-Driven development is pretty new, there isn&#8217;t much guidance on best practice, especially when it comes to the &#8220;User Stories&#8221; (which form the basis of the system&#8217;s acceptance tests).  With that in mind, we thought we&#8217;d share our basic process we follow for each new feature.</p>
<div id="__ss_775444" style="width: 425px; text-align: left;"><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="425" height="355" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowFullScreen" value="true" /><param name="allowScriptAccess" value="always" /><param name="src" value="http://static.slideshare.net/swf/ssplayer2.swf?doc=rspec-user-stories-1227282976892036-9&amp;stripped_title=rspec-user-stories-presentation" /><embed type="application/x-shockwave-flash" width="425" height="355" src="http://static.slideshare.net/swf/ssplayer2.swf?doc=rspec-user-stories-1227282976892036-9&amp;stripped_title=rspec-user-stories-presentation" allowscriptaccess="always" allowfullscreen="true"></embed></object> </div>
<p>(Download the original presentation <a href="http://www.slideshare.net/rahoulb/rspec-user-stories-presentation/download">here</a>)</p>
<p>By the way, there&#8217;s a very subtle bug in the code; no prizes if you spot it!</p>]]></content:encoded>
			<wfw:commentRss>http://blog.brightbox.co.uk/posts/using-rspec-cucumber-and-user-stories-to-build-our-internal-systems/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Rails CSRF Security Vulnerability</title>
		<link>http://blog.brightbox.co.uk/posts/rails-csrf-security-vulnerability</link>
		<comments>http://blog.brightbox.co.uk/posts/rails-csrf-security-vulnerability#comments</comments>
		<pubDate>Wed, 19 Nov 2008 20:27:25 +0000</pubDate>
		<dc:creator>Rahoul Baruah</dc:creator>
				<category><![CDATA[Misc]]></category>
		<category><![CDATA[csrf]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[rails 2.1]]></category>
		<category><![CDATA[rails 2.2]]></category>
		<category><![CDATA[security]]></category>

		<guid isPermaLink="false">http://blog.brightbox.co.uk/?p=223</guid>
		<description><![CDATA[Users of Rails 2.1 and 2.2 need to be aware of a vulnerability in Rails&#8217; CSRF forgery protection. For those that don&#8217;t know, Rails generates an authentication token within your forms and verifies this token when the form is submitted back to your application. This prevents attackers from crafting malicious requests whilst pretending to be [...]]]></description>
			<content:encoded><![CDATA[<p>Users of <a href="http://weblog.rubyonrails.com/2008/11/18/potential-circumvention-of-csrf-protection-in-rails-2-1">Rails 2.1 and 2.2</a> need to be aware of a <a href="http://www.rorsecurity.info/journal/2008/11/19/circumvent-rails-csrf-protection.html">vulnerability</a> in Rails&#8217; <a href="http://en.wikipedia.org/wiki/Cross-site_request_forgery">CSRF</a> forgery protection.  </p>
<p>For those that don&#8217;t know, Rails generates an <a href="http://guides.rubyonrails.org/security.html#_csrf_countermeasures">authentication token</a> within your forms and verifies this token when the form is submitted back to your application.  This prevents attackers from crafting malicious requests whilst pretending to be your authenticated user.  </p>
<p>However, for certain types of request (supposedly those that cannot be generated from a browser) this authentication token is ignored &#8211; in order to make it simpler for automated API access to your application (using JSON, XML or a few other data transport types).  Unfortunately, <tt>text/plain</tt> is wrongly included as one of these types.  </p>
<p>Luckily, the fix is simple.  The long-term solution is to upgrade your application to Rails 2.1.3 or 2.2.2 (when they are released); the quick fix is even easier &#8211; tell Rails to verify <tt>text/plain</tt> requests by creating a file (called <tt>mime_type_csrf_fix.rb</tt>) in your <tt>config/initializers</tt> folder: </p>
<p><code><br />
# temporary fix for http://www.rorsecurity.info/journal/2008/11/19/circumvent-rails-csrf-protection.html<br />
Mime::Type.unverifiable_types.delete(:text)<br />
</code></p>]]></content:encoded>
			<wfw:commentRss>http://blog.brightbox.co.uk/posts/rails-csrf-security-vulnerability/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>&#8220;uninitialized constant REXML::VERSION&#8221; with Rails 2.1.1 and Rails 2.2</title>
		<link>http://blog.brightbox.co.uk/posts/uninitialized-constant-rexmlversion-with-rails-211-and-rails-22</link>
		<comments>http://blog.brightbox.co.uk/posts/uninitialized-constant-rexmlversion-with-rails-211-and-rails-22#comments</comments>
		<pubDate>Wed, 10 Sep 2008 10:48:02 +0000</pubDate>
		<dc:creator>Rahoul Baruah</dc:creator>
				<category><![CDATA[tech]]></category>
		<category><![CDATA[bugs]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[rails 2.1.1]]></category>
		<category><![CDATA[rails 2.2]]></category>
		<category><![CDATA[rexml]]></category>

		<guid isPermaLink="false">http://blog.brightbox.co.uk/?p=137</guid>
		<description><![CDATA[We&#8217;ve found a minor problem with Rails 2.1.1 (and Rails 2.2) on our Brightboxes. Because we use Ubuntu Dapper, which ships with Ruby 1.8.4, it includes an earlier version of the REXML library (for XML processing). As you may know, there was a recent security vulnerability to do with the REXML library and these latest [...]]]></description>
			<content:encoded><![CDATA[<p>We&#8217;ve found a minor problem with Rails 2.1.1 (and Rails 2.2) on our Brightboxes.  </p>
<p>Because we use Ubuntu Dapper, which ships with Ruby 1.8.4, it includes an earlier version of the REXML library (for XML processing).  As you may know, there was a recent security vulnerability to do with the REXML library and these latest two versions of Rails include a fix for this.  </p>
<p>Unfortunately, the library that ships with 1.8.4 is slightly incorrect.  Ruby conventions state that a constant should be all capitals so, quite rightly, the Rails updates check for a constant called <tt>REXML::VERSION</tt>.  However, in 1.8.4, the constant is actually called <tt>REXML::Version</tt> meaning that Rails falls over with an &#8220;<tt>uninitialized constant REXML::VERSION</tt>&#8221; error.  </p>
<p>The quick fix is to manually edit <tt> /usr/lib/ruby/1.8/rexml/rexml.rb</tt> and add a new (correctly named constant).  You will need to use sudo to edit the file, as it is owned by root; after editing the file should look something like: </p>
<pre><code>
module REXML
        Copyright = "Copyright © 2001, 2002, 2003, 2004 Sean Russell <&#x73;&#x65;&#x72;&#x40;&#x67;&#x65;&#x72;&#x6d;&#x61;&#x6e;&#x65;&#x2d;&#x73;&#x6f;&#x66;&#x74;&#x77;&#x61;&#x72;&#x65;&#x2e;&#x63;om>"
        Date = "2005/224"
        Version = "3.1.3"
        VERSION = "3.1.3"
end
</code></pre>
<p>We are also looking at our options for a permanent fix for this issue.  </p>]]></content:encoded>
			<wfw:commentRss>http://blog.brightbox.co.uk/posts/uninitialized-constant-rexmlversion-with-rails-211-and-rails-22/feed</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>RailsConf Europe 2008 Round-up</title>
		<link>http://blog.brightbox.co.uk/posts/railsconf-europe-2008-round-up</link>
		<comments>http://blog.brightbox.co.uk/posts/railsconf-europe-2008-round-up#comments</comments>
		<pubDate>Tue, 09 Sep 2008 12:53:22 +0000</pubDate>
		<dc:creator>Rahoul Baruah</dc:creator>
				<category><![CDATA[Misc]]></category>
		<category><![CDATA[2008]]></category>
		<category><![CDATA[events]]></category>
		<category><![CDATA[networking]]></category>
		<category><![CDATA[railsconf]]></category>
		<category><![CDATA[railsconf europe]]></category>
		<category><![CDATA[railsconfeurope08]]></category>

		<guid isPermaLink="false">http://blog.brightbox.co.uk/?p=102</guid>
		<description><![CDATA[The time: Tuesday the 2nd September 2008, 9am CET. The place: The Maritim proArte Hotel, Friedrichstrasse, Berlin. The plan: Brightbox set up their booth and then have a leisurely stroll around Berlin, taking in the sights, sounds and Bratwurst, before a good night&#8217;s kip and a fantastic exhibition at RailsConf Europe. That was the plan. [...]]]></description>
			<content:encoded><![CDATA[<p><img class="content_image" src="http://farm4.static.flickr.com/3077/2827096711_d16d4d71b9_d.jpg" alt="" width="500" height="375" /></p>
<p>The time: Tuesday the 2nd September 2008, 9am CET.<br />
The place: The Maritim proArte Hotel, Friedrichstrasse, Berlin.<br />
The plan: Brightbox set up their booth and then have a leisurely stroll around Berlin, taking in the sights, sounds and Bratwurst, before a good night&#8217;s kip and a fantastic exhibition at RailsConf Europe.</p>
<p>That was the plan.  Unfortunately KLM conspired against us.  A two and a half hour journey rapidly expanded into a twenty three hour marathon, involving unidentifiable hotel food, a detour via Paris, lost luggage, hysterical, smelly geeks, truffle cake and &#8220;luxury&#8221; mojitos. We were also without Neil, who bravely volunteered to stay in England installing a load of new hardware in our new racks.</p>
<p><a href="http://en.oreilly.com/railseurope2008/public/content/home">RailsConf Europe</a> is pretty much the biggest Ruby on Rails event on our continent.  We were told there were about 800 attendees here (although RailsConf US in Portland, earlier in the year, had twice as many).  With that in mind Brightbox stepped up to become gold sponsors of the event, providing us with a booth between <a href="http://www.elctech.com/">ELC Technologies</a>, a global agile development shop, and <a href="http://www.fiveruns.com/">Five Runs</a>, the Rails profiling tool, who we <a href="http://www.brightbox.co.uk/about/partners#fiveruns">know quite well</a>.</p>
<p>We didn&#8217;t get the chance to see many sessions, but there was a pre-conference Q&amp;A session on Tuesday evening with David Heinemeier Hansson (DHH), Jeremy Kemper and Michael Koziarski. It was interesting to hear DHH praising 37signals&#8217; Xen virtualisation setup (this being the platform we also currently use), later on I chatted with him and explained how we&#8217;re working hard to get a production-ready Rails stack included with Ubuntu; which will help when setting up your servers, even if you don&#8217;t choose Brightbox.</p>
<p>DHH also opened the conference proper on Wednesday morning with his Keynote on dealing with legacy code.  This was interesting to me as, like most developers, I am often overwhelmed by the urge to rewrite code that I wrote a few months ago.  This was followed, later in the day, by Jeremy Kemper talking about performance improvements &#8211; in particular the new features in Rails that make use of the facilities that HTTP provides.</p>
<p>Overall, however, the consensus seemed to be that the talks were solid but uninspiring (apart from our very own <a href="http://www.monkeyhelper.com/">Rob Lee</a> with a talk on semantic markup, dressed in a Brightbox t-shirt).</p>
<p>At the booth things were mental &#8211; especially in the first break. All the free Brightbox t-shirts vanished in less than ten minutes, as did the &#8220;I love Ruby&#8221; stickers.  However, our giveaway was nowhere near as good as ELCs &#8211; they had free beer!</p>
<p>We did meet some of our existing customers (a few for the first time in real life) and a lot of prospects.  Interestingly, at least from our point of view, we saw a lot of interest in our Managed Cluster services (where we build and maintain a high availability cluster of boxes for you).</p>
<p>An evening out with a load of our friends from Yorkshire (the aforementioned <a href="http://www.monkeyhelper.com">Rob</a> and <a href="http://www.urbanwide.com">Deb</a>, <a href="http://fametastic.co.uk/">Louisa</a>, <a href="http://deaddeadgood.com">Paul</a> and Charmagne) ended my involvement with RailsConf (I had to fly back early because my babby was starting school) but John and Jeremy stayed on till the very end.</p>
<p>Overall, the travel was horrible, the food was great (I had the best burger I&#8217;ve ever eaten at a hotel just off Friedrichstrasse) and the conference was good.  Berlin is a magnificent city and we had a fantastic time with some old friends and made some new great new ones.  So that&#8217;s our story &#8211; how was it for you?</p>]]></content:encoded>
			<wfw:commentRss>http://blog.brightbox.co.uk/posts/railsconf-europe-2008-round-up/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

