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
92 stars 30 forks source link

`insert_json_metadata': undefined method `version' for nil:NilClass #63

Closed kclinden closed 5 years ago

kclinden commented 5 years ago

xccdf2inspec fails with the below error.

Command

xccdf2inspec fails with the following command.

inspec_tools xccdf2inspec -x U_VMware_vSphere_6-5_ESXi_STIG_V1R1_Manual-xccdf.xml -o esxi-65-stig-v1r1 -f ruby -s false -m metadata.json

Error

/usr/local/Cellar/gem-inspec_tools/1.4.0/gems/inspec_tools-1.4.0/lib/inspec_tools/xccdf.rb:112:in `insert_json_metadata': undefined method `version' for nil:NilClass (NoMethodError)
    from /usr/local/Cellar/gem-inspec_tools/1.4.0/gems/inspec_tools-1.4.0/lib/inspec_tools/xccdf.rb:35:in `to_inspec'
    from /usr/local/Cellar/gem-inspec_tools/1.4.0/gems/inspec_tools-1.4.0/lib/inspec_tools/cli.rb:21:in `xccdf2inspec'
    from /usr/local/Cellar/gem-inspec_tools/1.4.0/gems/thor-0.20.3/lib/thor/command.rb:27:in `run'
    from /usr/local/Cellar/gem-inspec_tools/1.4.0/gems/thor-0.20.3/lib/thor/invocation.rb:126:in `invoke_command'
    from /usr/local/Cellar/gem-inspec_tools/1.4.0/gems/thor-0.20.3/lib/thor.rb:387:in `dispatch'
    from /usr/local/Cellar/gem-inspec_tools/1.4.0/gems/inspec_tools-1.4.0/lib/inspec_tools/command.rb:46:in `dispatch'
    from /usr/local/Cellar/gem-inspec_tools/1.4.0/gems/thor-0.20.3/lib/thor/base.rb:466:in `start'
    from /usr/local/Cellar/gem-inspec_tools/1.4.0/gems/inspec_tools-1.4.0/exe/inspec_tools:14:in `<top (required)>'
    from /usr/local/bin/inspec_tools:6:in `load'
    from /usr/local/bin/inspec_tools:6:in `<main>'
kclinden commented 5 years ago

Attached are the following files in a zip file. esxi-files.zip

metadata.json 
DoD-DISA-logos-as-JPEG.jpg
STIG_unclass.xsl
U_VMware_vSphere_6-5_ESXi_STIG_V1R1_Manual-xccdf.xml 
aaronlippold commented 5 years ago

Great. Thankyou. @samcornwell can you take a peek.

samcornwell commented 5 years ago

@kclinden I'm having a hard time reproducing this. I am unable to recreate your configuration because apparently InSpec 4.3.2 requires ruby >= 2.4. Can you do me a favor and show me the output of gem list | grep inspec? I'm wondering if inspec_tools is using an older version of inspec.

kclinden commented 5 years ago

I used homebrew to install inspec and brew-gem to install inspec_tools.

If I run brew cask info inspec, I get the following:

klinden-a02:~ klinden$ brew cask info inspec
inspec: 4.3.2
https://www.inspec.io/
/usr/local/Caskroom/inspec/4.3.2 (2 files, 25.4MB)
From: https://github.com/chef/homebrew-chef/blob/master/Casks/inspec.rb
==> Name
InSpec by Chef
==> Artifacts
inspec-4.3.2-1.pkg (Pkg)
kclinden commented 5 years ago

I linked the latest version of ruby with homebrew vs the default OS version and got the same error. ruby 2.6.3p62 (2019-04-16 revision 67580) [x86_64-darwin18]

kclinden commented 5 years ago

I ended up installing rvm, then ruby and inspec/inspec_tools to get this to work. It must have been something to do with the version like you mentioned.

aaronlippold commented 5 years ago

Actually the other issue we may be running into is the new chef licensing on InSpec in 4.x. If it really is a 4.x issue we may want to look into that.

Aaron Lippold

lippold@gmail.com

260-255-4779

twitter/aim/yahoo,etc. 'aaronlippold'

On Mon, Jun 17, 2019 at 7:48 PM Kasey Linden notifications@github.com wrote:

I ended up installing rvm, then ruby and inspec/inspec_tools to get this to work. It must have been something to do with the version like you mentioned.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/mitre/inspec_tools/issues/63?email_source=notifications&email_token=AALK42CGEMAAY3YCF5AB4J3P3APEPA5CNFSM4HYNV3P2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODX4YGYY#issuecomment-502891363, or mute the thread https://github.com/notifications/unsubscribe-auth/AALK42D5HCXTTASHGUZ7JXTP3APEPANCNFSM4HYNV3PQ .

samcornwell commented 5 years ago

@aaronlippold I don't think this has anything to do with that. I think I know how to fix the error he was having originally, but had no way to test it first. I'm just going to make the fix and submit it as a PR. It just involves adding some more explicit require statements.

samcornwell commented 5 years ago

65

kclinden commented 5 years ago

So I am running into this issue again with the csv2inspec command. I am trying to avoid using rvm this time.