nexty 0.20 → 0.30
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.
- data/bin/nexty +27 -6
- data/conf/config.yaml.sample +3 -0
- data/lib/nexty/device.rb +5 -2
- data/lib/nexty/report.rb +3 -3
- data/lib/nexty/version.rb +1 -1
- metadata +3 -3
data/bin/nexty
CHANGED
@@ -34,6 +34,7 @@ require 'csv'
|
|
34
34
|
opts = GetoptLong.new(
|
35
35
|
[ '--report', '-r', GetoptLong::REQUIRED_ARGUMENT ],
|
36
36
|
[ '--host', '-H', GetoptLong::REQUIRED_ARGUMENT ],
|
37
|
+
[ '--bulk-load', '-l', GetoptLong::NO_ARGUMENT ],
|
37
38
|
[ '--full-export', '-f', GetoptLong::REQUIRED_ARGUMENT ],
|
38
39
|
[ '--download', '-d', GetoptLong::REQUIRED_ARGUMENT ]
|
39
40
|
)
|
@@ -62,17 +63,21 @@ rescue ::Nexpose::APIError => e
|
|
62
63
|
end
|
63
64
|
printf "succeded\n".color(:green)
|
64
65
|
|
66
|
+
bulk_load = false
|
65
67
|
|
66
68
|
opts.each do |opt, arg|
|
67
69
|
case opt
|
68
70
|
|
71
|
+
when '--bulk-load'
|
72
|
+
bulk_load = true
|
73
|
+
|
69
74
|
when '--download'
|
70
75
|
|
71
76
|
file_name = "export_#{Time.now.strftime("%Y%m%d%H%M%s")}.csv"
|
72
77
|
puts "Report saved: #{Nexty::Report.download(arg, file_name, nsc)}".color(:white)
|
73
78
|
|
74
79
|
when '--full-export'
|
75
|
-
|
80
|
+
|
76
81
|
fn = Nexty::Report.generate_from_a_template(arg, nsc)
|
77
82
|
file_name = "export_#{Time.now.strftime("%Y%m%d%H%M%s")}.csv"
|
78
83
|
nsc.logout
|
@@ -89,16 +94,32 @@ opts.each do |opt, arg|
|
|
89
94
|
puts "Report saved: #{Nexty::Report.download(fn, file_name, nsc)}".color(:white)
|
90
95
|
|
91
96
|
when '--report'
|
92
|
-
fn = Nexty::Report.generate_from_a_list_of_sites(arg, nsc)
|
97
|
+
fn = Nexty::Report.generate_from_a_list_of_sites({:site_list=>arg, :template=>conn.config["report"]["template"]}, nsc)
|
93
98
|
puts "Report saved: #{fn}".color(:white)
|
94
99
|
|
95
100
|
when '--host'
|
96
101
|
|
97
|
-
|
98
|
-
|
99
|
-
|
102
|
+
if ! bulk_load
|
103
|
+
dev= Nexty::Device.find_by_address(nsc, arg)
|
104
|
+
if ! dev.nil?
|
105
|
+
puts "#{dev.address} found @ site #{dev.site_id}. Risk score = #{dev.riskscore} * #{dev.riskfactor}".color(:green)
|
106
|
+
else
|
107
|
+
puts "#{arg} not found".color(:red)
|
108
|
+
end
|
100
109
|
else
|
101
|
-
|
110
|
+
lines = []
|
111
|
+
|
112
|
+
lines = File.open(arg).readlines if File.exists?(arg)
|
113
|
+
puts "#{lines.count} hosts read from #{arg}".color(:white)
|
114
|
+
|
115
|
+
lines.each do |l|
|
116
|
+
dev= Nexty::Device.find_by_address(nsc, l.chomp)
|
117
|
+
if ! dev.nil?
|
118
|
+
puts "#{dev.address} found @ site #{dev.site_id}. Risk score = #{dev.riskscore} * #{dev.riskfactor}".color(:green)
|
119
|
+
else
|
120
|
+
puts "#{l.chomp} not found".color(:red)
|
121
|
+
end
|
122
|
+
end
|
102
123
|
end
|
103
124
|
end
|
104
125
|
end
|
data/conf/config.yaml.sample
CHANGED
data/lib/nexty/device.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
module Nexty
|
2
2
|
class Device
|
3
|
+
attr_reader :devices
|
4
|
+
|
3
5
|
def self.all(connection)
|
4
6
|
@devices = []
|
5
7
|
|
@@ -16,8 +18,9 @@ module Nexty
|
|
16
18
|
end
|
17
19
|
|
18
20
|
def self.find_by_address(connection, address)
|
19
|
-
devices = Nexty::Device.all(connection)
|
20
|
-
|
21
|
+
@devices = Nexty::Device.all(connection) if @devices.nil? or @devices.empty?
|
22
|
+
|
23
|
+
@devices.each do |d|
|
21
24
|
if d.address == address
|
22
25
|
return d
|
23
26
|
end
|
data/lib/nexty/report.rb
CHANGED
@@ -64,13 +64,13 @@ module Nexty
|
|
64
64
|
result[:url]
|
65
65
|
end
|
66
66
|
|
67
|
-
def self.generate_from_a_list_of_sites(
|
68
|
-
sites=Nexty::Sites.load_from_file(site_list)
|
67
|
+
def self.generate_from_a_list_of_sites(options={}, nsc)
|
68
|
+
sites=Nexty::Sites.load_from_file(options[:site_list])
|
69
69
|
s = []
|
70
70
|
sites.each do |site|
|
71
71
|
s << nsc.find_site_by_name(site)
|
72
72
|
end
|
73
|
-
result = Nexty::Report.generate(nsc, s, {:template=>
|
73
|
+
result = Nexty::Report.generate(nsc, s, {:template=>options[:template], :format=>'csv', :filename=>nil, :scan_to_include=>4})
|
74
74
|
Nexty::Report.download(result[:url], result[:filename], nsc)
|
75
75
|
end
|
76
76
|
end
|
data/lib/nexty/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nexty
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '0.
|
4
|
+
version: '0.30'
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-12-18 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: A command line interface to your Nexpose VA tool
|
15
15
|
email:
|
@@ -52,7 +52,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
52
52
|
version: '0'
|
53
53
|
segments:
|
54
54
|
- 0
|
55
|
-
hash:
|
55
|
+
hash: 1408093193201014683
|
56
56
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
57
57
|
none: false
|
58
58
|
requirements:
|