nexpose 0.7.4 → 0.7.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ba59c0bac7e5f25cdd613a70b20b71090047a7d2
4
- data.tar.gz: f265a3d518dc026a7d5bfc06745020562b84daad
3
+ metadata.gz: edb5b752be2087e90490daa5915d7d119108b47f
4
+ data.tar.gz: eedd2185b13fd299dd888acacf33be3937f5095e
5
5
  SHA512:
6
- metadata.gz: a374f92191a04827fa4fb570724def193cbaea92e991cb2008c7a5be47bea85ce4322fbe3c8aeb0a40605dfc5f1968d844879f3d655a15d3f9e5c93101bb3468
7
- data.tar.gz: 97f09e56659a23ce47ae322adca8a159724a84a21efef4327480afa2de7bb4e781b3690196bd249922b50a9457b0bf9fd42aeada9162764169bf973db65d4d3d
6
+ metadata.gz: 47e3c5c57d28c16e496d57fd4a5632f114cf0adae28f140a4cc7048fb873449cdedd41d88471f960a8b9c4d4a052f11b26044e29ad601dd0389d341df06bef2b
7
+ data.tar.gz: 348b64a4bb09e90d58db1de3b572e09f9765c054bb9b72d1ee8a2861c20dafad6a18b2d8437f87f0387cf98f9698d4ae5ab9ec94c4093c42ecf1a95559306afb
data/lib/nexpose/ajax.rb CHANGED
@@ -21,9 +21,11 @@ module Nexpose
21
21
  # @param [Connection] nsc API connection to a Nexpose console.
22
22
  # @param [String] uri Controller address relative to https://host:port
23
23
  # @param [String] content_type Content type to use when issuing the GET.
24
+ # @param [Hash] options Parameter options to the call.
24
25
  # @return [String|REXML::Document|Hash] The response from the call.
25
26
  #
26
- def get(nsc, uri, content_type = CONTENT_TYPE::XML)
27
+ def get(nsc, uri, content_type = CONTENT_TYPE::XML, options = {})
28
+ parameterize_uri(uri, options)
27
29
  get = Net::HTTP::Get.new(uri)
28
30
  get.set_content_type(content_type)
29
31
  _request(nsc, get)
@@ -110,7 +112,7 @@ module Nexpose
110
112
  # @return [Hash] The parameterized URI.
111
113
 
112
114
  def parameterize_uri(uri, parameters)
113
- uri = uri.concat(('?').concat(parameters.map { |k, v| "#{k}=#{CGI.escape(v.to_s)}" }.join('&'))) if parameters
115
+ uri = uri.concat(('?').concat(parameters.map { |k, v| "#{k}=#{CGI.escape(v.to_s)}" }.join('&'))) unless Hash(parameters).empty?
114
116
  end
115
117
 
116
118
  ###
@@ -421,7 +421,7 @@ module Nexpose
421
421
  # 3. potential (The check for a potential vulnerability was positive.)
422
422
  # These values are supported for CSV and XML formats.
423
423
  attr_reader :id
424
- # One of: site|group|device|scan|vuln-categories|vuln-severity|vuln-status|cyberscope-component|cyberscope-bureau|cyberscope-enclave
424
+ # One of: site|group|device|scan|vuln-categories|vuln-severity|vuln-status|cyberscope-component|cyberscope-bureau|cyberscope-enclave|tag
425
425
  attr_reader :type
426
426
 
427
427
  def initialize(type, id)
data/lib/nexpose/tag.rb CHANGED
@@ -6,15 +6,15 @@ module Nexpose
6
6
  #
7
7
  # @return [Array[TagSummary]] List of current tags.
8
8
  #
9
- def list_tags
9
+ def tags
10
10
  tag_summary = []
11
- tags = JSON.parse(AJAX.get(self, '/api/2.0/tags'))
11
+ tags = JSON.parse(AJAX.get(self, '/api/2.0/tags', AJAX::CONTENT_TYPE::JSON, { per_page: 2147483647 }))
12
12
  tags['resources'].each do |json|
