norad_cli 0.1.0

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.
Files changed (82) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +9 -0
  3. data/.gitlab-ci.yml +43 -0
  4. data/.rspec +2 -0
  5. data/.rubocop.yml +34 -0
  6. data/.ruby-gemset +1 -0
  7. data/.ruby-version +1 -0
  8. data/.travis.yml +5 -0
  9. data/CONTRIBUTING.md +102 -0
  10. data/Gemfile +5 -0
  11. data/LICENSE +201 -0
  12. data/README.md +119 -0
  13. data/Rakefile +7 -0
  14. data/bin/console +15 -0
  15. data/bin/norad +6 -0
  16. data/bin/setup +8 -0
  17. data/lib/norad_cli/cli/main.rb +12 -0
  18. data/lib/norad_cli/cli/secrepo.rb +46 -0
  19. data/lib/norad_cli/cli/sectest.rb +183 -0
  20. data/lib/norad_cli/support/api_security_container_seed_script.rb +42 -0
  21. data/lib/norad_cli/support/manifest.rb +16 -0
  22. data/lib/norad_cli/support/readme.rb +3 -0
  23. data/lib/norad_cli/templates/.gitignore +2 -0
  24. data/lib/norad_cli/templates/.rspec +2 -0
  25. data/lib/norad_cli/templates/CONTRIBUTING.md +193 -0
  26. data/lib/norad_cli/templates/LICENSE.erb +201 -0
  27. data/lib/norad_cli/templates/README.md +2 -0
  28. data/lib/norad_cli/templates/ci/.gitlab.ci.yml +44 -0
  29. data/lib/norad_cli/templates/spec/spec_helper.rb +247 -0
  30. data/lib/norad_cli/templates/spec/support/Dockerfile.testserver +22 -0
  31. data/lib/norad_cli/templates/spec/support/Dockerfile.ubuntu_ssh +20 -0
  32. data/lib/norad_cli/templates/spec/support/ssh_key +27 -0
  33. data/lib/norad_cli/templates/spec/support/ssh_key.pub +1 -0
  34. data/lib/norad_cli/templates/spec/support/test_server/.gitignore +21 -0
  35. data/lib/norad_cli/templates/spec/support/test_server/Gemfile +5 -0
  36. data/lib/norad_cli/templates/spec/support/test_server/Gemfile.lock +116 -0
  37. data/lib/norad_cli/templates/spec/support/test_server/Rakefile +6 -0
  38. data/lib/norad_cli/templates/spec/support/test_server/app/controllers/application_controller.rb +2 -0
  39. data/lib/norad_cli/templates/spec/support/test_server/app/controllers/results_controller.rb +23 -0
  40. data/lib/norad_cli/templates/spec/support/test_server/app/models/application_record.rb +3 -0
  41. data/lib/norad_cli/templates/spec/support/test_server/app/models/result.rb +2 -0
  42. data/lib/norad_cli/templates/spec/support/test_server/bin/bundle +3 -0
  43. data/lib/norad_cli/templates/spec/support/test_server/bin/rails +9 -0
  44. data/lib/norad_cli/templates/spec/support/test_server/bin/rake +9 -0
  45. data/lib/norad_cli/templates/spec/support/test_server/config/application.rb +30 -0
  46. data/lib/norad_cli/templates/spec/support/test_server/config/boot.rb +3 -0
  47. data/lib/norad_cli/templates/spec/support/test_server/config/cable.yml +9 -0
  48. data/lib/norad_cli/templates/spec/support/test_server/config/database.yml +25 -0
  49. data/lib/norad_cli/templates/spec/support/test_server/config/environment.rb +5 -0
  50. data/lib/norad_cli/templates/spec/support/test_server/config/environments/development.rb +47 -0
  51. data/lib/norad_cli/templates/spec/support/test_server/config/environments/production.rb +78 -0
  52. data/lib/norad_cli/templates/spec/support/test_server/config/environments/test.rb +42 -0
  53. data/lib/norad_cli/templates/spec/support/test_server/config/initializers/application_controller_renderer.rb +6 -0
  54. data/lib/norad_cli/templates/spec/support/test_server/config/initializers/backtrace_silencers.rb +7 -0
  55. data/lib/norad_cli/templates/spec/support/test_server/config/initializers/cors.rb +16 -0
  56. data/lib/norad_cli/templates/spec/support/test_server/config/initializers/filter_parameter_logging.rb +4 -0
  57. data/lib/norad_cli/templates/spec/support/test_server/config/initializers/inflections.rb +16 -0
  58. data/lib/norad_cli/templates/spec/support/test_server/config/initializers/mime_types.rb +4 -0
  59. data/lib/norad_cli/templates/spec/support/test_server/config/initializers/new_framework_defaults.rb +18 -0
  60. data/lib/norad_cli/templates/spec/support/test_server/config/initializers/wrap_parameters.rb +14 -0
  61. data/lib/norad_cli/templates/spec/support/test_server/config/locales/en.yml +23 -0
  62. data/lib/norad_cli/templates/spec/support/test_server/config/puma.rb +47 -0
  63. data/lib/norad_cli/templates/spec/support/test_server/config/routes.rb +5 -0
  64. data/lib/norad_cli/templates/spec/support/test_server/config/secrets.yml +20 -0
  65. data/lib/norad_cli/templates/spec/support/test_server/config.ru +5 -0
  66. data/lib/norad_cli/templates/spec/support/test_server/db/migrate/20160725144604_create_results.rb +15 -0
  67. data/lib/norad_cli/templates/spec/support/test_server/db/schema.rb +2 -0
  68. data/lib/norad_cli/templates/spec/support/test_server/lib/tasks/.keep +0 -0
  69. data/lib/norad_cli/templates/spec/support/test_server/log/.keep +0 -0
  70. data/lib/norad_cli/templates/spec/support/test_server/public/robots.txt +5 -0
  71. data/lib/norad_cli/templates/spec/support/test_server/tmp/.keep +0 -0
  72. data/lib/norad_cli/templates/tool/Dockerfile.auth.target.erb +2 -0
  73. data/lib/norad_cli/templates/tool/Dockerfile.erb +11 -0
  74. data/lib/norad_cli/templates/tool/Dockerfile.unauth.target.erb +5 -0
  75. data/lib/norad_cli/templates/tool/README.md.erb +17 -0
  76. data/lib/norad_cli/templates/tool/manifest.yml.erb +19 -0
  77. data/lib/norad_cli/templates/tool/tool_spec.rb.erb +55 -0
  78. data/lib/norad_cli/templates/tool/wrapper.rb.erb +47 -0
  79. data/lib/norad_cli/version.rb +4 -0
  80. data/lib/norad_cli.rb +7 -0
  81. data/norad_cli.gemspec +38 -0
  82. metadata +285 -0
