Giter Club home page Giter Club logo

nexpose-client's Introduction

DEPRECATED

The RESTful API for the Nexpose/InsightVM Security Console has rendered this library obsolete. If you require a Ruby library for that API you can use a generated client. Clients for other languages can be generated from the Swagger specification. Note that generated clients are not officially supported or maintained by Rapid7.

While this project is no longer under active development, it is still maintained by Rapid7 for internal testing needs. Pull requests will continue to be reviewed and accepted, and new versions published as requested.

Nexpose-Client

No Maintenance Intended Gem Version Build Status Test Coverage Inline docs Code Climate

This is the official gem package for the Ruby Nexpose API client library.

For assistance with using the gem or to discuss different approaches, please open an issue. To share or discuss scripts which use the gem head over to the Nexpose Resources project.

Check out the wiki for walk-throughs and other documentation. Submit bugs and feature requests on the issues page.

This gem is heavily used for internal, automated testing of the Nexpose product. It provides calls to the Nexpose XML APIs version 1.1 and 1.2, and JSON API 2.1. It also includes a number of helper methods which are not currently exposed through alternate means.

Since version 1.0 nexpose-client uses Semantic Versioning. This allows for confident use of the pessimistic operator in scripts or larger ruby projects.

Install the gem with Rubygems: gem install nexpose

Release Notes

Release notes are available on the Releases page.

The full Changelog is available as well, on the Changelog page.

Contributions

We welcome contributions to this package. Please see CONTRIBUTING for details.

Our coding standards include:

  • Favor returning classes over key-value maps. Classes tend to be easier for users to manipulate and use.
  • Unless otherwise noted, code should adhere to the Ruby Style Guide: https://github.com/bbatsov/ruby-style-guide
  • Use YARDoc comment style to improve the API documentation of the gem.

Full usage examples or task-oriented scripts should be submitted to the Nexpose Resources project. Smaller examples can be added to the wiki.

License

The nexpose-client gem is provided under the 3-Clause BSD License. See COPYING for details.

Credits

Rapid7, Inc.

nexpose-client's People

Contributors

abunn-r7 avatar adevitt-r7 avatar asalazar-r7 avatar bperry-r7 avatar cfleming-r7 avatar clee-r7 avatar dcastellanos-r7 avatar dmurray-r7 avatar dsadgat-r7 avatar erran avatar erran-r7 avatar gperez-r7 avatar gschneider-r7 avatar hdub-tech avatar jhart-r7 avatar jmadruga-r7 avatar jmartin-tech avatar jsteers-r7 avatar kkohli-r7 avatar mdaines-r7 avatar mhughes-r7 avatar mrongali avatar nbirnel avatar red5d avatar sgreen-r7 avatar smorris-r7 avatar snehitgajjar avatar ugohil-r7 avatar xliu-r7 avatar zeroorone-huff avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

nexpose-client's Issues

Move NexpoesAPI into a new Nexpose::API module

Ideal

  • Remove the NexposeAPI module from other classes and define a Nexpose::API namespace
  • Alias NexposeAPI if backwards compat. is required. (possibly define NexposeAPI as a method that warns of the deprecation and returns Nexpose::API method)
  • OPTION 1: Move all method definitions into a file under lib/nexpose_api/$CLASS and include all the API modules into Nexpose::API
  • OPTION 2: Move NexposeAPI into lib/nexpose_api.rb and move all method definitions into the new file

Implement Missing Silo Calls

The following Silo management calls are not currently implemented in the gem:

  • SiloConfigRequest
  • SiloProfileConfigRequest
  • SiloProfileUpdateRequest
  • SiloUpdateRequest

Site save failing with a repository error after adding credentials

I end up getting this error in a script used for ControlsInsight's automation:

Nexpose::APIError: NexposeAPI: Action failed: A repository error occurred while attempting
to create a site credential

I only access credentials via this in my script:

site.credentials << Nexpose::Credential.for_service(
  Nexpose::Credential::Type::CIFS,
  username,
  password
)

Convert to_map to to_h

Several objects in filter.rb have to_map methods. It is Ruby standard to use to_h to indicate a method which converts an object to a hash map representation. We should convert these over.

If we don't create a backwards-compatible alias to still respond to to_map, please provide a solid explanation why.

DynamicAssetGroup#save should raise an error if the result was an error

