Skip to content

Commit

Permalink
Move out taint filters from String bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
meh committed Nov 22, 2013
1 parent 1459f04 commit 7827aeb
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 26 deletions.
26 changes: 0 additions & 26 deletions spec/opal/filters/bugs/string.rb
Expand Up @@ -10,23 +10,19 @@
fails "String#[] calls to_int on the given index"
fails "String#[] raises a TypeError if the given index is nil"
fails "String#[] raises a TypeError if the given index can't be converted to an Integer"
fails "String#[] with index, length always taints resulting strings when self is tainted"
fails "String#[] with index, length returns nil if the length is negative"
fails "String#[] with index, length calls to_int on the given index and the given length"
fails "String#[] with index, length calls to_int on the given index and the given length"
fails "String#[] with index, length raises a TypeError when idx or length can't be converted to an integer"
fails "String#[] with index, length raises a TypeError when the given index or the given length is nil"
fails "String#[] with Range returns nil if the beginning of the range falls outside of self"
fails "String#[] with Range always taints resulting strings when self is tainted"
fails "String#[] with Range calls to_int on range arguments"
fails "String#[] with Range calls to_int on range arguments"
fails "String#[] with Range handles repeated application"
fails "String#[] with Regexp returns the matching portion of self"
fails "String#[] with Regexp returns nil if there is no match"
fails "String#[] with Regexp always taints resulting strings when self or regexp is tainted"
fails "String#[] with Regexp sets $~ to MatchData when there is a match and nil when there's none"
fails "String#[] with Regexp, index returns the capture for the given index"
fails "String#[] with Regexp, index always taints resulting strings when self or regexp is tainted"
fails "String#[] with Regexp, index returns nil if there is no match"
fails "String#[] with Regexp, index returns nil if there is no capture for the given index"
fails "String#[] with Regexp, index calls to_int on the given index"
Expand All @@ -35,7 +31,6 @@
fails "String#[] with Regexp, index raises a TypeError when the given index is nil"
fails "String#[] with Regexp, index sets $~ to MatchData when there is a match and nil when there's none"
fails "String#[] with String returns other_str if it occurs in self"
fails "String#[] with String taints resulting strings when other is tainted"
fails "String#[] with String returns nil if there is no match"
fails "String#[] with String doesn't call to_str on its argument"
fails "String#[] with String returns a subclass instance when given a subclass instance"
Expand All @@ -45,7 +40,6 @@
fails "String#end_with? converts its argument using :to_str"
fails "String#end_with? returns true if other is empty"

fails "String#each_line taints substrings that are passed to the block if self is tainted"
fails "String#each_line passes self as a whole to the block if the separator is nil"
fails "String#each_line yields paragraphs (broken by 2 or more successive newlines) when passed ''"
fails "String#each_line uses $/ as the separator when none is given"
Expand All @@ -71,7 +65,6 @@
fails "String#gsub with pattern and replacement replaces \\+ with the last paren that actually matched"
fails "String#gsub with pattern and replacement treats \\+ as an empty string if there was no captures"
fails "String#gsub with pattern and replacement maps \\\\ in replacement to \\"
fails "String#gsub with pattern and replacement taints the result if the original string or replacement is tainted"
fails "String#gsub with pattern and replacement handles pattern collapse without $KCODE"
fails "String#gsub with pattern and replacement untrusts the result if the original string or replacement is untrusted"
fails "String#gsub with pattern and replacement raises a TypeError when replacement can't be converted to a string"
Expand All @@ -89,8 +82,6 @@
fails "String#gsub with pattern and Hash doesn't interpolate special sequences like \\1 for the block's return value"
fails "String#gsub with pattern and Hash untrusts the result if the original string is untrusted"
fails "String#gsub with pattern and Hash untrusts the result if a hash value is untrusted"
fails "String#gsub with pattern and Hash taints the result if the original string is tainted"
fails "String#gsub with pattern and Hash taints the result if a hash value is tainted"
fails "String#gsub with pattern and block sets $~ for access from the block"
fails "String#gsub with pattern and block restores $~ after leaving the block"
fails "String#gsub with pattern and block sets $~ to MatchData of last match and nil when there's none for access from outside"
Expand All @@ -109,7 +100,6 @@
fails "String#lines should split on the default record separator and return enumerator if not block is given"
fails "String#lines splits using default newline separator when none is specified"
fails "String#lines splits self using the supplied record separator and passes each substring to the block"
fails "String#lines taints substrings that are passed to the block if self is tainted"
fails "String#lines passes self as a whole to the block if the separator is nil"
fails "String#lines yields paragraphs (broken by 2 or more successive newlines) when passed ''"
fails "String#lines yields subclass instances for subclasses"
Expand All @@ -123,13 +113,11 @@
fails "String#lines returns an array when no block given"

