inspec 1.51.0 → 1.51.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (111) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +29 -15
  3. data/README.md +1 -1
  4. data/docs/glossary.md +99 -0
  5. data/docs/resources/aide_conf.md.erb +16 -9
  6. data/docs/resources/apache.md.erb +66 -0
  7. data/docs/resources/apache_conf.md.erb +11 -5
  8. data/docs/resources/apt.md.erb +1 -1
  9. data/docs/resources/audit_policy.md.erb +1 -1
  10. data/docs/resources/auditd_conf.md.erb +12 -9
  11. data/docs/resources/bash.md.erb +24 -12
  12. data/docs/resources/bond.md.erb +26 -24
  13. data/docs/resources/bridge.md.erb +18 -11
  14. data/docs/resources/bsd_service.md.erb +11 -2
  15. data/docs/resources/command.md.erb +30 -29
  16. data/docs/resources/cpan.md.erb +33 -17
  17. data/docs/resources/cran.md.erb +26 -17
  18. data/docs/resources/crontab.md.erb +18 -1
  19. data/docs/resources/csv.md.erb +13 -7
  20. data/docs/resources/{dh_params.md → dh_params.md.erb} +30 -6
  21. data/docs/resources/directory.md.erb +9 -4
  22. data/docs/resources/docker.md.erb +1 -1
  23. data/docs/resources/docker_container.md.erb +32 -26
  24. data/docs/resources/docker_image.md.erb +29 -26
  25. data/docs/resources/docker_service.md.erb +37 -31
  26. data/docs/resources/elasticsearch.md.erb +18 -32
  27. data/docs/resources/etc_fstab.md.erb +19 -15
  28. data/docs/resources/etc_group.md.erb +13 -39
  29. data/docs/resources/etc_hosts.md.erb +12 -5
  30. data/docs/resources/etc_hosts_allow.md.erb +9 -4
  31. data/docs/resources/etc_hosts_deny.md.erb +12 -7
  32. data/docs/resources/file.md.erb +139 -134
  33. data/docs/resources/filesystem.md.erb +5 -4
  34. data/docs/resources/firewalld.md.erb +1 -1
  35. data/docs/resources/gem.md.erb +2 -2
  36. data/docs/resources/group.md.erb +1 -1
  37. data/docs/resources/host.md.erb +1 -1
  38. data/docs/resources/iis_app.md.erb +1 -1
  39. data/docs/resources/iis_site.md.erb +1 -1
  40. data/docs/resources/interface.md.erb +1 -1
  41. data/docs/resources/iptables.md.erb +1 -1
  42. data/docs/resources/json.md.erb +1 -1
  43. data/docs/resources/kernel_module.md.erb +1 -1
  44. data/docs/resources/kernel_parameter.md.erb +1 -1
  45. data/docs/resources/launchd_service.md.erb +1 -1
  46. data/docs/resources/limits_conf.md.erb +1 -1
  47. data/docs/resources/login_def.md.erb +1 -1
  48. data/docs/resources/mount.md.erb +1 -1
  49. data/docs/resources/mysql_conf.md.erb +1 -1
  50. data/docs/resources/nginx_conf.md.erb +1 -1
  51. data/docs/resources/npm.md.erb +1 -1
  52. data/docs/resources/oneget.md.erb +1 -1
  53. data/docs/resources/os.md.erb +1 -1
  54. data/docs/resources/os_env.md.erb +2 -2
  55. data/docs/resources/package.md.erb +1 -1
  56. data/docs/resources/packages.md.erb +66 -0
  57. data/docs/resources/parse_config.md.erb +1 -1
  58. data/docs/resources/parse_config_file.md.erb +1 -1
  59. data/docs/resources/passwd.md.erb +1 -1
  60. data/docs/resources/pip.md.erb +1 -1
  61. data/docs/resources/port.md.erb +1 -1
  62. data/docs/resources/postgres_conf.md.erb +1 -1
  63. data/docs/resources/postgres_session.md.erb +1 -1
  64. data/docs/resources/powershell.md.erb +2 -2
  65. data/docs/resources/processes.md.erb +1 -1
  66. data/docs/resources/registry_key.md.erb +1 -1
  67. data/docs/resources/runit_service.md.erb +1 -1
  68. data/docs/resources/security_policy.md.erb +1 -1
  69. data/docs/resources/service.md.erb +1 -1
  70. data/docs/resources/shadow.md.erb +1 -1
  71. data/docs/resources/ssh_config.md.erb +1 -1
  72. data/docs/resources/sshd_config.md.erb +1 -1
  73. data/docs/resources/ssl.md.erb +1 -1
  74. data/docs/resources/sys_info.md.erb +1 -1
  75. data/docs/resources/systemd_service.md.erb +1 -1
  76. data/docs/resources/sysv_service.md.erb +1 -1
  77. data/docs/resources/upstart_service.md.erb +1 -1
  78. data/docs/resources/user.md.erb +1 -1
  79. data/docs/resources/users.md.erb +1 -1
  80. data/docs/resources/windows_feature.md.erb +1 -1
  81. data/docs/resources/windows_hotfix.md.erb +1 -1
  82. data/docs/resources/xinetd_conf.md.erb +1 -1
  83. data/docs/resources/xml.md.erb +1 -1
  84. data/docs/resources/yaml.md.erb +1 -1
  85. data/docs/resources/yum.md.erb +1 -1
  86. data/lib/inspec.rb +2 -1
  87. data/lib/inspec/base_cli.rb +98 -18
  88. data/lib/inspec/cli.rb +33 -21
  89. data/lib/inspec/formatters.rb +3 -0
  90. data/lib/inspec/formatters/base.rb +208 -0
  91. data/lib/inspec/formatters/json_rspec.rb +20 -0
  92. data/lib/inspec/formatters/show_progress.rb +12 -0
  93. data/lib/inspec/objects.rb +1 -0
  94. data/lib/inspec/objects/describe.rb +92 -0
  95. data/lib/inspec/reporters.rb +33 -0
  96. data/lib/inspec/reporters/base.rb +23 -0
  97. data/lib/inspec/reporters/cli.rb +395 -0
  98. data/lib/inspec/reporters/json.rb +132 -0
  99. data/lib/inspec/reporters/json_min.rb +44 -0
  100. data/lib/inspec/reporters/junit.rb +77 -0
  101. data/lib/inspec/runner.rb +14 -1
  102. data/lib/inspec/runner_rspec.rb +34 -14
  103. data/lib/inspec/schema.rb +1 -0
  104. data/lib/inspec/shell.rb +0 -1
  105. data/lib/inspec/version.rb +1 -1
  106. data/lib/resources/apache.rb +20 -0
  107. data/lib/resources/apache_conf.rb +33 -8
  108. data/lib/resources/audit_policy.rb +1 -1
  109. data/lib/resources/packages.rb +4 -3
  110. metadata +17 -4
  111. data/lib/inspec/rspec_json_formatter.rb +0 -940