If data['response'] is "failure." then an APIError should be raised. I suppose this may not be the expected functionality so I've opened an issue vs. PR for discussion.

I also think that DynamicAssetGroup#save should return the group ID vs. true/false. Is there a recommended way to retrieve this ID or is the only solution gathering all asset groups and searching by name and get the ID from the new asset group summary?

hostnames not included in site_config

Looks like only host/ranges and not host/hosts are included in the site configuration. When making changes and saving back to the instance, any configured host elements are lost. Also the host element appears to have changed from 'hostname' to just 'host' as least on Community version 5.2.3

diff --git a/lib/nexpose/site.rb b/lib/nexpose/site.rb
index 5d87686..3d8e129 100644
--- a/lib/nexpose/site.rb
+++ b/lib/nexpose/site.rb
@@ -502,6 +502,9 @@ module Nexpose
s.elements.each('Hosts/range') do |r|
@hosts.push(IPRange.new(r.attributes['from'], r.attributes['to']))
end

  •    s.elements.each('Hosts/host') do |r|
    
  •      @hosts.push(HostName.new(r.text))
    
  •    end
            s.elements.each('ScanConfig') do |c|
                @scanConfig = ScanConfig.new(c.attributes['configID'],
                                             c.attributes['name'],
    

    @@ -848,7 +851,7 @@ module Nexpose
    include Sanitize

    def to_xml
    
  •       "<hostname>#{replace_entities(hostname)}</hostname>"
    
  •       "<host>#{replace_entities(hostname)}</host>"
    end
    

    end

site_device_listing not returning risk scores

I am trying to list all of the devices per site with associated risk score, and the @nsc.site_device_listing(site[:site_id]) appears to be returning invalid info. It appears that this would be the correct way to retrieve the data. In the example below, the total site risk score should be reflected in the hosts also.

Example Code

sites = @nsc.site_listing || []
sites.each do |site|
    ap @nsc.site_device_listing(site[:site_id])
    puts("    Site ##{site[:site_id]} '#{site[:name]}' Risk Factor: #{site[:risk_factor]} Risk Score: #{site[:risk_score]}")
end

Example Output

[
    [0] {
          :device_id => 9,
            :address => "123.123.123.124",
        :risk_factor => 0.0,
         :risk_score => 0.0
    },
    [1] {
          :device_id => 6,
            :address => "123.123.123.123",
        :risk_factor => 0.0,
         :risk_score => 0.0
    }
]
Site #7 'Production Misc' Risk Factor: 1.0 Risk Score: 1252.2251

Version Info

Ruby: ruby 1.9.2p180 (2011-02-18 revision 30909) [x86_64-linux]
nexpose-client: nexpose (0.0.98)
nexpose: 5.4.1 Enterprise
Last content update: 4122285428 (Wednesday, August 15, 2012 12:04:56 PM GMT)
Last product update : 4038634561 (Wednesday, August 15, 2012 12:00:00 PM GMT)

Gem version 0.1.8 doesn't work with Ruby 1.8.7

Hi there, unfortunately it seems Nexpose Gem has a syntax that doesn't work with Ruby 1.8.7.

/Users/thesp0nge/.rvm/gems/ruby-1.8.7-p358-i386@engage/gems/nexpose-0.1.8/lib/nexpose.rb:67:in `require': /Users/thesp0nge/.rvm/gems/ruby-1.8.7-p358-i386@engage/gems/nexpose-0.1.8/lib/nexpose/site.rb:94: syntax error, unexpected '.', expecting kEND (SyntaxError)
                                .max_by { |scan| scan.end_time }
                                 ^
    from /Users/thesp0nge/.rvm/gems/ruby-1.8.7-p358-i386@engage/gems/nexpose-0.1.8/lib/nexpose.rb:67
    from /Users/thesp0nge/.rvm/gems/ruby-1.8.7-p358-i386@global/gems/bundler-1.1.5/lib/bundler/runtime.rb:68:in `require'
    from /Users/thesp0nge/.rvm/gems/ruby-1.8.7-p358-i386@global/gems/bundler-1.1.5/lib/bundler/runtime.rb:68:in `require'
    from /Users/thesp0nge/.rvm/gems/ruby-1.8.7-p358-i386@global/gems/bundler-1.1.5/lib/bundler/runtime.rb:66:in `each'
    from /Users/thesp0nge/.rvm/gems/ruby-1.8.7-p358-i386@global/gems/bundler-1.1.5/lib/bundler/runtime.rb:66:in `require'
    from /Users/thesp0nge/.rvm/gems/ruby-1.8.7-p358-i386@global/gems/bundler-1.1.5/lib/bundler/runtime.rb:55:in `each'
    from /Users/thesp0nge/.rvm/gems/ruby-1.8.7-p358-i386@global/gems/bundler-1.1.5/lib/bundler/runtime.rb:55:in `require'
    from /Users/thesp0nge/.rvm/gems/ruby-1.8.7-p358-i386@global/gems/bundler-1.1.5/lib/bundler.rb:119:in `require'
    from /Users/thesp0nge/.rvm/gems/ruby-1.8.7-p358-i386@global/gems/bundler-1.1.5/lib/bundler/cli.rb:493:in `console'
    from /Users/thesp0nge/.rvm/gems/ruby-1.8.7-p358-i386@global/gems/bundler-1.1.5/lib/bundler/vendor/thor/task.rb:22:in `send'
    from /Users/thesp0nge/.rvm/gems/ruby-1.8.7-p358-i386@global/gems/bundler-1.1.5/lib/bundler/vendor/thor/task.rb:22:in `run'
    from /Users/thesp0nge/.rvm/gems/ruby-1.8.7-p358-i386@global/gems/bundler-1.1.5/lib/bundler/vendor/thor/invocation.rb:118:in `invoke_task'
    from /Users/thesp0nge/.rvm/gems/ruby-1.8.7-p358-i386@global/gems/bundler-1.1.5/lib/bundler/vendor/thor.rb:263:in `dispatch'
    from /Users/thesp0nge/.rvm/gems/ruby-1.8.7-p358-i386@global/gems/bundler-1.1.5/lib/bundler/vendor/thor/base.rb:386:in `start'
    from /Users/thesp0nge/.rvm/gems/ruby-1.8.7-p358-i386@global/gems/bundler-1.1.5/bin/bundle:13
    from /Users/thesp0nge/.rvm/gems/ruby-1.8.7-p358-i386@global/bin/bundle:23:in `load'
    from /Users/thesp0nge/.rvm/gems/ruby-1.8.7-p358-i386@global/bin/bundle:23

Using Ruby 1.9.3 with the same Gemset, the code works

Request for site_device_search_by_address in site.rb

As you are working the asset.rb search feature, would you consider this as a temporary solution in site.rb:

def site_device_by_address(site_id = nil, address)
  r = execute(make_xml('SiteDeviceListingRequest', {'site-id' => site_id}))

  if r.success
    r.res.elements.each('SiteDeviceListingResponse/SiteDevices') do |site|
      site_id = site.attributes['site-id'].to_i
      site.elements.each('device') do |device|
         if device.attributes['address'] == address
            return device
         end
      end
    end
  end
  return nil
end

Please keep in mind that I would hope to have future changes made to eliminate the requirement to pull all site devices via the site_device_listing, especially for really large sites. We have a site with 200k devices. It would be great to pass the address filter all the way up through to the where clause in the sql select.

Extract Common Credential Module

There is some shared functionality between the Credential and Shared Credential class. Perhaps this can be split out into a module. In particular, the gem currently only exposes the test method for shared credentials.

I would call the common module (or class, if that makes sense) Credential, and then rename the existing class with that name to SiteCredential.

Then, in order to have both use the test method, make sure that both implement a to_hash method which provides the required format for testing a credential.

Gem Isn't Using Nokogiri

The gem no longer needs to use Nokogiri as a dependency. We have two options:

  1. Sit on it, since we may want to use it for parsing some response objects which are large. If this is the case, we don't have any customers currently complaining about it.
  2. Strip it out, and only re-introduce it if needed. (We are moving toward a JSON API, so this makes more sense to me immediately).

list_engines doesn't parse scope attribute

EngineSummary.new(engine.attributes['id'].to_i,
engine.attributes['name'],
engine.attributes['address'],
engine.attributes['port'].to_i,
engine.attributes['status'])

Site save doesn't sanitize description for XML entities

Line 263 in site.rb will sanitize site name, but not description:

xml = %(<Site id='#{id}' name='#{replace_entities(name)}' description='#{description}' riskfactor='#{risk_factor}'>)

This results in an error when trying to save a site that has any of the following in the description: & ' " < >

To reproduce:

Using the web UI in Nexpose:

  1. Create a site with any title
  2. Set the description to contain any of & ' " < >

Then, using a Ruby script with the gem:
3. Load the site
4. Save the site

list_shared_credentials fails

Trying to call any variation of list_shared_credentials fails with the following error:

irb(main):029:0> old_nsc.list_shared_credentials
NoMethodError: undefined method auth_type=' for #<Nexpose::SharedCredentialSummary:0x007f8093c3d9d8> from /Library/Ruby/Gems/2.0.0/gems/nexpose-0.8.1/lib/nexpose/shared_cred.rb:53:infrom_json'
from /Library/Ruby/Gems/2.0.0/gems/nexpose-0.8.1/lib/nexpose/shared_cred.rb:10:in block in list_shared_credentials' from /Library/Ruby/Gems/2.0.0/gems/nexpose-0.8.1/lib/nexpose/shared_cred.rb:10:inmap'
from /Library/Ruby/Gems/2.0.0/gems/nexpose-0.8.1/lib/nexpose/shared_cred.rb:10:in list_shared_credentials' from (irb):29 from /usr/bin/irb:12:in

'

bug in regex in vuln.rb:461

vuln.rb:461 currently has this regex:

expiration_date =~ /\A\desc{4}-(\desc{2})-(\desc{2})\z/

I believe it should be:

expiration_date =~ /\A\d{4}-(\d{2})-(\d{2})\z/

Implement Role API Calls

The gem only implements the listing request at this time. The following calls are not implemented:

  • RoleCreateRequest
  • RoleDeleteRequest
  • RoleDetailsRequest
  • RoleUpdateRequest

Remove 1.9.3 Support

Ruby 1.9.3 ended normal maintenance on 2014-02-23 and will finish security maintenance on 2015-02-23. [https://bugs.ruby-lang.org/projects/ruby/wiki/ReleaseEngineering].

Once 1.9.3 is completely EOL, we should bump the gem spec required_ruby_version.

Saving of Asset Groups

The gem does not currently support the API call AssetGroupSaveRequest.

When implementing this. all Asset Group calls should be grouped into a single .rb file (probably group.rb).

Nexpose::ReportConfig.build incorrectly adds frequency when generate_now is true

Assume you've built and scanned a site, but no reports are configured. This won't work:

Nexpose::ReportConfig.build(nsc, site.id, site.name, report_type, report_format, true)

When the last argument is true, the report is supposed to run immediately, however it doesn't because a Frequency is added which says generate only after the scan.

In short, with the gem you cannot report on a site immediately after creating the report config.

Make the Wiki Helpful

Make the github wiki for the gem helpful. Perhaps put some guidelines, examples, etc. there.

Also, as older methods are deprecated in favor of a unified interface, perhaps provide transition guides for those looking to upgrade their scripts.

Nexpose::ReportAdHoc strange behavior with different formats

Hi there, creating an ad hoc report, if you supply 'text' or 'csv' file format Rex library complains about parse errors.

Using 'html' or 'raw-xml' report is generated.

report = Nexpose::ReportAdHoc.new(nsc, 'report-card', 'text')
report.addFilter('scan', scan[:scan_id])
puts report.generate

Clean up Comments - Switch to YARDoc

Adjust the comments throughout the code to produce useful RDoc. For example, if you visit the gem page (i.e., through http://rubygems.org/gems/nexpose), there is no clear starting point, and it isn't clear that many of the useful methods are actually exposed through the Nexpose::NexposeAPI module's documentation.

When adding new documentation, covert to using YARDoc style.

Nexpose changed answer format since yesterday?

I there, after the today software update, when I asked nexpose a CSV report the format is application/xml;charset=UTF-8 and so code in ReportAdHoc.generate doesn't work anymore. Note that when asking for a raw-xml the answer is multipart/mixed; boundary=AxB9sl3299asdjvbA;charset=UTF-8 and the API doesn't return nil.

Has the product update changed something?

Discovery Connection Calls

The gem does not currently implement any of the Discovery Connection calls to the API.

  • DiscoveryConnectionConnectRequest
  • DiscoveryConnectionCreateRequest
  • DiscoveryConnectionDeleteRequest
  • DiscoveryConnectionListingRequest
  • DiscoveryConnectionUpdateRequest

When implemented, they should be grouped into a common .rb file, perhaps discovery.rb.

rescan_assets does not work in 0.6.1

load an asset group and use rescan_assets to experience an error:

2.0.0p247 :043 > my_scan_group.rescan_assets(nsc)
ArgumentError: wrong number of arguments (1 for 2)
    from /home/gschneider/.rvm/gems/ruby-2.0.0-p247/gems/nexpose-0.6.1/lib/nexpose/scan.rb:61:in `scan_assets'
    from /home/gschneider/.rvm/gems/ruby-2.0.0-p247/gems/nexpose-0.6.1/lib/nexpose/group.rb:115:in `block in rescan_assets'
    from /home/gschneider/.rvm/gems/ruby-2.0.0-p247/gems/nexpose-0.6.1/lib/nexpose/group.rb:113:in `each'
    from /home/gschneider/.rvm/gems/ruby-2.0.0-p247/gems/nexpose-0.6.1/lib/nexpose/group.rb:113:in `rescan_assets'
    from (irb):43
    from /home/gschneider/.rvm/rubies/ruby-2.0.0-p247/bin/irb:13:in `<main>'

After a successful authentication, session_id is nil since gem version 0.1.3

Hi there, I have a small ruby utility I daily use in my job to fetch data from my Nexpose server (https://github.com/thesp0nge/nexty).

When moving form nexpose gem from version 0.1.4 (included) and later, after being successfully authenticated, all further requests fails. Session ID is not nil as stated before, however my code searching for an IP is not working, instead using gem version 0.1.3 works like a sharm.

Paolo

VulnException save() drops comment when sending request

When saving a VulnException with a comment the method takes in the passed int comment variable but later repurposes into a comment element which drops the string object and then passes itself into the text field making the comment object have blank text.

Out of Memory Error on Large Adhoc Report

I have several huge reports to download and I have been having the console generate them after every scan. This approach works but I have to have enough disk space for the console to store them. My problem is that I don't have this much disk space to work with.

My solution is to switch from the console generating the report and then me downloading it to using the new Connection::past_scans method and Nexpose::AdhocReportConfig. I run my code in a cronjob that generates and downloads scans since it's last run. Seems simple enough.

Minimal code snippit is below.

nsc = Nexpose::Connection.new(...)
nsc.login
most_recent = nil
scans = nsc.past_scans(expected*4)
scans.reject! { |scan| scan.end_time.to_i < most_recent.end_time.to_i  || scan.id == most_recent.id } if not most_recent.nil?
#### ... code to change #{expected} for next run... ####
nsc.logout
scans.peach(2) do |scan| #download 2 reports at a time
  local_nexpose = Nexpose::Connection.new(...)
  local_nexpose.login
  config = Nexpose::AdhocReportConfig.new('audit-report', 'raw-xml-v2', nil, nil, 0)
  config.add_filter('scan', scan.id)
  raw_xml = config.generate(local_nexpose, timeout=3600)
  File.write("unique_name.xml", raw_data)
  most_recent = scan
  local_nexpose.logout
end

Commit 7903b8d was a great step since I can now download 200MB reports however I still crash on reports larger than 350MB. I have looked at making the reports smaller however I need every report to contain exactly 1 whole network site. Some of these sites have about 1000 RHSA updates that need to be applied and each of these updates contains way too much vulnerability information.

Stacktrace is below.

Downloading scan 412687 for <SITENAME_THATS_NOT_PUBLIC>.
/home/<username>/.rvm/gems/ruby-2.1.5/gems/nexpose-0.8.19/lib/nexpose/api_request.rb:128:in `execute': NexposeAPI: Action failed: Error parsing response: #<RegexpError: failed to allocate memory: /\A([^<]*)/m> (Nexpose::APIError)
/home/<username>/.rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/rexml/source.rb:219:in `match'
/home/<username>/.rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/rexml/source.rb:219:in `match'
/home/<username>/.rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/rexml/parsers/baseparser.rb:426:in `pull_event'
/home/<username>/.rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/rexml/parsers/baseparser.rb:184:in `pull'
/home/<username>/.rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/rexml/parsers/treeparser.rb:22:in `parse'
/home/<username>/.rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/rexml/document.rb:287:in `build'
/home/<username>/.rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/rexml/document.rb:44:in `initialize'
/home/<username>/.rvm/gems/ruby-2.1.5/gems/nexpose-0.8.19/lib/nexpose/util.rb:12:in `new'
/home/<username>/.rvm/gems/ruby-2.1.5/gems/nexpose-0.8.19/lib/nexpose/util.rb:12:in `parse_xml'
/home/<username>/.rvm/gems/ruby-2.1.5/gems/nexpose-0.8.19/lib/nexpose/api_request.rb:50:in `execute'
/home/<username>/.rvm/gems/ruby-2.1.5/gems/nexpose-0.8.19/lib/nexpose/api_request.rb:127:in `execute'
/home/<username>/.rvm/gems/ruby-2.1.5/gems/nexpose-0.8.19/lib/nexpose/connection.rb:90:in `execute'
/home/<username>/.rvm/gems/ruby-2.1.5/gems/nexpose-0.8.19/lib/nexpose/report.rb:238:in `generate'
test.rb:71:in `block in <main>'
/home/<username>/.rvm/gems/ruby-2.1.5/gems/peach-0.5.1/lib/peach.rb:22:in `block (2 levels) in peach'
/home/<username>/.rvm/gems/ruby-2.1.5/gems/peach-0.5.1/lib/peach.rb:22:in `each'
/home/<username>/.rvm/gems/ruby-2.1.5/gems/peach-0.5.1/lib/peach.rb:22:in `block in peach'
/home/<username>/.rvm/gems/ruby-2.1.5/gems/peach-0.5.1/lib/peach.rb:13:in `block (2 levels) in _peach_run'
...
Exception parsing
Line: 1282579
Position: 100040694
Last 80 unconsumed characters:
 Content-Transfer-t/xml; name=report.xml
        from /home/<username>/.rvm/gems/ruby-2.1.5/gems/nexpose-0.8.19/lib/nexpose/connection.rb:90:in `execute'
        from /home/<username>/.rvm/gems/ruby-2.1.5/gems/nexpose-0.8.19/lib/nexpose/report.rb:238:in `generate'
        from test.rb:71:in `block in <main>'

According to the stacktrace, the issue is actually in REXML however REXML developers already closed the issue with a status of "WILL NOT FIX" saying that it's a problem with Base64 encoding and XML.

As far as I can tell, the only reason the Nexpose gem is parsing the XML is to check the value of the success attribute on the root node. There is probably not a reason to have the gem parse the entire report if the report is larger than 32MB. I have a monkey patch that drops the header and footer and uses the Base64 module to get me the raw xml. This patch is really slow though since it causes the generic errors in APIRequest::execute to trigger retrying 5 times. I would rather help fix the issue upstream than throw 3 or 4 monkey patches into production.

site_device_listing not returning risk scores

I am trying to list all of the devices per site with associated risk score, and the @nsc.site_device_listing(site[:site_id]) appears to be returning invalid info. It appears that this would be the correct way to retrieve the data. In the example below, the total site risk score should be reflected in the hosts also.

Example Code

sites = @nsc.site_listing || []
sites.each do |site|
    ap @nsc.site_device_listing(site[:site_id])
    puts("    Site ##{site[:site_id]} '#{site[:name]}' Risk Factor: #{site[:risk_factor]} Risk Score: #{site[:risk_score]}")
end

Example Output

[
    [0] {
          :device_id => 9,
            :address => "123.123.123.124",
        :risk_factor => 0.0,
         :risk_score => 0.0
    },
    [1] {
          :device_id => 6,
            :address => "123.123.123.123",
        :risk_factor => 0.0,
         :risk_score => 0.0
    }
]
Site #7 'Production Misc' Risk Factor: 1.0 Risk Score: 1252.2251

Version Info

Ruby: ruby 1.9.2p180 (2011-02-18 revision 30909) [x86_64-linux]
nexpose-client: nexpose (0.0.98)
nexpose: 5.4.1 Enterprise
Last content update 4122285428 (Wednesday, August 15, 2012 12:04:56 PM GMT)
Last product update 4038634561 (Wednesday, August 15, 2012 12:00:00 PM GMT)


No Method geturl in nexpose.rb:2536

When creating a new Nexpose::ReportHistory(connection,config_id)
The error is raised:
ruby-1.8.7-p334 :022 > Nexpose::ReportHistory.new(connection,223)
NoMethodError: undefined method geturl' for #<Nexpose::Connection:0x7f86bf934890> from /home/bhamilton/.rvm/gems/[email protected]/gems/nexpose-0.0.8/lib/nexpose.rb:2536:ininitialize'
from (irb):22:in `new'
from (irb):22
from :0

The instance methods available on the connection class do not include a geturl. The connection does have a url method.
I am looking for a fix myself but wanted to let you know it looks broken. If I am going about this the wrong way let me know.

Site.save on dynamic site causes APIError

When attempting to modify a dynamic site (for instance, changing an alert), calling Site.save results in an APIError:
<ajaxResponse success="0"> <Errors> <Error>Insufficient privileges to remove credentials</Error> </Errors> </ajaxResponse>

However I did not modify the credentials of the loaded site and static sites do not give the same error. Am I unaware of something that's different about handling dynamic sites? The documentation only mentions that connection and asset filter changes must be saved through the DiscoveryConnection#update_site call.

undefined local variable or method `response'

nexpose.rb:1841:in initialize': undefined local variable or methodresponse' for Nexpose::SiteDeviceListing:0x007fce3315b9c8 (NameError)

Needs updating to:

BEFORE::

    if(r.success)
        respsonse.elements.each('SiteDeviceListingResponse/SiteDevices/device') do |d|
            @devices.push(Device.new(d.attributes['id'],@site_id,d.attributes["address"],d.attributes["riskfactor"],d.attributes['riskscore']))
        end
    end

AFTER::

    if(r.success)
        r.res.elements.each('SiteDeviceListingResponse/SiteDevices/device') do |d|
            @devices.push(Device.new(d.attributes['id'],@site_id,d.attributes["address"],d.attributes["riskfactor"],d.attributes['riskscore']))
        end
    end

Error When Loading Dynamic Sites

If I attempt to Site.load a Dynamic site my script crashes with
C:/Ruby193/lib/ruby/gems/1.9.1/gems/nexpose-0.8.4/lib/nexpose/filter.rb:302:in initialize': undefined methodupcase' for nil:NilClass (NoMethodError)
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/nexpose-0.8.4/lib/nexpose/filte
r.rb:332:in new' from C:/Ruby193/lib/ruby/gems/1.9.1/gems/nexpose-0.8.4/lib/nexpose/filte r.rb:332:inparse'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/nexpose-0.8.4/lib/nexpose/site.
rb:323:in load_dynamic_attributes' from C:/Ruby193/lib/ruby/gems/1.9.1/gems/nexpose-0.8.4/lib/nexpose/site. rb:221:inload'

Alerts Are Not Correctly Parsed or Saved

Alerts are not correctly parsed from site configurations when loading them from a Nexpose console. An attempt to save a site which contains an alert will fail to save with a 'name cannot be null' error.

The underlying XML is not correctly parsed or used.

Here is an example of the three kinds of alerts.

SMTP

<Alert name="Scan Completion e-mail" enabled="1" maxAlerts="1">
  <scanFilter scanStart="0" scanStop="1" scanFailed="0" scanResumed="0" scanPaused="0"/>
  <vulnFilter severityThreshold="1" confirmed="0" unconfirmed="0" potential="0"/>
  <smtpAlert sender="[email protected]" server="smtp.company.com" limitText="0">
    <recipient>[email protected]</recipient>
  </smtpAlert>
</Alert>

Syslog

<Alert name="syslog attempt" enabled="1" maxAlerts="1">
  <scanFilter scanStart="1" scanStop="0" scanFailed="0" scanResumed="0" scanPaused="0"/>
  <vulnFilter severityThreshold="1" confirmed="0" unconfirmed="1" potential="1"/>
  <syslogAlert server="syslog.company.com"/>
</Alert>      

SNMP

<Alert name="snmp" enabled="1" maxAlerts="2">
  <scanFilter scanStart="0" scanStop="0" scanFailed="0" scanResumed="0" scanPaused="1"/>
  <vulnFilter severityThreshold="8" confirmed="1" unconfirmed="0" potential="0"/>
  <snmpAlert community="communityname" server="managementserver"/>
</Alert>

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.