├── .rspec ├── lib └── contrast │ ├── user_api │ ├── version.rb │ ├── trace_filter_request.rb │ ├── agent_profile_response.rb │ ├── trace_base_request.rb │ ├── field_error_item.rb │ ├── agent_versions_response.rb │ ├── app_display_name_request.rb │ ├── application_base_resource.rb │ ├── quick_filter_response.rb │ ├── agent_profiles_response.rb │ ├── interval_frequency_item.rb │ ├── application_importance_request.rb │ ├── applications_group_request.rb │ ├── agent_activity_response.rb │ ├── response.rb │ ├── applications_agent_activity_response.rb │ ├── application_settings_request.rb │ ├── webhooks_api.rb │ ├── agent_profile_request.rb │ ├── rule_exclusion_request.rb │ ├── alerts_api.rb │ ├── messages_api.rb │ ├── agent_profile_resource.rb │ ├── modules_api.rb │ ├── history_api.rb │ ├── events_api.rb │ ├── activity_api.rb │ ├── agent_api.rb │ ├── api_support.rb │ ├── profile_api.rb │ ├── scores_api.rb │ ├── libraries_api.rb │ ├── traces_api.rb │ ├── organizations_api.rb │ ├── security_api.rb │ ├── tags_api.rb │ ├── api.rb │ ├── servers_api.rb │ └── application_api.rb │ └── user_api.rb ├── .travis.yml ├── Gemfile ├── Rakefile ├── bin ├── setup └── console ├── .gitignore ├── spec ├── contrast │ └── user_api │ │ ├── tags_api_spec.rb │ │ ├── agent_api_spec.rb │ │ ├── alerts_api_spec.rb │ │ ├── events_api_spec.rb │ │ ├── scores_api_spec.rb │ │ ├── traces_api_scpe.rb │ │ ├── traces_api_spec.rb │ │ ├── activity_api_spec.rb │ │ ├── history_api_spec.rb │ │ ├── messages_api_spec.rb │ │ ├── modules_api_spec.rb │ │ ├── profile_api_spec.rb │ │ ├── security_api_spec.rb │ │ ├── servers_api_spec.rb │ │ ├── application_api_spec.rb │ │ ├── field_error_item_spec.rb │ │ ├── libraries_api_spec.rb │ │ ├── organizations_api_spec.rb │ │ ├── agent_profile_request_spec.rb │ │ ├── quick_filter_response_spec.rb │ │ ├── agent_profile_resource_spec.rb │ │ ├── rule_exclusion_request_spec.rb │ │ ├── agent_activity_response_spec.rb │ │ ├── agent_profiles_response_spec.rb │ │ ├── agent_versions_response_spec.rb │ │ ├── app_display_name_request_spec.rb │ │ ├── interval_frequence_item_spec.rb │ │ ├── application_base_resource_spec.rb │ │ ├── applications_group_request_spec.rb │ │ ├── application_settings_request_spec.rb │ │ ├── version_spec.rb │ │ ├── application_importance_request_spec.rb │ │ └── applications_agent_activity_response_spec.rb ├── spec_helper.rb ├── integration.yml.example └── integration_spec.rb ├── LICENSE.txt ├── contrast-user-api.gemspec ├── README.md └── CODE_OF_CONDUCT.md /.rspec: -------------------------------------------------------------------------------- 1 | --format documentation 2 | --color 3 | -------------------------------------------------------------------------------- /lib/contrast/user_api/version.rb: -------------------------------------------------------------------------------- 1 | module Contrast 2 | module UserApi 3 | VERSION = "0.1.0" 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: false 2 | language: ruby 3 | rvm: 4 | - 2.3.1 5 | before_install: gem install bundler -v 1.13.6 6 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | 3 | # Specify your gem's dependencies in contrast-user-api.gemspec 4 | gemspec 5 | -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | require "bundler/gem_tasks" 2 | require "rspec/core/rake_task" 3 | 4 | RSpec::Core::RakeTask.new(:spec) 5 | 6 | task :default => :spec 7 | -------------------------------------------------------------------------------- /lib/contrast/user_api/trace_filter_request.rb: -------------------------------------------------------------------------------- 1 | module Contrast 2 | module UserApi 3 | class TraceFilterRequest 4 | 5 | end 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /lib/contrast/user_api/agent_profile_response.rb: -------------------------------------------------------------------------------- 1 | module Contrast 2 | module UserApi 3 | class AgentProfileResponse < Response 4 | end 5 | end 6 | end 7 | -------------------------------------------------------------------------------- /bin/setup: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -euo pipefail 3 | IFS=$'\n\t' 4 | set -vx 5 | 6 | bundle install 7 | 8 | # Do any other automated setup that you need to do here 9 | -------------------------------------------------------------------------------- /lib/contrast/user_api/trace_base_request.rb: -------------------------------------------------------------------------------- 1 | module Contrast 2 | module UserApi 3 | class TraceBaseRequest 4 | attr_accessor :traces 5 | end 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /lib/contrast/user_api/field_error_item.rb: -------------------------------------------------------------------------------- 1 | module Contrast 2 | module UserApi 3 | class FieldErrorItem 4 | attr_accessor :field, :message 5 | end 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /.bundle/ 2 | /.yardoc 3 | /Gemfile.lock 4 | /_yardoc/ 5 | /coverage/ 6 | /doc/ 7 | /pkg/ 8 | /spec/reports/ 9 | /spec/integration.yml 10 | /tmp/ 11 | /coverage/ 12 | -------------------------------------------------------------------------------- /lib/contrast/user_api/agent_versions_response.rb: -------------------------------------------------------------------------------- 1 | module Contrast 2 | module UserApi 3 | class AgentVersionsResponse < Response 4 | attr_accessor :agents 5 | end 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /lib/contrast/user_api/app_display_name_request.rb: -------------------------------------------------------------------------------- 1 | module Contrast 2 | module UserApi 3 | class AppDisplayNameRequest 4 | attr_accessor :display_name 5 | end 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /lib/contrast/user_api/application_base_resource.rb: -------------------------------------------------------------------------------- 1 | module Contrast 2 | module UserApi 3 | class ApplicationBaseResource 4 | attr_accessor :app_id, :name 5 | end 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /lib/contrast/user_api/quick_filter_response.rb: -------------------------------------------------------------------------------- 1 | module Contrast 2 | module UserApi 3 | class QuickFilterResponse < Response 4 | attr_accessor :catalog 5 | end 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /lib/contrast/user_api/agent_profiles_response.rb: -------------------------------------------------------------------------------- 1 | module Contrast 2 | module UserApi 3 | class AgentProfilesResponse < Response 4 | attr_accessor :profiles 5 | end 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /lib/contrast/user_api/interval_frequency_item.rb: -------------------------------------------------------------------------------- 1 | module Contrast 2 | module UserApi 3 | class IntervalFrequencyItem 4 | attr_accessor :count, :start, :end 5 | end 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /lib/contrast/user_api/application_importance_request.rb: -------------------------------------------------------------------------------- 1 | module Contrast 2 | module UserApi 3 | class ApplicationImportanceRequest 4 | attr_accessor :importance 5 | end 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /lib/contrast/user_api/applications_group_request.rb: -------------------------------------------------------------------------------- 1 | module Contrast 2 | module UserApi 3 | class ApplicationsGroupRequest 4 | attr_accessor :group_name, :apps 5 | end 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /lib/contrast/user_api/agent_activity_response.rb: -------------------------------------------------------------------------------- 1 | module Contrast 2 | module UserApi 3 | class AgentActivityResponse < Response 4 | attr_accessor :activities, :errors 5 | end 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /lib/contrast/user_api/response.rb: -------------------------------------------------------------------------------- 1 | module Contrast 2 | module UserApi 3 | class Response 4 | attr_accessor :success, 5 | :messages, 6 | :stacktrace 7 | end 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /lib/contrast/user_api/applications_agent_activity_response.rb: -------------------------------------------------------------------------------- 1 | module Contrast 2 | module UserApi 3 | class ApplicationsAgentActivityResponse < Response 4 | attr_accessor :activities 5 | end 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /spec/contrast/user_api/tags_api_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe Contrast::UserApi::TagsApi do 4 | it 'can be instantiated' do 5 | expect(Contrast::UserApi::TagsApi.new).to_not be_nil 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /spec/contrast/user_api/agent_api_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe Contrast::UserApi::AgentApi do 4 | it 'can be instantiated' do 5 | expect(Contrast::UserApi::AgentApi.new).to_not be_nil 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /spec/contrast/user_api/alerts_api_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe Contrast::UserApi::AlertsApi do 4 | it 'can be instantiated' do 5 | expect(Contrast::UserApi::AlertsApi.new).to_not be_nil 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /spec/contrast/user_api/events_api_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe Contrast::UserApi::EventsApi do 4 | it 'can be instantiated' do 5 | expect(Contrast::UserApi::EventsApi.new).to_not be_nil 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /spec/contrast/user_api/scores_api_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe Contrast::UserApi::ScoresApi do 4 | it 'can be instantiated' do 5 | expect(Contrast::UserApi::ScoresApi.new).to_not be_nil 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /spec/contrast/user_api/traces_api_scpe.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe Contrast::UserApi::TracesApi do 4 | it 'can be instantiated' do 5 | expect(Contrast::UserApi::TracesApi.new).to_not be_nil 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /spec/contrast/user_api/traces_api_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe Contrast::UserApi::TracesApi do 4 | it 'can be instantiated' do 5 | expect(Contrast::UserApi::TracesApi.new).to_not be_nil 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /spec/contrast/user_api/activity_api_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe Contrast::UserApi::ActivityApi do 4 | it 'can be instantiated' do 5 | expect(Contrast::UserApi::ActivityApi.new).to_not be_nil 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /spec/contrast/user_api/history_api_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe Contrast::UserApi::HistoryApi do 4 | it 'can be instantiated' do 5 | expect(Contrast::UserApi::HistoryApi.new).to_not be_nil 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /spec/contrast/user_api/messages_api_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe Contrast::UserApi::MessagesApi do 4 | it 'can be instantiated' do 5 | expect(Contrast::UserApi::MessagesApi.new).to_not be_nil 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /spec/contrast/user_api/modules_api_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe Contrast::UserApi::ModulesApi do 4 | it 'can be instantiated' do 5 | expect(Contrast::UserApi::ModulesApi.new).to_not be_nil 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /spec/contrast/user_api/profile_api_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe Contrast::UserApi::ProfileApi do 4 | it 'can be instantiated' do 5 | expect(Contrast::UserApi::ProfileApi.new).to_not be_nil 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /spec/contrast/user_api/security_api_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe Contrast::UserApi::SecurityApi do 4 | it 'can be instantiated' do 5 | expect(Contrast::UserApi::SecurityApi.new).to_not be_nil 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /spec/contrast/user_api/servers_api_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe Contrast::UserApi::ServersApi do 4 | it 'can be instantiated' do 5 | expect(Contrast::UserApi::ServersApi.new).to_not be_nil 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /spec/contrast/user_api/application_api_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe Contrast::UserApi::ApplicationApi do 4 | it 'can be instantiated' do 5 | expect(Contrast::UserApi::ApplicationApi.new).to_not be_nil 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /spec/contrast/user_api/field_error_item_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe Contrast::UserApi::FieldErrorItem do 4 | it 'can be instantiated' do 5 | expect(Contrast::UserApi::FieldErrorItem.new).to_not be_nil 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /spec/contrast/user_api/libraries_api_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe Contrast::UserApi::LibrariesApi do 4 | it 'can be instantiated' do 5 | expect(Contrast::UserApi::LibrariesApi.new).to_not be_nil 6 | end 7 | end 8 | 9 | -------------------------------------------------------------------------------- /spec/contrast/user_api/organizations_api_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe Contrast::UserApi::OrganizationsApi do 4 | it 'can be instantiated' do 5 | expect(Contrast::UserApi::OrganizationsApi.new).to_not be_nil 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /spec/contrast/user_api/agent_profile_request_spec.rb: -------------------------------------------------------------------------------- 1 | require "spec_helper" 2 | 3 | describe Contrast::UserApi::AgentProfileRequest do 4 | it 'can be instantiated' do 5 | expect(Contrast::UserApi::AgentProfileRequest.new).to_not be_nil 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /spec/contrast/user_api/quick_filter_response_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe Contrast::UserApi::QuickFilterResponse do 4 | it 'can be instantiated' do 5 | expect(Contrast::UserApi::QuickFilterResponse.new).to_not be_nil 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /spec/contrast/user_api/agent_profile_resource_spec.rb: -------------------------------------------------------------------------------- 1 | require "spec_helper" 2 | 3 | describe Contrast::UserApi::AgentProfileResource do 4 | it 'can be instantiated' do 5 | expect(Contrast::UserApi::AgentProfileResource.new).to_not be_nil 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /spec/contrast/user_api/rule_exclusion_request_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe Contrast::UserApi::RuleExclusionRequest do 4 | it 'can be instantiated' do 5 | expect(Contrast::UserApi::RuleExclusionRequest.new).to_not be_nil 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /spec/contrast/user_api/agent_activity_response_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe Contrast::UserApi::AgentActivityResponse do 4 | it 'can be instantiated' do 5 | expect(Contrast::UserApi::AgentActivityResponse.new).to_not be_nil 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /spec/contrast/user_api/agent_profiles_response_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe Contrast::UserApi::AgentProfilesResponse do 4 | it 'can be instantiated' do 5 | expect(Contrast::UserApi::AgentProfilesResponse.new).to_not be_nil 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /spec/contrast/user_api/agent_versions_response_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe Contrast::UserApi::AgentVersionsResponse do 4 | it 'can be instantiated' do 5 | expect(Contrast::UserApi::AgentVersionsResponse.new).to_not be_nil 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /spec/contrast/user_api/app_display_name_request_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe Contrast::UserApi::AppDisplayNameRequest do 4 | it 'can be instantiated' do 5 | expect(Contrast::UserApi::AppDisplayNameRequest.new).to_not be_nil 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /spec/contrast/user_api/interval_frequence_item_spec.rb: -------------------------------------------------------------------------------- 1 | require "spec_helper" 2 | 3 | describe Contrast::UserApi::IntervalFrequencyItem do 4 | it "can be instantiated" do 5 | expect(Contrast::UserApi::IntervalFrequencyItem.new).to_not be_nil 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /spec/contrast/user_api/application_base_resource_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe Contrast::UserApi::ApplicationBaseResource do 4 | it 'can be instantiated' do 5 | expect(Contrast::UserApi::ApplicationBaseResource.new).to_not be_nil 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /spec/contrast/user_api/applications_group_request_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe Contrast::UserApi::ApplicationsGroupRequest do 4 | it 'can be instantiated' do 5 | expect(Contrast::UserApi::ApplicationsGroupRequest.new).to_not be_nil 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /spec/contrast/user_api/application_settings_request_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe Contrast::UserApi::ApplicationSettingsRequest do 4 | it 'can be instantiated' do 5 | expect(Contrast::UserApi::ApplicationSettingsRequest.new).to_not be_nil 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /spec/contrast/user_api/version_spec.rb: -------------------------------------------------------------------------------- 1 | require "spec_helper" 2 | 3 | describe Contrast::UserApi do 4 | it "has a version number" do 5 | expect(Contrast::UserApi::VERSION).not_to be nil 6 | expect(Contrast::UserApi::VERSION).to match /[\d]+\.[\d]+\.[\d]+/ 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /spec/contrast/user_api/application_importance_request_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe Contrast::UserApi::ApplicationImportanceRequest do 4 | it 'can be instantiated' do 5 | expect(Contrast::UserApi::ApplicationImportanceRequest.new).to_not be_nil 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /spec/contrast/user_api/applications_agent_activity_response_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe Contrast::UserApi::ApplicationsAgentActivityResponse do 4 | it 'can be instantiated' do 5 | expect(Contrast::UserApi::ApplicationsAgentActivityResponse.new).to_not be_nil 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /lib/contrast/user_api/application_settings_request.rb: -------------------------------------------------------------------------------- 1 | module Contrast 2 | module UserApi 3 | class ApplicationSettingsRequest 4 | attr_accessor :code, 5 | :display_name, 6 | :importance, 7 | :notes, 8 | :override_url 9 | end 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /spec/spec_helper.rb: -------------------------------------------------------------------------------- 1 | require 'simplecov' 2 | SimpleCov.start 3 | 4 | $LOAD_PATH.unshift File.expand_path("../../lib", __FILE__) 5 | require "contrast/user_api" 6 | 7 | RSpec.configure do |config| 8 | unless ENV['INTEGRATION_TESTS'].to_s == "true" 9 | config.filter_run_excluding :integration => true 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /lib/contrast/user_api/webhooks_api.rb: -------------------------------------------------------------------------------- 1 | require 'httparty' 2 | 3 | module Contrast 4 | module UserApi 5 | class WebhooksApi 6 | include HTTParty 7 | include ApiSupport 8 | 9 | attr_accessor :version 10 | 11 | def initialize version 12 | @version = version 13 | end 14 | end 15 | end 16 | end 17 | -------------------------------------------------------------------------------- /spec/integration.yml.example: -------------------------------------------------------------------------------- 1 | teamserver: 2 | host: http://localhost:19080/Contrast # path to server 3 | org_uuid: 9c1dd905-e8d5-447b-b1be-00cbda0d0e67 # Organization UUID (visible in the Teamserver interface) 4 | api_key: demo # API key in plain text 5 | authorization: Y29udHJhc3RfYWRtaW46ZGVtbw== # username:key base 64 encoded (e.g. contrast_admin:demo ) 6 | -------------------------------------------------------------------------------- /lib/contrast/user_api/agent_profile_request.rb: -------------------------------------------------------------------------------- 1 | module Contrast 2 | module UserApi 3 | class AgentProfileRequest 4 | attr_accessor :engine_type, 5 | :name, 6 | :proxy_auth, 7 | :proxy_host, 8 | :proxy_pass, 9 | :proxy_port, 10 | :proxy_user, 11 | :use_proxy 12 | end 13 | end 14 | end 15 | -------------------------------------------------------------------------------- /bin/console: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | require "bundler/setup" 4 | require "contrast/user/api" 5 | 6 | # You can add fixtures and/or initialization code here to make experimenting 7 | # with your gem easier. You can also use a different console, if you like. 8 | 9 | # (If you use this, don't forget to add pry to your Gemfile!) 10 | # require "pry" 11 | # Pry.start 12 | 13 | require "irb" 14 | IRB.start 15 | -------------------------------------------------------------------------------- /lib/contrast/user_api/rule_exclusion_request.rb: -------------------------------------------------------------------------------- 1 | module Contrast 2 | module UserApi 3 | class RuleExclusionRequest 4 | attr_accessor :all_assessment_rules, 5 | :all_protection_rules, 6 | :all_rules, 7 | :assessment_rules, 8 | :codes, 9 | :event_uuid, 10 | :input_name, 11 | :input_type, 12 | :name, 13 | :protection_rules, 14 | :rules, 15 | :type, 16 | :url_pattern_type, 17 | :urls 18 | end 19 | end 20 | end 21 | 22 | -------------------------------------------------------------------------------- /lib/contrast/user_api/alerts_api.rb: -------------------------------------------------------------------------------- 1 | module Contrast 2 | module UserApi 3 | class AlertsApi 4 | include HTTParty 5 | include ApiSupport 6 | 7 | attr_accessor :version 8 | 9 | def initialize version = 'ng' 10 | @version = version 11 | end 12 | 13 | def alerts 14 | self.class.get(path("alerts")) do |response| 15 | # TODO: AlertsResponse 16 | end 17 | end 18 | 19 | def alert alert_id 20 | self.class.get(path("alerts/#{ alert_id }")) do |response| 21 | # TODO: AlertResponse 22 | end 23 | end 24 | end 25 | end 26 | end 27 | -------------------------------------------------------------------------------- /lib/contrast/user_api/messages_api.rb: -------------------------------------------------------------------------------- 1 | require 'httparty' 2 | 3 | module Contrast 4 | module UserApi 5 | class MessagesApi 6 | include HTTParty 7 | include ApiSupport 8 | 9 | attr_reader :version 10 | 11 | def initialize version = "ng" 12 | @version = version 13 | end 14 | 15 | def messages 16 | self.class.get(global_path('messages')) do |response| 17 | # TODO: build SystemMessagesResponse 18 | end 19 | end 20 | 21 | def next_message 22 | self.class.get(global_path('messages/next')) do |response| 23 | # TODO: build NextSystemMessageResponse 24 | end 25 | end 26 | end 27 | end 28 | end 29 | -------------------------------------------------------------------------------- /lib/contrast/user_api/agent_profile_resource.rb: -------------------------------------------------------------------------------- 1 | module Contrast 2 | module UserApi 3 | class AgentProfileResource 4 | attr_accessor :name, # string 5 | :engine_type, # string 6 | :log_file, # string 7 | :log_level, # string 8 | :log_stdout, # boolean 9 | :log_to_file, # boolean 10 | :sampling, # boolean, sampling enabled 11 | :sampling_baseline, 12 | :sampling_frequency, 13 | :sampling_window, 14 | :stacktrace_capture_mode, # string 15 | :use_proxy, # boolean 16 | :proxy_host, 17 | :proxy_port, 18 | :proxy_auth, 19 | :proxy_user 20 | end 21 | end 22 | end 23 | -------------------------------------------------------------------------------- /lib/contrast/user_api/modules_api.rb: -------------------------------------------------------------------------------- 1 | require 'httparty' 2 | 3 | module Contrast 4 | module UserApi 5 | class ModulesApi 6 | include HTTParty 7 | include ApiSupport 8 | 9 | attr_reader :version 10 | 11 | def initialize version = "ng" 12 | @version = version 13 | end 14 | 15 | def modules expand = nil 16 | params = query_params(expand, nil, nil, nil) 17 | self.class.get(path("modules"), { query: params }) do |response| 18 | # TODO: build ModulesResponse 19 | end 20 | end 21 | 22 | def application_modules app_id, expand = nil 23 | params = query_params(expand, nil, nil, nil) 24 | self.class.get(path("modules/#{ app_id }"), { query: params }) do |response| 25 | # TODO: build ApplicationsResponse 26 | end 27 | end 28 | end 29 | end 30 | end 31 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Contrast Security 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /lib/contrast/user_api/history_api.rb: -------------------------------------------------------------------------------- 1 | require 'httparty' 2 | 3 | module Contrast 4 | module UserApi 5 | class HistoryApi 6 | include HTTParty 7 | include ApiSupport 8 | 9 | attr_reader :version 10 | 11 | def initialize version = "ng" 12 | @version = version 13 | end 14 | 15 | def history_scores limit = nil 16 | params = query_params(nil, nil, nil, limit) 17 | self.class.get(path("history/scores"), { query: params }) do |response| 18 | # TODO: build HistoryScoresResponse 19 | end 20 | end 21 | 22 | def history_scores_by_interval interval 23 | params = query_params(nil, nil, nil, nil) 24 | params[:interval] = interval unless interval.nil? 25 | self.class.get(path("history/scores/interval"), { query: params }) do |response| 26 | # TODO: build HistoryScoresResponse 27 | end 28 | end 29 | 30 | def history_scores_with_defense_by_interval interval 31 | params = query_params(nil, nil, nil, nil) 32 | params[:interval] = interval unless interval.nil? 33 | self.class.get(path("history/scores/interval/defense"), { query: params }) do |response| 34 | # TODO: build HistoryScoresResponse 35 | end 36 | end 37 | end 38 | end 39 | end 40 | -------------------------------------------------------------------------------- /lib/contrast/user_api/events_api.rb: -------------------------------------------------------------------------------- 1 | module Contrast 2 | module UserApi 3 | class EventsApi 4 | include HTTParty 5 | include ApiSupport 6 | 7 | attr_reader :version 8 | 9 | def initialize version = "ng" 10 | @version = version 11 | end 12 | 13 | def events limit = nil 14 | params = query_params(nil, nil, nil, limit) 15 | self.class.get(path("events"), { query: params }) do |response| 16 | # TODO: build ActivityResponse 17 | end 18 | end 19 | 20 | def events_application limit = nil 21 | params = query_params(nil, nil, nil, limit) 22 | self.class.get(path("events/application"), { query: params }) do |response| 23 | # TODO: build ActivityResponse 24 | end 25 | end 26 | 27 | def events_server limit = nil 28 | params = query_params(nil, nil, nil, limit) 29 | self.class.get(path("events/server"), { query: params }) do |response| 30 | # TODO: build ActivityResponse 31 | end 32 | end 33 | 34 | def events_trace limit = nil 35 | params = query_params(nil, nil, nil, limit) 36 | self.class.get(path("events/trace"), { query: params }) do |response| 37 | # TODO: build ActivityResponse 38 | end 39 | end 40 | end 41 | end 42 | end 43 | -------------------------------------------------------------------------------- /lib/contrast/user_api/activity_api.rb: -------------------------------------------------------------------------------- 1 | module Contrast 2 | module UserApi 3 | class ActivityApi 4 | include HTTParty 5 | include ApiSupport 6 | 7 | attr_reader :version 8 | 9 | def initialize version = "ng" 10 | @version = version 11 | end 12 | 13 | def inactive_activity expand = nil, archived = nil, merged = nil, limit = nil 14 | params = query_params(expand, archived, merged, limit) 15 | self.class.get(path("activity/inactive"), { query: params }) do |response| 16 | # TODO: build ApplicationsResponse object 17 | end 18 | end 19 | 20 | def newest_activity expand = nil, archived = nil, merged = nil, limit = nil 21 | params = query_params(expand, archived, merged, limit) 22 | self.class.get(path("activity/inactive"), { query: params }) do |response| 23 | # TODO: build ApplicationsResponse object 24 | end 25 | end 26 | 27 | def recent_activity expand = nil, archived = nil, merged = nil, limit = nil 28 | params = query_params(expand, archived, merged, limit) 29 | self.class.get(path("activity/recent"), { query: params }) do |response| 30 | # TODO: build ApplicationsResponse object 31 | end 32 | end 33 | 34 | def application_agent_activity app_id, range, merged = nil 35 | params = query_params(nil, nil, merged, nil) 36 | self.class.get(application_path(app_id, "agent/activity/#{ range }"), { query: params }) do |response| 37 | # TODO: build ApplicationAgentActivityResponse object 38 | end 39 | end 40 | 41 | end 42 | end 43 | end 44 | -------------------------------------------------------------------------------- /contrast-user-api.gemspec: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | lib = File.expand_path('../lib', __FILE__) 3 | $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) 4 | require 'contrast/user_api/version' 5 | 6 | Gem::Specification.new do |spec| 7 | spec.name = "contrast-user-api" 8 | spec.version = Contrast::UserApi::VERSION 9 | spec.authors = ["Galen Palmer"] 10 | spec.email = ["galen.palmer@contrastsecurity.com"] 11 | 12 | spec.summary = %q{Ruby API access to the Teamserver user api} 13 | spec.description = %q{Ruby API access to the Teamserver user api} 14 | spec.homepage = "https://api.contrastsecurity.com" 15 | spec.license = "MIT" 16 | 17 | # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host' 18 | # to allow pushing to a single host or delete this section to allow pushing to any host. 19 | if spec.respond_to?(:metadata) 20 | spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'" 21 | else 22 | raise "RubyGems 2.0 or newer is required to protect against " \ 23 | "public gem pushes." 24 | end 25 | 26 | spec.files = `git ls-files -z`.split("\x0").reject do |f| 27 | f.match(%r{^(test|spec|features)/}) 28 | end 29 | spec.bindir = "exe" 30 | spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) } 31 | spec.require_paths = ["lib"] 32 | 33 | spec.add_dependency "httparty", "~> 0.14" 34 | 35 | spec.add_development_dependency "bundler", "~> 1.13" 36 | spec.add_development_dependency "rake", "~> 10.0" 37 | spec.add_development_dependency "rspec", "~> 3.0" 38 | spec.add_development_dependency "simplecov" 39 | end 40 | -------------------------------------------------------------------------------- /lib/contrast/user_api/agent_api.rb: -------------------------------------------------------------------------------- 1 | require 'httparty' 2 | 3 | module Contrast 4 | module UserApi 5 | class AgentApi 6 | include HTTParty 7 | include ApiSupport 8 | 9 | attr_reader :version 10 | 11 | def initialize version = "ng" 12 | @version = version 13 | end 14 | 15 | def profiles expand = false 16 | params = expand ? { query: { expand: true } } : {} 17 | self.class.get(agents_path('profiles'), params) 18 | end 19 | 20 | def profile name, expand = false 21 | params = expand ? { query: { expand: true } } : {} 22 | self.class.get(agents_path("profiles/#{ name }"), params) 23 | end 24 | 25 | def create_profile agent_profile_request 26 | expect_class!(agent_profile_request, Contrast::UserApi::AgentProfileRequest) 27 | 28 | body = { body: agent_profile_request.to_hash } 29 | self.class.post(agents_path('profiles'), body) 30 | end 31 | 32 | def update_profile name, agent_profile_request 33 | expect_class!(agent_profile_request, Contrast::UserApi::AgentProfileRequest) 34 | 35 | body = { body: agent_profile_request.to_hash } 36 | self.class.put(agents_path("profiles/#{ name }"), body) 37 | end 38 | 39 | def versions 40 | self.class.get(agents_path("profiles/versions")) 41 | end 42 | 43 | def agent name, platform 44 | self.class.get(agents_path("profiles/#{ name }/#{ platform }")) 45 | end 46 | 47 | private 48 | 49 | def agents_path path 50 | value_required!(path) 51 | path("agents/#{ path }") 52 | end 53 | end 54 | end 55 | end 56 | 57 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Contrast::User::Api 2 | 3 | This gem provides examples of API access to the Contrast Security Teamserver application. 4 | 5 | ## Installation 6 | 7 | Add this line to your application's Gemfile: 8 | 9 | ```ruby 10 | gem 'contrast-user-api' 11 | ``` 12 | 13 | And then execute: 14 | 15 | $ bundle 16 | 17 | Or install it yourself as: 18 | 19 | $ gem install contrast-user-api 20 | 21 | ## Usage 22 | 23 | The endpoints supported by this gem are available through a common API class. 24 | 25 | api = Contrast::UserApi::Api.new('path/to/configuration.yml') 26 | api.applications # => response object containing JSON 27 | 28 | The configuration can be defined in API initialization, a path defined in the "CONTRAST_SECURITY_CONFIG" environment variable or in `contrast_security.yml` in current working directory, in a config subdirectory, or in `/etc/contrast_security.yml`. 29 | 30 | ## Development 31 | 32 | After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment. 33 | 34 | To run the tests. First, rename the test configuration file in `spec/integration.yml.example` to `spec/integration.yml` and update the value to match the value in your local environment. 35 | 36 | 37 | ## Contributing 38 | 39 | Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/contrast-user-api. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct. 40 | 41 | 42 | ## License 43 | 44 | The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT). 45 | 46 | -------------------------------------------------------------------------------- /lib/contrast/user_api.rb: -------------------------------------------------------------------------------- 1 | require "contrast/user_api/version" 2 | 3 | ## APIs 4 | 5 | require "contrast/user_api/api" 6 | 7 | require "contrast/user_api/api_support" 8 | require "contrast/user_api/agent_api" 9 | require "contrast/user_api/activity_api" 10 | require "contrast/user_api/application_api" 11 | require "contrast/user_api/events_api" 12 | require "contrast/user_api/history_api" 13 | require "contrast/user_api/libraries_api" 14 | require "contrast/user_api/messages_api" 15 | require "contrast/user_api/modules_api" 16 | require "contrast/user_api/alerts_api" 17 | require "contrast/user_api/profile_api" 18 | require "contrast/user_api/organizations_api" 19 | require "contrast/user_api/security_api" 20 | require "contrast/user_api/scores_api" 21 | require "contrast/user_api/servers_api" 22 | require "contrast/user_api/tags_api" 23 | require "contrast/user_api/traces_api" 24 | require "contrast/user_api/webhooks_api" 25 | 26 | ## Models 27 | 28 | # Global 29 | require "contrast/user_api/response" 30 | require "contrast/user_api/field_error_item" 31 | require "contrast/user_api/interval_frequency_item" 32 | 33 | # Agent Request 34 | require "contrast/user_api/agent_profile_request" 35 | 36 | # Agent Resource 37 | require "contrast/user_api/agent_profile_resource" 38 | 39 | # Agent Response 40 | require "contrast/user_api/agent_profile_response" 41 | require "contrast/user_api/agent_profiles_response" 42 | require "contrast/user_api/agent_activity_response" 43 | require "contrast/user_api/agent_versions_response" 44 | require "contrast/user_api/applications_agent_activity_response" 45 | 46 | # Application Request 47 | require "contrast/user_api/app_display_name_request" 48 | require "contrast/user_api/application_importance_request" 49 | require "contrast/user_api/application_settings_request" 50 | require "contrast/user_api/applications_group_request" 51 | require "contrast/user_api/quick_filter_response" 52 | require "contrast/user_api/rule_exclusion_request" 53 | 54 | # Application Resource 55 | require "contrast/user_api/application_base_resource" 56 | 57 | module Contrast 58 | module UserApi 59 | end 60 | end 61 | -------------------------------------------------------------------------------- /lib/contrast/user_api/api_support.rb: -------------------------------------------------------------------------------- 1 | module Contrast 2 | module UserApi 3 | module ApiSupport 4 | 5 | class PathIDError < RuntimeError 6 | end 7 | 8 | def org_uuid 9 | @_org_uuid ||= nil 10 | end 11 | 12 | def org_uuid= val 13 | @_org_uuid = val 14 | end 15 | 16 | def expect_class! instance, clazz 17 | unless instance.is_a?(clazz) 18 | raise ArgumentError.new("Expected #{ clazz.name } but got #{ instance.class.name }") 19 | end 20 | end 21 | 22 | def value_required! val, field = "Path" 23 | if val.nil? || val.to_s.empty? 24 | raise PathIDError.new("#{ field } is required for this endpoint") 25 | end 26 | end 27 | 28 | def org_uuid_required! 29 | if org_uuid.nil? || org_uuid.to_s.empty? 30 | raise PathIDError.new("Organization UUID is required for this endpoint") 31 | end 32 | end 33 | 34 | def query_params expand, archived, merged, limit 35 | params = {} 36 | params[:expand] = expand unless expand.nil? 37 | params[:includeArchived] = archived unless archived.nil? 38 | params[:includeMerged] = merged unless merged.nil? 39 | params[:limit] = limit.to_i unless limit.nil? 40 | params 41 | end 42 | 43 | def global_path path 44 | "/#{ version }/#{ path }" 45 | end 46 | 47 | def path path = nil 48 | org_uuid_required! 49 | value_required!(path) 50 | 51 | if path.nil? 52 | "/#{ version }/#{ org_uuid }/#{ path }" 53 | else 54 | "/#{ version }/#{ org_uuid }/#{ path }" 55 | end 56 | end 57 | 58 | def application_path app_id, sub = nil 59 | value_required!(app_id, "Application ID") 60 | 61 | if sub.nil? 62 | path("applications/#{ app_id }") 63 | else 64 | path("applications/#{ app_id }/#{ sub }") 65 | end 66 | end 67 | 68 | def server_path server_id, sub = nil 69 | value_required!(server_id, "Server ID") 70 | 71 | if sub.nil? 72 | path("servers/#{ server_id }") 73 | else 74 | path("servers/#{ server_id }/#{ sub }") 75 | end 76 | end 77 | 78 | def traces_path app_id, sub = nil 79 | value_required!(app_id, "Application ID") 80 | 81 | if sub.nil? 82 | path("traces/#{ app_id }") 83 | else 84 | path("traces/#{ app_id }/#{ sub }") 85 | end 86 | end 87 | end 88 | end 89 | end 90 | -------------------------------------------------------------------------------- /lib/contrast/user_api/profile_api.rb: -------------------------------------------------------------------------------- 1 | require 'httparty' 2 | 3 | module Contrast 4 | module UserApi 5 | class ProfileApi 6 | include HTTParty 7 | include ApiSupport 8 | 9 | attr_accessor :version 10 | 11 | def initialize version = 'ng' 12 | @version = version 13 | end 14 | 15 | def roles 16 | self.class.get(global_path("roles")) do |response| 17 | # TODO: build RolesResponse 18 | end 19 | end 20 | 21 | def profile 22 | self.class.get(global_path("profile")) do |response| 23 | # TODO: build UserResponse 24 | end 25 | end 26 | 27 | def update_profile profile 28 | expect_class!(profile, Contrast::UserApi::EditProfileRequest) 29 | self.class.put(global_path("profile"), { body: profile }) do |response| 30 | # TODO: build BaseApiResponse 31 | end 32 | end 33 | 34 | def update_expired_password password 35 | expect_class!(password, Contrast::UserApi::ExpiredPasswordRequest) 36 | self.class.put(global_path("profile/expired"), { body: password }) do |response| 37 | # TODO: build BaseApiResponse 38 | end 39 | end 40 | 41 | def update_password password 42 | expect_class!(password, Contrast::UserApi::PasswordProfileRequest) 43 | self.class.put(global_path("profile/password"), { body: password }) do |response| 44 | # TODO: build BaseApiResponse 45 | end 46 | end 47 | 48 | def password_policy 49 | self.class.get(global_path("profile/passwordpolicy")) do |response| 50 | # TODO: build PasswordPolicyResponse 51 | end 52 | end 53 | 54 | def user_roles 55 | self.class.get(global_path("profile/roles")) do |response| 56 | # TODO: build UserSettingsResponse 57 | end 58 | end 59 | 60 | def toggle_profile 61 | self.class.get(global_path("profile/toggle")) do |response| 62 | # TODO: build BaseApiResponse 63 | end 64 | end 65 | 66 | def report_preferences 67 | self.class.get(path("report/preferences")) do |response| 68 | # TODO: build UserReportPreferencesResponse 69 | end 70 | end 71 | 72 | def update_default_organization uuid 73 | self.class.put(global_path("profile/#{ uuid }/default")) do |response| 74 | # TODO: build OrganizationWithRolesResponse 75 | end 76 | end 77 | 78 | def allowed_organizations 79 | self.class.get(global_path("profile/organizations")) do |response| 80 | # TODO: build AllowedOrganizationsResponse 81 | end 82 | end 83 | 84 | def organization_by_uuid uuid 85 | self.class.get(global_path("profile/organizations/#{ uuid }")) do |response| 86 | # TODO: build OrganizationWithRolesResponse 87 | end 88 | end 89 | end 90 | end 91 | end 92 | -------------------------------------------------------------------------------- /lib/contrast/user_api/scores_api.rb: -------------------------------------------------------------------------------- 1 | require 'httparty' 2 | 3 | module Contrast 4 | module UserApi 5 | class ScoresApi 6 | include HTTParty 7 | include ApiSupport 8 | 9 | attr_accessor :version 10 | 11 | def initialize version = 'ng' 12 | @version = version 13 | end 14 | 15 | def scores 16 | self.class.get(path('scores')) do |response| 17 | # TODO: build ScoreResponse 18 | end 19 | end 20 | 21 | def scores_breakdown_category 22 | self.class.get(path("scores/breakdown/category")) do |response| 23 | # TODO: build RuleCategoryBreakdownResponse 24 | end 25 | end 26 | 27 | def scores_breakdown_rule 28 | self.class.get(path("scores/breakdown/rule")) do |response| 29 | # TODO: build RuleTitleBreakdownResponse 30 | end 31 | end 32 | 33 | def scores_breakdown_server 34 | self.class.get(path("scores/breakdown/server")) do |response| 35 | # TODO: build ServerTypeBreakdownResponse 36 | end 37 | end 38 | 39 | def scores_breakdown_severity 40 | self.class.get(path("scores/breakdown/severity")) do |response| 41 | # TODO: build RuleSeverityBreakdownResponse 42 | end 43 | end 44 | 45 | def scores_breakdown_status 46 | self.class.get(path("scores/breakdown/status")) do |response| 47 | # TODO: build TraceStatusBreakdownResponse 48 | end 49 | end 50 | 51 | def scores_breakdown_trace 52 | self.class.get(path("scores/breakdown/trace")) do |response| 53 | # TODO: build TraceBreakdownResponse 54 | end 55 | end 56 | 57 | def scores_breakdown_trace_rule 58 | self.class.get(path("scores/breakdown/trace/rule")) do |response| 59 | # TODO: build TraceRuleTypeBreakdownResponse 60 | end 61 | end 62 | 63 | def scores_breakdown_trace_severity 64 | self.class.get(path("scores/breakdown/trace/severity")) do |response| 65 | # TODO: TraceSeverityBreakdownResponse 66 | end 67 | end 68 | 69 | def scores_breakdown_trace_status 70 | self.class.get(path("scores/breakdown/trace/status")) do |response| 71 | # TODO: TraceEnvStatusBreakdownResponse 72 | end 73 | end 74 | 75 | def platform_score 76 | self.class.get(path("scores/platform")) do |response| 77 | # TODO: build ScoreMetricResponse 78 | end 79 | end 80 | 81 | def platform_score_with_defense 82 | self.class.get(path("scores/platform/defense")) do |response| 83 | # TODO: build ScoreMetricResponse 84 | end 85 | end 86 | 87 | def organization_security_score 88 | self.class.get(path("scores/security")) do |response| 89 | # TODO: build SecurityScoreMetricResponse 90 | end 91 | end 92 | 93 | def organization_security_score_with_defense 94 | self.class.get(path("scores/security/defense")) do |response| 95 | # TODO: biuld SecurityScoreMetricResponse 96 | end 97 | end 98 | end 99 | end 100 | end 101 | -------------------------------------------------------------------------------- /lib/contrast/user_api/libraries_api.rb: -------------------------------------------------------------------------------- 1 | require 'httparty' 2 | 3 | module Contrast 4 | module UserApi 5 | class LibrariesApi 6 | include HTTParty 7 | include ApiSupport 8 | 9 | attr_reader :version 10 | 11 | def initialize version = "ng" 12 | @version = version 13 | end 14 | 15 | def libraries quick_filter = nil, expand = nil 16 | params = query_params(expand, nil, nil, nil) 17 | params[:quickFilter] = quick_filter unless quick_filter.nil? 18 | self.class.get(path("libraries"), { query: params }) do |response| 19 | # TODO: build LibrariesResponse 20 | end 21 | end 22 | 23 | def libraries_filter apps = nil, servers = nil, tags = nil, q = nil, quick_filter = nil, expand = nil 24 | params = query_params(expand, nil, nil, nil) 25 | params[:apps] = Array(apps) unless apps.nil? 26 | params[:servers] = Array(servers) unless servers.nil? 27 | params[:tags] = Array(tags) unless tags.nil? 28 | params[:q] = q unless q.nil? 29 | params[:quickFilter] = quick_filter unless quick_filter.nil? 30 | self.class.get(path("libraries/filter"), { query: params }) do |response| 31 | # TODO: build LibrariesReponse 32 | end 33 | end 34 | 35 | def dotnet_libraries hash, expand = nil 36 | params = query_params(expand, nil, nil, nil) 37 | self.class.get(path("libraries/dotnet/#{ hash }"), { query: params }) do |response| 38 | # TODO: build LibrariesResponse 39 | end 40 | end 41 | 42 | def java_libraries hash, expand = nil 43 | params = query_params(expand, nil, nil, nil) 44 | self.class.get(path("libraries/java/#{ hash }"), { query: params }) do |response| 45 | # TODO: build LibrariesResponse 46 | end 47 | end 48 | 49 | def libraries_subfilter subfilter = nil 50 | self.class.get(path("libraries/filters/#{ subfilter }/listing")) do |response| 51 | # TODO: build LibraryFilterCatalogDetailsResponse 52 | end 53 | end 54 | 55 | def libraries_stats 56 | self.class.get(path("libraries/stats")) do |response| 57 | # TODO: build LibrariesStatsResponse 58 | end 59 | end 60 | 61 | def libraries_filters_listing filter_type 62 | params = query_params(nil, nil, nil, nil) 63 | params[:filterType] = filter_type 64 | self.class.get(global_path("libraries/filters/listing"), { query: params }) do |response| 65 | # TODO: LibraryFilterCatalogResponse 66 | end 67 | end 68 | 69 | def library_policy 70 | self.class.get(path("library/policy")) do |response| 71 | # TODO: LibraryPolicyResponse 72 | end 73 | end 74 | 75 | def update_library_policy policy 76 | expect_class!(policy, Contrast::UserApi::LibraryPolicyRequest) 77 | self.class.put(path("library/policy"), { body: policy }) do |response| 78 | # TODO: BaseApiResponse 79 | end 80 | end 81 | 82 | def library_policy_libraries 83 | self.class.get(path("library/policy/libraries")) do |response| 84 | # TODO: build LibrariesPolicyResponse 85 | end 86 | end 87 | end 88 | end 89 | end 90 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | In the interest of fostering an open and welcoming environment, we as 6 | contributors and maintainers pledge to making participation in our project and 7 | our community a harassment-free experience for everyone, regardless of age, body 8 | size, disability, ethnicity, gender identity and expression, level of experience, 9 | nationality, personal appearance, race, religion, or sexual identity and 10 | orientation. 11 | 12 | ## Our Standards 13 | 14 | Examples of behavior that contributes to creating a positive environment 15 | include: 16 | 17 | * Using welcoming and inclusive language 18 | * Being respectful of differing viewpoints and experiences 19 | * Gracefully accepting constructive criticism 20 | * Focusing on what is best for the community 21 | * Showing empathy towards other community members 22 | 23 | Examples of unacceptable behavior by participants include: 24 | 25 | * The use of sexualized language or imagery and unwelcome sexual attention or 26 | advances 27 | * Trolling, insulting/derogatory comments, and personal or political attacks 28 | * Public or private harassment 29 | * Publishing others' private information, such as a physical or electronic 30 | address, without explicit permission 31 | * Other conduct which could reasonably be considered inappropriate in a 32 | professional setting 33 | 34 | ## Our Responsibilities 35 | 36 | Project maintainers are responsible for clarifying the standards of acceptable 37 | behavior and are expected to take appropriate and fair corrective action in 38 | response to any instances of unacceptable behavior. 39 | 40 | Project maintainers have the right and responsibility to remove, edit, or 41 | reject comments, commits, code, wiki edits, issues, and other contributions 42 | that are not aligned to this Code of Conduct, or to ban temporarily or 43 | permanently any contributor for other behaviors that they deem inappropriate, 44 | threatening, offensive, or harmful. 45 | 46 | ## Scope 47 | 48 | This Code of Conduct applies both within project spaces and in public spaces 49 | when an individual is representing the project or its community. Examples of 50 | representing a project or community include using an official project e-mail 51 | address, posting via an official social media account, or acting as an appointed 52 | representative at an online or offline event. Representation of a project may be 53 | further defined and clarified by project maintainers. 54 | 55 | ## Enforcement 56 | 57 | Instances of abusive, harassing, or otherwise unacceptable behavior may be 58 | reported by contacting the project team at galen.palmer@contrastsecurity.com. All 59 | complaints will be reviewed and investigated and will result in a response that 60 | is deemed necessary and appropriate to the circumstances. The project team is 61 | obligated to maintain confidentiality with regard to the reporter of an incident. 62 | Further details of specific enforcement policies may be posted separately. 63 | 64 | Project maintainers who do not follow or enforce the Code of Conduct in good 65 | faith may face temporary or permanent repercussions as determined by other 66 | members of the project's leadership. 67 | 68 | ## Attribution 69 | 70 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, 71 | available at [http://contributor-covenant.org/version/1/4][version] 72 | 73 | [homepage]: http://contributor-covenant.org 74 | [version]: http://contributor-covenant.org/version/1/4/ 75 | -------------------------------------------------------------------------------- /lib/contrast/user_api/traces_api.rb: -------------------------------------------------------------------------------- 1 | require 'httparty' 2 | 3 | module Contrast 4 | module UserApi 5 | class TracesApi 6 | include HTTParty 7 | include ApiSupport 8 | 9 | attr_accessor :version 10 | 11 | def initialize version = "ng" 12 | @version = version 13 | end 14 | 15 | def delete_trace_set resource 16 | expect_class!(resource, Contrast::UserApi::TraceBaseRequest) 17 | self.class.delete(path("orgtaces"), { body: resource }) do |response| 18 | 19 | end 20 | end 21 | 22 | def export_traces_csv request = nil 23 | params = query_params(nil, nil, nil, nil) 24 | params[:request] = request unless request.nil? 25 | self.class.post(path("orgtraces/export/csv"), { query: params }) do |response| 26 | 27 | end 28 | end 29 | 30 | def export_all_traces_csv request = nil, sort = nil 31 | params = query_params(nil, nil, nil, nil) 32 | params[:sort] = sort unless sort.nil? 33 | params[:request] = request unless request.nil? 34 | self.class.post(path("orgtraces/export/csv/all"), { query: params }) do |response| 35 | 36 | end 37 | end 38 | 39 | def export_traces_xml request = nil 40 | params = query_params(nil, nil, nil, nil) 41 | params[:request] = request unless request.nil? 42 | self.class.post(path("orgtraces/export/xml"), { query: params }) do |response| 43 | 44 | end 45 | end 46 | 47 | def export_all_traces_xml request = nil, sort = nil 48 | params = query_params(nil, nil, nil, nil) 49 | params[:sort] = sort unless sort.nil? 50 | params[:request] = request unless request.nil? 51 | self.class.post(path("orgtraces/export/xml/all"), { query: params }) do |response| 52 | 53 | end 54 | end 55 | 56 | def orgtraces_ids request = nil, sort = nil 57 | params = query_params(nil, nil, nil, nil) 58 | params[:sort] = sort unless sort.nil? 59 | params[:request] = request unless request.nil? 60 | self.class.get(path("orgtraces/ids"), { query: params }) do |response| 61 | 62 | end 63 | end 64 | 65 | def orgtraces_with_policy_violations 66 | self.class.get(path("orgtraces/policy/violations")) do |response| 67 | 68 | end 69 | end 70 | 71 | def orgtraces_quick_filters request = nil 72 | params = query_params(nil, nil, nil, nil) 73 | params[:request] = request unless request.nil? 74 | self.class.get(path("orgtraces/quick"), { query: params }) do |response| 75 | 76 | end 77 | end 78 | 79 | def delete_orgtrace trace_uuid 80 | self.class.delete(path("orgtraces/trace/#{ trace_uuid }")) do |response| 81 | 82 | end 83 | end 84 | 85 | def export_traces_filter_and_keycode_csv filter_type, keycode, form = nil, sort = ni 86 | params = query_params(nil, nil, nil, nil) 87 | params[:form] = form unless form.nil? 88 | params[:sort] = sor unless sort.nil? 89 | self.class.post(path("orgtraces/#{ filter_type }/#{ keycode }/csv"), { query: params }) do |response| 90 | 91 | end 92 | end 93 | 94 | def export_traces_filter_and_keycode_xml filter_type, keycode, form = nil, sort = ni 95 | params = query_params(nil, nil, nil, nil) 96 | params[:form] = form unless form.nil? 97 | params[:sort] = sor unless sort.nil? 98 | self.class.post(path("orgtraces/#{ filter_type }/#{ keycode }/xml"), { query: params }) do |response| 99 | 100 | end 101 | end 102 | 103 | end 104 | end 105 | end 106 | -------------------------------------------------------------------------------- /lib/contrast/user_api/organizations_api.rb: -------------------------------------------------------------------------------- 1 | require 'httparty' 2 | 3 | module Contrast 4 | module UserApi 5 | class OrganizationsApi 6 | include HTTParty 7 | include ApiSupport 8 | 9 | attr_accessor :version 10 | 11 | def initialize version = "ng" 12 | @version = version 13 | end 14 | 15 | def organization 16 | self.class.get(path("organizations")) do |response| 17 | # TODO: build OrganizationResponse 18 | end 19 | end 20 | 21 | def organization_administrators 22 | self.class.get(path("organizations/administrators")) do |response| 23 | # TODO: build OrganizationAdminResponse 24 | end 25 | end 26 | 27 | def organization_apikey 28 | self.class.get(path("organizations/apikey")) do |response| 29 | # TODO: build UserApiKeyResponse 30 | end 31 | end 32 | 33 | def organization_application_roles 34 | self.class.get(path("organizations/application/roles")) do |response| 35 | # TODO: ApplicationsRoleResponse 36 | end 37 | end 38 | 39 | def server_need_restart_on_change language 40 | self.class.get(path("organizations/servers/restart/#{ language }")) do |response| 41 | # TODO: build ServerBaseResponse 42 | end 43 | end 44 | 45 | def organization_application_stats interval = nil, expand = nil 46 | params = query_params(expand, nil, nil, nil) 47 | params[:interval] = interval unless interval.nil? 48 | self.class.get(path("organizations/stats/application"), { query: params }) do |response| 49 | # TODO: build OrganizationApplicationStatsResponse 50 | end 51 | end 52 | 53 | def organization_library_stats interval = nil, expand = nil 54 | params = query_params(expand, nil, nil, nil) 55 | params[:interval] = interval unless interval.nil? 56 | self.class.get(path("organizations/stats/library"), { query: params }) do |response| 57 | # TODO: build OrganizationLibraryStatsResponse 58 | end 59 | end 60 | 61 | def organization_server_stats interval = nil, expand = nil 62 | params = query_params(expand, nil, nil, nil) 63 | params[:interval] = interval unless interval.nil? 64 | self.class.get(path("organizations/stats/server"), { query: params }) do |response| 65 | # TODO: build OrganizationServerStatsResponse 66 | end 67 | end 68 | 69 | def organization_trace_stats interval = nil 70 | params = query_params(nil, nil, nil, nil) 71 | params[:interval] = interval unless interval.nil? 72 | self.class.get(path("organizations/stats/trace"), { query: params }) do |response| 73 | # TODO: build OrganizationTraceStatsResponse 74 | end 75 | end 76 | 77 | def server_settings 78 | self.class.get(path("server/settings")) do |response| 79 | # TODO: build ServerSettingsResponse 80 | end 81 | end 82 | 83 | def update_server_settings settings 84 | expect_class!(settings, Contrast::UserApi::ServerSettingsRequest) 85 | 86 | self.class.put(path("server/settings"), { body: settings }) do |response| 87 | # TODO: build BaseApiResponse 88 | end 89 | end 90 | 91 | def update_assess_settings settings 92 | # TODO: no class listed in documentation 93 | # expect_class!(settings, Contrast::UserApi::... 94 | 95 | self.class.put(path("server/settings/assess"), { body: settings }) do |response| 96 | # TODO: build BaseApiResponse 97 | end 98 | end 99 | 100 | def update_bot_protection_settings settings 101 | # TODO: no class listed in documentation 102 | # expect_class!(settings, Contrast::UserApi::... 103 | 104 | self.class.put(path("server/settings/botblocking"), { body: settings }) do |response| 105 | # TODO: build BaseApiResponse 106 | end 107 | end 108 | 109 | def update_defend_settings settings 110 | # TODO: no class listed in documentation 111 | # expect_class!(settings, Contrast::UserApi::... 112 | 113 | self.class.put(path("server/settings/defend"), { body: settings }) do |response| 114 | # TODO: build BaseApiResponse 115 | end 116 | end 117 | 118 | def organization_search q 119 | params = query_params(nil, nil, nil, nil) 120 | params[:q] = q 121 | self.class.get(path("search"), { query: params }) do |response| 122 | # TODO: build OrganizationSearchResultsResponse 123 | end 124 | end 125 | end 126 | end 127 | end 128 | -------------------------------------------------------------------------------- /lib/contrast/user_api/security_api.rb: -------------------------------------------------------------------------------- 1 | require 'httparty' 2 | 3 | module Contrast 4 | module UserApi 5 | class SecurityApi 6 | include HTTParty 7 | include ApiSupport 8 | 9 | attr_accessor :version 10 | 11 | def initialize version = "ng" 12 | @version = version 13 | end 14 | 15 | def controls 16 | self.class.get(path("controls")) do |response| 17 | # TODO: build SecurityControlsResponse 18 | end 19 | end 20 | 21 | def sanitizer_controls 22 | self.class.get(path("controls/sanitizers")) do |response| 23 | # TODO: build SecuritySanitizersResponse 24 | end 25 | end 26 | 27 | def sanitizer_control sanitizer_id 28 | self.class.get(path("controls/sanitizer/#{ sanitizer_id }")) do |response| 29 | # TODO: build SecuritySanitizerResponse 30 | end 31 | end 32 | 33 | def create_sanitizer_control control 34 | expect_class!(control, Contrast::UserApi::SecurityControlRequest) 35 | self.class.post(path("controls/sanitizers"), { body: control }) do |response| 36 | # TODO: build SecuritySanitizerResponse 37 | end 38 | end 39 | 40 | def update_sanitizer_control sanitizer_id, control 41 | expect_class!(control, Contrast::UserApi::SecurityControlRequest) 42 | self.class.put(path("controls/sanitizers/#{ sanitizer_id }")) do |response| 43 | # TODO: build BaseApiResponse 44 | end 45 | end 46 | 47 | def toggle_sanitizer_control sanitizer_id 48 | self.class.put(path("controls/sanitizers/#{ sanitizer_id }/enabled")) do |response| 49 | # TODO: build BaseApiResponse 50 | end 51 | end 52 | 53 | def delete_sanitizer_control sanitizer_id 54 | self.class.delete(path("controls/sanitizers/#{ sanitizer_id }")) do |response| 55 | # TODO: build BaseApiResponse 56 | end 57 | end 58 | 59 | def control_suggestions 60 | self.class.get(path("controls/suggestion")) do |response| 61 | # TODO: build SecurityControlSuggestionsResponse 62 | end 63 | end 64 | 65 | def create_sanitizer_control_suggestion possible_sanitizer_id, suggestion 66 | expect_class!(suggestion, Contrast::UserApi::SecurityControlSuggestionRequest) 67 | self.class.post(path("controls/suggestion/sanitizers/#{ possible_sanitizer_id }"), { body: suggestion }) do |response| 68 | # TODO: build SecurityControlResponse 69 | end 70 | end 71 | 72 | def undo_sanitizer_control_suggestion possible_sanitizer_id 73 | self.class.put(path("controls/suggestion/sanitizers/#{ possible_sanitizer_id }")) do |response| 74 | # TODO: build SecurityControlSuggestionResponse 75 | end 76 | end 77 | 78 | def delete_sanitizer_control_suggestion possible_sanitizer_id 79 | self.class.delete(path("controls/suggestion/sanitizers/#{ possible_sanitizer_id }")) do |response| 80 | # TODO: build BaseApiResponse 81 | end 82 | end 83 | 84 | def create_validator_control_suggestion possible_validator_id, suggestion 85 | expect_class!(suggestion, Contrast::UserApi::SecurityControlSuggestionRequest) 86 | self.class.post(path("controls/suggestion/validators/#{ possible_validator_id }"), { body: suggestion }) do |response| 87 | # TODO: build SecurityControlResponse 88 | end 89 | end 90 | 91 | def undo_validator_control_suggestion possible_validator_id 92 | self.class.put(path("controls/suggestion/validators/#{ possible_validator_id }")) do |response| 93 | # TODO: build SecurityControlSuggestionResponse 94 | end 95 | end 96 | 97 | def delete_validator_control_suggestion possible_validator_id 98 | self.class.delete(path("controls/suggestion/validators/#{ possible_validator_id }")) do |response| 99 | # TODO: build BaseApiResponse 100 | end 101 | end 102 | 103 | def validator_control validator_id 104 | self.class.get(path("controls/validator/#{ validator_id }")) do |response| 105 | # TODO: build SecurityValidatorResponse 106 | end 107 | end 108 | 109 | def validator_controls 110 | self.class.get(path("controls/validators")) do |response| 111 | # TODO: build SecurityValidatorsResponse 112 | end 113 | end 114 | 115 | def create_validator_control control 116 | expect_class!(control, Contrast::UserApi::SecurityControlRequest) 117 | self.class.post(path("controls/validators"), { body: control }) do |response| 118 | # TODO: build SecurityValidatorResponse 119 | end 120 | end 121 | 122 | def update_validator_control validator_id, control 123 | expect_class!(control, Contrast::UserApi::SecurityControlRequest) 124 | self.class.put(path("controls/validators/#{ validator_id }"), { body: control }) do |response| 125 | # TODO: build SecurityValidatorResponse 126 | end 127 | end 128 | 129 | def delete_validator_control validator_id 130 | self.class.delete(path("controls/validators/#{ validator_id }")) do |response| 131 | # TODO: build BaseApiResponse 132 | end 133 | end 134 | 135 | def toggle_validator_control validator_id 136 | self.class.put(path("controler/validators/#{ validator_id }/enabled")) do |response| 137 | # TODO: build BaseApiResponse 138 | end 139 | end 140 | end 141 | end 142 | end 143 | -------------------------------------------------------------------------------- /lib/contrast/user_api/tags_api.rb: -------------------------------------------------------------------------------- 1 | require 'httparty' 2 | 3 | module Contrast 4 | module UserApi 5 | class TagsApi 6 | include HTTParty 7 | include ApiSupport 8 | 9 | attr_accessor :version 10 | 11 | def initialize version = "ng" 12 | @version = version 13 | end 14 | 15 | def tags_by_application app_id 16 | self.class.get(path("tags/application/list/#{ app_id }")) do |response| 17 | # TODO: TagsResponse 18 | end 19 | end 20 | 21 | def delete_application_tags app_id 22 | self.class.delete(path("tags/application/#{ app_id }")) do |response| 23 | # TODO: TagsResponse 24 | end 25 | end 26 | 27 | def update_tag_applications resource 28 | expect_class!(resource, Contrast::UserApi::TagsServersResource) 29 | self.class.put(path("tags/applications"), { body: resource }) do |response| 30 | # TODO: BaseApiResponse 31 | end 32 | end 33 | 34 | def create_tag_applications_bulk resource 35 | expect_class!(resource, Contrast::UserApi::TagsApplicationsRequest) 36 | self.class.post(path("tags/applications/bulk"), { body: resource }) do |response| 37 | # TODO: TagsResponse 38 | end 39 | end 40 | 41 | def update_tag_applications_bulk resource 42 | expect_class!(resource, Contrast::UserApi::TagsApplicationsUpdateRequest) 43 | self.class.put(path("tags/applications/bulk"), { body: resource }) do |response| 44 | # TODO: BaseApiResponse 45 | end 46 | end 47 | 48 | def applications_tags_list 49 | self.class.get(path("tags/applications/list")) do |response| 50 | # TODO: TagsResponse 51 | end 52 | end 53 | 54 | def tag_libraries resource 55 | expect_class!(resource, Contrast::UserApi::TagsLibrariesResource) 56 | self.class.put(path("tags/libraries"), { body: resource }) do |response| 57 | # TODO: BaseApiResponse 58 | end 59 | end 60 | 61 | def create_tag_libraries_bulk resource 62 | expect_class!(resource, Contrast::UserApi::TagsLibrariesRequest) 63 | self.class.post(path("tags/libraries/bulk"), { body: resource }) do |response| 64 | # TODO: TagsResponse 65 | end 66 | end 67 | 68 | def update_tag_libraries_bulk resource 69 | expect_class!(resource, Contrast::UserApi::TagsTracesUpdateRequest) 70 | self.class.put(path("tags/libraries/bulk"), { body: resource }) do |response| 71 | # TODO: TagsResponse 72 | end 73 | end 74 | 75 | def tag_libraries_list 76 | self.class.get(path("tags/libraries/list")) do |response| 77 | 78 | end 79 | end 80 | 81 | def tags_libraries_for_application app_id 82 | self.class.get(path("tags/libraries/#{ app_id }/list")) do |response| 83 | 84 | end 85 | end 86 | 87 | def tags_libraries_by_hash hash 88 | params = query_params 89 | params[:hash] = hash 90 | self.class.get(path("tags/library/list/#{ hash }")) do |response| 91 | 92 | end 93 | end 94 | 95 | def delete_tags_libraries_by_hash hash 96 | self.class.delete(path("tags/library/list/#{ hash }")) do |response| 97 | 98 | end 99 | end 100 | 101 | def tags_libraries_by_server server_id 102 | self.class.get(path("tags/server/list/#{ server_id }")) do |response| 103 | 104 | end 105 | end 106 | 107 | def delete_tags_libraries_by_server server_id 108 | self.class.delete(path("tags/server/#{ server_id }")) do |response| 109 | 110 | end 111 | end 112 | 113 | def tag_servers resource 114 | expect_class!(resource, Contrast::UserApi::TagsServersResource) 115 | self.class.put(path("tags/servers"), { body: resource }) do |response| 116 | 117 | end 118 | end 119 | 120 | def create_tag_servers_bulk resource 121 | expect_class!(resource, Contrast::UserApi::TagsServersRequest) 122 | self.class.post(path("tags/servers/bulk"), { body: resource }) do |response| 123 | 124 | end 125 | end 126 | 127 | def update_tag_servers_bulk resource 128 | expect_class!(resource, Contrast::UserApi::TagsServersUpdateRequest) 129 | self.class.put(path("tags/servers/bulk"), { body: resource }) do |response| 130 | 131 | end 132 | end 133 | 134 | def tags_servers_list 135 | self.class.get(path("tags/servers/list")) do |response| 136 | 137 | end 138 | end 139 | 140 | def delete_tags_trace trace_uuid 141 | self.class.delete(path("tags/trace/#{ trace_uuid }")) do |response| 142 | 143 | end 144 | end 145 | 146 | def tags_traces 147 | self.class.get(path("tags/traces")) do |response| 148 | 149 | end 150 | end 151 | 152 | def update_tags_traces resource 153 | self.class.put(path("tags/traces"), { body: resource }) do |response| 154 | 155 | end 156 | end 157 | 158 | def unique_traces_by_application app_id 159 | self.class.get(path("tags/traces/application/#{ app_id }")) do |response| 160 | 161 | end 162 | end 163 | 164 | def create_tag_traces resource 165 | expect_class!(resource, Contrast::UserApi::TagsTracesRequest) 166 | self.class.post(path("tags/traces/bulk"), { body: resource }) do |response| 167 | 168 | end 169 | end 170 | 171 | def update_tag_traces resource 172 | expect_classs!(resource, Contrast::UserApi::TagsTracesUpdateRequest) 173 | self.class.put(path("tags/traces/bulk"), { body: resource }) do |response| 174 | 175 | end 176 | end 177 | 178 | def tags_traces_by_server server_id 179 | self.class.get(path("tags/traces/server/#{ server_id }")) do |response| 180 | 181 | end 182 | end 183 | 184 | def tags_by_trace trace_uuid 185 | self.class.get(path("tags/traces/trace/#{ trace_uuid }")) do |response| 186 | 187 | end 188 | end 189 | end 190 | end 191 | end 192 | -------------------------------------------------------------------------------- /spec/integration_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | require 'yaml' 3 | require 'pp' 4 | 5 | describe "This is an Integration Test", :integration do 6 | it "should parse a YAML file with settings" do 7 | hash = YAML.load(IO.read("spec/integration.yml")) 8 | expect(hash['teamserver']).to be_a Hash 9 | 10 | expect(hash['teamserver']['host']).to_not be_nil 11 | expect(hash['teamserver']['org_uuid']).to_not be_nil 12 | expect(hash['teamserver']['api_key']).to_not be_nil 13 | expect(hash['teamserver']['authorization']).to_not be_nil 14 | end 15 | 16 | let(:api) { Contrast::UserApi::API.new('spec/integration.yml') } 17 | 18 | # NOTE: the following specs don't really do anything yet. They hit a 19 | # teamserver instance defined in the config file and return a response 20 | it 'should be able to return applications from local server' do 21 | pp api.applications_allowed 22 | pp response = api.applications 23 | response.fetch('applications', []).each do |application| 24 | id = application['app_id'] 25 | pp api.application(id) 26 | pp api.application_license(id) 27 | pp api.application_component(id) 28 | pp api.application_coverage(id) 29 | pp api.application_coverage_weekly_stats(id) 30 | pp api.application_history(id) 31 | pp api.application_libraries(id) 32 | pp api.application_libraries_filter(id) 33 | pp api.application_libraries_stats(id) 34 | pp api.application_status_breakdown(id) 35 | pp api.application_trace_breakdown(id) 36 | pp api.application_servers(id) 37 | pp api.application_servers_breakdown(id) 38 | pp api.application_servers_count(id) 39 | pp api.application_newest_server(id) 40 | pp api.application_servers_properties(id) 41 | pp api.application_servers_settings(id) 42 | pp api.application_technologies(id) 43 | pp api.application_traces_filter(id) 44 | pp api.export_application_traces_csv(id) 45 | pp api.export_application_traces_csv_all(id) 46 | pp api.export_application_traces_xml(id) 47 | pp api.export_application_traces_xml_all(id) 48 | pp api.tags_by_application(id) 49 | pp api.tags_libraries_for_application(id) 50 | pp api.unique_traces_by_application(id) 51 | end 52 | pp api.applications_simplified 53 | pp api.applications_filters 54 | pp api.applications_filters_quick 55 | pp api.applications_name 56 | end 57 | 58 | it 'should be able to return agent info' do 59 | pp response = api.profiles 60 | pp api.versions 61 | end 62 | 63 | it 'should be able to return actvity messages from local server' do 64 | pp api.inactive_activity 65 | pp api.newest_activity 66 | pp api.recent_activity 67 | end 68 | 69 | it 'should be able to return library from local server' do 70 | pp api.libraries 71 | pp api.libraries_filter 72 | pp api.libraries_subfilter 73 | pp api.libraries_stats 74 | pp api.library_policy 75 | pp api.library_policy_libraries 76 | end 77 | 78 | it 'should be able to return events from local server' do 79 | pp api.events 80 | pp api.events_application 81 | pp api.events_server 82 | pp api.events_trace 83 | end 84 | 85 | it 'should be able to return history from local server' do 86 | pp api.history_scores 87 | end 88 | 89 | it 'should be able to return system messages from local server' do 90 | pp api.messages 91 | pp api.next_message 92 | end 93 | 94 | it 'should be able to return modules from local server' do 95 | pp api.modules 96 | pp api.modules(['scores']) 97 | end 98 | 99 | it 'should be able to return alerts from local server' do 100 | pp api.alerts 101 | end 102 | 103 | it 'should return organization and related info from local server' do 104 | pp api.organization 105 | pp api.organization_administrators 106 | pp api.organization_apikey 107 | pp api.organization_application_roles 108 | pp api.server_need_restart_on_change('Java') 109 | pp api.organization_application_stats 110 | end 111 | 112 | it 'should return profile info from local server' do 113 | pp api.roles 114 | pp api.profile 115 | pp api.password_policy 116 | pp api.user_roles 117 | pp api.report_preferences 118 | pp api.allowed_organizations 119 | end 120 | 121 | it 'should return security and validators from local server' do 122 | pp api.controls 123 | pp api.sanitizer_controls 124 | pp api.validator_controls 125 | pp api.control_suggestions 126 | end 127 | 128 | it 'should return score information' do 129 | pp api.scores 130 | pp api.scores_breakdown_category 131 | pp api.scores_breakdown_rule 132 | pp api.scores_breakdown_server 133 | pp api.scores_breakdown_severity 134 | pp api.scores_breakdown_status 135 | pp api.scores_breakdown_trace 136 | pp api.scores_breakdown_trace_rule 137 | pp api.scores_breakdown_trace_severity 138 | pp api.scores_breakdown_trace_status 139 | pp api.platform_score 140 | pp api.platform_score_with_defense 141 | pp api.organization_security_score 142 | pp api.organization_security_score_with_defense 143 | end 144 | 145 | it 'should return server information' do 146 | pp response = api.servers 147 | response.fetch('servers', []).each do |server| 148 | server_id = server['server_id'] 149 | pp api.server(server_id) 150 | pp api.server_activity(server_id) 151 | pp api.server_activity_unity(server_id) 152 | pp api.server_attack_status_breakdown(server_id) 153 | pp api.server_attack_type_breakdown(server_id) 154 | pp api.server_attack_severity_breakdown(server_id) 155 | pp api.server_attack_rule_breakdown(server_id) 156 | pp api.server_libraries_breakdown(server_id) 157 | pp api.server_properties(server_id) 158 | pp api.tags_libraries_by_server(server_id) 159 | pp api.tags_traces_by_server(server_id) 160 | end 161 | pp api.active_servers 162 | pp api.servers_filter 163 | pp api.servers_filters 164 | pp api.servers_modes 165 | end 166 | 167 | it 'should return tag information' do 168 | pp api.applications_tags_list 169 | pp api.tag_libraries_list 170 | pp api.tags_servers_list 171 | pp api.tags_traces 172 | end 173 | 174 | it 'should return trace information' do 175 | pp api.export_traces_csv 176 | pp api.export_all_traces_csv 177 | pp api.export_traces_xml 178 | pp api.export_all_traces_xml 179 | pp api.orgtraces_ids 180 | pp api.orgtraces_with_policy_violations 181 | pp api.orgtraces_quick_filters 182 | end 183 | end 184 | -------------------------------------------------------------------------------- /lib/contrast/user_api/api.rb: -------------------------------------------------------------------------------- 1 | module Contrast 2 | module UserApi 3 | class API 4 | extend Forwardable 5 | 6 | def_delegators :@application_api, 7 | :applications_name, 8 | :applications, 9 | :application, 10 | :applications_allowed, 11 | :applications_simplified, 12 | :applications_filters, 13 | :applications_filters_quick, 14 | :applications_subfilters, 15 | :update_application_importance, 16 | :application_license, 17 | :application_component, 18 | :application_coverage, 19 | :application_coverage_weekly_stats, 20 | :application_history, 21 | :application_history_by_interval, 22 | :application_history_by_interval_with_defense, 23 | :application_libraries, 24 | :application_libraries_filter, 25 | :application_libraries_filter_by_type, 26 | :application_libraries_stats, 27 | :application_status_breakdown, 28 | :application_servers, 29 | :application_servers_breakdown, 30 | :application_servers_count, 31 | :application_newest_server, 32 | :application_servers_properties, 33 | :application_servers_settings, 34 | :application_servers_settings_by_environment, 35 | :application_technologies, 36 | :application_trace_breakdown, 37 | :application_trace_rule_breakdown, 38 | :application_trace_severity_breakdown, 39 | :application_trace_status_breakdown, 40 | :application_traces_filter, 41 | :application_traces_subfilter, 42 | :application_traces_subfilter_keycode_search, 43 | :application_traces_subfilter_keycode_search_simplified, 44 | :application_traces_subfilter_keycode_severities, 45 | :application_traces_subfilter_keycode_status, 46 | :application_filter_trace, 47 | :delete_application_traces, 48 | :delete_application_trace, 49 | :export_application_traces_csv, 50 | :export_application_traces_csv_all, 51 | :export_application_traces_xml, 52 | :export_application_traces_xml_all, 53 | :application_trace_uuids, 54 | :application_traces_with_policy_violations, 55 | :application_traces_quick_filters, 56 | :application_trace_requirements, 57 | :application_trace_servers, 58 | :application_trace_url_instances, 59 | :export_application_traces_subfilter_keycode_csv, 60 | :export_application_traces_subfilter_keycode_xml, 61 | :application_trace_simplified, 62 | :application_trace_visibility 63 | 64 | def_delegators :@activity_api, 65 | :inactive_activity, 66 | :newest_activity, 67 | :recent_activity, 68 | :application_agent_activity 69 | 70 | def_delegators :@agent_api, 71 | :profiles, 72 | :profile, 73 | :create_profile, 74 | :update_profile, 75 | :versions, 76 | :agent 77 | 78 | def_delegators :@libraries_api, 79 | :libraries, 80 | :libraries_filter, 81 | :dotnet_libraries, 82 | :java_libraries, 83 | :libraries_subfilter, 84 | :libraries_stats, 85 | :libraries_filters_listing, 86 | :library_policy, 87 | :update_library_policy, 88 | :library_policy_libraries 89 | 90 | def_delegators :@events_api, 91 | :events, 92 | :events_application, 93 | :events_server, 94 | :events_trace 95 | 96 | def_delegators :@history_api, 97 | :history_scores, 98 | :history_scores_by_interval, 99 | :history_scores_with_defense_by_interval 100 | 101 | def_delegators :@messages_api, 102 | :messages, 103 | :next_message 104 | 105 | def_delegators :@modules_api, 106 | :modules, 107 | :application_modules 108 | 109 | def_delegators :@alerts_api, 110 | :alerts, 111 | :alert 112 | 113 | def_delegators :@organizations_api, 114 | :organization, 115 | :organization_administrators, 116 | :organization_apikey, 117 | :organization_application_roles, 118 | :server_need_restart_on_change, 119 | :organization_application_stats, 120 | :organization_library_stats, 121 | :organization_server_stats, 122 | :organization_trace_stats, 123 | :server_settings, 124 | :update_server_settings, 125 | :update_assess_settings, 126 | :update_bot_protection_settings, 127 | :update_defend_settings, 128 | :organization_search 129 | 130 | def_delegators :@profile_api, 131 | :roles, 132 | :profile, 133 | :update_profile, 134 | :update_expired_password, 135 | :update_password, 136 | :password_policy, 137 | :user_roles, 138 | :toggle_profile, 139 | :report_preferences, 140 | :update_default_organization, 141 | :allowed_organizations, 142 | :organization_by_uuid 143 | 144 | def_delegators :@security_api, 145 | :controls, 146 | :sanitizer_controls, 147 | :sanitizer_control, 148 | :create_sanitizer_control, 149 | :update_sanitizer_control, 150 | :toggle_sanitizer_control, 151 | :delete_sanitizer_control, 152 | :control_suggestions, 153 | :create_sanitizer_control_suggestion, 154 | :undo_sanitizer_control_suggestion, 155 | :delete_sanitizer_control_suggestion, 156 | :create_validator_control_suggestion, 157 | :undo_validator_control_suggestion, 158 | :delete_validator_control_suggestion, 159 | :validator_control, 160 | :validator_controls, 161 | :create_validator_control, 162 | :update_validator_control, 163 | :delete_validator_control, 164 | :toggle_validator_control 165 | 166 | def_delegators :@scores_api, 167 | :scores, 168 | :scores_breakdown_category, 169 | :scores_breakdown_rule, 170 | :scores_breakdown_server, 171 | :scores_breakdown_severity, 172 | :scores_breakdown_status, 173 | :scores_breakdown_trace, 174 | :scores_breakdown_trace_rule, 175 | :scores_breakdown_trace_severity, 176 | :scores_breakdown_trace_status, 177 | :platform_score, 178 | :platform_score_with_defense, 179 | :organization_security_score, 180 | :organization_security_score_with_defense 181 | 182 | def_delegators :@servers_api, 183 | :servers, 184 | :active_servers, 185 | :servers_filter, 186 | :servers_filters, 187 | :servers_filters_quick, 188 | :servers_filters_by_type, 189 | :servers_modes, 190 | :server, 191 | :server_activity, 192 | :server_activity_unity, 193 | :server_apptraces, 194 | :server_attack_status_breakdown, 195 | :server_attack_type_breakdown, 196 | :server_attack_rule_breakdown, 197 | :server_attack_severity_breakdown, 198 | :server_attack_status_breakdown, 199 | :server_libraries_breakdown, 200 | :update_server_name, 201 | :server_properties, 202 | :server_urls, 203 | :server_attack_urls, 204 | :server_vulnerability_urls, 205 | :server_libraries, 206 | :server_libraries_by_filter, 207 | :server_libraries_by_subfilter, 208 | :server_library_stats 209 | 210 | def_delegators :@tags_api, 211 | :tags_by_application, 212 | :delete_application_tags, 213 | :update_tag_applications, 214 | :create_tag_applications, 215 | :create_tag_applications_bulk, 216 | :update_tag_applications_bulk, 217 | :applications_tags_list, 218 | :tag_libraries, 219 | :create_tag_libraries_bulk, 220 | :update_tag_libraries_bulk, 221 | :tag_libraries_list, 222 | :tags_libraries_for_application, 223 | :tags_libraries_by_hash, 224 | :delete_tags_libraries_by_hash, 225 | :tags_libraries_by_server, 226 | :delete_tags_libraries_by_server, 227 | :tag_servers, 228 | :create_tag_servers_bulk, 229 | :update_tag_servers_bulk, 230 | :tags_servers_list, 231 | :delete_tags_trace, 232 | :tags_traces, 233 | :update_tags_traces, 234 | :unique_traces_by_application, 235 | :create_tag_traces, 236 | :update_tag_traces, 237 | :tags_traces_by_server, 238 | :tags_by_trace 239 | 240 | def_delegators :@traces_api, 241 | :delete_trace_set, 242 | :export_traces_csv, 243 | :export_all_traces_csv, 244 | :export_traces_xml, 245 | :export_all_traces_xml, 246 | :orgtraces_ids, 247 | :orgtraces_with_policy_violations, 248 | :orgtraces_quick_filters, 249 | :delete_orgtrace, 250 | :export_traces_filter_and_keycode_csv, 251 | :export_traces_filter_and_keycode_xml 252 | 253 | 254 | 255 | attr_reader :host, 256 | :org_uuid, 257 | :api_key, 258 | :authorization_base64 259 | 260 | def initialize config = nil 261 | options = load_config(config) 262 | raise ArgumentError.new("Unable to load config options from #{ config }") unless options.is_a?(Hash) 263 | raise ArgumentError.new("Expected a configuration section named 'teamserver'") unless options['teamserver'].is_a?(Hash) 264 | 265 | teamserver = options['teamserver'] 266 | @host = teamserver['host'] # 'http://localhost:19080/Contrast/' 267 | @org_uuid = teamserver['org_uuid'] # '9c1dd905-e8d5-447b-b1be-00cbda0d0e67' 268 | @api_key = teamserver['api_key'] # 'demo' 269 | @authorization_base64 = teamserver['authorization'] # 'Y29udHJhc3RfYWRtaW46ZGVtbw==' 270 | 271 | @activity_api = with_defaults(ActivityApi) 272 | @application_api = with_defaults(ApplicationApi) 273 | @agent_api = with_defaults(AgentApi) 274 | @libraries_api = with_defaults(LibrariesApi) 275 | @events_api = with_defaults(EventsApi) 276 | @history_api = with_defaults(HistoryApi) 277 | @messages_api = with_defaults(MessagesApi) 278 | @modules_api = with_defaults(ModulesApi) 279 | @alerts_api = with_defaults(AlertsApi) 280 | @organizations_api = with_defaults(OrganizationsApi) 281 | @profile_api = with_defaults(ProfileApi) 282 | @security_api = with_defaults(SecurityApi) 283 | @scores_api = with_defaults(ScoresApi) 284 | @servers_api = with_defaults(ServersApi) 285 | @traces_api = with_defaults(TracesApi) 286 | @tags_api = with_defaults(TagsApi) 287 | end 288 | 289 | def load_config config 290 | if config.is_a?(Hash) 291 | config 292 | else 293 | [ (config ? config.to_s : nil ), 294 | ENV["CONTRAST_SECURITY_CONFIG"], 295 | 'contrast_security.yml', 296 | 'config/contrast_security.yml', 297 | '/etc/contrast_security.yml' 298 | ].each do |path| 299 | if path && File.readable?(path) 300 | break YAML.load(IO.read(path)) 301 | else 302 | nil 303 | end 304 | end 305 | end 306 | end 307 | 308 | def with_defaults clazz 309 | inst = clazz.new('api/ng') 310 | inst.org_uuid = org_uuid 311 | inst.class.base_uri(base_uri) 312 | inst.class.headers(headers) 313 | inst 314 | end 315 | 316 | def base_uri 317 | host 318 | end 319 | 320 | def headers 321 | { 322 | "API-Key" => api_key, 323 | "Authorization" => authorization_base64 324 | } 325 | end 326 | end 327 | end 328 | end 329 | -------------------------------------------------------------------------------- /lib/contrast/user_api/servers_api.rb: -------------------------------------------------------------------------------- 1 | require 'httparty' 2 | 3 | module Contrast 4 | module UserApi 5 | class ServersApi 6 | include HTTParty 7 | include ApiSupport 8 | 9 | attr_accessor :version 10 | 11 | def initialize version = "ng" 12 | @version = version 13 | end 14 | 15 | def servers q = nil, expand = nil, archived = nil 16 | params = query_params(expand, archived, nil, nil) 17 | params[:q] = q unless q.nil? 18 | self.class.get(path("servers"), { query: params }) do |response| 19 | # TODO 20 | end 21 | end 22 | 23 | def active_servers 24 | self.class.get(path("servers/active")) do |response| 25 | # TODO: 26 | end 27 | end 28 | 29 | def servers_filter log_levels = nil, apps = nil, tags = nil, agent_versions = nil, environments = nil, q = nil, quick_filter = nil, expand = nil, archived = nil, limit = nil, offset = nil, sort = nil 30 | params = query_params(expand, archived, nil, limit) 31 | params[:offset] = offset.to_i unless offset.nil? 32 | params[:sort] = sort unless sort.nil? 33 | params[:logLevels] = Array(log_levels) unless log_levels.nil? 34 | params[:applicationIds] = Array(apps) unless apps.nil? 35 | params[:tags] = Array(tags) unless tags.nil? 36 | params[:agentVersions] = Array(agent_versions) unless agent_versions.nil? 37 | params[:environments] = Array(environments) unless environments.nil? 38 | params[:q] = q unless q.nil? 39 | params[:quickFilter] = quick_filter unless quick_filter.nil? 40 | self.class.get(path("servers/filter"), { query: params }) do |response| 41 | # TODO: 42 | end 43 | end 44 | 45 | def servers_filters 46 | self.class.get(path("servers/filters/listing")) do |response| 47 | # TODO: ServerFilterCatalogResponse 48 | end 49 | end 50 | 51 | def servers_filters_quick log_levels = nil, apps = nil, tags = nil, agent_versions = nil, environments = nil, q = nil, archived = nil 52 | params = query_params(nil, archived, nil, nil) 53 | params[:logLevels] = Array(log_level) unless log_levels.nil? 54 | params[:applicationIds] = Array(apps) unless apps.nil? 55 | params[:tags] = Array(tags) unless tags.nil? 56 | params[:agentVersions] = Array(agent_version) unless agent_versions.nil? 57 | params[:environments] = Array(environments) unless environments.nil? 58 | params[:q] = q unless q.nil? 59 | self.class.get(path("servers/filters/quick"), { query: params }) do |response| 60 | # TODO: QuickFilterResponse 61 | end 62 | end 63 | 64 | def servers_filters_by_type filter_type 65 | self.class.get(path("servers/filters/#{ filter_type }/listing")) do |response| 66 | # TODO: ServerFilterCatalogDetailsResponse 67 | end 68 | end 69 | 70 | def servers_modes 71 | self.class.get(path("servers/modes")) do |response| 72 | # TODO: build ServersAssessDefendResponse 73 | end 74 | end 75 | 76 | def server server_id, expand = nil 77 | params = query_params(expand, nil, nil, nil) 78 | self.class.get(server_path(server_id), { query: params }) do |response| 79 | # TODO: build ServerResponse 80 | end 81 | end 82 | 83 | def server_activity server_id, form = nil 84 | params = query_params(nil, nil, nil, nil) 85 | params[:form] = form unless form.nil? 86 | self.class.get(server_path(server_id, "activity"), { query: params }) do |response| 87 | # TODO: build ServerActivityResponse 88 | end 89 | end 90 | 91 | def server_activity_unity server_id, interval = nil 92 | params = query_params(nil, nil, nil, nil) 93 | params[:interval] = interval unless interval.nil? 94 | self.class.get(server_path(server_id, "activity/unity"), { query: params }) do |response| 95 | # TODO: build ServerActivityResponse 96 | end 97 | end 98 | 99 | def server_apptraces server_id, orphans 100 | params = query_params(nil, nil, nil, nil) 101 | params[:orphans] = orphans unless orphans.nil? 102 | self.class.get(server_path(server_id, "apptraces"), { query: params }) do |response| 103 | # TODO: build ServerOrphansResponse 104 | end 105 | end 106 | 107 | def server_attack_status_breakdown server_id, merged = nil 108 | params = query_params(nil, nil, merged, nil) 109 | self.class.get(server_path(server_id, "breakdown/attack/status"), { query: params }) do |response| 110 | # TODO: build AttackStatusBreakdownResponse 111 | end 112 | end 113 | 114 | def server_attack_type_breakdown server_id, merged = nil 115 | params = query_params(nil, nil, merged, nil) 116 | self.class.get(server_path(server_id, "breakdown/attack/type"), { query: params }) do |response| 117 | # TODO: build AttackTypeBreakdownResponse 118 | end 119 | end 120 | 121 | def server_attack_rule_breakdown server_id, merged = nil 122 | params = query_params(nil, nil, merged, nil) 123 | self.class.get(server_path(server_id, "breakdown/attack/rule"), { query: params }) do |response| 124 | # TODO: build AttackRuleBreakdownResponse 125 | end 126 | end 127 | 128 | def server_attack_severity_breakdown server_id, merged = nil 129 | params = query_params(nil, nil, merged, nil) 130 | self.class.get(server_path(server_id, "breakdown/attack/severity"), { query: params }) do |response| 131 | # TODO: build AttackSeverityBreakdownResponse 132 | end 133 | end 134 | 135 | def server_libraries_breakdown server_id, archived = nil, merged = nil 136 | params = query_params(nil, archived, merged, nil) 137 | self.class.get(server_path(server_id, "libraries/breakdown"), { query: params }) do |response| 138 | # TODO: build ServerLibraryBreakdownResponse 139 | end 140 | end 141 | 142 | def update_server_name server_id, request 143 | expect_class!(request, Contrast::UserApi::ServerNameRequest) 144 | self.class.put(server_path(server_id, "name"), { query: params }) do |response| 145 | # TODO: build BaseApiResponse 146 | end 147 | end 148 | 149 | def server_properties server_id 150 | self.class.get(server_path(server_id, "properties")) do |response| 151 | # TODO: build ServerPropertiesResponse 152 | end 153 | end 154 | 155 | def server_urls server_id, interval = nil 156 | params = query_params(nil, nil, nil, nil) 157 | params[:interval] = interval unless interval.nil? 158 | self.class.get(server_path(server_id, "url"), { query: params }) do |response| 159 | # TODO: build URLServerBreakdownResponse 160 | end 161 | end 162 | 163 | def server_attack_urls server_id, interval = nil 164 | params = query_params(nil, nil, nil, nil) 165 | params[:interval] = interval unless interval.nil? 166 | self.class.get(server_path(server_id, "url/attack"), { query: params }) do |response| 167 | # TODO: build URLServerBreakdownResponse 168 | end 169 | end 170 | 171 | def server_vulnerability_urls server_id, interval = nil 172 | params = query_params(nil, nil, nil, nil) 173 | params[:interval] = interval unless interval.nil? 174 | self.class.get(server_path(server_id, "url/vuln"), { query: params }) do |response| 175 | # TODO: build URLServerBreakdownResponse 176 | end 177 | end 178 | 179 | def server_libraries server_id, quick_filter = nil, expand = nil 180 | params = query_params(expand, nil, nil, nil) 181 | params[:quickFilter] = quick_filter unless quick_filter.nil? 182 | self.class.get(server_path(server_id, "libraries"), { query: params}) do |response| 183 | # TODO: build ServersResponse 184 | end 185 | end 186 | 187 | def server_libraries_by_filter server_id, apps = nil, tags = nil, q = nil, quick_filter = nil, expand = nil 188 | params = query_params(expand, nil, nil, nil) 189 | params[:apps] = Array(apps) unless apps.nil? 190 | params[:tags] = Array(tags) unless tags.nil? 191 | params[:q] = q unless q.nil? 192 | params[:quickFilter] = quick_filter unless quick_filter.nil? 193 | self.class.get(server_path(server_id, "libraries/filter"), { query: params }) do |response| 194 | # TODO: build ServersResponse 195 | end 196 | end 197 | 198 | def server_libraries_by_subfilter server_id, filter_type 199 | self.class.get(server_path(server_id, "libraries/filters/#{ filter_type }")) do |response| 200 | # TODO: build LibraryFilterCatalogDetailsResponse 201 | end 202 | end 203 | 204 | def server_library_stats server_id, merged = nil 205 | params = query_params(nil, nil, merged, nil) 206 | self.class.get(server_path(server_id, "libraries/stats"), { query: params }) do |response| 207 | # TODO: build LibrariesStatsResponse 208 | end 209 | end 210 | 211 | def delete_server_traces server_id 212 | self.class.delete(path("servertraces/#{ server_id }")) do |response| 213 | # TODO: build BackgroundJobResponse 214 | end 215 | end 216 | 217 | def export_server_traces_csv server_id, request = nil 218 | params = query_params(nil, nil, nil, nil) 219 | if request 220 | expect_class!(request, Contrast::UserApi::TraceBaseRequest) 221 | params[:request] = request 222 | end 223 | 224 | self.class.post(path("servertraces/#{ server_id }/export/csv"), { query: params }) do |response| 225 | # CSV 226 | end 227 | end 228 | 229 | def export_server_traces_csv_all server_id, request = nil, sort = nil 230 | params = query_params(nil, nil, nil, nil) 231 | params[:sort] = sort unless sort.nil? 232 | 233 | if request 234 | expect_class!(request, Contrast::UserApi::TraceBaseRequest) 235 | params[:request] = request 236 | end 237 | 238 | self.class.post(path("servertraces/#{ server_id }/export/csv/all"), { query: params }) do |response| 239 | # CSV 240 | end 241 | end 242 | 243 | def export_server_traces_xml server_id, request = nil 244 | params = query_params(nil, nil, nil, nil) 245 | if request 246 | expect_class!(request, Contrast::UserApi::TraceBaseRequest) 247 | params[:request] = request 248 | end 249 | 250 | self.class.post(path("servertraces/#{ server_id }/export/xml"), { query: params }) do |response| 251 | # XML 252 | end 253 | end 254 | 255 | def export_server_traces_xml_all server_id, request = nil, sort = nil 256 | params = query_params(nil, nil, nil, nil) 257 | params[:sort] = sort unless sort.nil? 258 | 259 | if request 260 | expect_class!(request, Contrast::UserApi::TraceBaseRequest) 261 | params[:request] = request 262 | end 263 | 264 | self.class.post(path("servertraces/#{ server_id }/export/xml/all"), { query: params }) do |response| 265 | # XML 266 | end 267 | end 268 | 269 | def server_trace_uuids server_id, request = nil, sort = nil 270 | params = query_params(nil, nil, nil, nil) 271 | params[:sort] = sort unless sort.nil? 272 | 273 | if request 274 | expect_class!(request, Contrast::UserApi::TraceBaseRequest) 275 | params[:request] = request 276 | end 277 | 278 | self.class.get(path("servertraces/#{ server_id }/ids"), { query: params }) do |response| 279 | # TODO: build TraceUUIDsResponse 280 | end 281 | end 282 | 283 | def server_traces_with_policy_violations server_id 284 | self.class.get(path("servertraces/#{ server_id }/policy/violations")) do |response| 285 | # TODO: build TraceRemediationPolicyViolationsResponse 286 | end 287 | end 288 | 289 | def server_traces_quick_filters server_id, request = nil 290 | params = query_params(nil, nil, nil, nil) 291 | 292 | if request 293 | expect_class!(request, Contrast::UserApi::TraceBaseRequest) 294 | params[:request] = request 295 | end 296 | 297 | self.class.get(path("servertraces/#{ server_id }/quick")) do |response| 298 | # TODO: build QuickFilterResponse 299 | end 300 | end 301 | 302 | def delete_server_trace server_id, trace_uuid 303 | self.class.delete(path("servertraces/#{ server_id }/trace/#{ trace_uuid }")) do |response| 304 | # TODO: build BaseApiResponse 305 | end 306 | end 307 | 308 | def server_trace_simplified server_id, trace_uuid, expand = nil 309 | params = query_params(expand, nil, nil, nil) 310 | self.class.get(path("servertraces/#{ server_id }/#{ trace_uuid }/short"), { query: params }) do |response| 311 | # TODO: build TraceShortResponse 312 | end 313 | end 314 | 315 | def server_trace_visibility server_id, trace_uuid 316 | self.class.get(path("servertraces/#{ server_id }/#{ trace_uuid }/visibility")) do |response| 317 | # TODO: build TraceVisibilityResponse 318 | end 319 | end 320 | 321 | def server_traces server_id, request = nil, expand = nil, limit = nil, offset = nil, sort = nil 322 | params = query_params(expand, nil, nil, limit) 323 | params[:offset] = offset.to_i unless offset.nil? 324 | params[:sort] = sort unless sort.nil 325 | 326 | if request 327 | expect_class!(request, Contrast::UserApi::TraceBaseRequest) 328 | params[:request] = request 329 | end 330 | 331 | self.class.get(path("servertraces/#{ server_id }/filter"), { query: params }) do |response| 332 | # TODO: build TraceFilterResponse 333 | end 334 | end 335 | 336 | def server_trace_filter_listing server_id, filter_type 337 | self.class.get(path("servertraces/#{ server_id }/filter/#{ filter_type }/listing")) do |response| 338 | # TODO: build TraceFilterCatalogDetailsResponse 339 | end 340 | end 341 | 342 | def server_trace server_id, trace_uuid, expand = nil 343 | params = query_params(expand, nil, nil, nil) 344 | self.class.get(path("servertraces/#{ server_id }/filter/#{ trace_uuid }"), { query: params }) do |response| 345 | # TODO 346 | end 347 | end 348 | 349 | 350 | end 351 | end 352 | end 353 | -------------------------------------------------------------------------------- /lib/contrast/user_api/application_api.rb: -------------------------------------------------------------------------------- 1 | require 'httparty' 2 | 3 | module Contrast 4 | module UserApi 5 | class ApplicationApi 6 | include HTTParty 7 | include ApiSupport 8 | 9 | attr_reader :version 10 | 11 | def initialize version = "ng" 12 | @version = version 13 | end 14 | 15 | def applications_allowed 16 | self.class.get(path("applications/allowed")) do |response| 17 | # TODO: build ApplicationsAllowedResponse 18 | end 19 | end 20 | 21 | # FIXME: Documentation refers to filters as an instance of ApplicationsFilterRequest but it 22 | # doesn't seem to be defined 23 | def applications filters = nil, expand = nil, merged = nil, limit = nil, offset = nil, sort = nil 24 | params = query_params(expand, nil, merged, limit) 25 | params[:offset] = offset.to_i unless offset.nil? 26 | params[:sort] = sort unless sort.nil? 27 | params[:filters] = filters unless filters.nil? 28 | self.class.get(path("applications/filter"), { query: params }) do |response| 29 | # TODO: build ApplicationsFilterResponse 30 | end 31 | end 32 | 33 | def applications_simplified filters = nil, sort = nil 34 | params = query_params(nil, nil, nil, nil) 35 | params[:sort] = sort unless sort.nil? 36 | params[:filters] = filters unless filters.nil? 37 | self.class.get(path("applications/filter/short"), { query: params }) do |response| 38 | # TODO: build ApplicationShortFilterResponse 39 | end 40 | end 41 | 42 | def applications_filters 43 | self.class.get(path("applications/filters/listing")) do |response| 44 | # TODO: build ApplicationFilterCatalogResponse 45 | end 46 | end 47 | 48 | def applications_filters_quick filters = nil 49 | params = query_params(nil, nil, nil, nil) 50 | params[:filters] = filters unless filters.nil? 51 | self.class.get(path("applications/filters/quick")) do |response| 52 | # TODO: build QuickFilterResponse 53 | end 54 | end 55 | 56 | def applications_subfilters filter_type, filters = nil, archived = nil 57 | params = query_params(nil, archived, nil, nil) 58 | params[:filters] = filters unless filters.nil? 59 | self.class.get(path("applications/filters/#{ filter_type }/listing"), { query: params }) do |response| 60 | # TODO: build ApplicationFilterCatalogDetailsResponse 61 | end 62 | end 63 | 64 | def applications_name filters = nil, trial = nil, merged = nil 65 | params = query_params(nil, nil, merged, nil) 66 | params[:trial] = trial unless trial.nil? 67 | params[:filters] = filters unless filters.nil? 68 | self.class.get(path("applications/name"), { query: params }) do |response| 69 | # TODO: build ApplicationsNameResponse 70 | end 71 | end 72 | 73 | def application app_id, expand = nil, merged = nil 74 | params = query_params(expand, nil, merged, nil) 75 | self.class.get(application_path(app_id), { query: params }) do |response| 76 | # TODO: build ApplicationResponse 77 | end 78 | end 79 | 80 | def update_application_importance app_id, importance 81 | expect_class!(importance, Contrast::UserApi::ApplicationImportanceRequest) 82 | self.class.put(application_path(app_id, "importance"), { body: importance.to_hash }) do |response| 83 | # TODO: build BaseApiResponse 84 | end 85 | end 86 | 87 | def application_license app_id 88 | self.class.get(application_path(app_id, "license")) do |response| 89 | # TODO: build ApplicationLicenseResponse 90 | end 91 | end 92 | 93 | def application_component app_id 94 | self.class.get(application_path(app_id, "components")) do |response| 95 | # TODO: build ApplicationComponentsResponse object 96 | end 97 | end 98 | 99 | def application_coverage app_id, merged = nil, limit = nil 100 | params = query_params(nil, nil, merged, limit) 101 | self.class.get(application_path(app_id, "coverage"), { query: params }) do |response| 102 | # TODO: build ApplicationCoverageResponse object 103 | end 104 | end 105 | 106 | def application_coverage_weekly_stats app_id, merged = nil 107 | params = query_params(nil, nil, merged, nil) 108 | self.class.get(application_path(app_id, "coverage/stats/week"), { query: params }) do |response| 109 | # TODO: build ApplicationCoverageStatsResponse object 110 | end 111 | end 112 | 113 | def application_history app_id, merged = nil 114 | params = query_params(nil, nil, merged, nil) 115 | self.class.get(application_path(app_id, "history"), { query: params }) do |response| 116 | # TODO: build HistoryScoresResponse object 117 | end 118 | end 119 | 120 | def application_history_by_interval app_id, environment, interval, merged = nil 121 | params = query_params(nil, nil, merged, nil) 122 | params[:environment] = environment 123 | params[:interval] = interval 124 | self.class.get(application_path(app_id, "history/interval"), { query: params }) do |response| 125 | # TODO: build HistoryScoresResponse object 126 | end 127 | end 128 | 129 | def application_history_by_interval_with_defense app_id, environment, interval, merged = nil 130 | params = query_params(nil, nil, merged, nil) 131 | params[:environment] = environment 132 | params[:interval] = interval 133 | self.class.get(application_path(app_id, "history/interval/defense"), { query: params }) do |response| 134 | # TODO: build HistoryScoresResponse object 135 | end 136 | end 137 | 138 | def application_libraries app_id, expand = nil, load_cve = nil, quick_filter = nil 139 | params = query_params(expand, nil, nil, nil) 140 | params[:loadCVE] = load_cve unless load_cve.nil? 141 | params[:quickFilter] = quick_filter unless quick_filter.nil? 142 | self.class.get(application_path(app_id, "libraries"), { query: params }) do |response| 143 | # TODO: build LibrariesResponse 144 | end 145 | end 146 | 147 | def application_libraries_filter app_id, expand = nil, servers = nil, tags = nil, q = nil, quick_filter = nil 148 | params = query_params(expand, nil, nil, nil) 149 | params[:servers] = Array(servers) unless servers.nil? 150 | params[:tags] = Array(tags) unless tags.nil? 151 | params[:q] = q unless q.nil? 152 | params[:quickFilter] = quick_filter unless quick_filter.nil? 153 | self.class.get(application_path(app_id, "libraries/filter"), { query: params }) do |response| 154 | # TODO: build LibrariesResponse 155 | end 156 | end 157 | 158 | def application_libraries_filter_by_type app_id, filter_type 159 | self.class.get(application_path(app_id, "libraries/filter/#{ filter_type }")) do |response| 160 | # TODO: build AppLibraryFilterCatalogDetailsResponse 161 | end 162 | end 163 | 164 | def application_libraries_stats app_id, merged = nil 165 | params = query_params(nil, nil, merged, nil) 166 | self.class.get(application_path(app_id, "libraries/stats"), { query: params }) do |response| 167 | # TODO: build LibrariesStatsResponse 168 | end 169 | end 170 | 171 | def application_status_breakdown app_id, merged = nil 172 | params = query_params(nil, nil, merged, nil) 173 | self.class.get(application_path(app_id, "breakdown/status"), { query: params }) do |response| 174 | # TODO: build TraceStatusBreakdownResponse 175 | end 176 | end 177 | 178 | def application_trace_breakdown app_id, merged = nil 179 | params = query_params(nil, nil, merged, nil) 180 | self.class.get(application_path(app_id, "breakdown/trace"), { query: params }) do |response| 181 | # TODO: build TraceBreakdownResponse 182 | end 183 | end 184 | 185 | def application_trace_rule_breakdown app_id, environment 186 | params = query_params(nil, nil, nil, nil) 187 | params[:environment] = environment 188 | self.class.get(application_path(app_id, "breakdown/trace/rule"), { query: params }) do |response| 189 | # TODO: build TraceRuleTypeBreakdownResponse 190 | end 191 | end 192 | 193 | def application_trace_severity_breakdown app_id, environment 194 | params = query_params(nil, nil, nil, nil) 195 | params[:environment] = environment 196 | self.class.get(application_path(app_id, "breakdown/trace/severity"), { query: params }) do |response| 197 | # TODO: build TraceSeverityBreakdownResponse 198 | end 199 | end 200 | 201 | def application_trace_status_breakdown app_id, environment 202 | params = query_params(nil, nil, nil, nil) 203 | params[:environment] = environment 204 | self.class.get(application_path(app_id, "breakdown/trace/status"), { query: params }) do |response| 205 | # TODO: TraceEnvStatusBreakdownResponse 206 | end 207 | end 208 | 209 | def application_servers app_id, expand = nil, merged = nil, licensed = nil 210 | params = query_params(expand, nil, merged, nil) 211 | params[:onlyLicensed] = licensed unless licensed.nil? 212 | self.class.get(application_path(app_id, "servers"), { query: params }) do |response| 213 | # TODO: ServersResponse 214 | end 215 | end 216 | 217 | def application_servers_breakdown app_id 218 | self.class.get(application_path(app_id, "servers/breakdown")) do |response| 219 | # TODO: ApplicationServersBreakdownResponse 220 | end 221 | end 222 | 223 | def application_servers_count app_id, merged = nil 224 | params = query_params(nil, nil, merged, nil) 225 | self.class.get(application_path(app_id, "servers/count"), { query: params }) do |response| 226 | # TODO: ApplicationServersResponse 227 | end 228 | end 229 | 230 | def application_newest_server app_id, expand = nil, merged = nil 231 | params = query_params(expand, nil, merged, nil) 232 | self.class.get(application_path(app_id, "servers/newest"), { query: params }) do |response| 233 | # TODO: ServerResponse 234 | end 235 | end 236 | 237 | def application_servers_properties app_id, merged = nil 238 | params = query_params(nil, nil, merged, nil) 239 | self.class.get(application_path(app_id, "servers/properties"), { query: params }) do |response| 240 | # TODO: ServersPropertiesResponse 241 | end 242 | end 243 | 244 | def application_servers_settings app_id, merged = nil 245 | params = query_params(nil, nil, merged, nil) 246 | self.class.get(application_path(app_id, "servers/settings"), { query: params }) do |response| 247 | # TODO: build ApplicationServerSettingsResponse 248 | end 249 | end 250 | 251 | def application_servers_settings_by_environment app_id, environment, merged = nil 252 | params = query_params(nil, nil, merged, nil) 253 | self.class.get(application_path(app_id, "servers/settings/environment"), { query: params }) do |response| 254 | # TODO: build ApplicationServerSettingsEnvironmentResponse 255 | end 256 | end 257 | 258 | def application_technologies app_id 259 | self.class.get(application_path(app_id, "techs")) do |response| 260 | # TODO: build ApplicationTechnologiesResponse 261 | end 262 | end 263 | 264 | def application_traces_filter app_id, request = nil, expand = nil, limit = nil, offset = nil, sort = nil 265 | params = query_params(expand, nil, nil, limit) 266 | params[:request] = request unless request.nil? 267 | params[:offset] = offset.to_i unless offset.nil? 268 | params[:sort] = sort unless sort.nil? 269 | self.class.get(traces_path(app_id, "filter"), { query: params }) do |response| 270 | # TODO: build TraceFilterResponse 271 | end 272 | end 273 | 274 | def application_traces_subfilter app_id, filter_type 275 | self.class.get(traces_path(app_id, "filter/#{ filter_type }/listing")) do |response| 276 | # TODO: build TraceFilterCatalogDetailsResponse 277 | end 278 | end 279 | 280 | def application_traces_subfilter_keycode_search app_id, filter_type, keycode, form = nil, expand = nil, limit = nil, offset = nil, sort = nil 281 | params = query_params(expand, nil, nil, limit) 282 | params[:offset] = offset.to_i unless offset.nil? 283 | params[:sort] = sort unless sort.nil? 284 | self.class.get(trace_path(app_id, "filter/#{ filter_type }/#{ keycode }/search")) do |response| 285 | # TODO: build TraceFilterResponse 286 | end 287 | end 288 | 289 | def application_traces_subfilter_keycode_search_simplified app_id, filter_type, keycode, form = nil, expand = nil, sort = nil 290 | params = query_params(expand, nil, nil, nil) 291 | params[:form] = form unless form.nil? 292 | params[:sort] = sort unless sort.nil? 293 | self.class.get(trace_path(app_id, "filter/#{ filter_type }/#{ keycode }/short"), { query: params }) do |response| 294 | # TODO: TracesShortResponse 295 | end 296 | end 297 | 298 | def application_traces_subfilter_keycode_severities app_id, filter_type, keycode, form = nil 299 | params = query_params(nil, nil, nil, nil) 300 | params[:form] = form unless form.nil? 301 | self.class.get(trace_path(app_id, "filter/#{ filter_type }/#{ keycode }/severities"), { query: params }) do |response| 302 | # TODO: build TraceFilterCatalogDetailsResponse 303 | end 304 | end 305 | 306 | def application_traces_subfilter_keycode_status app_id, filter_type, keycode, form = nil 307 | params = query_params(nil, nil, nil, nil) 308 | params[:form] = form unless form.nil? 309 | self.class.get(trace_path(app_id, "filter/#{ filter_type }/#{ keycode }/status"), { query: params }) do |response| 310 | # TODO: build TraceFilterCatalogDetailsResponse 311 | end 312 | end 313 | 314 | def application_filter_trace app_id, trace_uuid, expand = nil 315 | params = query_params(expand, nil, nil, nil) 316 | self.class.get(trace_path(app_id, "filter/#{ trace_uuid }"), { query: params }) do |response| 317 | # TODO: build TraceResponse 318 | end 319 | end 320 | 321 | def delete_application_traces app_id 322 | self.class.delete(trace_path(app_id)) do |response| 323 | # TODO: build BackgroundJobResponse 324 | end 325 | end 326 | 327 | def export_application_traces_csv app_id, request = nil 328 | params = query_params(nil, nil, nil, nil) 329 | 330 | # TODO: verify that this expects a request object and not just an array of strings 331 | if request 332 | expect_class!(request, Contrast::UserApi::TraceBaseRequest) 333 | params[:request] = request 334 | end 335 | 336 | self.class.post(traces_path(app_id, "export/csv"), { query: params }) do |response| 337 | # TODO: handle CSV response 338 | end 339 | end 340 | 341 | def export_application_traces_csv_all app_id, request = nil, sort = nil 342 | params = query_params(nil, nil, nil, nil) 343 | params[:sort] = sort unless sort.nil? 344 | 345 | # TODO: verify that this expects a request object and not just an array of strings 346 | if request 347 | expect_class!(request, Contrast::UserApi::TraceBaseRequest) 348 | params[:request] = request 349 | end 350 | 351 | self.class.post(traces_path(app_id, "export/csv/all"), { query: params }) do |response| 352 | # TODO: handle CSV response 353 | end 354 | end 355 | 356 | def export_application_traces_xml app_id, request = nil 357 | params = query_params(nil, nil, nil, nil) 358 | 359 | # TODO: verify that this expects a request object and not just an array of strings 360 | if request 361 | expect_class!(request, Contrast::UserApi::TraceBaseRequest) 362 | params[:request] = request 363 | end 364 | 365 | self.class.post(traces_path(app_id, "export/xml"), { query: params }) do |response| 366 | # TODO: handle XML response 367 | end 368 | end 369 | 370 | def export_application_traces_xml_all app_id, request = nil, sort = nil 371 | params = query_params(nil, nil, nil, nil) 372 | params[:sort] = sort unless sort.nil? 373 | 374 | # TODO: verify that this expects a request object and not just an array of strings 375 | if request 376 | expect_class!(request, Contrast::UserApi::TraceBaseRequest) 377 | params[:request] = request 378 | end 379 | 380 | self.class.post(traces_path(app_id, "export/xml/all"), { query: params }) do |response| 381 | # TODO: handle XML response 382 | end 383 | end 384 | 385 | # FIXME: Documentation references TraceFilterRequest but does not define it 386 | def application_trace_uuids app_id, request = nil, sort = nil 387 | params = query_params(nil, nil, nil, nil) 388 | params[:sort] = sort unless sort.nil? 389 | params[:request] = request unless request.nil? 390 | self.class.get(trace_path(app_id, "ids"), { query: params }) do |response| 391 | # TODO: build TraceUUIDsResponse 392 | end 393 | end 394 | 395 | def application_traces_with_policy_violations app_id, environment = nil 396 | params = query_params(nil, nil, nil, nil) 397 | params[:environment] = environment unless environment.nil? 398 | self.class.get(trace_path(app_id, "policy/violations"), { query: params }) do |response| 399 | # TODO: build TraceRemediationPolicyViolationsResponse 400 | end 401 | end 402 | 403 | def application_traces_quick_filters app_id, request = nil 404 | params = query_params(nil, nil, nil, nil) 405 | if request 406 | expect_class!(request, Contrast::UserApi::TraceFilterRequest) 407 | params[:request] = request 408 | end 409 | 410 | self.class.get(trace_path(app_id, "quick"), { query: params }) do |response| 411 | # TODO: build QuickFilterResponse 412 | end 413 | end 414 | 415 | def delete_application_trace app_id, trace_uuid 416 | self.class.delete(trace_path(app_id, "trace/#{ trace_uuid }")) do |response| 417 | # TODO: build BaseApiResponse 418 | end 419 | end 420 | 421 | def application_trace app_id, trace_uuid, expand = nil 422 | params = query_params(expand, nil, nil, nil) 423 | self.class.get(trace_path(app_id, "trace/#{ trace_uuid }"), { query: params }) do |response| 424 | # TODO: build TraceResponse 425 | end 426 | end 427 | 428 | def application_trace_requirements app_id, trace_uuid, expand = nil 429 | params = query_params(expand, nil, nil, nil) 430 | self.class.get(trace_path(app_id, "trace/#{ trace_uuid }/requirements"), { query: params }) do |response| 431 | # TODO: build TraceRequirementsResponse 432 | end 433 | end 434 | 435 | def application_trace_servers app_id, trace_uuid, expand = nil 436 | params = query_params(expand, nil, nil, nil) 437 | self.class.get(trace_path(app_id, "trace/#{ trace_uuid }/servers"), { query: params }) do |response| 438 | # TODO: build TraceServerResponse 439 | end 440 | end 441 | 442 | def application_trace_url_instances app_id, trace_uuid, expand = nil 443 | params = query_params(expand, nil, nil, nil) 444 | self.class.get(trace_path(app_id, "trace/#{ trace_uuid }/urlinstances"), { query: params }) do |response| 445 | # TODO: build TraceUrlInstanceResponse 446 | end 447 | end 448 | 449 | def export_application_traces_subfilter_keycode_csv app_id, filter_type, keycode, form = nil, sort = nil 450 | params = query_params(nil, nil, nil, nil) 451 | params[:form] = form unless form.nil? 452 | params[:sort] = sort unless sort.nil? 453 | self.class.post(trace_path(app_id, "#{ filter_type }/#{ keycode }/export/csv"), { query: params }) do |response| 454 | # TODO: build CSV 455 | end 456 | end 457 | 458 | def export_application_traces_subfilter_keycode_xml app_id, filter_type, keycode, form = nil, sort = nil 459 | params = query_params(nil, nil, nil, nil) 460 | params[:form] = form unless form.nil? 461 | params[:sort] = sort unless sort.nil? 462 | self.class.post(trace_path(app_id, "#{ filter_type }/#{ keycode }/export/xml"), { query: params }) do |response| 463 | # TODO: build XML 464 | end 465 | end 466 | 467 | def application_trace_simplified app_id, trace_uuid, expand = nil 468 | params = query_params(expand, nil, nil, nil) 469 | self.class.get(trace_path(app_id, "#{ trace_uuid }/short"), { query: params }) do 470 | # TODO: build TraceResponse 471 | end 472 | end 473 | 474 | def application_trace_visibility app_id, trace_uuid 475 | self.class.get(trace_path(app_id, "#{ trace_uuid }/visibility")) do 476 | # TODO: build TraceVisibilityResponse 477 | end 478 | end 479 | end 480 | end 481 | end 482 | --------------------------------------------------------------------------------