diff options
| author | mo <mo.khan@gmail.com> | 2018-03-19 10:00:08 -0600 |
|---|---|---|
| committer | mo <mo.khan@gmail.com> | 2018-03-19 10:00:08 -0600 |
| commit | d80d15250d2554af913182a8a99dff0e14e4c867 (patch) | |
| tree | 5822e36b7f22ce99f7974a04e1dff12715de6ab4 /lib | |
| parent | 3caf1440cddb8b2187afb7020dc8c98049dd3701 (diff) | |
default to port 443.v0.1.4
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/ats/amp4e/api.rb | 6 | ||||
| -rw-r--r-- | lib/ats/cli.rb | 2 | ||||
| -rw-r--r-- | lib/ats/http_api.rb | 2 | ||||
| -rw-r--r-- | lib/ats/threat_grid/api.rb | 6 |
4 files changed, 13 insertions, 3 deletions
diff --git a/lib/ats/amp4e/api.rb b/lib/ats/amp4e/api.rb index 9495a8d..c2ba8cc 100644 --- a/lib/ats/amp4e/api.rb +++ b/lib/ats/amp4e/api.rb @@ -44,7 +44,7 @@ module ATS private def build_uri(relative_url, version:) - URI::Generic.build(host: host, scheme: scheme, path: "/v#{version}/#{relative_url}") + URI::Generic.build(host: host, port: port, scheme: scheme, path: "/v#{version}/#{relative_url}") end def client_id @@ -63,6 +63,10 @@ module ATS configuration[profile][:amp4e][:scheme] end + def port + configuration[profile][:amp4e][:port] + end + def headers { AUTHORIZATION: "Basic #{Base64.strict_encode64("#{client_id}:#{client_secret}")}" } end diff --git a/lib/ats/cli.rb b/lib/ats/cli.rb index 86d807d..60c3709 100644 --- a/lib/ats/cli.rb +++ b/lib/ats/cli.rb @@ -46,11 +46,13 @@ module ATS client_id: '', client_secret: '', host: 'api.amp.cisco.com', + port: 443, scheme: 'https', }, threat_grid: { api_key: '', host: 'panacea.threatgrid.com', + port: 443, scheme: 'https', }, } diff --git a/lib/ats/http_api.rb b/lib/ats/http_api.rb index acc7524..82e2d22 100644 --- a/lib/ats/http_api.rb +++ b/lib/ats/http_api.rb @@ -43,7 +43,7 @@ module ATS def http_for(uri) http = Net::HTTP.new(uri.host, uri.port) http.read_timeout = 30 - http.use_ssl = uri.is_a?(URI::HTTPS) + http.use_ssl = uri.scheme == "https" http.set_debug_output(ATS.logger) http end diff --git a/lib/ats/threat_grid/api.rb b/lib/ats/threat_grid/api.rb index 160f797..cb982b9 100644 --- a/lib/ats/threat_grid/api.rb +++ b/lib/ats/threat_grid/api.rb @@ -53,7 +53,7 @@ module ATS end def build_uri(relative_url, version:) - URI::Generic.build(host: host, scheme: scheme, path: "/api/v#{version}/#{relative_url}") + URI::Generic.build(host: host, port: port, scheme: scheme, path: "/api/v#{version}/#{relative_url}") end def api_key @@ -67,6 +67,10 @@ module ATS def scheme configuration[profile][:threat_grid][:scheme] end + + def port + configuration[profile][:threat_grid][:port] + end end end end |
