mitre / inspec_tools

A command-line and ruby API of utilities, converters and tools for creating, converting and processing security baseline formats, results and data
https://inspec-tools.mitre.org/
Other
91 stars 30 forks source link

CIS XCCDF Schema `insert_json_metadata': undefined method `plaintext' for nil:NilClass (NoMethodError) #71

Closed rcolanero closed 2 years ago

rcolanero commented 5 years ago

Getting an error similar to #63 but instead of 'version' I'm seeing it for 'plaintext'.

inspec_tools xccdf2inspec -x CIS_Microsoft_Windows_server_2016_RTM_Release_1607_Benchmark_v1.1.0-xccdf.xml -o Windows_2016_v1.1.0

Traceback (most recent call last):                                                                                                                     
        10: from /home/rcolanero/.gems/bin/inspec_tools:23:in `<main>'                                                                                 
         9: from /home/rcolanero/.gems/bin/inspec_tools:23:in `load'                                                                                   
         8: from /home/rcolanero/.gems/gems/inspec_tools-1.4.2/exe/inspec_tools:14:in `<top (required)>'                                               
         7: from /home/rcolanero/.gems/gems/thor-0.20.3/lib/thor/base.rb:466:in `start'                                                                
         6: from /home/rcolanero/.gems/gems/inspec_tools-1.4.2/lib/inspec_tools/command.rb:46:in `dispatch'                                            
         5: from /home/rcolanero/.gems/gems/thor-0.20.3/lib/thor.rb:387:in `dispatch'                                                                  
         4: from /home/rcolanero/.gems/gems/thor-0.20.3/lib/thor/invocation.rb:126:in `invoke_command'                                                 
         3: from /home/rcolanero/.gems/gems/thor-0.20.3/lib/thor/command.rb:27:in `run'                                                                
         2: from /home/rcolanero/.gems/gems/inspec_tools-1.4.2/lib/inspec_tools/cli.rb:21:in `xccdf2inspec'                                            
         1: from /home/rcolanero/.gems/gems/inspec_tools-1.4.2/lib/inspec_tools/xccdf.rb:36:in `to_inspec'                                             
/home/rcolanero/.gems/gems/inspec_tools-1.4.2/lib/inspec_tools/xccdf.rb:115:in `insert_json_metadata': undefined method `plaintext' for nil:NilClass (NoMethodError)                                                                                                                                          

Clean Ubuntu 16.04 tst machine, ruby 2.5.6p201 (2019-08-28 revision 67796) [x86_64-linux] gem list | grep inspec

inspec (4.16.0)
inspec_tools (1.4.2)
aaronlippold commented 5 years ago

Hello, I'm in the middle of teaching class right now but my thought is that this might be a tag issue inside the XCCDF file. I had a similar issue while I was parsing the j boss stig. In the options you can list extra tags that might be inside the XML file that are causing parsnips. Try passing plaintext to see if letting the person know that this is a tag it doesn't have to worry about fixes the issue. If it persists please update the comment and will look into it a bit deeper.

On Thu, Sep 5, 2019, 12:36 PM Raymond Colanero notifications@github.com wrote:

Getting an error similar to #63 https://github.com/mitre/inspec_tools/issues/63 but instead of 'version' I'm seeing it for 'plaintext'.

inspec_tools xccdf2inspec -x CIS_Microsoft_Windows_server_2016_RTM_Release_1607_Benchmark_v1.1.0-xccdf.xml -o Windows_2016_v1.1.0

Traceback (most recent call last): 10: from /home/rcolanero/.gems/bin/inspec_tools:23:in <main>' 9: from /home/rcolanero/.gems/bin/inspec_tools:23:inload' 8: from /home/rcolanero/.gems/gems/inspec_tools-1.4.2/exe/inspec_tools:14:in <top (required)>' 7: from /home/rcolanero/.gems/gems/thor-0.20.3/lib/thor/base.rb:466:instart' 6: from /home/rcolanero/.gems/gems/inspec_tools-1.4.2/lib/inspec_tools/command.rb:46:in dispatch' 5: from /home/rcolanero/.gems/gems/thor-0.20.3/lib/thor.rb:387:indispatch' 4: from /home/rcolanero/.gems/gems/thor-0.20.3/lib/thor/invocation.rb:126:in invoke_command' 3: from /home/rcolanero/.gems/gems/thor-0.20.3/lib/thor/command.rb:27:inrun' 2: from /home/rcolanero/.gems/gems/inspec_tools-1.4.2/lib/inspec_tools/cli.rb:21:in xccdf2inspec' 1: from /home/rcolanero/.gems/gems/inspec_tools-1.4.2/lib/inspec_tools/xccdf.rb:36:into_inspec' /home/rcolanero/.gems/gems/inspec_tools-1.4.2/lib/inspec_tools/xccdf.rb:115:in insert_json_metadata': undefined methodplaintext' for nil:NilClass (NoMethodError)

