Sha256: efe4de7958c15057f15ecdd4c54823efb1af2451ce19193b483c442f9a9a90ec

Contents?: true

Size: 1.11 KB

Versions: 7

Compression:

Stored size: 1.11 KB

Contents

# frozen_string_literal: true

require 'json'
require_relative 'gateway/multiplex'
require_relative '../../instrumentation/gateway'

module Datadog
  module AppSec
    module Contrib
      module GraphQL
        # These methods will be called by the GraphQL runtime to send the variables to the WAF.
        # We actually don't need to create any span/trace.
        module AppSecTrace
          def execute_multiplex(multiplex:)
            return super unless Datadog::AppSec.enabled?

            gateway_multiplex = Gateway::Multiplex.new(multiplex)

            multiplex_return, multiplex_response = Instrumentation.gateway.push('graphql.multiplex', gateway_multiplex) do
              super
            end

            # Returns an error * the number of queries so that the entire multiplex is blocked
            if multiplex_response
              blocked_event = multiplex_response.find { |action, _options| action == :block }
              multiplex_return = AppSec::Response.graphql_response(gateway_multiplex) if blocked_event
            end

            multiplex_return
          end
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
datadog-2.9.0 lib/datadog/appsec/contrib/graphql/appsec_trace.rb
datadog-2.8.0 lib/datadog/appsec/contrib/graphql/appsec_trace.rb
datadog-2.7.1 lib/datadog/appsec/contrib/graphql/appsec_trace.rb
datadog-2.7.0 lib/datadog/appsec/contrib/graphql/appsec_trace.rb
datadog-2.6.0 lib/datadog/appsec/contrib/graphql/appsec_trace.rb
datadog-2.5.0 lib/datadog/appsec/contrib/graphql/appsec_trace.rb
datadog-2.4.0 lib/datadog/appsec/contrib/graphql/appsec_trace.rb