Commit graph

1057 commits

Author SHA1 Message Date
Chris Redekop
d428a96bab Add a new access-key resource
Signed-off-by: Chris Redekop <chris.redekop@d2l.com>
2017-04-18 15:03:31 +02: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
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
Viktor Yakovlyev
ff72e81915 Add iam password policy
Signed-off-by: Viktor Yakovlyev <Viktor.Y@D2L.com>

wire up mock resource twice

Signed-off-by: Viktor Yakovlyev <Viktor.Y@D2L.com>

cleaning up as per pr feedback

Signed-off-by: Viktor Yakovlyev <Viktor.Y@D2L.com>

style fixes

Signed-off-by: Viktor Yakovlyev <Viktor.Y@D2L.com>

fix indent in test

Signed-off-by: Viktor Yakovlyev <Viktor.Y@D2L.com>

remove unneeded line

Signed-off-by: Viktor Yakovlyev <Viktor.Y@D2L.com>

use minitest mock instead of object

Signed-off-by: Viktor Yakovlyev <Viktor.Y@D2L.com>
2017-04-11 14:16:21 -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
266241f173 do not install apache and postgres on windows
Signed-off-by: Christoph Hartmann <chris@lollyrock.com>
2017-04-07 10:57:03 +02: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
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
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
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
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
a96059a3eb x509 integration tests
Signed-off-by: Christoph Hartmann <chris@lollyrock.com>
2017-03-22 11:44:33 +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
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
sfreeman
d9221bb925 Add ability to choose a user by username
Add has MFA enabled member
Add "has console password" member

Signed-off-by: sfreeman <Steffanie.Freeman@d2l.com>
2017-03-15 15:49:13 -04: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
Carl Johnston
30b4152dd2 Add integration tests for symlinked apache configuration.
Remove httpd helper cookbook and write out simple configuration by hand.

Signed-off-by: Carl Johnston <carldjohnston@gmail.com>
2017-03-14 14:48:19 +11: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
Russell Seymour
ff4a1ba200 Renamed public ip address test
Removed debugging flag

Signed-off-by: Russell Seymour <russell.seymour@turtlesystems.co.uk>
2017-03-07 08:15:50 +00: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
Russell Seymour
ef323e3b31 Updated resource to follow RSpec convention
Closes #31

Signed-off-by: Russell Seymour <russell.seymour@turtlesystems.co.uk>
2017-03-02 14:08:33 +00:00
Russell Seymour
de1b7134ef Added new resources
Allows testing of network configurations
Closes #2

Signed-off-by: Russell Seymour <russell.seymour@turtlesystems.co.uk>
2017-03-02 14:01:54 +00:00
Russell Seymour
47cda053fb Renamed matcher to admin_username
Closes #30

Signed-off-by: Russell Seymour <russell.seymour@turtlesystems.co.uk>
2017-03-02 11:17:00 +00: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
Russell Seymour
7842d37fb3 Renamed azure_rg resource
Closes #25

Signed-off-by: Russell Seymour <russell.seymour@turtlesystems.co.uk>
2017-03-01 17:32:17 +00:00
Russell Seymour
6f57529a44 Renamed the host attribute on azure_virtual_machine_resource
Updated README file
Closes #26

Signed-off-by: Russell Seymour <russell.seymour@turtlesystems.co.uk>
2017-03-01 17:20:59 +00:00
Russell Seymour
a4e0df698a Renamed resources for readability
Closes #27

Signed-off-by: Russell Seymour <russell.seymour@turtlesystems.co.uk>
2017-03-01 17:14:09 +00:00
Russell Seymour
ec072cadd3 Added integration tests for current resources
Closes #19

Signed-off-by: Russell Seymour <russell.seymour@turtlesystems.co.uk>
2017-03-01 16:00:19 +01:00
Adam Leff
19f114deea Merge pull request #1454 from jkerry/FunctionalJUnitReporter
Functional JUnit reporter
2017-02-27 12:00:36 -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
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
Carl Johnston
3bdf1563e8 Added unit tests for apache_conf inclusion of symlinked files.
Same test added to both Ubuntu and Centos for consistency.

Signed-off-by: Carl Johnston <carldjohnston@gmail.com>
2017-02-24 16:13:22 +11: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
Viktor Yakovlyev
bdd86542b0 add negative case test for exists?
Signed-off-by: Viktor Yakovlyev <Viktor.Y@D2L.com>
2017-02-16 14:33:21 -05:00
Viktor Yakovlyev
f0773ccc75 fix tests
Signed-off-by: Viktor Yakovlyev <Viktor.Y@D2L.com>
2017-02-16 14:27:35 -05:00
Viktor Yakovlyev
6ee43f8fb5 Adding check for ec2 instance existence. #13
Signed-off-by: Viktor Yakovlyev <Viktor.Y@D2L.com>
2017-02-16 14:02:44 -05:00
Chris Redekop
3cad7d1e78 #13, Ec2#exists returns false positives
Signed-off-by: Chris Redekop <chris.redekop@d2l.com>
2017-02-16 14:02:44 -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
Chris Redekop
9d8afa5440 add tests for :instance and :exists
Signed-off-by: Chris Redekop <chris.redekop@d2l.com>
2017-02-14 18:38:15 +01:00
Chris Redekop
1842cc2fd9 add another id-method test
Signed-off-by: Chris Redekop <chris.redekop@d2l.com>
2017-02-14 18:38:11 +01:00
Chris Redekop
5d00aac059 Add unit test skeleton with Minitest dependency
Signed-off-by: Chris Redekop <chris.redekop@d2l.com>
2017-02-14 18:38:06 +01: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
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
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
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
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
83e44f9d2a add another variable handling example test
Signed-off-by: Alex Pop <apop@chef.io>
2017-02-03 08:28:46 +00:00
Alex Pop
f7444ed372 update the tests to reflect the list->entries migration and where support
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
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
6f3a9d22d7 define protocol as done in CentOS
Signed-off-by: Alex Pop <apop@chef.io>
2017-01-31 14:47:21 +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
5a087bd256 Add matchers and expectations to all object tests
Signed-off-by: Alex Pop <apop@chef.io>
2017-01-30 11:21:57 +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
ce90f0aa30 Add Inspec::List and Inspec::Control tests
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
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
976e5d85e4 improve http header handling
Signed-off-by: Christoph Hartmann <chris@lollyrock.com>
2017-01-26 17:16:37 +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
Christoph Hartmann
c2d92d8e86 use new devsec baseline
Signed-off-by: Christoph Hartmann <chris@lollyrock.com>
2017-01-25 20:22:38 +01:00
Christoph Hartmann
a55b341b32 use terraform + inspec for integration testing 2017-01-24 21:51:10 +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
Jeremy J. Miller
72b0c0dd2e control and lib eval unit tests
Signed-off-by: Jeremy J. Miller <jm@chef.io>
2017-01-04 11:33:14 -05: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
74ed60ce5f Merge pull request #1387 from jvrplmlmn/package-brew-unit-test
Unit test the 'package' resource for OSX (with brew)
2017-01-03 12:24:46 +01:00
Christoph Hartmann
07ee8ecd66 call ssh cookbook from prepare cookbook
Signed-off-by: Christoph Hartmann <chris@lollyrock.com>
2017-01-03 11:40:09 +01:00
Christoph Hartmann
ab097ef8d1 update functional tests
Signed-off-by: Christoph Hartmann <chris@lollyrock.com>
2017-01-03 11:06:05 +01:00
Javier Palomo Almena
07b41eb9df Fix wrong description for the Solaris cases in the unit tests of the 'package' resource
Obvious fix.

