Skip to content

Commit

Permalink
[WIP] Fix signatures
Browse files Browse the repository at this point in the history
  • Loading branch information
lloeki committed May 26, 2023
1 parent f3b4998 commit 114b7a0
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 18 deletions.
4 changes: 0 additions & 4 deletions lib/datadog/appsec/processor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,6 @@ def ready?
!@handle.nil?
end

def new_context
Context.new(self)
end

def finalize
@handle.finalize
end
Expand Down
5 changes: 3 additions & 2 deletions lib/datadog/appsec/scope.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ def finalize
class << self
def activate_scope(trace, service_entry_span, processor)
raise ActiveScopeError, 'another scope is active, nested scopes are not supported' if active_scope
context = Datadog::AppSec::Processor::Context.new(processor)

self.active_scope = new(trace, service_entry_span, processor.new_context)
self.active_scope = new(trace, service_entry_span, context)
end

def deactivate_scope
Expand All @@ -41,7 +42,7 @@ def active_scope
private

def active_scope=(scope)
raise ArgumentError, "#{scope.inspect} is not a Datadog::AppSec::Scope" unless scope.instance_of?(Scope)
raise ArgumentError, 'not a Datadog::AppSec::Scope' unless scope.instance_of?(Scope)

Thread.current[:datadog_appsec_active_scope] = scope
end
Expand Down
12 changes: 0 additions & 12 deletions sig/datadog/appsec/processor.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,6 @@ module Datadog

private

def self.active_context=: (untyped context) -> untyped
def self.reset_active_context: () -> untyped

class NoActiveContextError < StandardError
end

class AlreadyActiveContextError < StandardError
end

attr_reader ruleset_info: untyped
attr_reader addresses: untyped

Expand All @@ -41,9 +32,6 @@ module Datadog

def initialize: (ruleset: ::Hash[untyped, untyped]) -> void
def ready?: () -> bool
def new_context: () -> Context
def activate_context: () -> Context
def deactivate_context: () -> void
def finalize: () -> void

attr_reader handle: untyped
Expand Down
35 changes: 35 additions & 0 deletions sig/datadog/appsec/scope.rbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
module Datadog
module AppSec
class Scope
attr_reader trace: Datadog::Tracing::TraceOperation

attr_reader service_entry_span: Datadog::Tracing::SpanOperation

attr_reader processor_context: Datadog::AppSec::Processor::Context

def initialize: (Datadog::Tracing::TraceOperation trace, Datadog::Tracing::SpanOperation service_entry_span, Datadog::AppSec::Processor::Context processor_context) -> void

def finalize: () -> void

def self.activate_scope: (Datadog::Tracing::TraceOperation trace, Datadog::Tracing::SpanOperation service_entry_span, Datadog::AppSec::Processor processor) -> Scope

def self.deactivate_scope: () -> void

def self.active_scope: () -> Scope

private

def self.active_scope=: (Scope scope) -> Scope

def self.reset_active_scope: () -> void

public

class InactiveScopeError < StandardError
end

class ActiveScopeError < StandardError
end
end
end
end

0 comments on commit 114b7a0

Please sign in to comment.