-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathSTIG_Parser.rb
50 lines (37 loc) · 1.03 KB
/
STIG_Parser.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/usr/bin/ruby
#created by mhassan772
#This parser will get you the title and how to check the finding. You may uncomment the fix part to get the fix too.
#You wil need to install nokogiri gem | sudo gem install nokogiri
def usage()
puts "Usage is:"
puts "#{__FILE__} path/to/STIG/file.xml"
puts
end
file_location = ARGV[0]
if ARGV.empty?
usage
exit
end
require 'nokogiri'
f = File.read(file_location)
doc = Nokogiri::XML(f)
groups_xml =
doc.css('Group').each do |node|
title = "#{node.css('Rule').css('title')}"
title.slice! "<title>"
title.slice! "</title>"
puts "The title is: "
puts title
check = "#{node.css('Rule').css('check').css('check-content')}"
check.slice! "</check-content>"
check.slice! ("<check-content>")
puts "How to check: "
puts check
#fix = "#{node.css('Rule').css('fixtext')}"
#fix.slice! "</fixtext>"
#fix.slice! (/<fixtext fixref=\"F-.*_fix\">/)
#puts "The fix is: "
#puts fix
puts "######################################"
puts "######################################"
end