nexpose_sourcefire 0.2.1 → 0.2.2
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 +4 -4
- data/README.md +62 -9
- data/bin/nexpose_sourcefire +16 -24
- data/lib/sourcefire/config/encryption.config +20 -0
- data/lib/sourcefire/config/rapid7_sourcefire.config +22 -1
- data/lib/sourcefire/nexpose_helper.rb +2 -2
- data/lib/sourcefire/utilities/config_parser.rb +141 -0
- data/lib/sourcefire/utilities/gem_options.rb +91 -0
- data/lib/sourcefire/{nx_logger.rb → utilities/nx_logger.rb} +2 -2
- data/lib/sourcefire/version.rb +2 -2
- data/lib/sourcefire_connector.rb +31 -8
- metadata +29 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a2f5744e61ccd40b64f0f2b51ae0b96b467e2056
|
4
|
+
data.tar.gz: 149e36d48a20550630d33c66ccb2f5cdef0816d4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 58788431b85aaed7a17990098515c197ba3d71ba9cb5eb7a28588db46cdc9cf6419e626653cc41219fff7de6901befcde5948806563996f4fd1f7049ecd8ec76
|
7
|
+
data.tar.gz: c41092ca68dcadc0383328a857d53784e0b015ff25ac87f864ca77953efd44ea6b7047333beb826b23ddc88876926a4ddc6d5c27668fb10de88624be3176590a
|
data/README.md
CHANGED
@@ -1,11 +1,14 @@
|
|
1
|
-
#
|
1
|
+
# SourceFireRuby
|
2
2
|
|
3
|
-
|
3
|
+
This is the official gem package for the Nexpose Cisco SourceFire Integration.
|
4
|
+
|
5
|
+
For assistance with using the gem, documentation, or issues, please email the Rapid7 support team at support@rapid7.com, including description of issues and log files.
|
4
6
|
|
7
|
+
## Installation
|
5
8
|
Add this line to your application's Gemfile:
|
6
9
|
|
7
10
|
```ruby
|
8
|
-
gem '
|
11
|
+
gem 'nexpose_sourcefire'
|
9
12
|
```
|
10
13
|
|
11
14
|
And then execute:
|
@@ -14,15 +17,45 @@ And then execute:
|
|
14
17
|
|
15
18
|
Or install it yourself as:
|
16
19
|
|
17
|
-
$ gem install
|
20
|
+
$ gem install nexpose_sourcefire
|
18
21
|
|
19
|
-
## Changelog
|
20
22
|
|
21
|
-
|
22
|
-
|
23
|
+
## Configuration
|
24
|
+
1. Please follow the SourceFire documentation to generate a PKCS12 certificate to use in the integration.
|
23
25
|
|
24
|
-
|
25
|
-
|
26
|
+
2. Set up the necessary environment variables as detailed in the documentation, or use the provided configuration file *nexpose_sourcefire.config*.
|
27
|
+
|
28
|
+
In the configuration file the siteID and pkcs12 location values **must** be filled in.
|
29
|
+
|
30
|
+
## Operation
|
31
|
+
The gem can be manually executed from within the 'bin' folder with the command:
|
32
|
+
|
33
|
+
nexpose_sourcefire
|
34
|
+
|
35
|
+
## Encryption Settings
|
36
|
+
|
37
|
+
The usernames and passwords within the configuration files are automatically encrypted when the integration runs. The key and IV files used during encryption/decryption are saved within the config folder by default.
|
38
|
+
|
39
|
+
#### Setting Custom Locations for Encryption Files
|
40
|
+
|
41
|
+
To set custom locations for the key and IV files, update the following values within the encryption.config file:
|
42
|
+
|
43
|
+
- key_filename - The absolute path to where the key file will be created.
|
44
|
+
- iv_file - The absolute path to where the IV file will be created.
|
45
|
+
|
46
|
+
To set a custom path after the integration has already executed, the files must be moved to the new location manually.
|
47
|
+
|
48
|
+
#### Encrypting the Configuration without running the Integration
|
49
|
+
The Nexpose SourceFire integration can encrypt its configuration file without running the gem. This allows users to secure their login information for future use e.g for use in a cron-schedule.
|
50
|
+
|
51
|
+
The command to do so is:
|
52
|
+
```
|
53
|
+
nexpose_sourcefire -e
|
54
|
+
```
|
55
|
+
or
|
56
|
+
```
|
57
|
+
nexpose_sourcefire --encrypt_config
|
58
|
+
```
|
26
59
|
|
27
60
|
## Development
|
28
61
|
|
@@ -39,3 +72,23 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERN
|
|
39
72
|
|
40
73
|
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
41
74
|
|
75
|
+
## Changelog
|
76
|
+
|
77
|
+
### 0.2.2
|
78
|
+
User now has the option to configure the gem using a configuration file as well as with environment variables. Nexpose and Sourcefire options have been added to the configuration file.
|
79
|
+
|
80
|
+
Added an encryption configuration file. Usernames and passwords within the configuration file are now encrypted when the application runs.
|
81
|
+
|
82
|
+
Command line options have been added to the gem. Several are common to all Nexpose gem integrations. Call the gem with '-h' or '--help' to view these options.
|
83
|
+
|
84
|
+
*Breaking change*: Environment variables **NEXPOSE_URL** and **SOURCEFIRE_ADDR** have been renamed to **NEXPOSE_ADDRESS** and **SOURCEFIRE_ADDRESS** respectively.
|
85
|
+
|
86
|
+
### 0.2.1
|
87
|
+
Implemented batching of large datasets for uploading to Sourcefire.
|
88
|
+
|
89
|
+
### 0.2.0
|
90
|
+
Host OS information is now uploaded, if available.
|
91
|
+
|
92
|
+
### 0.1.0
|
93
|
+
Initial release.
|
94
|
+
|
data/bin/nexpose_sourcefire
CHANGED
@@ -1,41 +1,33 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
require 'sourcefire_connector'
|
3
|
-
require 'sourcefire/
|
3
|
+
require 'sourcefire/utilities/config_parser'
|
4
|
+
require 'sourcefire/utilities/nx_logger'
|
5
|
+
require 'sourcefire/utilities/gem_options'
|
4
6
|
require 'sourcefire/version'
|
5
|
-
require 'yaml'
|
6
7
|
|
7
8
|
#Set the encoding for external CSV files.
|
8
9
|
Encoding.default_external=Encoding.find("UTF-8")
|
9
10
|
|
10
|
-
CONFIG_PATH = File.join(File.dirname(__FILE__),
|
11
|
+
CONFIG_PATH = File.join(File.dirname(__FILE__),
|
12
|
+
'../lib/sourcefire/config/rapid7_sourcefire.config')
|
13
|
+
config_path = File.expand_path(CONFIG_PATH)
|
11
14
|
|
12
|
-
#
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
15
|
+
# Setup CLI Options
|
16
|
+
GemOptions.create_parser
|
17
|
+
.with_banner_and_options('nexpose_sourcefire')
|
18
|
+
.with_configuration_encryption([config_path])
|
19
|
+
.with_help_and_version('Nexpose SourceFire', Sourcefire::VERSION)
|
20
|
+
.parse
|
18
21
|
|
19
|
-
|
20
|
-
ENV['NEXPOSE_USERNAME'].nil? ||
|
21
|
-
ENV['NEXPOSE_PASSWORD'].nil?
|
22
|
-
raise 'Must configure SourceFire settings before starting' if ENV['SOURCEFIRE_ADDR'].nil? ||
|
23
|
-
ENV['SOURCEFIRE_PORT'].nil? ||
|
24
|
-
ENV['SOURCEFIRE_PKCS12_PASSWORD'].nil?
|
22
|
+
configuration_settings = ConfigParser.get_config(config_path)
|
25
23
|
|
26
24
|
log = Sourcefire::NxLogger.instance
|
27
|
-
log.setup_statistics_collection(Sourcefire::PRODUCT,
|
25
|
+
log.setup_statistics_collection(Sourcefire::PRODUCT,
|
26
|
+
Sourcefire::VENDOR,
|
27
|
+
Sourcefire::VERSION)
|
28
28
|
log.setup_logging(configuration_settings[:options][:logging_enabled],
|
29
29
|
configuration_settings[:options][:log_level])
|
30
30
|
|
31
|
-
configuration_settings[:nexpose_address] = ENV['NEXPOSE_URL']
|
32
|
-
configuration_settings[:nexpose_username] = ENV['NEXPOSE_USERNAME']
|
33
|
-
configuration_settings[:nexpose_password] = ENV['NEXPOSE_PASSWORD']
|
34
|
-
configuration_settings[:nexpose_port] = ENV['NEXPOSE_PORT']
|
35
|
-
configuration_settings[:sourcefire_address] = ENV['SOURCEFIRE_ADDR']
|
36
|
-
configuration_settings[:sourcefire_port] = ENV['SOURCEFIRE_PORT']
|
37
|
-
configuration_settings[:sourcefire_pkcs12_password] = ENV['SOURCEFIRE_PKCS12_PASSWORD']
|
38
|
-
|
39
31
|
# Initialize and start the integration
|
40
32
|
r7sfc = Sourcefire::Rapid7SourceFireConnector.new
|
41
33
|
r7sfc.setup(configuration_settings)
|
@@ -0,0 +1,20 @@
|
|
1
|
+
#
|
2
|
+
# Symmetric Encryption for Ruby
|
3
|
+
#
|
4
|
+
---
|
5
|
+
production:
|
6
|
+
# Since the encryption key must NOT be stored along with the
|
7
|
+
# source code, only store the key encryption key here.
|
8
|
+
private_rsa_key:
|
9
|
+
|
10
|
+
# List Symmetric Key Ciphers in the order of current / newest first
|
11
|
+
ciphers:
|
12
|
+
-
|
13
|
+
# Name of the file containing the encrypted key and iv.
|
14
|
+
key_filename: <absolute/path/to/filename>.key
|
15
|
+
iv_filename: <absolute/path/to/filename>.iv
|
16
|
+
|
17
|
+
cipher: aes-256-cbc
|
18
|
+
encoding: base64strict
|
19
|
+
version: 1
|
20
|
+
always_add_header: true
|
@@ -16,4 +16,25 @@
|
|
16
16
|
# Absolute location of the SourceFire pkcs12 file
|
17
17
|
:p12_location: '/an/absolute/location/file.pkcs12'
|
18
18
|
# Timeout in seconds. The number of seconds the GEM waits for a response from Nexpose before exiting.
|
19
|
-
:timeout: 10800
|
19
|
+
:timeout: 10800
|
20
|
+
:nexpose_options:
|
21
|
+
# (M) Nexpose console hostname.
|
22
|
+
:nexpose_address: 127.0.0.1
|
23
|
+
# (M) Nexpose username.
|
24
|
+
:nexpose_username: nxadmin
|
25
|
+
# (M) Nexpose password.
|
26
|
+
:nexpose_password: nxadmin
|
27
|
+
# (M) The port Nexpose listens on. Default is 3780
|
28
|
+
:nexpose_port: 3780
|
29
|
+
:sourcefire_options:
|
30
|
+
# (M) SourceFire Instance hostname.
|
31
|
+
:sourcefire_address: 127.0.0.1
|
32
|
+
# (M) The server port on which Sourcefire may be contacted. Default is 8307
|
33
|
+
:sourcefire_port: 8307
|
34
|
+
# (M) The password associated with the generated ‘.pkcs12’ file.
|
35
|
+
:sourcefire_pkcs12_password: password
|
36
|
+
# Encryption options
|
37
|
+
:encryption_options:
|
38
|
+
# (M) Path to the encryption.config file
|
39
|
+
:directory: ../../config/encryption.config
|
40
|
+
|
@@ -0,0 +1,141 @@
|
|
1
|
+
require 'erb'
|
2
|
+
require 'yaml'
|
3
|
+
require 'fileutils'
|
4
|
+
require 'symmetric-encryption'
|
5
|
+
|
6
|
+
class ConfigParser
|
7
|
+
ENCRYPTED_FORMAT = '<%%= SymmetricEncryption.try_decrypt "%s" %%>'
|
8
|
+
PLACEHOLDER = '<absolute/path/to/filename>'
|
9
|
+
# The environment to use, defined within the encryption config
|
10
|
+
STANZA = 'production'
|
11
|
+
# The line width of the YAML file before line-wrapping occurs
|
12
|
+
WIDTH = 120
|
13
|
+
|
14
|
+
# Encrypts a configuration file and returns the unencrypted hash.
|
15
|
+
def self.get_config(config_path, enc_path=nil)
|
16
|
+
# Try to load a path from the provided config
|
17
|
+
custom_enc_path = get_enc_directory(config_path)
|
18
|
+
enc_path = custom_enc_path unless custom_enc_path.nil?
|
19
|
+
|
20
|
+
enc_path = File.expand_path(enc_path, __FILE__)
|
21
|
+
config_path = File.expand_path(config_path)
|
22
|
+
|
23
|
+
|
24
|
+
generate_keys(enc_path, config_path)
|
25
|
+
encrypt_config(enc_path, config_path)
|
26
|
+
decrypt_config(enc_path, config_path)
|
27
|
+
end
|
28
|
+
|
29
|
+
# Writes the YAML to file with custom formatting options
|
30
|
+
def self.save_config(config_details, config_path)
|
31
|
+
yaml = config_details.to_yaml(line_width: WIDTH)
|
32
|
+
File.open(config_path, 'w') {|f| f.write yaml }
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.encrypt_field(value)
|
36
|
+
encrypted_value = SymmetricEncryption.encrypt value
|
37
|
+
ENCRYPTED_FORMAT % encrypted_value
|
38
|
+
end
|
39
|
+
|
40
|
+
# Retrieves the custom directory of the encryption config
|
41
|
+
def self.get_enc_directory(config_path)
|
42
|
+
settings = YAML.load_file(config_path)
|
43
|
+
return nil if settings[:encryption_options].nil?
|
44
|
+
|
45
|
+
enc_dir = settings[:encryption_options][:directory]
|
46
|
+
return nil if (enc_dir.nil? || enc_dir == '')
|
47
|
+
|
48
|
+
File.expand_path(enc_dir, __FILE__)
|
49
|
+
end
|
50
|
+
|
51
|
+
# Generates the RSA key, associated files and directories.
|
52
|
+
def self.generate_keys(enc_path, config_path)
|
53
|
+
settings = YAML.load_file(enc_path)
|
54
|
+
key = settings[STANZA]['private_rsa_key']
|
55
|
+
|
56
|
+
# Recognise an existing key
|
57
|
+
return unless (key.nil? || key == '')
|
58
|
+
|
59
|
+
# Generate a new RSA key and store the details
|
60
|
+
new_rsa_key = SymmetricEncryption::KeyEncryptionKey.generate
|
61
|
+
settings[STANZA]['private_rsa_key'] = new_rsa_key
|
62
|
+
save_config(settings, enc_path)
|
63
|
+
|
64
|
+
# Populate the placeholder values within the config
|
65
|
+
populate_ciphers(enc_path, config_path)
|
66
|
+
|
67
|
+
# Need to create a folder (specified by the user) to store the key files
|
68
|
+
dir = File.dirname(settings[STANZA]['ciphers'].first['key_filename'])
|
69
|
+
|
70
|
+
begin
|
71
|
+
unless File.directory?(dir) || PLACEHOLDER.include?(dir)
|
72
|
+
puts "Creating folder: #{dir}"
|
73
|
+
FileUtils::mkdir_p dir
|
74
|
+
end
|
75
|
+
rescue Exception => e
|
76
|
+
msg = "Unable to create the folders used to store encryption details.\n"\
|
77
|
+
'Please ensure the user has permissions to create folders in the ' \
|
78
|
+
"path specified in the encryption config: #{enc_path}\n"
|
79
|
+
handle_error(msg, e)
|
80
|
+
end
|
81
|
+
|
82
|
+
SymmetricEncryption.generate_symmetric_key_files(enc_path, STANZA)
|
83
|
+
end
|
84
|
+
|
85
|
+
# Replace placeholder values for the key and iv file paths,
|
86
|
+
# placing them in the config folder by default.
|
87
|
+
def self.populate_ciphers(enc_path, config_path)
|
88
|
+
settings = YAML.load_file(enc_path)
|
89
|
+
ciphers = settings[STANZA]['ciphers'].first
|
90
|
+
config_folder = File.dirname(config_path)
|
91
|
+
config_name = File.basename(config_path, File.extname(config_path))
|
92
|
+
|
93
|
+
%w(key iv).each do |file|
|
94
|
+
label = "#{file}_filename"
|
95
|
+
file_path = ciphers[label]
|
96
|
+
next unless file_path.include? PLACEHOLDER
|
97
|
+
|
98
|
+
filename = ".#{config_name}.#{file}"
|
99
|
+
ciphers[label] = File.join(config_folder, filename)
|
100
|
+
end
|
101
|
+
|
102
|
+
save_config(settings, enc_path)
|
103
|
+
end
|
104
|
+
|
105
|
+
def self.encrypt_config(enc_path, config_path)
|
106
|
+
SymmetricEncryption.load!(enc_path, STANZA)
|
107
|
+
|
108
|
+
# Read the config in as an array of strings
|
109
|
+
f = File.open(config_path)
|
110
|
+
config_lines = f.readlines
|
111
|
+
f.close
|
112
|
+
|
113
|
+
# Define the regex that can find relevant fields
|
114
|
+
regex = /^(?<label>\s*:?\w*(passw|pwd|user|usr)\w*:?\s)(?<value>.*)$/
|
115
|
+
|
116
|
+
# Line by line, write the line to file, encrypting sensitive fields
|
117
|
+
File.open(config_path, 'w+') do |f|
|
118
|
+
config_lines.each do |l|
|
119
|
+
matches = l.match(regex)
|
120
|
+
|
121
|
+
# Encrypt fields with username/password labels that are in plaintext
|
122
|
+
unless matches.nil? || matches['value'].include?('SymmetricEncryption')
|
123
|
+
l = "#{matches['label']}#{encrypt_field(matches['value'])}"
|
124
|
+
end
|
125
|
+
|
126
|
+
f.puts l
|
127
|
+
end
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
# Returns a hash containing the decrypted details from a config file.
|
132
|
+
def self.decrypt_config(enc_path, config_path)
|
133
|
+
SymmetricEncryption.load!(enc_path, STANZA)
|
134
|
+
return YAML.load(ERB.new(File.new(config_path).read).result)
|
135
|
+
end
|
136
|
+
|
137
|
+
def self.handle_error(message, error)
|
138
|
+
puts message
|
139
|
+
raise error
|
140
|
+
end
|
141
|
+
end
|
@@ -0,0 +1,91 @@
|
|
1
|
+
require 'optparse'
|
2
|
+
|
3
|
+
class GemOptions
|
4
|
+
|
5
|
+
@parser
|
6
|
+
|
7
|
+
def self.create_parser
|
8
|
+
@parser = OptionParser.new
|
9
|
+
self
|
10
|
+
end
|
11
|
+
|
12
|
+
# How the gem is used e.g 'nexpose ticketing jira [options]'
|
13
|
+
def self.with_banner(gem_usage_string)
|
14
|
+
@parser.banner = "Usage: #{gem_usage_string} [options]"
|
15
|
+
@parser.separator ''
|
16
|
+
self
|
17
|
+
end
|
18
|
+
|
19
|
+
# Header for options list
|
20
|
+
def self.with_options
|
21
|
+
@parser.separator 'Options:'
|
22
|
+
self
|
23
|
+
end
|
24
|
+
|
25
|
+
# Creates banner and options
|
26
|
+
def self.with_banner_and_options(gem_usage_string)
|
27
|
+
with_banner(gem_usage_string)
|
28
|
+
with_options
|
29
|
+
self
|
30
|
+
end
|
31
|
+
|
32
|
+
# For setting encryption switch. Can be set to work with two configurations
|
33
|
+
# Config_paths is an array
|
34
|
+
def self.with_configuration_encryption(config_paths, enc_path = nil)
|
35
|
+
@parser.on('-e',
|
36
|
+
'--encrypt_config',
|
37
|
+
'Encrypt the configuration file(s) without running the gem') do |e|
|
38
|
+
ConfigParser.get_config(config_paths.first, enc_path) unless enc_path.nil?
|
39
|
+
ConfigParser.get_config(config_paths.last)
|
40
|
+
puts "\nConfiguration File(s) Encrypted"
|
41
|
+
exit
|
42
|
+
end
|
43
|
+
self
|
44
|
+
end
|
45
|
+
|
46
|
+
def self.with_help
|
47
|
+
@parser.on_tail('-h', '--help', 'Show this message') do |h|
|
48
|
+
puts @parser
|
49
|
+
exit
|
50
|
+
end
|
51
|
+
self
|
52
|
+
end
|
53
|
+
|
54
|
+
def self.with_version(gem, version)
|
55
|
+
@parser.on_tail('--version', 'Version Information') do |v|
|
56
|
+
puts "#{gem} #{version}"
|
57
|
+
exit
|
58
|
+
end
|
59
|
+
self
|
60
|
+
end
|
61
|
+
|
62
|
+
def self.with_help_and_version(gem, version)
|
63
|
+
with_help
|
64
|
+
with_version(gem, version)
|
65
|
+
self
|
66
|
+
end
|
67
|
+
|
68
|
+
# Method to allow integrations to create own options, with both short and long
|
69
|
+
# switches and description.
|
70
|
+
# Handler is the block to run when option is called.
|
71
|
+
def self.with_other_option(short_switch, long_switch, description, &handler)
|
72
|
+
@parser.on("-#{short_switch}", "--#{long_switch}", description) do |opt|
|
73
|
+
handler.call
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
# Method to allow integrations to create own options, with only one size of
|
78
|
+
# switch and description.
|
79
|
+
# '-' for short switches and '--' for long switches is required.
|
80
|
+
# Handler is the block to run when option is called.
|
81
|
+
def self.with_single_switch_option(identifier, switch, description, &handler)
|
82
|
+
@parser.on("#{identifier}#{switch}", description) do |opt|
|
83
|
+
handler.call
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
# Parses the options to make them available
|
88
|
+
def self.parse
|
89
|
+
@parser.parse!
|
90
|
+
end
|
91
|
+
end
|
@@ -6,7 +6,7 @@ require 'singleton'
|
|
6
6
|
module Sourcefire
|
7
7
|
class NxLogger
|
8
8
|
include Singleton
|
9
|
-
LOG_PATH = "
|
9
|
+
LOG_PATH = "../logs/rapid7_%s.log"
|
10
10
|
KEY_FORMAT = "external.integration.%s"
|
11
11
|
PRODUCT_FORMAT = "%s_%s"
|
12
12
|
|
@@ -163,4 +163,4 @@ module Sourcefire
|
|
163
163
|
end
|
164
164
|
|
165
165
|
end
|
166
|
-
end
|
166
|
+
end
|
data/lib/sourcefire/version.rb
CHANGED
data/lib/sourcefire_connector.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
1
|
+
require 'sourcefire/utilities/nx_logger'
|
2
|
+
require 'sourcefire/p12_utils'
|
3
|
+
require 'sourcefire/nexpose_helper'
|
4
4
|
require 'openssl'
|
5
5
|
require 'socket'
|
6
6
|
require 'csv'
|
@@ -9,8 +9,21 @@ module Sourcefire
|
|
9
9
|
class Rapid7SourceFireConnector
|
10
10
|
|
11
11
|
def setup(config_options)
|
12
|
-
@config =
|
12
|
+
@config = {}
|
13
13
|
@log = Sourcefire::NxLogger.instance
|
14
|
+
set_variables(config_options[:nexpose_options])
|
15
|
+
set_variables(config_options[:sourcefire_options])
|
16
|
+
@config[:options] = config_options[:options]
|
17
|
+
|
18
|
+
if @config[:nexpose_address].nil? || @config[:nexpose_username].nil? ||
|
19
|
+
@config[:nexpose_password].nil?
|
20
|
+
raise 'Must configure Nexpose settings before starting'
|
21
|
+
end
|
22
|
+
|
23
|
+
if @config[:sourcefire_address].nil? || @config[:sourcefire_port].nil? ||
|
24
|
+
@config[:sourcefire_pkcs12_password].nil?
|
25
|
+
raise 'Must configure SourceFire settings before starting'
|
26
|
+
end
|
14
27
|
end
|
15
28
|
|
16
29
|
def start
|
@@ -19,15 +32,16 @@ module Sourcefire
|
|
19
32
|
# Create a new Nexpose connection
|
20
33
|
nxro = Sourcefire::ReportOps.new
|
21
34
|
nxro.login(@config[:nexpose_address],@config[:nexpose_username],
|
22
|
-
|
23
|
-
|
35
|
+
@config[:nexpose_password], @config[:options][:timeout],
|
36
|
+
@config[:nexpose_port])
|
24
37
|
|
25
38
|
#Generate the required data from Nexpose
|
26
39
|
time = Time.now.to_i
|
27
40
|
report_file = File.open("nexpose_report_#{time}.csv", 'w')
|
28
41
|
puts "Site ID: #{@config[:options][:sites].join(', ')}"
|
29
42
|
puts 'Generating report.'
|
30
|
-
nxro.generate_sourcefire_nexpose_report(report_file,
|
43
|
+
nxro.generate_sourcefire_nexpose_report(report_file,
|
44
|
+
@config[:options][:sites])
|
31
45
|
puts 'Report generation complete.'
|
32
46
|
|
33
47
|
#Process the Nexpose results.report("name:") { TESTS.times { } }ort into SourceFire format
|
@@ -49,6 +63,15 @@ module Sourcefire
|
|
49
63
|
@log.log_message('Finished processing. Exiting...')
|
50
64
|
end
|
51
65
|
|
66
|
+
def set_variables(options)
|
67
|
+
options.each_key do |key|
|
68
|
+
value = ENV[key.to_s.upcase]
|
69
|
+
value ||= options[key]
|
70
|
+
@log.log_message('No configuration value found for #{key}') if value.nil?
|
71
|
+
@config[key] = value
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
52
75
|
def get_assets(report_file)
|
53
76
|
assets = []
|
54
77
|
current_asset = nil
|
@@ -305,6 +328,6 @@ module Sourcefire
|
|
305
328
|
retry
|
306
329
|
end
|
307
330
|
end
|
308
|
-
end
|
331
|
+
end
|
309
332
|
end
|
310
333
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nexpose_sourcefire
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- JJ Cassidy
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2017-05-30 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: bundler
|
@@ -46,14 +46,34 @@ dependencies:
|
|
46
46
|
requirements:
|
47
47
|
- - "~>"
|
48
48
|
- !ruby/object:Gem::Version
|
49
|
-
version: '
|
49
|
+
version: '3.2'
|
50
50
|
type: :runtime
|
51
51
|
prerelease: false
|
52
52
|
version_requirements: !ruby/object:Gem::Requirement
|
53
53
|
requirements:
|
54
54
|
- - "~>"
|
55
55
|
- !ruby/object:Gem::Version
|
56
|
-
version: '
|
56
|
+
version: '3.2'
|
57
|
+
- !ruby/object:Gem::Dependency
|
58
|
+
name: symmetric-encryption
|
59
|
+
requirement: !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
61
|
+
- - "~>"
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: '3.9'
|
64
|
+
- - ">="
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: 3.9.0
|
67
|
+
type: :runtime
|
68
|
+
prerelease: false
|
69
|
+
version_requirements: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
|
+
- - "~>"
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: '3.9'
|
74
|
+
- - ">="
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: 3.9.0
|
57
77
|
description: This GEM allows enables the importing of Nexpose host and vulnerability
|
58
78
|
data into SourceFire
|
59
79
|
email:
|
@@ -69,11 +89,14 @@ files:
|
|
69
89
|
- README.md
|
70
90
|
- Rakefile
|
71
91
|
- bin/nexpose_sourcefire
|
92
|
+
- lib/sourcefire/config/encryption.config
|
72
93
|
- lib/sourcefire/config/rapid7_sourcefire.config
|
73
94
|
- lib/sourcefire/nexpose_helper.rb
|
74
|
-
- lib/sourcefire/nx_logger.rb
|
75
95
|
- lib/sourcefire/p12_utils.rb
|
76
96
|
- lib/sourcefire/queries.rb
|
97
|
+
- lib/sourcefire/utilities/config_parser.rb
|
98
|
+
- lib/sourcefire/utilities/gem_options.rb
|
99
|
+
- lib/sourcefire/utilities/nx_logger.rb
|
77
100
|
- lib/sourcefire/version.rb
|
78
101
|
- lib/sourcefire_connector.rb
|
79
102
|
homepage: http://www.rapid7.com
|
@@ -96,9 +119,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
96
119
|
version: '0'
|
97
120
|
requirements: []
|
98
121
|
rubyforge_project:
|
99
|
-
rubygems_version: 2.
|
122
|
+
rubygems_version: 2.5.1
|
100
123
|
signing_key:
|
101
124
|
specification_version: 4
|
102
125
|
summary: Nexpose SourceFire Integration GEM
|
103
126
|
test_files: []
|
104
|
-
has_rdoc:
|