inspec 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +46 -3
- data/Gemfile +4 -1
- data/README.md +3 -0
- data/docs/dsl_inspec.md +3 -3
- data/docs/profiles.md +17 -0
- data/docs/resources/apache_conf.md.erb +10 -10
- data/docs/resources/apt.md.erb +13 -13
- data/docs/resources/audit_policy.md.erb +10 -10
- data/docs/resources/auditd_conf.md.erb +10 -10
- data/docs/resources/auditd_rules.md.erb +11 -11
- data/docs/resources/bash.md.erb +12 -12
- data/docs/resources/bond.md.erb +15 -15
- data/docs/resources/bridge.md.erb +11 -11
- data/docs/resources/bsd_service.md.erb +11 -11
- data/docs/resources/command.md.erb +21 -21
- data/docs/resources/csv.md.erb +10 -10
- data/docs/resources/directory.md.erb +8 -8
- data/docs/resources/etc_group.md.erb +16 -16
- data/docs/resources/etc_passwd.md.erb +17 -17
- data/docs/resources/etc_shadow.md.erb +19 -19
- data/docs/resources/file.md.erb +58 -58
- data/docs/resources/gem.md.erb +12 -12
- data/docs/resources/group.md.erb +12 -12
- data/docs/resources/grub_conf.md.erb +11 -11
- data/docs/resources/host.md.erb +13 -13
- data/docs/resources/iis_site.md.erb +16 -16
- data/docs/resources/inetd_conf.md.erb +10 -10
- data/docs/resources/ini.md.erb +9 -9
- data/docs/resources/interface.md.erb +11 -11
- data/docs/resources/iptables.md.erb +11 -11
- data/docs/resources/json.md.erb +10 -10
- data/docs/resources/kernel_module.md.erb +10 -10
- data/docs/resources/kernel_parameter.md.erb +12 -12
- data/docs/resources/launchd_service.md.erb +11 -11
- data/docs/resources/limits_conf.md.erb +10 -10
- data/docs/resources/login_def.md.erb +12 -12
- data/docs/resources/mount.md.erb +13 -13
- data/docs/resources/mysql_conf.md.erb +14 -14
- data/docs/resources/mysql_session.md.erb +10 -10
- data/docs/resources/npm.md.erb +12 -12
- data/docs/resources/ntp_conf.md.erb +9 -9
- data/docs/resources/oneget.md.erb +11 -11
- data/docs/resources/os.md.erb +13 -13
- data/docs/resources/os_env.md.erb +12 -12
- data/docs/resources/package.md.erb +15 -15
- data/docs/resources/parse_config.md.erb +13 -13
- data/docs/resources/parse_config_file.md.erb +22 -16
- data/docs/resources/pip.md.erb +12 -12
- data/docs/resources/port.md.erb +18 -18
- data/docs/resources/postgres_conf.md.erb +13 -13
- data/docs/resources/postgres_session.md.erb +11 -11
- data/docs/resources/powershell.md.erb +13 -13
- data/docs/resources/process.md.erb +12 -12
- data/docs/resources/registry_key.md.erb +17 -17
- data/docs/resources/runit_service.md.erb +11 -11
- data/docs/resources/security_policy.md.erb +10 -10
- data/docs/resources/service.md.erb +17 -17
- data/docs/resources/ssh_config.md.erb +13 -13
- data/docs/resources/sshd_config.md.erb +14 -14
- data/docs/resources/ssl.md.erb +12 -12
- data/docs/resources/sys_info.md.erb +10 -10
- data/docs/resources/systemd_service.md.erb +11 -11
- data/docs/resources/sysv_service.md.erb +11 -11
- data/docs/resources/upstart_service.md.erb +11 -11
- data/docs/resources/user.md.erb +20 -20
- data/docs/resources/users.md.erb +19 -19
- data/docs/resources/vbscript.md.erb +9 -9
- data/docs/resources/windows_feature.md.erb +10 -10
- data/docs/resources/wmi.md.erb +10 -10
- data/docs/resources/xinetd_conf.md.erb +17 -17
- data/docs/resources/yaml.md.erb +10 -10
- data/docs/resources/yum.md.erb +16 -16
- data/examples/meta-profile/README.md +0 -5
- data/lib/inspec/base_cli.rb +6 -0
- data/lib/inspec/cli.rb +10 -3
- data/lib/inspec/profile.rb +3 -3
- data/lib/inspec/rspec_json_formatter.rb +24 -15
- data/lib/inspec/version.rb +1 -1
- data/lib/resources/registry_key.rb +15 -5
- data/lib/utils/filter.rb +1 -0
- metadata +3 -4
data/docs/resources/csv.md.erb
CHANGED
@@ -6,7 +6,7 @@ title: About the csv Resource
|
|
6
6
|
|
7
7
|
Use the `csv` InSpec audit resource to test configuration data in a CSV file.
|
8
8
|
|
9
|
-
|
9
|
+
## Syntax
|
10
10
|
|
11
11
|
A `csv` resource block declares the configuration data to be tested:
|
12
12
|
|
@@ -21,41 +21,41 @@ where
|
|
21
21
|
* `should eq 'foo'` tests a value of `name` as read from a CSV file versus the value declared in the test
|
22
22
|
|
23
23
|
|
24
|
-
|
24
|
+
## Matchers
|
25
25
|
|
26
26
|
This InSpec audit resource has the following matchers:
|
27
27
|
|
28
|
-
|
28
|
+
### be
|
29
29
|
|
30
30
|
<%= partial "/shared/matcher_be" %>
|
31
31
|
|
32
|
-
|
32
|
+
### cmp
|
33
33
|
|
34
34
|
<%= partial "/shared/matcher_cmp" %>
|
35
35
|
|
36
|
-
|
36
|
+
### eq
|
37
37
|
|
38
38
|
<%= partial "/shared/matcher_eq" %>
|
39
39
|
|
40
|
-
|
40
|
+
### include
|
41
41
|
|
42
42
|
<%= partial "/shared/matcher_include" %>
|
43
43
|
|
44
|
-
|
44
|
+
### match
|
45
45
|
|
46
46
|
<%= partial "/shared/matcher_match" %>
|
47
47
|
|
48
|
-
|
48
|
+
### name
|
49
49
|
|
50
50
|
The `name` matcher tests the value of `name` as read from a CSV file versus the value declared in the test:
|
51
51
|
|
52
52
|
its('name') { should eq 'foo' }
|
53
53
|
|
54
|
-
|
54
|
+
## Examples
|
55
55
|
|
56
56
|
The following examples show how to use this InSpec audit resource.
|
57
57
|
|
58
|
-
|
58
|
+
### Test a CSV file
|
59
59
|
|
60
60
|
describe csv('some_file.csv') do
|
61
61
|
its('setting') { should eq 1 }
|
@@ -6,7 +6,7 @@ title: About the directory Resource
|
|
6
6
|
|
7
7
|
Use the `directory` InSpec audit resource to test if the file type is a directory. This is equivalent to using the `file` resource and the `be_directory` matcher, but provides a simpler and more direct way to test directories. All of the matchers available to `file` may be used with `directory`.
|
8
8
|
|
9
|
-
|
9
|
+
## Syntax
|
10
10
|
|
11
11
|
A `directory` resource block declares the location of the directory to be tested, and then one (or more) matchers:
|
12
12
|
|
@@ -14,30 +14,30 @@ A `directory` resource block declares the location of the directory to be tested
|
|
14
14
|
it { should MATCHER 'value' }
|
15
15
|
end
|
16
16
|
|
17
|
-
|
17
|
+
## Matchers
|
18
18
|
|
19
19
|
This resource may use any of the matchers available to the `file` resource that may be useful when testing a directory.
|
20
20
|
|
21
|
-
|
21
|
+
### be
|
22
22
|
|
23
23
|
<%= partial "/shared/matcher_be" %>
|
24
24
|
|
25
|
-
|
25
|
+
### cmp
|
26
26
|
|
27
27
|
<%= partial "/shared/matcher_cmp" %>
|
28
28
|
|
29
|
-
|
29
|
+
### eq
|
30
30
|
|
31
31
|
<%= partial "/shared/matcher_eq" %>
|
32
32
|
|
33
|
-
|
33
|
+
### include
|
34
34
|
|
35
35
|
<%= partial "/shared/matcher_include" %>
|
36
36
|
|
37
|
-
|
37
|
+
### match
|
38
38
|
|
39
39
|
<%= partial "/shared/matcher_match" %>
|
40
40
|
|
41
|
-
|
41
|
+
## Examples
|
42
42
|
|
43
43
|
None.
|
@@ -6,7 +6,7 @@ title: About the etc_group Resource
|
|
6
6
|
|
7
7
|
Use the `etc_group` InSpec audit resource to test groups that are defined on Linux and Unix platforms. The `/etc/group` file stores details about each group---group name, password, group identifier, along with a comma-separate list of users that belong to the group.
|
8
8
|
|
9
|
-
|
9
|
+
## Syntax
|
10
10
|
|
11
11
|
A `etc_group` resource block declares a collection of properties to be tested:
|
12
12
|
|
@@ -28,49 +28,49 @@ where
|
|
28
28
|
* `.where()` may specify a specific item and value, to which the matchers are compared
|
29
29
|
* `'gids'`, `'groups'`, and `'users'` are valid matchers for this resource
|
30
30
|
|
31
|
-
|
31
|
+
## Matchers
|
32
32
|
|
33
33
|
This InSpec audit resource has the following matchers:
|
34
34
|
|
35
|
-
|
35
|
+
### be
|
36
36
|
|
37
37
|
<%= partial "/shared/matcher_be" %>
|
38
38
|
|
39
|
-
|
39
|
+
### cmp
|
40
40
|
|
41
41
|
<%= partial "/shared/matcher_cmp" %>
|
42
42
|
|
43
|
-
|
43
|
+
### eq
|
44
44
|
|
45
45
|
<%= partial "/shared/matcher_eq" %>
|
46
46
|
|
47
|
-
|
47
|
+
### gids
|
48
48
|
|
49
49
|
The `gids` matcher tests if the named group identifier is present or if it contains duplicates:
|
50
50
|
|
51
51
|
its('gids') { should_not contain_duplicates }
|
52
52
|
|
53
|
-
|
53
|
+
### groups
|
54
54
|
|
55
55
|
The `groups` matcher tests all groups for the named user:
|
56
56
|
|
57
57
|
its('groups') { should include 'my_group' }
|
58
58
|
|
59
|
-
|
59
|
+
### include
|
60
60
|
|
61
61
|
<%= partial "/shared/matcher_include" %>
|
62
62
|
|
63
|
-
|
63
|
+
### match
|
64
64
|
|
65
65
|
<%= partial "/shared/matcher_match" %>
|
66
66
|
|
67
|
-
|
67
|
+
### users
|
68
68
|
|
69
69
|
The `users` matcher tests all groups for the named user:
|
70
70
|
|
71
71
|
its('users') { should include 'my_user' }
|
72
72
|
|
73
|
-
|
73
|
+
### where
|
74
74
|
|
75
75
|
The `where` matcher allows the test to be focused to one (or more) specific items:
|
76
76
|
|
@@ -87,29 +87,29 @@ where `item` may be one (or more) of:
|
|
87
87
|
* `members: 'member_name'`
|
88
88
|
|
89
89
|
|
90
|
-
|
90
|
+
## Examples
|
91
91
|
|
92
92
|
The following examples show how to use this InSpec audit resource.
|
93
93
|
|
94
|
-
|
94
|
+
### Test group identifiers (GIDs) for duplicates
|
95
95
|
|
96
96
|
describe etc_group do
|
97
97
|
its('gids') { should_not contain_duplicates }
|
98
98
|
end
|
99
99
|
|
100
|
-
|
100
|
+
### Test all groups to see if a specific user belongs to one (or more) groups
|
101
101
|
|
102
102
|
describe etc_group do
|
103
103
|
its('groups') { should include 'my_group' }
|
104
104
|
end
|
105
105
|
|
106
|
-
|
106
|
+
### Test all groups for a specific user name
|
107
107
|
|
108
108
|
describe etc_group do
|
109
109
|
its('users') { should include 'my_user' }
|
110
110
|
end
|
111
111
|
|
112
|
-
|
112
|
+
### Filter a list of groups for a specific user
|
113
113
|
|
114
114
|
describe etc_group.where(name: 'my_group') do
|
115
115
|
its('users') { should include 'my_user' }
|
@@ -18,7 +18,7 @@ These entries are defined as a colon-delimited row in the file, one row per user
|
|
18
18
|
|
19
19
|
root:x:1234:5678:additional_info:/home/dir/:/bin/bash
|
20
20
|
|
21
|
-
|
21
|
+
## Syntax
|
22
22
|
|
23
23
|
A `passwd` resource block declares one (or more) users and associated user information to be tested:
|
24
24
|
|
@@ -38,40 +38,40 @@ where
|
|
38
38
|
* `filter` may take any of the following arguments: `count` (retrieves the number of entries), `lines` (provides raw `passwd` lines), and `params` (returns an array of maps for all entries)
|
39
39
|
|
40
40
|
|
41
|
-
|
41
|
+
## Matchers
|
42
42
|
|
43
43
|
This InSpec audit resource has the following matchers:
|
44
44
|
|
45
|
-
|
45
|
+
### be
|
46
46
|
|
47
47
|
<%= partial "/shared/matcher_be" %>
|
48
48
|
|
49
|
-
|
49
|
+
### cmp
|
50
50
|
|
51
51
|
<%= partial "/shared/matcher_cmp" %>
|
52
52
|
|
53
|
-
|
53
|
+
### eq
|
54
54
|
|
55
55
|
<%= partial "/shared/matcher_eq" %>
|
56
56
|
|
57
|
-
|
57
|
+
### gids
|
58
58
|
|
59
59
|
The `gids` matcher tests if the group indentifiers in the test match group identifiers in `/etc/passwd`:
|
60
60
|
|
61
61
|
its('gids') { should include 1234 }
|
62
62
|
its('gids') { should cmp 0 }
|
63
63
|
|
64
|
-
|
64
|
+
### homes
|
65
65
|
|
66
66
|
The `homes` matcher tests the absolute path to a user's home directory:
|
67
67
|
|
68
68
|
its('home') { should eq '/' }
|
69
69
|
|
70
|
-
|
70
|
+
### include
|
71
71
|
|
72
72
|
<%= partial "/shared/matcher_include" %>
|
73
73
|
|
74
|
-
|
74
|
+
### length
|
75
75
|
|
76
76
|
The `length` matcher tests the length of a password that appears in `/etc/passwd`:
|
77
77
|
|
@@ -83,11 +83,11 @@ This matcher is best used in conjunction with filters. For example:
|
|
83
83
|
its('length') { should_not be < 16 }
|
84
84
|
end
|
85
85
|
|
86
|
-
|
86
|
+
### match
|
87
87
|
|
88
88
|
<%= partial "/shared/matcher_match" %>
|
89
89
|
|
90
|
-
|
90
|
+
### passwords
|
91
91
|
|
92
92
|
The `passwords` matcher tests if passwords are
|
93
93
|
|
@@ -100,7 +100,7 @@ For example:
|
|
100
100
|
its('passwords') { should eq ['x'] }
|
101
101
|
its('passwords') { should cmp '*' }
|
102
102
|
|
103
|
-
|
103
|
+
### shells
|
104
104
|
|
105
105
|
The `shells` matcher tests the absolute path of a shell (or command) to which a user has access:
|
106
106
|
|
@@ -112,7 +112,7 @@ or to find all users with the nologin shell:
|
|
112
112
|
its('users') { should_not include 'my_login_user' }
|
113
113
|
end
|
114
114
|
|
115
|
-
|
115
|
+
### uids
|
116
116
|
|
117
117
|
The `uids` matcher tests if the user indentifiers in the test match user identifiers in `/etc/passwd`:
|
118
118
|
|
@@ -125,24 +125,24 @@ or:
|
|
125
125
|
its('count') { should eq 1 }
|
126
126
|
end
|
127
127
|
|
128
|
-
|
128
|
+
### users
|
129
129
|
|
130
130
|
The `users` matcher tests if the user names in the test match user names in `/etc/passwd`:
|
131
131
|
|
132
132
|
its('users') { should eq ['root', 'www-data'] }
|
133
133
|
|
134
|
-
|
134
|
+
## Examples
|
135
135
|
|
136
136
|
The following examples show how to use this InSpec audit resource.
|
137
137
|
|
138
|
-
|
138
|
+
### Test usernames and UIDs
|
139
139
|
|
140
140
|
describe passwd do
|
141
141
|
its('users') { should eq ['root', 'www-data'] }
|
142
142
|
its('uids') { should eq [0, 33] }
|
143
143
|
end
|
144
144
|
|
145
|
-
|
145
|
+
### Select one user and test for multiple occurrences
|
146
146
|
|
147
147
|
describe passwd.uids(0) do
|
148
148
|
its('users') { should cmp 'root' }
|
@@ -19,7 +19,7 @@ These entries are defined as a colon-delimited row in the file, one row per user
|
|
19
19
|
|
20
20
|
dannos:Gb7crrO5CDF.:10063:0:99999:7:::
|
21
21
|
|
22
|
-
|
22
|
+
## Syntax
|
23
23
|
|
24
24
|
A `shadow` resource block declares one (or more) users and associated user information to be tested:
|
25
25
|
|
@@ -40,19 +40,19 @@ where
|
|
40
40
|
* `filter` one (or more) arguments, for example: `passwd.users(/name/)` used to define filtering; `filter` may take any of the following arguments: `count` (retrieves the number of entries), `lines` (provides raw `passwd` lines), and `params` (returns an array of maps for all entries)
|
41
41
|
|
42
42
|
|
43
|
-
|
43
|
+
## Matchers
|
44
44
|
|
45
45
|
This InSpec audit resource has the following matchers:
|
46
46
|
|
47
|
-
|
47
|
+
### be
|
48
48
|
|
49
49
|
<%= partial "/shared/matcher_be" %>
|
50
50
|
|
51
|
-
|
51
|
+
### cmp
|
52
52
|
|
53
53
|
<%= partial "/shared/matcher_cmp" %>
|
54
54
|
|
55
|
-
|
55
|
+
### count
|
56
56
|
|
57
57
|
The `count` matcher tests the number of times the named user appears in `/etc/shadow`:
|
58
58
|
|
@@ -64,49 +64,49 @@ TThis matcher is best used in conjunction with filters. For example:
|
|
64
64
|
its('count') { should eq 1 }
|
65
65
|
end
|
66
66
|
|
67
|
-
|
67
|
+
### eq
|
68
68
|
|
69
69
|
<%= partial "/shared/matcher_eq" %>
|
70
70
|
|
71
|
-
|
71
|
+
### expiry_dates
|
72
72
|
|
73
73
|
The `expiry_dates` matcher tests the number of days a user account has been disabled:
|
74
74
|
|
75
75
|
its('expiry_dates') { should eq '' }
|
76
76
|
|
77
|
-
|
77
|
+
### inactive_days
|
78
78
|
|
79
79
|
The `inactive_days` matcher tests the number of days a user must be inactive before the user account is disabled:
|
80
80
|
|
81
81
|
its('inactive_days') { should eq '' }
|
82
82
|
|
83
|
-
|
83
|
+
### include
|
84
84
|
|
85
85
|
<%= partial "/shared/matcher_include" %>
|
86
86
|
|
87
|
-
|
87
|
+
### last_changes
|
88
88
|
|
89
89
|
The `last_changes` matcher tests the last time a password was changed:
|
90
90
|
|
91
91
|
its('last_changes') { should eq '' }
|
92
92
|
|
93
|
-
|
93
|
+
### match
|
94
94
|
|
95
95
|
<%= partial "/shared/matcher_match" %>
|
96
96
|
|
97
|
-
|
97
|
+
### max_days
|
98
98
|
|
99
99
|
The `max_days` matcher tests the maximum number of days after which a password must be changed:
|
100
100
|
|
101
101
|
its('max_days') { should eq 90 }
|
102
102
|
|
103
|
-
|
103
|
+
### min_days
|
104
104
|
|
105
105
|
The `min_days` matcher tests the minimum number of days a password must exist, before it may be changed:
|
106
106
|
|
107
107
|
its('min_days') { should eq 0 }
|
108
108
|
|
109
|
-
|
109
|
+
### passwords
|
110
110
|
|
111
111
|
The `passwords` matcher tests if passwords are
|
112
112
|
|
@@ -119,29 +119,29 @@ For example:
|
|
119
119
|
its('passwords') { should eq ['x'] }
|
120
120
|
its('passwords') { should cmp '*' }
|
121
121
|
|
122
|
-
|
122
|
+
### users
|
123
123
|
|
124
124
|
The `users` matcher tests if the user name exists `/etc/shadow`:
|
125
125
|
|
126
126
|
its('users') { should eq 'root' }
|
127
127
|
|
128
|
-
|
128
|
+
### warn_days
|
129
129
|
|
130
130
|
The `warn_days` matcher tests the number of days a user is warned about an expiring password:
|
131
131
|
|
132
132
|
its('warn_days') { should eq 7 }
|
133
133
|
|
134
|
-
|
134
|
+
## Examples
|
135
135
|
|
136
136
|
The following examples show how to use this InSpec audit resource.
|
137
137
|
|
138
|
-
|
138
|
+
### Test for a forbidden user
|
139
139
|
|
140
140
|
describe shadow do
|
141
141
|
its('users') { should_not include 'forbidden_user' }
|
142
142
|
end
|
143
143
|
|
144
|
-
|
144
|
+
### Test that a user appears one time
|
145
145
|
|
146
146
|
describe shadow.users('bin') do
|
147
147
|
its('passwords') { should cmp 'x' }
|