inspec 1.0.0.beta2 → 1.0.0.beta3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (95) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +41 -2
  3. data/Gemfile +4 -0
  4. data/Rakefile +2 -1
  5. data/docs/.gitignore +2 -0
  6. data/docs/README.md +21 -1
  7. data/docs/resources/apache_conf.md.erb +75 -0
  8. data/docs/resources/apt.md.erb +84 -0
  9. data/docs/resources/audit_policy.md.erb +61 -0
  10. data/docs/resources/auditd_conf.md.erb +79 -0
  11. data/docs/resources/auditd_rules.md.erb +132 -0
  12. data/docs/resources/bash.md.erb +84 -0
  13. data/docs/resources/bond.md.erb +97 -0
  14. data/docs/resources/bridge.md.erb +67 -0
  15. data/docs/resources/bsd_service.md.erb +76 -0
  16. data/docs/resources/command.md.erb +151 -0
  17. data/docs/resources/csv.md.erb +62 -0
  18. data/docs/resources/directory.md.erb +43 -0
  19. data/docs/resources/etc_group.md.erb +116 -0
  20. data/docs/resources/etc_passwd.md.erb +155 -0
  21. data/docs/resources/etc_shadow.md.erb +149 -0
  22. data/docs/resources/file.md.erb +460 -0
  23. data/docs/resources/gem.md.erb +73 -0
  24. data/docs/resources/group.md.erb +74 -0
  25. data/docs/resources/grub_conf.md.erb +115 -0
  26. data/docs/resources/host.md.erb +85 -0
  27. data/docs/resources/iis_site.md.erb +142 -0
  28. data/docs/resources/inetd_conf.md.erb +99 -0
  29. data/docs/resources/ini.md.erb +69 -0
  30. data/docs/resources/interface.md.erb +66 -0
  31. data/docs/resources/iptables.md.erb +70 -0
  32. data/docs/resources/json.md.erb +76 -0
  33. data/docs/resources/kernel_module.md.erb +60 -0
  34. data/docs/resources/kernel_parameter.md.erb +72 -0
  35. data/docs/resources/launchd_service.md.erb +76 -0
  36. data/docs/resources/limits_conf.md.erb +80 -0
  37. data/docs/resources/login_def.md.erb +77 -0
  38. data/docs/resources/mount.md.erb +83 -0
  39. data/docs/resources/mysql_conf.md.erb +102 -0
  40. data/docs/resources/mysql_session.md.erb +63 -0
  41. data/docs/resources/npm.md.erb +75 -0
  42. data/docs/resources/ntp_conf.md.erb +76 -0
  43. data/docs/resources/oneget.md.erb +67 -0
  44. data/docs/resources/os.md.erb +154 -0
  45. data/docs/resources/os_env.md.erb +98 -0
  46. data/docs/resources/package.md.erb +115 -0
  47. data/docs/resources/parse_config.md.erb +122 -0
  48. data/docs/resources/parse_config_file.md.erb +143 -0
  49. data/docs/resources/pip.md.erb +74 -0
  50. data/docs/resources/port.md.erb +150 -0
  51. data/docs/resources/postgres_conf.md.erb +90 -0
  52. data/docs/resources/postgres_session.md.erb +75 -0
  53. data/docs/resources/powershell.md.erb +116 -0
  54. data/docs/resources/process.md.erb +73 -0
  55. data/docs/resources/registry_key.md.erb +149 -0
  56. data/docs/resources/runit_service.md.erb +76 -0
  57. data/docs/resources/security_policy.md.erb +61 -0
  58. data/docs/resources/service.md.erb +135 -0
  59. data/docs/resources/ssh_config.md.erb +94 -0
  60. data/docs/resources/sshd_config.md.erb +97 -0
  61. data/docs/resources/ssl.md.erb +133 -0
  62. data/docs/resources/sys_info.md.erb +55 -0
  63. data/docs/resources/systemd_service.md.erb +76 -0
  64. data/docs/resources/sysv_service.md.erb +76 -0
  65. data/docs/resources/upstart_service.md.erb +76 -0
  66. data/docs/resources/user.md.erb +154 -0
  67. data/docs/resources/users.md.erb +140 -0
  68. data/docs/resources/vbscript.md.erb +69 -0
  69. data/docs/resources/windows_feature.md.erb +61 -0
  70. data/docs/resources/wmi.md.erb +95 -0
  71. data/docs/resources/xinetd_conf.md.erb +170 -0
  72. data/docs/resources/yaml.md.erb +69 -0
  73. data/docs/resources/yum.md.erb +103 -0
  74. data/docs/ruby_usage.md +154 -0
  75. data/docs/shared/matcher_be.md.erb +1 -0
  76. data/docs/shared/matcher_cmp.md.erb +45 -0
  77. data/docs/shared/matcher_eq.md.erb +3 -0
  78. data/docs/shared/matcher_include.md.erb +1 -0
  79. data/docs/shared/matcher_match.md.erb +1 -0
  80. data/lib/fetchers/url.rb +27 -29
  81. data/lib/inspec/cached_fetcher.rb +67 -0
  82. data/lib/inspec/dependencies/requirement.rb +6 -7
  83. data/lib/inspec/objects/each_loop.rb +5 -2
  84. data/lib/inspec/plugins/fetcher.rb +2 -0
  85. data/lib/inspec/profile.rb +9 -41
  86. data/lib/inspec/resource.rb +1 -1
  87. data/lib/inspec/rspec_json_formatter.rb +11 -5
  88. data/lib/inspec/version.rb +1 -1
  89. data/lib/resources/groups.rb +190 -0
  90. data/lib/resources/users.rb +3 -2
  91. metadata +79 -6
  92. data/docs/cli.rst +0 -448
  93. data/docs/resources.rst +0 -4836
  94. data/docs/ruby_usage.rst +0 -145
  95. data/lib/resources/group.rb +0 -137
