Commit graph

10 commits

Author SHA1 Message Date
Adam Leff
9580732814 Source reader should not hand back files with nil contents (#2003)
If a profile has a data files directory that looks like this:

```
files/platforms/one/data.json
files/platforms/two/data.json
files/platforms/three/data.json
```

... the source reader will return the directories in the list of files but with
nil contents. This causes an issue when Inspec::Profile tries to create a sha256
checksum of the profile contents only to try to cast nil to a string when
building the null-delimited profile contents string.

Files that are empty will have an empty string as its contents, so it's safe to
assume that file entries with nil contents are actually a directory and have no
affect on the profile's checksum. Therefore, this change will eliminate any file
entries in responses from the source readers where the contents are nil.

Signed-off-by: Adam Leff <adam@leff.co>
2017-07-11 21:33:55 +02:00
Dominik Richter
5d1765c9bb add inspec.profile.file(...) for profile files
Fixes https://github.com/chef/inspec/issues/1396

Signed-off-by: Dominik Richter <dominik.richter@gmail.com>
2017-05-03 20:39:27 +02:00
Adam Leff
dfce561276 Provide better error message when inspec.yml is invalid
Currently, if the inspec.yml for a profile is invalid (such as including
an improperly-defined multi-line string), InSpec will throw an exception
from the YAML parser that does not given a clear indication that the
issue was encountered while parsing the inspec.yml file.

This change introduces a better exception message to clue the user into
where the problem actually lies.

Signed-off-by: Adam Leff <adam@leff.co>
2017-03-09 18:03:01 +01:00
Adam Leff
7e64c99738 Doc fix for SourceReaders::InspecReader
The inline docs for SourceReaders::InspecReader#new state that it takes
a SourceReader object for the target... but we're trying to create the
SourceReader object! It actually takes a FileProvider object that is
capabile of listing files for the given profile and reading them.

Signed-off-by: Adam Leff <adam@leff.co>
2017-02-13 13:19:22 -05:00
Christoph Hartmann
9db1e6958c do not load controls from test directory
Signed-off-by: Christoph Hartmann <chris@lollyrock.com>
2016-11-25 15:51:31 -07:00
Christoph Hartmann
793f842e33 copy vendored dependencies into cache
Signed-off-by: Christoph Hartmann <chris@lollyrock.com>
2016-11-09 11:49:51 -06:00
Steven Danna
210dbc9425 Remove SourceReader::Inspec#prepare_load_path
We already monkeypatch require so that it is redirected through the
require_loader.  All of the tests pass with this removal.  We might
cause some breakage with this removal that we aren't testing, but given
that we are mucking with `require` it seems preferable to have one
mechanism by which we do that and solve any bugs with that single path.

Signed-off-by: Steven Danna <steve@chef.io>
2016-09-07 10:35:58 +02:00
Dominik Richter
37ec3cf6f2 migrate load-path hooking for legacy modes 2016-02-22 12:06:42 +01:00
Dominik Richter
c79d9f7777 add flat source reader 2016-02-22 11:24:35 +01:00
Dominik Richter
f023d02bbb add inspec source reader 2016-02-22 11:24:35 +01:00