13
13
  tag_summary << TagSummary.parse(json)
14
14
  end
15
15
  tag_summary
16
16
  end
17
- alias_method :tags, :list_tags
17
+ alias_method :list_tags, :tags
18
18
 
19
19
  # Deletes a tag by ID
20
20
  #
@@ -29,15 +29,15 @@ module Nexpose
29
29
  # @param [Fixnum] asset_id of the asset to list the applied tags for
30
30
  # @return [Array[TagSummary]] list of tags on asset
31
31
  #
32
- def list_asset_tags(asset_id)
32
+ def asset_tags(asset_id)
33
33
  tag_summary = []
34
- asset_tag = JSON.parse(AJAX.get(self, "/api/2.0/assets/#{asset_id}/tags"))
34
+ asset_tag = JSON.parse(AJAX.get(self, "/api/2.0/assets/#{asset_id}/tags", AJAX::CONTENT_TYPE::JSON, { per_page: 2147483647 }))
35
35
  asset_tag['resources'].select { |r| r['asset_ids'].find { |i| i == asset_id } }.each do |json|
36
36
  tag_summary << TagSummary.parse(json)
37
37
  end
38
38
  tag_summary
39
39
  end
40
- alias_method :asset_tags, :list_asset_tags
40
+ alias_method :list_asset_tags, :asset_tags
41
41
 
42
42
  # Removes a tag from an asset
43
43
  #
@@ -53,14 +53,15 @@ module Nexpose
53
53
  # @param [Fixnum] site_id id of the site to get the applied tags
54
54
  # @return [Array[TagSummary]] list of tags on site
55
55
  #
56
- def list_site_tags(site_id)
56
+ def site_tags(site_id)
57
57
  tag_summary = []
58
- site_tag = JSON.parse(AJAX.get(self, "/api/2.0/sites/#{site_id}/tags"))
58
+ site_tag = JSON.parse(AJAX.get(self, "/api/2.0/sites/#{site_id}/tags", AJAX::CONTENT_TYPE::JSON, { per_page: 2147483647 }))
59
59
  site_tag['resources'].each do |json|
60
60
  tag_summary << TagSummary.parse(json)
61
61
  end
62
62
  tag_summary
63
63
  end
64
+ alias_method :list_site_tags, :site_tags
64
65
 
65
66
  # Removes a tag from a site
66
67
  #
@@ -76,16 +77,16 @@ module Nexpose
76
77
  # @param [Fixnum] asset_group_id id of the group on which tags are listed
77
78
  # @return [Array[TagSummary]] list of tags on asset group
78
79
  #
79
- def list_asset_group_tags(asset_group_id)
80
+ def asset_group_tags(asset_group_id)
80
81
  tag_summary = []
81
- asset_group_tag = JSON.parse(AJAX.get(self, "/api/2.0/asset_groups/#{asset_group_id}/tags"))
82
+ asset_group_tag = JSON.parse(AJAX.get(self, "/api/2.0/asset_groups/#{asset_group_id}/tags", AJAX::CONTENT_TYPE::JSON, { per_page: 2147483647 }))
82
83
  asset_group_tag['resources'].each do |json|
83
84
  tag_summary << TagSummary.parse(json)
84
85
  end
85
86
  tag_summary
86
87
  end
87
- alias_method :group_tags, :list_asset_group_tags
88
- alias_method :asset_group_tags, :list_asset_group_tags
88
+ alias_method :group_tags, :asset_group_tags
89
+ alias_method :list_asset_group_tags, :asset_group_tags
89
90
 
90
91
  # Removes a tag from an asset_group
91
92
  #
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nexpose
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.4
4
+ version: 0.7.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - HD Moore
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2014-05-07 00:00:00.000000000 Z
13
+ date: 2014-05-29 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: librex