norad_cli 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
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
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: f67e3b7d29e50815d288e17ba88cf0791e5cc808
4
+ data.tar.gz: b1b7675b3bab7237fc7cfa9b094181d9918cbb29
5
+ SHA512:
6
+ metadata.gz: 24c52f33dd524c6057465193569229968f3eb90e48963a530919191450e91b504d6112bfaacbad903e95259d61590eb72ed6e35e4911884a9d6b692948c0c2ec
7
+ data.tar.gz: bf5fb027e9df8357164c6c9971b24a5db7077ed822fcb5d7eff24220199028f061811e247923fc82b35e9ece3121bd06f246225aecb659c9dd2beee27472d2e6
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.gitlab-ci.yml ADDED
@@ -0,0 +1,43 @@
1
+ stages:
2
+ - static_analysis
3
+ - security_test
4
+ # - behavior_test
5
+ - release
6
+
7
+ image: ruby:2.3.3
8
+
9
+ cache:
10
+ key: "$CI_BUILD_NAME"
11
+ paths:
12
+ - vendor/bundle
13
+
14
+ before_script:
15
+ - bundle install --jobs=4 --with development
16
+
17
+ rubocop:
18
+ stage: static_analysis
19
+ script: bundle exec rubocop
20
+
21
+ bundle_audit:
22
+ stage: security_test
23
+ script: bundle exec bundle-audit check --update
24
+
25
+ #rspec:
26
+ # stage: behavior_test
27
+ # script: bundle exec rspec
28
+
29
+ publish:
30
+ stage: release
31
+ script:
32
+ - echo "---" > ~/.gem/credentials
33
+ - COLON=':' && echo "${COLON}rubygems_api_key${COLON} ${RUBYGEMS_API_KEY}" >> ~/.gem/credentials
34
+ - git config --global user.email "norad.dev@gmail.com"
35
+ - git config --global user.name "Norad Release"
36
+ - git config --global push.default simple
37
+ - chmod 0600 ~/.gem/credentials
38
+ - bundle exec rake build
39
+ - bundle exec rake release:guard_clean
40
+ - gem push `ls ./pkg/norad_cli-*.gem`
41
+ - rm -fr ~/.gem
42
+ only:
43
+ - master
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.rubocop.yml ADDED
@@ -0,0 +1,34 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.3
3
+ DisplayCopNames: true
4
+ Exclude:
5
+ - 'lib/norad_cli/templates/spec/**/*'
6
+ Documentation:
7
+ Enabled: false
8
+ Metrics/LineLength:
9
+ Max: 120
10
+ Exclude:
11
+ - 'lib/norad_cli/support/api_security_container_seed_script.rb'
12
+ - 'lib/norad_cli/cli/sectest.rb'
13
+ Metrics/MethodLength:
14
+ Exclude:
15
+ - 'lib/norad_cli/support/api_security_container_seed_script.rb'
16
+ - 'lib/norad_cli/cli/sectest.rb'
17
+ Metrics/AbcSize:
18
+ Exclude:
19
+ - 'lib/norad_cli/support/api_security_container_seed_script.rb'
20
+ - 'lib/norad_cli/cli/sectest.rb'
21
+ Metrics/BlockLength:
22
+ Exclude:
23
+ - 'spec/**/*'
24
+ - 'lib/norad_cli/cli/sectest.rb'
25
+ Metrics/ClassLength:
26
+ Exclude:
27
+ - 'lib/norad_cli/cli/sectest.rb'
28
+ Style/NegatedIf:
29
+ Exclude:
30
+ - 'lib/norad_cli/cli/sectest.rb'
31
+ Security/YAMLLoad:
32
+ Exclude:
33
+ - 'lib/norad_cli/support/manifest.rb'
34
+ - 'lib/norad_cli/support/api_security_container_seed_script.rb'
data/.ruby-gemset ADDED
@@ -0,0 +1 @@
1
+ norad-gem
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.3.3
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.3.0
5
+ before_install: gem install bundler -v 1.12.5
data/CONTRIBUTING.md ADDED
@@ -0,0 +1,102 @@
1
+ # How to contribute
2
+
3
+ This guide is meant to provide guidelines for how to contribute to the Norad CLI project. These
4
+ procedures should work in the majority of cases. At times, it will be necessary to step outside of
5
+ these guidelines and Do What Makes Sense. This is an living document that we can continue to modify
6
+ 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 want to set up a [development box](https://gitlab.cisco.com/norad/dev-box).
11
+ This provides a consistent environment for running tests.
12
+ * We use [rubocop](https://github.com/bbatsov/rubocop) to enforce code quality and style guidelines.
13
+ You can familiarize yourself with the [style guide](https://github.com/bbatsov/ruby-style-guide).
14
+ You can also install a tool into your editor which will help you follow the style guideline. One
15
+ for vim can be found [here](https://github.com/scrooloose/syntastic).
16
+
17
+ ## Making Changes
18
+
19
+ Fundamentally, we follow the Github Flow(1) methodology for branching and committing code. The
20
+ process essentially breaks down as follows:
21
+
22
+ 1. Assign the feature you are beginning to work on to yourself in JIRA.
23
+ 2. Create a feature branch off of the master branch. Note that anything in master is always
24
+ deployable, so this branch will always have the latest code. Branch names should be descriptive.
25
+ 3. Your branch is your branch. Feel free to experiment and commit freely. You may wish to make your
26
+ life easier when it's time to merge into master by learning about [auto-squashing
27
+ commits](https://robots.thoughtbot.com/autosquashing-git-commits).[^1]
28
+ 4. You are free to push the feature branch to the origin as freqently as you wish. This will run the
29
+ CI suite. You can also run the test suite locally on your dev box. By pushing to the feature
30
+ branch, you can engage other engineers on the team if you need help. They can checkout your
31
+ branch and examine the code.
32
+ 5. When your feature is done, open a Merge Request in Gitlab.
33
+
34
+ At this point in process, there is no requirement of any kind for your commit messages. Before
35
+ merging into master, though, you will need a "good commit message" for any commits that aren't being
36
+ squashed. Links to further reading on this topic are available in the Additional Resources section.
37
+
38
+ ## Submitting Changes
39
+
40
+ When your feature is ready, or is at a state where you'd like to formally begin engaging the rest of
41
+ the team, create a [Merge Request](https://gitlab.cisco.com/norad/norad/merge_requests)
42
+ in Gitlab. Please write a meaningful title and detailed description that provides an overview of
43
+ What your feature does and Why it does it. You can leave it to the code itself to explain the How,
44
+ but feel free to call anything out here that you would like the reviewer(s) to pay special attention
45
+ to. If you feel that someone in particular needs to look at your Merge Request, you may assign the
46
+ MR to them. Mentioning someone in the Merge Request description is another way to alert someone in
47
+ particular you'd like for them to look at your MR, e.g. ```cc @bmanifol```.
48
+
49
+ **ProTips**
50
+
51
+ * Gitlab will autofill the title and description with your most recent commit when opening the Merge
52
+ Request. So, writing a good commit for your last commit before opening the Merge Request can help
53
+ you kill two birds with one stone.
54
+
55
+ ## Code Review Process
56
+
57
+ The Code Review Process is meant to be an open-ended discussion about the feature that is being
58
+ committed. It should address whether the changeset meets the requirements of the feature as well as
59
+ the quality of the code itself. The reviewer(s) should also make sure that the feature includes an
60
+ adequate number of meaningful tests.
61
+
62
+ Please be polite in both giving and receiving feedback. Remember that it's a review of the code, not
63
+ an individual. As a reviewer, do your best to separate your personal opinion of how you would do
64
+ something from what is objectively constructive criticism. Please review the Thoughtbot guide for
65
+ Code Reviews in the Additional Resources section (3).
66
+
67
+ Make any changes to your feature branch that you and the reviewer agree should be made, and push
68
+ those changes to your feature branch. This will automatically update your Merge Request. Repeat this
69
+ process until the Merge Request is approved.
70
+
71
+ The merge request must receive at least one **+1** before it can be merged. If individuals are
72
+ called out to look at something during any point of the review process, they will need to provide a
73
+ **+1** as well before it can be merged.
74
+
75
+ ## Merge Process
76
+
77
+ Your feature got approved! Great! Now it's time to merge into master.
78
+
79
+ 1. Before code can be merged to master, **all tests must be passing**. In other words, you need a
80
+ green check from Gitlab CI.
81
+ 2. In order to keep the master branch's commit history clean, you may be required to rebase your
82
+ feature branch before it can be merged. This is a loose a requirement, but please consider
83
+ squashing interim commits into one or more block commits. The goal here is to keep the master
84
+ branch devoid of commits such as "fixing typo" or "trying out this method." To rebase, run the
85
+ following on your freature branch: ```git rebase -i origin/master```. See the additional
86
+ resources for more information on rebasing.
87
+ 3. After (force) pushing your rebased feature branch, the Merge Request can be merged **as long as
88
+ all tests still pass**.
89
+
90
+ # Additional Resources
91
+
92
+ 1. [Github Flow](https://guides.github.com/introduction/flow/)
93
+ 2. [Code Review Guide](https://github.com/thoughtbot/guides/tree/master/code-review)
94
+ 3. [Style Guide](https://github.com/bbatsov/ruby-style-guide)
95
+ 4. [Git Tips](https://github.com/thoughtbot/guides/blob/master/protocol/git)
96
+ 5. [Git Rebase](https://help.github.com/articles/about-git-rebase/)
97
+ 6. [Auto-squashing Git Commits](https://robots.thoughtbot.com/autosquashing-git-commits)
98
+ 7. [Good Commit Messages](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html)
99
+ 8. [More Good Commit Messages](http://chris.beams.io/posts/git-commit/)
100
+ 9. [Even More Good Commit Messages](http://www.alexkras.com/19-git-tips-for-everyday-use/#good-commit-message)
101
+
102
+ [^1]: Some background and additional reading on squashing commits. [Squashing Commits with Git](https://davidwalsh.name/squash-commits-git) deals with squashing commits in a feature branch. [git rebase --autosquash](https://coderwall.com/p/hh-4ea/git-rebase-autosquash) picks up where the previous article leaves off and explains how the "git rebase" option "--autosquash" complements squashing commits.
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+ source 'https://rubygems.org'
3
+
4
+ # Specify your gem's dependencies in norad.gemspec
5
+ gemspec
data/LICENSE ADDED
@@ -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 2015 Cisco Systems, Inc.
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.
data/README.md ADDED
@@ -0,0 +1,119 @@
1
+ # Norad
2
+
3
+ The norad gem is a command line interface (CLI) to create new security tests and interface with an instance of norad. Currently, the project only contains code to create new security tests.
4
+
5
+ ## Dependencies
6
+
7
+ To use this tool to create new security tests, the only dependencies is Docker. The easiest way to install Docker is through the community edition.
8
+
9
+ [Docker Community Edition](https://www.docker.com/community-edition)
10
+
11
+ The above site contains all the necessary information to install Docker on a Mac, Windows, or Linux machines.
12
+
13
+ ## Installation
14
+
15
+ This utility can be installed simply by:
16
+
17
+ ```
18
+ $ gem install norad
19
+ ```
20
+
21
+ Once installed, a norad executable should be available.
22
+
23
+ ## Usage
24
+
25
+ The norad executable has several subcommands to aid a developer in creating security tests. The tool contains a help interface to provide information about the available subcommand and options. An example of the available help:
26
+
27
+ ```
28
+ $ norad help
29
+ Commands:
30
+ norad help [COMMAND] # Describe available commands or one specific command
31
+ norad repo <command> # Commands for norad security repos housing security tests.
32
+ norad sectest <command> # Commands to create new security tests.
33
+ ```
34
+
35
+ Additional help for subcommands (e.g. repo or sectest) is available by:
36
+
37
+ ```
38
+ $ norad repo help
39
+ Commands:
40
+ norad repo create REPONAME # Create a new norad security test repository called REPONAME
41
+ norad repo help [COMMAND] # Describe subcommands or one specific subcommand
42
+
43
+ ```
44
+
45
+ Individual help for a command is available with:
46
+
47
+ ```
48
+ $ norad repo create --help
49
+ Usage:
50
+ norad create REPONAME
51
+
52
+ Create a new norad security test repository called REPONAME
53
+ ```
54
+
55
+ ### Repo Subcommand
56
+
57
+ The repo subcommand creates a new git repository to house new security tests. It is a helper command which ensures new repositories conform to standard layout and ci best practices. To create a new repository for housing multiple security tests:
58
+
59
+ ```
60
+ $ norad repo create asig-security
61
+ Initializing a new norad security test repository
62
+ create asig-security/base
63
+ create asig-security/spec
64
+ License the repo under Apache 2? y
65
+ Who is the copyright holder (Default: Cisco Systems, Inc.)?
66
+ create asig-security/LICENSE
67
+ create asig-security/.gitlab.ci.yml
68
+ create asig-security/.gitignore
69
+ create asig-security/CONTRIBUTING.md
70
+ create asig-security/README.md
71
+ ```
72
+
73
+ The user will be prompted whether to license the code under Apache 2 and for the copyright holder. The norad framework is released under the Apache 2 license, test content is not required to be licensed the same.
74
+
75
+ As shown, a new directory, asig-security, has been created and multiple files created. Changing directory into asig-security and running git status shows a new git repository waiting for an initial commit:
76
+
77
+ ```
78
+ $ git status
79
+ On branch master
80
+
81
+ Initial commit
82
+
83
+ Untracked files:
84
+ (use "git add <file>..." to include in what will be committed)
85
+
86
+ .gitignore
87
+ .gitlab.ci.yml
88
+ CONTRIBUTING.md
89
+ LICENSE
90
+ README.md
91
+
92
+ nothing added to commit but untracked files present (use "git add" to track)
93
+ ```
94
+
95
+ The repo command is only useful when starting an entirely new repository to house multiple security tests! For general security test development inside of an existing repository see the below sectest subcommand.
96
+
97
+ ### Sectest Subcommand
98
+
99
+ The sectest subcommand is where general security test tool development occurs. The sectest subcommand can scaffold a new security test, build security test docker images, test images, execute a security test, and create a seed file for important into a Norad instance. A listing of the current commands is:
100
+
101
+ ```
102
+ $ norad help sectest
103
+ Commands:
104
+ norad sectest build SECTESTNAME # Builds the docker image for the security test SECTESTNAME
105
+ norad sectest build:all SECTESTNAME # Builds all images for security test SECTESTNAME
106
+ norad sectest build:specs SECTESTNAME # Builds the spec images for the security test SECTESTNAME
107
+ norad sectest execute SECTESTNAME ARGUMENTS # Executes the specified security test SECTESTNAME w/ ARGUMENTS
108
+ norad sectest help [COMMAND] # Describe subcommands or one specific subcommand
109
+ norad sectest scaffold TESTNAME # Create a new security test with standard files + testing
110
+ norad sectest seed # Create the containers.rb seed to import into the api
111
+ norad sectest spec SECTESTNAME # Run the rspec tests for security tool SECTESTNAME
112
+ ```
113
+
114
+ ## Development
115
+
116
+ ## Contributing
117
+
118
+ Bug reports and pull requests are welcome on Gitlab at https://gitlab.com/norad/cli
119
+
data/Rakefile ADDED
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+ require 'bundler/gem_tasks'
3
+ require 'rspec/core/rake_task'
4
+
5
+ RSpec::Core::RakeTask.new(:spec)
6
+
7
+ task default: :spec
data/bin/console ADDED
@@ -0,0 +1,15 @@
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/norad ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby -U
2
+ # frozen_string_literal: true
3
+
4
+ require 'norad_cli'
5
+
6
+ NoradCli::CLI.start(ARGV)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
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
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+ require 'thor'
3
+ require 'norad_cli/cli/secrepo'
4
+ require 'norad_cli/cli/sectest'
5
+
6
+ module NoradCli
7
+ class CLI < Thor
8
+ # Register all of the subcommands
9
+ register(Repo, 'repo', 'repo <command>', 'Commands for norad security repos housing security tests.')
10
+ register(Sectest, 'sectest', 'sectest <command>', 'Commands to create new security tests.')
11
+ end
12
+ end
@@ -0,0 +1,46 @@
1
+ # frozen_string_literal: true
2
+ require 'thor'
3
+ require 'git'
4
+ require 'docker'
5
+
6
+ class Repo < Thor
7
+ include Thor::Actions
8
+
9
+ def self.source_root
10
+ File.join(File.dirname(File.expand_path(__FILE__)), '../templates/')
11
+ end
12
+
13
+ # rubocop:disable Metrics/AbcSize
14
+ # rubocop:disable Metrics/MethodLength
15
+ desc 'create REPONAME', 'Create a new norad security test repository called REPONAME'
16
+ def create(repo_name)
17
+ say 'Initializing a new norad security test repository'
18
+
19
+ # Initialize a new git repository
20
+ Git.init(repo_name)
21
+
22
+ # Create the necessary directories
23
+ %w(base spec).each do |dirrepo_name|
24
+ empty_directory "#{repo_name}/#{dirrepo_name}"
25
+ end
26
+
27
+ # Ask about licensing
28
+ if yes?('License the repo under Apache 2?')
29
+ options[:year] = Date.today.year
30
+ options[:company] = ask('Who is the copyright holder (Default: Cisco Systems, Inc.)?')
31
+ options[:company] = 'Cisco Systems, Inc.' if options[:company].empty?
32
+ template 'LICENSE.erb', "#{repo_name}/LICENSE"
33
+ end
34
+
35
+ # Copy the necessary root files
36
+ copy_file 'ci/.gitlab.ci.yml', "#{repo_name}/.gitlab.ci.yml"
37
+ copy_file '.gitignore', "#{repo_name}/.gitignore"
38
+ copy_file 'CONTRIBUTING.md', "#{repo_name}/CONTRIBUTING.md"
39
+ copy_file 'README.md', "#{repo_name}/README.md"
40
+
41
+ # Copy the spec helper
42
+ copy_file 'spec/spec_helper.rb', "#{repo_name}/spec/spec_helper.rb"
43
+ end
44
+ # rubocop:enable Metrics/AbcSize
45
+ # rubocop:enable Metrics/MethodLength
46
+ end