Class: Vigilion::HTTP
- Inherits:
-
Object
- Object
- Vigilion::HTTP
- Defined in:
- lib/vigilion/http.rb
Instance Attribute Summary collapse
-
#method ⇒ Object
Returns the value of attribute method.
-
#options ⇒ Object
Returns the value of attribute options.
-
#url ⇒ Object
Returns the value of attribute url.
Class Method Summary collapse
Instance Method Summary collapse
- #get(uuid) ⇒ Object
-
#initialize ⇒ HTTP
constructor
A new instance of HTTP.
- #scan_path(key, path, options = {}) ⇒ Object
- #scan_url(key, url, options = {}) ⇒ Object
- #validate ⇒ Object
Constructor Details
#initialize ⇒ HTTP
Returns a new instance of HTTP.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/vigilion/http.rb', line 5 def initialize validate_access_keys @conn = ::Faraday.new(url: Configuration.server_url) do |c| c.request :multipart c.request :json c.response :json, content_type: /\bjson$/ if Configuration.debug c.response :detailed_logger, Configuration.logger end c.adapter ::Faraday.default_adapter c.headers = { 'X-Api-Key' => Configuration.access_key_id, 'User-Agent' => "Vigilion #{Vigilion::VERSION} (#{RUBY_PLATFORM}, Ruby #{RUBY_VERSION})" } end end |
Instance Attribute Details
#method ⇒ Object
Returns the value of attribute method.
3 4 5 |
# File 'lib/vigilion/http.rb', line 3 def method @method end |
#options ⇒ Object
Returns the value of attribute options.
3 4 5 |
# File 'lib/vigilion/http.rb', line 3 def end |
#url ⇒ Object
Returns the value of attribute url.
3 4 5 |
# File 'lib/vigilion/http.rb', line 3 def url @url end |
Class Method Details
.digest(body) ⇒ Object
40 41 42 |
# File 'lib/vigilion/http.rb', line 40 def self.digest(body) Digest::MD5.hexdigest("#{body}#{Vigilion::Configuration.secret_access_key}") end |
Instance Method Details
#get(uuid) ⇒ Object
30 31 32 33 |
# File 'lib/vigilion/http.rb', line 30 def get(uuid) response = @conn.get "/scans/#{uuid}" response.body end |
#scan_path(key, path, options = {}) ⇒ Object
26 27 28 |
# File 'lib/vigilion/http.rb', line 26 def scan_path(key, path, = {}) send scan: .merge({ key: key, file: Faraday::UploadIO.new(path, 'application') }) end |
#scan_url(key, url, options = {}) ⇒ Object
22 23 24 |
# File 'lib/vigilion/http.rb', line 22 def scan_url(key, url, = {}) send scan: .merge({ key: key, url: Addressable::URI.unescape(url) }) end |
#validate ⇒ Object
35 36 37 38 |
# File 'lib/vigilion/http.rb', line 35 def validate response = @conn.get "/projects/validate" process_response("", response) end |