Configure the Ruby agent

The #UUID-8adcd37e-eeb9-d64d-8ad4-58676d5d734d_section-idm13235277930596 for all agents uses this order of precedence. Configure the agent using a YAML configuration file.

The Ruby agent launches an executable on startup that also needs access to the configuration files. Since the service is generally launched by the Ruby agent process, it has access to the same configuration file as the agent. However, if the service is started independently, it will attempt to use the same order of precedence for its configuration file.

In other words, the service can share the application's configuration file, if (as is usually the case) the service's working directory is also the base directory of the application. Both the agent and the service use the ./config/contrast_security.yaml path.

Follow these guidelines depending on your framework:

Configure with Rails

If you are using Rails, the Ruby agent functions as a Railtie so no additional configuration is required.

Configure with Sinatra

If you're using the Sinatra framework, you must configure your application to use the Ruby agent. A simple application configured to work with the Ruby agent looks like the following example:

require 'sinatra'
require 'contrast-agent'

class App < Sinatra::Base
  use Contrast::Agent::Middleware, true
end

Ruby YAML template

Use this template to configure the Ruby agent using a YAML configuration file. Place the contrast_security.yaml file in the web application's configuration directory. (You may also place it in the root directory.)

https://docs.contrastsecurity.com/common-agent-config/ruby_contrast_security.yaml