Sha256: 2a782a29f38b4c741fb56a4ebfb0331c5f25a2df52f34dff60408b13782d3eaa

Contents?: true

Size: 1.91 KB

Versions: 4

Compression:

Stored size: 1.91 KB

Contents

# Copyright (c) 2022 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
# frozen_string_literal: true

require 'yaml'

module Contrast
  # A Rake task to generate a contrast_security.yaml file with some basic settings
  module Config
    extend Rake::DSL
    DEFAULT_CONFIG = {
        'api' => {
            'url' => 'Enter your Contrast URL ex: https://app.contrastsecurity.com/Contrast',
            'api_key' => 'Enter your Contrast api key',
            'service_key' => 'Enter your Contrast service key',
            'user_name' => 'Enter your Contrast user name'
        },
        'agent' => {
            'service' => {
                'logger' => {
                    'path' => 'contrast_service.log',
                    'level' => 'ERROR' # DEBUG | INFO | WARN | ERROR
                },
                'socket' => '/tmp/contrast_service.sock'
            },
            'logger' => {
                'level' => 'ERROR',
                'path' => 'contrast_agent.log'
            }
        }
    }.cs__freeze

    namespace :contrast do
      namespace :config do
        desc 'Create a contrast_security.yaml in the applications root directory'
        task :create do
          execution_directory = Dir.pwd
          target_path = File.join(execution_directory, 'contrast_security.yaml')
          if File.exist?(target_path)
            puts 'WARNING: contrast_security.yaml already exists'
          else
            File.open(target_path, 'w') do |f|
              f.write(YAML.dump(DEFAULT_CONFIG))
            end

            puts "Created contrast_security.yaml at #{ target_path }"
            puts 'Open the file and enter your Contrast Security api keys or set them via environment variables'
            puts 'Visit our documentation site for more details: https://docs.contrastsecurity.com/installation-rubyconfig.html'
          end
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
contrast-agent-5.3.0 lib/contrast/tasks/config.rb
contrast-agent-5.2.0 lib/contrast/tasks/config.rb
contrast-agent-5.1.0 lib/contrast/tasks/config.rb
contrast-agent-5.0.0 lib/contrast/tasks/config.rb