Files
codeql/ruby/ql/test/library-tests/dataflow/global/callbacks.rb
2025-01-09 09:30:08 +01:00

29 lines
440 B
Ruby

def taint x
x
end
def sink x
puts "SINK: #{x}"
end
def apply (f, x)
f.call(x)
end
def apply_wrap (f, x)
apply(f, x)
end
apply_wrap(->(x) { sink(x) }, taint(1)) # $ hasValueFlow=1
apply_wrap(->(x) { sink(x) }, "safe")
def apply_block x
yield x
end
def apply_block_wrap (x, &block)
apply_block(x, &block)
end
apply_block_wrap(taint(2)) { |x| sink(x) } # $ hasValueFlow=2
apply_block_wrap("safe") { |x| sink(x) }