Class: TaintedLove::Replacer::ReplaceGraphQL

Inherits:
Base
  • Object
show all
Defined in:
lib/tainted_love/replacer/replace_graphql.rb

Instance Method Summary collapse

Methods inherited from Base

replacers

Instance Method Details

#replace!Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/tainted_love/replacer/replace_graphql.rb', line 10

def replace!
  require 'graphql'

  GraphQL::Query::Arguments::ArgumentValue.class_eval do
    def value
      return @value if default_used?

      @tainted_value ||= @value.dup.taint

      TaintedLove.tag(@tainted_value, { source: "GraphQL argument #{key.inspect}", value: @tainted_value })

      @tainted_value
    end
  end
end

#should_replace?Boolean

Returns:

  • (Boolean)


6
7
8
# File 'lib/tainted_love/replacer/replace_graphql.rb', line 6

def should_replace?
  Gem.loaded_specs.has_key?('graphql') # fixme: very bundler specific
end