Signed-off-by: Javier Palomo Almena <javier.palomo.almena@gmail.com>
2017-01-02 18:06:59 +01:00
Javier Palomo Almena
8ab8fcdda5 Unit test the package resource for Darwin
Signed-off-by: Javier Palomo Almena <javier.palomo.almena@gmail.com>
2017-01-02 17:57:41 +01:00
Javier Palomo Almena
3f1986eb6f Mock 'brew info --json=v1 curl' to facilitate unit testing the package resource for the darwin platform
Signed-off-by: Javier Palomo Almena <javier.palomo.almena@gmail.com>
2017-01-02 17:57:20 +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
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
Lee Briggs
02530310cd Updating tests for profile versions
Signed-off-by: Lee Briggs <lbriggs@apptio.com>
2016-12-14 16:20:27 +00:00
Christoph Hartmann
1472fd4bff deactivate functional tests until logging is reintroduced
Signed-off-by: Christoph Hartmann <chris@lollyrock.com>
2016-12-02 19:52:34 +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
db4ce72407 merge json tests for vendored profiles
Signed-off-by: Christoph Hartmann <chris@lollyrock.com>
2016-11-30 11:17: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
Wei, He
fd04daf77c add testcase for #1332
Signed-off-by: Wei, He <weihe924stephen@gmail.com>
2016-11-30 13:25:44 +09:00
Christoph Hartmann
826c9fd4c8 add functional tests for tar lockfile reading
Signed-off-by: Christoph Hartmann <chris@lollyrock.com>
2016-11-30 00:37:47 +01:00
Christoph Hartmann
8808c57cae Extend functional tests for vending based on feedback from @alexpop
Signed-off-by: Christoph Hartmann <chris@lollyrock.com>
2016-11-29 23:40:42 +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
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
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
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
jkerry
944040fcf9 adding functional tests for the junit rspec formatter
Signed-off-by: jkerry <john@kerryhouse.net>
2016-11-22 14:45:34 -05:00
jkerry
3ee2808e08 Adding the initial top-level functional tests for inspec result junit xml
Signed-off-by: jkerry <john@kerryhouse.net>
2016-11-21 08:06:46 -05:00
username-is-already-taken2
e6e47eec4c Added unit tests, only took most of the night :) 2016-11-20 20:07:59 +00:00
username-is-already-taken2
20de35157c Added integration tests 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
Christoph Hartmann
fef4f9447b add functional tests
Signed-off-by: Christoph Hartmann <chris@lollyrock.com>
2016-11-09 11:49:51 -06:00
Christoph Hartmann
2c75a2c8db Merge pull request #1280 from grimm26/apt
improved regex for matching deb sources
2016-11-09 11:19:13 -06:00
Mark Keisler
bd33aa7175 improved regex for matching deb sources
also added tests.
Signed-off-by: Mark Keisler <mark@mitsein.net>
2016-11-09 11:10:46 -06:00
Christoph Hartmann
66449cae32 add functional tests
Signed-off-by: Christoph Hartmann <chris@lollyrock.com>
2016-11-09 09:12:10 -06:00
Christoph Hartmann
4b22400012 update functional tests
Signed-off-by: Christoph Hartmann <chris@lollyrock.com>
2016-11-04 18:01:28 +01:00
Christoph Hartmann
7d7e1efef3 move file mount test to mount_spec.rb
Signed-off-by: Christoph Hartmann <chris@lollyrock.com>
2016-11-03 22:23:50 +01:00
Christoph Hartmann
e78d682c24 activate file integration tests in docker
Signed-off-by: Christoph Hartmann <chris@lollyrock.com>
2016-11-03 22:13:45 +01:00
Artem Sidorenko
9d766252f7 Contain matcher maps to include matcher with warning
to allow easier migration from serverspec, where contain
matcher is used often

