nexpose_pxgrid 0.1.4-java → 0.1.5-java

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 559f9d7dfc2d8ce64039b4106e985629950c6aa1
4
- data.tar.gz: 617ec01f58471af86831030578d210383562183e
3
+ metadata.gz: b491e0306e3ef6a0a86c6c130aac80a8593ea78d
4
+ data.tar.gz: 15dead73f58934f3d38f117c959ed741017ac975
5
5
  SHA512:
6
- metadata.gz: d9fed3967f1a6f21a8da545ccfc8b8c13e2aa5fc24f660bd56a81335f5028af997e6fe1a5783defd36cfd0b65e7505a01ad1c72f930984c65ff7c3c5947eaa93
7
- data.tar.gz: fa64263ae1183e1433de07ef557436068d856c35857015f2e69fb398426280f18285ef664278a976408027ae094a9ca5000844b0290fa2d0a5418d2bf76962fa
6
+ metadata.gz: b93c8118dc23da7bb0b0ef382ffa419881bdbf314811ec046af45bd9693779eb7c4534adca13210b00e5ad5d4b3d438408e9854396b11130e3ca7abe44d4adfb
7
+ data.tar.gz: 1d1ea1ae083831bcabd3d3cc7a1a79473e5997c4ae7b82825bfb7e41d8cad2c381c7f91a4687b02d88b1270e9bb0137b50778ce038409d862fec4fe8c81ab28f
@@ -23,6 +23,8 @@
23
23
  :riskscore: 20
24
24
  # (M) Time to wait before cancelling a scan and continuing.
25
25
  :scan_timeout: 3600
26
+ # (M) Nexpose scan template ID to be used while creating temporary Site for scanning.
27
+ :scan_template_id: full-audit
26
28
  # Cisco pxGrid options. Note all of these options can be set through environment variables of the same capitalised name e.g. ISE_URL instead of :ise_url
27
29
  :pxg_data:
28
30
  # Cisco Identity Services Engine hostname/ip.
@@ -20,6 +20,11 @@ module PxnxJruby
20
20
 
21
21
  # TODO: This method ABC is too high (http://c2.com/cgi/wiki?AbcMetric)
22
22
  def setup(config_options = {})
23
+ # Fail early if scan template id is invalid
24
+ unless PxnxJruby::NexposeConnection.is_valid_scan_template(config_options)
25
+ @log.error("#{config_options[:nexpose_data][:scan_template_id]} is not a valid scan template ID -- aborting application.")
26
+ abort('Scan template ID not valid, please update pxnx.config with proper setting')
27
+ end
23
28
  # We can only have a certain number of connections to Nexpose. Generate a pool of connections for realtime or batched scans.
24
29
  @connection_pool = Executors.newFixedThreadPool(config_options[:nexpose_connection_max])
25
30
  # Schedule our "realtime" or batched tasks
@@ -25,7 +25,7 @@ module PxnxJruby
25
25
  def call
26
26
  begin
27
27
  @ip = @ip_list.is_a?(Array) ? @ip_list : Array.new(1, @ip_list)
28
- @site = Nexpose::Site.new("pxGrid-Nexpose-#{DateTime.now.strftime('%Y%jT%H%M%SZ')}", 'full-audit')
28
+ @site = Nexpose::Site.new("pxGrid-Nexpose-#{DateTime.now.strftime('%Y%jT%H%M%SZ')}", @options[:nexpose_data][:scan_template_id])
29
29
  @site.description = "Rapid7 Nexpose - Cisco pxGrid Integration scan job saved at #{DateTime.now.strftime('%Y%jT%H%M%SZ')}"
30
30
  @log.info("Scanning IPs <#{@ip.each{|ip| ip}}> on site <#{@site.name}>.")
31
31
  @ip.each { |ip| @site.add_ip(ip) }
@@ -37,7 +37,7 @@ module PxnxJruby
37
37
  # Add ', :verbose => true' to get more info.
38
38
  WaitUtil.wait_for_condition('waiting_for_scan_to_finish', :timeout_sec => @options[:nexpose_data][:scan_timeout], :delay_sec => 30) do
39
39
  @completed = true
40
- if %w(unknown dispatched running).include? (@nsc.scan_status(@scan_info.id))
40
+ if %w(unknown dispatched running integrating).include? (@nsc.scan_status(@scan_info.id))
41
41
  @completed = false
42
42
  @log.debug("Scan still running for site <#{@site.name}>")
43
43
  end
@@ -45,10 +45,10 @@ module PxnxJruby
45
45
  end
46
46
  @log.info("Scan completed for site #{@site.name}>")
47
47
  devices = @nsc.devices(@site.id)
48
- @devices_to_quarantine = devices.select { |d| d.risk_score >= @options[:nexpose_data][:riskscore]}
48
+ @devices_to_quarantine = devices.map { |d| d.address if d.risk_score >= @options[:nexpose_data][:riskscore]}
49
49
  Thread.new do
50
50
  eps_broker = PxnxJruby::EpsBroker.new(@options[:grid_connection].grid)
51
- @log.info("Quarantining device <#{@devices_to_quarantine}> for site <#{@site.name}>.")
51
+ @log.info("Quarantining device(s) <#{@devices_to_quarantine}> for site <#{@site.name}>.")
52
52
  eps_broker.quarantine_ip(@devices_to_quarantine) unless @devices_to_quarantine.empty?
53
53
  end unless @options[:debug] == true
54
54
  @log.debug("Deleting temporary site <#{@site.name}>, logging out and exiting.")
@@ -58,5 +58,11 @@ module PxnxJruby
58
58
  @log.error("Exception while running a Nexpose connection thread! Message is <#{e.message}> and stacktrace is <#{e.backtrace.join("\n")}>.")
59
59
  end
60
60
  end
61
+
62
+ def self.is_valid_scan_template(options)
63
+ nsc = Nexpose::Connection.new(options[:nexpose_data][:nxconsole],options[:nexpose_data][:nxuser], ENV['NEXPOSE_PASSWORD'])
64
+ nsc.login
65
+ return nsc.list_scan_templates.select{|template_summary| template_summary.id.eql?(options[:nexpose_data][:scan_template_id])}.any?
66
+ end
61
67
  end
62
68
  end
@@ -1,5 +1,5 @@
1
1
  module PxnxJruby
2
2
  PRODUCT = 'pxGrid'
3
3
  VENDOR = 'Cisco'
4
- VERSION = "0.1.4"
4
+ VERSION = "0.1.5"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nexpose_pxgrid
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: java
6
6
  authors:
7
7
  - Damian Finol
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2017-01-16 00:00:00.000000000 Z
13
+ date: 2017-03-03 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: bundler
@@ -212,7 +212,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
212
212
  version: '0'
213
213
  requirements: []
214
214
  rubyforge_project:
215
- rubygems_version: 2.5.1
215
+ rubygems_version: 2.5.2
216
216
  signing_key:
217
217
  specification_version: 4
218
218
  summary: Nexpose - pxGrid Node implementation.