norad_cli 0.1.0 → 0.1.1

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: f67e3b7d29e50815d288e17ba88cf0791e5cc808
4
- data.tar.gz: b1b7675b3bab7237fc7cfa9b094181d9918cbb29
3
+ metadata.gz: 9f317f6169f280d37dcf3f342361e7c4254f5599
4
+ data.tar.gz: 942032c69b1630bebd3107617799abda9e1a713f
5
5
  SHA512:
6
- metadata.gz: 24c52f33dd524c6057465193569229968f3eb90e48963a530919191450e91b504d6112bfaacbad903e95259d61590eb72ed6e35e4911884a9d6b692948c0c2ec
7
- data.tar.gz: bf5fb027e9df8357164c6c9971b24a5db7077ed822fcb5d7eff24220199028f061811e247923fc82b35e9ece3121bd06f246225aecb659c9dd2beee27472d2e6
6
+ metadata.gz: ba8692954a43ba7fb99e902e8f8d6351f696f3f448d988aecf58a857f4c3b8f4c6ee807670dd5dd9bf12dfcf4b20523baa690659c45ed5cad278519584fe65a4
7
+ data.tar.gz: dce51da0d3e7daffe7e306885fb19b4d5f565ff46884f309bc92ca1b48b0c18fe4d0430a99e430ee31414bedf56206f847d0bdad2b5d975049b446f553218f1b
data/.gitlab-ci.yml CHANGED
@@ -4,7 +4,7 @@ stages:
4
4
  # - behavior_test
5
5
  - release
6
6
 
7
- image: ruby:2.3.3
7
+ image: ruby:2.4.0
8
8
 
9
9
  cache:
10
10
  key: "$CI_BUILD_NAME"
data/.rubocop.yml CHANGED
@@ -1,5 +1,5 @@
1
1
  AllCops:
2
- TargetRubyVersion: 2.3
2
+ TargetRubyVersion: 2.4
3
3
  DisplayCopNames: true
4
4
  Exclude:
5
5
  - 'lib/norad_cli/templates/spec/**/*'
@@ -32,3 +32,6 @@ Security/YAMLLoad:
32
32
  Exclude:
33
33
  - 'lib/norad_cli/support/manifest.rb'
34
34
  - 'lib/norad_cli/support/api_security_container_seed_script.rb'
35
+ Performance/RegexpMatch:
36
+ Exclude:
37
+ - 'lib/norad_cli/cli/sectest.rb'
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.3.3
1
+ 2.4.0
@@ -20,7 +20,7 @@ class Repo < Thor
20
20
  Git.init(repo_name)
21
21
 
22
22
  # Create the necessary directories
23
- %w(base spec).each do |dirrepo_name|
23
+ %w(base spec sectests).each do |dirrepo_name|
24
24
  empty_directory "#{repo_name}/#{dirrepo_name}"
25
25
  end
26
26
 
@@ -13,16 +13,16 @@ class Sectest < Thor
13
13
  end
14
14
 
15
15
  desc 'scaffold TESTNAME', 'Create a new security test with standard files + testing'
16
- option :test_type, default: 'whole_host', desc: 'The security test type, Options: [authenticated|web_application|brute_force|ssl_crypto|ssh_crypto|whole_host]'
17
- option :registry, default: 'norad-registry.cisco.com:5000', desc: 'The Docker registry to store docker images'
18
- option :version, default: 'latest', desc: 'The version of the security test'
19
- option :base_image, default: 'norad-registry.cisco.com:5000/norad:0.0.1', desc: 'Base Docker image to use (i.e. FROM field in the DOckerfile)'
20
- option :authenticated, type: :boolean, default: false, desc: 'Does the security test require authenticating to the unit under test'
21
- option :configurable, type: :boolean, default: false, desc: 'Is the security test configurable (e.g. Qualys username and password)'
16
+ option :test_type, aliases: '-t', default: 'whole_host', desc: 'The security test type, Options: [authenticated|web_application|brute_force|ssl_crypto|ssh_crypto|whole_host]'
17
+ option :registry, aliases: '-r', default: 'norad-registry.cisco.com:5000', desc: 'The Docker registry to store docker images'
18
+ option :version, aliases: '-v', default: 'latest', desc: 'The version of the security test'
19
+ option :base_image, aliases: '-b', default: 'norad-registry.cisco.com:5000/norad:0.0.1', desc: 'Base Docker image to use (i.e. FROM field in the Dockerfile)'
20
+ option :configurable, type: :boolean, aliases: '-c', desc: 'Is the security test configurable (e.g. Qualys username and password)'
22
21
  def scaffold(sectest_name)
23
22
  # Grab the current directory
24
23
  repo_dir = Dir.pwd
25
24
 
25
+ puts options[:configurable]
26
26
  # Set options for templates
