Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inspec check fails on examples/profile #485

Closed
jcreedcmu opened this issue Feb 23, 2016 · 6 comments
Closed

Inspec check fails on examples/profile #485

jcreedcmu opened this issue Feb 23, 2016 · 6 comments
Assignees
Labels
Type: Bug Feature not working as expected

Comments

@jcreedcmu
Copy link
Contributor

$ bundle exec inspec check examples/profile
/Users/jreed/.inspec/plugins/inspec-scap/lib/inspec-scap/targets.rb:2:in `require': cannot load such file -- inspec/targets/core (LoadError)
from /Users/jreed/.inspec/plugins/inspec-scap/lib/inspec-scap/targets.rb:2:in `<top (required)>'
    from /Users/jreed/.inspec/plugins/inspec-scap/lib/inspec-scap/cli.rb:4:in `require'
    from /Users/jreed/.inspec/plugins/inspec-scap/lib/inspec-scap/cli.rb:4:in `<top (required)>'
    from /Users/jreed/.inspec/plugins/inspec-scap/lib/inspec-scap.rb:11:in `require'
    from /Users/jreed/.inspec/plugins/inspec-scap/lib/inspec-scap.rb:11:in `<top (required)>'
    from /Users/jreed/oc/code/chef/inspec/lib/inspec/plugins.rb:56:in `require'
    from /Users/jreed/oc/code/chef/inspec/lib/inspec/plugins.rb:56:in `load'
    from /Users/jreed/oc/code/chef/inspec/bin/inspec:152:in `block in <top (required)>'
    from /Users/jreed/oc/code/chef/inspec/bin/inspec:152:in `each'
    from /Users/jreed/oc/code/chef/inspec/bin/inspec:152:in `<top (required)>'
    from /Users/jreed/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/bin/inspec:23:in `load'
    from /Users/jreed/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/bin/inspec:23:in `<main>'

(at commit 16c0e0c)

@jcreedcmu
Copy link
Contributor Author

(assume this is something to do with the recent big rewrite)

@srenatus
Copy link
Contributor

This might have something to do with your symlinked inspec-scap in ~/.inspec/plugins - is it up to date, too?

Asking because I cannot reproduce it

inspec (master)* (0)$ b/inspec check examples/profile/
Summary
-------
Location: examples/profile/
Profile: profile
Controls: 3
Timestamp: 2016-02-23T15:47:37+01:00
Valid: true

Errors
------

Warnings
--------

inspec (master)* (0)$ git log -1
commit 16c0e0c471d6540e9d2cad88dbcc5b7ba30f1c29
Merge: a470262 47b0d97
Author: Christoph Hartmann <chris@lollyrock.com>
Date:   Mon Feb 22 21:42:55 2016 +0100

    Merge pull request #484 from chef/0.14.2

    0.14.2
inspec (master)* (0)$ find ~/.inspec/
/Users/stephan/.inspec/
/Users/stephan/.inspec//compliance
/Users/stephan/.inspec//compliance/config.json
/Users/stephan/.inspec//plugins

@username-is-already-taken2
Copy link
Contributor

Hi there,

I cant seem to be able to use check on either my windows or Ubuntu box, I tried 3 different paths in case its a windows idiosyncrasy :)

PS C:\chef-compliance> inspec version
0.14.2
C:\CHEF-COMPLIANCE\INIT_TEST_PROFILE
│   inspec.yml
│   README.md
│
├───controls
│       example.rb
│
└───libraries
        .gitkeep
PS C:\chef-compliance> inspec check .\init_test_profile
C:/Users/gbright/AppData/Local/chefdk/gem/ruby/2.1.0/gems/inspec-0.14.2/bin/inspec:53:in check: undefined method check for nil:NilClass (NoMethodError)
        from C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/thor-0.19.1/lib/thor/command.rb:27:in run
        from C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/thor-0.19.1/lib/thor/invocation.rb:126:in invoke_command
        from C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/thor-0.19.1/lib/thor.rb:359:in dispatch
        from C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/thor-0.19.1/lib/thor/base.rb:440:in start
        from C:/Users/gbright/AppData/Local/chefdk/gem/ruby/2.1.0/gems/inspec-0.14.2/bin/inspec:166:in <top (required)>
        from C:/Users/gbright/AppData/Local/chefdk/gem/ruby/2.1.0/bin/inspec:23:in load
        from C:/Users/gbright/AppData/Local/chefdk/gem/ruby/2.1.0/bin/inspec:23:in <main>
PS C:\chef-compliance> inspec check .\init_test_profile\controls\
C:/Users/gbright/AppData/Local/chefdk/gem/ruby/2.1.0/gems/inspec-0.14.2/bin/inspec:53:in check: undefined method check for nil:NilClass (NoMethodError)
        from C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/thor-0.19.1/lib/thor/command.rb:27:in run
        from C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/thor-0.19.1/lib/thor/invocation.rb:126:in invoke_command
        from C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/thor-0.19.1/lib/thor.rb:359:in dispatch
        from C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/thor-0.19.1/lib/thor/base.rb:440:in start
        from C:/Users/gbright/AppData/Local/chefdk/gem/ruby/2.1.0/gems/inspec-0.14.2/bin/inspec:166:in <top (required)>
        from C:/Users/gbright/AppData/Local/chefdk/gem/ruby/2.1.0/bin/inspec:23:in load
        from C:/Users/gbright/AppData/Local/chefdk/gem/ruby/2.1.0/bin/inspec:23:in <main>
PS C:\chef-compliance> inspec check c:\chef-compliance\init_test_profile\controls\example.rb
C:/Users/gbright/AppData/Local/chefdk/gem/ruby/2.1.0/gems/inspec-0.14.2/lib/inspec/plugins/fetcher.rb:52:in +: no implicit conversion of nil into String (TypeError)
        from C:/Users/gbright/AppData/Local/chefdk/gem/ruby/2.1.0/gems/inspec-0.14.2/lib/inspec/plugins/fetcher.rb:52:in abs_path
        from C:/Users/gbright/AppData/Local/chefdk/gem/ruby/2.1.0/gems/inspec-0.14.2/lib/inspec/profile.rb:109:in check
        from C:/Users/gbright/AppData/Local/chefdk/gem/ruby/2.1.0/gems/inspec-0.14.2/bin/inspec:53:in check
        from C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/thor-0.19.1/lib/thor/command.rb:27:in run
        from C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/thor-0.19.1/lib/thor/invocation.rb:126:in invoke_command
        from C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/thor-0.19.1/lib/thor.rb:359:in dispatch
        from C:/opscode/chefdk/embedded/lib/ruby/gems/2.1.0/gems/thor-0.19.1/lib/thor/base.rb:440:in start
        from C:/Users/gbright/AppData/Local/chefdk/gem/ruby/2.1.0/gems/inspec-0.14.2/bin/inspec:166:in <top (required)>
        from C:/Users/gbright/AppData/Local/chefdk/gem/ruby/2.1.0/bin/inspec:23:in load
        from C:/Users/gbright/AppData/Local/chefdk/gem/ruby/2.1.0/bin/inspec:23:in <main>

@jcreedcmu
Copy link
Contributor Author

@vjeffrey reports getting

➜  profile git:(master) bundle exec inspec check examples/profile
/Users/vjeffrey/oc/code/opscode/inspec/bin/inspec:53:in `check': undefined method `check' for nil:NilClass (NoMethodError)
    from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/thor-0.19.1/lib/thor/command.rb:27:in `run'
    from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/thor-0.19.1/lib/thor/invocation.rb:126:in `invoke_command'
    from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/thor-0.19.1/lib/thor.rb:359:in `dispatch'
    from /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/thor-0.19.1/lib/thor/base.rb:440:in `start'
    from /Users/vjeffrey/oc/code/opscode/inspec/bin/inspec:166:in `<top (required)>'
    from /Users/vjeffrey/.chefdk/gem/ruby/2.1.0/bin/inspec:23:in `load'
    from /Users/vjeffrey/.chefdk/gem/ruby/2.1.0/bin/inspec:23:in `<main>'
➜  profile git:(master)

but I can't reproduce it. All my problems went away when I pulled inspec-scap, derp.

Is this something weird with ruby or dependency versions? I don't know how pessimistic/paranoid I should even be about that.

@username-is-already-taken2
Copy link
Contributor

Hi there

Since I have upgraded to 0.14.3 I don't get that error any more

Would you be able to confirm if this output is correct?

PS C:\> inspec check C:\chef-compliance\init_profile_0.14.3\controls\example.rb
Summary
-------
Location: C:\chef-compliance\init_profile_0.14.3\controls\example.rb
Profile:
Controls: 2
Timestamp: 2016-02-25T17:35:09+00:00
Valid: false

Errors
------
:0:0: Missing profile name in
:0:0: Missing profile version in

Warnings
--------
:0:0: Missing profile title in
:0:0: Missing profile summary in
:0:0: Missing profile maintainer in
:0:0: Missing profile copyright in

I used it to check the example file generated with inspec init profile, should this pass cleanly?

from the 'inspec help check' it looked like I should just be able to point it at the profile folder but I couldn't get any combination of path to work

PS C:\> inspec check C:\chef-compliance\init_profile_0.14.3
PS C:\> inspec check C:\chef-compliance\init_profile_0.14.3\
PS C:\> inspec check C:\chef-compliance\init_profile_0.14.3\controls

all gave ....

C:/Users/xxx/AppData/Local/chefdk/gem/ruby/2.1.0/gems/inspec-0.14.3/lib/inspec/profile.rb:27:in for_target: Don't understand inspec profile in "C:\\chef-compliance\\init_profile_0.14.3\\", it doesn't look like a supported profile structure. (RuntimeError)
        from C:/Users/xxx/AppData/Local/chefdk/gem/ruby/2.1.0/gems/inspec-0.14.3/bin/inspec:52:in check

Here is my dir structure

C:\CHEF-COMPLIANCE\INIT_PROFILE_0.14.3
│   inspec.yml
│   README.md
│
├───controls
│       example.rb
│
└───libraries
        .gitkeep

It did process the .yml file but found no controls

PS C:\> inspec check C:\chef-compliance\init_profile_0.14.3\inspec.yml
Summary
-------
Location: C:\chef-compliance\init_profile_0.14.3\inspec.yml
Profile: init_profile_0.14.3
Controls: 0
Timestamp: 2016-02-25T17:42:04+00:00
Valid: true

Errors
------

Warnings
--------
::: No controls or tests were defined.

Thanks for your help

Gary

@chris-rock chris-rock added the Type: Bug Feature not working as expected label Mar 3, 2016
@chris-rock
Copy link
Contributor

@username-is-already-taken2 This output is correct. I'd like to mention that you can also get the result as json:

$ inspec check examples/profile --format=json
{"summary":{"valid":true,"timestamp":"2016-04-16T07:51:00-04:00","location":"examples/profile","profile":"profile","controls":4},"errors":[],"warnings":[]}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Feature not working as expected
Projects
None yet
Development

No branches or pull requests

5 participants