@@ -0,0 +1,183 @@
1
+ # frozen_string_literal: true
2
+ require 'thor'
3
+ require 'git'
4
+ require 'docker'
5
+ require 'norad_cli/support/api_security_container_seed_script'
6
+ require 'rspec'
7
+
8
+ class Sectest < Thor
9
+ include Thor::Actions
10
+
11
+ def self.source_root
12
+ File.join(File.dirname(File.expand_path(__FILE__)), '../templates/')
13
+ end
14
+
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)'
22
+ def scaffold(sectest_name)
23
+ # Grab the current directory
24
+ repo_dir = Dir.pwd
25
+
26
+ # Set options for templates
27
+ options[:name] = sectest_name
28
+ options[:spec_class_name] = sectest_name.split('-').map { |t| t =~ /\d+/ ? t : t.capitalize! }.join
29
+
30
+ # Error check to ensure this is a norad security test repository
31
+
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")
36
+
37
+ # Create a starter wrapper script
38
+ template('tool/wrapper.rb.erb', "#{repo_dir}/#{sectest_name}/#{sectest_name}-wrapper.rb")
39
+
40
+ # Create the spec files
41
+ template('tool/tool_spec.rb.erb', "#{repo_dir}/spec/#{sectest_name}/#{sectest_name}_spec.rb")
42
+ if options[:authenticated]
43
+ template('tool/Dockerfile.auth.target.erb', "#{repo_dir}/spec/#{sectest_name}/targets/Dockerfile.secure")
44
+ template('tool/Dockerfile.auth.target.erb', "#{repo_dir}/spec/#{sectest_name}/targets/Dockerfile.vulnerable")
45
+ else
46
+ template('tool/Dockerfile.unauth.target.erb', "#{repo_dir}/spec/#{sectest_name}/targets/Dockerfile.secure")
47
+ template('tool/Dockerfile.unauth.target.erb', "#{repo_dir}/spec/#{sectest_name}/targets/Dockerfile.vulnerable")
48
+ end
49
+ end
50
+
51
+ # 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)
56
+ imgs_to_build = {}
57
+ imgs_to_build[name.to_s] = "#{options[:registry]}/#{name}:#{options[:version]}"
58
+
59
+ # Check for the Dockerfile
60
+ if !dockerfile?(imgs_to_build.keys[0])
61
+ say("Missing #{imgs_to_build.keys[0]}/Dockerfile", :red)
62
+ exit(1)
63
+ end
64
+
65
+ # Determine if base image needs to be built
66
+ base_img = extract_base_img(imgs_to_build.keys[0])
67
+ while dockerfile?("base/#{base_img[0]}")
68
+ imgs_to_build["base/#{base_img[0]}"] = base_img[1]
69
+ base_img = extract_base_img(imgs_to_build.keys[-1])
70
+ end
71
+
72
+ # Build the images in reverse (Note: Hashes enumerate their values in insertion order.)
73
+ Docker.options[:read_timeout] = 36_000
74
+ imgs_to_build.keys.reverse_each do |img_dir|
75
+ say("Building image #{img_dir}...", :green)
76
+ Docker::Image.build_from_dir(img_dir, t: imgs_to_build[img_dir]) do |v|
77
+ $stdout.puts v
78
+ end
79
+ end
80
+ end
81
+
82
+ # 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'
86
+ define_method 'build:specs' do |name|
87
+ imgs_to_build = {}
88
+ imgs_to_build["#{File.expand_path(File.dirname(__FILE__))}/../templates/spec/support/Dockerfile.testserver"] = 'docker-images-test-results-server:latest'
89
+ imgs_to_build["#{File.expand_path(File.dirname(__FILE__))}/../templates/spec/support/Dockerfile.ubuntu_ssh"] = 'docker-images-test-ubuntu-ssh-server:latest'
90
+
91
+ # Determine the Dockerfiles in the assessment spec dir
92
+ Dir.glob("spec/#{name}/targets/Dockerfile*").each do |entry|
93
+ entry_components = entry.split('.')
94
+ imgs_to_build[entry] = "#{name}-#{entry_components[-1]}:latest"
95
+ end
96
+
97
+ # Build the images
98
+ Docker.options[:read_timeout] = 36_000
99
+ imgs_to_build.keys.each do |img_dir|
100
+ say("Building image #{img_dir}...", :green)
101
+ docker_file = img_dir.split('/')[-1]
102
+ Docker::Image.build_from_dir(img_dir.gsub(docker_file, ''), dockerfile: docker_file, t: imgs_to_build[img_dir]) do |v|
103
+ $stdout.puts v
104
+ end
105
+ end
106
+
107
+ # Pull the apline image for base testing
108
+ Docker::Image.create('fromImage' => 'alpine:3.4')
109
+ end
110
+
111
+ # 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'
115
+ define_method 'build:all' do |name|
116
+ # Build the tool
117
+ build(name)
118
+
119
+ # Build the specs for testing
120
+ send('build:specs', name)
121
+ end
122
+
123
+ # Define arguments and options
124
+ 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'
127
+ def execute(name, arguments)
128
+ # Ensure container exists
129
+ if !Docker::Image.exist?("#{options[:registry]}/#{name}:#{options[:version]}")
130
+ say("Requested image #{options[:registry]}/#{name}:#{options[:version]} does not exist!", :red)
131
+ exit(1)
132
+ end
133
+
134
+ # Setup and run the container
135
+ env = ['NORAD_ROOT=', %(ASSESSMENT_PATHS=[{"id":"1", "assessment": "1"}]), 'NORAD_SECRET=1234']
136
+ container = Docker::Container.create(Image: "#{options[:registry]}/#{name}:#{options[:version]}",
137
+ Env: env,
138
+ Cmd: arguments)
139
+
140
+ # Start the container, watch stdout
141
+ container.tap(&:start).attach { |stream, chunk| puts "#{stream}: #{chunk}" }
142
+ end
143
+
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|
148
+ # Set environment variables
149
+ ENV['ENABLE_LOGS'] = options[:verbose] ? 'true' : 'false'
150
+ ENV['SCAN_ASSESSMENT'] = options[:scan_assessment] ? 'true' : 'false'
151
+ ENV['TEST_RESULTS_SERVER_IMAGE'] = 'docker-images-test-results-server'
152
+ ENV['UBUNTU_SSH_SERVER_IMAGE'] = 'docker-images-test-ubuntu-ssh-server'
153
+
154
+ # Run the tests
155
+ RSpec::Core::Runner.run(["spec/#{name}/#{name}_spec.rb"], $stderr, $stdout)
156
+ end
157
+
158
+ 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'
161
+ def seed
162
+ # Error check to ensure this is a plugin directory
163
+
164
+ # Generate the seed file
165
+ SeedGenerator.process_manifests(options[:seedfile], options[:docsite])
166
+ end
167
+
168
+ no_tasks do
169
+ def dockerfile?(img_dir)
170
+ # Ensure the Dockerfile exists for the new tool
171
+ File.file?("#{img_dir}/Dockerfile")
172
+ end
173
+
174
+ # Check for a base image
175
+ def extract_base_img(img_dir)
176
+ from_line = File.readlines("#{img_dir}/Dockerfile").select { |line| line =~ /^FROM/ }
177
+ # Check for multiple from lines?
178
+ from_line_arr = from_line[0].split(' ')
179
+ from_image = from_line[0][%r{\AFROM\s+(.*?\/)?(.*?)(:.*?)?\Z}i, 2] || raise('bad from')
180
+ [from_image, from_line_arr[1]]
181
+ end
182
+ end
183
+ end
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+ require 'yaml'
3
+
4
+ module SeedGenerator
5
+ def self.add_container(container_file, m, long_name, docsite, readme_anchor)
6
+ container_file.write("\n") unless container_file.size.zero?
7
+ container_file.write("sc = SecurityContainer.where(name: '#{long_name}').first_or_initialize\n")
8
+ container_file.write("sc.prog_args = '#{m['prog_args']}'\n")
9
+ container_file.write("sc.default_config = #{symbolized_config(m['default_config'])}\n") if m.key?('default_config')
10
+ container_file.write("sc.category = :#{m['category'].to_sym}\n")
11
+ container_file.write("sc.test_types = #{m['test_types']}\n")
12
+ container_file.write("sc.common_service_type = CommonServiceType.find_by(name: '#{m['common_service_type']}')\n") if m.key?('common_service_type')
13
+ container_file.write("sc.configurable = #{m['configurable']}\n") if m.key?('configurable')
14
+ container_file.write("sc.multi_host = #{m['multi_host']}\n") if m.key?('multi_host')
15
+ container_file.write("sc.help_url = '#{docsite}##{readme_anchor}'\n")
16
+ container_file.write("sc.save!\n")
17
+ end
18
+
19
+ def self.symbolized_config(config)
20
+ '{ ' + config.reduce([]) do |a, p|
21
+ a << "#{p.first}: '#{p.last}'"
22
+ end.join(', ') + ' }'
23
+ end
24
+
25
+ def self.readme_anchor(readme)
26
+ title = readme.readline
27
+ # ## My Test Name123
28
+ # Trim off ## portion of title, replace spaces with -, and downcase
29
+ title.match(/\s*##\s+(.+)/)[1].strip.gsub(/[ .]/, '-').downcase
30
+ end
31
+
32
+ def self.process_manifests(seed_file, docsite)
33
+ File.open(seed_file, 'w') do |container_file|
34
+ Dir.glob('./**/manifest.yml').each do |p|
35
+ manifest = YAML.load(File.new(p, 'r').read)
36
+ readme_anchor = readme_anchor(File.new(p.gsub(/manifest\.yml/, 'README.md')))
37
+ long_name = "#{manifest['registry']}/#{manifest['name']}:#{manifest['version']}"
38
+ add_container(container_file, manifest, long_name, docsite, readme_anchor)
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+ require 'safe_yaml'
3
+ SafeYAML::OPTIONS[:default_mode] = :safe
4
+
5
+ class Manifest
6
+ attr_accessor :values
7
+
8
+ def initialize(manifest_file)
9
+ f = File.new manifest_file, 'r'
10
+ @values = YAML.load f.read
11
+ end
12
+
13
+ def name
14
+ "#{@values['registry']}/#{@values['name']}:#{@values['version']}"
15
+ end
16
+ end
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+ class Readme
3
+ end
@@ -0,0 +1,2 @@
1
+ containers.rb
2
+ *.swp
@@ -0,0 +1,2 @@
1
+ --color
2
+ --require spec_helper
@@ -0,0 +1,193 @@
1
+ # How to contribute
2
+
3
+ This guide is meant to provide guidelines for how to contribute to the Norad docker-images project.
4
+ These procedures should work in the majority of cases. At times, it will be necessary to step
5
+ outside of these guidelines and Do What Makes Sense. This is a living document that we can continue
6
+ to modify as we define the process that helps us add code quickly and safely.
7
+
8
+ ## Getting Started
9
+
10
+ * If you haven't already, you'll likely want to set up a [development
11
+ box](https://gitlab.com/norad/dev-box). This provides a consistent environment for
12
+ building assessments.
13
+
14
+ * Due to the variance in types of assessments that will be written, we do not enforce any sort of
15
+ style or code quality. However, if the code you are writing is written in Ruby, you may wish to
16
+ use [rubocop](https://github.com/bbatsov/rubocop). You can familiarize yourself with the
17
+ [style guide](https://github.com/bbatsov/ruby-style-guide). You can also install a tool into your
18
+ editor which will help you follow the style guideline. One for vim can be found
19
+ [here](https://github.com/scrooloose/syntastic).
20
+
21
+ * You may wish to use the scaffold generator provided in this repository. For more information,
22
+ please reference [the README](https://gitlab.com/norad/security-modules#scaffolding).
23
+
24
+ ## Making Changes
25
+
26
+ Fundamentally, we follow the Github Flow(1) methodology for branching and committing code. The
27
+ process essentially breaks down as follows:
28
+
29
+ 1. Assign the feature you are beginning to work on to yourself in JIRA.
30
+ 2. Create a feature branch off of the master branch. Note that anything in master is always
31
+ deployable, so this branch will always have the latest code. Branch names should be descriptive.
32
+ 3. Your branch is your branch. Feel free to experiment and commit freely. You may wish to make your
33
+ life easier when it's time to merge into master by learning about [auto-squashing
34
+ commits](https://robots.thoughtbot.com/autosquashing-git-commits).
35
+ 4. You are free to push the feature branch to the origin as freqently as you wish. This will run the
36
+ CI suite for the following stages: **validate**, **build**, and **test**. You can also run the
37
+ test suite locally on your dev box (refer to the .gitlab-ci.yml file and the scripts in the
38
+ ```./ci``` directory). By pushing to the feature branch, you can engage other engineers on the
39
+ team if you need help. They can checkout your branch and examine the code.
40
+ 5. When your feature is done, open a Merge Request in Gitlab.
41
+
42
+ At this point in process, there is no requirement of any kind for your commit messages. Before
43
+ merging into master, though, you will need a "good commit message" for any commits that aren't being
44
+ squashed. Links to further reading on this topic are available in the Additional Resources section.
45
+
46
+ ## Creating a Manifest File
47
+
48
+ In addition to creating the Dockerfile and wrapper scripts for your image, you
49
+ will need to create a manifest.yml file in the directory for your new tool.
50
+ This manifest file is used by the CI scripts to create a Merge Request against
51
+ the Norad [API](https://gitlab.com/norad/api) project to add the
52
+ new assessment to the API database. A sample manifest file is included below:
53
+
54
+ ```yaml
55
+ registry: norad-registry.cisco.com:5000
56
+ name: arachni-xss
57
+ version: 0.0.1
58
+ prog_args: '--checks=%{check} %{protocol}://%{target}:%{port}%{url}'
59
+ default_config:
60
+ protocol: "https"
61
+ port: '443'
62
+ url: '/'
63
+ check: "xss*"
64
+ category: blackbox
65
+ ```
66
+
67
+ ## Writing Tests
68
+
69
+ A testing harness is provided for verifying basic functionality of the
70
+ assessments included in this repository. In general, the following steps
71
+ outline the test-creation process:
72
+
73
+ 1. Create a directory in ```spec/assessments``` by the same name of the image you want to test, e.g. ```spec/assessments/nmap-ssl-dh-param/```
74
+ 2. Create an rspec file, also named the same as the image under test, in this directory e.g. ```nmap-ssl-dh-param_spec.rb```
75
+ 3. In this directory, create a ```targets/``` directory
76
+ 4. Add a ```Dockerfile.secure``` and ```Dockerfile.vulnerable``` to the ```targets/``` directory
77
+
78
+ The CI scripts will handle building the secure and vulnerable test targets and execute the
79
+ assessment against each. It will make the results available to your Rspec script via instance
80
+ variables. If your assessment requires authentication on the target, the test harness will determine
81
+ this automatically based on the default arguments for the assessment.
82
+
83
+ ### Sample Rspec Script
84
+ ```ruby
85
+ require_relative '../../spec_helper.rb'
86
+
87
+ class NmapSslDhParam
88
+ extend AssessmentHelpers
89
+ end
90
+
91
+ describe NmapSslDhParam, scan_assessment: true do
92
+ context 'for all targets' do
93
+ it 'should report a single result' do
94
+ expect(@vulnerable_results.size).to eq(1)
95
+ expect(@secure_results.size).to eq(1)
96
+ expect(@base_results.size).to eq(1)
97
+ end
98
+ end
99
+ end
100
+ ```
101
+
102
+ ## Writing a README
103
+
104
+ The README.md file included with each assessment is used by the CI suite to update the Norad
105
+ [docs](https://gitlab.com/norad/docs) application with information about the assessment
106
+ it is associated with. The contents of this README are largely up to the author, but should include
107
+ some general information such as:
108
+
109
+ 1. A description of what the assessment tests for
110
+ 2. Configuration options table explaining how to configure the asssessment
111
+ 3. Whether or not the assessment requires authentication on the target (i.e. SSH)
112
+ 4. What requirements, if any, are addressed by the assessment
113
+
114
+ ## Submitting Changes
115
+
116
+ When your feature is ready, or is at a state where you'd like to formally begin engaging the rest of
117
+ the team, create a [Merge
118
+ Request](https://gitlab.com/norad/security-modules/merge_requests) in Gitlab. Please write
119
+ a meaningful title and detailed description that provides an overview of What your feature does and
120
+ Why it does it. You can leave it to the code itself to explain the How, but feel free to call
121
+ anything out here that you would like the reviewer(s) to pay special attention to. If you feel that
122
+ someone in particular needs to look at your Merge Request, you may assign the MR to them. Mentioning
123
+ someone in the Merge Request description is another way to alert someone in particular you'd like
124
+ for them to look at your MR, e.g. ```cc @ravangar```.
125
+
126
+ ## Code Review Process
127
+
128
+ The Code Review Process is meant to be an open-ended discussion about the feature that is being
129
+ committed. It should address whether the changeset meets the requirements of the feature as well as
130
+ the quality of the code itself. The reviewer(s) should also make sure that the feature includes an
131
+ adequate number of meaningful tests.
132
+
133
+ Please be polite in both giving and receiving feedback. Remember that it's a review of the code, not
134
+ an individual. As a reviewer, do your best to separate your personal opinion of how you would do
135
+ something from what is objectively constructive criticism. Please review the Thoughtbot guide for
136
+ Code Reviews in the Additional Resources section (3).
137
+
138
+ Make any changes to your feature branch that you and the reviewer agree should be made, and push
139
+ those changes to your feature branch. This will automatically update your Merge Request. Repeat this
140
+ process until the Merge Request is approved.
141
+
142
+ The merge request must receive at least one **+1** before it can be merged. If individuals are
143
+ called out to look at something during any point of the review process, they will need to provide a
144
+ **+1** as well before it can be merged.
145
+
146
+ ## Testing and Integration Process
147
+
148
+ We leverage [Gitlab CI](https://about.gitlab.com/gitlab-ci/) to execute our test suite and integrate
149
+ the merged assessment content into our documentation and API applications as well as push the newly
150
+ created image to our Registry. The integration is broken down into the following 5 stages:
151
+
152
+ 1. validate (ensure correctness of the manifest file and the existence of a README)
153
+ 2. build (attempt to build all of the Docker images in the repository)
154
+ 3. test (execute the test suite for the built Docker images)
155
+ 4. deploy (push the Docker images to the Norad Registry)*
156
+ 5. integrate (open pull requests in the [api](https://gitlab.com/norad/api) and
157
+ [docs](https://gitlab.com/norad/docs) using the manifest files and the READMEs,
158
+ respectively)*
159
+
160
+ *\* only execute on the ```master``` branch*
161
+
162
+ More details can be found in the
163
+ [.gitlab-ci.yml](https://gitlab.com/norad/security-modules/blob/master/.gitlab-ci.yml)
164
+ file.
165
+
166
+ ## Merge Process
167
+
168
+ Your feature got approved! Great! Now it's time to merge into master.
169
+
170
+ 1. Before code can be merged to master, **all tests must be passing**. In other words, you need a
171
+ green check from Gitlab CI.
172
+ 2. In order to keep the master branch's commit history clean, you may be required to rebase your
173
+ feature branch before it can be merged. You may also consider squashing interim commits into one
174
+ or more block commits. The goal here is to keep the master branch devoid of commits such as
175
+ "fixing typo" or "trying out this method." Either way, you should rebase your commits on top of
176
+ the most recent commit to master. This helps keep the git history organized and commits related
177
+ to the same feature will be grouped to gether. To rebase, run the following on your freature
178
+ branch: ```git fetch orgin master && git rebase -i origin/master```. See the additional
179
+ resources for more information on rebasing.
180
+ 3. After (force) pushing your rebased feature branch, the Merge Request can be merged **as long as
181
+ all tests still pass**.
182
+
183
+ # Additional Resources
184
+
185
+ 1. [Github Flow](https://guides.github.com/introduction/flow/)
186
+ 2. [Code Review Guide](https://github.com/thoughtbot/guides/tree/master/code-review)
187
+ 3. [Style Guide](https://github.com/bbatsov/ruby-style-guide)
188
+ 4. [Git Tips](https://github.com/thoughtbot/guides/blob/master/protocol/git)
189
+ 5. [Git Rebase](https://help.github.com/articles/about-git-rebase/)
190
+ 6. [Auto-squashing Git Commits](https://robots.thoughtbot.com/autosquashing-git-commits)
191
+ 7. [Good Commit Messages](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html)
192
+ 8. [More Good Commit Messages](http://chris.beams.io/posts/git-commit/)
193
+ 9. [Even More Good Commit Messages](http://www.alexkras.com/19-git-tips-for-everyday-use/#good-commit-message)
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "{}"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright <%= options[:year] %> <%= options[:company] %>
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,2 @@
1
+ FIXME
2
+ ------