# Copyright (c) 2020 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details. # frozen_string_literal: true require_relative './lib/contrast/agent/version' lib = File.expand_path('lib', __dir__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) # Add the team as authors of the Agent def self.add_authors spec spec.authors = %w[ galen.palmer@contrastsecurity.com harold.mcginnis@contrastsecurity.com donald.propst@contrastsecurity.com alex.macdonald@contrastsecurity.com mark.petersen@contrastsecurity.com joshua.reed@contrastsecurity.com ] end # Add those dependencies required to develop or test the Agent def self.add_dev_dependencies spec spec.add_development_dependency 'amazing_print' spec.add_development_dependency 'bundler' spec.add_development_dependency 'climate_control' # mock ENV spec.add_development_dependency 'debase' spec.add_development_dependency 'debride' spec.add_development_dependency 'execjs' spec.add_development_dependency 'factory_bot' spec.add_development_dependency 'fake_ftp' spec.add_development_dependency 'fasterer' spec.add_development_dependency 'flay' spec.add_development_dependency 'openssl' spec.add_development_dependency 'parser', '~> 2.6' spec.add_development_dependency 'pry' spec.add_development_dependency 'rails', '>= 3' spec.add_development_dependency 'rake', '~> 10.0' spec.add_development_dependency 'rake-compiler', '~> 0' spec.add_development_dependency 'rspec', '~> 3.0' spec.add_development_dependency 'rspec-benchmark' spec.add_development_dependency 'rspec_junit_formatter', '0.3.0' spec.add_development_dependency 'rubocop', '0.93.1' spec.add_development_dependency 'rubocop-performance', '1.8.1' spec.add_development_dependency 'rubocop-rspec', '1.43.2' spec.add_development_dependency 'ruby-debug-ide' spec.add_development_dependency 'simplecov', '~> 0.18' spec.add_development_dependency 'sinatra', '>= 2' spec.add_development_dependency 'sqlite3', '1.3.9' spec.add_development_dependency 'therubyracer' spec.add_development_dependency 'tilt' spec.add_development_dependency 'xpath' spec.add_development_dependency 'yarjuf', '~> 2.0' end # Add those dependencies required to run the Agent in customer applications. # # Note: If you add a runtime dependency to the Agent, you'll need to update the # dependencies.csv in this directory to indicate that and create a # corresponding update to the fake gem server data in TeamServer. def self.add_dependencies spec spec.add_dependency 'ougai', '~> 1.8' spec.add_dependency 'parser', '~> 2.6' spec.add_dependency 'protobuf', '~> 3.10' spec.add_dependency 'rack', '~> 2.0' end # Enumerate the files required to build the Agent. def self.add_files spec spec.files = `git ls-files -z`.split("\x0").reject do |f| # Directories used for testing: f.match(%r{^(spec|test)/}) || # Directories used in pipelines f.match(%r{^(\.github|bin|internal_resources|vendor)/}) || # Configuration and other files that don't belong to one directory f.match(/(Dockerfile)/) || f.match(/(.*\.csv)/) || f.match(/(.*\.md)/) || f.match(/(.*\.sh)/) || f.match(/(.*\.xml)/) || f.match(/(.*\.ya?ml)/) end spec.files << 'lib/contrast/api/dtm.pb.rb' spec.files << 'lib/contrast/api/settings.pb.rb' spec.files += Dir['service_executables/**/*'] spec.files += Dir['funchook/**/*'] spec.files += Dir['shared_libraries/**/*'] # Clean up compiled funchook files that may have been generated during # testing. Only a concern locally, but better than leaving it to chance. spec.files.delete_if do |file| file.end_with?('ext/libfunchook.dylib', 'ext/libfunchook.so', 'ext/funchook.h', 'shared_libraries/libfunchook.dylib', 'shared_libraries/libfunchook.so', 'shared_libraries/funchook.h', 'funchook/src/libfunchook.dylib', 'funchook/src/libfunchook.so') end end def self.add_metadata spec spec.metadata['changelog_uri'] = 'https://docs.contrastsecurity.com/release.html' spec.metadata['support_uri'] = 'https://support.contrastsecurity.com' spec.metadata['trouble_shooting_uri'] = 'https://support.contrastsecurity.com/hc/en-us/search?utf8=%E2%9C%93&query=Ruby' spec.metadata['wiki_uri'] = 'https://docs.contrastsecurity.com/' end Gem::Specification.new do |spec| spec.name = 'contrast-agent' spec.version = Contrast::Agent::VERSION spec.email = %w[ ruby@contrastsecurity.com ] spec.summary = 'Contrast Security\'s agent for rack-based applications.' spec.description = 'This gem instantiates a Rack middleware for rack-based ' \ 'web applications in order to provide Interactive Application Security ' \ 'Testing and Protection.' spec.homepage = 'https://www.contrastsecurity.com' spec.license = 'CONTRAST SECURITY (see license file)' spec.required_ruby_version = ['>= 2.5.0', '< 2.8.0'] spec.bindir = 'exe' spec.executables = ['contrast_service'] # Keep cs__common first, it handles funchook.h right now. spec.extensions = Dir['ext/cs__common/extconf.rb', 'ext/**/extconf.rb'] spec.require_paths = ['lib'] unless File.exist?(File.join(Dir.pwd, 'contrast_security.yaml')) spec.post_install_message = 'To generate the required contrast_security.yaml file you can run: bundle exec rake contrast:config:create' end add_authors(spec) add_files(spec) add_dev_dependencies(spec) add_dependencies(spec) add_metadata(spec) end