@@ -4,7 +4,7 @@ title: About the etc_fstab Resource
4
4
 
5
5
  # etc_fstab
6
6
 
7
- Use the `etc_fstab` InSpec audit resource to test information about all partitions and storage devices on a system.
7
+ Use the `etc_fstab` InSpec audit resource to test information about all partitions and storage devices on a Linux system.
8
8
 
9
9
  <br>
10
10
 
@@ -13,7 +13,7 @@ Use the `etc_fstab` InSpec audit resource to test information about all partitio
13
13
  An etc_fstab rule specifies a device name, its mount point, its mount type, the options its mounted with,
14
14
  its dump options, and the order the files system should be checked.
15
15
 
16
- Use the where clause to match a property to one or more rules in the fstab file.
16
+ Use the where clause to match a property to one or more rules in the fstab file:
17
17
 
18
18
  describe etc_fstab.where { device_name == 'value' } do
19
19
  its('mount_point') { should cmp 'hostname' }
@@ -23,7 +23,7 @@ Use the where clause to match a property to one or more rules in the fstab file.
23
23
  its('file_system_options') { should cmp 'list' }
24
24
  end
25
25
 
26
- Use the optional constructor parameter to give an alternative path to fstab file
26
+ Use the optional constructor parameter to give an alternative path to fstab file:
27
27
 