@@ -0,0 +1,115 @@
1
+ ---
2
+ title: About the package Resource
3
+ ---
4
+
5
+ # package
6
+
7
+ Use the `package` InSpec audit resource to test if the named package and/or package version is installed on the system.
8
+
9
+
10
+ # Syntax
11
+
12
+ A `package` resource block declares a package and (optionally) a package version:
13
+
14
+ describe package('name') do
15
+ it { should be_installed }
16
+ end
17
+
18
+ where
19
+
20
+ * `('name')` must specify the name of a package, such as `'nginx'`
21
+ * `be_installed` is a valid matcher for this resource
22
+
23
+ # Matchers
24
+
25
+ This InSpec audit resource has the following matchers:
26
+
27
+ ## be
28
+
29
+ <%= partial "/shared/matcher_be" %>
30
+
31
+ ## be_installed
32
+
33
+ The `be_installed` matcher tests if the named package is installed on the system:
34
+
35
+ it { should be_installed }
36
+
37
+ ## cmp
38
+
39
+ <%= partial "/shared/matcher_cmp" %>
40
+
41
+ ## eq
42
+
43
+ <%= partial "/shared/matcher_eq" %>
44
+
45
+ ## include
46
+
47
+ <%= partial "/shared/matcher_include" %>
48
+
49
+ ## match
50
+
51
+ <%= partial "/shared/matcher_match" %>
52
+
53
+ ## version
54
+
55
+ The `version` matcher tests if the named package version is on the system:
56
+
57
+ its('version') { should eq '1.2.3' }
58
+
59
+ # Examples
60
+
61
+ The following examples show how to use this InSpec audit resource.
62
+
63
+ ## Test if nginx version 1.9.5 is installed
64
+
65
+ describe package('nginx') do
66
+ it { should be_installed }
67
+ its('version') { should eq 1.9.5 }
68
+ end
69
+
70
+ ## Test that a package is not installed
71
+
72
+ describe package('some_package') do
73
+ it { should_not be_installed }
74
+ end
75
+
76
+ ## Test if telnet is installed
77
+
78
+ describe package('telnetd') do
79
+ it { should_not be_installed }
80
+ end
81
+
82
+ describe inetd_conf do
83
+ its('telnet') { should eq nil }
84
+ end
85
+
86
+ ## Test if ClamAV (an antivirus engine) is installed and running
87
+
88
+ describe package('clamav') do
89
+ it { should be_installed }
90
+ its('version') { should eq '0.98.7' }
91
+ end
92
+
93
+ describe service('clamd') do
94
+ it { should_not be_enabled }
95
+ it { should_not be_installed }
96
+ it { should_not be_running }
97
+ end
98
+
99
+ ## Verify if Memcached is installed, enabled, and running
100
+
101
+ Memcached is an in-memory key-value store that helps improve the performance of database-driven websites and can be installed, maintained, and tested using the `memcached` cookbook (maintained by Chef). The following example is from the `memcached` cookbook and shows how to use a combination of the `package`, `service`, and `port` InSpec audit resources to test if Memcached is installed, enabled, and running:
102
+
103
+ describe package('memcached') do
104
+ it { should be_installed }
105
+ end
106
+
107
+ describe service('memcached') do
108
+ it { should be_installed }
109
+ it { should be_enabled }
110
+ it { should be_running }
111
+ end
112
+
113
+ describe port(11_211) do
114
+ it { should be_listening }
115
+ end
@@ -0,0 +1,122 @@
1
+ ---
2
+ title: About the parse_config Resource
3
+ ---
4
+
5
+ # parse_config
6
+
7
+ Use the `parse_config` InSpec audit resource to test arbitrary configuration files.
8
+
9
+ # Syntax
10
+
11
+ A `parse_config` resource block declares the location of the configuration setting to be tested, and then what value is to be tested. Because this resource relies on arbitrary configuration files, the test itself is often arbitrary and relies on custom Ruby code:
12
+
13
+ output = command('some-command').stdout
14
+
15
+ describe parse_config(output, { data_config_option: value } ) do
16
+ its('setting') { should eq 1 }
17
+ end
18
+
19
+ or:
20
+
21
+ audit = command('/sbin/auditctl -l').stdout
22
+ options = {
23
+ assignment_re: /^\s*([^:]*?)\s*:\s*(.*?)\s*$/,
24
+ multiple_values: true
25
+ }
26
+
27
+ describe parse_config(audit, options) do
28
+ its('setting') { should eq 1 }
29
+ end
30
+
31
+ where each test
32
+
33
+ * Must declare the location of the configuration file to be tested
34
+ * Must declare one (or more) settings to be tested
35
+ * May run a command to `stdout`, and then run the test against that output
36
+ * May use options to define how configuration data is to be parsed
37
+
38
+ # Matchers
39
+
40
+ This InSpec audit resource has the following matchers:
41
+
42
+ ## assignment_re
43
+
44
+ Use `assignment_re` to test a key value using a regular expression:
45
+
46
+ 'key = value'
47
+
48
+ may be tested using the following regular expression, which determines assignment from key to value:
49
+
50
+ assignment_re: /^\s*([^=]*?)\s*=\s*(.*?)\s*$/
51
+
52
+ ## be
53
+
54
+ <%= partial "/shared/matcher_be" %>
55
+
56
+ ## cmp
57
+
58
+ <%= partial "/shared/matcher_cmp" %>
59
+
60
+ ## comment_char
61
+
62
+ Use `comment_char` to test for comments in a configuration file:
63
+
64
+ comment_char: '#'
65
+
66
+ ## eq
67
+
68
+ <%= partial "/shared/matcher_eq" %>
69
+
70
+ ## include
71
+
72
+ <%= partial "/shared/matcher_include" %>
73
+
74
+ ## key_vals
75
+
76
+ Use `key_vals` to test how many values a key contains:
77
+
78
+ key = a b c
79
+
80
+ contains three values. To test that value to ensure it only contains one, use:
81
+
82
+ key_vals: 1
83
+
84
+ ## match
85
+
86
+ <%= partial "/shared/matcher_match" %>
87
+
88
+ ## multiple_values
89
+
90
+ Use `multiple_values` if the source file uses the same key multiple times. All values will be aggregated in an array:
91
+
92
+ # # file structure:
93
+ # key = a
94
+ # key = b
95
+ # key2 = c
96
+ params['key'] = ['a', 'b']
97
+ params['key2'] = ['c']
98
+
99
+ To use plain key value mapping, use `multiple_values: false`:
100
+
101
+ # # file structure:
102
+ # key = a
103
+ # key = b
104
+ # key2 = c
105
+ params['key'] = 'b'
106
+ params['key2'] = 'c'
107
+
108
+ ## standalone_comments
109
+
110
+ Use `standalone_comments` to parse comments as a line, otherwise inline comments are allowed:
111
+
112
+ 'key = value # comment'
113
+ params['key'] = 'value # comment'
114
+
115
+ Use `standalone_comments: false`, to parse the following:
116
+
117
+ 'key = value # comment'
118
+ params['key'] = 'value'
119
+
120
+ # Examples
121
+
122
+ None.
@@ -0,0 +1,143 @@
1
+ ---
2
+ title: About the parse_config_file Resource
3
+ ---
4
+
5
+ # parse_config_file
6
+
7
+ Use the `parse_config_file` InSpec audit resource to test arbitrary configuration files. It works in the same way as `parse_config`. Instead of using a command output, this resource works with files.
8
+
9
+ # Syntax
10
+
11
+ A `parse_config_file` InSpec audit resource block declares the location of the configuration file to be tested, and then which settings in that file are to be tested.
12
+
13
+ describe parse_config_file('/path/to/file', { data_config_option: value } ) do
14
+ its('setting') { should eq 1 }
15
+ end
16
+
17
+ or:
18
+
19
+ options = {
20
+ assignment_re: /^\s*([^:]*?)\s*:\s*(.*?)\s*$/,
21
+ multiple_values: true
22
+ }
23
+
24
+ describe parse_config_file('path/to/file', options) do
25
+ its('setting') { should eq 1 }
26
+ end
27
+
28
+ where each test
29
+
30
+ * Must declare the location of the configuration file to be tested
31
+ * Must declare one (or more) settings to be tested
32
+ * May run a command to `stdout`, and then run the test against that output
33
+ * May use options to define how configuration data is to be parsed
34
+
35
+ # Options
36
+
37
+ This resource supports the following options for parsing configuration data. Use them in an `options` block stated outside of (and immediately before) the actual test:
38
+
39
+ options = {
40
+ assignment_re: /^\s*([^:]*?)\s*:\s*(.*?)\s*$/,
41
+ multiple_values: true
42
+ }
43
+ describe parse_config_file('path/to/file', options) do
44
+ its('setting') { should eq 1 }
45
+ end
46
+
47
+ # Matchers
48
+
49
+ This InSpec audit resource has the following matchers:
50
+
51
+ ## assignment_re
52
+
53
+ Use `assignment_re` to test a key value using a regular expression:
54
+
55
+ 'key = value'
56
+
57
+ may be tested using the following regular expression, which determines assignment from key to value:
58
+
59
+ assignment_re: /^\s*([^=]*?)\s*=\s*(.*?)\s*$/
60
+
61
+ ## be
62
+
63
+ <%= partial "/shared/matcher_be" %>
64
+
65
+ ## cmp
66
+
67
+ <%= partial "/shared/matcher_cmp" %>
68
+
69
+ ## comment_char
70
+
71
+ Use `comment_char` to test for comments in a configuration file:
72
+
73
+ comment_char: '#'
74
+
75
+ ## eq
76
+
77
+ <%= partial "/shared/matcher_eq" %>
78
+
79
+ ## include
80
+
81
+ <%= partial "/shared/matcher_include" %>
82
+
83
+ ## key_vals
84
+
85
+ Use `key_vals` to test how many values a key contains:
86
+
87
+ key = a b c
88
+
89
+ contains three values. To test that value to ensure it only contains one, use:
90
+
91
+ key_vals: 1
92
+
93
+ ## match
94
+
95
+ <%= partial "/shared/matcher_match" %>
96
+
97
+ ## multiple_values
98
+
99
+ Use `multiple_values` if the source file uses the same key multiple times. All values will be aggregated in an array:
100
+
101
+ # # file structure:
102
+ # key = a
103
+ # key = b
104
+ # key2 = c
105
+ params['key'] = ['a', 'b']
106
+ params['key2'] = ['c']
107
+
108
+ To use plain key value mapping, use `multiple_values: false`:
109
+
110
+ # # file structure:
111
+ # key = a
112
+ # key = b
113
+ # key2 = c
114
+ params['key'] = 'b'
115
+ params['key2'] = 'c'
116
+
117
+ ## standalone_comments
118
+
119
+ Use `standalone_comments` to parse comments as a line, otherwise inline comments are allowed:
120
+
121
+ 'key = value # comment'
122
+ params['key'] = 'value # comment'
123
+
124
+ Use `standalone_comments: false`, to parse the following:
125
+
126
+ 'key = value # comment'
127
+ params['key'] = 'value'
128
+
129
+ # Examples
130
+
131
+ The following examples show how to use this InSpec audit resource.
132
+
133
+ ## Test a configuration setting
134
+
135
+ describe parse_config_file('/path/to/file.conf') do
136
+ its('PARAM_X') { should eq 'Y' }
137
+ end
138
+
139
+ ## Use options, and then test a configuration setting
140
+
141
+ describe parse_config_file('/path/to/file.conf', { multiple_values: true }) do
142
+ its('PARAM_X') { should include 'Y' }
143
+ end
@@ -0,0 +1,74 @@
1
+ ---
2
+ title: About the pip Resource
3
+ ---
4
+
5
+ # pip
6
+
7
+ Use the `pip` InSpec audit resource to test packages that are installed using the Python PIP installer.
8
+
9
+ # Syntax
10
+
11
+ A `pip` resource block declares a package and (optionally) a package version:
12
+
13
+ describe pip('Jinja2') do
14
+ it { should be_installed }
15
+ end
16
+
17
+ where
18
+
19
+ * `'Jinja2'` is the name of the package
20
+ * `be_installed` tests to see if the `Jinja2` package is installed
21
+
22
+
23
+ # Matchers
24
+
25
+ This InSpec audit resource has the following matchers:
26
+
27
+ ## be
28
+
29
+ <%= partial "/shared/matcher_be" %>
30
+
31
+ ## be_installed
32
+
33
+ The `be_installed` matcher tests if the named package is installed on the system:
34
+
35
+ it { should be_installed }
36
+
37
+ ## cmp
38
+
39
+ <%= partial "/shared/matcher_cmp" %>
40
+
41
+ ## eq
42
+
43
+ <%= partial "/shared/matcher_eq" %>
44
+
45
+ ## include
46
+
47
+ <%= partial "/shared/matcher_include" %>
48
+
49
+ ## match
50
+
51
+ <%= partial "/shared/matcher_match" %>
52
+
53
+ ## version
54
+
55
+ The `version` matcher tests if the named package version is on the system:
56
+
57
+ its('version') { should eq '1.2.3' }
58
+
59
+ # Examples
60
+
61
+ The following examples show how to use this InSpec audit resource.
62
+
63
+ ## Test if Jinja2 is installed on the system
64
+
65
+ describe pip('Jinja2') do
66
+ it { should be_installed }
67
+ end
68
+
69
+ ## Test if Jinja2 2.8 is installed on the system
70
+
71
+ describe pip('Jinja2') do
72
+ it { should be_installed }
73
+ its('version') { should eq '2.8' }
74
+ end