<?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>LRBlog &#187; Web Security</title>
	<atom:link href="http://blog.lrdesign.com/category/web-security/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.lrdesign.com</link>
	<description>Logical Reality Design: Web Design and Software Development</description>
	<lastBuildDate>Thu, 08 Jul 2010 01:40:49 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Bypassing mass assignment for update_attributes</title>
		<link>http://blog.lrdesign.com/2009/03/bypassing-mass-assignment-for-update_attributes/</link>
		<comments>http://blog.lrdesign.com/2009/03/bypassing-mass-assignment-for-update_attributes/#comments</comments>
		<pubDate>Sat, 14 Mar 2009 21:45:05 +0000</pubDate>
		<dc:creator>Evan</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[Web Security]]></category>
		<category><![CDATA[Active Record]]></category>
		<category><![CDATA[mass assignment]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[update_attributes]]></category>

		<guid isPermaLink="false">http://blog.lrdesign.com/?p=51</guid>
		<description><![CDATA[I've been following this excellent post by M. Hartl and this post by E. Chapweske banishing mass assignment from one of my Rails applications due to launch soon. I'm following Chapweske's approach of blocking mass assignment by default in all models, by putting this line in an initializer: ActiveRecord::Base.send(:attr_accessible, nil) This had the expected side [...]]]></description>
			<content:encoded><![CDATA[<p>I've been following <a href="http://blog.insoshi.com/2008/09/21/finding-and-fixing-mass-assignment-problems-in-rails-applications/#">this excellent post by M. Hartl</a> and <a href="http://railspikes.com/2008/9/22/is-your-rails-application-safe-from-mass-assignment">this post by E. Chapweske</a> banishing mass assignment from one of my Rails applications due to launch soon.</p>
<p>I'm following Chapweske's approach of blocking mass assignment by default in all models, by putting this line in an initializer:</p>
<p><code>ActiveRecord::Base.send(:attr_accessible, nil)</code></p>
<p>This had the expected side effect of breaking several zillion tests, because tests frequently use things like Model.build() and Model.create!() to generate on-demand fixtures during testing.  Hartl has a great bit of code that creates unsafe_build() and unsafe_create() methods in ActiveRecord.   You can use these methods instead of build() and create() to function as expected in your tests.</p>
<p>This works great, except that I also use the mass-assignment method update_attributes! in my tests and specs frequently, particularly when I want to spec the effect a change on one model has on an associated models' methods.   So, I expanded on Hartl's helper code a bit, to give myself the necessary methods.   In case it helps anyone else:</p>
<h4>/lib/initializers/unsafe_build_and_create.rb</h4>
<p><code>class ActiveRecord::Base</p>
<p>  # Build and create records unsafely, bypassing attr_accessible.<br />
  # These methods are especially useful in tests and in the console.</p>
<p>  def self.unsafe_build(attrs)<br />
    record = new<br />
    record.unsafe_attributes = attrs<br />
    record<br />
  end</p>
<p>  def self.unsafe_create(attrs)<br />
    record = unsafe_build(attrs)<br />
    record.save<br />
    record<br />
  end</p>
<p>  def self.unsafe_create!(attrs)<br />
    unsafe_build(attrs).save!<br />
  end</p>
<p>  def unsafe_update_attributes!(attrs)<br />
    self.unsafe_attributes = attrs<br />
    self.save!<br />
  end</p>
<p>  def unsafe_update_attributes(attrs)<br />
    self.unsafe_attributes = attrs<br />
    self.save<br />
  end</p>
<p>  def unsafe_attributes=(attrs)<br />
    attrs.each do |k, v|<br />
      send("#{k}=", v)<br />
    end<br />
  end<br />
end</code></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.lrdesign.com/2009/03/bypassing-mass-assignment-for-update_attributes/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Likely web scam notice: webatrades.com</title>
		<link>http://blog.lrdesign.com/2008/05/likely-web-scam-notice-webatradescom/</link>
		<comments>http://blog.lrdesign.com/2008/05/likely-web-scam-notice-webatradescom/#comments</comments>
		<pubDate>Tue, 27 May 2008 03:54:34 +0000</pubDate>
		<dc:creator>Evan</dc:creator>
				<category><![CDATA[Web Security]]></category>
		<category><![CDATA[Craigslist]]></category>
		<category><![CDATA[escrow]]></category>
		<category><![CDATA[scam]]></category>
		<category><![CDATA[used car]]></category>
		<category><![CDATA[webatrades.com]]></category>

		<guid isPermaLink="false">http://blog.lrdesign.com/?p=22</guid>
		<description><![CDATA[Looking for used cars on Craig's List, my girlfriend and I found what appears to be a classic web escrow auto scam: Web Auto Trades. An ad we responded to (a used Honda Accord at a surprisingly low price for the mileage) claimed to be using their service, which included a "five day guarantee" if [...]]]></description>
			<content:encoded><![CDATA[<p>Looking for used cars on <a href="http://craigslist.com">Craig's List</a>, my girlfriend and I found what appears to be a classic web escrow auto scam: <a href="http://webatrades.com">Web Auto Trades</a>.   An ad we responded to (a used Honda Accord at a surprisingly low price for the mileage) claimed to be using their service, which included a "five day guarantee" if you didn't like the car, and said we wouldn't have to meet the seller in person.   These are all signs of a typical scam: buyer beware!   </p>
<p>Other scam signs: though their snazzy flash-based website presents them as worldwide experts in escrow services, a google search for their domain name results in <strong>zero hits</strong>, and the domain has only been registered for five days and lists no telephone contacts:</p>
<p><code><br />
Registrant:<br />
Domain Privacy Group, Inc.<br />
c/o webatrades.com,<br />
5160 Yonge St. Suite 1800<br />
Toronto, ON M2N 6L9<br />
CA</p>
<p>Domain name: webatrades.com</p>
<p>Administrative Contact:<br />
Domain Privacy Group, Inc. privacy-356772@domainprivacygroup.com<br />
c/o webatrades.com,<br />
5160 Yonge St. Suite 1800<br />
Toronto, ON M2N 6L9<br />
CA<br />
Fax:</p>
<p>Technical Contact:<br />
Domain Privacy Group, Inc. privacy-356772@domainprivacygroup.com<br />
c/o webatrades.com,<br />
5160 Yonge St. Suite 1800<br />
Toronto, ON M2N 6L9<br />
CA<br />
Fax: </p>
<p>Registrar of Record: Netfirms Inc.<br />
Record expires on 2009-05-21.<br />
Record created on 2008-05-21.<br />
Database last updated on 2008-05-28 12:54:04.<br />
</code></p>
<p>If you are finding this post because you googled their address after considering buying a car from someone using their service, I strongly consider you to avoid doing business with them, or at least to investigate the company much more thoroughly.   Check with your state's attorney general's office to see if they've heard of them or have any complaints, and also consider checking with the BBB.   Be very careful not to have your money taken by escrow scams, which this company gives every appearance of being.</p>
<p>Here's a screenshot of their front page, in case they pop up somewhere later under a different name.</p>
<p><a href='http://blog.lrdesign.com/wp-content/uploads/2008/05/web-auto-trades.png'><img src="http://blog.lrdesign.com/wp-content/uploads/2008/05/web-auto-trades-300x272.png" alt="This looks like an auto escrow scam." title="Web Auto Trades Front Page" width="300" height="272" class="size-medium wp-image-23" /></a></p>
<h2>Update: How to Avoid Escrow Fraud</h2>
<p>Here are some useful links on escrow fraud, what it is, and how to avoid it:</p>
<ul>
<li><a href="http://blogs.zdnet.com/threatchaos/?p=519">Escrow fraud ruining Craigslist?</a></li>
<li><a href="http://en.wikipedia.org/wiki/Bogus_escrow">Wikipedia article on Bogus Escrow</a></li>
<li><a href="http://www.lets-ride.com/classifiedadvertisements/tipsforspottingfraud.htm">Tips for Spotting Escrow Fraud</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.lrdesign.com/2008/05/likely-web-scam-notice-webatradescom/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
	</channel>
</rss>
