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



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

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

.patch_default_middlewaresObject



153
154
155
# File 'lib/datadog/appsec/contrib/sinatra/patcher.rb', line 153

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

.patch_dispatchObject



157
158
159
# File 'lib/datadog/appsec/contrib/sinatra/patcher.rb', line 157

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

.patch_routeObject



161
162
163
# File 'lib/datadog/appsec/contrib/sinatra/patcher.rb', line 161

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

.patched?Boolean

Returns:

  • (Boolean)


132
133
134
# File 'lib/datadog/appsec/contrib/sinatra/patcher.rb', line 132

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

.setup_securityObject



149
150
151
# File 'lib/datadog/appsec/contrib/sinatra/patcher.rb', line 149

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

.target_versionObject



136
137
138
# File 'lib/datadog/appsec/contrib/sinatra/patcher.rb', line 136

def target_version
  Integration.version
end