Class: Contrast::Components::Api::Interface
Overview
A wrapper build around the Common Agent Configuration project to allow for Api keys to be mapped with their values contained in their parent_configuration_spec.yaml.
Constant Summary
collapse
- CANON_NAME =
'api'
- PROXY_NAME =
"#{ CANON_NAME }.proxy".cs__freeze
- CONFIG_VALUES =
%w[api_key user_name service_key url].cs__freeze
- DEFAULT_URL =
'https://app.contrastsecurity.com/Contrast'
Contrast::Config::BaseConfiguration::AT_UNDERSCORE
ComponentBase::ENABLE
Contrast::Config::Diagnostics::Tools::CHECK
Contrast::Config::Diagnostics::SingletonTools::API_CREDENTIALS, Contrast::Config::Diagnostics::SingletonTools::CONTRAST_MARK
Instance Attribute Summary collapse
Instance Method Summary
collapse
#to_contrast_hash
#canon_name, #config_values, #false?, #file_exists?, #stringify_array, #true?, #valid_cert?
#add_effective_config_values, #add_single_effective_value
#flatten_settings, #to_config_values, #update_config, #value_to_s
Constructor Details
#initialize(hsh = {}) ⇒ Interface
Returns a new instance of Interface.
Instance Attribute Details
25
26
27
|
# File 'lib/contrast/components/api.rb', line 25
def api_key
@api_key
end
|
#service_key ⇒ String
29
30
31
|
# File 'lib/contrast/components/api.rb', line 29
def service_key
@service_key
end
|
46
47
48
|
# File 'lib/contrast/components/api.rb', line 46
def url
@url.nil? ? DEFAULT_URL : @url
end
|
#user_name ⇒ String
27
28
29
|
# File 'lib/contrast/components/api.rb', line 27
def user_name
@user_name
end
|
Instance Method Details
71
72
73
74
75
76
77
|
# File 'lib/contrast/components/api.rb', line 71
def api_url
@_api_url ||= begin
tmp = Contrast::CONFIG.api.url
tmp += '/Contrast' unless tmp.end_with?('/Contrast')
tmp
end
end
|
#certification_ca_file ⇒ Object
115
116
117
|
# File 'lib/contrast/components/api.rb', line 115
def certification_ca_file
@_certification_ca_file ||= ::Contrast::CONFIG.api.certificate.ca_file
end
|
#certification_cert_file ⇒ Object
119
120
121
|
# File 'lib/contrast/components/api.rb', line 119
def certification_cert_file
@_certification_cert_file ||= ::Contrast::CONFIG.api.certificate.cert_file
end
|
#certification_enable ⇒ Object
111
112
113
|
# File 'lib/contrast/components/api.rb', line 111
def certification_enable
@_certification_enable ||= certification_truly_enabled?(::Contrast::CONFIG.api.certificate)
end
|
#certification_key_file ⇒ Object
123
124
125
|
# File 'lib/contrast/components/api.rb', line 123
def certification_key_file
@_certification_key_file ||= ::Contrast::CONFIG.api.certificate.key_file
end
|
#proxy_enable ⇒ Object
79
80
81
82
83
|
# File 'lib/contrast/components/api.rb', line 79
def proxy_enable
return @_proxy_enable unless @_proxy_enable.nil?
@_proxy_enable = true?(::Contrast::CONFIG.api.proxy.enable)
end
|
#proxy_url ⇒ Object
85
86
87
|
# File 'lib/contrast/components/api.rb', line 85
def proxy_url
proxy.url
end
|
#request_audit_enable ⇒ Object
89
90
91
92
93
|
# File 'lib/contrast/components/api.rb', line 89
def request_audit_enable
return @_request_audit_enable unless @_request_audit_enable.nil?
@_request_audit_enable = true?(::Contrast::CONFIG.api.request_audit.enable)
end
|
#request_audit_path ⇒ Object
107
108
109
|
# File 'lib/contrast/components/api.rb', line 107
def request_audit_path
@_request_audit_path ||= ::Contrast::CONFIG.api.request_audit.path.to_s
end
|
#request_audit_requests ⇒ Object
95
96
97
98
99
|
# File 'lib/contrast/components/api.rb', line 95
def request_audit_requests
return @_request_audit_requests unless @_request_audit_requests.nil?
@_request_audit_requests = true?(::Contrast::CONFIG.api.request_audit.requests)
end
|
#request_audit_responses ⇒ Object
101
102
103
104
105
|
# File 'lib/contrast/components/api.rb', line 101
def request_audit_responses
return @_request_audit_responses unless @_request_audit_responses.nil?
@_request_audit_responses = true?(::Contrast::CONFIG.api.request_audit.responses)
end
|
#to_effective_config(effective_config) ⇒ Object
Converts current configuration to effective config values class and appends them to EffectiveConfig class.
131
132
133
134
135
136
|
# File 'lib/contrast/components/api.rb', line 131
def to_effective_config effective_config
add_effective_config_values(effective_config, CONFIG_VALUES, CANON_NAME, CANON_NAME)
effective_proxy(effective_config)
request_audit&.to_effective_config(effective_config)
certificate&.to_effective_config(effective_config)
end
|