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 array input treated as hash w/ keys #271

Open
rjhornsby opened this issue Feb 3, 2021 · 1 comment
Open

inspec array input treated as hash w/ keys #271

rjhornsby opened this issue Feb 3, 2021 · 1 comment
Labels
Status: Untriaged An issue that has yet to be triaged.

Comments

@rjhornsby
Copy link

Version:

2.2.2

Environment:

Host system - macOS 10.15, guest OS CentOS 7

Scenario:

Make kitchen pass inputs to inspec, specifically an array of values that inspec will later iterate over. It seems like the array type is crucial here.

Steps to Reproduce:

My kitchen.yml, under the suite, contains this inspec config:

    verifier:
      inspec_tests:
      ...
      inputs:
      - name: domains
        type: array
        value: ['foo.com', 'bar.com']

now run kitchen verify against this setup.

Expected Result:

The domains array should be iterable in an inspec test

Actual Result:

The execution never makes it to inspec proper. It looks like kitchen-inspec is (always?) expecting to get a hash. When it gets an array instead, and then tries to access its hash keys, it errors out:

Message: Failed to complete #verify action: [undefined method 'keys' for #<Array:memaddr>]

I believe this is where things break:

if config[:inputs]
    ...
    opts[inputs_key] = Hashie.stringify_keys config[:inputs]
end

A work around is to move the inputs config from kitchen.yml into the inspec profile's inspec.yml file.

@rjhornsby rjhornsby added the Status: Untriaged An issue that has yet to be triaged. label Feb 3, 2021
@clintoncwolfe
Copy link
Contributor

Here's the referenced code now, in a permelink -

opts[inputs_key] = Hashie.stringify_keys config[:inputs]
- we call Hashie stringify keys on it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Untriaged An issue that has yet to be triaged.
Projects
None yet
Development

No branches or pull requests

2 participants