Sha256: 2a3d8ebc03ff0e6661112a4c15e0cfec7a599cf9e8c8db270ed2e6e8fe3c5483

Contents?: true

Size: 1.96 KB

Versions: 6

Compression:

Stored size: 1.96 KB

Contents

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

cs__scoped_require 'yaml'

module Contrast
  # A Rake task to generate a contrast_security.yaml file with some basic settings
  module Config
    extend Rake::DSL
    include Contrast::Components::Interface
    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

6 entries across 6 versions & 1 rubygems

Version Path
contrast-agent-3.13.2 lib/contrast/tasks/config.rb
contrast-agent-3.13.1 lib/contrast/tasks/config.rb
contrast-agent-3.13.0 lib/contrast/tasks/config.rb
contrast-agent-3.12.2 lib/contrast/tasks/config.rb
contrast-agent-3.12.1 lib/contrast/tasks/config.rb
contrast-agent-3.12.0 lib/contrast/tasks/config.rb