Commit graph

971 commits

Author SHA1 Message Date
Christoph Hartmann
6cf8ecf304 add target helper for compliance plugin, extract API methods from CLI 2016-02-05 14:14:34 +01:00
Christoph Hartmann
0b59dab9ea initial version of compliance plugin 2016-02-05 14:13:22 +01:00
Christoph Hartmann
bab7eb1986 improve styling 2016-02-05 14:06:55 +01:00
Christoph Hartmann
589db0bcd0 add registry for cli plugins 2016-02-05 14:06:55 +01:00
Stephan Renatus
f63a8ad1d5 upstart_service: add version fallback, fix regexp
before this regexp change, a service called "running" (hello integration
tests) would always be "running" ;)
2016-02-05 13:49:18 +01:00
Christoph Hartmann
e6ff20f91e add metadata warnings in structured hash 2016-02-04 18:46:11 +01:00
Christoph Hartmann
d7cb5a9ae0 adapt unit tests 2016-02-04 18:05:40 +01:00
Christoph Hartmann
ea63a39b40 improve code style 2016-02-04 17:01:38 +01:00
Christoph Hartmann
14a3100e41 simplify result value from profile check 2016-02-04 16:47:33 +01:00
Christoph Hartmann
7e19c5eec6 fix ignore errors option use in archive method 2016-02-04 16:41:59 +01:00
Christoph Hartmann
1796c3271b generate hash output for check and use it in inspec cli 2016-02-04 16:41:14 +01:00
Christoph Hartmann
6b7e5818fb expose source location in rule 2016-02-04 16:38:57 +01:00
Christoph Hartmann
d50b634879 bugfix: fix control tests 2016-02-04 16:38:57 +01:00
Christoph Hartmann
826d059b19 optimize json logger for line delimited JSON 2016-02-04 16:38:57 +01:00
Christoph Hartmann
907a4e1f33 add json stream logger for inspec check 2016-02-04 16:38:57 +01:00
Dominik Richter
ecb78e3a19 establish plugin loading dock 2016-02-04 14:43:51 +01:00
Stephan Renatus
e8c7452acf Inspec::Profile: document that it always reads with ignore_supports 2016-02-03 16:47:52 +01:00
Stephan Renatus
828d6ad443 Inspec::Profile fix @metadata 2016-02-03 16:47:49 +01:00
Stephan Renatus
cc60fa1e23 tar/zip: return empty-string if an entry is empty; zip: return ref 2016-02-03 14:38:46 +01:00
Stephan Renatus
1510f330a9 read and return metadata from archives, too
Note that this adds `ref: some/where/in/tarball/file` to the file
contents hash; it wasn't there before but it may be useful for error
reporting nonetheless.
2016-02-03 14:38:46 +01:00
Stephan Renatus
f335865377 WIP: kill all the checks that fail with tarballs.
current output:

    $ inspec check test/unit/mock/profiles/complete-profile.tgz
    I, [2016-02-03T10:22:21.377650 #13207]  INFO -- : Checking profile in test/unit/mock/profiles/complete-profile.tgz
    I, [2016-02-03T10:22:21.377745 #13207]  INFO -- : Found 1 rules.
    I, [2016-02-03T10:22:21.377771 #13207]  INFO -- : Rule definitions OK.
2016-02-03 14:38:46 +01:00
Stephan Renatus
889be88543 remove stray require 2016-02-03 14:04:55 +01:00
Stephan Renatus
79d171fb2c rubocop 2016-02-03 14:04:55 +01:00
Stephan Renatus
45f0cbff03 inspec/rspec: decouple reporting and formatting
If reporting is requested, register a "reporting formatter", i.e.,
Inspec::RSpecReporter, that does the same things JsonFormatter does, but
suppresses output.

When the report is then requested, it returns the output hash that
JsonFormatter aggregates.
2016-02-03 14:04:55 +01:00
Stephan Renatus
6789e089d7 Inspec::Runner: provide a report 2016-02-03 14:04:55 +01:00
Stephan Renatus
ff682532cf fix warning in #find_files[_or_error] 2016-02-01 16:32:47 +01:00
Dominik Richter
34bc94d13f mock resource operating systems for tests 2016-01-29 21:55:08 +01:00
Dominik Richter
4c1b6f7509 remove os check exposure in file resource 2016-01-29 21:55:08 +01:00
Christoph Hartmann
9cfc69cf15 0.9.11 2016-01-29 18:34:12 +01:00
Stephan Renatus
6fbd28c2bb runit_service: fix resource, improve integration tests
Turns out using `/usr/bin/yes` to imitate a daemon process is a TERRIBLE idea.
2016-01-29 17:03:05 +01:00
Christoph Hartmann
317b0cae9d lint check in user resource 2016-01-28 21:11:13 +01:00
Christoph Hartmann
6ccfbe5e95 bugfix: use freebsd netstat parser instead of linux netstat parser for solaris 2016-01-28 21:08:52 +01:00
Christoph Hartmann
35899ebce6 optimize style in user resource 2016-01-28 18:30:39 +01:00
Christoph Hartmann
202190ea56 fix user resource unit test 2016-01-28 18:30:39 +01:00
Christoph Hartmann
ef3dbbb35c improvement: make port parsing on solaris more reliable 2016-01-28 18:30:38 +01:00
Christoph Hartmann
678ee2b473 parse port information on solaris 10 and 11 via netstat 2016-01-28 18:30:38 +01:00
Christoph Hartmann
59f3214817 use id -a for solaris 2016-01-28 18:30:38 +01:00
Christoph Hartmann
bd1e5e4085 service resource for solaris 10 and 11 2016-01-28 18:30:38 +01:00
Christoph Hartmann
913191fb9e package resource for solaris 10 and 11 2016-01-28 18:30:38 +01:00
Christoph Hartmann
dd59dd9a5a use os.linux and os.windows where possible 2016-01-28 18:30:38 +01:00
Christoph Hartmann
a5f526b368 use freebsd file permission checks for solaris 2016-01-28 18:30:38 +01:00
Christoph Hartmann
2fd6aea357 extend etc_group support for all unix systems 2016-01-28 18:30:38 +01:00
Christoph Hartmann
058ec27d64 0.9.10 2016-01-25 17:45:43 +01:00
Stephan Renatus
56f22a1d2a resource/postgres_session: add integration tests, change error handling
this makes it work (tested with default-ubuntu-1404), but doesn't
improve the error handling (i.e., the skip_resource doesn't really
prevent the failure)
2016-01-25 16:44:53 +01:00
Stephan Renatus
9821c4c754 resource/launchd_service: correctly match non-running services 2016-01-25 16:29:08 +01:00
Christoph Hartmann
5506319ad8 Merge pull request #389 from chef/dr/write-id-to-json
bugfix: write given ID to metadata json
2016-01-25 07:22:19 -08:00
Dominik Richter
88d2b26387 bugfix: write given ID to metadata json
Whenever the user provides an ID under which the profile is scoped, write it out to JSON during generation.
2016-01-25 15:48:56 +01:00
Christoph Hartmann
cc0db43813 optimize the error output for missing registry keys to nil 2016-01-25 13:55:47 +01:00
Christoph Hartmann
b30720f926 Merge pull request #380 from chef/sr/service-override
add service overrides for picking specific service managers, add runit_service
2016-01-21 13:35:23 +01:00
Stephan Renatus
ef77e01229 service resources: fix service_ctl default/override handling 2016-01-21 11:35:34 +01:00
Dominik Richter
d10207caca warn about legacy supports fields in metadata
I.e.: Prevent users from writing `supports: linux` and similar. These are deprecated and will be removed. Also improve the warning to indicate what the user should do instead. Finally add tests to make sure we get all these.
2016-01-21 11:05:26 +01:00
Stephan Renatus
492c7f8146 runit_service: cleanup; fix "non-running-runit-service" test + recipe 2016-01-21 09:05:29 +01:00
Stephan Renatus
c761b8b40d service resources: further simplifications, debian/centos handling
I've recovered the debian/centos special handling of the `service`
binary, although I doubt that it's necessary.
2016-01-21 08:22:04 +01:00
Dominik Richter
cac102aeac add profile tests (non-legacy) 2016-01-20 21:57:23 +01:00
Stephan Renatus
3f39b35502 add runit_service resource, fix service_ctl handling 2016-01-20 17:54:16 +01:00
Stephan Renatus
709e4ca9e0 some code simplifications 2016-01-20 16:05:20 +01:00
Stephan Renatus
0e410df69d add *_service overrides, allowing for different control binaries 2016-01-20 15:33:18 +01:00
Dominik Richter
20b138778e bugfix: expose tests for docker unit-tests 2016-01-19 15:48:06 +01:00
Dominik Richter
c713a0af87 lint 2016-01-19 15:48:06 +01:00
Dominik Richter
22c6fa871d add code docs to rspec runner 2016-01-19 15:48:06 +01:00
Dominik Richter
611487e956 clearly identify legacy profile tests and fix identification 2016-01-19 15:48:06 +01:00
Dominik Richter
8c464965c1 extract example group creation
and restore profile tests that had been completely mocked until now
2016-01-19 15:48:06 +01:00
Dominik Richter
dd2d93fd6f completely separate rspec runner parts 2016-01-19 15:48:06 +01:00
Dominik Richter
21a92a0c4e isolate rspec-dsl in profile context 2016-01-19 15:48:06 +01:00
Dominik Richter
b991dd03bb flatten creation of profile context 2016-01-19 15:48:06 +01:00
Dominik Richter
21d9ae7e1d move resource dsl creation to resource plugin 2016-01-19 15:48:06 +01:00
Jason Reed
1807c688b8 Fix typo 2016-01-19 09:07:24 -05:00
Dominik Richter
b0ffe684ab freeze those versions 2016-01-15 21:41:20 +01:00
Christoph Hartmann
e9b94d55d1 0.9.9 2016-01-15 15:20:04 -05:00
Dominik Richter
acbc345321 make metadata.rb legacy mode consistent for supports
Before introducing InSpec profiles in https://github.com/chef/inspec/pull/252 we had `metadata.rb` keep all information. This included an undisclosed field called `supports`. However, this field was never actually used in practice. So for legacy profiles, this means that `supports` was ignored. In order to keep old profiles running in exactly the way they were before, ignore this field when reading from metadata.rb
2016-01-15 18:58:18 +01:00
Christoph Hartmann
b9978b5606 new rubocop fixes 2016-01-14 23:15:10 -05:00
Christoph Hartmann
46d85c2cbc fail test if lsof is not available 2016-01-14 23:03:51 -05:00
Jeremy W. Chalfant
9e40e6d9f3 my rubocop is different 2016-01-14 23:03:26 -05:00
Jeremy W. Chalfant
0681562fcd rubocop is nuts 2016-01-14 23:03:26 -05:00
Jeremy W. Chalfant
98a7e6303e fix remaining rubocop complaints 2016-01-14 23:03:26 -05:00
Jeremy W. Chalfant
2fc8ba1b83 fix lint complaint 2016-01-14 23:03:26 -05:00
Jeremy W. Chalfant
2d8c892298 use formmated lsof output to ensure accuracy and consistency across platforms 2016-01-14 23:03:26 -05:00
Jeremy W. Chalfant
adbc5b8ef4 sanity check and AIX tests 2016-01-14 23:03:26 -05:00
Jeremy W. Chalfant
2e7ab9bad7 fix rubocop complaint 2016-01-14 23:03:25 -05:00
Jeremy W. Chalfant
388937e9b4 add aix user support 2016-01-14 23:03:25 -05:00
Jeremy W. Chalfant
3b87e385d7 my rubocop is different 2016-01-14 23:03:25 -05:00
Jeremy W. Chalfant
6cd801fbb9 rubocop is nuts 2016-01-14 23:03:25 -05:00
Jeremy W. Chalfant
94a286929f fix remaining rubocop complaints 2016-01-14 23:03:25 -05:00
Jeremy W. Chalfant
420aef7cb9 fix lint complaint 2016-01-14 23:03:25 -05:00
Jeremy W. Chalfant
c8c676e1d6 use formmated lsof output to ensure accuracy and consistency across platforms 2016-01-14 23:03:25 -05:00
Jeremy W. Chalfant
f31a9f35b5 sanity check and AIX tests 2016-01-14 23:03:25 -05:00
Jeremy W. Chalfant
5a6b1bbddf fix rubocop complaint 2016-01-14 23:03:25 -05:00
Jeremy W. Chalfant
fbe79d1bc4 add aix user support 2016-01-14 23:03:25 -05:00
Jeremy W. Chalfant
b167854c18 my rubocop is different 2016-01-14 23:03:25 -05:00
Jeremy W. Chalfant
bbed0e7164 rubocop is nuts 2016-01-14 23:03:25 -05:00
Jeremy W. Chalfant
88656c9ea8 fix remaining rubocop complaints 2016-01-14 23:03:25 -05:00
Jeremy W. Chalfant
2aceba417c fix lint complaint 2016-01-14 23:03:25 -05:00
Jeremy W. Chalfant
d5a7bad414 superflous chomp 2016-01-14 23:03:25 -05:00
Jeremy W. Chalfant
b6649dd581 use formmated lsof output to ensure accuracy and consistency across platforms 2016-01-14 23:03:24 -05:00
Jeremy W. Chalfant
55d7faec8a sanity check and AIX tests 2016-01-14 23:03:24 -05:00
Jeremy W. Chalfant
a0bbb175c2 AIX packages 2016-01-14 23:03:24 -05:00
Jeremy W. Chalfant
1d99afe623 fix rubocop complaint 2016-01-14 23:03:24 -05:00
Jeremy W. Chalfant
3168e4d100 add aix user support 2016-01-14 23:03:24 -05:00
Jeremy W. Chalfant
d51d86e6d8 disable cops 2016-01-14 23:03:24 -05:00
Jeremy W. Chalfant
6bdb06fbe9 move lsof parsing to seperate method 2016-01-14 23:03:24 -05:00
Jeremy W. Chalfant
c982daaf6e my rubocop is different 2016-01-14 23:03:24 -05:00
Jeremy W. Chalfant
3211071b9f simplify lsof call 2016-01-14 23:03:24 -05:00
Jeremy W. Chalfant
221d27423e rubocop is nuts 2016-01-14 23:03:24 -05:00
Jeremy W. Chalfant
f817840d38 fix remaining rubocop complaints 2016-01-14 23:03:24 -05:00
Jeremy W. Chalfant
3a90ea3a74 fix lint complaint 2016-01-14 23:03:23 -05:00
Jeremy W. Chalfant
2c5cb06990 superflous chomp 2016-01-14 23:03:23 -05:00
Jeremy W. Chalfant
b9ce468886 add AIX service support 2016-01-14 23:03:23 -05:00
Jeremy W. Chalfant
d855602efe use formmated lsof output to ensure accuracy and consistency across platforms 2016-01-14 23:03:23 -05:00
Jeremy W. Chalfant
aef7f6de39 sanity check and AIX tests 2016-01-14 23:00:10 -05:00
Jeremy W. Chalfant
bc503f080d rename etc_group to etc_group_spec and etc_group test success on AIX 2016-01-14 23:00:10 -05:00
Jeremy W. Chalfant
db43739951 AIX packages 2016-01-14 23:00:10 -05:00
Jeremy W. Chalfant
506b0ea996 fix rubocop complaint 2016-01-14 23:00:10 -05:00
Jeremy W. Chalfant
26afecf857 add aix user support 2016-01-14 23:00:09 -05:00
Mark Harrison
f5780b69a4 Correctly detect UDP ports on linux
netstat on UDP lines doesn't display a port state (e.g. LISTEN), so make this
field optional when parsing the netstat line.
2016-01-14 22:53:38 -05:00
Christoph Hartmann
454a7e466d bugfix: only skip regkey if required 2016-01-14 22:39:17 -05:00
Dominik Richter
375f65c903 casecmp == 0 if both entries are the same 2016-01-15 04:18:48 +01:00
Dominik Richter
4092691a78 lint 2016-01-15 04:07:25 +01:00
Stephan Renatus
5c17f8b643 regexp github url targets, add tests for Inspec::Targests::UrlHelper
replacing occuring http:// with https:// is probably ok, github
redirects to https anyways
2016-01-14 12:05:58 -05:00
Jacob McCann
f25ab3a373 Fix systemd service enabled check 2016-01-11 15:32:33 -06:00
Christoph Hartmann
ab88c23ab6 0.9.8 2016-01-11 12:48:36 -05:00
Stephan Renatus
ee62499fc0 bugfix: ignore supports when generating a profile's json representation
without this, `inspec json PATH` does never contain rules != {}, because
of the usage of the mock backend
2016-01-11 09:16:06 +01:00
Christoph Hartmann
a1ddbe4cf2 explicitly ignore supports for inspec check 2016-01-10 23:59:57 -05:00
Stephan Renatus
a26dbe146d fix reading profiles bug
For reading the profiles metadata, we're using the train mock backend
through Inspec::Runner. The new `supports` feature never agrees with the
mock backend.

Now, it we figure out if this is a mock class and then just say that it
supports whatever we're asking for.

Tl;dr: there's probably a more beautiful solution to this.

Added a test case, but it fails -- while the command line interface
works fine.
2016-01-07 15:16:49 -08:00
Stephan Renatus
3ce8cd7d16 support old "supports" field in metadata
current compliance-profiles still have

```yaml
supports:
  - linux
```

and we might want to be a little backwards compatible, too.
2016-01-05 22:50:56 +01:00
Dominik Richter
26c0cd0871 lint 2016-01-03 09:49:40 +01:00
Dominik Richter
8953278204 unfortunately Enumerator#last is not supported 2016-01-03 09:40:17 +01:00
Christoph Hartmann
e1d7d30919 add deprecation warning for serverspec users 2016-01-03 00:03:24 +01:00
Christoph Hartmann
a72ba94f10 handle mount results with multiple entries 2016-01-03 00:03:24 +01:00
Christoph Hartmann
9930773f37 restrict mount functionality to linux 2016-01-03 00:03:24 +01:00
Christoph Hartmann
a5acb03e49 add mount resource 2016-01-03 00:03:24 +01:00
Christoph Hartmann
772df929f6 implement be_mounted.with for file resources 2016-01-03 00:03:24 +01:00
Christoph Hartmann
19ed6be39f more fine-grained utils parser 2016-01-02 22:41:58 +01:00
Christoph Hartmann
3be9ea18cc use 1.8 syntax for dash key values to be compatible with older ruby versions 2016-01-02 22:29:31 +01:00
Christoph Hartmann
c11c36058a separate os check 2016-01-02 21:25:22 +01:00
Dominik Richter
d6f48d3534 catch empty support clause 2015-12-31 17:57:59 +01:00
Dominik Richter
af8e4e93ca add supports keyword to profiles 2015-12-31 17:54:13 +01:00
Dominik Richter
2e0da6e9e8 unify metadata resolution 2015-12-31 12:49:18 +01:00
Dominik Richter
3db2dd756d resolve metadata from profile targets 2015-12-31 12:49:18 +01:00
Dominik Richter
e7b7f166cf dry folder resolver 2015-12-31 12:49:18 +01:00
Dominik Richter
96c9794cbf bugfix: reload inspec DSL after loading libraries 2015-12-29 19:27:00 +01:00
Dominik Richter
526932584d fix metadata validation 2015-12-28 13:35:38 +01:00
Dominik Richter
cfa2b9a39c fix metadata reading and parsing 2015-12-28 13:16:09 +01:00
Dominik Richter
cdc95df5ca keep metadata checks in metadata.rb 2015-12-28 13:07:21 +01:00
Dominik Richter
aef0cabde8 fix method length in inspec.check 2015-12-28 13:01:27 +01:00
Christoph Hartmann
0ab46ff5b1 rename metadata.yml to inspec.yml 2015-12-28 12:53:42 +01:00
Christoph Hartmann
1d4295ee4d remove owner/name restriction 2015-12-28 12:53:42 +01:00
Christoph Hartmann
06c1265b38 add support for .tgz extension. Thanks @srenatus 2015-12-28 12:53:42 +01:00
Christoph Hartmann
31c8509092 lint profile implementation 2015-12-28 12:53:42 +01:00
Christoph Hartmann
27150e5341 feature: generate profile archive 2015-12-28 12:53:42 +01:00
Christoph Hartmann
9da0e32f3d bugfix: only add path to load path if the test is located on filesystem 2015-12-28 12:53:42 +01:00