28
28
  describe etc_fstab(hosts_path).where { device_name == 'value' } do
29
29
  its('mount_point') { should cmp 'hostname' }
@@ -33,7 +33,9 @@ Use the optional constructor parameter to give an alternative path to fstab file
33
33
  its('file_system_options') { should cmp 'list ' }
34
34
  end
35
35
 
36
- where
36
+ <br>
37
+
38
+ ## Supported Resource Properties
37
39
 
38
40
  * `device_name` is the name associated with the device.
39
41
  * `mount_point` is the directory at which the filesystem is configured to be mounted.
@@ -42,7 +44,9 @@ where
42
44
  * `dump_options` is a number used by dump to decide if a file system should be backed up.
43
45
  * `file_system_options` is a number that specifies the order the file system should be checked.
44
46
 
45
- ## Property Examples and Return Types
47
+ <br>
48
+
49
+ ## Property Examples
46
50
 
47
51
  ### device_name
48
52
 
@@ -60,7 +64,7 @@ where
60
64
  its('mount_point') { should cmp '/mnt/sr0' }
61
65
  end
62
66
 
63
- ### file_system_type
67
+ ### file\_system_type
64
68
 
65
69
  `file_system_type` returns a String array of each partitions file system type.
66
70
 
@@ -92,13 +96,7 @@ where
92
96
  its('file_system_options') { should cmp 0 }
93
97
  end
94
98
 
95
- <br>
96
-
97
- ## Examples
98
-
99
- The following examples show how to use this InSpec resource.
100
-
101
- ### Check all partitions that have type of 'nfs'.
99
+ ### Check all partitions that have type of 'nfs'
102
100
 
103
101
  nfs_systems = etc_fstab.nfs_file_systems.entries
104
102
  nfs_systems.each do |partition|
@@ -107,14 +105,20 @@ The following examples show how to use this InSpec resource.
107
105
  end
108
106
  end
109
107
 
110
- ### Check the partition mounted at /home contains 'nosuid' in its mount_options.
108
+ ### Check the partition mounted at /home contains 'nosuid' in its mount_options
111
109
 
112
110
  describe etc_fstab do
113
111
  its('home_mount_options') { should include 'nosuid' }
114
112
  end
115
113
 
116
- ### Check if a partition is mounted at a point.
114
+ ### Check if a partition is mounted at a point
117
115
 
118
116
  describe etc_fstab.where { mount_point == '/home' } do
119
117
  it { should be_configured }
120
118
  end
