inspec_tools 2.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE.md +15 -0
- data/README.md +373 -0
- data/Rakefile +96 -0
- data/exe/inspec_tools +14 -0
- data/lib/data/README.TXT +25 -0
- data/lib/data/U_CCI_List.xml +38403 -0
- data/lib/data/attributes.yml +23 -0
- data/lib/data/cci2html.xsl +136 -0
- data/lib/data/cis_to_nist_critical_controls +0 -0
- data/lib/data/cis_to_nist_mapping +0 -0
- data/lib/data/mapping.yml +17 -0
- data/lib/data/rubocop.yml +4 -0
- data/lib/data/stig.csv +1 -0
- data/lib/data/threshold.yaml +83 -0
- data/lib/exceptions/impact_input_error.rb +6 -0
- data/lib/exceptions/severity_input_error.rb +6 -0
- data/lib/happy_mapper_tools/benchmark.rb +161 -0
- data/lib/happy_mapper_tools/cci_attributes.rb +66 -0
- data/lib/happy_mapper_tools/stig_attributes.rb +216 -0
- data/lib/happy_mapper_tools/stig_checklist.rb +99 -0
- data/lib/inspec_tools.rb +17 -0
- data/lib/inspec_tools/ckl.rb +20 -0
- data/lib/inspec_tools/cli.rb +31 -0
- data/lib/inspec_tools/csv.rb +101 -0
- data/lib/inspec_tools/help.rb +9 -0
- data/lib/inspec_tools/help/compliance.md +7 -0
- data/lib/inspec_tools/help/csv2inspec.md +5 -0
- data/lib/inspec_tools/help/inspec2ckl.md +5 -0
- data/lib/inspec_tools/help/inspec2csv.md +5 -0
- data/lib/inspec_tools/help/inspec2xccdf.md +5 -0
- data/lib/inspec_tools/help/pdf2inspec.md +6 -0
- data/lib/inspec_tools/help/summary.md +5 -0
- data/lib/inspec_tools/help/xccdf2inspec.md +5 -0
- data/lib/inspec_tools/inspec.rb +331 -0
- data/lib/inspec_tools/pdf.rb +125 -0
- data/lib/inspec_tools/plugin.rb +15 -0
- data/lib/inspec_tools/plugin_cli.rb +275 -0
- data/lib/inspec_tools/summary.rb +126 -0
- data/lib/inspec_tools/version.rb +8 -0
- data/lib/inspec_tools/xccdf.rb +156 -0
- data/lib/inspec_tools/xlsx_tool.rb +135 -0
- data/lib/inspec_tools_plugin.rb +7 -0
- data/lib/overrides/false_class.rb +5 -0
- data/lib/overrides/nil_class.rb +5 -0
- data/lib/overrides/object.rb +5 -0
- data/lib/overrides/string.rb +5 -0
- data/lib/overrides/true_class.rb +5 -0
- data/lib/utilities/cis_to_nist.rb +11 -0
- data/lib/utilities/csv_util.rb +14 -0
- data/lib/utilities/extract_pdf_text.rb +20 -0
- data/lib/utilities/inspec_util.rb +441 -0
- data/lib/utilities/parser.rb +373 -0
- data/lib/utilities/text_cleaner.rb +69 -0
- metadata +359 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: c551987d4bfca9ae4d14630f4beb3f4dd6cbe78314a2f229d5df49b4c72cd0e2
|
4
|
+
data.tar.gz: d0553cb380d6103f21b879fdb43d39c502ba94d80cc6b30ae8c69cf246464f4d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: ffb7fa2a36d380a08c193fc0b1295c74a9479ef54ac5085cf3f36072509d67d235603c6fb589e81ce6c1d52544793fab3b91d37153e303923e7c99bb843f4510
|
7
|
+
data.tar.gz: 8e10eacec2b81f6a7c57198cc817050ee501ede1a390e347be50c80429d3834d506eb1f417b9f659ef0c620240d36e15cd65e118ea59fbbaa5481131cba4eb38
|
data/LICENSE.md
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
Licensed under the Apache 2.0 license.
|
2
|
+
|
3
|
+
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
4
|
+
|
5
|
+
* Redistributions of source code must retain the above copyright/ digital rights legend, this list of conditions and the following Notice.
|
6
|
+
|
7
|
+
* Redistributions in binary form must reproduce the above copyright copyright/ digital rights legend, this list of conditions and the following Notice in the documentation and/or other materials provided with the distribution.
|
8
|
+
|
9
|
+
* Neither the name of The MITRE Corporation nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
10
|
+
|
11
|
+
MITRE’s licensed products include third-party materials that are subject to open source or free software licenses (“Open Source Materials”). The Open Source Materials are as follows:
|
12
|
+
|
13
|
+
* CIS Benchmarks. Please visit www.cissecurity.org for full terms of use.
|
14
|
+
|
15
|
+
The Open Source Materials are licensed under the terms of the applicable third-party licenses that accompany the Open Source Materials. MITTRE’s license does not limit a licensee’s rights under the terms of the Open Source Materials license. MITRE’s license also does not grant licensee rights to the Open Source Materials that supersede the terms and conditions of the Open Source Materials license.
|
data/README.md
ADDED
@@ -0,0 +1,373 @@
|
|
1
|
+
# InspecTools
|
2
|
+
|
3
|
+
![Overall Status](https://github.com/mitre/inspec_tools/workflows/inspec_tools/badge.svg)
|
4
|
+
![Inspec Tools Release](https://github.com/mitre/inspec_tools/workflows/Release%20Management/badge.svg)
|
5
|
+
|
6
|
+
InspecTools supplies several CLI tools to convert to and from InSpec format.
|
7
|
+
|
8
|
+
The inspec_tools support the following modules:
|
9
|
+
|
10
|
+
- generate_map
|
11
|
+
- generate_ckl_metadata
|
12
|
+
- generate_inspec_metadata
|
13
|
+
- compliance
|
14
|
+
- summary
|
15
|
+
- csv2inspec
|
16
|
+
- inspec2csv
|
17
|
+
- xccdf2inspec
|
18
|
+
- inspec2xccdf
|
19
|
+
- inspec2ckl
|
20
|
+
- pdf2inspec
|
21
|
+
- xlsx2inspec
|
22
|
+
|
23
|
+
It also includes an API that can be used in a ruby application. The Ruby API is defined in lib/inspec_tools/inspec.rb
|
24
|
+
|
25
|
+
# Installation
|
26
|
+
|
27
|
+
Ensure `happymapper` is not installed, as it will take precedence over `nokogiri-happymapper`.
|
28
|
+
|
29
|
+
Add this line to your application's Gemfile:
|
30
|
+
|
31
|
+
```
|
32
|
+
gem 'inspec_tools'
|
33
|
+
```
|
34
|
+
|
35
|
+
# Usage
|
36
|
+
|
37
|
+
## Ruby Usage
|
38
|
+
|
39
|
+
The gem exposes methods for converting from an InSpec results JSON to three formats: CKL, XCCDF, and CSV. In the ruby file add a require statement:
|
40
|
+
|
41
|
+
```
|
42
|
+
require 'inspec_tools'
|
43
|
+
```
|
44
|
+
|
45
|
+
Pass in the results JSON object to the InspecTools class to get an object that can convert the results into the three formats:
|
46
|
+
|
47
|
+
```
|
48
|
+
tool = InspecTools::Inspec.new(results_json)
|
49
|
+
ckl_reuslts = tool.to_ckl
|
50
|
+
csv_results = tool.to_ccsv
|
51
|
+
```
|
52
|
+
|
53
|
+
The XCCDF converter requires a parameter - a JSON object containing attributes that exist in the XCCDF format, but don't exist in the InSpec results JSON. There's an example of these attributes at [examples/attribute.json](examples/attribute.json).
|
54
|
+
|
55
|
+
```
|
56
|
+
xccdf_results = tool.to_xccdf(attribs_json)
|
57
|
+
```
|
58
|
+
|
59
|
+
## Command line Usage
|
60
|
+
|
61
|
+
On the Command Line, `inspec_tools help` will print a listing of all the command with a short description.
|
62
|
+
For detailed help on any command, run `inspec_tools help [COMMAND]`. Help can also be called with the `-h, --help` flags after any command, like `inspec_tools xccdf2inspec -h`.
|
63
|
+
|
64
|
+
For Docker usage, replace the `inspec_tools` command with the correct Docker command below for your operating system:
|
65
|
+
|
66
|
+
- **On Linux and Mac**: `docker run -it -v$(pwd):/share mitre/inspec_tools`
|
67
|
+
- **On Windows CMD**: `docker run -it -v%cd%:/share mitre/inspec_tools`
|
68
|
+
|
69
|
+
Note that all of the above Docker commands will mount your current directory on the Docker container. Ensure that you have navigated to the directory you intend to convert files in before executing the command.
|
70
|
+
|
71
|
+
### generate_map
|
72
|
+
|
73
|
+
This command will generate a `mapping.xml` file that can be passed in to the `csv2inspec` command with the `--m` option.
|
74
|
+
|
75
|
+
```
|
76
|
+
USAGE: inspec_tools generate_map
|
77
|
+
```
|
78
|
+
|
79
|
+
## generate_ckl_metadata
|
80
|
+
|
81
|
+
This command will generate a `metadata.json` file that can be passed in to the `inspec2ckl` command with the `-m` option.
|
82
|
+
|
83
|
+
```
|
84
|
+
USAGE: inspec_tools generate_ckl_metadata
|
85
|
+
```
|
86
|
+
|
87
|
+
## generate_inspec_metadata
|
88
|
+
|
89
|
+
This command will generate a `metadata.json` file that can be passed in to the `xccdf2inspec` command with the `-m` option.
|
90
|
+
|
91
|
+
```
|
92
|
+
USAGE: inspec_tools generate_inspec_metadata
|
93
|
+
```
|
94
|
+
|
95
|
+
## compliance
|
96
|
+
|
97
|
+
`compliance` parses an inspec results json to check if the compliance level meets a specified threshold.
|
98
|
+
|
99
|
+
If the specified threshold is not met, an error code (1) is returned along with non-compliant elements.
|
100
|
+
|
101
|
+
The compliance score are rounded down to the nearest whole number. For example a score of 77.3 would be displayed as 77.
|
102
|
+
|
103
|
+
```
|
104
|
+
USAGE: inspec_tools compliance [OPTIONS] -j <inspec-json> -i <threshold-inline>
|
105
|
+
inspec_tools compliance [OPTIONS] -j <inspec-json> -f <threshold-file>
|
106
|
+
FLAGS:
|
107
|
+
-j --inspec-json <inspec-json> : path to InSpec results Json
|
108
|
+
-i --template-inline <threshold-inline> : inline compliance threshold definition
|
109
|
+
-f --template-file <threshold-file> : yaml file with compliance threshold definition
|
110
|
+
Examples:
|
111
|
+
|
112
|
+
inspec_tools compliance -j examples/sample_json/rhel-simp.json -i '{compliance.min: 80, failed.critical.max: 0, failed.high.max: 0}'
|
113
|
+
|
114
|
+
inspec_tools compliance -j examples/sample_json/rhel-simp.json -f examples/sample_yaml/threshold.yaml
|
115
|
+
```
|
116
|
+
|
117
|
+
### YAML file or In-line threshold definition styles:
|
118
|
+
|
119
|
+
#### File Examples
|
120
|
+
```
|
121
|
+
failed:
|
122
|
+
critical:
|
123
|
+
max: 0
|
124
|
+
high:
|
125
|
+
max: 1
|
126
|
+
compliance:
|
127
|
+
min: 81
|
128
|
+
```
|
129
|
+
|
130
|
+
```
|
131
|
+
compliance.min: 81
|
132
|
+
failed.critical.max: 1
|
133
|
+
failed.high.max: 1
|
134
|
+
```
|
135
|
+
|
136
|
+
#### In-Line Examples
|
137
|
+
```
|
138
|
+
{compliance: {min: 90}, failed: {critical: {max: 0}, high: {max: 0}}}
|
139
|
+
```
|
140
|
+
|
141
|
+
```
|
142
|
+
{compliance.min: 81, failed.critical.max: 0, failed.high.max: 0}
|
143
|
+
```
|
144
|
+
|
145
|
+
## summary
|
146
|
+
|
147
|
+
`summary` parses an inspec results json and displays the information from all of the tests that were run. Running the command with flags but `-j` it will display information like:
|
148
|
+
|
149
|
+
```
|
150
|
+
Overall compliance: 77%
|
151
|
+
|
152
|
+
failed
|
153
|
+
total : 41
|
154
|
+
critical : 0
|
155
|
+
high : 3
|
156
|
+
medium : 33
|
157
|
+
low : 5
|
158
|
+
passed
|
159
|
+
total : 174
|
160
|
+
critical : 0
|
161
|
+
high : 21
|
162
|
+
medium : 147
|
163
|
+
low : 6
|
164
|
+
no_impact
|
165
|
+
total : 21
|
166
|
+
critical : 0
|
167
|
+
high : 0
|
168
|
+
medium : 0
|
169
|
+
low : 0
|
170
|
+
skipped
|
171
|
+
total : 10
|
172
|
+
critical : 0
|
173
|
+
high : 2
|
174
|
+
medium : 5
|
175
|
+
low : 3
|
176
|
+
error
|
177
|
+
total : 0
|
178
|
+
critical : 0
|
179
|
+
high : 0
|
180
|
+
medium : 0
|
181
|
+
low : 0
|
182
|
+
```
|
183
|
+
|
184
|
+
Using additional flags will override the normal output and only display the output that flag specifies.
|
185
|
+
|
186
|
+
USAGE: inspec_tools summary [OPTIONS] -j <inspec-json>
|
187
|
+
|
188
|
+
```
|
189
|
+
FLAGS:
|
190
|
+
-j --inspec-json <inspec-json> : path to InSpec results JSON
|
191
|
+
-V --verbose, --no-verbose : print verbose an debug output
|
192
|
+
-f --json-full, --no-json-full : print the summary STDOUT as JSON
|
193
|
+
-k --json-counts, --no-json_cou : print the reslut status to STDOUT as JSON
|
194
|
+
|
195
|
+
Examples:
|
196
|
+
|
197
|
+
inspec_tools summary -j examples/sample_json/rhel-simp.json -f
|
198
|
+
```
|
199
|
+
|
200
|
+
## xccdf2inspec
|
201
|
+
|
202
|
+
`xccdf2inspec` converts a STIG XCCDF file to an InSpec profile
|
203
|
+
|
204
|
+
```
|
205
|
+
USAGE: inspec_tools xccdf2inspec [OPTIONS] -x <xccdf-file>
|
206
|
+
|
207
|
+
FLAGS:
|
208
|
+
-x --xccdf <xccdf-file> : path to the disa stig xccdf file
|
209
|
+
-a --attributes <xccdf-attr-yml> : path to yml file to save XCCDF values which do not fit into the InSpec schema. These are useful if you want to convert the resulting profile back into XCCDF [optional]
|
210
|
+
-o --output <profile-path> : path to the InSpec profile output (default: profile) [optional]
|
211
|
+
-f --format [ruby | hash] : the format you would like (default: ruby) [optional]
|
212
|
+
-s --separate-files [true | false] : output the resulting controls as one or mutiple files (default: true) [optional]
|
213
|
+
-m --metadata <metadata-json> : path to json file with additional metadata for the inspec.yml file [optional]
|
214
|
+
-r --replace-tags <array> : A case-sensitive, space separated list to replace tags with a $ if found in a group rules description tag [optional]
|
215
|
+
|
216
|
+
example: inspec_tools xccdf2inspec -x xccdf_file.xml -a attributes.yml -o myprofile -f ruby -s false
|
217
|
+
```
|
218
|
+
|
219
|
+
## inspec2xccdf
|
220
|
+
|
221
|
+
`inspec2xccdf` converts an InSpec profile in json format to a STIG XCCDF Document
|
222
|
+
|
223
|
+
```
|
224
|
+
USAGE: inspec_tools inspec2xccdf [OPTIONS] -j <inspec-json> -a <xccdf-attr-yml> -o <xccdf-xml>
|
225
|
+
|
226
|
+
FLAGS:
|
227
|
+
-j --inspec-json <inspec-json> : path to InSpec Json file created using command 'inspec json <profile> > example.json'
|
228
|
+
-a --attributes <xccdf-attr-yml> : path to yml file that provides the required attributes for the XCCDF Document. these attributes are parts of XCCDF document which do not fit into the InSpec schema
|
229
|
+
-o --output <xccdf-xml> : name or path to create the xccdf and title to give the xccdf
|
230
|
+
-V --verbose : verbose run [optional]
|
231
|
+
|
232
|
+
example: inspec_tools inspec2xccdf -j example.json -a attributes.yml -o xccdf.xml
|
233
|
+
```
|
234
|
+
|
235
|
+
## csv2inspec
|
236
|
+
|
237
|
+
`csv2inspec` converts a csv security control spreadsheet of STIG controls to an InSpec profile
|
238
|
+
|
239
|
+
```
|
240
|
+
USAGE: inspec_tools csv2inspec [OPTIONS] -c <stig-csv> -m <map-yml>
|
241
|
+
|
242
|
+
FLAGS:
|
243
|
+
-c --csv <stig-csv> : path to DISA Stig style csv
|
244
|
+
-m --mapping <map-yml> : path to yaml with mapping from CSV to InSpec Controls
|
245
|
+
-V --verbose : verbose run [optional]
|
246
|
+
-o --output <profile-path> : path to the InSpec profile output (default: profile) [optional]
|
247
|
+
-f --format [ruby | hash] : the format you would like (default: ruby) [optional]
|
248
|
+
-s --separate-files [true | false] : separate the controls into different files (default: true) [optional]
|
249
|
+
|
250
|
+
example: inspec_tools csv2inspec -c examples/csv2inspec/stig.csv -m examples/csv2inspec/mapping.yml -o mydir -f ruby -s true # To map stig.csv to InSpec via mapping.yml
|
251
|
+
```
|
252
|
+
|
253
|
+
## inspec2csv
|
254
|
+
|
255
|
+
`inspec2csv` converts an InSpec profile in json format to a csv security control spreadsheet
|
256
|
+
|
257
|
+
```
|
258
|
+
USAGE: inspec_tools inspec2csv [OPTIONS] -j <inspec-json> -o <profile-csv>
|
259
|
+
|
260
|
+
FLAGS:
|
261
|
+
-j --inspec-json <inspec-json> : path to InSpec json file
|
262
|
+
-o --output <profile-csv> : path to output csv
|
263
|
+
-V --verbose : run in verbose mode [optional]
|
264
|
+
|
265
|
+
example: inspec_tools inspec2csv -j inspec_profile.json -o mycsv.csv
|
266
|
+
```
|
267
|
+
|
268
|
+
## inspec2ckl
|
269
|
+
|
270
|
+
`inspec2ckl` translates an InSpec results json into Stig Checklist
|
271
|
+
|
272
|
+
```
|
273
|
+
USAGE: inspec_tools inspec2ckl [OPTIONS] -j <inspec-json> -o <results-ckl>
|
274
|
+
|
275
|
+
FLAGS:
|
276
|
+
-j --inspec-json <inspec-json> : path to InSpec results json file
|
277
|
+
-o --output <results-ckl> : path to output checklist file
|
278
|
+
-m --metadata <metadata-json> : path to json file with additional metadata for the checklist file [optional]
|
279
|
+
-V --verbose : verbose run [optional]
|
280
|
+
|
281
|
+
example: inspec_tools inspec2ckl -j results.json -o output.ckl
|
282
|
+
```
|
283
|
+
|
284
|
+
## pdf2inspec
|
285
|
+
|
286
|
+
`pdf2inspec` translates a pdf containing a CIS benchmark into an InSpec profile.
|
287
|
+
|
288
|
+
```
|
289
|
+
USAGE: inspec_tools pdf2inspec [OPTIONS] -p <cis-benchmark>
|
290
|
+
|
291
|
+
FLAGS:
|
292
|
+
-p --pdf <cis-benchmark> : path to CIS Benchmark pdf file
|
293
|
+
-o --output <profile-path> : path to the InSpec profile output (default: profile) [optional]
|
294
|
+
-f --format [ruby | hash] : the format you would like (default: ruby) [optional]
|
295
|
+
-s --separate-files [true | false] : output the resulting controls as multiple files (default: true) [optional]
|
296
|
+
-d --debug : debug run [optional]
|
297
|
+
|
298
|
+
example: inspec_tools pdf2inspec -p examples/CIS_Ubuntu_Linux_16.04_LTS_Benchmark_v1.0.0.pdf -o /path/to/myprofile -f ruby -s true
|
299
|
+
```
|
300
|
+
|
301
|
+
## xlsx2inspec
|
302
|
+
```
|
303
|
+
Usage:
|
304
|
+
inspec_tools xlsx2inspec -m, --mapping=MAPPING -p, --control-name-prefix=CONTROL_NAME_PREFIX -x, --xlsx=XLSX
|
305
|
+
|
306
|
+
Options:
|
307
|
+
-x, --xlsx=XLSX
|
308
|
+
-m, --mapping=MAPPING
|
309
|
+
-p, --control-name-prefix=CONTROL_NAME_PREFIX
|
310
|
+
-V, [--verbose], [--no-verbose]
|
311
|
+
-o, [--output=OUTPUT]
|
312
|
+
# Default: profile
|
313
|
+
-f, [--format=FORMAT]
|
314
|
+
# Default: ruby
|
315
|
+
# Possible values: ruby, hash
|
316
|
+
-s, [--separate-files], [--no-separate-files]
|
317
|
+
# Default: true
|
318
|
+
[--log-level=LOG_LEVEL] # Set the logging level: ["debug", "info", "warn", "error", "fatal"]
|
319
|
+
[--log-location=LOG_LOCATION] # Location to send diagnostic log messages to. (default: $stdout or Inspec::Log.error)
|
320
|
+
l, [--log-directory=LOG_DIRECTORY] # Provie log location
|
321
|
+
|
322
|
+
xlsx2inspec translates CIS Benchmarks in XLSX format to Inspec controls using a mapping file
|
323
|
+
|
324
|
+
See examples/xlsx2inspec/mapping.cis.yml for an example mapping file
|
325
|
+
|
326
|
+
example: bundle exec inspec_tools xlsx2inspec -m examples/xlsx2inspec/mapping.cis.yml -p azure-cis-foundations -x examples/cis.xlsx
|
327
|
+
```
|
328
|
+
|
329
|
+
## version
|
330
|
+
|
331
|
+
Prints out the gem version
|
332
|
+
|
333
|
+
```
|
334
|
+
USAGE: inspec_tools version
|
335
|
+
```
|
336
|
+
|
337
|
+
# Format of Input and Output Files
|
338
|
+
|
339
|
+
InspecTools will make a best effort approach when converting various legacy terms and values in input files. If some terminology is not supported, please open an issue.
|
340
|
+
|
341
|
+
InspecTools is opinionated about the output of its profiles. Profiles generated by InspecTools generally attempt to adhere to latest National Institute of Standards and Technology (NIST) terms and values, such as the Common Vulnerability Scoring System (CVSS).
|
342
|
+
|
343
|
+
View our wiki pages on [expected](https://github.com/mitre/inspec_tools/wiki/Expected-Input) input and [expected output](https://github.com/mitre/inspec_tools/wiki/Expected-Output) for more information about what is currently supported input and expected output.
|
344
|
+
|
345
|
+
# `inspec_tools` Development
|
346
|
+
|
347
|
+
View our [wiki page](https://github.com/mitre/inspec_tools/wiki/Development) for more information on contributing.
|
348
|
+
|
349
|
+
# Publishing a Release
|
350
|
+
|
351
|
+
If you are a maintainer, it is very easy to cut a release of this gem:
|
352
|
+
|
353
|
+
1. Click on "Releases" and there should be a draft pending.
|
354
|
+
2. Make sure the Tag version and Release title match!
|
355
|
+
3. Add any additional notes can be added in the Description box.
|
356
|
+
4. Click "Publish release".
|
357
|
+
5. Release notes will be posted and a new gem will be pushed to Rubygems & Github Packages with the version you specified on step 2.
|
358
|
+
|
359
|
+
### NOTICE
|
360
|
+
|
361
|
+
© 2018 The MITRE Corporation.
|
362
|
+
|
363
|
+
Approved for Public Release; Distribution Unlimited. Case Number 18-3678.
|
364
|
+
|
365
|
+
### NOTICE
|
366
|
+
|
367
|
+
MITRE hereby grants express written permission to use, reproduce, distribute, modify, and otherwise leverage this software to the extent permitted by the licensed terms provided in the LICENSE.md file included with this project.
|
368
|
+
|
369
|
+
### NOTICE
|
370
|
+
|
371
|
+
This software was produced for the U. S. Government under Contract Number HHSM-500-2012-00008I, and is subject to Federal Acquisition Regulation Clause 52.227-14, Rights in Data-General.
|
372
|
+
|
373
|
+
No other use other than that granted to the U. S. Government, or to those acting on behalf of the U. S. Government under that Clause is authorized without the express written permission of The MITRE Corporation. DISA STIGs are published by DISA, see: https://public.cyber.mil/privacy-security/
|
data/Rakefile
ADDED
@@ -0,0 +1,96 @@
|
|
1
|
+
require 'rake/testtask'
|
2
|
+
require File.expand_path('../lib/inspec_tools/version', __FILE__)
|
3
|
+
|
4
|
+
Rake::TestTask.new(:test) do |t|
|
5
|
+
t.libs << 'test'
|
6
|
+
t.libs << 'lib'
|
7
|
+
t.test_files = FileList['test/**/*_test.rb']
|
8
|
+
end
|
9
|
+
|
10
|
+
namespace :test do
|
11
|
+
Rake::TestTask.new(:windows) do |t|
|
12
|
+
t.libs << 'test'
|
13
|
+
t.libs << "lib"
|
14
|
+
t.test_files = Dir.glob([
|
15
|
+
'test/unit/inspec_tools/csv_test.rb',
|
16
|
+
'test/unit/inspec_tools/inspec_test.rb',
|
17
|
+
'test/unit/inspec_tools/xccdf_test.rb',
|
18
|
+
'test/unit/utils/inspec_util_test.rb',
|
19
|
+
'test/unit/inspec_tools_test.rb'
|
20
|
+
])
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
desc 'Build for release'
|
25
|
+
task :build_release do
|
26
|
+
|
27
|
+
Rake::Task["generate_mapping_objects"].reenable
|
28
|
+
Rake::Task["generate_mapping_objects"].invoke
|
29
|
+
|
30
|
+
system('gem build inspec_tools.gemspec')
|
31
|
+
end
|
32
|
+
|
33
|
+
desc 'Generate mapping objects'
|
34
|
+
task :generate_mapping_objects do
|
35
|
+
require 'roo'
|
36
|
+
|
37
|
+
nist_mapping_cis_controls = ENV['NIST_MAPPING_CIS_CONTROLS'] || 'NIST_Map_02052020_CIS_Controls_Version_7.1_Implementation_Groups_1.2.xlsx'.freeze
|
38
|
+
nist_mapping_cis_critical_controls = ENV['NIST_MAPPING_CIS_CRITICAL_CONTROLS'] || 'NIST_Map_09212017B_CSC-CIS_Critical_Security_Controls_VER_6.1_Excel_9.1.2016.xlsx'.freeze
|
39
|
+
|
40
|
+
data_root_path = File.join(File.expand_path(__dir__), 'lib', 'data')
|
41
|
+
cis_controls_path = File.join(data_root_path, nist_mapping_cis_controls)
|
42
|
+
cis_critical_controls_path = File.join(data_root_path, nist_mapping_cis_critical_controls)
|
43
|
+
|
44
|
+
raise "#{cis_controls_path} does not exist" unless File.exist?(cis_controls_path)
|
45
|
+
|
46
|
+
raise "#{cis_critical_controls_path} does not exist" unless File.exist?(cis_critical_controls_path)
|
47
|
+
|
48
|
+
marshal_cis_controls(cis_controls_path, data_root_path)
|
49
|
+
marshal_cis_critical_controls(cis_critical_controls_path, data_root_path)
|
50
|
+
end
|
51
|
+
|
52
|
+
def marshal_cis_controls(cis_controls_path, data_root_path)
|
53
|
+
cis_to_nist = {}
|
54
|
+
Roo::Spreadsheet.open(cis_controls_path).sheet(3).each do |row|
|
55
|
+
if row[3].is_a?(Numeric)
|
56
|
+
cis_to_nist[row[3].to_s] = row[0]
|
57
|
+
else
|
58
|
+
cis_to_nist[row[2].to_s] = row[0] unless (row[2] == '') || row[2].to_i.nil?
|
59
|
+
end
|
60
|
+
end
|
61
|
+
output_file = File.new(File.join(data_root_path, 'cis_to_nist_mapping'), 'w')
|
62
|
+
Marshal.dump(cis_to_nist, output_file)
|
63
|
+
output_file.close
|
64
|
+
end
|
65
|
+
|
66
|
+
def marshal_cis_critical_controls(cis_critical_controls_path, data_root_path)
|
67
|
+
controls_spreadsheet = Roo::Spreadsheet.open(cis_critical_controls_path)
|
68
|
+
controls_spreadsheet.default_sheet = 'VER 6.1 Controls'
|
69
|
+
headings = {}
|
70
|
+
controls_spreadsheet.row(3).each_with_index { |header, idx| headings[header] = idx }
|
71
|
+
|
72
|
+
nist_ver = 4
|
73
|
+
cis_ver = controls_spreadsheet.row(2)[4].split(' ')[-1]
|
74
|
+
control_count = 1
|
75
|
+
mapping = []
|
76
|
+
((controls_spreadsheet.first_row + 3)..controls_spreadsheet.last_row).each do |row_value|
|
77
|
+
current_row = {}
|
78
|
+
if controls_spreadsheet.row(row_value)[headings['NIST SP 800-53 Control #']].to_s != ''
|
79
|
+
current_row[:nist] = controls_spreadsheet.row(row_value)[headings['NIST SP 800-53 Control #']].to_s
|
80
|
+
else
|
81
|
+
current_row[:nist] = 'Not Mapped'
|
82
|
+
end
|
83
|
+
current_row[:nist_ver] = nist_ver
|
84
|
+
if controls_spreadsheet.row(row_value)[headings['Control']].to_s == ''
|
85
|
+
current_row[:cis] = control_count.to_s
|
86
|
+
control_count += 1
|
87
|
+
else
|
88
|
+
current_row[:cis] = controls_spreadsheet.row(row_value)[headings['Control']].to_s
|
89
|
+
end
|
90
|
+
current_row[:cis_ver] = cis_ver
|
91
|
+
mapping << current_row
|
92
|
+
end
|
93
|
+
output_file = File.new(File.join(data_root_path, 'cis_to_nist_critical_controls'), 'w')
|
94
|
+
Marshal.dump(mapping, output_file)
|
95
|
+
output_file.close
|
96
|
+
end
|