avs 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/Gemfile +2 -0
- data/Gemfile.lock +31 -0
- data/README.adoc +162 -0
- data/Rakefile +21 -0
- data/avs.gemspec +22 -0
- data/lib/asset/command.rb +74 -0
- data/lib/asset/model.rb +71 -0
- data/lib/avs/version.rb +3 -0
- data/lib/avs.rb +5 -0
- data/test/default_test.rb +14 -0
- data/test/test_helper.rb +4 -0
- metadata +28 -3
- data/README.rdoc +0 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e3d8707cf431524fd229b1214e8b9fa6e04e79355679917afa9999d5f9b4b54b
|
4
|
+
data.tar.gz: b8ad24e89a29dc34ceedfb2eec8c16b6b49f38793dca9c5e33b3000e5f9eef03
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1bfaca46b315a65f95364f29d977fa7f62e3ff7016b236f6a432a9f73cf098ed64d633800e4c7a1acbbb66043bd39a42052c2b53aa8070450493a7454f82a830
|
7
|
+
data.tar.gz: e965e76ae0b0da5416368d75b924f149c86449f52027825f37b5ed43e8923e9029f4c094a1531a6c5210c0a2bf3e3f7318872ade05bdbb2b369bf9c349ae4c2b
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
avs (0.0.2)
|
5
|
+
gli (~> 2.21.1)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
bump (0.10.0)
|
11
|
+
gli (2.21.1)
|
12
|
+
minitest (5.22.3)
|
13
|
+
psych (5.1.2)
|
14
|
+
stringio
|
15
|
+
rake (13.1.0)
|
16
|
+
rdoc (6.6.2)
|
17
|
+
psych (>= 4.0.0)
|
18
|
+
stringio (3.1.0)
|
19
|
+
|
20
|
+
PLATFORMS
|
21
|
+
arm64-darwin-21
|
22
|
+
|
23
|
+
DEPENDENCIES
|
24
|
+
avs!
|
25
|
+
bump
|
26
|
+
minitest
|
27
|
+
rake
|
28
|
+
rdoc
|
29
|
+
|
30
|
+
BUNDLED WITH
|
31
|
+
2.4.8
|
data/README.adoc
ADDED
@@ -0,0 +1,162 @@
|
|
1
|
+
= avs
|
2
|
+
Christian Kyony <ckyony@changamuka.com>
|
3
|
+
v0.0.1, 2024-03.14
|
4
|
+
|
5
|
+
:uri-freesoftware: https://www.gnu.org/philosophy/free-sw.html
|
6
|
+
|
7
|
+
|
8
|
+
|
9
|
+
|
10
|
+
== For security engineers
|
11
|
+
who need to interact with a Rapid7 Nexpose console,
|
12
|
+
the *avs* gem is a command line utility
|
13
|
+
that manage (e.g. create, list, update, and remove) the following entities:
|
14
|
+
- sites,
|
15
|
+
- scans,
|
16
|
+
- assets,
|
17
|
+
- asset groups,
|
18
|
+
- reports,
|
19
|
+
- vulnerabilities
|
20
|
+
- etc...
|
21
|
+
|
22
|
+
|
23
|
+
|
24
|
+
== Personal scratch
|
25
|
+
|
26
|
+
I need to automate the creation of hundreds sites and reports.
|
27
|
+
|
28
|
+
|
29
|
+
== Installation
|
30
|
+
|
31
|
+
Simply run the command below
|
32
|
+
|
33
|
+
----
|
34
|
+
$ gem install avs
|
35
|
+
----
|
36
|
+
|
37
|
+
|
38
|
+
== Usage
|
39
|
+
|
40
|
+
You can get help on available commands.
|
41
|
+
|
42
|
+
----
|
43
|
+
NAME
|
44
|
+
nsc - CLI to interface with Nexpose Security Console
|
45
|
+
|
46
|
+
SYNOPSIS
|
47
|
+
nsc [global options] command [command options] [arguments...]
|
48
|
+
|
49
|
+
VERSION
|
50
|
+
0.0.2
|
51
|
+
|
52
|
+
GLOBAL OPTIONS
|
53
|
+
--help - Show this message
|
54
|
+
--version - Display the program version
|
55
|
+
|
56
|
+
COMMANDS
|
57
|
+
assets - Manage assets
|
58
|
+
bulk_delete - Bulk delete assets with unknown OS
|
59
|
+
connect, login - Verify connection to the server
|
60
|
+
groups - Manage asset groups
|
61
|
+
help - Shows a list of commands or help for one command
|
62
|
+
reports - Manage reports
|
63
|
+
sites - Manage sites
|
64
|
+
----
|
65
|
+
|
66
|
+
// List all active scans
|
67
|
+
//
|
68
|
+
// nsc scan list
|
69
|
+
//
|
70
|
+
// Run an adhoc sql query and export via csv
|
71
|
+
//
|
72
|
+
// nsc reports --sql "select * from dim_asset"
|
73
|
+
//
|
74
|
+
// or for more complex sql queries, put the sql into a file and run
|
75
|
+
//
|
76
|
+
// nsc reports --sqlfile ./new_assets.sql
|
77
|
+
//
|
78
|
+
//
|
79
|
+
// List all reports defined
|
80
|
+
//
|
81
|
+
// nsc reports
|
82
|
+
//
|
83
|
+
// Request the console's version details
|
84
|
+
//
|
85
|
+
// nsc console commands "ver"
|
86
|
+
//
|
87
|
+
// Run an adhoc scan for a single ip or network cidr-noted range ( --id )
|
88
|
+
//
|
89
|
+
// nsc scans create --range 192.168.42.103/32
|
90
|
+
//
|
91
|
+
// how to add a new custom role for configuration within the console ui, based on a copy of existinsc role
|
92
|
+
//
|
93
|
+
// nsc roles -n security-manager --description "New Role Name" --newname new-short-name
|
94
|
+
//
|
95
|
+
// how to add a new user, with default password of "nxpassword" until moved to yaml config is supported
|
96
|
+
//
|
97
|
+
// nsc users create --name <username> --fullname "Full Name"
|
98
|
+
//
|
99
|
+
// how to export packaged scan data in a single zip file
|
100
|
+
//
|
101
|
+
// nsc scan --update --scanpath ./ --action export --id <scan id>
|
102
|
+
//
|
103
|
+
|
104
|
+
== Configuration
|
105
|
+
|
106
|
+
----
|
107
|
+
# ~/lab.yaml consists of the following:
|
108
|
+
|
109
|
+
config:
|
110
|
+
server: 10.10.10.10
|
111
|
+
port: 3780
|
112
|
+
user: nxuser
|
113
|
+
password: password
|
114
|
+
----
|
115
|
+
|
116
|
+
|
117
|
+
== Development
|
118
|
+
|
119
|
+
Checkout the github repository
|
120
|
+
|
121
|
+
git clone https://github.com/rhc/avs
|
122
|
+
|
123
|
+
Access the source code folder directory.
|
124
|
+
|
125
|
+
$ cd avs
|
126
|
+
|
127
|
+
Install dependencies
|
128
|
+
|
129
|
+
bin/setup
|
130
|
+
|
131
|
+
Run the tests
|
132
|
+
|
133
|
+
rake test
|
134
|
+
|
135
|
+
Experiment with the code under development
|
136
|
+
|
137
|
+
run bin/console
|
138
|
+
|
139
|
+
Install this gem onto your local machine
|
140
|
+
|
141
|
+
bundle exec rake install
|
142
|
+
|
143
|
+
Release a new version
|
144
|
+
|
145
|
+
gem bump
|
146
|
+
gem release
|
147
|
+
|
148
|
+
== Contributing
|
149
|
+
|
150
|
+
In the spirit of {uri-freesoftware}[free software],
|
151
|
+
everyone is encouraged to help improve this project.
|
152
|
+
|
153
|
+
If you discover errors or omissions in the source code, documentation, or website content,
|
154
|
+
please don’t hesitate to submit an issue or open a pull request with a fix. New contributors are always welcome!
|
155
|
+
|
156
|
+
== License
|
157
|
+
|
158
|
+
The gem is available as open source under the terms of the
|
159
|
+
http://opensource.org/licenses/MIT[MIT License].
|
160
|
+
|
161
|
+
|
162
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'rake/clean'
|
2
|
+
require 'rubygems'
|
3
|
+
require 'rubygems/package_task'
|
4
|
+
require 'rdoc/task'
|
5
|
+
Rake::RDocTask.new do |rd|
|
6
|
+
rd.main = "README.rdoc"
|
7
|
+
rd.rdoc_files.include("README.rdoc","lib/**/*.rb","bin/**/*")
|
8
|
+
rd.title = 'Your application title'
|
9
|
+
end
|
10
|
+
|
11
|
+
spec = eval(File.read('avs.gemspec'))
|
12
|
+
|
13
|
+
Gem::PackageTask.new(spec) do |pkg|
|
14
|
+
end
|
15
|
+
require 'rake/testtask'
|
16
|
+
Rake::TestTask.new do |t|
|
17
|
+
t.libs << "test"
|
18
|
+
t.test_files = FileList['test/*_test.rb']
|
19
|
+
end
|
20
|
+
|
21
|
+
task :default => :test
|
data/avs.gemspec
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# Ensure we require the local version and not one we might have installed already
|
2
|
+
require File.join([File.dirname(__FILE__),'lib','avs','version.rb'])
|
3
|
+
spec = Gem::Specification.new do |s|
|
4
|
+
s.name = 'avs'
|
5
|
+
s.version = Avs::VERSION
|
6
|
+
s.author = 'Christian Kyony'
|
7
|
+
s.email = 'ckyony@changamuka.com'
|
8
|
+
s.homepage = 'http://your.website.com'
|
9
|
+
s.platform = Gem::Platform::RUBY
|
10
|
+
s.summary = 'A description of your project'
|
11
|
+
s.files = `git ls-files`.split(" ")
|
12
|
+
s.require_paths << 'lib'
|
13
|
+
s.extra_rdoc_files = ['README.adoc','avs.rdoc']
|
14
|
+
s.rdoc_options << '--title' << 'avs' << '--main' << 'README.rdoc' << '-ri'
|
15
|
+
s.bindir = 'bin'
|
16
|
+
s.executables << 'avs'
|
17
|
+
s.add_development_dependency('bump')
|
18
|
+
s.add_development_dependency('rake')
|
19
|
+
s.add_development_dependency('rdoc')
|
20
|
+
s.add_development_dependency('minitest')
|
21
|
+
s.add_runtime_dependency('gli','~> 2.21.1')
|
22
|
+
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
require_relative 'model'
|
2
|
+
|
3
|
+
# Reopen the App class or module to add the 'asset' command
|
4
|
+
class App
|
5
|
+
extend GLI::App
|
6
|
+
|
7
|
+
desc 'Describe asset here'
|
8
|
+
arg_name 'Describe arguments to asset here'
|
9
|
+
command :asset do |c|
|
10
|
+
c.desc 'Describe a switch to asset'
|
11
|
+
c.switch :s
|
12
|
+
|
13
|
+
c.desc 'Describe a flag to asset'
|
14
|
+
c.default_value 'default'
|
15
|
+
c.flag :f
|
16
|
+
c.action do |_global_options, _options, _args|
|
17
|
+
# Your command logic specific to 'asset' here
|
18
|
+
assets = [
|
19
|
+
CmdbAsset.new(
|
20
|
+
id: 100,
|
21
|
+
country_code: 'cd',
|
22
|
+
business_unit: 'bu',
|
23
|
+
sub_area: 'sa',
|
24
|
+
application: 'ewallet',
|
25
|
+
utr: 'UTR01966',
|
26
|
+
fqdn: 'fqdn.co.za',
|
27
|
+
host_name: 'fqdn',
|
28
|
+
ip_address: '172.16.19.66',
|
29
|
+
operating_system: 'ubuntu',
|
30
|
+
server_environment: 'linux',
|
31
|
+
server_category: 'linux',
|
32
|
+
host_key: 'xxxx',
|
33
|
+
country: 'DRC'
|
34
|
+
),
|
35
|
+
CmdbAsset.new(
|
36
|
+
id: 200,
|
37
|
+
country_code: 'mw',
|
38
|
+
business_unit: 'bu',
|
39
|
+
sub_area: 'sa',
|
40
|
+
application: 'atm',
|
41
|
+
utr: 'UTR01966',
|
42
|
+
fqdn: 'fqdn.co.za',
|
43
|
+
host_name: 'fqdn',
|
44
|
+
ip_address: '198.172.19.66',
|
45
|
+
operating_system: 'ubuntu',
|
46
|
+
server_environment: 'linux',
|
47
|
+
server_category: 'linux',
|
48
|
+
host_key: 'xxxx',
|
49
|
+
country: 'Malawi'
|
50
|
+
),
|
51
|
+
CmdbAsset.new(
|
52
|
+
id: 300,
|
53
|
+
country_code: 'bw',
|
54
|
+
business_unit: 'bu',
|
55
|
+
sub_area: 'sa',
|
56
|
+
application: 'forex',
|
57
|
+
utr: 'UTR01986',
|
58
|
+
fqdn: 'fqdn.co.za',
|
59
|
+
host_name: 'fqdn',
|
60
|
+
ip_address: '10.12.19.66',
|
61
|
+
operating_system: 'ubuntu',
|
62
|
+
server_environment: 'linux',
|
63
|
+
server_category: 'linux',
|
64
|
+
host_key: 'xxxx',
|
65
|
+
country: 'Botswana'
|
66
|
+
)
|
67
|
+
]
|
68
|
+
puts 'list assets'
|
69
|
+
assets.each do |asset|
|
70
|
+
puts asset
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
data/lib/asset/model.rb
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
class CmdbAsset
|
2
|
+
attr_accessor :id,
|
3
|
+
:country_code,
|
4
|
+
:business_unit,
|
5
|
+
:sub_area,
|
6
|
+
:application,
|
7
|
+
:utr,
|
8
|
+
:fqdn,
|
9
|
+
:host_name,
|
10
|
+
:ip_address,
|
11
|
+
:operating_system,
|
12
|
+
:server_environment,
|
13
|
+
:server_category,
|
14
|
+
:host_key,
|
15
|
+
:country
|
16
|
+
|
17
|
+
def initialize(id:,
|
18
|
+
country_code:,
|
19
|
+
business_unit:,
|
20
|
+
sub_area:,
|
21
|
+
application:,
|
22
|
+
utr:,
|
23
|
+
fqdn:,
|
24
|
+
host_name:,
|
25
|
+
ip_address:,
|
26
|
+
operating_system:,
|
27
|
+
server_environment:,
|
28
|
+
server_category:,
|
29
|
+
host_key:,
|
30
|
+
country:)
|
31
|
+
@id = id
|
32
|
+
@country_code = country_code
|
33
|
+
@business_unit = business_unit
|
34
|
+
@sub_area = sub_area
|
35
|
+
@application = application
|
36
|
+
@utr = utr
|
37
|
+
@fqdn = fqdn
|
38
|
+
@host_name = host_name
|
39
|
+
@ip_address = ip_address
|
40
|
+
@operating_system = operating_system
|
41
|
+
@server_category = server_category
|
42
|
+
@server_environment = server_environment
|
43
|
+
@host_key = host_key
|
44
|
+
@country = country
|
45
|
+
end
|
46
|
+
|
47
|
+
def site_name
|
48
|
+
['', country_code, business_unit, sub_area, application, utr].join(':')
|
49
|
+
end
|
50
|
+
|
51
|
+
def self.from_csv(row)
|
52
|
+
CmdbAsset.new(id: row[:id],
|
53
|
+
country_code: row[:country_code],
|
54
|
+
country: row[:country],
|
55
|
+
business_unit: row[:business_unit],
|
56
|
+
sub_area: row[:sub_area],
|
57
|
+
application: row[:application],
|
58
|
+
utr: row[:utr],
|
59
|
+
fqdn: row[:fqdn],
|
60
|
+
ip_address: row[:ip_address],
|
61
|
+
host_name: row[:host_name],
|
62
|
+
host_key: row[:host_key],
|
63
|
+
operating_system: row[:operating_system],
|
64
|
+
server_environment: row[:server_environment],
|
65
|
+
server_category: row[:server_category])
|
66
|
+
end
|
67
|
+
|
68
|
+
def to_s
|
69
|
+
[id, site_name, fqdn, ip_address].join ','
|
70
|
+
end
|
71
|
+
end
|
data/lib/avs/version.rb
ADDED
data/lib/avs.rb
ADDED
data/test/test_helper.rb
ADDED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: avs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Christian Kyony
|
@@ -10,6 +10,20 @@ bindir: bin
|
|
10
10
|
cert_chain: []
|
11
11
|
date: 2024-03-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bump
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: rake
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -72,12 +86,23 @@ executables:
|
|
72
86
|
- avs
|
73
87
|
extensions: []
|
74
88
|
extra_rdoc_files:
|
75
|
-
- README.
|
89
|
+
- README.adoc
|
76
90
|
- avs.rdoc
|
77
91
|
files:
|
78
|
-
-
|
92
|
+
- ".gitignore"
|
93
|
+
- Gemfile
|
94
|
+
- Gemfile.lock
|
95
|
+
- README.adoc
|
96
|
+
- Rakefile
|
97
|
+
- avs.gemspec
|
79
98
|
- avs.rdoc
|
80
99
|
- bin/avs
|
100
|
+
- lib/asset/command.rb
|
101
|
+
- lib/asset/model.rb
|
102
|
+
- lib/avs.rb
|
103
|
+
- lib/avs/version.rb
|
104
|
+
- test/default_test.rb
|
105
|
+
- test/test_helper.rb
|
81
106
|
homepage: http://your.website.com
|
82
107
|
licenses: []
|
83
108
|
metadata: {}
|