inspec 1.9.0 → 1.10.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1f94253412c3c460db42fc5f03154c96a51a4c7b
4
- data.tar.gz: 460e9aa3231989faa7af89b29cc51d4f2a518eb0
3
+ metadata.gz: f9d96ad2cb03fa0071dad1bfb2c2409af0555584
4
+ data.tar.gz: 9e4f11747702ebad75c867b4bea1befa2f9c611a
5
5
  SHA512:
6
- metadata.gz: cb44eed7117103ec33fb7ed1f69f236637798124533f1daa2fc0039f86871599d47d1e67506abd904ab3915cb9a6f8078caafdb78465da9ad6c4845f311a08ab
7
- data.tar.gz: c10829d5c72a263cbf7794a2e8617a5aae54765de056226604527d3a5dd1217b04006f449da51b11325f2113b4949ca12dc6f6c70b887facc0e935e317aa1ad7
6
+ metadata.gz: 9823737855e6322463707930f5dc977a4cbd44373c765e336ef2690fa49077197670aea0f1a4d31bc8e0bbfccb90788a55e0833a8843ae5b4a33622292c163e0
7
+ data.tar.gz: 918ecce5051aa29d57aa6b158bacc20fd3c47f41af6389a14c4c1f3d300f03f0e95b82538647074cf6a0cbd9e7943d81500965a040f107789199e9aa7218ee6c
data/CHANGELOG.md CHANGED
@@ -1,7 +1,34 @@
1
1
  # Change Log
2
2
 
