[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

SAFE levels

Tom Allison

2/12/2006 1:55:00 PM

Is there somewhere I can find some description on the proper care and feeding of
Ruby SafeLevels?

I was going to start looking into Rails, but the notion of SafeLevel = 0 being a
requirement is kind of a "really bad idea" (Assumption: this is still valid for
mod_ruby) in my opinion.

But it can still be useful to work under CGI (again, assuming the SafeLevel can
be >0) and not worry about doing something fundamentally dumb.

From a Perl background much of this makes wonderful sense until I get to the
SafeLevel of a tainted object. How do you cleans such a beast? untainting
strings is trivial, but larger objects... My Perl background fails me at this
point.


3 Answers

David Vallner

2/12/2006 8:13:00 PM

0

Dna Nedela 12 Február 2006 14:54 Tom Allison napísal:
> Is there somewhere I can find some description on the proper care and
> feeding of Ruby SafeLevels?
>
> I was going to start looking into Rails, but the notion of SafeLevel = 0
> being a requirement is kind of a "really bad idea" (Assumption: this is
> still valid for mod_ruby) in my opinion.
>
> But it can still be useful to work under CGI (again, assuming the SafeLevel
> can be >0) and not worry about doing something fundamentally dumb.
>
> From a Perl background much of this makes wonderful sense until I get to
> the SafeLevel of a tainted object. How do you cleans such a beast?
> untainting strings is trivial, but larger objects... My Perl background
> fails me at this point.

irb(main):001:0> require 'ostruct'
=> true
irb(main):002:0> foo = OpenStruct.new
=> <OpenStruct>
irb(main):003:0> foo.tainted?
=> false
irb(main):004:0> foo.bar = gets
quux
=> "quux\n"
irb(main):005:0> foo.bar.tainted?
=> true
irb(main):006:0> foo.tainted?
=> false

irb(main):001:0> foo = gets
bar
=> "bar\n"
irb(main):002:0> "foo = #{foo}"
=> "foo = bar\n"
irb(main):003:0> _.tainted?
=> true
irb(main):004:0> foo = gets
%s
=> "%s\n"
irb(main):005:0> foo % "bar"
=> "bar\n"
irb(main):006:0> _.tainted?
=> true
irb(main):007:0>

Whether an object is tainted or not depends on the class of the object. By
default, any objects are untainted unless you decide to taint them. If Rails
provides you with a tainted object, it's your responsibility to sanitize it's
attributes, and then call #untaint on it.

There's usually no magic involved in deciding whether an object is or isn't
tainted, short of the well known tainting strings from user input, and any
strings resulting from interpolation of these with or into other strings.

David Vallner


Sam Smoot

2/13/2006 12:06:00 AM

0

What's that "_" method/object? Google doesn't search on punctuation
apparently :-/

David Vallner

2/13/2006 12:31:00 AM

0

Dna Pondelok 13 Február 2006 01:08 ssmoot@gmail.com napísal:
> What's that "_" method/object? Google doesn't search on punctuation
> apparently :-/

irb automatically populates the _ variable with the result of the last line
executed. __ is two lines past, ___ three lines past. I didn't feel like
using half a million metasyntactic identifiers cluttering up the session.