Clean Ubuntu 16.04 tst machine, ruby 2.5.6p201 (2019-08-28 revision 67796) [x86_64-linux] gem list | grep inspec

inspec (4.16.0) inspec_tools (1.4.2)

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/mitre/inspec_tools/issues/71?email_source=notifications&email_token=AALK42CVICO24U24EG5SNS3QIEYSJA5CNFSM4IUAAUH2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4HJS4ZMA, or mute the thread https://github.com/notifications/unsubscribe-auth/AALK42G656WSRIGLN25AUMDQIEYSJANCNFSM4IUAAUHQ .

aaronlippold commented 4 years ago

@kevin-j-smith can you reproduce this as well on your side?

barbich commented 4 years ago

hi just to confirm that I encounter the exact same behaviour on a different XCCDF result file. ~/work/ruby-inspec$ gem list | grep inspec inspec (4.18.51) inspec_tools (1.4.2)

~/work/ruby-inspec$ inspec_tools xccdf2inspec -x 20200202-green100-stig.xml -a attributes.yml -o profile -s false -a attributes.yml Traceback (most recent call last): 10: from /home/seb/work/./ruby-inspec/bin/inspec_tools:23:in <main>' 9: from /home/seb/work/./ruby-inspec/bin/inspec_tools:23:inload' 8: from /home/seb/work/ruby-inspec/rubygems/gems/inspec_tools-1.4.2/exe/inspec_tools:14:in <top (required)>' 7: from /home/seb/work/ruby-inspec/rubygems/gems/thor-0.20.3/lib/thor/base.rb:466:instart' 6: from /home/seb/work/ruby-inspec/rubygems/gems/inspec_tools-1.4.2/lib/inspec_tools/command.rb:46:in dispatch' 5: from /home/seb/work/ruby-inspec/rubygems/gems/thor-0.20.3/lib/thor.rb:387:indispatch' 4: from /home/seb/work/ruby-inspec/rubygems/gems/thor-0.20.3/lib/thor/invocation.rb:126:in invoke_command' 3: from /home/seb/work/ruby-inspec/rubygems/gems/thor-0.20.3/lib/thor/command.rb:27:inrun' 2: from /home/seb/work/ruby-inspec/rubygems/gems/inspec_tools-1.4.2/lib/inspec_tools/cli.rb:21:in xccdf2inspec' 1: from /home/seb/work/ruby-inspec/rubygems/gems/inspec_tools-1.4.2/lib/inspec_tools/xccdf.rb:36:into_inspec' /home/seb/work/ruby-inspec/rubygems/gems/inspec_tools-1.4.2/lib/inspec_tools/xccdf.rb:115:in insert_json_metadata': undefined methodplaintext' for nil:NilClass (NoMethodError)