Signed-off-by: Artem Sidorenko <artem@posteo.de>
2016-11-03 20:58:34 +01:00
Dave Parfitt
51378d326b adds profile signing/verification
Signed-off-by: Dave Parfitt <dparfitt@chef.io>
2016-10-27 14:44:10 +02:00
Christoph Hartmann
9d86f7b022 Fix unit test and activate verbose mock backend to see missing command in cli output
Signed-off-by: Christoph Hartmann <chris@lollyrock.com>
2016-10-27 14:33:34 +02:00
Jeremy J. Miller
5494ec0c60 refactored file resource unit tests
Signed-off-by: Jeremy J. Miller <jm@chef.io>
2016-10-26 15:57:30 +02:00
Jeremy J. Miller
cda492af96 file/dir permissions for os_prepare file recipe
Signed-off-by: Jeremy J. Miller <jm@chef.io>
2016-10-26 15:57:30 +02:00
Jeremy J. Miller
c4abbed2a6 adding integration test
Signed-off-by: Jeremy J. Miller <jm@chef.io>
2016-10-26 15:57:30 +02:00
Alex Pop
70416a35b4 use command instead of comm and set user column width on linux
Signed-off-by: Alex Pop <apop@chef.io>
2016-10-17 15:39:13 +01:00
Anirudh Gupta
8efec7ac6c fix processes resource for os's where username is long to avoid truncation 2016-10-17 11:46:16 +01:00
Alex Pop
5d51b7a0aa dot inspect actual value to match the expected string one 2016-10-13 07:13:51 -07:00
Alex Pop
6719cf544d add tests for cmp output 2016-10-10 05:40:22 -07:00
Artem Sidorenko
77738dd895 Some further tests for Mint 2016-10-08 23:34:56 +02:00
Artem Sidorenko
aa725fe2df Linux Mint support for service resource 2016-10-08 23:34:56 +02:00
Alex Pop
10116724fc Missing registry keys should not exist 2016-10-05 14:55:04 +02:00
Dominik Richter
441967510f bugfix: support nil entries in filter table 2016-10-05 13:04:00 +02:00
Victoria Jeffrey
47c6427082 print profile info before test results (inherited profiles) 2016-09-27 10:39:35 -04:00
Steven Danna
7aa4c6da8e Fix require_controls DSL method
Previous, require_controls was including all controls from the named
profile, despite the documented behavior being that it only includes
controls explicitly pulled in by the user.  The cause was two-fold:

1) A previous refactor meant that we weren't removing the rule from the
correct context, and

2) We weren't descending down the dependency tree when filtering rules.

This commit fixes the require_controls DSL method and adds a test to
help prevent future regressions.

Signed-off-by: Steven Danna <steve@chef.io>
2016-09-26 15:20:56 +02:00
Steven Danna
f23a0d1098
Bump lockfile version to 1.0
Signed-off-by: Steven Danna <steve@chef.io>
2016-09-26 09:51:04 +01:00
Christoph Hartmann
dab8ff5c13 replace wmi win32_useraccount with adsi users 2016-09-26 01:31:44 +02:00
Alex Pop
13da437dcc Show skip_message and correct title 2016-09-23 07:47:21 +01:00
Christoph Hartmann
f7ec24a337 implement filter table for group/groups resource 2016-09-23 00:53:24 +02:00
Steven Danna
d29e8768ca Rename --no-write-lockfile to --no-create-lockfile
Signed-off-by: Steven Danna <steve@chef.io>
2016-09-22 10:08:32 +02:00
Steven Danna
2f3a916080 Always write lockfiles for local top-level profiles
This commit threads through some state related to whether or not a
profile is "local", that is whether it is a directory on disk.  If it
is, we then write out the lockfile to disk.

Signed-off-by: Steven Danna <steve@chef.io>
2016-09-22 10:08:32 +02:00
Steven Danna
8d63db9a2b
Change :shasum key to :sha256 for future upgrade
Signed-off-by: Steven Danna <steve@chef.io>
2016-09-21 10:51:04 +01:00
Steven Danna
6814d6ad2b
Fail if a remote source content doesn't match lockfile
If a URL based source does not match the shasum recorded in the
lockfile, it likely means a new version has been pushed to the remote
source. In this case, we fail to help ensure that when using a lockfile
we always run the same code as when the lockfile was created.

Signed-off-by: Steven Danna <steve@chef.io>
2016-09-21 10:15:52 +01:00
David Pell
155995adfd In ApacheConf#include_files, check for abs paths
If the path is absolute, just use what was passed, otherwise build an
absolute path using `@conf_dir`.

Fixes #1013
2016-09-20 09:11:09 -04:00
Alex Pop
e1faebd527 Include code description in the output of failed controls 2016-09-20 10:10:08 +01:00
Steven Danna
b2146d8758 Allow users to reference resources from dependencies
All resources from deps are added into the control_eval_context used by
the current profile. However, if there is a name conflict, the last
loaded resource wins. The new `require_resource` dsl method allows the
user to do the following:

    require_resource(profile: 'profile_name',
                     resource: 'other',
                    as: 'renamed')

    describe renamed do
      ...
    end

Signed-off-by: Steven Danna <steve@chef.io>
2016-09-19 19:08:43 +02:00
Christoph Hartmann
17ce99df7f use Gem::Version instead of a regular expression for a test version bump 2016-09-19 18:58:30 +02:00
Dominik Richter
6792550f8c adopt new json formatting 2016-09-19 13:45:03 +02:00
Dominik Richter
38f2680cf4 static keys in all json 2016-09-19 12:00:14 +02:00
Victoria Jeffrey
ecac8ae9cb print profile summary and test summary 2016-09-18 21:53:16 -04:00
Steven Danna
be1a61f2e5 Process transitive dependencies from lock file
This is a regression introduced by the changes from string to symbol
keys in v0.34.0. It seems that our test cookbook that had a nested
dependency example wasn't actually wired up to run.

This adds a basic functional test and corrects the typo.

Signed-off-by: Steven Danna <steve@chef.io>
2016-09-15 09:41:40 +02:00
Christoph Hartmann
5088795ffc Merge pull request #1077 from chef/ssd/no-gpg-for-you
Don't gpg-sign commits during tests
2016-09-14 17:57:35 +02:00
Steven Danna
7fbb768fc7 Don't gpg-sign commits during tests
If you have gpg singing globally enabled, the tests would ask you for
your gpg pin.  This is not fun.

Signed-off-by: Steven Danna <steve@chef.io>
2016-09-14 17:50:37 +02:00
Christoph Hartmann
178156499f Merge pull request #1076 from chef/ssd/issue-1074
Ensure resources are visible inside its blocks
2016-09-14 17:48:26 +02:00
Steven Danna
8024eea8b7
Ensure resources are visible inside its blocks
The recent changes to provide isolated views of the available resources
was not extended to Rspec::ExampleGroups. This ensures that
ExampleGroups have access to the same resources as the enclosing
Inspec::Rule.

Signed-off-by: Steven Danna <steve@chef.io>
2016-09-14 16:27:59 +01:00
Steven Danna
f2e587f6d5
Skip controls from profile's that don't support the current platform
Any controls included from profiles that don't support our current
platform are now marked as skipped.