119
+
120
+ <br>
121
+
122
+ ## Matchers
123
+
124
+ For a full list of available matchers please visit our [matchers page](https://www.inspec.io/docs/reference/matchers/).
@@ -4,7 +4,7 @@ title: About the etc_group Resource
4
4
 
5
5
  # etc_group
6
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.
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
  <br>
10
10
 
@@ -13,7 +13,7 @@ Use the `etc_group` InSpec audit resource to test groups that are defined on Lin
13
13
  A `etc_group` resource block declares a collection of properties to be tested:
14
14
 
15
15
  describe etc_group('path') do
16
- its('matcher') { should eq 'some_value' }
16
+ its('property') { should eq 'some_value' }
17
17
  end
18
18
 
19
19
  or:
@@ -27,11 +27,18 @@ or:
27
27
  where
28
28
 
29
29
  * `('path')` is the non-default path to the `inetd.conf` file
30
- * `.where()` may specify a specific item and value, to which the matchers are compared
31
- * `'gids'`, `'groups'`, and `'users'` are valid matchers for this resource
30
+ * `.where()` filters for a specific item and value, to which the parameter are compared
31
+ * `.where` filter may be one or more of:
32
+ * `name: 'name'`, `group_name: 'group_name'`, `password: 'password'`, `gid: 'gid'`, `group_id: 'gid'`, `users: 'user_name'`, `members: 'member_name'`
33
+ <br>
34
+
35
+ ## Supported Resource parameters
32
36
 
37
+ * `'gids'`, `'groups'`, and `'users'` are valid resource parameters for this resource.
33
38
 
34
- ## Examples
39
+ <br>
40
+
41
+ ## Resource Parameter Examples
35
42
 
36
43
  The following examples show how to use this InSpec audit resource.
37
44
 
@@ -63,38 +70,5 @@ The following examples show how to use this InSpec audit resource.
63
70
 
64
71
  ## Matchers
65
72
 
66
- This InSpec audit resource has the following matchers. For a full list of available matchers please visit our [matchers page](https://www.inspec.io/docs/reference/matchers/).
67
-
68
- ### gids
69
-
70
- The `gids` matcher tests if the named group identifier is present or if it contains duplicates:
71
-
72
- its('gids') { should_not contain_duplicates }
73
-
74
- ### groups
75
-
76
- The `groups` matcher tests all groups for the named user:
77
-
78
- its('groups') { should include 'my_group' }
79
-
80
- ### users
81
-
82
- The `users` matcher tests all groups for the named user:
83
-
84
- its('users') { should include 'my_user' }
85
-
86
- ### where
87
-
88
- The `where` matcher allows the test to be focused to one (or more) specific items:
89
-
90
- etc_group.where(item: 'value', item: 'value')
91
-
92
- where `item` may be one (or more) of:
73
+ For a full list of available matchers please visit our [matchers page](https://www.inspec.io/docs/reference/matchers/).
93
74
 
94
- * `name: 'name'`
95
- * `group_name: 'group_name'`
96
- * `password: 'password'`
97
- * `gid: 'gid'`
98
- * `group_id: 'gid'`
99
- * `users: 'user_name'`
100
- * `members: 'member_name'`
@@ -5,6 +5,9 @@ title: About the etc_hosts Resource
5
5
  # etc_hosts
6
6
 
7
7
  Use the `etc_hosts` InSpec audit resource to test rules set to match IP addresses with hostnames.
8
+
9
+ <br>
10
+
8
11
  ## Syntax
9
12
 
10
13
  An etc/hosts rule specifies an IP address and what its hostname is along with optional aliases it can have.
@@ -13,14 +16,14 @@ An etc/hosts rule specifies an IP address and what its hostname is along with op
13
16
 
14
17
  ## Syntax
15
18
 
16
- Use the where clause to match a property to one or more rules in the hosts file.
19
+ Use the `.where` clause to match a property to one or more rules in the hosts file:
17
20
 
18
21
  describe etc_hosts.where { ip_address == 'value' } do
19
22
  its('primary_name') { should cmp 'hostname' }
20
23
  its('all_host_names') { should cmp 'list' }
21
24
  end
22
25
 
23
- Use the optional constructor parameter to give an alternative path to hosts file
26
+ Use the optional resource parameter to give an alternative path to the hosts file:
24
27
 
25
28
  describe etc_hosts('path/to/hosts').where { ip_address == 'value' } do
26
29
  its('primary_name') { should cmp 'hostname' }
@@ -35,13 +38,13 @@ where
35
38
 
36
39
  <br>
37
40
 
38
- ## Supported Properties
41
+ ## Supported Resource Properties
39
42
 
40
43
  'ip_address', 'primary_name', 'all_host_names'
41
44
 
42
45
  <br>
43
46
 
44
- ## Property Examples and Return Types
47
+ ## Property Examples
45
48
 
46
49
  ### ip_address
47
50
 
@@ -59,10 +62,14 @@ where
59
62
  its('primary_name') { should cmp 'localhost' }
60
63
  end
61
64
 
62
- ### all_host_names
65
+ ### all\_host_names
63
66
 
64
67
  `all_host_names` returns a two dimensional string array where each entry has the primary_name first followed by any aliases.
65
68
 
66
69
  describe etc_hosts.where { ip_address == '127.0.1.154' } do
67
70
  its('all_host_names') { should eq [['localhost', 'localhost.localdomain', 'localhost4', 'localhost4.localdomain4'], ['localhost', 'localhost.localdomain', 'localhost6', 'localhost6.localdomain6']] }
68
71
  end
72
+
73
+ ## Matchers
74
+
75
+ For a full list of available matchers please visit our [matchers page](https://www.inspec.io/docs/reference/matchers/).
@@ -4,14 +4,13 @@ title: About the etc_hosts_allow Resource
4
4
 
5
5
  # etc\_hosts\_allow
6
6
 
7
- Use the `etc_hosts_allow` InSpec audit resource to test rules set to accept daemon and client traffic set in /etc/hosts.allow file.
7
+ Use the `etc_hosts_allow` InSpec audit resource to test rules defined for accepting daemon and client traffic in the `'/etc/hosts.allow'` file.
8
8
 
9
9
  <br>
10
10
 
11
11
  ## Syntax
12
12
 
13
- An etc/hosts.allow rule specifies one or more daemons mapped to one or more clients,
14
- with zero or more options to use to accept traffic when found.
13
+ An etc/hosts.allow rule specifies one or more daemons mapped to one or more clients, with zero or more options to for accepting traffic when found.
15
14
 
16
15
  Use the where clause to match a property to one or more rules in the hosts.allow file.
17
16
 
@@ -41,7 +40,7 @@ where
41
40
 
42
41
  <br>
43
42
 
44
- ## Property Examples and Return Types
43
+ ## Property Examples
45
44
 
46
45
  ### daemon
47
46
 
@@ -66,3 +65,9 @@ where
66
65
  describe etc_hosts_allow.where { daemon == 'sshd' } do
67
66
  its('options') { should include ['deny', 'echo "REJECTED"'] }
68
67
  end
68
+
69
+ <br>
70
+
71
+ ## Matchers
72
+
73
+ For a full list of available matchers please visit our [matchers page](https://www.inspec.io/docs/reference/matchers/).
@@ -4,23 +4,22 @@ title: About the etc_hosts_deny Resource
4
4
 
5
5
  # etc\_hosts\_deny
6
6
 
7
- Use the `etc_hosts_deny` InSpec audit resource to test rules set to reject daemon and client traffic set in /etc/hosts.deny.
7
+ Use the `etc_hosts_deny` InSpec audit resource to test rules for rejecting daemon and client traffic defined in /etc/hosts.deny.
8
8
 
9
9
  <br>
10
10
 
11
11
  ## Syntax
12
12
 
13
- An etc/hosts.deny rule specifies one or more daemons mapped to one or more clients,
14
- with zero or more options to use to reject traffic when found.
13
+ An etc/hosts.deny rule specifies one or more daemons mapped to one or more clients, with zero or more options for rejecting traffic when found.
15
14
 
16
- Use the where clause to match a property to one or more rules in the hosts.deny file.
15
+ Use the where clause to match a property to one or more rules in the hosts.deny file:
17
16
 
18
17
  describe etc_hosts_deny.where { daemon == 'value' } do
19
18
  its ('client_list') { should include ['values'] }
20
19
  its ('options') { should include ['values'] }
21
20
  end
22
21
 
23
- Use the optional constructor parameter to give an alternative path to hosts.deny
22
+ Use the optional constructor parameter to give an alternative path to hosts.deny:
24
23
 
25
24
  describe etc_hosts_deny(hosts_path).where { daemon == 'value' } do
26
25
  its ('client_list') { should include ['values'] }
@@ -35,13 +34,13 @@ where
35
34
 
36
35
  <br>
37
36
 
38
- ## Supported Properties
37
+ ## Supported Resource Properties
39
38
 
40
39
  'daemon', 'client_list', 'options'
41
40
 
42
41
  <br>
43
42
 
44
- ## Property Examples and Return Types
43
+ ## Parameter Examples and Return Types
45
44
 
46
45
  ### daemon
47
46
 
@@ -66,3 +65,9 @@ where
66
65
  describe etc_hosts_deny.where { daemon == 'sshd' } do
67
66
  its('options') { should include ['deny', 'echo "REJECTED"'] }
68
67
  end
68
+
69
+ <br>
70
+
71
+ ## Matchers
72
+
73
+ For a full list of available matchers please visit our [matchers page](https://www.inspec.io/docs/reference/matchers/).
@@ -10,24 +10,156 @@ Use the `file` InSpec audit resource to test all system file types, including fi
10
10
 
11
11
  ## Syntax
12
12
 
13
- A `file` resource block declares the location of the file type to be tested, what type that file should be (if required), and then one (or more) matchers:
13
+ A `file` resource block declares the location of the file type to be tested, the expected file type (if required), and one (or more) resource properties.
14
14
 
15
15
  describe file('path') do
16
- it { should MATCHER 'value' }
16
+ it { should PROPERTY 'value' }
17
17
  end
18
18
 
19
19
  where
20
20
 
21
- * `('path')` is the name of the file and/or the path to the file
22
- * `MATCHER` is a valid matcher for this resource
23
- * `'value'` is the value to be tested
21
+ * `('path')` is the name of the file and/or the path to the file.
22
+ * `PROPERTY` is a valid resource property for this resource'
23
+ * `'value'` is the value to be tested.
24
24
 
25
25
  <br>
26
26
 
27
- ## Examples
27
+ ## Supported Resource Properties
28
+
29
+ ### General Resource Properties
30
+
31
+ content, size, basename, path, owner, group, type
32
+
33
+ ### Unix/Linux Resource Properties
34
+
35
+ symlink, mode, link_path, mtime, size, selinux\_label, md5sum, sha256sum, path, source, source\_path, uid, gid
36
+
37
+ ### Windows Resource Properties
38
+
39
+ file\_version, product\_version
40
+
41
+ ## Resource Property Examples
42
+
43
+ ### content
44
+
45
+ The `content` property tests if contents in the file match the value specified in a regular expression. The values of the `content` property are arbitrary and depend on the file type being tested and also the type of information that is expected to be in that file:
46
+
47
+ its('content') { should match REGEX }
48
+
49
+ The following complete example tests the `pg_hba.conf` file in PostgreSQL for MD5 requirements. The tests look at all `host` and `local` settings in that file, and then compare the MD5 checksums against the values in the test:
50
+
51
+ describe file(hba_config_file) do
52
+ its('content') { should match(%r{local\s.*?all\s.*?all\s.*?md5}) }
53
+ its('content') { should match(%r{host\s.*?all\s.*?all\s.*?127.0.0.1\/32\s.*?md5}) }
54
+ its('content') { should match(%r{host\s.*?all\s.*?all\s.*?::1\/128\s.*?md5})
55
+ end
56
+
57
+ ### file_version
58
+
59
+ The `file_version` property tests if a Windows file's version matches the specified value. The difference between a file's "file version" and "product version" is that the file version is the version number of the file itself, whereas the product version is the version number associated with the application from which that file originates:
60
+
61
+ its('file_version') { should eq '1.2.3' }
62
+
63
+ ### group
64
+
65
+ The `group` property tests if the group to which a file belongs matches the specified value.
66
+
67
+ its('group') { should eq 'admins' }
28
68
 
29
69
  The following examples show how to use this InSpec audit resource.
30
70
 
71
+ ### link_path
72
+
73
+ The `link_path` property tests if the file exists at the specified path. If the file is a symlink,
74
+ InSpec will resolve the symlink and return the ultimate linked file.
75
+
76
+ its('link_path') { should eq '/some/path/to/file' }
77
+
78
+ ### md5sum
79
+
80
+ The `md5sum` property tests if the MD5 checksum for a file matches the specified value.
81
+
82
+ its('md5sum') { should eq '3329x3hf9130gjs9jlasf2305mx91s4j' }
83
+
84
+ ### mode
85
+
86
+ The `mode` property tests if the mode assigned to the file matches the specified value.
87
+
88
+ its('mode') { should cmp '0644' }
89
+
90
+ ### mtime
91
+
92
+ The `mtime` property tests if the file modification time for the file matches the specified value. The mtime, where supported, is returned as the number of seconds since the epoch.
93
+
94
+ describe file('/') do
95
+ its('mtime') { should <= Time.now.to_i }
96
+ its('mtime') { should >= Time.now.to_i - 1000 }
97
+ end
98
+
99
+ ### owner
100
+
101
+ The `owner` property tests if the owner of the file matches the specified value.
102
+
103
+ its('owner') { should eq 'root' }
104
+
105
+ ### product_version
106
+
107
+ The `product_version` property tests if a Windows file's product version matches the specified value. The difference between a file's "file version" and "product version" is that the file version is the version number of the file itself, whereas the product version is the version number associated with the application from which that file originates.
108
+
109
+ its('product_version') { should eq 2.3.4 }
110
+
111
+ ### selinux_label
112
+
113
+ The `selinux_label` property tests if the SELinux label for a file matches the specified value.
114
+
115
+ its('selinux_label') { should eq 'system_u:system_r:httpd_t:s0' }
116
+
117
+ ### sha256sum
118
+
119
+ The `sha256sum` property tests if the SHA-256 checksum for a file matches the specified value.
120
+
121
+ its('sha256sum') { should eq 'b837ch38lh19bb8eaopl8jvxwd2e4g58jn9lkho1w3ed9jbkeicalplaad9k0pjn' }
122
+
123
+ ### size
124
+
125
+ The `size` property tests if a file's size matches, is greater than, or is less than the specified value. For example, equal:
126
+
127
+ its('size') { should eq 32375 }
128
+
129
+ Greater than:
130
+
131
+ its('size') { should > 64 }
132
+
133
+ Less than:
134
+
135
+ its('size') { should < 10240 }
136
+
137
+ ### type
138
+
139
+ The `type` property tests for the file type. The available types are:
140
+
141
+ * `file`: the object is a file
142
+ * `directory`: the object is a directory
143
+ * `link`: the object is a symbolic link
144
+ * `pipe`: the object is a named pipe
145
+ * `socket`: the object is a socket
146
+ * `character_device`: the object is a character device
147
+ * `block_device`: the object is a block device
148
+ * `door`: the object is a door device
149
+
150
+ The `type` method usually returns the type as a Ruby "symbol". We recommend using the `cmp` matcher to match
151
+ either by symbol or string.
152
+
153
+ For example:
154
+
155
+ its('type') { should eq :file }
156
+ its('type') { should cmp 'file' }
157
+
158
+ or:
159
+
160
+ its('type') { should eq :socket }
161
+ its('type') { should cmp 'socket' }
162
+
31
163
  ### Test the contents of a file for MD5 requirements
32
164
 
33
165
  describe file(hba_config_file) do
@@ -128,11 +260,6 @@ The following examples show how to use this InSpec audit resource.
128
260
  its('size') { should be 0 }
129
261
  end
130
262
 
131
- ### Test that a file is not mounted
132
-
133
- describe file('/proc/cpuinfo') do
134
- it { should_not be_mounted }
135
- end
136
263
 
137
264
  ### Test an MD5 checksum
138
265
 
@@ -198,7 +325,7 @@ For example, for the following symlink:
198
325
 
199
326
  ## Matchers
200
327
 
201
- This InSpec audit resource has the following matchers. For a full list of available matchers please visit our [matchers page](https://www.inspec.io/docs/reference/matchers/).
328
+ For a full list of available matchers please visit our [matchers page](https://www.inspec.io/docs/reference/matchers/).
202
329
 
203
330
  ### be\_allowed
204
331
 
@@ -278,11 +405,6 @@ The `be_linked_to` matcher tests if the file is linked to the named target:
278
405
 
279
406
  it { should be_linked_to '/etc/target-file' }
280
407
 
281
- ### be_mounted
282
-
283
- The `be_mounted` matcher tests if the file is accessible from the file system:
284
-
285
- it { should be_mounted }
286
408
 
287
409
  ### be\_owned\_by
288
410
 
@@ -376,132 +498,15 @@ a user:
376
498
 
377
499
  it { should be_writable.by_user('user') }
378
500
 
379
- ### content
380
-
381
- The `content` matcher tests if contents in the file match the value specified in a regular expression. The values of the `content` matcher are arbitrary and depend on the file type being tested and also the type of information that is expected to be in that file:
382
-
383
- its('content') { should match REGEX }
384
-
385
- The following complete example tests the `pg_hba.conf` file in PostgreSQL for MD5 requirements. The tests look at all `host` and `local` settings in that file, and then compare the MD5 checksums against the values in the test:
386
-
387
- describe file(hba_config_file) do
388
- its('content') { should match(%r{local\s.*?all\s.*?all\s.*?md5}) }
389
- its('content') { should match(%r{host\s.*?all\s.*?all\s.*?127.0.0.1\/32\s.*?md5}) }
390
- its('content') { should match(%r{host\s.*?all\s.*?all\s.*?::1\/128\s.*?md5})
391
- end
392
-
393
501
  ### exist
394
502
 
395
503
  The `exist` matcher tests if the named file exists:
396
504
 
397
505
  it { should exist }
398
506
 
399
- ### file_version
400
-
401
- The `file_version` matcher tests if the file's version matches the specified value. The difference between a file's "file version" and "product version" is that the file version is the version number of the file itself, whereas the product version is the version number associated with the application from which that file originates:
402
-
403
- its('file_version') { should eq '1.2.3' }
404
-
405
- ### group
406
-
407
- The `group` matcher tests if the group to which a file belongs matches the specified value:
408
-
409
- its('group') { should eq 'admins' }
410
-
411
507
  ### have_mode
412
508
 
413
509
  The `have_mode` matcher tests if a file has a mode assigned to it:
414
510
 
415
511
  it { should have_mode }
416
512
 
417
- ### link_path
418
-
419
- The `link_path` matcher tests if the file exists at the specified path. If the file is a symlink,
420
- InSpec will resolve the symlink and return the ultimate linked file:
421
-
422
- its('link_path') { should eq '/some/path/to/file' }
423
-
424
- ### md5sum
425
-
426
- The `md5sum` matcher tests if the MD5 checksum for a file matches the specified value:
427
-
428
- its('md5sum') { should eq '3329x3hf9130gjs9jlasf2305mx91s4j' }
429
-
430
- ### mode
431
-
432
- The `mode` matcher tests if the mode assigned to the file matches the specified value:
433
-
434
- its('mode') { should cmp '0644' }
435
-
436
- ### mtime
437
-
438
- The `mtime` matcher tests if the file modification time for the file matches the specified value. The mtime, where supported, is returned as the number of seconds since the epoch.
439
-
440
- describe file('/') do
441
- its('mtime') { should <= Time.now.to_i }
442
- its('mtime') { should >= Time.now.to_i - 1000 }
443
- end
444
-
445
- ### owner
446
-
447
- The `owner` matcher tests if the owner of the file matches the specified value:
448
-
449
- its('owner') { should eq 'root' }
450
-
451
- ### product_version
452
-
453
- The `product_version` matcher tests if the file's product version matches the specified value. The difference between a file's "file version" and "product version" is that the file version is the version number of the file itself, whereas the product version is the version number associated with the application from which that file originates:
454
-
455
- its('product_version') { should eq 2.3.4 }
456
-
457
- ### selinux_label
458
-
459
- The `selinux_label` matcher tests if the SELinux label for a file matches the specified value:
460
-
461
- its('selinux_label') { should eq 'system_u:system_r:httpd_t:s0' }
462
-
463
- ### sha256sum
464
-
465
- The `sha256sum` matcher tests if the SHA-256 checksum for a file matches the specified value:
466
-
467
- its('sha256sum') { should eq 'b837ch38lh19bb8eaopl8jvxwd2e4g58jn9lkho1w3ed9jbkeicalplaad9k0pjn' }
468
-
469
- ### size
470
-
471
- The `size` matcher tests if a file's size matches, is greater than, or is less than the specified value. For example, equal:
472
-
473
- its('size') { should eq 32375 }
474
-
475
- Greater than:
476
-
477
- its('size') { should > 64 }
478
-
479
- Less than:
480
-
481
- its('size') { should < 10240 }
482
-
483
- ### type
484
-
485
- The `type` matcher tests for the file type. The available types are:
486
-
487
- * `file`: the object is a file
488
- * `directory`: the object is a directory
489
- * `link`: the object is a symbolic link
490
- * `pipe`: the object is a named pipe
491
- * `socket`: the object is a socket
492
- * `character_device`: the object is a character device
493
- * `block_device`: the object is a block device
494
- * `door`: the object is a door device
495
-
496
- The `type` method usually returns the type as a Ruby "symbol". We recommend using the `cmp` matcher to match
497
- either by symbol or string.
498
-
499
- For example:
500
-
501
- its('type') { should eq :file }
502
- its('type') { should cmp 'file' }
503
-
504
- or:
505
-
506
- its('type') { should eq :socket }
507
- its('type') { should cmp 'socket' }