when using replace-tags option I fail as follow: ~/work/ruby-inspec$ inspec_tools xccdf2inspec -x 20200202-green100-stig.xml -a attributes.yml -o profile -s false -a attributes.yml --replace-tags=plaintext Traceback (most recent call last): 11: from /home/seb/work/./ruby-inspec/bin/inspec_tools:23:in <main>' 10: from /home/seb/work/./ruby-inspec/bin/inspec_tools:23:inload' 9: from /home/seb/work/ruby-inspec/rubygems/gems/inspec_tools-1.4.2/exe/inspec_tools:14:in <top (required)>' 8: from /home/seb/work/ruby-inspec/rubygems/gems/thor-0.20.3/lib/thor/base.rb:466:instart' 7: from /home/seb/work/ruby-inspec/rubygems/gems/inspec_tools-1.4.2/lib/inspec_tools/command.rb:46:in dispatch' 6: from /home/seb/work/ruby-inspec/rubygems/gems/thor-0.20.3/lib/thor.rb:387:indispatch' 5: from /home/seb/work/ruby-inspec/rubygems/gems/thor-0.20.3/lib/thor/invocation.rb:126:in invoke_command' 4: from /home/seb/work/ruby-inspec/rubygems/gems/thor-0.20.3/lib/thor/command.rb:27:inrun' 3: from /home/seb/work/ruby-inspec/rubygems/gems/inspec_tools-1.4.2/lib/inspec_tools/cli.rb:20:in xccdf2inspec' 2: from /home/seb/work/ruby-inspec/rubygems/gems/inspec_tools-1.4.2/lib/inspec_tools/cli.rb:20:innew' 1: from /home/seb/work/ruby-inspec/rubygems/gems/inspec_tools-1.4.2/lib/inspec_tools/xccdf.rb:18:in initialize' /home/seb/work/ruby-inspec/rubygems/gems/inspec_tools-1.4.2/lib/inspec_tools/xccdf.rb:94:inreplace_tags_in_xccdf': undefined method `each' for "plaintext":String (NoMethodError)

tx

aaronlippold commented 4 years ago

Hi. In a little hacking on the code base right now so we'll see if we can roll this into our work

aaronlippold commented 4 years ago

Raymond, can you also send us those input files via email so we can examine them a little more closely in the test bed. I think it might actually be a schema issue but I'd like to have a couple of the CIS xccdf files as reference

On Thu, Sep 5, 2019, 12:36 PM Raymond Colanero notifications@github.com wrote:

Getting an error similar to #63 https://github.com/mitre/inspec_tools/issues/63 but instead of 'version' I'm seeing it for 'plaintext'.

inspec_tools xccdf2inspec -x CIS_Microsoft_Windows_server_2016_RTM_Release_1607_Benchmark_v1.1.0-xccdf.xml -o Windows_2016_v1.1.0

Traceback (most recent call last): 10: from /home/rcolanero/.gems/bin/inspec_tools:23:in <main>' 9: from /home/rcolanero/.gems/bin/inspec_tools:23:inload' 8: from /home/rcolanero/.gems/gems/inspec_tools-1.4.2/exe/inspec_tools:14:in <top (required)>' 7: from /home/rcolanero/.gems/gems/thor-0.20.3/lib/thor/base.rb:466:instart' 6: from /home/rcolanero/.gems/gems/inspec_tools-1.4.2/lib/inspec_tools/command.rb:46:in dispatch' 5: from /home/rcolanero/.gems/gems/thor-0.20.3/lib/thor.rb:387:indispatch' 4: from /home/rcolanero/.gems/gems/thor-0.20.3/lib/thor/invocation.rb:126:in invoke_command' 3: from /home/rcolanero/.gems/gems/thor-0.20.3/lib/thor/command.rb:27:inrun' 2: from /home/rcolanero/.gems/gems/inspec_tools-1.4.2/lib/inspec_tools/cli.rb:21:in xccdf2inspec' 1: from /home/rcolanero/.gems/gems/inspec_tools-1.4.2/lib/inspec_tools/xccdf.rb:36:into_inspec' /home/rcolanero/.gems/gems/inspec_tools-1.4.2/lib/inspec_tools/xccdf.rb:115:in insert_json_metadata': undefined methodplaintext' for nil:NilClass (NoMethodError)

Clean Ubuntu 16.04 tst machine, ruby 2.5.6p201 (2019-08-28 revision 67796) [x86_64-linux] gem list | grep inspec

inspec (4.16.0) inspec_tools (1.4.2)

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/mitre/inspec_tools/issues/71?email_source=notifications&email_token=AALK42CVICO24U24EG5SNS3QIEYSJA5CNFSM4IUAAUH2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4HJS4ZMA, or mute the thread https://github.com/notifications/unsubscribe-auth/AALK42G656WSRIGLN25AUMDQIEYSJANCNFSM4IUAAUHQ .

Bialogs commented 4 years ago

Hello all,

We do not have HappyMapper classes for the CIS xccdf schema, only STIG.

If you can attach the CIS XCCDF File that you are trying to convert we can add the required mapping.

aaronlippold commented 3 years ago

@Bialogs does #246 also cover this issue with metadata or is it a conneted issue?

camdenmoors commented 2 years ago

If this is still a concern please try this under the new SAF CLI