fails "String#lstrip returns a copy of self with leading whitespace removed"
fails "String#lstrip taints the result when self is tainted"

fails "String#next returns the successor by increasing the rightmost alphanumeric (digit => digit, letter => letter with same case)"
fails "String#next increases the next best alphanumeric (jumping over non-alphanumerics) if there is a carry"
fails "String#next increases the next best character if there is a carry for non-alphanumerics"
fails "String#next adds an additional character (just left to the last increased one) if there is a carry and no character left to increase"
fails "String#next taints the result if self is tainted"

fails "String#partition with String accepts regexp"
fails "String#partition with String sets global vars if regexp used"
Expand All @@ -154,29 +142,24 @@

fails "String#rstrip returns a copy of self with trailing whitespace removed"
fails "String#rstrip returns a copy of self with all trailing whitespace and NULL bytes removed"
fails "String#rstrip taints the result when self is tainted"

fails "String#slice calls to_int on the given index"
fails "String#slice calls to_int on the given index"
fails "String#slice raises a TypeError if the given index is nil"
fails "String#slice raises a TypeError if the given index can't be converted to an Integer"
fails "String#slice with index, length always taints resulting strings when self is tainted"
fails "String#slice with index, length returns nil if the length is negative"
fails "String#slice with index, length calls to_int on the given index and the given length"
fails "String#slice with index, length calls to_int on the given index and the given length"
fails "String#slice with index, length raises a TypeError when idx or length can't be converted to an integer"
fails "String#slice with index, length raises a TypeError when the given index or the given length is nil"
fails "String#slice with Range returns nil if the beginning of the range falls outside of self"
fails "String#slice with Range always taints resulting strings when self is tainted"
fails "String#slice with Range calls to_int on range arguments"
fails "String#slice with Range calls to_int on range arguments"
fails "String#slice with Range handles repeated application"
fails "String#slice with Regexp returns the matching portion of self"
fails "String#slice with Regexp returns nil if there is no match"
fails "String#slice with Regexp always taints resulting strings when self or regexp is tainted"
fails "String#slice with Regexp sets $~ to MatchData when there is a match and nil when there's none"
fails "String#slice with Regexp, index returns the capture for the given index"
fails "String#slice with Regexp, index always taints resulting strings when self or regexp is tainted"
fails "String#slice with Regexp, index returns nil if there is no match"
fails "String#slice with Regexp, index returns nil if there is no capture for the given index"
fails "String#slice with Regexp, index calls to_int on the given index"
Expand All @@ -185,7 +168,6 @@
fails "String#slice with Regexp, index raises a TypeError when the given index is nil"
fails "String#slice with Regexp, index sets $~ to MatchData when there is a match and nil when there's none"
fails "String#slice with String returns other_str if it occurs in self"
fails "String#slice with String taints resulting strings when other is tainted"
fails "String#slice with String returns nil if there is no match"
fails "String#slice with String doesn't call to_str on its argument"
fails "String#slice with String returns a subclass instance when given a subclass instance"
Expand All @@ -201,7 +183,6 @@
fails "String#split with String tries converting limit to an integer via to_int"
fails "String#split with String returns subclass instances based on self"
fails "String#split with String does not call constructor on created subclass instances"
fails "String#split with String taints the resulting strings if self is tainted"
fails "String#split with Regexp divides self on regexp matches"
fails "String#split with Regexp treats negative limits as no limit"
fails "String#split with Regexp suppresses trailing empty fields when limit isn't given or 0"
Expand All @@ -216,9 +197,6 @@
fails "String#split with Regexp returns a type error if limit can't be converted to an integer"
fails "String#split with Regexp returns subclass instances based on self"
fails "String#split with Regexp does not call constructor on created subclass instances"
fails "String#split with Regexp taints the resulting strings if self is tainted"
fails "String#split with Regexp taints an empty string if self is tainted"
fails "String#split with Regexp doesn't taints the resulting strings if the Regexp is tainted"
fails "String#split with Regexp retains the encoding of the source string"
fails "String#split with Regexp returns an ArgumentError if an invalid UTF-8 string is supplied"

Expand All @@ -227,7 +205,6 @@

fails "String#strip returns a new string with leading and trailing whitespace removed"
fails "String#strip returns a copy of self with trailing NULL bytes and whitespace"
fails "String#strip taints the result when self is tainted"

