Class: Sectest
- Inherits:
-
Thor
- Object
- Thor
- Sectest
- Includes:
- Thor::Actions
- Defined in:
- lib/norad_cli/cli/sectest.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.source_root ⇒ Object
11 12 13 |
# File 'lib/norad_cli/cli/sectest.rb', line 11 def self.source_root File.join(File.dirname(File.(__FILE__)), '../templates/') end |
Instance Method Details
#build ⇒ Object
63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/norad_cli/cli/sectest.rb', line 63 def build # Check for the root_dir root_dir? # Error check to ensure this is a plugin directory Dir.glob('sectests/*').select do |f| if File.directory? f # Build all for the sectest send('build:all', f.split('/')[-1]) end end end |
#scaffold(sectest_name) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/norad_cli/cli/sectest.rb', line 21 def scaffold(sectest_name) # Grab the current directory repo_dir = Dir.pwd # Check for the root_dir root_dir? # Check for valid test types if !%w(authenticated web_application brute_force ssl_crypto ssh_crypto whole_host).include?([:test_type]) say("#{options[:test_type]} is not a supported test type", :red) say('Exiting...', :red) exit(1) end # Set options for templates [:name] = sectest_name [:spec_class_name] = sectest_name.split('-').map { |t| t =~ /\d+/ ? t : t.capitalize! }.join # Error check to ensure this is a norad security test repository # Create the security tests standard files template('tool/Dockerfile.erb', "#{repo_dir}/sectests/#{sectest_name}/Dockerfile") template('tool/README.md.erb', "#{repo_dir}/sectests/#{sectest_name}/README.md") template('tool/manifest.yml.erb', "#{repo_dir}/sectests/#{sectest_name}/manifest.yml") # Create a starter wrapper script template('tool/wrapper.rb.erb', "#{repo_dir}/sectests/#{sectest_name}/#{sectest_name}-wrapper.rb") # Create the spec files template('tool/tool_spec.rb.erb', "#{repo_dir}/spec/#{sectest_name}/#{sectest_name}_spec.rb") if [:test_type] == 'authenticated' template('tool/Dockerfile.auth.target.erb', "#{repo_dir}/spec/#{sectest_name}/targets/Dockerfile.secure") template('tool/Dockerfile.auth.target.erb', "#{repo_dir}/spec/#{sectest_name}/targets/Dockerfile.vulnerable") else template('tool/Dockerfile.unauth.target.erb', "#{repo_dir}/spec/#{sectest_name}/targets/Dockerfile.secure") template('tool/Dockerfile.unauth.target.erb', "#{repo_dir}/spec/#{sectest_name}/targets/Dockerfile.vulnerable") end end |
#seed ⇒ Object
200 201 202 203 204 205 206 |
# File 'lib/norad_cli/cli/sectest.rb', line 200 def seed # Check for the root_dir root_dir? # Generate the seed file SeedGenerator.process_manifests([:seedfile], [:docsite]) end |
#spec ⇒ Object
184 185 186 187 188 189 190 191 192 193 194 195 |
# File 'lib/norad_cli/cli/sectest.rb', line 184 def spec # Check for the root_dir root_dir? # Error check to ensure this is a plugin directory Dir.glob('sectests/*').select do |f| if File.directory? f # Build all for the sectest send('spec:image', f.split('/')[-1]) end end end |
#validate ⇒ Object
222 223 224 225 226 227 228 229 230 231 232 233 |
# File 'lib/norad_cli/cli/sectest.rb', line 222 def validate # Check for the root_dir root_dir? # Error check to ensure this is a plugin directory Dir.glob('sectests/*').select do |f| if File.directory? f # Build all for the sectest send('validate:image', f.split('/')[-1]) end end end |