Fixes #1049
2016-09-14 09:57:53 +01:00
Steven Danna
8f10ee53c5 Provide inspec.yml shortcut syntax
- Allow users to elide the `name` attributes
- Assume a default source of supermarket

Fixes #1048

Signed-off-by: Steven Danna <steve@chef.io>
2016-09-14 08:46:06 +02:00
Christoph Hartmann
9c7d06c167 use simple config for security policy resource 2016-09-12 12:20:57 +02:00
Steven Danna
b48b9edae9
Improve duplicate and cycle detection in resolver
Signed-off-by: Steven Danna <steve@chef.io>
2016-09-12 10:57:55 +01:00
Christoph Hartmann
a2143b8249 identify enabled/disabled accounts for windows 2016-09-12 11:40:25 +02:00
Steven Danna
85cbe713d7
Add GitFetcher and rework Fetchers+SourceReaders
This adds a new git fetcher. In doing so, it also refactors how the
fetchers work a bit to better support fetchers that need to resolve
user-provided sources to fully specified sources appropriate for a
lockfile.

Signed-off-by: Steven Danna <steve@chef.io>
2016-09-09 14:14:36 +01:00
Steven Danna
3777f06927
Remove some warnings during the test run 2016-09-09 14:14:36 +01:00
Christoph Hartmann
e61f71143d add unit tests 2016-09-09 12:43:03 +02:00
Christoph Hartmann
78a47aa43b improve windows implementation 2016-09-09 09:31:38 +02:00
Christoph Hartmann
94100d98b0 full implementation for filtable for linux and mac 2016-09-09 09:31:37 +02:00
Steven Danna
7e8f3f571e
Ensure simplecov starts before everything else
Before this change, simplecov was reporting

    1864 / 5198 LOC (35.86%) covered

After this change it is reporting

    4131 / 5275 LOC (78.31%) covered.

Keeping the require at the top of the file ensure that simplecov is
loaded before any of our application code.
2016-09-08 21:32:15 +01:00
Christoph Hartmann
1bd55f8cc4 allow direct access to iis configuration parameters 2016-09-07 11:19:34 +02:00
Steven Danna
74e712854e Pass attributes from command line into profile context
We broke attributes with the dependency work. Minimally fix them. TODO:
Maximally fix them.

Signed-off-by: Steven Danna <steve@chef.io>
2016-09-07 10:29:47 +02:00
Christoph Hartmann
0a34ffef5a always display error message 2016-09-05 17:23:14 +02:00
Christoph Hartmann
73f93c2756 fix powershell based unit tests 2016-09-05 13:36:48 +02:00
Christoph Hartmann
c3c648eeb9 fix integration tests for usage with winrm v2 2016-09-05 13:36:48 +02:00
Christoph Hartmann
3ddcb4c418 fix integration tests for suse 11 2016-09-05 11:22:52 +02:00
Christoph Hartmann
3346d7e1a9 support /etc/init.d directory for run level configuration 2016-09-05 11:08:21 +02:00
Steven Danna
9bb65bd60c Use per-profile execution contexts for library loading
Previously, libraries were loaded by instance_eval'ing them against
the same execution context used for control files.  All resources were
registered against a single global registry when the `name` dsl method
was invoked.  To obtain seperation of resources, we would mutate the
instance variable holding the globale registry and then change it back
at the end.

Now, we instance_eval library files inside an anonymous class.  This
class has its own version of `Inspec.resource` that returns another
class with the resource DSL method and the profile-specific resource
registry.
2016-09-04 20:55:20 +02:00
Steven Danna
5fdf659df1 Load all dependent libraries, even if include_context isn't called
The goal of these changes is to ensure that the libraries from
dependencies are loaded even if their controls are never included.  To
facilitate this, we break up the loading into seperate steps, and move
the loading code into the Profile which has acceess to the dependency
information.

Signed-off-by: Steven Danna <steve@chef.io>
2016-09-04 20:55:20 +02:00
Steven Danna
384ccb610c Initial attempt at isolating resources between dependencies
Previously, all resources were loaded into a single resource registry.
Now, each profile context has a resource registry, when a profile's
library is loaded into the profile context, we update the
profile-context-specific resource registry.  This local registry is
then used to populate the execution context that the rules are
evaluated in.

Signed-off-by: Steven Danna <steve@chef.io>
2016-09-04 20:55:20 +02:00
Christoph Hartmann
a116406b4e Merge pull request #1014 from jeremymv2/fix_apache_conf
Fix apache conf
2016-09-04 20:18:16 +02:00
Victoria Jeffrey
0667c334e9 fix inherited profile cli report for realz this time 2016-09-04 18:28:01 +02:00
Victoria Jeffrey
99ce09c4ac fix inherited profile cli report 2016-09-04 18:28:01 +02:00
Jeremy J. Miller
d5b2e4bf53 removed testing artifact 2016-09-02 22:04:06 -04:00
Jeremy J. Miller
03cb244e84 removed superflous Listen 80 2016-09-02 22:02:47 -04:00
Jeremy J. Miller
c0d105671e better description for tests 2016-09-02 22:00:12 -04:00
Jeremy J. Miller
1b92d15d8f added unit tests 2016-09-02 21:55:28 -04:00
Victoria Jeffrey
5d5aa6354d fix and add test 2016-09-01 20:39:52 -04:00
Martin Hegarty
ffee9bd2fc Fix failing unit test 2016-08-31 16:56:23 +01:00
Alex Pop
fd676ceb5c promote cmp usage as it provides results with octal mode 2016-08-30 18:23:47 +01:00
Jeremy J. Miller
3822b8ea3a one more test for good measure 2016-08-29 19:50:03 -04:00
Jeremy J. Miller
0d817017bb changed regex for integer to allow 0 2016-08-29 19:39:39 -04:00
Jeremy J. Miller
53dbaa9c3e add test 2016-08-29 15:57:46 -04:00
Steven Danna
3a6e610de9 Allow functional tests to pass on OSX
A few minor issues were causing 3 functional test failures on OS X.
These were not program errors but where rather the result of the
profiles under test assuming a linux environment.

Since many of the developers who will work on this project in the future
will be running OS X, let's ensure they can run the functional tests
easily.