fails "String#sub with pattern, replacement supports \\G which matches at the beginning of the string"
fails "String#sub with pattern, replacement replaces \\1 sequences with the regexp's corresponding capture"
Expand All @@ -238,7 +215,6 @@
fails "String#sub with pattern, replacement replaces \\+ with the last paren that actually matched"
fails "String#sub with pattern, replacement treats \\+ as an empty string if there was no captures"
fails "String#sub with pattern, replacement maps \\\\ in replacement to \\"
fails "String#sub with pattern, replacement taints the result if the original string or replacement is tainted"
fails "String#sub with pattern, replacement tries to convert pattern to a string using to_str"
fails "String#sub with pattern, replacement tries to convert pattern to a string using to_str"
fails "String#sub with pattern, replacement raises a TypeError when pattern can't be converted to a string"
Expand All @@ -249,13 +225,11 @@
fails "String#sub with pattern and block sets $~ for access from the block"
fails "String#sub with pattern and block sets $~ to MatchData of last match and nil when there's none for access from outside"
fails "String#sub with pattern and block doesn't raise a RuntimeError if the string is modified while substituting"
fails "String#sub with pattern and block taints the result if the original string or replacement is tainted"

fails "String#succ returns the successor by increasing the rightmost alphanumeric (digit => digit, letter => letter with same case)"
fails "String#succ increases the next best alphanumeric (jumping over non-alphanumerics) if there is a carry"
fails "String#succ increases the next best character if there is a carry for non-alphanumerics"
fails "String#succ adds an additional character (just left to the last increased one) if there is a carry and no character left to increase"
fails "String#succ taints the result if self is tainted"

fails "String#sum returns a basic n-bit checksum of the characters in self"
fails "String#sum tries to convert n to an integer using to_int"
Expand Down
39 changes: 39 additions & 0 deletions spec/opal/filters/unsupported/tainted.rb
Expand Up @@ -60,6 +60,12 @@

fails "Hash#reject taints the resulting hash"

fails "String#[] with index, length always taints resulting strings when self is tainted"
fails "String#[] with Range always taints resulting strings when self is tainted"
fails "String#[] with Regexp always taints resulting strings when self or regexp is tainted"
fails "String#[] with Regexp, index always taints resulting strings when self or regexp is tainted"
fails "String#[] with String taints resulting strings when other is tainted"

fails "String#capitalize taints resulting string when self is tainted"

fails "String#downcase taints result when self is tainted"
Expand All @@ -77,16 +83,49 @@

fails "String#chop taints result when self is tainted"

fails "String#each_line taints substrings that are passed to the block if self is tainted"

fails "String#gsub with pattern and replacement taints the result if the original string or replacement is tainted"
fails "String#gsub with pattern and Hash taints the result if the original string is tainted"
fails "String#gsub with pattern and Hash taints the result if a hash value is tainted"

fails "String#lines taints substrings that are passed to the block if self is tainted"

fails "String#ljust with length, padding taints result when self or padstr is tainted"
fails "String#ljust with length, padding when padding is tainted and self is untainted returns a tainted string if and only if length is longer than self"

fails "String#lstrip taints the result when self is tainted"

fails "String#next taints the result if self is tainted"

fails "String#reverse taints the result if self is tainted"

fails "String#rjust with length, padding taints result when self or padstr is tainted"
fails "String#rjust with length, padding when padding is tainted and self is untainted returns a tainted string if and only if length is longer than self"


fails "String#rstrip taints the result when self is tainted"

fails "String#slice with index, length always taints resulting strings when self is tainted"
fails "String#slice with Range always taints resulting strings when self is tainted"
fails "String#slice with Regexp always taints resulting strings when self or regexp is tainted"
fails "String#slice with Regexp, index always taints resulting strings when self or regexp is tainted"
fails "String#slice with String taints resulting strings when other is tainted"

fails "String#split with String taints the resulting strings if self is tainted"
fails "String#split with Regexp taints the resulting strings if self is tainted"
fails "String#split with Regexp taints an empty string if self is tainted"
fails "String#split with Regexp doesn't taints the resulting strings if the Regexp is tainted"

fails "String#strip taints the result when self is tainted"

fails "String#swapcase taints resulting string when self is tainted"

fails "String#sub with pattern, replacement taints the result if the original string or replacement is tainted"
fails "String#sub with pattern and block taints the result if the original string or replacement is tainted"

fails "String#succ taints the result if self is tainted"

fails "String#to_s taints the result when self is tainted"

fails "String#to_str taints the result when self is tainted"
Expand Down

0 comments on commit 7827aeb

Please sign in to comment.