Skip to content

Commit 0ca88ea

Browse files
committed
[GR-20446] Update taint to noop and warn when used in verbose mode
PullRequest: truffleruby/2175
2 parents aec4636 + 7dfb719 commit 0ca88ea

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+198
-874
lines changed

lib/truffle/pathname.rb

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -223,12 +223,20 @@ def initialize(path)
223223

224224
@path = path.dup
225225

226-
self.taint if @path.tainted?
226+
self
227227
end
228228

229229
def freeze() super; @path.freeze; self end
230-
def taint() super; @path.taint; self end
231-
def untaint() super; @path.untaint; self end
230+
231+
def taint
232+
warn 'Pathname#taint is deprecated and will be removed in Ruby 3.2.', uplevel: 1 if $VERBOSE
233+
self
234+
end
235+
236+
def untaint
237+
warn 'Pathname#untaint is deprecated and will be removed in Ruby 3.2.', uplevel: 1 if $VERBOSE
238+
self
239+
end
232240

233241
#
234242
# Compare this pathname with +other+. The comparison is string-based.

lib/truffle/stringio.rb

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,6 @@ def initialize(string=nil, mode=nil)
9696
def initialize_copy(from)
9797
from = Truffle::Type.coerce_to(from, StringIO, :to_strio)
9898

99-
taint if from.tainted?
100-
10199
@append = from.instance_variable_get(:@append)
102100
@readable = from.instance_variable_get(:@readable)
103101
@writable = from.instance_variable_get(:@writable)
@@ -232,7 +230,6 @@ def write(str)
232230
end
233231
Primitive.string_splice(string, str, pos, stop, string.encoding)
234232
d.pos += str.bytesize
235-
string.taint if str.tainted?
236233
end
237234

238235
str.bytesize
@@ -467,7 +464,6 @@ def reopen(string=nil, mode=Undefined)
467464
if string and not string.kind_of? String and mode.equal? Undefined
468465
stringio = Truffle::Type.coerce_to(string, StringIO, :to_strio)
469466

470-
taint if stringio.tainted?
471467
initialize_copy stringio
472468
else
473469
mode = nil if mode.equal? Undefined

lib/truffle/strscan.rb

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ def [](n)
7878
if @match
7979
raise TypeError, "no implicit conversion of #{n.class} into Integer" if Range === n
8080
str = @match[n]
81-
str.taint if @string.tainted?
8281
str
8382
end
8483
end
@@ -174,7 +173,6 @@ def inspect
174173
end
175174
end
176175

177-
str.taint if @string.tainted?
178176
str
179177
else
180178
"#<#{self.class} (uninitialized)>"
@@ -188,7 +186,6 @@ def match?(pattern)
188186
def matched
189187
if @match
190188
matched = @match.to_s
191-
matched.taint if @string.tainted?
192189
matched
193190
end
194191
end

lib/truffle/truffle/cext.rb

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -270,10 +270,6 @@ def RB_OBJ_TAINTABLE(object)
270270
end
271271
end
272272

273-
def rb_tr_obj_infect(dest, source)
274-
Primitive.infect(dest, source)
275-
end
276-
277273
FREEZE_METHOD = Kernel.instance_method :freeze
278274

279275
def rb_obj_freeze(obj)
@@ -678,7 +674,7 @@ def rb_cstr_to_dbl(string, badcheck)
678674

679675
def rb_str_new_native(pointer, length)
680676
raise "#{pointer} not a pointer" unless Truffle::Interop.pointer?(pointer)
681-
Truffle::FFI::Pointer.new(pointer).read_string(length).untaint
677+
Truffle::FFI::Pointer.new(pointer).read_string(length)
682678
end
683679

684680
def rb_enc_str_coderange(str)

lib/truffle/truffle/cext_structs.rb

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,6 @@ def set_user_flags(flags)
158158
def compute_flags
159159
flags = 0
160160
flags |= RUBY_FL_FREEZE if @object.frozen?
161-
flags |= RUBY_FL_TAINT if @object.tainted?
162161
flags | user_flags
163162
end
164163

@@ -194,10 +193,7 @@ def flags_to_string(flags)
194193

195194
def set_flags(flags)
196195
if flags & RUBY_FL_TAINT != 0
197-
@object.taint
198196
flags &= ~RUBY_FL_TAINT
199-
elsif @object.tainted?
200-
@object.untaint
201197
end
202198

203199
set_user_flags(flags & USER_FLAGS_MASK)

lib/truffle/truffle/fiddle_backend.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,6 @@ def self.to_ptr(val)
319319
else
320320
ptr = Pointer.new(Integer(val))
321321
end
322-
Primitive.infect ptr, val
323322
ptr
324323
end
325324

spec/tags/core/kernel/taint_tags.txt

Lines changed: 0 additions & 2 deletions
This file was deleted.

spec/tags/core/kernel/tainted_tags.txt

Lines changed: 0 additions & 2 deletions
This file was deleted.

spec/tags/core/kernel/trust_tags.txt

Lines changed: 0 additions & 2 deletions
This file was deleted.

spec/tags/core/kernel/untaint_tags.txt

Lines changed: 0 additions & 2 deletions
This file was deleted.

0 commit comments

Comments
 (0)