Skip to content

Commit

Permalink
Merge pull request rapid7#300 from rapid7/conn_timeout_fixes
Browse files Browse the repository at this point in the history
Some methods were not honoring custom Connection Timeouts
  • Loading branch information
sgreen-r7 authored Sep 28, 2017
2 parents ef9d9e6 + 9ee7203 commit e84e383
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions lib/nexpose/connection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,11 @@ class Connection
attr_reader :response_xml
# The trust store to validate connections against if any
attr_reader :trust_store
# The main HTTP read_timeout value
# The main HTTP read_timeout value, in seconds
# For more information visit the link below:
# https://ruby-doc.org/stdlib/libdoc/net/http/rdoc/Net/HTTP.html#read_timeout-attribute-method
attr_accessor :timeout
# The optional HTTP open_timeout value
# The optional HTTP open_timeout value, in seconds
# For more information visit the link below:
# http://ruby-doc.org/stdlib/libdoc/net/http/rdoc/Net/HTTP.html#open_timeout-attribute-method
attr_accessor :open_timeout
Expand Down
2 changes: 1 addition & 1 deletion lib/nexpose/group.rb
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ def rescan_assets(connection)
#
def self.load(connection, id)
xml = %(<AssetGroupConfigRequest session-id="#{connection.session_id}" group-id="#{id}"/>)
r = APIRequest.execute(connection.url, xml)
r = APIRequest.execute(connection.url, xml, '1.1', { timeout: connection.timeout, open_timeout: connection.open_timeout })
parse(r.res)
end

Expand Down
4 changes: 2 additions & 2 deletions lib/nexpose/role.rb
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ def initialize(name, full_name, id = -1, enabled = true, scope = Scope::SILO)
def self.load(nsc, name, scope = Scope::SILO)
xml = nsc.make_xml('RoleDetailsRequest')
xml.add_element('Role', { 'name' => name, 'scope' => scope })
response = APIRequest.execute(nsc.url, xml, '1.2')
response = APIRequest.execute(nsc.url, xml, '1.2', { timeout: nsc.timeout, open_timeout: nsc.open_timeout })

if response.success
elem = REXML::XPath.first(response.res, 'RoleDetailsResponse/Role/')
Expand All @@ -179,7 +179,7 @@ def save(nsc)
end
xml.add_element(as_xml)

response = APIRequest.execute(nsc.url, xml, '1.2')
response = APIRequest.execute(nsc.url, xml, '1.2', { timeout: nsc.timeout, open_timeout: nsc.open_timeout })
xml = REXML::XPath.first(response.res, 'RoleCreateResponse')
@id = xml.attributes['id'].to_i unless @existing
@existing = true
Expand Down
2 changes: 1 addition & 1 deletion lib/nexpose/site.rb
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ def scan(connection, sync_id = nil, blackout_override = false)
'sync-id' => sync_id })

xml.add_attributes({ 'force' => true }) if blackout_override
response = connection.execute(xml, '1.1', timeout: 60)
response = connection.execute(xml, '1.1', timeout: connection.timeout)
Scan.parse(response.res) if response.success
end
end
Expand Down

0 comments on commit e84e383

Please sign in to comment.