Signed-off-by: Steven Danna <steve@chef.io>
2016-08-26 15:25:59 +02:00
Victoria Jeffrey
d6ee153aaa print controls, then tests. print describe block header then each test 2016-08-26 10:12:56 +02:00
Christoph Hartmann
efb2e08a16 add tests for users with sid on windows 2016-08-26 09:40:24 +02:00
Christoph Hartmann
64a5a4d082 switch from os-hardening to ssh-hardening profile 2016-08-25 14:42:55 +02:00
Steven Danna
6034ece853 Initial control isolation support
The goal of this change is to provide an isolated view of the available
profiles when the user calls the include_controls or require_controls
APIs.  Namely,

- A profile should only be able to reference profiles that are part of
  its transitive dependency tree. That is, if the dependency tree for a
  profile looks like the following:

  A
  |- B --> C
  |
  |- D --> E

  Then profile B should only be able to see profile C and fail if it
  tries to reference A, D, or E.

- The same profile should be include-able at different versions from
  different parts of the tree without conflict.  That is, if the
  dependency tree for a profile looks like the following:

  A
  |- B --> C@1.0
  |
  |- D --> C@2.0

  Then profile B should see the 1.0 version of C and profile D should
  see the 2.0 profile C with respect to the included controls.

To achieve these goals we:

- Ensure that we construct ProfileContext objects with respect to the
  correct dependencies in Inspec::DSL.

- Provide a method of accessing all transitively defined rules on a
  ProfileContext without pushing all of the rules onto the same global
  namespace.

This does not yet handle attributes or libraries.
2016-08-25 14:42:55 +02:00
Christoph Hartmann
1300900693 add unit test for local fetcher with windows path support 2016-08-24 16:23:27 +02:00
Annie Hedgpeth
fe5c7c49a4 Attempt at a bug fix to read backslashes as forward slashes in local fetcher 2016-08-24 15:11:20 +02:00
Christoph Hartmann
1989c25b2a add integration test for package resource 2016-08-24 14:40:26 +02:00
Christoph Hartmann
956d3b7292 add unit test for new package resource 2016-08-24 14:40:26 +02:00
Anirudh Gupta
4041f1898e can check windows service startup mode now 2016-08-24 02:01:10 +05:30
Kartik Null Cating-Subramanian
3415359ea2 Merge pull request #961 from chef/ssd/deps-resolver-replace
WIP: Replace Molinillo-based resolver
2016-08-23 10:52:41 -04:00
Christoph Hartmann
a381e406c4 add integration tests for file permissions on windows 2016-08-23 16:03:58 +02:00
Steven Danna
366e65b198
Add the start of tests for the Resolver class
Signed-off-by: Steven Danna <steve@chef.io>
2016-08-23 14:50:12 +01:00
Kartik Null Cating-Subramanian
039c760545 Fixup behavior and add functional tests 2016-08-23 03:07:23 +02:00
Kartik Null Cating-Subramanian
33ae22d313 Support controls and describe blocks in InSpec shell 2016-08-19 19:07:23 +02:00
Christoph Hartmann
f72fddb114 fix functional test for compliance plugin 2016-08-19 17:16:19 +02:00
Christoph Hartmann
95029203cd unique controls for dependency tests 2016-08-19 09:47:41 +02:00
Steven Danna
d779dd53ae Move all dependency related classes into inspec/dependencies
Signed-off-by: Steven Danna <steve@chef.io>
2016-08-19 09:47:40 +02:00
Steven Danna
2041a08aa2 Fetch deps based on urls
This extends the dependency feature to include support for url-based
dependencies.  It takes some deviations from the current support for
URLs that we'll likely want to make more consistent.

By default, we store downloaded archives in the cache rather than the
unpacked archive. However, to facilitate debugging, we will prefer the
unpacked archive if we find it in the cache.

Signed-off-by: Steven Danna <steve@chef.io>
2016-08-19 09:47:40 +02:00
Steven Danna
34ae3122e9 Fix recursive deps for path-based deps
Signed-off-by: Steven Danna <steve@chef.io>
2016-08-18 16:02:16 +02:00
Christoph Hartmann
1d8f8bb3e3 restructure unit tests 2016-08-18 13:47:43 +02:00
Chris Evett
3df98b7a19 add iis_site tests and refactor post code review 2016-08-17 06:57:48 -04:00
Christoph Hartmann
c23263f3d0 handle xinetd config with only one entry 2016-08-16 17:23:22 +02:00
Steven Danna
b5cd64d16a Ignore comment lines in /etc/passwd
Most passwd/shadow implementations treat lines that start with '#' as
comments. For example, the implementation in OS X:

     if (buf[0] == '#') {
          /* skip comments for Rhapsody. */
          continue;
     }

https://opensource.apple.com/source/remote_cmds/remote_cmds-41/rpc_yppasswdd.tproj/passwd.c

Fixes #725

Signed-off-by: Steven Danna <steve@chef.io>
2016-08-16 10:54:52 +02:00
Victoria Jeffrey
6f198f539b cleanup 2016-08-16 10:01:10 +02:00
Victoria Jeffrey
cf771ab967 ssh_config parse should be case insensitive 2016-08-16 10:01:10 +02:00
Dominik Richter
5f1d83f196 Merge pull request #912 from chef/ap/port-win-process
Windows ports with pid and process name
2016-08-12 20:59:28 +02:00
Alex Pop
353dcf10ec make netstat default for getting ports and get only listening ones 2016-08-12 16:02:56 +01:00
Christoph Hartmann
97a9e67181 update messages for integration tests 2016-08-12 14:51:23 +02:00
Christoph Hartmann
57bdd3464c add feature to fetch children from registry key 2016-08-12 14:51:23 +02:00
Christoph Hartmann
571bc14742 support hash params as options for registry key 2016-08-12 14:51:23 +02:00
Steven Danna
9957138909
Fix inheritance tests to account for dependency spike
Signed-off-by: Steven Danna <steve@chef.io>
2016-08-11 16:41:09 +01:00
Christoph Hartmann
92d3702043 add integration test for windows file and directory 2016-08-10 21:41:32 +02:00
Steven Danna
9346f5dd34
travis experiment: lower docker concurrency
Signed-off-by: Steven Danna <steve@chef.io>
2016-08-10 12:52:21 +01:00
Steven Danna
afddebaf3f
Add inspec env command to configure shell tab-completion
This adds a new subcommand:

   inspec env [SHELL]

