ssp-creator 0.4.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.
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.1.6
4
+ before_install: gem install bundler -v 1.11.2
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in ssp-creator.gemspec
4
+ gemspec
5
+
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Nathan Gibson
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,41 @@
1
+ # Ssp::Creator
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/ssp/creator`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'ssp-creator'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install ssp-creator
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/ssp-creator.
36
+
37
+
38
+ ## License
39
+
40
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
41
+
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
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
data/bin/ssp ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "ssp/creator"
5
+ $stdout.sync = true
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
+ Ssp::Creator.start
@@ -0,0 +1,5 @@
1
+ module Ssp
2
+ module Creator
3
+ VERSION = "0.4.0"
4
+ end
5
+ end
@@ -0,0 +1,220 @@
1
+ require "ssp/creator/version"
2
+ require 'json'
3
+
4
+ module Ssp
5
+ module Creator
6
+ def Creator.start
7
+
8
+ file = File.read('nist-json.json')
9
+ output = File.new('output.html', 'w')
10
+ data_hash = JSON.parse(file)
11
+ controls = data_hash['controls']['control']
12
+ output.write "Date #{Time.new}"
13
+ controls.each do |c|
14
+ c.each do |key, value|
15
+ value.each do |v|
16
+ case key
17
+ when "family"
18
+ if v != @family
19
+ family = v
20
+ @family = family
21
+ puts "________________FAMILY : #{family}___________________"
22
+ output.write("\n\n________________FAMILY : #{family}___________________\n")
23
+ end
24
+ when "number"
25
+ @control = v
26
+ when "title"
27
+ title = v
28
+ puts "#{@control} : #{title}"
29
+ output.write("\n\n#{@control} : #{title}\n")
30
+ when "priority"
31
+ priority = v
32
+ puts "Priority : #{priority}"
33
+ when "baseline-impact"
34
+ @impact = v
35
+ when "statement"
36
+ output.write("#{v["description"].first}\n")
37
+ v.each do |v2key, v2val|
38
+ if v2val.kind_of?(Array)
39
+ v2val.each do |avals|
40
+ if avals.kind_of?(Hash)
41
+ avals.each do |h2key,h2vals|
42
+ if h2key == "statement"
43
+ h2vals.each do |sval|
44
+ if sval.kind_of?(Hash)
45
+ sval.each do |s2key,s2val|
46
+ case s2key
47
+ when "number"
48
+ @number_l2 = s2val
49
+ when "description"
50
+ @description_l2 = s2val
51
+ puts "#{@number_l2.first} : #{@description_l2.first}"
52
+ output.write("#{@number_l2.first} : #{@description_l2.first}\n")
53
+ else
54
+ puts s2val
55
+ output.write("#{@number_l2.first} : #{s2val}\n")
56
+ end
57
+ end
58
+ else
59
+ puts sval
60
+ output.write("#{@number_l2.first} : #{sval}\n")
61
+ end
62
+ end
63
+ else
64
+ case h2key
65
+ when "number"
66
+ @number_l1 = h2vals
67
+ when "description"
68
+ @description_l1 = h2vals
69
+ puts "#{@number_l1.first} : #{@description_l1.first}"
70
+ output.write("#{@number_l1.first} : #{@description_l1.first}\n")
71
+ else
72
+ puts h2vals
73
+ end
74
+ end
75
+ end
76
+ else
77
+ puts avals
78
+ end
79
+ end
80
+ end
81
+ end
82
+ when "supplemental-guidance"
83
+ puts "Supplmental Guidance: "
84
+ output.write("\nSupplmental Guidance:\n")
85
+ if v.key?("description")
86
+ output.write("#{v["description"].first}\n\n")
87
+ end
88
+ if v.key?("related")
89
+ output.write("Related Controls: \n")
90
+ v["related"].each do |r|
91
+ output.write("#{r}\n")
92
+ end
93
+ output.write("\n")
94
+ end
95
+
96
+ when "control-enhancements"
97
+ puts "Control Enhancements: "
98
+ output.write("Control Enhancements: \n")
99
+ v.each do |value_ch_key,value_ch|
100
+ value_ch.each do |v_ch|
101
+ v_ch.each do |v_ch_key, v_ch_value|
102
+ case v_ch_key
103
+ when "number"
104
+ @control_ch = v_ch_value
105
+ when "title"
106
+ title_ch = v_ch_value
107
+ puts "#{@control_ch.first} : #{title_ch.first}"
108
+ output.write("#{@control_ch.first} : #{title_ch.first}\n")
109
+ when "baseline-impact"
110
+ @impact_ch = v_ch_value
111
+ when "statement"
112
+ v_ch_value.each do |v2key_ch, v2val_ch|
113
+ if v2val_ch.kind_of?(Array)
114
+ v2val_ch.each do |avals_ch|
115
+ if avals_ch.kind_of?(Hash)
116
+ avals_ch.each do |h2key_ch,h2vals_ch|
117
+ if h2key_ch == "statement"
118
+ h2vals_ch.each do |sval_ch|
119
+ if sval_ch.kind_of?(Hash)
120
+ sval_ch.each do |s2key_ch,s2val_ch|
121
+ case s2key_ch
122
+ when "number"
123
+ @number_l2_ch = s2val_ch
124
+ when "description"
125
+ @description_l2_ch = s2val_ch
126
+ puts "#{@number_l2_ch.first} : #{@description_l2_ch.first}"
127
+ output.write("#{@number_l2_ch.first} : #{@description_l2_ch.first}\n")
128
+ else
129
+ puts s2val_ch
130
+ end
131
+ end
132
+ else
133
+ puts sval_ch
134
+ end
135
+ end
136
+ else
137
+ case h2key_ch
138
+ when "number"
139
+ @number_l1_ch = h2vals_ch
140
+ when "description"
141
+ @description_l1_ch = h2vals_ch
142
+ puts "#{@number_l1_ch.first} : #{@description_l1_ch.first}"
143
+ output.write("#{@number_l1_ch.first} : #{@description_l1_ch.first}")
144
+ else
145
+ puts h2vals_ch
146
+ end
147
+ end
148
+ end
149
+ else
150
+ puts avals_ch
151
+ end
152
+ end
153
+ end
154
+ end
155
+ when "supplemental-guidance"
156
+ puts "Supplmental Guidance: "
157
+ v.each do |v2key, v2val|
158
+ if v2val.kind_of?(Array)
159
+ v2val.each do |avals|
160
+ if avals.kind_of?(Hash)
161
+ avals.each do |h2key,h2vals|
162
+ if h2key == "description"
163
+ h2vals.each do |sval|
164
+ if sval.kind_of?(Hash)
165
+ sval.each do |s2key,s2val|
166
+ case s2key
167
+ when "description"
168
+ @description_sup = s2val
169
+ puts @description_sup
170
+ output.write("#{@description_sup}\n")
171
+ else
172
+ puts s2val
173
+ end
174
+ end
175
+ else
176
+ puts sval
177
+ end
178
+ end
179
+ else
180
+ case h2key
181
+ when "number"
182
+ @number_l1 = h2vals
183
+ when "description"
184
+ @description_l1 = h2vals
185
+ puts "#{@number_l1.first} : #{@description_l1.first}"
186
+ output.write("#{@number_l1.first} : #{@description_l1.first}\n")
187
+ else
188
+ puts h2vals
189
+ end
190
+ end
191
+ end
192
+ else
193
+ puts avals
194
+ end
195
+ end
196
+ end
197
+ end
198
+ when "control-enhancements"
199
+ puts "Control Enhancements: "
200
+ @enhancement = v
201
+ puts @enhancement
202
+ output.write("#{@enhancement}\n")
203
+ else
204
+ puts v
205
+ end
206
+ end
207
+ end
208
+ end
209
+ else
210
+ puts v
211
+ end
212
+ end
213
+ end
214
+ end
215
+ end
216
+ end
217
+ end
218
+
219
+
220
+