27
27
  options[:name] = sectest_name
28
28
  options[:spec_class_name] = sectest_name.split('-').map { |t| t =~ /\d+/ ? t : t.capitalize! }.join
@@ -30,16 +30,16 @@ class Sectest < Thor
30
30
  # Error check to ensure this is a norad security test repository
31
31
 
32
32
  # Create the security tests standard files
33
- template('tool/Dockerfile.erb', "#{repo_dir}/#{sectest_name}/Dockerfile")
34
- template('tool/README.md.erb', "#{repo_dir}/#{sectest_name}/README.md")
35
- template('tool/manifest.yml.erb', "#{repo_dir}/#{sectest_name}/manifest.yml")
33
+ template('tool/Dockerfile.erb', "#{repo_dir}/sectests/#{sectest_name}/Dockerfile")
34
+ template('tool/README.md.erb', "#{repo_dir}/sectests/#{sectest_name}/README.md")
35
+ template('tool/manifest.yml.erb', "#{repo_dir}/sectests/#{sectest_name}/manifest.yml")
36
36
 
37
37
  # Create a starter wrapper script
38
- template('tool/wrapper.rb.erb', "#{repo_dir}/#{sectest_name}/#{sectest_name}-wrapper.rb")
38
+ template('tool/wrapper.rb.erb', "#{repo_dir}/sectests/#{sectest_name}/#{sectest_name}-wrapper.rb")
39
39
 
40
40
  # Create the spec files
41
41
  template('tool/tool_spec.rb.erb', "#{repo_dir}/spec/#{sectest_name}/#{sectest_name}_spec.rb")
42
- if options[:authenticated]
42
+ if options[:test_type] == 'authenticated'
43
43
  template('tool/Dockerfile.auth.target.erb', "#{repo_dir}/spec/#{sectest_name}/targets/Dockerfile.secure")
44
44
  template('tool/Dockerfile.auth.target.erb', "#{repo_dir}/spec/#{sectest_name}/targets/Dockerfile.vulnerable")
45
45
  else
@@ -48,13 +48,26 @@ class Sectest < Thor
48
48
  end
49
49
  end
50
50
 
51
+ desc 'build', 'Build all sectest images and specs for the entire repository'
52
+ option :registry, aliases: '-r', default: 'norad-registry.cisco.com:5000', desc: 'The Docker registry for Docker images'
53
+ option :version, aliases: '-v', default: 'latest', desc: 'The version of the sectest container to build'
54
+ def build
55
+ # Error check to ensure this is a plugin directory
56
+ Dir.glob('sectests/*').select do |f|
57
+ if File.directory? f
58
+ # Build all for the sectest
59
+ send('build:all', f.split('/')[-1])
60
+ end
61
+ end
62
+ end
63
+
51
64
  # Define arguments and options
52
- desc 'build SECTESTNAME', 'Builds the docker image for the security test SECTESTNAME'
53
- option :registry, default: 'norad-registry.cisco.com:5000', desc: 'The Docker registry for Docker images'
54
- option :version, default: 'latest', desc: 'The version of the sectest container to build'
55
- def build(name)
65
+ desc 'build:image SECTESTNAME', 'Build the docker image for the security test SECTESTNAME'
66
+ option :registry, aliases: '-r', default: 'norad-registry.cisco.com:5000', desc: 'The Docker registry for Docker images'
67
+ option :version, aliases: '-v', default: 'latest', desc: 'The version of the sectest container to build'
68
+ define_method 'build:image' do |name|
56
69
  imgs_to_build = {}
57
- imgs_to_build[name.to_s] = "#{options[:registry]}/#{name}:#{options[:version]}"
70
+ imgs_to_build["sectests/#{name}"] = "#{options[:registry]}/#{name}:#{options[:version]}"
58
71
 
59
72
  # Check for the Dockerfile
60
73
  if !dockerfile?(imgs_to_build.keys[0])
@@ -80,9 +93,9 @@ class Sectest < Thor
80
93
  end
81
94
 
82
95
  # Define arguments and options
83
- desc 'build:specs SECTESTNAME', 'Builds the spec images for the security test SECTESTNAME'
84
- option :registry, default: 'norad-registry.cisco.com:5000', desc: 'The Docker registry for Docker images'
85
- option :version, default: 'latest', desc: 'The version of the sectest container to build'
96
+ desc 'build:specs SECTESTNAME', 'Build the spec images (test images) for the security test SECTESTNAME'
97
+ option :registry, aliases: '-r', default: 'norad-registry.cisco.com:5000', desc: 'The Docker registry for Docker images'
98
+ option :version, aliases: '-v', default: 'latest', desc: 'The version of the sectest container to build'
86
99
  define_method 'build:specs' do |name|