which outputs a shell-appropriate completion script that the user can
source into their shell:

   eval "$(inspec env SHELL)"

Currently, we provide completions for ZSH and Bash. The completion
scripts are generated from the data Thor collects.

If the user doesn't provide SHELL we attempt to detect what the user's
shell may be using a number of methods.

Signed-off-by: Steven Danna <steve@chef.io>
2016-08-10 02:07:53 +01:00
Dominik Richter
16bd6a14d5 revert control_summary field in output
(1) The field is not yet optimal, the calculations are great!
(2) Changing this field should go together with all other breaking json changes, especially if https://github.com/chef/inspec/pull/811 results in a change.
2016-08-08 11:54:27 +02:00
Kartik Null Cating-Subramanian
470b7bb7d2 Merge pull request #860 from chef/vj/inspec-controls-count
Count controls in the summary output. Fix #852
2016-08-05 13:47:45 -04:00
Kartik Null Cating-Subramanian
8094add5b3 Test summary JSON schema 2016-08-05 13:27:30 -04:00
Steven Danna
dea19846a3
Explicitly require docker transport to avoid autoload bug
Ruby's autoload feature is not threadsafe.  We are hoping requiring the
docker plugin early will fix odd failures we have been seeing.

Signed-off-by: Steven Danna <steve@chef.io>
2016-08-05 17:58:20 +01:00
Kartik Null Cating-Subramanian
0f572df4be Fix integration test 2016-08-05 10:01:29 -04:00
Steven Danna
13ebea48e1 Allow port to be specified as a string
This allows the user to write:

   describe port(22) do
     it { should be_listening }
   end

as well as

   describe port('22') do
     it { should be_listening }
   end

without hitting an error.

Fixes #867

