inspec 1.0.0.beta2 → 1.0.0.beta3
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 +41 -2
- data/Gemfile +4 -0
- data/Rakefile +2 -1
- data/docs/.gitignore +2 -0
- data/docs/README.md +21 -1
- data/docs/resources/apache_conf.md.erb +75 -0
- data/docs/resources/apt.md.erb +84 -0
- data/docs/resources/audit_policy.md.erb +61 -0
- data/docs/resources/auditd_conf.md.erb +79 -0
- data/docs/resources/auditd_rules.md.erb +132 -0
- data/docs/resources/bash.md.erb +84 -0
- data/docs/resources/bond.md.erb +97 -0
- data/docs/resources/bridge.md.erb +67 -0
- data/docs/resources/bsd_service.md.erb +76 -0
- data/docs/resources/command.md.erb +151 -0
- data/docs/resources/csv.md.erb +62 -0
- data/docs/resources/directory.md.erb +43 -0
- data/docs/resources/etc_group.md.erb +116 -0
- data/docs/resources/etc_passwd.md.erb +155 -0
- data/docs/resources/etc_shadow.md.erb +149 -0
- data/docs/resources/file.md.erb +460 -0
- data/docs/resources/gem.md.erb +73 -0
- data/docs/resources/group.md.erb +74 -0
- data/docs/resources/grub_conf.md.erb +115 -0
- data/docs/resources/host.md.erb +85 -0
- data/docs/resources/iis_site.md.erb +142 -0
- data/docs/resources/inetd_conf.md.erb +99 -0
- data/docs/resources/ini.md.erb +69 -0
- data/docs/resources/interface.md.erb +66 -0
- data/docs/resources/iptables.md.erb +70 -0
- data/docs/resources/json.md.erb +76 -0
- data/docs/resources/kernel_module.md.erb +60 -0
- data/docs/resources/kernel_parameter.md.erb +72 -0
- data/docs/resources/launchd_service.md.erb +76 -0
- data/docs/resources/limits_conf.md.erb +80 -0
- data/docs/resources/login_def.md.erb +77 -0
- data/docs/resources/mount.md.erb +83 -0
- data/docs/resources/mysql_conf.md.erb +102 -0
- data/docs/resources/mysql_session.md.erb +63 -0
- data/docs/resources/npm.md.erb +75 -0
- data/docs/resources/ntp_conf.md.erb +76 -0
- data/docs/resources/oneget.md.erb +67 -0
- data/docs/resources/os.md.erb +154 -0
- data/docs/resources/os_env.md.erb +98 -0
- data/docs/resources/package.md.erb +115 -0
- data/docs/resources/parse_config.md.erb +122 -0
- data/docs/resources/parse_config_file.md.erb +143 -0
- data/docs/resources/pip.md.erb +74 -0
- data/docs/resources/port.md.erb +150 -0
- data/docs/resources/postgres_conf.md.erb +90 -0
- data/docs/resources/postgres_session.md.erb +75 -0
- data/docs/resources/powershell.md.erb +116 -0
- data/docs/resources/process.md.erb +73 -0
- data/docs/resources/registry_key.md.erb +149 -0
- data/docs/resources/runit_service.md.erb +76 -0
- data/docs/resources/security_policy.md.erb +61 -0
- data/docs/resources/service.md.erb +135 -0
- data/docs/resources/ssh_config.md.erb +94 -0
- data/docs/resources/sshd_config.md.erb +97 -0
- data/docs/resources/ssl.md.erb +133 -0
- data/docs/resources/sys_info.md.erb +55 -0
- data/docs/resources/systemd_service.md.erb +76 -0
- data/docs/resources/sysv_service.md.erb +76 -0
- data/docs/resources/upstart_service.md.erb +76 -0
- data/docs/resources/user.md.erb +154 -0
- data/docs/resources/users.md.erb +140 -0
- data/docs/resources/vbscript.md.erb +69 -0
- data/docs/resources/windows_feature.md.erb +61 -0
- data/docs/resources/wmi.md.erb +95 -0
- data/docs/resources/xinetd_conf.md.erb +170 -0
- data/docs/resources/yaml.md.erb +69 -0
- data/docs/resources/yum.md.erb +103 -0
- data/docs/ruby_usage.md +154 -0
- data/docs/shared/matcher_be.md.erb +1 -0
- data/docs/shared/matcher_cmp.md.erb +45 -0
- data/docs/shared/matcher_eq.md.erb +3 -0
- data/docs/shared/matcher_include.md.erb +1 -0
- data/docs/shared/matcher_match.md.erb +1 -0
- data/lib/fetchers/url.rb +27 -29
- data/lib/inspec/cached_fetcher.rb +67 -0
- data/lib/inspec/dependencies/requirement.rb +6 -7
- data/lib/inspec/objects/each_loop.rb +5 -2
- data/lib/inspec/plugins/fetcher.rb +2 -0
- data/lib/inspec/profile.rb +9 -41
- data/lib/inspec/resource.rb +1 -1
- data/lib/inspec/rspec_json_formatter.rb +11 -5
- data/lib/inspec/version.rb +1 -1
- data/lib/resources/groups.rb +190 -0
- data/lib/resources/users.rb +3 -2
- metadata +79 -6
- data/docs/cli.rst +0 -448
- data/docs/resources.rst +0 -4836
- data/docs/ruby_usage.rst +0 -145
- data/lib/resources/group.rb +0 -137
@@ -0,0 +1,62 @@
|
|
1
|
+
---
|
2
|
+
title: About the csv Resource
|
3
|
+
---
|
4
|
+
|
5
|
+
# csv
|
6
|
+
|
7
|
+
Use the `csv` InSpec audit resource to test configuration data in a CSV file.
|
8
|
+
|
9
|
+
# Syntax
|
10
|
+
|
11
|
+
A `csv` resource block declares the configuration data to be tested:
|
12
|
+
|
13
|
+
describe csv('file') do
|
14
|
+
its('name') { should eq 'foo' }
|
15
|
+
end
|
16
|
+
|
17
|
+
where
|
18
|
+
|
19
|
+
* `'file'` is the path to a CSV file
|
20
|
+
* `name` is a configuration setting in a CSV file
|
21
|
+
* `should eq 'foo'` tests a value of `name` as read from a CSV file versus the value declared in the test
|
22
|
+
|
23
|
+
|
24
|
+
# Matchers
|
25
|
+
|
26
|
+
This InSpec audit resource has the following matchers:
|
27
|
+
|
28
|
+
## be
|
29
|
+
|
30
|
+
<%= partial "/shared/matcher_be" %>
|
31
|
+
|
32
|
+
## cmp
|
33
|
+
|
34
|
+
<%= partial "/shared/matcher_cmp" %>
|
35
|
+
|
36
|
+
## eq
|
37
|
+
|
38
|
+
<%= partial "/shared/matcher_eq" %>
|
39
|
+
|
40
|
+
## include
|
41
|
+
|
42
|
+
<%= partial "/shared/matcher_include" %>
|
43
|
+
|
44
|
+
## match
|
45
|
+
|
46
|
+
<%= partial "/shared/matcher_match" %>
|
47
|
+
|
48
|
+
## name
|
49
|
+
|
50
|
+
The `name` matcher tests the value of `name` as read from a CSV file versus the value declared in the test:
|
51
|
+
|
52
|
+
its('name') { should eq 'foo' }
|
53
|
+
|
54
|
+
# Examples
|
55
|
+
|
56
|
+
The following examples show how to use this InSpec audit resource.
|
57
|
+
|
58
|
+
## Test a CSV file
|
59
|
+
|
60
|
+
describe csv('some_file.csv') do
|
61
|
+
its('setting') { should eq 1 }
|
62
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
---
|
2
|
+
title: About the directory Resource
|
3
|
+
---
|
4
|
+
|
5
|
+
# directory
|
6
|
+
|
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
|
+
|
9
|
+
# Syntax
|
10
|
+
|
11
|
+
A `directory` resource block declares the location of the directory to be tested, and then one (or more) matchers:
|
12
|
+
|
13
|
+
describe directory('path') do
|
14
|
+
it { should MATCHER 'value' }
|
15
|
+
end
|
16
|
+
|
17
|
+
# Matchers
|
18
|
+
|
19
|
+
This resource may use any of the matchers available to the `file` resource that may be useful when testing a directory.
|
20
|
+
|
21
|
+
## be
|
22
|
+
|
23
|
+
<%= partial "/shared/matcher_be" %>
|
24
|
+
|
25
|
+
## cmp
|
26
|
+
|
27
|
+
<%= partial "/shared/matcher_cmp" %>
|
28
|
+
|
29
|
+
## eq
|
30
|
+
|
31
|
+
<%= partial "/shared/matcher_eq" %>
|
32
|
+
|
33
|
+
## include
|
34
|
+
|
35
|
+
<%= partial "/shared/matcher_include" %>
|
36
|
+
|
37
|
+
## match
|
38
|
+
|
39
|
+
<%= partial "/shared/matcher_match" %>
|
40
|
+
|
41
|
+
# Examples
|
42
|
+
|
43
|
+
None.
|
@@ -0,0 +1,116 @@
|
|
1
|
+
---
|
2
|
+
title: About the etc_group Resource
|
3
|
+
---
|
4
|
+
|
5
|
+
# etc_group
|
6
|
+
|
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
|
+
|
9
|
+
# Syntax
|
10
|
+
|
11
|
+
A `etc_group` resource block declares a collection of properties to be tested:
|
12
|
+
|
13
|
+
describe etc_group('path') do
|
14
|
+
its('matcher') { should eq 'some_value' }
|
15
|
+
end
|
16
|
+
|
17
|
+
or:
|
18
|
+
|
19
|
+
describe etc_group.where(item: 'value', item: 'value') do
|
20
|
+
its('gids') { should_not contain_duplicates }
|
21
|
+
its('groups') { should include 'user_name' }
|
22
|
+
its('users') { should include 'user_name' }
|
23
|
+
end
|
24
|
+
|
25
|
+
where
|
26
|
+
|
27
|
+
* `('path')` is the non-default path to the `inetd.conf` file
|
28
|
+
* `.where()` may specify a specific item and value, to which the matchers are compared
|
29
|
+
* `'gids'`, `'groups'`, and `'users'` are valid matchers for this resource
|
30
|
+
|
31
|
+
# Matchers
|
32
|
+
|
33
|
+
This InSpec audit resource has the following matchers:
|
34
|
+
|
35
|
+
## be
|
36
|
+
|
37
|
+
<%= partial "/shared/matcher_be" %>
|
38
|
+
|
39
|
+
## cmp
|
40
|
+
|
41
|
+
<%= partial "/shared/matcher_cmp" %>
|
42
|
+
|
43
|
+
## eq
|
44
|
+
|
45
|
+
<%= partial "/shared/matcher_eq" %>
|
46
|
+
|
47
|
+
## gids
|
48
|
+
|
49
|
+
The `gids` matcher tests if the named group identifier is present or if it contains duplicates:
|
50
|
+
|
51
|
+
its('gids') { should_not contain_duplicates }
|
52
|
+
|
53
|
+
## groups
|
54
|
+
|
55
|
+
The `groups` matcher tests all groups for the named user:
|
56
|
+
|
57
|
+
its('groups') { should include 'my_group' }
|
58
|
+
|
59
|
+
## include
|
60
|
+
|
61
|
+
<%= partial "/shared/matcher_include" %>
|
62
|
+
|
63
|
+
## match
|
64
|
+
|
65
|
+
<%= partial "/shared/matcher_match" %>
|
66
|
+
|
67
|
+
## users
|
68
|
+
|
69
|
+
The `users` matcher tests all groups for the named user:
|
70
|
+
|
71
|
+
its('users') { should include 'my_user' }
|
72
|
+
|
73
|
+
## where
|
74
|
+
|
75
|
+
The `where` matcher allows the test to be focused to one (or more) specific items:
|
76
|
+
|
77
|
+
etc_group.where(item: 'value', item: 'value')
|
78
|
+
|
79
|
+
where `item` may be one (or more) of:
|
80
|
+
|
81
|
+
* `name: 'name'`
|
82
|
+
* `group_name: 'group_name'`
|
83
|
+
* `password: 'password'`
|
84
|
+
* `gid: 'gid'`
|
85
|
+
* `group_id: 'gid'`
|
86
|
+
* `users: 'user_name'`
|
87
|
+
* `members: 'member_name'`
|
88
|
+
|
89
|
+
|
90
|
+
# Examples
|
91
|
+
|
92
|
+
The following examples show how to use this InSpec audit resource.
|
93
|
+
|
94
|
+
## Test group identifiers (GIDs) for duplicates
|
95
|
+
|
96
|
+
describe etc_group do
|
97
|
+
its('gids') { should_not contain_duplicates }
|
98
|
+
end
|
99
|
+
|
100
|
+
## Test all groups to see if a specific user belongs to one (or more) groups
|
101
|
+
|
102
|
+
describe etc_group do
|
103
|
+
its('groups') { should include 'my_group' }
|
104
|
+
end
|
105
|
+
|
106
|
+
## Test all groups for a specific user name
|
107
|
+
|
108
|
+
describe etc_group do
|
109
|
+
its('users') { should include 'my_user' }
|
110
|
+
end
|
111
|
+
|
112
|
+
## Filter a list of groups for a specific user
|
113
|
+
|
114
|
+
describe etc_group.where(name: 'my_group') do
|
115
|
+
its('users') { should include 'my_user' }
|
116
|
+
end
|
@@ -0,0 +1,155 @@
|
|
1
|
+
---
|
2
|
+
title: About the passwd Resource
|
3
|
+
---
|
4
|
+
|
5
|
+
# passwd
|
6
|
+
|
7
|
+
Use the `passwd` InSpec audit resource to test the contents of `/etc/passwd`, which contains the following information for users that may log into the system and/or as users that own running processes. The format for `/etc/passwd` includes:
|
8
|
+
|
9
|
+
* A username
|
10
|
+
* The password for that user (on newer systems passwords should be stored in `/etc/shadow` )
|
11
|
+
* The user identifier (UID) assigned to that user
|
12
|
+
* The group identifier (GID) assigned to that user
|
13
|
+
* Additional information about that user
|
14
|
+
* That user's home directory
|
15
|
+
* That user's default command shell
|
16
|
+
|
17
|
+
These entries are defined as a colon-delimited row in the file, one row per user:
|
18
|
+
|
19
|
+
root:x:1234:5678:additional_info:/home/dir/:/bin/bash
|
20
|
+
|
21
|
+
# Syntax
|
22
|
+
|
23
|
+
A `passwd` resource block declares one (or more) users and associated user information to be tested:
|
24
|
+
|
25
|
+
describe passwd do
|
26
|
+
its('users') { should_not include 'forbidden_user' }
|
27
|
+
end
|
28
|
+
|
29
|
+
describe passwd.uid(filter) do
|
30
|
+
its('users') { should cmp 'root' }
|
31
|
+
its('count') { should eq 1 }
|
32
|
+
end
|
33
|
+
|
34
|
+
where
|
35
|
+
|
36
|
+
* `homes`, `gids`, `passwords`, `shells`, `uids`, and `users` are valid accessors for `passwd`
|
37
|
+
* `filter` one (or more) arguments, for example: `passwd.users(/name/)` used to define filtering
|
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
|
+
|
40
|
+
|
41
|
+
# Matchers
|
42
|
+
|
43
|
+
This InSpec audit resource has the following matchers:
|
44
|
+
|
45
|
+
## be
|
46
|
+
|
47
|
+
<%= partial "/shared/matcher_be" %>
|
48
|
+
|
49
|
+
## cmp
|
50
|
+
|
51
|
+
<%= partial "/shared/matcher_cmp" %>
|
52
|
+
|
53
|
+
## eq
|
54
|
+
|
55
|
+
<%= partial "/shared/matcher_eq" %>
|
56
|
+
|
57
|
+
## gids
|
58
|
+
|
59
|
+
The `gids` matcher tests if the group indentifiers in the test match group identifiers in `/etc/passwd`:
|
60
|
+
|
61
|
+
its('gids') { should include 1234 }
|
62
|
+
its('gids') { should cmp 0 }
|
63
|
+
|
64
|
+
## homes
|
65
|
+
|
66
|
+
The `homes` matcher tests the absolute path to a user's home directory:
|
67
|
+
|
68
|
+
its('home') { should eq '/' }
|
69
|
+
|
70
|
+
## include
|
71
|
+
|
72
|
+
<%= partial "/shared/matcher_include" %>
|
73
|
+
|
74
|
+
## length
|
75
|
+
|
76
|
+
The `length` matcher tests the length of a password that appears in `/etc/passwd`:
|
77
|
+
|
78
|
+
its('length') { should be <= 32 }
|
79
|
+
|
80
|
+
This matcher is best used in conjunction with filters. For example:
|
81
|
+
|
82
|
+
describe passwd.users('highlander') do
|
83
|
+
its('length') { should_not be < 16 }
|
84
|
+
end
|
85
|
+
|
86
|
+
## match
|
87
|
+
|
88
|
+
<%= partial "/shared/matcher_match" %>
|
89
|
+
|
90
|
+
## passwords
|
91
|
+
|
92
|
+
The `passwords` matcher tests if passwords are
|
93
|
+
|
94
|
+
* Encrypted
|
95
|
+
* Have direct logins disabled, as indicated by an asterisk (`*`)
|
96
|
+
* In the `/etc/shadow` file, as indicated by the letter x (`x`)
|
97
|
+
|
98
|
+
For example:
|
99
|
+
|
100
|
+
its('passwords') { should eq ['x'] }
|
101
|
+
its('passwords') { should cmp '*' }
|
102
|
+
|
103
|
+
## shells
|
104
|
+
|
105
|
+
The `shells` matcher tests the absolute path of a shell (or command) to which a user has access:
|
106
|
+
|
107
|
+
its('shells') { should_not include 'user' }
|
108
|
+
|
109
|
+
or to find all users with the nologin shell:
|
110
|
+
|
111
|
+
describe passwd.shells(/nologin/) do
|
112
|
+
its('users') { should_not include 'my_login_user' }
|
113
|
+
end
|
114
|
+
|
115
|
+
## uids
|
116
|
+
|
117
|
+
The `uids` matcher tests if the user indentifiers in the test match user identifiers in `/etc/passwd`:
|
118
|
+
|
119
|
+
its('uids') { should eq ['1234', '1235'] }
|
120
|
+
|
121
|
+
or:
|
122
|
+
|
123
|
+
describe passwd.uids(0) do
|
124
|
+
its('users') { should cmp 'root' }
|
125
|
+
its('count') { should eq 1 }
|
126
|
+
end
|
127
|
+
|
128
|
+
## users
|
129
|
+
|
130
|
+
The `users` matcher tests if the user names in the test match user names in `/etc/passwd`:
|
131
|
+
|
132
|
+
its('users') { should eq ['root', 'www-data'] }
|
133
|
+
|
134
|
+
# Examples
|
135
|
+
|
136
|
+
The following examples show how to use this InSpec audit resource.
|
137
|
+
|
138
|
+
## Test usernames and UIDs
|
139
|
+
|
140
|
+
describe passwd do
|
141
|
+
its('users') { should eq ['root', 'www-data'] }
|
142
|
+
its('uids') { should eq [0, 33] }
|
143
|
+
end
|
144
|
+
|
145
|
+
## Select one user and test for multiple occurrences
|
146
|
+
|
147
|
+
describe passwd.uids(0) do
|
148
|
+
its('users') { should cmp 'root' }
|
149
|
+
its('count') { should eq 1 }
|
150
|
+
end
|
151
|
+
|
152
|
+
describe passwd.filter(user: 'www-data') do
|
153
|
+
its('uids') { should cmp 33 }
|
154
|
+
its('count') { should eq 1 }
|
155
|
+
end
|
@@ -0,0 +1,149 @@
|
|
1
|
+
---
|
2
|
+
title: About the shadow Resource
|
3
|
+
---
|
4
|
+
|
5
|
+
# shadow
|
6
|
+
|
7
|
+
Use the `shadow` InSpec audit resource to test the contents of `/etc/shadow`, which contains password details that are only readable by the `root` user. The format for `/etc/shadow` includes:
|
8
|
+
|
9
|
+
* A username
|
10
|
+
* The password for that user (on newer systems passwords should be stored in `/etc/shadow` )
|
11
|
+
* The last time a password was changed
|
12
|
+
* The minimum number of days a password must exist, before it may be changed
|
13
|
+
* The maximum number of days after which a password must be changed
|
14
|
+
* The number of days a user is warned about an expiring password
|
15
|
+
* The number of days a user must be inactive before the user account is disabled
|
16
|
+
* The number of days a user account has been disabled
|
17
|
+
|
18
|
+
These entries are defined as a colon-delimited row in the file, one row per user:
|
19
|
+
|
20
|
+
dannos:Gb7crrO5CDF.:10063:0:99999:7:::
|
21
|
+
|
22
|
+
# Syntax
|
23
|
+
|
24
|
+
A `shadow` resource block declares one (or more) users and associated user information to be tested:
|
25
|
+
|
26
|
+
describe shadow do
|
27
|
+
its('users') { should_not include 'forbidden_user' }
|
28
|
+
end
|
29
|
+
|
30
|
+
or with a filter:
|
31
|
+
|
32
|
+
describe shadow.uid(filter) do
|
33
|
+
its('users') { should cmp 'root' }
|
34
|
+
its('count') { should eq 1 }
|
35
|
+
end
|
36
|
+
|
37
|
+
where
|
38
|
+
|
39
|
+
* `homes`, `gids`, `passwords`, `shells`, `uids`, and `users` are valid accessors for `passwd`
|
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
|
+
|
42
|
+
|
43
|
+
# Matchers
|
44
|
+
|
45
|
+
This InSpec audit resource has the following matchers:
|
46
|
+
|
47
|
+
## be
|
48
|
+
|
49
|
+
<%= partial "/shared/matcher_be" %>
|
50
|
+
|
51
|
+
## cmp
|
52
|
+
|
53
|
+
<%= partial "/shared/matcher_cmp" %>
|
54
|
+
|
55
|
+
## count
|
56
|
+
|
57
|
+
The `count` matcher tests the number of times the named user appears in `/etc/shadow`:
|
58
|
+
|
59
|
+
its('count') { should eq 1 }
|
60
|
+
|
61
|
+
TThis matcher is best used in conjunction with filters. For example:
|
62
|
+
|
63
|
+
describe shadow.users('dannos') do
|
64
|
+
its('count') { should eq 1 }
|
65
|
+
end
|
66
|
+
|
67
|
+
## eq
|
68
|
+
|
69
|
+
<%= partial "/shared/matcher_eq" %>
|
70
|
+
|
71
|
+
## expiry_dates
|
72
|
+
|
73
|
+
The `expiry_dates` matcher tests the number of days a user account has been disabled:
|
74
|
+
|
75
|
+
its('expiry_dates') { should eq '' }
|
76
|
+
|
77
|
+
## inactive_days
|
78
|
+
|
79
|
+
The `inactive_days` matcher tests the number of days a user must be inactive before the user account is disabled:
|
80
|
+
|
81
|
+
its('inactive_days') { should eq '' }
|
82
|
+
|
83
|
+
## include
|
84
|
+
|
85
|
+
<%= partial "/shared/matcher_include" %>
|
86
|
+
|
87
|
+
## last_changes
|
88
|
+
|
89
|
+
The `last_changes` matcher tests the last time a password was changed:
|
90
|
+
|
91
|
+
its('last_changes') { should eq '' }
|
92
|
+
|
93
|
+
## match
|
94
|
+
|
95
|
+
<%= partial "/shared/matcher_match" %>
|
96
|
+
|
97
|
+
## max_days
|
98
|
+
|
99
|
+
The `max_days` matcher tests the maximum number of days after which a password must be changed:
|
100
|
+
|
101
|
+
its('max_days') { should eq 90 }
|
102
|
+
|
103
|
+
## min_days
|
104
|
+
|
105
|
+
The `min_days` matcher tests the minimum number of days a password must exist, before it may be changed:
|
106
|
+
|
107
|
+
its('min_days') { should eq 0 }
|
108
|
+
|
109
|
+
## passwords
|
110
|
+
|
111
|
+
The `passwords` matcher tests if passwords are
|
112
|
+
|
113
|
+
* Encrypted
|
114
|
+
* Have direct logins disabled, as indicated by an asterisk (`*`)
|
115
|
+
* In the `/etc/shadow` file, as indicated by the letter x (`x`)
|
116
|
+
|
117
|
+
For example:
|
118
|
+
|
119
|
+
its('passwords') { should eq ['x'] }
|
120
|
+
its('passwords') { should cmp '*' }
|
121
|
+
|
122
|
+
## users
|
123
|
+
|
124
|
+
The `users` matcher tests if the user name exists `/etc/shadow`:
|
125
|
+
|
126
|
+
its('users') { should eq 'root' }
|
127
|
+
|
128
|
+
## warn_days
|
129
|
+
|
130
|
+
The `warn_days` matcher tests the number of days a user is warned about an expiring password:
|
131
|
+
|
132
|
+
its('warn_days') { should eq 7 }
|
133
|
+
|
134
|
+
# Examples
|
135
|
+
|
136
|
+
The following examples show how to use this InSpec audit resource.
|
137
|
+
|
138
|
+
## Test for a forbidden user
|
139
|
+
|
140
|
+
describe shadow do
|
141
|
+
its('users') { should_not include 'forbidden_user' }
|
142
|
+
end
|
143
|
+
|
144
|
+
## Test that a user appears one time
|
145
|
+
|
146
|
+
describe shadow.users('bin') do
|
147
|
+
its('passwords') { should cmp 'x' }
|
148
|
+
its('count') { should eq 1 }
|
149
|
+
end
|