3
- ## [1.9.0](https://github.com/chef/inspec/tree/1.9.0) (2017-01-06)
4
- [Full Changelog](https://github.com/chef/inspec/compare/v1.8.0...1.9.0)
3
+ ## [1.10.0](https://github.com/chef/inspec/tree/1.10.0) (2017-01-26)
4
+ [Full Changelog](https://github.com/chef/inspec/compare/v1.9.0...1.10.0)
5
+
6
+ **Implemented enhancements:**
7
+
8
+ - HTTP request resource [\#336](https://github.com/chef/inspec/issues/336)
9
+
10
+ **Closed issues:**
11
+
12
+ - fix functional tests [\#1429](https://github.com/chef/inspec/issues/1429)
13
+
14
+ **Merged pull requests:**
15
+
16
+ - improve http header handling [\#1432](https://github.com/chef/inspec/pull/1432) ([chris-rock](https://github.com/chris-rock))
17
+ - use new devsec baseline [\#1431](https://github.com/chef/inspec/pull/1431) ([chris-rock](https://github.com/chris-rock))
18
+ - 'execution' is spelled correctly [\#1428](https://github.com/chef/inspec/pull/1428) ([nathenharvey](https://github.com/nathenharvey))
19
+ - Bug fixes + New Elements [\#1426](https://github.com/chef/inspec/pull/1426) ([hannah-radish](https://github.com/hannah-radish))
20
+ - Docs: fix resource name \('processes' instead of 'process'\) [\#1423](https://github.com/chef/inspec/pull/1423) ([techraf](https://github.com/techraf))
21
+ - update copyright of the year [\#1422](https://github.com/chef/inspec/pull/1422) ([chris-rock](https://github.com/chris-rock))
22
+ - Link to the 1.0 release webinar [\#1419](https://github.com/chef/inspec/pull/1419) ([nathenharvey](https://github.com/nathenharvey))
23
+ - Updated compliance api requests to actually use refresh token correctly [\#1416](https://github.com/chef/inspec/pull/1416) ([brentm5](https://github.com/brentm5))
24
+ - Docs examples: use double quotes to prevent escaping backslash in the expected string [\#1413](https://github.com/chef/inspec/pull/1413) ([techraf](https://github.com/techraf))
25
+ - Fixed error in OS docs, added CentOS to redhat family docs. [\#1407](https://github.com/chef/inspec/pull/1407) ([gscho](https://github.com/gscho))
26
+ - Solicit talks for ChefConf [\#1405](https://github.com/chef/inspec/pull/1405) ([nathenharvey](https://github.com/nathenharvey))
27
+ - Add an http test method [\#1403](https://github.com/chef/inspec/pull/1403) ([guilhem](https://github.com/guilhem))
28
+ - new inspec.io frontpage [\#1362](https://github.com/chef/inspec/pull/1362) ([hannah-radish](https://github.com/hannah-radish))
29
+
30
+ ## [v1.9.0](https://github.com/chef/inspec/tree/v1.9.0) (2017-01-06)
31
+ [Full Changelog](https://github.com/chef/inspec/compare/v1.8.0...v1.9.0)
5
32
 
6
33
  **Implemented enhancements:**
7
34
 
@@ -2001,19 +2028,10 @@
2001
2028
 
2002
2029
  **Implemented enhancements:**
2003
2030
 
2004
- - pretty-print resources [\#78](https://github.com/chef/inspec/issues/78)
2005
- - Add networking resources [\#68](https://github.com/chef/inspec/issues/68)
2006
2031
  - Add WinRM transport layer [\#64](https://github.com/chef/inspec/issues/64)
2007
2032
 
2008
- **Fixed bugs:**
2009
-
2010
- - expose all necessary methods in OS resource [\#79](https://github.com/chef/inspec/issues/79)
2011
-
2012
2033
  **Closed issues:**
2013
2034
 
2014
- - script resource [\#74](https://github.com/chef/inspec/issues/74)
2015
- - add project docs [\#72](https://github.com/chef/inspec/issues/72)
2016
- - OS detection on debian does not detect versions [\#39](https://github.com/chef/inspec/issues/39)
2017
2035
  - ensure all resources have a proper to\_s method [\#98](https://github.com/chef/inspec/issues/98)
2018
2036
  - Escape commands before we execute them [\#70](https://github.com/chef/inspec/issues/70)
2019
2037
 
@@ -2040,90 +2058,6 @@
2040
2058
  - Improve unit tests [\#106](https://github.com/chef/inspec/pull/106) ([chris-rock](https://github.com/chris-rock))
2041
2059
  - add to\_s methods to resources, fixes \#98 [\#105](https://github.com/chef/inspec/pull/105) ([chris-rock](https://github.com/chris-rock))
2042
2060
  - 0.7.0 release [\#104](https://github.com/chef/inspec/pull/104) ([chris-rock](https://github.com/chris-rock))
2043
- - implement iptables resource [\#103](https://github.com/chef/inspec/pull/103) ([chris-rock](https://github.com/chris-rock))
2044
- - bugfix: return function if data is already cached [\#102](https://github.com/chef/inspec/pull/102) ([chris-rock](https://github.com/chris-rock))
2045
- - implement apt resource [\#101](https://github.com/chef/inspec/pull/101) ([chris-rock](https://github.com/chris-rock))
2046
- - improve shell [\#100](https://github.com/chef/inspec/pull/100) ([chris-rock](https://github.com/chris-rock))
2047
- - implement host resource [\#99](https://github.com/chef/inspec/pull/99) ([chris-rock](https://github.com/chris-rock))
2048
- - implement bridge resource [\#97](https://github.com/chef/inspec/pull/97) ([chris-rock](https://github.com/chris-rock))
2049
- - interactive shell [\#95](https://github.com/chef/inspec/pull/95) ([arlimus](https://github.com/arlimus))
2050
- - interface resource [\#94](https://github.com/chef/inspec/pull/94) ([chris-rock](https://github.com/chris-rock))
2051
- - lint: dont use undefined vars [\#93](https://github.com/chef/inspec/pull/93) ([arlimus](https://github.com/arlimus))
2052
- - fix delivery dependencies [\#92](https://github.com/chef/inspec/pull/92) ([arlimus](https://github.com/arlimus))
2053
- - improvement: add default print method to resources [\#91](https://github.com/chef/inspec/pull/91) ([arlimus](https://github.com/arlimus))
2054
- - extend os backend helper [\#90](https://github.com/chef/inspec/pull/90) ([chris-rock](https://github.com/chris-rock))
2055
- - integrate docs [\#89](https://github.com/chef/inspec/pull/89) ([chris-rock](https://github.com/chris-rock))
2056
- - integrate docs [\#88](https://github.com/chef/inspec/pull/88) ([chris-rock](https://github.com/chris-rock))
2057
- - script resource [\#87](https://github.com/chef/inspec/pull/87) ([chris-rock](https://github.com/chris-rock))
2058
- - implement group resource [\#85](https://github.com/chef/inspec/pull/85) ([chris-rock](https://github.com/chris-rock))
2059
- - add author header [\#84](https://github.com/chef/inspec/pull/84) ([chris-rock](https://github.com/chris-rock))
2060
- - Resource bugfix [\#83](https://github.com/chef/inspec/pull/83) ([arlimus](https://github.com/arlimus))
2061
- - Resource in resource [\#80](https://github.com/chef/inspec/pull/80) ([arlimus](https://github.com/arlimus))
2062
- - ignore local delivery config [\#77](https://github.com/chef/inspec/pull/77) ([arlimus](https://github.com/arlimus))
2063
- - bugfix user resource for windows [\#76](https://github.com/chef/inspec/pull/76) ([chris-rock](https://github.com/chris-rock))
2064
- - activate lint in travis [\#75](https://github.com/chef/inspec/pull/75) ([arlimus](https://github.com/arlimus))
2065
- - Simplify SSL configuration [\#69](https://github.com/chef/inspec/pull/69) ([arlimus](https://github.com/arlimus))
2066
- - implement user resource [\#67](https://github.com/chef/inspec/pull/67) ([chris-rock](https://github.com/chris-rock))
2067
- - switch from open4 -\> mixlib-shellout [\#66](https://github.com/chef/inspec/pull/66) ([arlimus](https://github.com/arlimus))
2068
- - WinRM path [\#63](https://github.com/chef/inspec/pull/63) ([arlimus](https://github.com/arlimus))
2069
- - bugfix: catch cases where oneget returns an array [\#62](https://github.com/chef/inspec/pull/62) ([chris-rock](https://github.com/chris-rock))
2070
- - extend delivery tests to extra docker images [\#61](https://github.com/chef/inspec/pull/61) ([arlimus](https://github.com/arlimus))
2071
- - rename --key-file to --key on cli [\#60](https://github.com/chef/inspec/pull/60) ([arlimus](https://github.com/arlimus))
2072
- - Simpleconfig groups [\#57](https://github.com/chef/inspec/pull/57) ([arlimus](https://github.com/arlimus))
2073
- - OS detection tests [\#56](https://github.com/chef/inspec/pull/56) ([arlimus](https://github.com/arlimus))
2074
- - Start Linting remaining resources [\#55](https://github.com/chef/inspec/pull/55) ([arlimus](https://github.com/arlimus))
2075
- - fix various robocop lint issues [\#54](https://github.com/chef/inspec/pull/54) ([chris-rock](https://github.com/chris-rock))
2076
- - overhaul rule structure [\#53](https://github.com/chef/inspec/pull/53) ([arlimus](https://github.com/arlimus))
2077
- - Verify ssh transport backend [\#51](https://github.com/chef/inspec/pull/51) ([arlimus](https://github.com/arlimus))
2078
- - Unit test for service resource [\#50](https://github.com/chef/inspec/pull/50) ([chris-rock](https://github.com/chris-rock))
2079
- - Ssh backend tests [\#49](https://github.com/chef/inspec/pull/49) ([arlimus](https://github.com/arlimus))
2080
- - Docker concurrency [\#48](https://github.com/chef/inspec/pull/48) ([arlimus](https://github.com/arlimus))
2081
- - unit tests for package resource [\#47](https://github.com/chef/inspec/pull/47) ([chris-rock](https://github.com/chris-rock))
2082
- - Docker runner test [\#46](https://github.com/chef/inspec/pull/46) ([arlimus](https://github.com/arlimus))
2083
- - add port resource [\#45](https://github.com/chef/inspec/pull/45) ([chris-rock](https://github.com/chris-rock))
2084
- - bugfix: windows server 2008 detection [\#44](https://github.com/chef/inspec/pull/44) ([arlimus](https://github.com/arlimus))
2085
- - Add detect command [\#43](https://github.com/chef/inspec/pull/43) ([arlimus](https://github.com/arlimus))
2086
- - unit test mock os [\#42](https://github.com/chef/inspec/pull/42) ([chris-rock](https://github.com/chris-rock))
2087
- - let travis do dockerized resource tests [\#41](https://github.com/chef/inspec/pull/41) ([arlimus](https://github.com/arlimus))
2088
- - docker test run [\#40](https://github.com/chef/inspec/pull/40) ([arlimus](https://github.com/arlimus))
2089
- - bugfix: detect os via unames [\#38](https://github.com/chef/inspec/pull/38) ([arlimus](https://github.com/arlimus))
2090
- - run kitchen test instead of converge [\#37](https://github.com/chef/inspec/pull/37) ([arlimus](https://github.com/arlimus))
2091
- - bugfix: local file owner [\#36](https://github.com/chef/inspec/pull/36) ([arlimus](https://github.com/arlimus))
2092
- - bugfix: backend description for local + docker [\#35](https://github.com/chef/inspec/pull/35) ([arlimus](https://github.com/arlimus))
2093
- - implement fake os method for mock backend \(for now\) [\#34](https://github.com/chef/inspec/pull/34) ([chris-rock](https://github.com/chris-rock))
2094
- - add Windows feature resource [\#33](https://github.com/chef/inspec/pull/33) ([chris-rock](https://github.com/chris-rock))
2095
- - add linux kernel resources [\#32](https://github.com/chef/inspec/pull/32) ([chris-rock](https://github.com/chris-rock))
2096
- - Exist vs exists [\#31](https://github.com/chef/inspec/pull/31) ([arlimus](https://github.com/arlimus))
2097
- - File formats [\#30](https://github.com/chef/inspec/pull/30) ([chris-rock](https://github.com/chris-rock))
2098
- - OS detection and resource [\#29](https://github.com/chef/inspec/pull/29) ([arlimus](https://github.com/arlimus))
2099
- - bugfix: fix simplified runner configuration [\#28](https://github.com/chef/inspec/pull/28) ([chris-rock](https://github.com/chris-rock))
2100
- - improvement: simplify runner configuration [\#27](https://github.com/chef/inspec/pull/27) ([arlimus](https://github.com/arlimus))
2101
- - bugfix: catch cases, where no service is available [\#26](https://github.com/chef/inspec/pull/26) ([chris-rock](https://github.com/chris-rock))
2102
- - support package for windows [\#25](https://github.com/chef/inspec/pull/25) ([chris-rock](https://github.com/chris-rock))
2103
- - implement service for FreeBSD [\#24](https://github.com/chef/inspec/pull/24) ([chris-rock](https://github.com/chris-rock))
2104
- - move integration dependencies to Gemfile [\#23](https://github.com/chef/inspec/pull/23) ([chris-rock](https://github.com/chris-rock))
2105
- - add oracle linux docker tests [\#22](https://github.com/chef/inspec/pull/22) ([arlimus](https://github.com/arlimus))
2106
- - Support FreeBSD [\#21](https://github.com/chef/inspec/pull/21) ([arlimus](https://github.com/arlimus))
2107
- - Service resource [\#20](https://github.com/chef/inspec/pull/20) ([chris-rock](https://github.com/chris-rock))
2108
- - Improvements [\#19](https://github.com/chef/inspec/pull/19) ([chris-rock](https://github.com/chris-rock))
2109
- - bugfix: set host for ssh config in specinfra [\#18](https://github.com/chef/inspec/pull/18) ([chris-rock](https://github.com/chris-rock))
2110
- - improve readme [\#17](https://github.com/chef/inspec/pull/17) ([chris-rock](https://github.com/chris-rock))
2111
- - Integration tests for the backend runner [\#16](https://github.com/chef/inspec/pull/16) ([arlimus](https://github.com/arlimus))
2112
- - Fix specinfra OS detection [\#15](https://github.com/chef/inspec/pull/15) ([arlimus](https://github.com/arlimus))
2113
- - Os detection [\#14](https://github.com/chef/inspec/pull/14) ([chris-rock](https://github.com/chris-rock))
2114
- - bugfix: require specinfra backend [\#13](https://github.com/chef/inspec/pull/13) ([chris-rock](https://github.com/chris-rock))
2115
- - improve docker test runner structure [\#12](https://github.com/chef/inspec/pull/12) ([arlimus](https://github.com/arlimus))
2116
- - Concurrent integrationtest [\#11](https://github.com/chef/inspec/pull/11) ([arlimus](https://github.com/arlimus))
2117
- - add oneget resource [\#10](https://github.com/chef/inspec/pull/10) ([chris-rock](https://github.com/chris-rock))
2118
- - Winrm [\#9](https://github.com/chef/inspec/pull/9) ([chris-rock](https://github.com/chris-rock))
2119
- - bugfix: linux file stat parameters and mount [\#8](https://github.com/chef/inspec/pull/8) ([arlimus](https://github.com/arlimus))
2120
- - Mysql conf [\#7](https://github.com/chef/inspec/pull/7) ([arlimus](https://github.com/arlimus))
2121
- - Lint update [\#6](https://github.com/chef/inspec/pull/6) ([arlimus](https://github.com/arlimus))
2122
- - SSH PTY [\#5](https://github.com/chef/inspec/pull/5) ([arlimus](https://github.com/arlimus))
2123
- - Start Docker + SSH backends [\#4](https://github.com/chef/inspec/pull/4) ([arlimus](https://github.com/arlimus))
2124
- - travis checks [\#3](https://github.com/chef/inspec/pull/3) ([chris-rock](https://github.com/chris-rock))
2125
- - Package [\#2](https://github.com/chef/inspec/pull/2) ([chris-rock](https://github.com/chris-rock))
2126
- - shared linux file handling + specinfra config + cleanup [\#1](https://github.com/chef/inspec/pull/1) ([arlimus](https://github.com/arlimus))
2127
2061
 
2128
2062
 
2129
2063
 
data/Gemfile CHANGED
@@ -20,6 +20,7 @@ group :test do
20
20
  gem 'mocha', '~> 1.1'
21
21
  gem 'ruby-progressbar', '~> 1.8'
22
22
  gem 'nokogiri', '~> 1.6'
23
+ gem 'webmock', '~> 2.3.2'
23
24
  end
24
25
 
25
26
  group :integration do
@@ -87,7 +87,7 @@ The following examples show how to use this InSpec audit resource.
87
87
  ### Test standard output (stdout)
88
88
 
89
89
  describe command('echo hello') do
90
- its('stdout') { should eq 'hello\n' }
90
+ its('stdout') { should eq "hello\n" }
91
91
  its('stderr') { should eq '' }
92
92
  its('exit_status') { should eq 0 }
93
93
  end
@@ -96,7 +96,7 @@ The following examples show how to use this InSpec audit resource.
96
96
 
97
97
  describe command('>&2 echo error') do
98
98
  its('stdout') { should eq '' }
99
- its('stderr') { should eq 'error\n' }
99
+ its('stderr') { should eq "error\n" }
100
100
  its('exit_status') { should eq 0 }
101
101
  end
102
102
 
@@ -0,0 +1,97 @@
1
+ ---
2
+ title: About the http Resource
3
+ ---
4
+
5
+ # http
6
+
7
+ Use the `http` InSpec audit resource to test an http endpoint.
8
+
9
+ ## Syntax
10
+
11
+ An `http` resource block declares the configuration settings to be tested:
12
+
13
+ describe http('url', auth: {user: 'user', pass: 'test'}, params: {params}, method: 'method', headers: {headers}, body: body) do
14
+ its('status') { should eq number }
15
+ its('body') { should eq 'body' }
16
+ its('headers.name') { should eq 'header' }
17
+ end
18
+
19
+ where
20
+
21
+ * `('url')` is the url to test
22
+ * `{user: 'user', pass: 'test'}` may be specified for basic auth request
23
+ * `{params}` may be specified for http request parameters
24
+ * `'method'` may be specified for http request method (default to 'GET')
25
+ * `{headers}` may be specified for http request headers
26
+ * `body` may be specified for http request body
27
+
28
+ ## Matchers
29
+
30
+ This InSpec audit resource has the following matchers:
31
+
32
+ ### be
33
+
34
+ <%= partial "/shared/matcher_be" %>
35
+
36
+ ### body
37
+
38
+ The `body` matcher tests body content of http response:
39
+
40
+ its('body') { should eq 'hello\n' }
41
+
42
+ ### cmp
43
+
44
+ <%= partial "/shared/matcher_cmp" %>
45
+
46
+ ### eq
47
+
48
+ <%= partial "/shared/matcher_eq" %>
49
+
50
+ ### headers
51
+
52
+ The `headers` matcher returns an hash of all http headers:
53
+
54
+ its('headers') { should eq {} }
55
+
56
+ Individual headers can be tested via:
57
+
58
+ its('headers.Content-Type') { should cmp 'text/html' }
59
+
60
+ ### include
61
+
62
+ <%= partial "/shared/matcher_include" %>
63
+
64
+ ### match
65
+
66
+ <%= partial "/shared/matcher_match" %>
67
+
68
+ ### status
69
+
70
+ The `status` matcher tests status of the http response:
71
+
72
+ its('status') { should eq 200 }
73
+
74
+ ## Examples
75
+
76
+ The following examples show how to use this InSpec audit resource.
77
+
78
+ ### Simple http test
79
+
80
+ For example, a service is listening on default http port can be tested like this:
81
+
82
+ describe http('http://localhost') do
83
+ its('status') { should cmp 200 }
84
+ end
85
+
86
+ ### Complex http test
87
+
88
+ describe http('http://localhost:8080/ping',
89
+ auth: {user: 'user', pass: 'test'},
90
+ params: {format: 'html'},
91
+ method: 'POST',
92
+ headers: {'Content-Type' => 'application/json'},
93
+ data: '{"data":{"a":"1","b":"five"}}') do
94
+ its('status') { should cmp 200 }
95
+ its('body') { should cmp 'pong' }
96
+ its('headers.Content-Type') { should cmp 'text/html' }
97
+ end
@@ -56,7 +56,7 @@ The `os` audit resource includes a collection of helpers that enable more granul
56
56
  * `debian?`
57
57
  * `hpux?`
58
58
  * `linux?` (including Alpine Linux, Amazon Linux, ArchLinux, CoreOS, Exherbo, Fedora, Gentoo, and Slackware)
59
- * `redhat?`
59
+ * `redhat?` (including CentOS)
60
60
  * `solaris?` (including Nexenta Core, OmniOS, Open Indiana, Solaris Open, and SmartOS)
61
61
  * `suse?`
62
62
  * `unix?`
@@ -103,7 +103,7 @@ Use `os[:family]` to enable more granular testing of platforms, platform names,
103
103
  * `:debian`
104
104
  * `:hpux`
105
105
  * `:linux`. For platforms that are part of the Linux family: `:alpine`, `:amazon`, `:arch`, `:coreos`, `:exherbo`, `:fedora`, `:gentoo`, and `:slackware`.
106
- * `:redhat`
106
+ * `:redhat`. For platforms that are part of the Redhat family: `:centos`.
107
107
  * `:solaris`. For platforms that are part of the Solaris family: `:nexentacore`, `:omnios`, `:openindiana`, `:opensolaris`, and `:smartos`.
108
108
  * `:suse`
109
109
  * `:unix`
@@ -115,7 +115,7 @@ For example, both of the following tests should have the same result:
115
115
  describe port(69) do
116
116
  its('processes') { should include 'in.tftpd' }
117
117
  end
118
- elsif os[:family] == 'rhel'
118
+ elsif os[:family] == 'redhat'
119
119
  describe port(69) do
120
120
  its('processes') { should include 'xinetd' }
121
121
  end
@@ -125,7 +125,7 @@ For example, both of the following tests should have the same result:
125
125
  describe port(69) do
126
126
  its('processes') { should include 'in.tftpd' }
127
127
  end
128
- elsif os[:rhel]
128
+ elsif os[:redhat]
129
129
  describe port(69) do
130
130
  its('processes') { should include 'xinetd' }
131
131
  end
File without changes
@@ -4,7 +4,7 @@ title: About the sshd_config Resource
4
4
 
5
5
  # sshd_config
6
6
 
7
- Use the `sshd_config` InSpec audit resource to test configuration data for the OpenSSH daemon located at `/etc/ssh/sshd_config` on Linux and Unix platforms. sshd---the OpenSSH daemon---listens on dedicated ports, starts a daemon for each incoming connection, and then handles encryption, authentication, key exchanges, command executation, and data exchanges.
7
+ Use the `sshd_config` InSpec audit resource to test configuration data for the OpenSSH daemon located at `/etc/ssh/sshd_config` on Linux and Unix platforms. sshd---the OpenSSH daemon---listens on dedicated ports, starts a daemon for each incoming connection, and then handles encryption, authentication, key exchanges, command execution, and data exchanges.
8
8
 
9
9
  ## Syntax
10
10
 
@@ -3,7 +3,7 @@
3
3
  # license: All rights reserved
4
4
 
5
5
  # import full profile
6
- include_controls 'hardening/ssh-hardening'
6
+ include_controls 'dev-sec/ssh-baseline'
7
7
 
8
8
  # select only individual controls
9
9
  include_controls 'ssl-benchmark' do
@@ -7,7 +7,7 @@ license: Apache 2
7
7
  summary: InSpec Profile that is only consuming dependencies
8
8
  version: 0.2.0
9
9
  depends:
10
- - name: hardening/ssh-hardening # defaults to supermarket
10
+ - name: dev-sec/ssh-baseline # defaults to supermarket
11
11
  - url: https://github.com/dev-sec/ssl-benchmark
12
12
  - name: windows-patch-benchmark
13
13
  url: https://github.com/chris-rock/windows-patch-benchmark
data/inspec.gemspec CHANGED
@@ -38,4 +38,5 @@ Gem::Specification.new do |spec|
38
38
  spec.add_dependency 'sslshake', '~> 1'
39
39
  spec.add_dependency 'parallel', '~> 1.9'
40
40
  spec.add_dependency 'rspec_junit_formatter', '~> 0.2.3'
41
+ spec.add_dependency 'http', '~> 2.1.0'
41
42
  end
@@ -81,7 +81,7 @@ Please login using `inspec compliance login https://compliance.test --user admin
81
81
  [res.is_a?(Net::HTTPSuccess), res.body]
82
82
  end
83
83
 
84
- # Use username and refresh_toke to get an API access token
84
+ # Use username and refresh_token to get an API access token
85
85
  def self.get_token_via_refresh_token(url, refresh_token, insecure)
86
86
  uri = URI.parse("#{url}/login")
87
87
  req = Net::HTTP::Post.new(uri.path)
@@ -130,20 +130,27 @@ Please login using `inspec compliance login https://compliance.test --user admin
130
130
  end
131
131
 
132
132
  def self.get_headers(config)
133
+ token = get_token(config)
133
134
  if config['server_type'] == 'automate'
134
135
  headers = { 'chef-delivery-enterprise' => config['automate']['ent'] }
135
136
  if config['automate']['token_type'] == 'dctoken'
136
- headers['x-data-collector-token'] = config['token']
137
+ headers['x-data-collector-token'] = token
137
138
  else
138
139
  headers['chef-delivery-user'] = config['user']
139
- headers['chef-delivery-token'] = config['token']
140
+ headers['chef-delivery-token'] = token
140
141
  end
141
142
  else
142
- headers = { 'Authorization' => "Bearer #{config['token']}" }
143
+ headers = { 'Authorization' => "Bearer #{token}" }
143
144
  end
144
145
  headers
145
146
  end
146
147
 
148
+ def self.get_token(config)
149
+ return config['token'] unless config['refresh_token']
150
+ _success, _msg, token = get_token_via_refresh_token(config['server'], config['refresh_token'], config['insecure'])
151
+ token
152
+ end
153
+
147
154
  def self.target_url(config, profile)
148
155
  if config['server_type'] == 'automate'
149
156
  target = "#{config['server']}/#{profile}/tar"
@@ -179,7 +179,7 @@ module Compliance
179
179
  end
180
180
 
181
181
  # determine user information
182
- if config['token'].nil? || config['user'].nil?
182
+ if (config['token'].nil? && config['refresh_token'].nil?) || config['user'].nil?
183
183
  error.call('Please login via `inspec compliance login`')
184
184
  end
185
185
 
@@ -287,11 +287,10 @@ module Compliance
287
287
  end
288
288
 
289
289
  def login_refreshtoken(url, options)
290
- success, msg, access_token = Compliance::API.get_token_via_refresh_token(url, options['refresh_token'], options['insecure'])
290
+ success, msg, _access_token = Compliance::API.get_token_via_refresh_token(url, options['refresh_token'], options['insecure'])
291
291
  if success
292
292
  config = Compliance::Configuration.new
293
293
  config['server'] = url
294
- config['token'] = access_token
295
294
  config['insecure'] = options['insecure']
296
295
  config['version'] = Compliance::API.version(url, options['insecure'])
297
296
  config['server_type'] = 'compliance'
@@ -344,11 +343,10 @@ module Compliance
344
343
  success = true
345
344
  msg = 'API refresh token stored'
346
345
  else
347
- success, msg, access_token = Compliance::API.get_token_via_refresh_token(url, refresh_token, insecure)
346
+ success, msg, _access_token= Compliance::API.get_token_via_refresh_token(url, refresh_token, insecure)
348
347
  if success
349
- config['token'] = access_token
350
348
  config.store
351
- msg = 'API access token verified and stored'
349
+ msg = 'API access token verified'
352
350
  end
353
351
  end
354
352
 
@@ -13,7 +13,7 @@ module Compliance
13
13
  class Fetcher < Fetchers::Url
14
14
  name 'compliance'
15
15
  priority 500
16
- def self.resolve(target) # rubocop:disable PerceivedComplexity, Metrics/CyclomaticComplexity
16
+ def self.resolve(target) # rubocop:disable PerceivedComplexity, Metrics/CyclomaticComplexity, Metrics/AbcSize
17
17
  uri = if target.is_a?(String) && URI(target).scheme == 'compliance'
18
18
  URI(target)
19
19
  elsif target.respond_to?(:key?) && target.key?(:compliance)
@@ -29,7 +29,7 @@ module Compliance
29
29
  else
30
30
  # check if we have a compliance token
31
31
  config = Compliance::Configuration.new
32
- if config['token'].nil?
32
+ if config['token'].nil? && config['refresh_token'].nil?
33
33
  if config['server_type'] == 'automate'
34
34
  server = 'automate'
35
35
  msg = 'inspec compliance login_automate https://your_automate_server --user USER --ent ENT --dctoken DCTOKEN or --usertoken USERTOKEN'
@@ -55,6 +55,9 @@ EOF
55
55
  end
56
56
  profile_fetch_url = Compliance::API.target_url(config, profile)
57
57
  end
58
+ # We need to pass the token to the fetcher
59
+ config['token'] = Compliance::API.get_token(config)
60
+
58
61
  new(profile_fetch_url, config)
59
62
  rescue URI::Error => _e
60
63
  nil
@@ -86,6 +86,7 @@ require 'resources/gem'
86
86
  require 'resources/groups'
87
87
  require 'resources/grub_conf'
88
88
  require 'resources/host'
89
+ require 'resources/http'
89
90
  require 'resources/iis_site'
90
91
  require 'resources/inetd_conf'
91
92
  require 'resources/interface'
@@ -4,5 +4,5 @@
4
4
  # author: Christoph Hartmann
5
5
 
6
6
  module Inspec
7
- VERSION = '1.9.0'.freeze
7
+ VERSION = '1.10.0'.freeze
8
8
  end
@@ -0,0 +1,60 @@
1
+ # encoding: utf-8
2
+ # copyright: 2017, Criteo
3
+ # author: Guilhem Lettron
4
+ # license: Apache v2
5
+
6
+ require 'http'
7
+ require 'hashie'
8
+
9
+ module Inspec::Resources
10
+ class Http < Inspec.resource(1)
11
+ name 'http'
12
+ desc 'Use the http InSpec audit resource to test http call.'
13
+ example "
14
+ describe http('http://localhost:8080/ping', auth: {user: 'user', pass: 'test'}, params: {format: 'html'}) do
15
+ its('status') { should cmp 200 }
16
+ its('body') { should cmp 'pong' }
17
+ its('headers.Content-Type') { should cmp 'text/html' }
18
+ end
19
+
20
+ describe http('http://example.com/ping').headers do
21
+ its('Content-Length') { should cmp 258 }
22
+ its('Content-Type') { should cmp 'text/html; charset=UTF-8' }
23
+ end
24
+ "
25
+
26
+ # rubocop:disable ParameterLists
27
+ def initialize(url, method: 'GET', params: nil, auth: {}, headers: {}, data: nil)
28
+ @url = url
29
+ @method = method
30
+ @params = params
31
+ @auth = auth
32
+ @headers = headers
33
+ @data = data
34
+ end
35
+
36
+ def status
37
+ response.status
38
+ end
39
+
40
+ def body
41
+ response.to_s
42
+ end
43
+
44
+ def headers
45
+ Hashie::Mash.new(response.headers.to_h)
46
+ end
47
+
48
+ def to_s
49
+ "http #{@method} on #{@url}"
50
+ end
51
+
52
+ private
53
+
54
+ def response
55
+ http = HTTP.headers(@headers)
56
+ http = http.basic_auth(@auth) unless @auth.empty?
57
+ @response ||= http.request(@method, @url, { body: @data, params: @params })
58
+ end
59
+ end
60
+ end
@@ -9,7 +9,7 @@ require 'utils/simpleconfig'
9
9
  module Inspec::Resources
10
10
  class SshConf < Inspec.resource(1)
11
11
  name 'ssh_config'
12
- desc 'Use the sshd_config InSpec audit resource to test configuration data for the Open SSH daemon located at /etc/ssh/sshd_config on Linux and UNIX platforms. sshd---the Open SSH daemon---listens on dedicated ports, starts a daemon for each incoming connection, and then handles encryption, authentication, key exchanges, command executation, and data exchanges.'
12
+ desc 'Use the sshd_config InSpec audit resource to test configuration data for the Open SSH daemon located at /etc/ssh/sshd_config on Linux and UNIX platforms. sshd---the Open SSH daemon---listens on dedicated ports, starts a daemon for each incoming connection, and then handles encryption, authentication, key exchanges, command execution, and data exchanges.'
13
13
  example "
14
14
  describe sshd_config do
15
15
  its('Protocol') { should eq '2' }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: inspec
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.9.0
4
+ version: 1.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dominik Richter
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-01-06 00:00:00.000000000 Z
11
+ date: 2017-01-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: train
@@ -218,6 +218,20 @@ dependencies:
218
218
  - - "~>"
219
219
  - !ruby/object:Gem::Version
220
220
  version: 0.2.3
221
+ - !ruby/object:Gem::Dependency
222
+ name: http
223
+ requirement: !ruby/object:Gem::Requirement
224
+ requirements:
225
+ - - "~>"
226
+ - !ruby/object:Gem::Version
227
+ version: 2.1.0
228
+ type: :runtime
229
+ prerelease: false
230
+ version_requirements: !ruby/object:Gem::Requirement
231
+ requirements:
232
+ - - "~>"
233
+ - !ruby/object:Gem::Version
234
+ version: 2.1.0
221
235
  description: InSpec provides a framework for creating end-to-end infrastructure tests.
222
236
  You can use it for integration or even compliance testing. Create fully portable
223
237
  test profiles and use them in your workflow to ensure stability and security. Integrate
@@ -268,6 +282,7 @@ files:
268
282
  - docs/resources/group.md.erb
269
283
  - docs/resources/grub_conf.md.erb
270
284
  - docs/resources/host.md.erb
285
+ - docs/resources/http.md.erb
271
286
  - docs/resources/iis_site.md.erb
272
287
  - docs/resources/inetd_conf.md.erb
273
288
  - docs/resources/ini.md.erb
@@ -295,7 +310,7 @@ files:
295
310
  - docs/resources/postgres_conf.md.erb
296
311
  - docs/resources/postgres_session.md.erb
297
312
  - docs/resources/powershell.md.erb
298
- - docs/resources/process.md.erb
313
+ - docs/resources/processes.md.erb
299
314
  - docs/resources/registry_key.md.erb
300
315
  - docs/resources/runit_service.md.erb
301
316
  - docs/resources/security_policy.md.erb
@@ -471,6 +486,7 @@ files:
471
486
  - lib/resources/groups.rb
472
487
  - lib/resources/grub_conf.rb
473
488
  - lib/resources/host.rb
489
+ - lib/resources/http.rb
474
490
  - lib/resources/iis_site.rb
475
491
  - lib/resources/inetd_conf.rb
476
492
  - lib/resources/ini.rb