Signed-off-by: Steven Danna <steve@chef.io>
2016-08-05 14:01:08 +02:00
Christoph Hartmann
d9a1a500d0 add params and content method to parse_config 2016-08-05 12:13:56 +02:00
Christoph Hartmann
93a068b8fa update kitchen container, activate all in travis 2016-08-05 10:52:03 +02:00
Christoph Hartmann
1c9d998afd do not run runit and upstart in docker since chef run fails 2016-08-05 10:52:03 +02:00
Christoph Hartmann
bb5fb617d5 harmonize cookbooks for integration tests, update docs, remove i386 in vagrant 2016-08-05 10:52:03 +02:00
Steven Danna
57d7275857
Update inspec for os[:family] change in Train
Signed-off-by: Steven Danna <steve@chef.io>
2016-08-04 13:32:35 +01:00
Steven Danna
f76bc6b7b4
Be a bit louder when skipping an entire integration suite 2016-08-03 16:41:27 +01:00
Steven Danna
f30902211c Use either /dev/kcore or /dev/core in tests
In many linux distributions a link to /proc/kcore is placed at
`/dev/core`. In TravisCI we see it at `/dev/kcore`. To avoid tests
failing for some developers locally, we support either location.
2016-08-02 14:14:49 +02:00
Dominik Richter
70dd639471 move base_cli to lib/inspec
It is not a disconnected library, but a core component of inspec. Fix its location.
2016-07-26 20:11:25 +02:00
Dominik Richter
c2f34932ad add port resource for windows 2008
using `netstat -an`
2016-07-21 14:58:43 +02:00
Dominik Richter
68cf88f701 add suid sgid and sticky support for file resource 2016-07-10 23:08:42 +02:00
Dominik Richter
c6644ebdfe check service running by ActiveState
See http://unix.stackexchange.com/questions/159174/differences-between-inactive-vs-disabled-and-active-vs-enabled-services
2016-07-06 12:57:04 +02:00
Dominik Richter
5da73db6a3 api: report source location with field identifiers
Mixing types in an array without specifying what these fields point to is not just confusing, but also causes issues with endpoints that may consume this data and dont process mixed types. We strive to have a stable api for 1.0 and this is a sin that was left after the major overhaul. Time to fix it.
2016-06-28 12:03:20 +02:00
Christoph Hartmann
9bdb01f1d5 improve wmi resource 2016-06-19 23:40:45 +02:00
Christoph Hartmann
f87f25fb07 add boolean support for cmp matcher 2016-06-18 20:33:08 +02:00
Dominik Richter
8660d5d81c feedback round with @chris-rock 2016-06-16 20:37:51 +02:00
Dominik Richter
211a2e25fb align inspec detect output 2016-06-16 13:00:09 +02:00
Dominik Richter
e3b20e88b7 provide target info in cli output 2016-06-16 12:26:46 +02:00
Dominik Richter
c34fd350cf multi-profile reporting in cli formatter 2016-06-16 00:08:50 +02:00
Dominik Richter
4fbdee84cf use utf-8 characters for default cli formatter
see https://github.com/chef/inspec/issues/532
2016-06-15 19:27:56 +02:00
Stephan Renatus
0a00d21113 integer?("0300") should not be true 2016-06-15 18:34:42 +02:00
Dominik Richter
f93084520f introduce cli report formatter 2016-06-15 17:11:29 +02:00
Christoph Hartmann
f1faf47112 introduce secrets backend 2016-06-14 02:49:47 +02:00
Dominik Richter
2db8d83d56 support intra-libraries file referencing + loading
solves https://github.com/chef/inspec/issues/779
2016-06-03 22:54:35 +02:00
Dominik Richter
302a718b48 list arbitrary ports and query it
utilizing filter table to make port more flexible and useful.
2016-05-31 03:14:07 +02:00
Dominik Richter
02dae2c3c5 add simple style for filter table data
for quick flattening, filtering, and non-nil results. this also simplifies some interal calls and structure
2016-05-31 03:01:03 +02:00
Christoph Hartmann
e9ca7107b0 add tests for os resource 2016-05-31 00:01:26 +02:00
Dominik Richter
d6345ffd17 add resource to filter table blocks
i.e. get access to the original resource for more information and calls.
2016-05-30 23:31:14 +02:00
Christoph Hartmann
ba95e461d3 run integration tests in docker 2016-05-16 18:25:17 +02:00
Anirudh Gupta
4a9d9a4757 fixed 'it' statements under file_test 2016-05-16 19:24:14 +05:30
Dominik Richter
67f7a5936c catch corner-case with symbols on test-objects 2016-05-13 20:39:17 +02:00
Dominik Richter
603e3e21b3 fix construction of ruby objects on string and array handlers 2016-05-13 19:07:43 +02:00
Dominik Richter
dde4433933 use struct for processes list
we know all the fields + struct is fully compatible to the curren hash implementation
2016-05-13 11:22:56 +02:00
Christoph Hartmann
1f470971d2 Revert "Add all_match to matchers"
This reverts commit 29cf4522e4.
2016-05-11 23:47:24 +02:00
Christoph Hartmann
48d8694789 Revert "fix contain_match, add none_match"
This reverts commit 54b397f3a5.
2016-05-11 23:47:24 +02:00
Christoph Hartmann
5939e5b2f9 Merge pull request #739 from chef/ap/port-not-nil
Return empty array instead of nil for port methods
2016-05-11 23:32:43 +02:00
Alex Pop
2a9d9b5481 return empty array instead of nil to be .each friendly 2016-05-11 22:21:22 +01:00
Christoph Hartmann
03b1ecfac5 Merge pull request #735 from tpcwang/escape-windows-osenv
Escape os_env command on Windows to handle env variables containing parentheses.
2016-05-11 23:09:34 +02:00
Alex Pop
54b397f3a5 fix contain_match, add none_match
update matchers doc and add more integration tests
allow non-string data types and non-arrays
2016-05-11 12:47:36 +01:00
tpcwang
c8d2991589 Escape os_env command on Windows to handle env variables containing parentheses.
Update the mock file to match the new command
2016-05-11 01:09:06 -07:00
Christoph Hartmann
9fd9f8aa69 Merge pull request #733 from chef/vj/add-label-for-processes
Expose label for processes only on linux
2016-05-10 22:39:02 +02:00
Victoria Jeffrey
1811eb6666 Expose label for processes only on linux 2016-05-10 13:59:13 -04:00
Victoria Jeffrey
29cf4522e4 Add all_match to matchers 2016-05-10 10:00:55 -04:00
Alex Pop
9ded3b8835 Provide service params as a mash, empty unless systemd for now 2016-05-09 14:54:09 +02:00
Christoph Hartmann
d2a8ba0022 add human-readable output for detect, as well as a --format json 2016-05-09 13:24:49 +02:00
Dominik Richter
5d925b2851 api: make processes return integers for pid/vsz/rss 2016-05-06 16:49:21 +02:00
Christoph Hartmann
6e905c8162 update functional tests 2016-05-06 13:47:22 +02:00
Alex Pop
c518b9edc2 expose systemd service properties via .info 2016-05-06 13:36:42 +02:00
Christoph Hartmann
8258d111ef rename json to minijson and fulljson to json 2016-05-06 13:27:42 +02:00
Dominik Richter
b14495051a prevent duplicate profile-loading
this happens when the profile is run (exec) and also interpreted (via profile.params). It will load 2 profile context calls (both via Runner) which in turn gets 2 rounds of interpreter+runner executions. This is an issue with auto-generated IDs, due to their random component, which changes in this case
2016-05-06 13:14:40 +02:00
Dominik Richter
20d08a63b5 inspec --format [json|fulljson|rspecjson] overhaul
Full rewrite of all formatters. Create a minimal JSON, a full JSON, and a fallback RSpec formatter. The latter is only needed for corner cases and should not really be used. The former 2 are for (1) running `inspec json` followed by `inspec exec` (`--format json`) and (2) running just `inspec exec --format fulljson`.
2016-05-06 13:14:40 +02:00
Dominik Richter
a809097d12 simplify full_id generation 2016-05-06 13:14:40 +02:00
Dominik Richter
fc718267c4 extend filter table to handle soft variable lookup 2016-05-04 15:27:58 +02:00
Dominik Richter
fb91b788a6 use filtertable with passwd resource 2016-05-04 15:27:58 +02:00
Alex Pop
f78afe0d75 Use only strings in resource examples, docs and tests 2016-05-03 23:27:18 +01:00
Anirudh Gupta
738ef69bcf prefixed hpux to cmd file name 2016-05-03 21:38:39 +05:30
Anirudh Gupta
d839f218bf hpux support for basic port properties 2016-05-03 14:30:59 +05:30
Alex Pop
56d856531b support basename parameter and add tests 2016-04-29 13:40:32 -04:00
Dominik Richter
83b4dfbf4d use the source_path instead of path for file internal reporting 2016-04-28 20:11:21 -04:00
Dominik Richter
0c8e891ee1 add #entries to filter table + remodel configuration 2016-04-28 22:46:39 +02:00
Dominik Richter
048a1584b9 encapsulated filters 2016-04-28 22:46:39 +02:00
Dominik Richter
652f10ad9a use Inspec::Filter in xinetd resource 2016-04-28 22:46:39 +02:00
Dominik Richter
01caf05020 add cmd for executing calls against the inspec api 2016-04-27 06:31:01 -07:00
Christoph Hartmann
ab9f5f9c1a Merge pull request #682 from Anirudh-Gupta/hpux
Hpux
2016-04-27 06:29:05 -07:00
Anirudh Gupta
045d8c6572 added file permission by user check for hp-ux 2016-04-26 15:08:01 +05:30
Anirudh Gupta
1330e09df5 added file permission by user check for hp-ux 2016-04-26 14:53:28 +05:30
Christoph Hartmann
2242790528 Merge pull request #678 from Anirudh-Gupta/hpux
added hpux user and package resource support
2016-04-25 07:22:19 -05:00
Dominik Richter
d0760662ce bugfix: restore pax_global_header fetcher filter
The original tests were deactivated. Reactivate and fix the implementation.

