Commit graph

1777 commits

Author SHA1 Message Date
Dominik Richter
37a2e45cd1 bugfix: unindent description misbehaviors
Unindent has been misbehaving for control `desc`riptions by completely removing newlines. This is now fixed and the unindentation mechanism improved to behave as expected.

Removing empty lines at the beginning and end of string remains unchanged.
Tabs are not treated as multi-space indentations; supporting them as 8-space chars would require additional effort (please comment if this is important to you)

Signed-off-by: Dominik Richter <dominik.richter@gmail.com>
2017-04-25 13:21:38 +02:00
Christoph Hartmann
b3cdc6ba04 handle json parse errors in docker resource
Signed-off-by: Christoph Hartmann <chris@lollyrock.com>
2017-04-25 12:02:26 +02:00
Dominik Richter
37a778173d inspec control.to_ruby to respect newlines
I.e. instead of printing them as:

```
desc "hello\nworld"
```

it would instead do:

```
desc "hello
world"
```

Signed-off-by: Dominik Richter <dominik.richter@gmail.com>
2017-04-25 10:34:45 +02:00
Adam Leff
e352deb6ef
Release 1.21.0
Signed-off-by: Adam Leff <adam@leff.co>
2017-04-24 16:27:27 -04:00
Christoph Hartmann
218bda9c34 Docker resource (#1566)
* add docker, docker_container, and docker_image resources

Signed-off-by: Christoph Hartmann <chris@lollyrock.com>
2017-04-24 10:47:03 -04:00
Dominik Richter
f731cbca92 bugfix: solve warn on uninitialized
@expectation was analyzed without initializeation, leading to ruby errors. fix it

Signed-off-by: Dominik Richter <dominik.richter@gmail.com>
2017-04-22 12:35:56 +02:00
Christoph Hartmann
b03ee9d0ba Merge pull request #1681 from Happycoil/add-windows-user-groups
fetch user groups while building user object
2017-04-21 11:00:49 +02:00
Tor Magnus Rakvåg
1c5b35c890 you -> your
Obvious fix.
2017-04-20 17:43:33 +02:00
Tor Magnus Rakvåg
96bb596bc4 fetch user groups while building user object
Signed-off-by: Tor Magnus Rakvåg <tm@intility.no>
2017-04-20 16:02:21 +02:00
Tyler Ball
488ef492de Merge pull request #1663 from chef/ER-508/extending_http_resource
ER-508 Extended http resource to support no ssl verification
2017-04-18 14:25:10 -06:00
Adam Leff
0fe13fd0af Merge pull request #1668 from chef/chris-rock/fix-help-sshd-config
fix sshd config help
2017-04-18 15:04:07 -04:00
Adam Leff
6f57af7579 Merge pull request #1669 from chef/chris-rock/fix-web-reference
fix web reference url
2017-04-18 15:02:25 -04:00
Elizabeth Uselton
d376a6a881 ER-508 Extended http resource to support no ssl verification
We needed to be able to run inspec against endpoints with self signed certificates and this was the quickest way for us to get there.

Signed-off-by: Elizabeth Uselton <elizabeth.uselton@gmail.com>
2017-04-18 19:01:57 +02:00
Christoph Hartmann
b93aa0715b fix web reference url
Signed-off-by: Christoph Hartmann <chris@lollyrock.com>
2017-04-18 12:04:59 +02:00
Christoph Hartmann
438a1c52ab fix sshd config help
Signed-off-by: Christoph Hartmann <chris@lollyrock.com>
2017-04-18 12:01:55 +02:00
Adam Leff
7a71719f13 Move Habitat sleep time to config file
Because the sleep_time is not written to a config file but instead
only rendered into the run hook, hab-sup doesn't restart the running
process upon any config updates. This change moves the sleep_time to
a settings config file which is read in by the run hook. This will
allow Habitat to restart the InSpec process whenever a user changes
the sleep time.

I also cleaned up the non-zero exit error message to give the user
a better indication as to why the run may have "failed."

Signed-off-by: Adam Leff <adam@leff.co>
2017-04-14 12:01:25 -04:00
Adam Leff
17d611c053
Release 1.20.0
Signed-off-by: Adam Leff <adam@leff.co>
2017-04-13 11:37:23 -04:00
Ryan Gerstenkorn
5e0cab08a0 Add OSX support for host resource (#1608)
* Add OSX support for host resource

Signed-off-by: Ryan Gerstenkorn <ryan_gerstenkorn@fastmail.fm>
2017-04-13 11:32:04 -04:00
Christoph Hartmann
effd0dd9f8 harmonize compliance profiles view with supermarket views (#1654)
* harmonize profiles view with supermarket plugin

Signed-off-by: Christoph Hartmann <chris@lollyrock.com>
2017-04-13 11:24:17 -04:00
Adam Leff
9b472e1b59
Habitat packages should run as root
Many InSpec resources require root access to properly scan. Let's
default the run user to root until we need to accommodate different
options.

Signed-off-by: Adam Leff <adam@leff.co>
2017-04-13 10:34:47 -04:00
Adam Leff
c70824d0c8 Merge pull request #1647 from jeremymv2/jeremymv2/automate_dependency_profiles
allow Automate profile dependencies
2017-04-12 15:42:31 -04:00
Adam Leff
2376cba73f Merge pull request #1646 from jeremymv2/jeremymv2/fix_validate_backend_error
pass options hash sans target key
2017-04-12 15:41:58 -04:00
Christoph Hartmann
29e286fee6 Merge pull request #1639 from chef/dr/rabbitmq_config
add `rabbitmq_config` resource
2017-04-12 21:19:15 +02:00
Dominik Richter
02e435b6d0 add rabbitmq config resource
Signed-off-by: Dominik Richter <dominik.richter@gmail.com>
2017-04-12 20:51:12 +02:00
Adam Leff
da56a08f74 Fix gem resource on Windows
RubyGems on windows comes with a batch file that wraps the `gem` command
so it executes correctly. This change uses that batch file for windows
for our `gem` resource, and also properly handles when we receive no output
from the command.

Signed-off-by: Adam Leff <adam@leff.co>
2017-04-12 17:34:16 +02:00
Christoph Hartmann
01eb102079 add support for hostname detection on macOS
Signed-off-by: Christoph Hartmann <chris@lollyrock.com>
2017-04-12 12:57:45 +02:00
Christoph Hartmann
4c64bafb51 Merge pull request #1624 from supergicko/sni-power-for-ssl
Adding SNI utilization to ssl resource
2017-04-12 11:07:27 +02:00
Jeremy J. Miller
735b67ab8a allow Automate profile dependencies
Signed-off-by: Jeremy J. Miller <jm@chef.io>
2017-04-11 16:45:24 -04:00
Jeremy J. Miller
c73417e0ae pass options hash minus target key
Signed-off-by: Jeremy J. Miller <jm@chef.io>
2017-04-11 14:39:46 -04:00
Adam Leff
231698808c
Release 1.19.2 patch release
Signed-off-by: Adam Leff <adam@leff.co>
2017-04-07 10:36:38 -04:00
Adam Leff
a8ffe449ff
Add helper methods, tests for registry key path building
Broke out some of the conditional logic in the `#initialize`
method into helper methods and added tests.

Signed-off-by: Adam Leff <adam@leff.co>
2017-04-07 10:09:51 -04:00
Christoph Hartmann
6f6f3985a6 fix #1131 circumvent bug in powershell where string are not properly handled
Signed-off-by: Christoph Hartmann <chris@lollyrock.com>
2017-04-07 10:57:02 +02:00
supergicko
e3c695e8e9 Adding SNI utilization to ssl resource
SSL resource now adds the servername option in client hello,
utilizing the the great work of @adamcaudill to support
SNI in sslshake [1]

[1] https://github.com/arlimus/sslshake/pull/5

Signed-off-by: Christoph Kappel <kappel.christoph@gmail.com>
2017-04-07 09:34:44 +02:00
Christoph Hartmann
90b985a7c1 fix #1268 and allows registry key resource with leading backslash
Signed-off-by: Christoph Hartmann <chris@lollyrock.com>
2017-04-06 23:30:10 +02:00
Adam Leff
24ab12e5b5
Releasing v1.19.1
Signed-off-by: Adam Leff <adam@leff.co>
2017-04-04 15:22:16 -04:00
Adam Leff
5a2a20dc3e
Releasing v1.19.0
Signed-off-by: Adam Leff <adam@leff.co>
2017-04-04 11:06:16 -04:00
Doc Walker
692e660140 Fix #1617 Add dh_params resource (#1618)
* Fix #1617 Add dh_params resource

Signed-off-by: Doc Walker <4-20ma@wvfans.net>
2017-04-04 10:34:09 -04:00
Adam Leff
73d46f9c49
Replace Nokogiri with REXML in the JUnit formatter
In #1454, we welcomed a newly-revamped JUnit formatter which has
a dependency on Nokogiri. Unfortunately, this had led us to problems
getting InSpec included in Chef omnibus builds (see chef/chef#5937)
because Chef is using Ruby 2.4.1 and the Nokogiri maintainers have
not yet released a windows binary gem that supports Ruby 2.4.x.
This has led to breaking builds in Chef's CI platform and would
block the acceptance of chef/chef#5937.

This change replaces Nokogiri use with REXML instead. While REXML
can be slower than Nokogiri, it does not require native extensions
and is supported on all Chef platforms.

Signed-off-by: Adam Leff <adam@leff.co>
2017-04-03 14:51:48 -04:00
Adam Leff
68a930f141 Merge pull request #1406 from carldjohnston/apache_conf-symlinks
Allow apache_conf to include symlinked configuration files
2017-04-03 10:38:22 -04:00
Adam Leff
76420432e0
Release v1.18.0
Signed-off-by: Adam Leff <adam@leff.co>
2017-03-30 11:25:58 -04:00
Ryan Larson
0e187f6117 Feature/fix ability to pass in supermarket url (#1595)
* Enable customization of supermarket_url

It looks like this was originally supposed to work, but at some point
the default value was put in the method body rather than in the method
parameters.

This change allows you to configure the supermarket_url in test kitchen
like so:

```
verifier:
  inspec_tests:
  - name: linux-hardening
    supermarket: som3guy/apache-disa-stig
    supermarket_url: https://my.supermarket.com
```

Signed-off-by: Ryan Larson <ryan.mango.larson@gmail.com>
2017-03-29 12:42:24 -04:00
Adam Leff
7df9674e42 Remove method_missing, provide methods for repo metadata
Instead of method_missing, methods for each output item from
`yum repolist` are provided.

Signed-off-by: Adam Leff <adam@leff.co>
2017-03-29 10:42:25 +02:00
Adam Leff
1cf80737ad Yum resource fix for non-existent repos and repo info
If a repo did not exist, running matchers against it (such as `exist`)
were failing due to a bug in `#to_s` when fetching the repo name. The
`info` method would return nil and we'd still try to treat it as a hash.

This change ensures that info is always a hash, possibly empty if the
repo doesn't exist, and uses the repo name provided by the user rather
than shortening it to be consistent with our other resources which don't
manipulate the user input in the formatter.

Also added a method_missing to allow users to interrogate repo options,
such as baseurl or gpgcheck.

Signed-off-by: Adam Leff <adam@leff.co>
2017-03-29 10:42:25 +02:00
Adam Leff
96d18435a4 Update CLI output, adjust tests
The CLI output for the vendoring of profiles has been updated slightly
to be more clear, and the functional tests have been modified to match
as well.

Signed-off-by: Adam Leff <adam@leff.co>
2017-03-29 10:22:20 +02:00
Adam Leff
e1c664272e Break out profile vendor activities into separate class
Per PR feedback, `Inspec::ProfileVendor` is created to centralize
the logic and data of vendoring profile dependencies. The `BaseCLI`
class and the `Habitat::Profile` class have been modified to use it

Signed-off-by: Adam Leff <adam@leff.co>
2017-03-29 10:22:20 +02:00
Adam Leff
8269d0da9e Support vendored profiles in Habitat-packaged profiles
This change adds support in Habitat-packaged profiles for
profiles that depend on other profiles. When `inspec habitat
profile create` or `inspec habitat profile upload` is run,
it will see if the profile's dependencies have been vendored
yet, and if not, it will vendor them before creating the
habitat artifact.

For the git and URL fetchers, more explicit creation of the
target directories for the vendored profiles is done. This
is implicitly done via normal CLI interactions a user may
go through, but in our case, we want to ensure those directories
are there before the fetchers try to write out content.

By adding this support, we also fix a bug experienced in Habitat
where a profile that was packaged before an `inspec exec` was run
for the profile would cause a failure in Habitat. This is caused
by `inspec exec` doing a vendor of the dependencies if necessary
and generating the inspec.lock file. In Habitat, the package dir
is not writable by the hab user and InSpec would fail to run due
to an inability to write out an inspec.lock.

Signed-off-by: Adam Leff <adam@leff.co>
2017-03-29 10:22:20 +02:00
Adam Leff
8e693a4ad9 Fix port resource for invalid IP address in netstat output
Netstat will sometimes output an IPv6 address that is not
formatted correctly; the address is either truncated or uses
or implies the `::` shorthand notation twice. This yields an
invalid IPv6 address and causes IPAddr.new to choke.

This change guards against invalid IP addresses and ensures they
do not end up in the port resource's entries list.

Signed-off-by: Adam Leff <adam@leff.co>
2017-03-29 08:33:50 +02:00
Adam Leff
90b0ce08c5 Remove errant puts in inspec habitat CLI command
Left a `puts` behind during some testing that made its way into
a PR. Removing it!

Signed-off-by: Adam Leff <adam@leff.co>
2017-03-28 22:57:08 +02:00
joe.nuspl
1ab80ea052 Extend gem to take an optional gem_binary
Allows one to test whether gems are installed into an omnibus environment.

Signed-off-by: Joe Nuspl <nuspl@nvwls.com>
2017-03-24 22:28:42 -07:00
Adam Leff
73e3bfda7a Merge pull request #1544 from chef/adamleff/hash-values-in-simpleconfig
Provide a method-based accessor for SimpleConfig hashes
2017-03-22 15:46:58 -04:00
Christoph Hartmann
7c11ff9280 add tag object (#1590)
* add tag object

Signed-off-by: Christoph Hartmann <chris@lollyrock.com>

* add tests for to_hash function in tag

Signed-off-by: Christoph Hartmann <chris@lollyrock.com>
2017-03-22 13:41:44 -04:00
Christoph Hartmann
9de56d25f7 Merge pull request #1589 from mr-exz/yaml-bug-file-name
Support YAML attributes files ending in .yaml
2017-03-22 14:36:26 +01:00
Christoph Hartmann
d2f000e435 refactor x509 resources and rsa key
Signed-off-by: Christoph Hartmann <chris@lollyrock.com>
2017-03-22 11:44:32 +01:00
Richard Nixon
f66f0b3a18 Initial support for x509_certificate and rsa_key
* Includes unit tests
* Includes 2 new resources
* Includes documentation

Signed-off-by: Richard Nixon <richard.nixon@btinternet.com>
2017-03-22 10:00:48 +01:00
Dominik Richter
738bae0db8 add inspec json schema validation to functional tests
Signed-off-by: Dominik Richter <dominik.richter@gmail.com>
2017-03-22 09:42:36 +01:00
Dominik Richter
c620cbf69e add inspec min json generator 2017-03-22 09:42:36 +01:00
Dominik Richter
55daa24cbc add json schema and generator 2017-03-22 09:42:36 +01:00
mr.exz
38c9648eb4 add fix
Signed-off-by: mr.exz <root@exzec.ru>
2017-03-22 08:17:18 +03:00
Adam Leff
66095722c8 release 1.17.0
Signed-off-by: Adam Leff <adam@leff.co>
2017-03-21 15:00:26 -04:00
John Kerry
d4a0ae4549 removing an unnecessary require of the rspec junit formatter
Signed-off-by: John Kerry <john@kerryhouse.net>
2017-03-19 22:07:19 -04:00
mr.exz
4647664d56 solve #1569 2017-03-19 00:00:49 +03:00
Adam Leff
ea7c0c493e Provide a method-based accessor for SimpleConfig hashes
When SimpleConfig parses a config file that has sections, such as a mysqld
config file, the values within that section are returned via a Hash. However,
we do not provide an easy way to write tests for those deep hash values:

```
describe mysql_conf('/tmp/my.cnf') do
  its('mysqld.expire_logs_days') { should cmp 10 }
end

  MySQL Configuration
     ∅  undefined method `expire_logs_days' for #<Hash:0x007fe463795a00>
```

This change provides a method-based accessor for Hashes that are built via
SimpleConfig.

```
describe mysql_conf('/tmp/my.cnf') do
  its('mysqld.expire_logs_days') { should cmp 10 }
end

  MySQL Configuration
     ✔  mysqld.expire_logs_days should cmp == 10
```

Fixes #1541 by changing the way the attributes are fetched.

Signed-off-by: Adam Leff <adam@leff.co>
2017-03-15 14:49:16 -05:00
Adam Leff
4f2b66302d Fix ObjectTraverser when accessing array values
When attempting to access array values via the `json` resource:

```
describe json('/tmp/test.json') do
      its(['array',0]) { should eq "zero" }
end
```

... the resulting data would be an array of the size of the original array
with all the values replaced with nils:

```
     expected: "zero"
          got: [nil, nil, nil]
```

This was due to a bug in the ObjectTraverser mixin that mapped array values
back through `extract_value` rather than properly handling the passed-in
key(s). This worked fine for the specific data format created by the `csv`
resource but did not work `json` or any other resource that subclassed the
`JsonConfig` resource.

This change fixes the logic when dealing with an array when it's encountered,
and fixes up the `csv` resource with its own `value` method.

This change also adds tests for ObjectTraverser.

Signed-off-by: Adam Leff <adam@leff.co>
2017-03-15 11:35:55 +01:00
Adam Leff
8155357d0a Add additional example for matching crontab commands
As raised in #1526, adding an additional example showing how
a user can use the `where` accessor to find commands matching
a pattern and write a test using the results.

Signed-off-by: Adam Leff <adam@leff.co>
2017-03-14 22:16:39 +01:00
Adam Leff
546486ff6a Merge pull request #1550 from chef/chris-rock/upstart-fallback
try to use sysv fallback if is not producing proper output
2017-03-09 17:25:29 -05: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
Christoph Hartmann
8b1619b60e try to use sysv fallback if is not producing proper output
Signed-off-by: Christoph Hartmann <chris@lollyrock.com>
2017-03-08 21:52:52 +01:00
Adam Leff
037f08beb2 Fixing port check with v4 IPs in a v6 netstat line
On Linux, netstat may show a tcp6/udp6 protocol line but include a
v4 address. This happens with AF_INET6 sockets that can accept
both v4 and v6 traffic. The port check was not properly handling
this situation and trying to pass a v4 address to URI bracketed as
if it was a v6 address.

Signed-off-by: Adam Leff <adam@leff.co>
2017-03-06 22:03:41 -07:00
Adam Leff
45f242e122 releasing 1.16.1 with a bug fix and omnibus fix
Signed-off-by: Adam Leff <adam@leff.co>
2017-03-06 11:58:00 -07:00
Makoto Nozaki
f913b56ffc Avoid connection timeout of "inspec version" (#1538)
* Add open_timeout to NET::HTTP.start call
Signed-off-by: Makoto Nozaki <makoto.nozaki@twosigma.com>

* Code cleanup based on the discussion at #1538
Signed-off-by: Makoto Nozaki <makoto.nozaki@twosigma.com>
2017-03-06 09:23:42 -07:00
Adam Leff
9550137605 Write Habitat-driven InSpec output to svc_var directory
When running a InSpec profile built with Habitat, we now
write the formatter/reporter data to a JSON file in the
pkg.svc_var_path rather than STDOUT. This will allow for
programmatic collection of this data and future enhancements
to allow this data to be passed around a Habitat ring.

This also corrects an issue creating a Habitat profile if the
profile had never been in the local InSpec cache. By setting a
mock Backend when creating the profile object, similarly to what
the archivers do, this issue is avoided.

Signed-off-by: Adam Leff <adam@leff.co>
2017-03-02 17:45:16 -05:00
Adam Leff
7154b6b95f Merge pull request #1530 from chef/1.16.0
1.16.0
2017-03-02 15:39:34 -05:00
Adam Leff
14d6678c82 1.16.0
Signed-off-by: Adam Leff <adam@leff.co>
2017-03-02 15:17:55 -05:00
Adam Leff
6bd66df014 Merge pull request #1511 from carldjohnston/oracle-linux-service-resource
Added oracle linux to rhel platform section of 'service' resource.
2017-03-02 07:00:56 -05:00
Christoph Hartmann
71cc62c757 use -- for description of inspec login_automate
Signed-off-by: Christoph Hartmann <chris@lollyrock.com>
2017-03-02 12:30:33 +01:00
Carl Johnston
316c994cc5 Added oracle linux to rhel platform section.
Broken when chef/train was fixed to detect oracle linux correctly.

Signed-off-by: Carl Johnston <carldjohnston@gmail.com>
2017-03-02 22:07:16 +11:00
Christoph Hartmann
be529dcea6 Merge pull request #1513 from postgred/kernel_module_centos
Fix kernel_module for centos/redhat
2017-03-02 09:27:10 +01:00
Adam Leff
f4b1a350ce Merge pull request #1501 from jbenden/jbenden/freebsd-zfs
Add FreeBSD support for ZFS datasets and pools
2017-03-01 13:06:44 -05:00
Adam Leff
19f114deea Merge pull request #1454 from jkerry/FunctionalJUnitReporter
Functional JUnit reporter
2017-02-27 12:00:36 -05:00
Adam Leff
d3f7de3134 Merge pull request #1519 from chef/v1.15.0
1.15.0
2017-02-27 11:29:44 -05:00
Adam Leff
1485debdde 1.15.0
Signed-off-by: Adam Leff <adam@leff.co>
2017-02-27 11:21:39 -05:00
John Kerry
e0ae7eb161 correcting a typo, anonymnous -> anonymous
Signed-off-by: John Kerry <john@kerryhouse.net>
2017-02-25 00:44:23 -05:00
jkerry
927a12c574 resolving old junit unit tests with the new format. Adding a skipped test node as a result 2017-02-25 00:44:23 -05:00
John Kerry
1f92268aa2 Converting the junit reporter to use nokogiri on top of the json reporter output hash 2017-02-25 00:44:23 -05:00
Adam Leff
91396d2029 Merge pull request #1488 from chef/adamleff/fix-multiple-flat-profiles
Generate default profile names, fix bug when using multiple flat profiles
2017-02-24 16:59:31 -05:00
Andrey Aleksandrov
70c33eb606
Remove os.family from kernel_module
Signed-off-by: Andrey Aleksandrov <postgred@gmail.com>
2017-02-24 23:30:00 +03:00
Christoph Hartmann
26dc4e7356 Merge pull request #1510 from trickyearlobe/fix_windows_output_formatting
Fix formatting and colors on Windows
2017-02-24 16:36:44 +01:00
Andrey Aleksandrov
82cf2baadd
fix syntax
Signed-off-by: Andrey Aleksandrov <postgred@gmail.com>
2017-02-24 16:55:20 +03:00
Andrey Aleksandrov
8fb6bd5c66
Fix kernel_module for centos/redhat
Signed-off-by: Andrey Aleksandrov <postgred@gmail.com>
2017-02-24 14:32:57 +03:00
Carl Johnston
efa1b951ab Merge remote-tracking branch 'origin/master' into apache_conf-symlinks 2017-02-24 16:07:02 +11:00
Richard Nixon
ee87dfb405 Fix formatting and colors on Windows
Fixes issue #1508

* Windows terminals don't support extended ANSI colours. Use basic + intensity
* Windows terminals don't support UTF-8 well so don't use special characters

Other OS'es get what they had before.

Signed-off-by: Richard Nixon <richard.nixon@btinternet.com>
2017-02-24 01:34:49 +00:00
Adam Leff
0342cca62e Adding a Habitat profile artifact creator
Two new commands have been created:

 * inspec habitat profile create /path/to/profile
 * inspec habitat profile upload /path/to/profile

The `create` command creates a Habitat artifact that contains the contents
of the Habitat profile found at the provided path. This will be used later
in some Habitat + InSpec integrations.

The `upload` command does the same create process but then uploads the
resulting artifact to the Habitat Depot.

Signed-off-by: Adam Leff <adam@leff.co>
2017-02-23 18:25:22 -05:00
Joseph Benden
1fdecc6680 Add FreeBSD support for ZFS datasets and pools
The following new resources have been added; however, they
presently only support FreeBSD and similar.

* `zfs_dataset`: tests if a named ZFS dataset is present
  and/or has certain properties.
* `zfs_pool`: tests if a named ZFS pool is present and/or
  has certain properties.

Additionally, the `mount` resource has been reworked to
include support for FreeBSD; while the existing class
was renamed to LinuxMountParser.

Unit-tests were added for all of the above.

Signed-off-by: Joseph Benden <joe@benden.us>
2017-02-22 10:29:49 -07:00
Adam Leff
bf07a58ed7 Merge pull request #1489 from chef/adamleff/doc-fix
Doc fix for SourceReaders::InspecReader
2017-02-15 09:28:39 -05:00
Alex Pop
88975bff2a Switch package resource to os.redhat detection and use two spaces as fileds delimited
Signed-off-by: Alex Pop <apop@chef.io>
2017-02-15 11:07:10 +00:00
Alex Pop
fae96f6249 Add RedHat support for packages resource
Fix dpkg trimming of first line
Signed-off-by: Alex Pop <apop@chef.io>
2017-02-15 11:07:10 +00:00
Adam Leff
bc7db89d70 Provide target info on shell invocation
When in inspec shell, you need to type the `help` command to find out info
about your target system. This info would be super helpful right out of the
gate so users have confidence that they're targeting the correct system.

The target info is still available via the `help` command as it always has
been, as well.

Signed-off-by: Adam Leff <adam@leff.co>
2017-02-14 14:46:47 +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
Adam Leff
d0bc085412 Generate default profile names, fix bug when using two-or-more flat profiles
When running InSpec with multiple profiles, and two or more of the profiles
are read in using the "Flat" SourceReader (i.e. they are not actual profiles
with a metadata file like inspec.yml, but rather just a folder containing
.rb files with controls and tests in them), InSpec would throw a NilClass
error when building the necessary objects for the formatter.

The cause was in `#profile_contains_example` in the formatter code which
checks to see if the profile name is the same as the profile_id in the given
example. However, if both of those were nil, it would potentially match the
wrong Flat-read profile.

This change fixes this in two ways: refusing to match if the profile name
or example profile ID is nil, and adding a default name to a profile if
it doesn't have a title or name. This will solve the matching issue and also
clean up the formatter output so users can more easily tell what tests
are from which profile/path.

Signed-off-by: Adam Leff <adam@leff.co>
2017-02-13 13:07:41 -05:00
Adam Leff
417b791baa Adding new crontab resource
The crontab resource parses a particular user's crontab file into
individual entries and allows the user to assert information about
each entry as needed.

Signed-off-by: Adam Leff <adam@leff.co>
2017-02-10 09:33:31 -05:00
Dominik Richter
4daa4d06c0 1.14.1 2017-02-10 14:13:12 +01:00
Alex Pop
ce927e657a Skip packages resource for unsupported OS
Signed-off-by: Alex Pop <apop@chef.io>
2017-02-10 10:34:01 +00:00
Dominik Richter
ddaa4c96cf 1.14.0 2017-02-09 00:39:04 +01:00
Dominik Richter
b86201d6df Merge pull request #1478 from chef/tduffield/relax-rubocop-pin
Use RuboCop 0.39.0 (same as chefstyle)
2017-02-09 00:09:48 +01:00
Tom Duffield
1ea83f526c Address rubocop violations
Signed-off-by: Tom Duffield <tom@chef.io>
2017-02-08 16:49:16 -06:00
Dominik Richter
d4243b3558 map url to https for compliance plugin
Signed-off-by: Dominik Richter <dominik.richter@gmail.com>
2017-02-08 23:29:58 +01:00
Dominik Richter
8c48e81b10 bugfix: warn users about insecure login requirements
Fixes https://github.com/chef/inspec/issues/1469

Signed-off-by: Dominik Richter <dominik.richter@gmail.com>
2017-02-08 08:47:31 +01:00
Adam Leff
c28d3bccbe Add support for "inspec -v" showing the version
The other Chef tooling (chef-client, chef, kitchen, berks, etc.)
support a `-v` flag to display the version. Currently, inspec
errors out with the following error:

```
Could not find command "_v".
```

This adds a Thor map so that `-v` executes the `version` command.

Signed-off-by: Adam Leff <adam@leff.co>
2017-02-07 15:28:39 -05:00
Dominik Richter
64ee82195d 1.13.0 2017-02-07 15:01:47 +01:00
jtimberman
d7fad68541 add "packages" resource
This pull request adds a packages resource so that we can check for pattern matches against all the packages on a system. This initially implements only dpkg support for debian-based platforms so we can cover this use case:

```ruby
describe packages(/^xserver-xorg.*/) do
  its("list") { should be_empty }
end
```

This uses FilterTable so we can supply additional queries, too.

```ruby
describe packages(/vi.+/).where { status != 'installed' } do
  its('statuses') { should be_empty }
end
```

Users can specify the name as a string or a regular expression. If it is a string, we will escape it and convert it to a regular expression to use in matching against the full returned list of packages. If it is a regular expression, we take that as is and use it to filter the results.

While some package management systems such as `dpkg` can take a shell glob argument to filter their results, we eschew this and require a regular expression to match multiple package names because we will need this to work across other platforms in the future. This means that the following:

```ruby
packages("vim")
```

Will return *all* the "vim" packages on the system. The `packages` resource will take `"vim"`, turn it into `/vim/`, and greedily match anything with "vim" in the name. To match only a single package named `vim`, it needs to be an anchored regular expression.

```ruby
packages(/^vim$/)
```

Signed-off-by: Joshua Timberman <joshua@chef.io>

Use entries instead of list

Added a few more tests and non installed package in output
Signed-off-by: Alex Pop <apop@chef.io>

fix lint

Signed-off-by: Alex Pop <apop@chef.io>

Signed-off-by: Joshua Timberman <joshua@chef.io>
2017-02-07 10:29:11 +00:00
Alex Pop
52842de552 Provide a way to force it vs its for any argument
Signed-off-by: Alex Pop <apop@chef.io>
2017-02-03 19:26:02 +00:00
Dominik Richter
2fa8039f60 1.12.0 2017-02-03 17:36:43 +01:00
Alex Pop
920ff068e6 Allow setting of the tests array
Signed-off-by: Alex Pop <apop@chef.io>
2017-02-03 15:03:09 +00:00
Alex Pop
eb450c08a6 deprecate .list
Signed-off-by: Alex Pop <apop@chef.io>
2017-02-03 08:28:46 +00:00
Alex Pop
92454f96c3 Add FilterTable for processes
Signed-off-by: Alex Pop <apop@chef.io>
2017-02-03 08:28:46 +00:00
Christoph Hartmann
58585e3455 switch to faraday as http backend
Signed-off-by: Christoph Hartmann <chris@lollyrock.com>
2017-02-02 22:13:36 +01:00
Christoph Hartmann
283bbda0c6 1.11.0 2017-02-01 14:07:32 +01:00
Alex Pop
495185b581 derive xinetd protocol from socket_type when not defined in the config file
Signed-off-by: Alex Pop <apop@chef.io>
2017-02-01 11:19:24 +00:00
Alex Pop
a3de32ad04 Fix xinetd parsing of services from the same file. Expose resource.protocols
Signed-off-by: Alex Pop <apop@chef.io>
2017-01-31 12:40:29 +00:00
Alex Pop
80ad877e02 Wrap regex in parenthesis no matter of the matcher used, ex: match, cmp
Signed-off-by: Alex Pop <apop@chef.io>
2017-01-30 11:51:06 +00:00
Alex Pop
11429a54d3 Add Inspec::Variable test to a control
Signed-off-by: Alex Pop <apop@chef.io>
2017-01-30 11:01:02 +00:00
Alex Pop
660b997342 Add negate! support for the describe.one object
Signed-off-by: Alex Pop <apop@chef.io>
2017-01-30 11:01:02 +00:00
Christoph Hartmann
78b7a2c680 Merge pull request #1435 from postgred/kernel_module_version
Version method for kernel_module
2017-01-27 17:49:23 +01:00
Andrey Aleksandrov
4caa8c50d1
Minor improvements
Signed-off-by: Andrey Aleksandrov <postgred@gmail.com>
2017-01-27 13:51:45 +03:00
Andrey Aleksandrov
3783357e50
Add version method to kernel_module
Signed-off-by: Andrey Aleksandrov <postgred@gmail.com>
2017-01-27 13:33:41 +03:00
Christoph Hartmann
fa707dfcab 1.10.0
Signed-off-by: Christoph Hartmann <chris@lollyrock.com>
2017-01-26 17:46:05 +01:00
Christoph Hartmann
976e5d85e4 improve http header handling
Signed-off-by: Christoph Hartmann <chris@lollyrock.com>
2017-01-26 17:16:37 +01:00
Christoph Hartmann
440c09ea38 Merge pull request #1416 from brentm5/bm-add-refresh-token
Updated compliance api requests to actually use refresh token correctly
2017-01-26 14:27:57 +01:00
Guilhem Lettron
51ca98c468 Add an http test method
Signed-off-by: Guilhem Lettron <g.lettron@criteo.com>
2017-01-26 12:02:54 +01:00
Montague, Brent
463f3ff09f Refactor after revisions requested from @chris-rock
Signed-off-by: Montague, Brent <brent@bmontague.com>
2017-01-25 14:33:34 -05:00
Montague, Brent
caa554b467 Updated compliance api requests to actually use refresh token correctly
We do not store a token in the config file but rather generate one on
each commmand.  This is just a first pass and needs some work.

Signed-off-by: Montague, Brent <brent@bmontague.com>
2017-01-25 14:33:34 -05:00
Nathen Harvey
2eda02932f
'execution' is spelled correctly
Fixes a minor typo. The correct spelling is 'execution', not
'executation'

Signed-off-by: Nathen Harvey <nharvey@chef.io>
2017-01-24 23:19:30 -05:00
Carl Johnston
0e3d8da16b Allow apache_conf to include symlinked configuration files
Signed-off-by: Carl Johnston <carldjohnston@gmail.com>
2017-01-08 10:54:00 +11:00
Christoph Hartmann
f2efaaded1 1.9.0 2017-01-06 18:34:44 +01:00
Christoph Hartmann
8015f1191c implement download of profiles
Signed-off-by: Christoph Hartmann <chris@lollyrock.com>
2017-01-05 13:31:36 +01:00
Christoph Hartmann
efab62ef00 optimize regular expression for postgres config parsing
Signed-off-by: Christoph Hartmann <chris@lollyrock.com>
2017-01-05 13:16:47 +01:00
Wei, He
370269c2dd Yum.repo should show correct name
https://github.com/chef/inspec/issues/1390

Signed-off-by: Wei, He <weihe924stephen@gmail.com>
2017-01-04 11:10:38 +09:00
Dominik Richter
a15749f328 bugfix: expose postgres_conf parameters via its
Signed-off-by: Dominik Richter <dominik.richter@gmail.com>
2017-01-03 16:17:36 +01:00
Christoph Hartmann
08e182843b fixes brew json parsing
Signed-off-by: Christoph Hartmann <chris@lollyrock.com>
2017-01-03 12:24:57 +01:00
Christoph Hartmann
f0cdad800f display if inspec version is outdated
Signed-off-by: Christoph Hartmann <chris@lollyrock.com>
2017-01-03 12:10:43 +01:00
Makoto Nozaki
9834e3f8f9 Make "permission denied" condition match that of Train
Signed-off-by: Makoto Nozaki <makoto.nozaki@twosigma.com>
2016-12-28 22:20:40 -05:00
Christoph Hartmann
fc6ab8d6f9 print name for supermarket profiles 2016-12-22 09:48:53 +01:00
Christoph Hartmann
10bb08b691 1.8.0 2016-12-16 17:49:51 +01:00
Christoph Hartmann
7a0b0803bd add fallback syntax for serverspec tests
Signed-off-by: Christoph Hartmann <chris@lollyrock.com>
2016-12-15 16:16:17 +01:00
Christoph Hartmann
6e2b21e1f8 Merge pull request #1366 from makotots/mn/json-variable-name-fix
JSON resource's error message is missing filename when file is not found
2016-12-15 15:17:28 +01:00
Makoto Nozaki
42cffeea61 Fix variable name. Add test.
Signed-off-by: Makoto Nozaki <makoto.nozaki@twosigma.com>
2016-12-15 08:00:56 -05:00
Jeremy J. Miller
6481f00454 cmp better support for version ops
Signed-off-by: Jeremy J. Miller <jm@chef.io>
2016-12-14 23:45:38 -05:00
Franklin Webber
ad82ac48c8 Removes profiles reader and replaces with ivar
The profiles method was never public and the @profiles is clearer.

Signed-off-by: Franklin Webber <franklin@chef.io>
2016-12-14 13:34:53 -06:00
Franklin Webber
0a0431ac29 Privatizes more methods within the Formatter
Based on some feedback from @arlimus there were some methods that
were not part of the public inteface that I moved to private.

I changed the examples collection from a delete from the output_hash
to retrieve the controls.

Created a helper for the all_unique_controls which was used in two helper
methods.

Signed-off-by: Franklin Webber <franklin@chef.io>
2016-12-14 13:34:53 -06:00
Franklin Webber
eb495e9675 Fixes to address Rubocop issues and privacy
The class size is too big and Rubocop is right. There are a few
more classes in there that could be extracted but I am going to
ignore it. The other issues that it presented were fair.

Signed-off-by: Franklin Webber <franklin@chef.io>
2016-12-14 13:34:53 -06:00
Franklin Webber
d8c7347ee9 Updates the Formatter's Control summary calcuation
* Moved things around for better understanding of the class
* Used `private` to denote what was on the public interface
* Solved the ugly TODO which was calculating the state of the control's
  summary
* Used `#examples` instead of `res = control[:results]` throughout the
  #summary and #title methods

Signed-off-by: Franklin Webber <franklin@chef.io>
2016-12-14 13:34:53 -06:00
Franklin Webber
4695c9e7be Fixes for functional tests and better displaying dep. profiles
* Fixes an issue when specifying no profile
* Fixes an issue when displaying a profile that has included/required profiels
* Fixes an issue when specifying profiles with only metadata
* Fixes formatting for spacing to ensure it adheres to previous alignment
* Fixes issue with the Control object and the rolling up of failed
  and skipped examples.

Signed-off-by: Franklin Webber <franklin@chef.io>
2016-12-14 13:34:53 -06:00
Franklin Webber
fa45c3993d Updates RSpec CLI Formater to print profiles correctly
The profiles will display  the controls with their results and
then display the examples not associated with any control but
within the profile.

Signed-off-by: Franklin Webber <franklin@chef.io>
2016-12-14 13:34:53 -06:00
Franklin Webber
914c8384c0 Adds CurrentControl class to Cli RSpecJSONFormatter
A lot of the work in #flush_current_control is acting on the control.
I am starting the flip of the control and bringing those messages being
sent originating from a control class itself.

Signed-off-by: Franklin Webber <franklin@chef.io>
2016-12-14 13:34:53 -06:00
Franklin Webber
7627add552 Refactors JSON / CLI formatter
Cleans up the #stop action on the JSON formatter by creating more
methods that memoize values or provide values through a method
interface.

There is still more that can be done with the whole mapping
examples to controls through profiles.

Signed-off-by: Franklin Webber <franklin@chef.io>
2016-12-14 13:34:53 -06:00
Franklin Webber
a8a949d996 Removes start stage from Json Formatter
The full JSON formatter was using the start step to setup the profiles_info.
I moved that to a memozied method so that the first time it is called it will
be created.

Signed-off-by: Franklin Webber <franklin@chef.io>
2016-12-14 13:34:52 -06:00
Victoria Jeffrey
b30a5dc165 add in some comments, etc 2016-12-14 13:34:52 -06:00
Victoria Jeffrey
37e60e929d wip: remove some global variable usage 2016-12-14 13:34:52 -06:00
Lee Briggs
4b28c9b342 Add profile version to archive
Signed-off-by: Lee Briggs <lbriggs@apptio.com>
2016-12-14 16:14:20 +00:00
Christoph Hartmann
a02bc81b19 1.7.2 2016-12-08 12:38:22 +00:00
Christoph Hartmann
7a0aa49986 use cached profile for compliance dependencies if vendored
Signed-off-by: Christoph Hartmann <chris@lollyrock.com>
2016-12-08 10:11:55 +00:00
Christoph Hartmann
9fbe6d0347 1.7.1 2016-12-03 10:22:26 +01:00
Alex Pop
76c4e26580 remove check and json logging for now
Signed-off-by: Alex Pop <apop@chef.io>
2016-12-02 18:06:51 +00:00
Christoph Hartmann
c1e7fc50b1 1.7.0 2016-12-02 12:59:10 +01:00
Victoria Jeffrey
0991cd142f move vendor_deps to base_cli
Signed-off-by: Victoria Jeffrey <vjeffrey@chef.io>
2016-12-01 15:29:47 +01:00
Victoria Jeffrey
b110c1fba5 Vendor profile when uploading to chef-compliance
Signed-off-by: Victoria Jeffrey <vjeffrey@chef.io>
2016-11-30 18:24:12 +01:00
Victoria Jeffrey
d8b512ec8c refactor headers retrieval into get_headers method
Signed-off-by: Victoria Jeffrey <vjeffrey@chef.io>
2016-11-30 18:10:33 +01:00
Victoria Jeffrey
60009b292b address comments
Signed-off-by: Victoria Jeffrey <vjeffrey@chef.io>
2016-11-30 13:27:50 +01:00
Victoria Jeffrey
bdf5eae15e Extend inspec compliance cli to support automate backend
Signed-off-by: Victoria Jeffrey <vjeffrey@chef.io>
2016-11-30 13:27:50 +01:00
Christoph Hartmann
d07e597f68 Merge pull request #1336 from burtlo/burtlo/add_junit_help
Adds junit to the inspec help exec
2016-11-30 10:14:17 +01:00
Christoph Hartmann
8346d2acfd Merge pull request #1333 from Wing924/fix_regexp_in_processes
fix bug: RegExp in processes resource can't match long-run process #1332
2016-11-30 10:13:38 +01:00
Franklin Webber
9d30628213 Adds junit to the inspec help exec
While rebasing the branch where I was working on the cli formatter I
noticed the addition of junit. However, it was not in the help.

Signed-off-by: Franklin Webber <franklin@chef.io>
2016-11-30 01:17:44 -06:00
Alex Pop
4c60a69eae Provide inspec.lock for archives as well
Signed-off-by: Alex Pop <apop@chef.io>
2016-11-29 23:59:39 +01:00
Christoph Hartmann
5bfc9745e3 move default cache creation to profile implementation
Signed-off-by: Christoph Hartmann <chris@lollyrock.com>
2016-11-29 14:28:03 +01:00
Alex Pop
b01440b7c8 pass default cache path to for_target, enable log change
Signed-off-by: Alex Pop <apop@chef.io>
2016-11-29 12:35:56 +01:00
Juan Carlos Castillo Cano
58ef61f1f4 Show process name during inspec output
Signed-off-by: Juan Carlos Castillo Cano <jccastillocano@gmail.com>
2016-11-29 11:00:43 +00:00
Wei, He
861856fbd9 fix bug: RegExp in processes resource can't match long-run process #1332
Signed-off-by: Wei, He <weihe924stephen@gmail.com>
2016-11-29 17:01:03 +09:00
Victoria Jeffrey
2e2502777c move methods around, separate into sections
Signed-off-by: Victoria Jeffrey <vjeffrey@chef.io>
2016-11-28 15:42:26 +01:00
Victoria Jeffrey
e4efbf6efe remove some unnecessary vars; comment methods 2016-11-28 15:42:26 +01:00
Christoph Hartmann
b0ed0806bb 1.6.0 2016-11-28 12:45:21 +01: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
a990d20fcd Merge pull request #1306 from username-is-already-taken2/digitalgaz/windows_task
Adding windows_task resource
2016-11-25 11:46:42 -07:00
Christoph Hartmann
ded7d4c3c4 Merge pull request #1304 from jkerry/AddJUnitFormatterSupport
Adding JUnit formatter support
2016-11-25 11:33:45 -07:00
hannah-radish
91fe22f044 Replaced Colors for output
Signed-off-by: hannah-radish <hannah@radish-life.com>
2016-11-23 20:19:18 -07:00
Dominik Richter
b86f8cdeba Merge pull request #1308 from jerryaldrichiii/fix-extra-quote-typo
Remove extra `'` in registry key examples
2016-11-23 20:15:18 -07:00
hannah-radish
ebb3bc729a Introduce new (awesome) CLI icons for results
Signed-off-by: Hannah Maddy hannah@radish-life.com
2016-11-23 20:06:17 -07:00
Victoria Jeffrey
444d5ea1bc revert style changes temporarily
Signed-off-by: Victoria Jeffrey <vjeffrey@chef.io>
2016-11-23 10:58:28 -05:00
hannah-radish
1338c39e1c Fixing what I broke
Declared var for labels when logic was not in place
2016-11-22 20:26:02 -08:00
hannah-radish
ff165834a5 Updated color palettes, label colors and icons
Added color palettes for helper, input, command and automate text.
2016-11-22 15:55:02 -08:00
jkerry
e5830c2c56 Adding my name to the authors on the rspec formatter file
Signed-off-by: jkerry <john@kerryhouse.net>
2016-11-22 15:06:19 -05:00
Jerry Aldrich III
66a47ce8b9 Remove extra ' in registry key examples
Signed-off-by: Jerry Aldrich III <jerry@chef.io>
2016-11-21 10:18:01 -06:00
Christoph Hartmann
c7e15f7fad 1.5.0 2016-11-20 21:39:11 -07:00
username-is-already-taken2
f4410c3fa6 Fixing errors reported in Travis
Signed-off-by: username-is-already-taken2 <digitalgaz@hotmail.com>
2016-11-20 20:32:48 +00:00
username-is-already-taken2
b6b4525379 Amended method after unit testing 2016-11-20 20:07:59 +00:00
username-is-already-taken2
269890ad3b Added windows_task to runtime 2016-11-20 20:07:59 +00:00
username-is-already-taken2
9b818aff5d Added windows_task resource
Signed-off-by: username-is-already-taken2 <digitalgaz@hotmail.com>
2016-11-20 20:07:59 +00:00
Christoph Hartmann
e3347f0ef0 ensure metadata release entry is a string, even if yml thinks it is a float
Signed-off-by: Christoph Hartmann <chris@lollyrock.com>
2016-11-20 12:38:27 -07:00
jkerry
e5038e1e5d adding a shell extension class of the rspec_junit_formatter gem formatter and including it in the formatters list with key 'junit'
Signed-off-by: jkerry <john@kerryhouse.net>
2016-11-20 00:18:34 -05:00
Robb Kidd
ae474b894e update supermarket profile search to use new type param
Reverts the work-around that pulls down the latest 100 tools
and filters for type == 'compliance_profile' in the client.

Go back to using tool-search with the new type parameter.

Omit start:0 because that's the default.

Keep the number of items returned at 100, which is more than the
default 10.

Signed-off-by: Robb Kidd <robb@thekidds.org>
2016-11-12 15:45:19 -05: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