<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" version="2.0">

<channel>
	<title>imedo Development Blog</title>
	
	<link>http://devblog.imedo.de</link>
	<description>there is no charge for awesomeness</description>
	<lastBuildDate>Thu, 18 Feb 2010 13:44:08 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/imedo_devblog" /><feedburner:info xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" uri="imedo_devblog" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>Multipage validator</title>
		<link>http://devblog.imedo.de/2010/02/18/multipage-validator/</link>
		<comments>http://devblog.imedo.de/2010/02/18/multipage-validator/#comments</comments>
		<pubDate>Thu, 18 Feb 2010 13:44:08 +0000</pubDate>
		<dc:creator>ehartung</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Testing]]></category>

		<guid isPermaLink="false">http://devblog.imedo.de/?p=52241</guid>
		<description><![CDATA[If you need a quick overview whether the internal links of your website are working and the markup is valid, checkout the Multipage Validator tool.
]]></description>
			<content:encoded><![CDATA[<p>If you need a quick overview whether the internal links of your website are working and the markup is valid, checkout the <a href="http://validator.ca">Multipage Validator</a> tool.</p>
<img src="http://devblog.imedo.de/?ak_action=api_record_view&id=52241&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://devblog.imedo.de/2010/02/18/multipage-validator/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>New version of CI output formatter available</title>
		<link>http://devblog.imedo.de/2010/02/16/new-version-of-ci-output-formatter-available/</link>
		<comments>http://devblog.imedo.de/2010/02/16/new-version-of-ci-output-formatter-available/#comments</comments>
		<pubDate>Tue, 16 Feb 2010 11:21:07 +0000</pubDate>
		<dc:creator>ehartung</dc:creator>
				<category><![CDATA[Open Source Releases]]></category>
		<category><![CDATA[Testing]]></category>

		<guid isPermaLink="false">http://devblog.imedo.de/?p=52238</guid>
		<description><![CDATA[With Cucumber 0.4 the API for the output formatters has been changed. We updated our output formatter according to these changes. It is now compatible with Cucumber versions 0.4.x to 0.6.x.
The the updated code can be found here: imedo_ci_formatter.rb
]]></description>
			<content:encoded><![CDATA[<p>With <a href="http://cukes.info">Cucumber</a> 0.4 the API for the output formatters has been changed. We updated our <a href="../2009/4/28/ci-output-formatter-for-cucumber-0-3">output formatter</a> according to these changes. It is now compatible with Cucumber versions 0.4.x to 0.6.x.</p>
<p>The the updated code can be found here: <a href="https://gist.github.com/raw/217658/32198667066a43f8c2a42c082acde412fe71d193/imedo_ci_formatter.rb">imedo_ci_formatter.rb</a></p>
<img src="http://devblog.imedo.de/?ak_action=api_record_view&id=52238&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://devblog.imedo.de/2010/02/16/new-version-of-ci-output-formatter-available/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Parameter pollution with JSON</title>
		<link>http://devblog.imedo.de/2010/01/09/parameter-pollution-with-json/</link>
		<comments>http://devblog.imedo.de/2010/01/09/parameter-pollution-with-json/#comments</comments>
		<pubDate>Sat, 09 Jan 2010 10:54:04 +0000</pubDate>
		<dc:creator>ehartung</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[input validation]]></category>
		<category><![CDATA[JSON]]></category>
		<category><![CDATA[parameter pollution]]></category>

		<guid isPermaLink="false">http://devblog.imedo.de/?p=52230</guid>
		<description><![CDATA[Nice approach for circumventing input validation for JSON: Parameter Pollution with JSON.
Be sure to have your input validation handle this kind of injection attacks.
]]></description>
			<content:encoded><![CDATA[<p>Nice approach for circumventing input validation for JSON: <a href="http://www.greebo.net/2010/01/08/parameter-pollution-with-json/">Parameter Pollution with JSON</a>.</p>
<p>Be sure to have your <a href="http://devblog.imedo.de/2009/09/01/secure-coding-with-ruby-on-rails-1-input-validation/">input validation</a> handle this kind of injection attacks.</p>
<img src="http://devblog.imedo.de/?ak_action=api_record_view&id=52230&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://devblog.imedo.de/2010/01/09/parameter-pollution-with-json/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Choosing a good web password</title>
		<link>http://devblog.imedo.de/2009/12/16/choosing-a-good-web-password/</link>
		<comments>http://devblog.imedo.de/2009/12/16/choosing-a-good-web-password/#comments</comments>
		<pubDate>Tue, 15 Dec 2009 22:14:20 +0000</pubDate>
		<dc:creator>ehartung</dc:creator>
				<category><![CDATA[Security]]></category>
		<category><![CDATA[Bruce Schneier]]></category>
		<category><![CDATA[microsoft]]></category>
		<category><![CDATA[MySpace]]></category>
		<category><![CDATA[password]]></category>
		<category><![CDATA[user name]]></category>

		<guid isPermaLink="false">http://devblog.imedo.de/?p=52186</guid>
		<description><![CDATA[Most web applications depend on user name password combinations in order to authorize user access. Hence one of the biggest security problems in the world wide web are weak passwords. Users choose easy to guess password because they are easy to remember. In this article some hints are given which should help choosing a good [...]]]></description>
			<content:encoded><![CDATA[<p>Most web applications depend on user name password combinations in order to authorize user access. Hence one of the biggest security problems in the world wide web are weak passwords. Users choose easy to guess password because they are easy to remember. In this article some hints are given which should help choosing a good password and remembering it, because good user passwords increase the overall security of a web application.</p>
<p>In 2006 Bruce Schneier, a well known security expert, <a href="http://www.schneier.com/blog/archives/2006/12/realworld_passw.html">analyzed 34,000 MySpace passwords</a> which were collected by a pishing attack. The most common of these passwords were password1, abc123, myspace1, password, blink182, qwerty1, fuckyou, 123abc, baseball1, football1, 123456, soccer, monkey1, liverpool1, princess1, jordan23, slipknot1, superman1, iloveyou1, and monkey.</p>
<p>Recently Microsoft published <a href="http://blogs.technet.com/mmpc/archive/2009/11/27/do-and-don-ts-for-p-w0rd.aspx">the results of a one year study</a> in which Microsoft monitored automated attacks against user accounts with a fake FTP server. From the collected data they generated statistics of the most common used user names and passwords for this kind of attack. In case of passwords the top 10 consists of password, 123456, #!comment:, changeme, Fuckyou, abc123, peter, Michael, andrew, and matthew.</p>
<p>Both analysis underline the basic thesis of this article. Users tend to choose simple passwords which would not resist a dictionary attack and the bad guys are aware of this vulnerability and try to exploit it.</p>
<p>From their analysis Microsoft derived three basic hints which should be remembered when choosing a password. These hints should be presented to users of web applications during signup.</p>
<ol>
<li>Use a combination of letters, numbers and special characters. Also, remember that some dictionaries used in attacks have a &#8220;l33t&#8221; mode, which allows common letter/number-to-special character substitutions (like changing a-@, i-1 ,o-0 and s=$, for example, password = p@$$w0rd). Therefore, mix them in different ways so that they are not predictable.</li>
<li>Use a combination of upper and lower case letters.</li>
<li>Make it lengthy. A longer password does not necessarily mean it is strong but it can help in some cases.</li>
</ol>
<p>Bruce Schneier recommends to <a href="http://www.schneier.com/blog/archives/2005/06/write_down_your.html">write passwords down and keep them with your valuable things</a> in e.g. your wallet, since passwords which are not based on a dictionary are hard to remember. But remember to change them like you cancel your credit card in case you lose your wallet.</p>
<img src="http://devblog.imedo.de/?ak_action=api_record_view&id=52186&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://devblog.imedo.de/2009/12/16/choosing-a-good-web-password/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Run Javascript, Run!</title>
		<link>http://devblog.imedo.de/2009/12/15/run-javascript-run/</link>
		<comments>http://devblog.imedo.de/2009/12/15/run-javascript-run/#comments</comments>
		<pubDate>Tue, 15 Dec 2009 13:14:10 +0000</pubDate>
		<dc:creator>agroves</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[textmate]]></category>
		<category><![CDATA[v8]]></category>

		<guid isPermaLink="false">http://devblog.imedo.de/?p=52191</guid>
		<description><![CDATA[We&#8217;re pretty much a Mac shop here at imedo and, as our application is built using Ruby on Rails, it&#8217;s safe to say that we are legally obliged to use TextMate for all our editing needs  .
One of the features I love about TextMate, catered for in most bundles, is the ability to execute [...]]]></description>
			<content:encoded><![CDATA[<p>We&#8217;re pretty much a Mac shop here at <a href="http://imedo.de">imedo</a> and, as our application is built using Ruby on Rails, it&#8217;s safe to say that we are legally obliged to use <a href="http://macromates.com">TextMate</a> for all our editing needs <img src='http://devblog.imedo.de/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> .</p>
<p>One of the features I love about TextMate, catered for in most bundles, is the ability to execute a script and get a nice pop-up window displaying the results. Scrolling through my installed language bundles, I see they all have a &#8220;Run Script&#8221; command. All, that is, except my second favourite language &#8211; Javascript. You fancy rectifying this? You fancy giving Javascript some TextMate/V8 lurv? Then walk this way …</p>
<p>First, lets grab V8. We&#8217;ll be using scons to build it. Scons? Aren&#8217;t they a strange  muffin-like concoction originating in the fair British Isles? That&#8217;ll be &#8216;<a href="http://en.wikipedia.org/wiki/Scone_%28bread%29">scones</a>&#8216; you&#8217;re thinking of. Scons is a software construction tool written in Python. Check it out at <a href="http://www.scons.org/">here</a>. It must be good &#8211; Zed likes it. Install with macports.</p>
<p>And on with the build.</p>
<p>Get v8:</p>
<p><code>$&gt; svn co http://v8.googlecode.com/svn/trunk v8</code><br />
- or -<br />
<code>$&gt; git clone git://github.com/v8/v8.git v8</code><br />
&#8230;<br />
<code>$&gt; cd v8<br />
$&gt; scons</code></p>
<p>The build should have been successful. V8 comes with a shell which we&#8217;re going to use. Build like so:</p>
<p><code>$&gt; g++ ./samples/shell.cc -o v8-shell -I include libv8.a</code></p>
<p>Make sure that &#8216;v8-shell&#8217; is in your PATH. And now for the final step. In TextMate: Bundles &gt; Bundle Editor &gt; Show Bundle Editor. Scroll down to the Javascript bundle and Create a new Command. We&#8217;ll use our imagination here and call it &#8220;Run Script&#8221;. In the Edit Command Window:</p>
<p>Save: Nothing<br />
Command(s):</p>
<p><code><br />
$(type -p "${TM_RUBY:-ruby}") -e'<br />
require ENV["TM_SUPPORT_PATH"] + "/lib/tm/executor"<br />
require ENV["TM_SUPPORT_PATH"] + "/lib/tm/save_current_document"<br />
TextMate.save_current_document<br />
TextMate::Executor.make_project_master_current_document<br />
TextMate::Executor.run("v8-shell", ENV["TM_FILEPATH"])'<br />
</code></p>
<p>Input: Entire Document<br />
Output: Show as HTML<br />
Activation: Key Equivalent &gt; Cmd+R<br />
Scope Selector: source.js</p>
<p>This is copied and adapted from the &#8220;Run Script&#8221; Command for the Ruby bundle.</p>
<p>And that &#8211; as they say &#8211; is that. Time to check it out:</p>
<p>Open a new window in TextMate and type the following:</p>
<p><code>function addSomeValues (first, second) {<br />
return first + second;<br />
}</code></p>
<p><code>print(addSomeValues(2,3))</code></p>
<p>Select the Javascript scope. Wait for it &#8230; Ready? &#8230; Go Cmd+R! Hopefully you saw the number five.</p>
<p>Now change the last line to read</p>
<p><code>print(addSomeValueCATsaTOnKeyboArD(2,3))</code></p>
<p>Run again and you should get a nice ReferenceError.</p>
<p>Thanks go to gs over at StackOverflow for <a href="http://stackoverflow.com/questions/1802478/running-v8-javascript-engine-standalone">this post</a> detailing the steps for getting the v8 shell built.</p>
<img src="http://devblog.imedo.de/?ak_action=api_record_view&id=52191&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://devblog.imedo.de/2009/12/15/run-javascript-run/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Smusher is crushing your images</title>
		<link>http://devblog.imedo.de/2009/12/15/smusher-is-crushing-your-images/</link>
		<comments>http://devblog.imedo.de/2009/12/15/smusher-is-crushing-your-images/#comments</comments>
		<pubDate>Tue, 15 Dec 2009 10:35:33 +0000</pubDate>
		<dc:creator>mscherf</dc:creator>
				<category><![CDATA[Development]]></category>

		<guid isPermaLink="false">http://devblog.imedo.de/?p=52189</guid>
		<description><![CDATA[Another short tip, because I really like the smusher gem!
first install it:
gem install smusher
then crush your images automatically using the PunyPng service, which is currently delivering the best results in terms of file size:
smusher * --service PunyPng
]]></description>
			<content:encoded><![CDATA[<p>Another short tip, because I really like the smusher gem!</p>
<p>first install it:<br />
<code>gem install smusher</code></p>
<p>then crush your images automatically using the PunyPng service, which is currently delivering the best results in terms of file size:<br />
<code>smusher * --service PunyPng</code></p>
<img src="http://devblog.imedo.de/?ak_action=api_record_view&id=52189&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://devblog.imedo.de/2009/12/15/smusher-is-crushing-your-images/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PDF2PNG – PDF Thumbnail Generator Script</title>
		<link>http://devblog.imedo.de/2009/12/10/pdf2png-pdf-thumbnail-generator-scrript/</link>
		<comments>http://devblog.imedo.de/2009/12/10/pdf2png-pdf-thumbnail-generator-scrript/#comments</comments>
		<pubDate>Thu, 10 Dec 2009 10:07:15 +0000</pubDate>
		<dc:creator>mscherf</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[pdf]]></category>
		<category><![CDATA[pdf2png]]></category>
		<category><![CDATA[png]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://devblog.imedo.de/2009/12/10/pdf2png-pdf-thumbnail-generator-scrript/</guid>
		<description><![CDATA[If you need to generate thumbnails of the first pages of alot of PDF documents you can use this tiny ruby script:
http://bit.ly/8T0B1a
I also included smusher support to crush the PNGs after they were created. Just gem install smusher and uncomment the smusher command.
Enjoy!
]]></description>
			<content:encoded><![CDATA[<p>If you need to generate thumbnails of the first pages of alot of PDF documents you can use this tiny ruby script:<br />
<a href="http://bit.ly/8T0B1a">http://bit.ly/8T0B1a</a><br />
I also included smusher support to crush the PNGs after they were created. Just gem install smusher and uncomment the smusher command.</p>
<p>Enjoy!</p>
<img src="http://devblog.imedo.de/?ak_action=api_record_view&id=52176&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://devblog.imedo.de/2009/12/10/pdf2png-pdf-thumbnail-generator-scrript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Is your web server up-to-date?</title>
		<link>http://devblog.imedo.de/2009/12/08/is-your-web-server-up-to-date/</link>
		<comments>http://devblog.imedo.de/2009/12/08/is-your-web-server-up-to-date/#comments</comments>
		<pubDate>Tue, 08 Dec 2009 10:02:03 +0000</pubDate>
		<dc:creator>ehartung</dc:creator>
				<category><![CDATA[Security]]></category>
		<category><![CDATA[attack]]></category>
		<category><![CDATA[exploit]]></category>
		<category><![CDATA[Metasploit]]></category>
		<category><![CDATA[Shodan]]></category>
		<category><![CDATA[web server]]></category>

		<guid isPermaLink="false">http://devblog.imedo.de/?p=52169</guid>
		<description><![CDATA[Here is an interesting article about the search engine Shodan which is supposed to find web servers instead of web pages. This means that one can e.g. search for a particular web server version in one country.
Finding vulnerable web servers with Shodan is as easy as using Google. Hence in combination with the Metasploit exploit [...]]]></description>
			<content:encoded><![CDATA[<p>Here is an <a href="http://erratasec.blogspot.com/2009/12/shodan-scares-me.html">interesting article</a> about the search engine <a href="http://shodan.surtri.com">Shodan</a> which is supposed to find web servers instead of web pages. This means that one can e.g. search for a particular web server version in one country.</p>
<p>Finding vulnerable web servers with Shodan is as easy as using Google. Hence in combination with the <a href="http://www.metasploit.com">Metasploit</a> exploit framework now almost everybody is able to easily run attacks against unpatched web servers.</p>
<p>So, have you installed the latest security updates for your web server?</p>
<img src="http://devblog.imedo.de/?ak_action=api_record_view&id=52169&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://devblog.imedo.de/2009/12/08/is-your-web-server-up-to-date/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Secure coding with Ruby on Rails 7: Cross-site request forgery (CSRF)</title>
		<link>http://devblog.imedo.de/2009/12/04/secure-coding-with-ruby-on-rails-7-cross-site-request-forgery-csrf/</link>
		<comments>http://devblog.imedo.de/2009/12/04/secure-coding-with-ruby-on-rails-7-cross-site-request-forgery-csrf/#comments</comments>
		<pubDate>Fri, 04 Dec 2009 14:45:56 +0000</pubDate>
		<dc:creator>ehartung</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[cross-side request forgery]]></category>
		<category><![CDATA[csrf]]></category>
		<category><![CDATA[ruby on rails]]></category>
		<category><![CDATA[secure coding]]></category>

		<guid isPermaLink="false">http://devblog.imedo.de/?p=52096</guid>
		<description><![CDATA[Although discovered already in 1988 by Norm Hardy, cross-site request forgery (CSRF) has been the shooting star of web attacks in 2008. As a result it has become one of the 2009 CWE/SANS Top 25 Most Dangerous Programming Errors.
The idea behind CSRF is that an attacker sends a malicious request to the target application using [...]]]></description>
			<content:encoded><![CDATA[<p>Although discovered already in 1988 by <a href="http://www.cis.upenn.edu/~KeyKOS/ConfusedDeputy.html">Norm Hardy</a>, <a href="http://cwe.mitre.org/data/definitions/352.html">cross-site request forgery (CSRF)</a> has been the shooting star of web attacks in 2008. As a result it has become one of the <a href="http://cwe.mitre.org/top25/">2009 CWE/SANS Top 25 Most Dangerous Programming Errors</a>.</p>
<p>The idea behind CSRF is that an attacker sends a malicious request to the target application using a trusted connection which he expects to have been established by an innocent user. In case of web applications this could be done by hiding the request in a web page with harmless content. If the user visits the malicious web page while he is logged in to the target application in another browser tab, the dangerous request is send to the target over the trusted connection between browser and web application. Two basic scenarios are possible. In the first scenario the attacker forges a request to a commonly used web application so that it doesn&#8217;t matter who opens the malicious web page. The other scenario is to trick somebody who is known to have special privileges for one web application to open the prepared web page.</p>
<p>In both scenarios the malicious web page of the attacker is crafted so that it sends a hidden request to the target application. For example a HTTP GET request could be executed by using the <em>src</em> attribute of an <em>img</em> tag like in the following line of code. In this case it would delete one user account.</p>
<pre>
<pre>&lt;img src="http://victim.example.com/user/destroy/1" /&gt;</pre>
</pre>
<p>Another possibility to hide a request in a web page is displayed in the next example. It&#8217;s a hidden HTTP POST request which changes the name and email address of the logged in user. It sends the request automatically on page load. With the changed email address the attacker can use the &#8220;forgot password?&#8221; function in order to receive a newly generated password and capture the account.</p>
<pre>
<pre>&lt;SCRIPT&gt;
  function SendAttack() {
    var form = document.createElement("form");
    form.style.display = "none";
    this.parentNode.appendChild(form);
    form.method = "POST";
    form.action = "http://victim.example.com/profile.php";
    form.first_name = "Bad";
    form.last_name = "Guy";
    form.email = "attacker@example.com";
    form.submit();
  }
&lt;/SCRIPT&gt;
&lt;BODY onload="javascript:SendAttack();"&gt;&lt;/BODY&gt;</pre>
</pre>
<p>These two examples demonstrate that HTTP GET as well as HTTP POST are vulnerable by CSRF. Hence it is not enough to allow only POST requests to alter data. Other measure need to be applied, too. An obvious client-side countermeasures is to use separate browsers for surfing and administration, but Rails provides a server-side measure as well. The method <a href="http://api.rubyonrails.org/classes/ActionController/RequestForgeryProtection/ClassMethods.html#M000514"><em>protect_from_forgery()</em></a> automatically inserts a security token in all forms and Ajax request generated by Rails. The token is calculated from the current session and the server-side secret. If the session storage is not <em>CookieStorage</em> the secret needs to be passed as option to the method. If an attacker is trying to send a request without the valid token to the application an <em>ActionController::InvalidAuthenticityToken</em> error is raised.</p>
<p>In Rails versions newer than 2.0 <em>protect_from_forgery()</em> is called for all HTTP POST requests by default. Hence it only has to be taken care of that HTTP GET  and HTTP POST requests are used appropriately (see <a href="http://www.w3.org/2001/tag/doc/whenToUseGet.html#checklist">W3C checklist</a>) and that this is enforced. For assuring that actions are only called by HTTP POST requests Rails provides the <a href="http://api.rubyonrails.org/classes/ActionController/Verification/ClassMethods.html#M000521"><em>verify()</em></a> method which can be added to a controller as demonstrated in the following example. It is also shown how to define actions which should be callable by other HTTP methods than POST with the <em>except</em> option.</p>
<pre>
<pre>class MyController &lt; ApplicationController
  verify :method =&gt; "post", :except =&gt; :index
end</pre>
</pre>
<p>In older Rails versions the <em>protect_from_forgery()</em> method can be used like shown in the following lines of code. In this example CSRF protection is disabled for the <em>index</em> action.</p>
<pre>
<pre>class MyController &lt; ApplicationController
  protect_from_forgery :except =&gt; :index
end</pre>
</pre>
<p>For further information on cross-side request forgery see <a href="http://www.cgisecurity.com/csrf-faq.html">www.cgisecurity.com/csrf-faq.html</a>.</p>
<img src="http://devblog.imedo.de/?ak_action=api_record_view&id=52096&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://devblog.imedo.de/2009/12/04/secure-coding-with-ruby-on-rails-7-cross-site-request-forgery-csrf/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Matching elements on complex web pages with Webrat 2</title>
		<link>http://devblog.imedo.de/2009/11/25/matching-elements-on-complex-web-pages-with-webrat-2/</link>
		<comments>http://devblog.imedo.de/2009/11/25/matching-elements-on-complex-web-pages-with-webrat-2/#comments</comments>
		<pubDate>Wed, 25 Nov 2009 16:46:36 +0000</pubDate>
		<dc:creator>ehartung</dc:creator>
				<category><![CDATA[Testing]]></category>
		<category><![CDATA[have_xpath]]></category>
		<category><![CDATA[webrat]]></category>
		<category><![CDATA[xpath]]></category>

		<guid isPermaLink="false">http://devblog.imedo.de/?p=52117</guid>
		<description><![CDATA[In the first part of this article it was shown how to use CSS selectors for matching elements on complex web pages. But selectors are not the only way of matching HTML elements, Webrat also supports matching via XPath.
XPath matchers can be combined with CSS-selector matchers. This is really useful if not, for example, the [...]]]></description>
			<content:encoded><![CDATA[<p>In the <a href="http://devblog.imedo.de/2009/11/12/matching-elements-on-complex-web-pages-with-webrat/">first part of this article</a> it was shown how to use <a title="CSS selectors" href="http://www.w3.org/TR/css3-selectors/">CSS selectors</a> for matching elements on complex web pages. But selectors are not the only way of matching HTML elements, <a title="Webrat" href="http://gitrdoc.com/brynary/webrat/tree/master/">Webrat</a> also supports matching via <a href="http://www.w3.org/TR/xpath">XPath</a>.</p>
<p>XPath matchers can be combined with CSS-selector matchers. This is really useful if not, for example, the content of an element should be matched but the element itself like in the following example. Here a form is used to display data as default value in its input elements. This can be the case in web applications in which data should be edited easily without additional clicks.</p>
<pre>&lt;div id="content"&gt;
  &lt;form&gt;
    Label 1: &lt;input id="entry_1" name="entry[1]" value="Entry 1"/&gt;
    Label 2: &lt;input id="entry_2" name="entry[2]" value="Entry 2"/&gt;
    &lt;input type="submit"&gt;
   &lt;/form&gt;
&lt;/div&gt;</pre>
<p>Matching the default values of input elements with Webrat can look like the following lines of code. It is a nested combination of CSS-selector and XPath matching in order to have a readable error message if the actual output differs from the expected.</p>
<pre>
<pre>response.body.should have_selector("#content") do |content|
  content.should have_tag("form") do |form|
    form.should have_selector("#entry_1") do |input|
      input.should have_xpath("@value") do |value|
        value.should contain("Entry 1")
      end
    end
  end
end</pre>
</pre>
<p>XPath matchers are currently not support by Webrat&#8217;s <em>within()</em> method and therefore cannot be used to limit the area on a web page where an action should take place, e.g. clicking of a link. They can only be used for evaluating the response of an action.</p>
<img src="http://devblog.imedo.de/?ak_action=api_record_view&id=52117&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://devblog.imedo.de/2009/11/25/matching-elements-on-complex-web-pages-with-webrat-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