TODO: verify that this matches expectations
2016-04-24 02:38:22 -04:00
Dominik Richter
bc724c81ff fix legacy supports call
as reported by Jeremy Miller and Alex Pop
2016-04-22 11:15:57 -04:00
Anirudh Gupta
75534fdaa5 added hpux user and package resource support 2016-04-21 14:01:56 +05:30
Alex Pop
34a22a290e add more cmp matcher tests 2016-04-20 11:57:31 -04:00
Dominik Richter
9da23f9cbc remodel bash and shell wrappers 2016-04-18 11:48:42 -04:00
Dominik Richter
0631779412 configure command execution shells to sh/bash/zsh 2016-04-18 01:09:37 -04:00
Thomas Cate
0f8aff0b91 added default and per kernel checking 2016-04-17 10:46:35 -04:00
Thomas Cate
3051ead64d added tests for grub_conf resource 2016-04-17 10:46:29 -04:00
Dominik Richter
2a0ccbfd76 fail on unsupported os/platform 2016-04-17 00:04:37 -04:00
Dominik Richter
f54195408f simplify key symbolization in metadata 2016-04-16 18:47:59 -04:00
Dominik Richter
14995534cd skip profiles if the platform isnt supported 2016-04-16 15:34:23 -04:00
Dominik Richter
a1188b26ce add supports_runtime? to metadata 2016-04-16 15:25:59 -04:00
Dominik Richter
5d58fa267b feature: cmp < / > / <= / >= / == / != sth matcher 2016-04-15 19:19:15 -04:00
Christoph Hartmann
3007aef248 add function tests for compliance command 2016-04-13 16:55:14 -04:00
Jacob McCann
9dbf5354e5 Add 'static' value as enabled to systemd service enabled check 2016-04-13 14:44:28 -05:00
Dominik Richter
046e6ce501 bugfix: non-profile execution with json formatter 2016-04-11 11:17:26 -04:00
Dominik Richter
fb54c4ea24 api: inspec.yml supports now adds tests w/o running
Instead of just removing all tests because of OS support, supports now acts by adding all tests to the execution context, but doesnt actually execute them. Instead tests are set to skip before they get to the actual execution context
2016-04-06 11:28:52 +02:00
Dominik Richter
c55fb0b587 prevent only_ifs from getting overwritten 2016-04-06 10:46:36 +02:00
Dominik Richter
a72fee6623 add only_if for controls 2016-04-06 10:46:36 +02:00
Dominik Richter
c73afd4c1c overhault rule/control internals
instead of keeping them as flat variables, prefix all internals with `__` to create consistency. Also add accessors on the class-level to expose these values in all rules. This way we keep all variable-names in one location and get some safety on access.
2016-04-06 10:46:36 +02:00
Dominik Richter
598e8be07f don't remove controls with only_if
instead mark them as skipped, but don't just remove them.

This also introduced a number of tests around only_if on the global level
2016-04-06 10:15:53 +02:00
Alex Pop
070c5bb0e9 update tests with 5 examples 2016-04-04 14:19:13 +01:00
Dominik Richter
2cad553de8 add advanced passwd filters (experimental) 2016-03-31 02:03:20 +02:00
Christoph Hartmann
bc3be2f302 fix functional tests 2016-03-28 01:15:48 +02:00
Christoph Hartmann
a0529075d3 add integration tests 2016-03-26 22:49:32 +01:00
Dominik Richter
ee170cc526 support --controls for json 2016-03-25 01:58:59 +01:00
Dominik Richter
17840e0299 split up functional tests 2016-03-25 01:32:03 +01:00
Christoph Hartmann
f4180780d1 document tags and refs 2016-03-25 00:58:27 +01:00
Alex Pop
53c7683ff7 update tests based on resource changes 2016-03-24 21:50:51 +01:00
Alex Pop
3c3d711dfd bugfix: fix rare inspec shell missing all resources
In some instances, when running inspec shell, you dont get any resources inside of it. i.e. `inspec shell` and then `os` will lead to

```ruby
NameError: undefined local variable or method `os' for
from (pry):1:in `add_content'
```

This is because of instance_eval loading withing the given source/line
information and not attaching to the profile context which actually has
all the resources. Fix it by making sure that inspec shell always
attaches to the profile context with resources by providing nil for
source and line information.
2016-03-24 20:37:46 +01:00
Christoph Hartmann
cd57b26bd0 wmi unit test 2016-03-20 11:53:56 +01:00
Christoph Hartmann
7e7196db77 add wmi integration tests 2016-03-20 11:53:56 +01:00
Christoph Hartmann
4c5a3ed412 add vbscript unit test 2016-03-19 19:04:31 +01:00
Christoph Hartmann
e8aa426846 add vbscript integration test 2016-03-19 19:04:31 +01:00
Christoph Hartmann
f50255486b add support for addresses in port resource 2016-03-19 11:48:14 +01:00
Dominik Richter
a9632d53d4 fix inspec shell and continuously test it 2016-03-19 09:13:23 +01:00
Christoph Hartmann
32a065239c update unit test, add integration test 2016-03-18 15:47:00 +01:00
Christoph Hartmann
1d043bfebc move kitchen integration tests to top-level 2016-03-18 11:30:54 +01:00
Christoph Hartmann
8433b55fc4 do not install postgres on ubuntu 15.10 2016-03-18 11:30:54 +01:00
Christoph Hartmann
ea085ef7c0 place empty iso in tmp directory 2016-03-18 11:30:54 +01:00
Dominik Richter
c78a7dfbde add functional tests for fulljson 2016-03-18 02:42:53 +01:00
Dominik Richter
76fe4483d4 feature: add tags and refs 2016-03-18 01:42:26 +01:00
Dominik Richter
9e6e2bd4f7 add inspec exec tests with json formatter 2016-03-18 00:29:10 +01:00
Dominik Richter
b7e438eabc add a mock fetcher 2016-03-17 23:37:09 +01:00
Dominik Richter
ca5f7b822b add tests for resource plugin 2016-03-17 15:58:20 +01:00
Dominik Richter
f7c2fa4392 functional tests for inspec detect + version + exec 2016-03-17 10:21:38 +01:00
Dominik Richter
6853284e31 validate inspec json generation 2016-03-17 10:21:38 +01:00
Dominik Richter
bfd88df27a verify that archive creates valid zip and tar files 2016-03-17 10:21:38 +01:00
Dominik Richter
0218f1f3ca feature: --output on archive 2016-03-17 10:21:38 +01:00
Dominik Richter
e3991a2025 bugfix: inspec archive with profile path for inheritance 2016-03-16 20:32:02 +01:00
Dominik Richter
26c34c3487 WIP profile check on inheritance profiles 2016-03-16 20:32:02 +01:00