Module: Datadog::AppSec::Contrib::Sinatra::Patcher

Includes:
Patcher
Defined in:
lib/datadog/appsec/contrib/sinatra/patcher.rb

Overview

Patcher for AppSec on Sinatra

Class Method Summary collapse

Class Method Details

.patchObject



138
139
140
141
142
143
144
145
# File 'lib/datadog/appsec/contrib/sinatra/patcher.rb', line 138

def patch
  Gateway::Watcher.watch
  patch_default_middlewares
  patch_dispatch
  patch_route
  setup_security
  Patcher.instance_variable_set(:@patched, true)
end

.patch_default_middlewaresObject



151
152
153
# File 'lib/datadog/appsec/contrib/sinatra/patcher.rb', line 151

def patch_default_middlewares
  ::Sinatra::Base.singleton_class.prepend(DefaultMiddlewarePatch)
end

.patch_dispatchObject



155
156
157
# File 'lib/datadog/appsec/contrib/sinatra/patcher.rb', line 155

def patch_dispatch
  ::Sinatra::Base.prepend(DispatchPatch)
end

.patch_routeObject



159
160
161
# File 'lib/datadog/appsec/contrib/sinatra/patcher.rb', line 159

def patch_route
  ::Sinatra::Base.prepend(RoutePatch)
end

.patched?Boolean

Returns:

  • (Boolean)


130
131
132
# File 'lib/datadog/appsec/contrib/sinatra/patcher.rb', line 130

def patched?
  Patcher.instance_variable_get(:@patched)
end

.setup_securityObject



147
148
149
# File 'lib/datadog/appsec/contrib/sinatra/patcher.rb', line 147

def setup_security
  ::Sinatra::Base.singleton_class.prepend(AppSecSetupPatch)
end

.target_versionObject



134
135
136
# File 'lib/datadog/appsec/contrib/sinatra/patcher.rb', line 134

def target_version
  Integration.version
end