87
100
  imgs_to_build = {}
88
101
  imgs_to_build["#{File.expand_path(File.dirname(__FILE__))}/../templates/spec/support/Dockerfile.testserver"] = 'docker-images-test-results-server:latest'
@@ -109,21 +122,21 @@ class Sectest < Thor
109
122
  end
110
123
 
111
124
  # Define arguments and options
112
- desc 'build:all SECTESTNAME', 'Builds all images for security test SECTESTNAME'
113
- option :registry, default: 'norad-registry.cisco.com:5000', desc: 'The Docker registry for Docker images'
114
- option :version, default: 'latest', desc: 'The version of the sectest container to build'
125
+ desc 'build:all SECTESTNAME', 'Build sectest images for SECTESTNAME and all testing images for SECTESTNAME'
126
+ option :registry, aliases: '-r', default: 'norad-registry.cisco.com:5000', desc: 'The Docker registry for Docker images'
127
+ option :version, aliases: '-v', default: 'latest', desc: 'The version of the sectest container to build'
115
128
  define_method 'build:all' do |name|
116
- # Build the tool
117
- build(name)
129
+ # Build the sectest image
130
+ send('build:image', name)
118
131
 
119
- # Build the specs for testing
132
+ # Build the specs for testing the sectest
120
133
  send('build:specs', name)
121
134
  end
122
135
 
123
136
  # Define arguments and options
124
137
  desc 'execute SECTESTNAME ARGUMENTS', 'Executes the specified security test SECTESTNAME w/ ARGUMENTS'
125
- option :registry, default: 'norad-registry.cisco.com:5000', desc: 'The Docker registry for Docker images'
126
- option :version, default: 'latest', desc: 'The version of the tools docker container to build'
138
+ option :registry, aliases: '-r', default: 'norad-registry.cisco.com:5000', desc: 'The Docker registry for Docker images'
139
+ option :version, aliases: '-v', default: 'latest', desc: 'The version of the tools docker container to build'
127
140
  def execute(name, arguments)
128
141
  # Ensure container exists
129
142
  if !Docker::Image.exist?("#{options[:registry]}/#{name}:#{options[:version]}")
@@ -141,10 +154,10 @@ class Sectest < Thor
141
154
  container.tap(&:start).attach { |stream, chunk| puts "#{stream}: #{chunk}" }
142
155
  end
143
156
 
144
- desc 'spec SECTESTNAME', 'Run the rspec tests for SECTESTNAME'
145
- option :verbose, type: :boolean, default: false, desc: 'Turn on verbose logging'
146
- option :scan_assessment, type: :boolean, default: true, desc: 'Fix me'
147
- define_method 'spec' do |name|
157
+ desc 'spec:image SECTESTNAME', 'Run the rspec tests for SECTESTNAME'
158
+ option :verbose, aliases: '-v', type: :boolean, default: false, desc: 'Turn on verbose logging'
159
+ option :scan_assessment, aliases: '-s', type: :boolean, default: true, desc: 'Fix me'
160
+ define_method 'spec:image' do |name|
148
161
  # Set environment variables
149
162
  ENV['ENABLE_LOGS'] = options[:verbose] ? 'true' : 'false'
150
163
  ENV['SCAN_ASSESSMENT'] = options[:scan_assessment] ? 'true' : 'false'
@@ -155,9 +168,22 @@ class Sectest < Thor
155
168
  RSpec::Core::Runner.run(["spec/#{name}/#{name}_spec.rb"], $stderr, $stdout)
156
169
  end
157
170
 
171
+ desc 'spec', 'Run all rspec tests for the entire repo (all sectests)'
172
+ option :verbose, aliases: '-v', type: :boolean, default: false, desc: 'Turn on verbose logging'
173
+ option :scan_assessment, aliases: '-s', type: :boolean, default: true, desc: 'Fix me'
174
+ def spec
175
+ # Error check to ensure this is a plugin directory
176
+ Dir.glob('sectests/*').select do |f|
177
+ if File.directory? f
178
+ # Build all for the sectest
179
+ send('spec:image', f.split('/')[-1])
180
+ end
181
+ end
182
+ end
183
+
158
184
  desc 'seed', 'Create the containers.rb seed to import into the api'
159
- option :seedfile, type: :string, default: './containers.rb', desc: 'The name of the seed file to generate'
160
- option :docsite, type: :string, default: 'https://norad.gitlab.io/docs/', desc: 'Set the documentation site'
185
+ option :seedfile, aliases: '-s', type: :string, default: './containers.rb', desc: 'The name of the seed file to generate'
186
+ option :docsite, aliases: '-d', type: :string, default: 'https://norad.gitlab.io/docs/', desc: 'Set the documentation site'
161
187
  def seed
162
188
  # Error check to ensure this is a plugin directory
