Ruby Instrumentation

Ruby Agent

Please see our Ruby - Supported Technologies page for additional information on our application stacks supported by our Ruby agent.

Installation and Configuration

  • Must be done with a YAML config file in app folder (or config subfolder)
  • Add this line to the top of your application’s Gemfile:
    source 'https://eval.contrastsecurity.com/Contrast/api/repo/rvm’
    
  • Add this section to your application’s Gemfile:
    group :contrast, :development, :testing, :production do
      gem 'contrast-agent’
    End
    
  • After editing the Gemfile, you’ll need to bundle the contrast-agent gem. To do that, you’ll need to add authorization to your Bundler (‘username’ and ‘service_key’ must be CGI encoded @ as %40):
    bundle config https://eval.contrastsecurity.com/Contrast/api/repo/rvm <USERNAME>:<SERVICE KEY>
    
  • Then run an update:
    bundle update --group contrast
    

Agent YAML Configuration File Example

A sample YAML config file is below, but please note that the following variables should be populated with each test run (e.g., by your CI/CD tool):

  • api
    • api_key
    • service_key
    • user_name
  • application
    • name (${app_name})
    • session_metadata (${branch_name} and ${test_run})
api: 
  url: https://eval.contrastsecurity.com/Contrast
  api_key: API Key from add agent screen in Team Server
  service_key: Service Key from add agent screen in Team Server
  user_name: Agent user name from add agent screen in Team Server
agent: 
  service: 
    logger: 
      path: contrast_service.log
      level: ERROR
    host: 127.0.0.1
    port: 30555
application:
  name: ${app_name}
  session_metadata: branchName=${branch_name},testRun=${test_run}