# 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' # rubocop:disable Kernel/RequireRelative require 'bundler' # rubocop:disable Kernel/Require # https://github.com/grpc/grpc/issues/21514#issuecomment-581417788 module BundlerHack def __materialize__ if name == 'google-protobuf' Bundler.settings.temporary(force_ruby_platform: true) do super end else super end end end Bundler::LazySpecification.prepend(BundlerHack) 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 ] end # Add those dependencies required to develop or test the Agent def self.add_dev_dependencies spec spec.add_development_dependency 'bundler' spec.add_development_dependency 'climate_control' # mock ENV 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 '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.80.0' spec.add_development_dependency 'rubocop-performance', '1.5.2' spec.add_development_dependency 'rubocop-rspec', '1.38.1' 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 'google-protobuf', '~> 3.9.0' spec.add_dependency 'parser', '~> 2.6' spec.add_dependency 'rack', '>= 1.0', '< 3.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{^(bin|bitbucket_scripts|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/**/*'] 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'] add_authors(spec) add_files(spec) add_dev_dependencies(spec) add_dependencies(spec) add_metadata(spec) end