Install the Ruby agent

Install the Ruby agent on your system.


Create Account

Installing the Sqreen Ruby agent enables you to monitor the security of your application and block attacks in real-time. Installing Ruby in your Rails application takes less than a minute:

Standard Ruby application

In your application root directory, add the Sqreen gem to your Gemfile:

echo "gem 'sqreen', '>= 1.16'" >> Gemfile

Find your organization token by going to Account Settings > Tokens in your Sqreen dashboard, or (https://my.sqreen.com/profile/organization/tokens). Your token is prefixed with org_.

To help Sqreen correctly identify the application when you use an organization token, you also need to set a unique application name.

Then, in a terminal, use the following commands from your application root directory:

# Install the Sqreen gem from your application directory
bundle install

# Set the Sqreen token and the application name
cat > config/sqreen.yml <<EOF
app_name: "YOUR_APPLICATION_NAME"
token: "SQREEN_TOKEN"
EOF

Application tokens depreciated

Appplication tokens are dedicated to an application, and organization tokens are available throughout the organization your account belongs to.

While Sqreen will continue to support application tokens for backward compatibility in the short term, they are now depreciated, and we encourage you to convert your applications to use organization tokens as soon as possible.

Install the agent on non production environments

Typically you install the Sqreen agent in your production environment, but you can create several applications by specifying the environment in the application name.

# Set the Sqreen token and the app name, including the environment
cat > config/sqreen.yml <<EOF
app_name: "foobar (production)"
token: "SQREEN_TOKEN"
EOF

Basic configuration

The Sqreen agent stores your configuration in the sqreen.yml file.

Instead of using the Sqreen configuration file, you can also use the SQREEN_TOKEN and SQREEN_APP_NAME environment variables to set up your token and the application name

export SQREEN_APP_NAME="YOUR_APPLICATION_NAME"
export SQREEN_TOKEN="SQREEN_TOKEN"

The Sqreen Ruby agent provides flexible configuration settings. Refer to Configuration of the Ruby agent for more detailed information.

Uninstall the agent

To uninstall the Sqreen agent, remove the sqreen gem from your Gemfile.

Notes

The Sqreen Ruby agent's gem is available on rubygems repository.

Use different Sqreen Applications for different environments

We recommend you to use different Sqreen applications on your different environments: Production, Staging and Development.

Bundler app (Sinatra)

For bundler apps (Sinatra), use the standard installation instructions for the Ruby agent and require the Sqreen gem from your application code after Sinatra in the Gemfile:

require 'sinatra'
require 'sqreen'

Linux distributions with no C++11 compiler

Some specific environments lack a C++11 compliant compiler (GCC >= 4.8 or clang >= 3.5). For example in:

  • Stripped down docker containers
  • Old distributions, such as Ubuntu Precise

In the first case, install g++ or clang before running bundle install or gem install. You can remove the C++ compiler immediately afterwards, but you must keep the C++ runtime library (usually libstdc++).

In case of older distributions, you might need to install a newer compiler from separate package repositories.

Travis Precise

To install Sqreen on Travis Precise, you can install GCC 4.8 by adding the below to the .travis.yml file:

addons:
  apt:
    sources:
      - ubuntu-toolchain-r-test
    packages:
      - g++-4.8
env:
  - CXX=g++-4.8