163
189
 
@@ -107,7 +107,7 @@ if ENV['SCAN_ASSESSMENT']
107
107
 
108
108
  define_method :manifest_file do
109
109
  assessment_path = @parent.nil? ? assessment_name : "#{@parent}/variants/#{assessment_name}"
110
- "./#{assessment_path}/manifest.yml"
110
+ "./sectests/#{assessment_path}/manifest.yml"
111
111
  end
112
112
 
113
113
  define_method :options do
@@ -1,19 +1,27 @@
1
1
  registry: <%= options[:registry] %>
2
2
  name: <%= options[:name] %>
3
3
  version: <%= options[:version] %>
4
- <% if options[:authenticated] %>
4
+ <% if options[:test_type] == 'authenticated' -%>
5
5
  prog_args: '%{target} %{ssh_user} %{ssh_port} %{ssh_key}'
6
6
  default_config:
7
7
  ssh_port: 22
8
+ test_types:
9
+ - <%= options[:test_type] %>
8
10
  category: whitebox
9
- <% else %>
11
+ configurable: true
12
+ <% elsif options[:configurable] -%>
10
13
  prog_args: '%{target} %{fixme_custom_option}'
11
- category: blackbox
12
- <% end %>
14
+ default_config:
15
+ fixme_custom_option: some_default_value
13
16
  test_types:
14
- - <%= options[:test_type] %>
15
- <% if options[:configurable] %>
17
+ - <%= options[:test_type] %>
18
+ category: blackbox
16
19
  configurable: true
17
- <% else %>
20
+ <% else -%>
21
+ prog_args: '%{target}'
22
+ test_types:
23
+ - <%= options[:test_type] %>
24
+ category: blackbox
18
25
  configurable: false
19
- <% end %>
26
+ <% end -%>
27
+
@@ -2,9 +2,10 @@ require_relative '../spec_helper.rb'
2
2
 
3
3
  class <%= options[:spec_class_name] %>
4
4
  extend AssessmentHelpers
5
- def self.default_test_config
6
- { }
7
- end
5
+ # Uncomment and use to set default config values for testing purporse
6
+ # def self.default_test_config
7
+ # { }
8
+ # end
8
9
  end
9
10
 
10
11
  describe <%= options[:spec_class_name] %>, scan_assessment: true do
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module NoradCli
3
- VERSION = '0.1.0'
3
+ VERSION = '0.1.1'
4
4
  end
data/norad_cli.gemspec CHANGED
@@ -14,7 +14,7 @@ Gem::Specification.new do |spec|
14
14
  spec.description = 'Command line interface for norad.'
15
15
  spec.homepage = 'https://gitlab.com/norad/cli'
16
16
  spec.license = 'Apache-2.0'
17
- spec.required_ruby_version = '~> 2.3.0'
17
+ spec.required_ruby_version = '~> 2.4.0'
18
18
 
19
19
  spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
20
20
  spec.bindir = 'bin'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: norad_cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Blake Hitchcock
@@ -172,9 +172,7 @@ email:
172
172
  - 'bmanifold@gmail.com '
173
173
  - roger.seagle@gmail.com
174
174
  executables:
175
- - console
176
175
  - norad
177
- - setup
178
176
  extensions: []
179
177
  extra_rdoc_files: []
180
178
  files:
@@ -190,9 +188,7 @@ files:
190
188
  - LICENSE
191
189
  - README.md
192
190
  - Rakefile
193
- - bin/console
194
191
  - bin/norad
195
- - bin/setup
196
192
  - lib/norad_cli.rb
197
193
  - lib/norad_cli/cli/main.rb
198
194
  - lib/norad_cli/cli/secrepo.rb
@@ -270,7 +266,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
270
266
  requirements:
271
267
  - - "~>"
272
268
  - !ruby/object:Gem::Version
273
- version: 2.3.0
269
+ version: 2.4.0
274
270
  required_rubygems_version: !ruby/object:Gem::Requirement
275
271
  requirements:
276
272
  - - ">="
data/bin/console DELETED
@@ -1,15 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # frozen_string_literal: true
3
-
4
- require 'bundler/setup'
5
- require 'norad'
6
-
7
- # You can add fixtures and/or initialization code here to make experimenting
8
- # with your gem easier. You can also use a different console, if you like.
9
-
10
- # (If you use this, don't forget to add pry to your Gemfile!)
11
- # require 'pry'
12
- # Pry.start
13
-
14
- require 'irb'
15
- IRB.start
data/bin/setup DELETED
@@ -1,8 +0,0 @@
1
- #!/usr/bin/env bash
2
- set -euo pipefail
3
- IFS=$'\n\t'
4
- set -vx
5
-
6
- bundle install
7
-
8
- # Do any other automated setup that you need to do here