inspec 0.34.1 → 1.0.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.
Files changed (146) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +323 -6
  3. data/Gemfile +10 -0
  4. data/README.md +1 -1
  5. data/Rakefile +4 -55
  6. data/docs/.gitignore +2 -0
  7. data/docs/README.md +40 -0
  8. data/docs/cli.md +342 -0
  9. data/docs/dsl_inspec.md +245 -0
  10. data/docs/dsl_resource.md +93 -0
  11. data/docs/inspec_and_friends.md +105 -0
  12. data/docs/matchers.md +136 -0
  13. data/docs/plugin_kitchen_inspec.html.md +55 -0
  14. data/docs/profiles.md +285 -0
  15. data/docs/resources/apache_conf.md.erb +75 -0
  16. data/docs/resources/apt.md.erb +84 -0
  17. data/docs/resources/audit_policy.md.erb +61 -0
  18. data/docs/resources/auditd_conf.md.erb +79 -0
  19. data/docs/resources/auditd_rules.md.erb +132 -0
  20. data/docs/resources/bash.md.erb +84 -0
  21. data/docs/resources/bond.md.erb +97 -0
  22. data/docs/resources/bridge.md.erb +67 -0
  23. data/docs/resources/bsd_service.md.erb +76 -0
  24. data/docs/resources/command.md.erb +151 -0
  25. data/docs/resources/csv.md.erb +62 -0
  26. data/docs/resources/directory.md.erb +43 -0
  27. data/docs/resources/etc_group.md.erb +116 -0
  28. data/docs/resources/etc_passwd.md.erb +155 -0
  29. data/docs/resources/etc_shadow.md.erb +149 -0
  30. data/docs/resources/file.md.erb +460 -0
  31. data/docs/resources/gem.md.erb +73 -0
  32. data/docs/resources/group.md.erb +74 -0
  33. data/docs/resources/grub_conf.md.erb +115 -0
  34. data/docs/resources/host.md.erb +85 -0
  35. data/docs/resources/iis_site.md.erb +142 -0
  36. data/docs/resources/inetd_conf.md.erb +99 -0
  37. data/docs/resources/ini.md.erb +69 -0
  38. data/docs/resources/interface.md.erb +66 -0
  39. data/docs/resources/iptables.md.erb +70 -0
  40. data/docs/resources/json.md.erb +76 -0
  41. data/docs/resources/kernel_module.md.erb +60 -0
  42. data/docs/resources/kernel_parameter.md.erb +72 -0
  43. data/docs/resources/launchd_service.md.erb +76 -0
  44. data/docs/resources/limits_conf.md.erb +80 -0
  45. data/docs/resources/login_def.md.erb +77 -0
  46. data/docs/resources/mount.md.erb +83 -0
  47. data/docs/resources/mysql_conf.md.erb +102 -0
  48. data/docs/resources/mysql_session.md.erb +63 -0
  49. data/docs/resources/npm.md.erb +75 -0
  50. data/docs/resources/ntp_conf.md.erb +76 -0
  51. data/docs/resources/oneget.md.erb +67 -0
  52. data/docs/resources/os.md.erb +154 -0
  53. data/docs/resources/os_env.md.erb +98 -0
  54. data/docs/resources/package.md.erb +115 -0
  55. data/docs/resources/parse_config.md.erb +122 -0
  56. data/docs/resources/parse_config_file.md.erb +143 -0
  57. data/docs/resources/pip.md.erb +74 -0
  58. data/docs/resources/port.md.erb +150 -0
  59. data/docs/resources/postgres_conf.md.erb +90 -0
  60. data/docs/resources/postgres_session.md.erb +75 -0
  61. data/docs/resources/powershell.md.erb +116 -0
  62. data/docs/resources/process.md.erb +73 -0
  63. data/docs/resources/registry_key.md.erb +149 -0
  64. data/docs/resources/runit_service.md.erb +76 -0
  65. data/docs/resources/security_policy.md.erb +61 -0
  66. data/docs/resources/service.md.erb +135 -0
  67. data/docs/resources/ssh_config.md.erb +94 -0
  68. data/docs/resources/sshd_config.md.erb +97 -0
  69. data/docs/resources/ssl.md.erb +133 -0
  70. data/docs/resources/sys_info.md.erb +55 -0
  71. data/docs/resources/systemd_service.md.erb +76 -0
  72. data/docs/resources/sysv_service.md.erb +76 -0
  73. data/docs/resources/upstart_service.md.erb +76 -0
  74. data/docs/resources/user.md.erb +154 -0
  75. data/docs/resources/users.md.erb +140 -0
  76. data/docs/resources/vbscript.md.erb +69 -0
  77. data/docs/resources/windows_feature.md.erb +61 -0
  78. data/docs/resources/wmi.md.erb +95 -0
  79. data/docs/resources/xinetd_conf.md.erb +170 -0
  80. data/docs/resources/yaml.md.erb +69 -0
  81. data/docs/resources/yum.md.erb +103 -0
  82. data/docs/ruby_usage.md +154 -0
  83. data/docs/shared/matcher_be.md.erb +1 -0
  84. data/docs/shared/matcher_cmp.md.erb +45 -0
  85. data/docs/shared/matcher_eq.md.erb +3 -0
  86. data/docs/shared/matcher_include.md.erb +1 -0
  87. data/docs/shared/matcher_match.md.erb +1 -0
  88. data/docs/shell.md +150 -0
  89. data/examples/meta-profile/inspec.yml +2 -4
  90. data/inspec.gemspec +1 -1
  91. data/lib/bundles/inspec-compliance/api.rb +28 -18
  92. data/lib/bundles/inspec-compliance/cli.rb +19 -27
  93. data/lib/bundles/inspec-compliance/target.rb +15 -2
  94. data/lib/fetchers/git.rb +4 -0
  95. data/lib/fetchers/local.rb +16 -1
  96. data/lib/fetchers/mock.rb +4 -0
  97. data/lib/fetchers/url.rb +46 -20
  98. data/lib/inspec/base_cli.rb +14 -0
  99. data/lib/inspec/cached_fetcher.rb +67 -0
  100. data/lib/inspec/cli.rb +22 -8
  101. data/lib/inspec/control_eval_context.rb +12 -2
  102. data/lib/inspec/dependencies/{vendor_index.rb → cache.rb} +5 -4
  103. data/lib/inspec/dependencies/dependency_set.rb +8 -14
  104. data/lib/inspec/dependencies/lockfile.rb +5 -13
  105. data/lib/inspec/dependencies/requirement.rb +31 -41
  106. data/lib/inspec/dependencies/resolver.rb +3 -3
  107. data/lib/inspec/dsl.rb +16 -4
  108. data/lib/inspec/errors.rb +1 -0
  109. data/lib/inspec/fetcher.rb +25 -1
  110. data/lib/inspec/objects/each_loop.rb +5 -2
  111. data/lib/inspec/objects/test.rb +8 -2
  112. data/lib/inspec/plugins/fetcher.rb +13 -12
  113. data/lib/inspec/plugins/resource.rb +3 -0
  114. data/lib/inspec/profile.rb +62 -26
  115. data/lib/inspec/profile_context.rb +44 -8
  116. data/lib/inspec/resource.rb +18 -3
  117. data/lib/inspec/rspec_json_formatter.rb +91 -40
  118. data/lib/inspec/rule.rb +45 -2
  119. data/lib/inspec/runner.rb +51 -39
  120. data/lib/inspec/shell.rb +5 -16
  121. data/lib/inspec/version.rb +1 -1
  122. data/lib/resources/apache_conf.rb +1 -1
  123. data/lib/resources/gem.rb +1 -0
  124. data/lib/resources/groups.rb +190 -0
  125. data/lib/resources/oneget.rb +1 -0
  126. data/lib/resources/os.rb +1 -1
  127. data/lib/resources/package.rb +3 -1
  128. data/lib/resources/parse_config.rb +18 -1
  129. data/lib/resources/pip.rb +1 -1
  130. data/lib/resources/security_policy.rb +54 -0
  131. data/lib/resources/ssl.rb +9 -11
  132. data/lib/resources/sys_info.rb +1 -1
  133. data/lib/resources/users.rb +81 -64
  134. metadata +91 -17
  135. data/docs/cli.rst +0 -442
  136. data/docs/dsl_inspec.rst +0 -259
  137. data/docs/dsl_resource.rst +0 -90
  138. data/docs/inspec_and_friends.rst +0 -85
  139. data/docs/matchers.rst +0 -137
  140. data/docs/profiles.rst +0 -169
  141. data/docs/readme.rst +0 -105
  142. data/docs/resources.rst +0 -4836
  143. data/docs/ruby_usage.rst +0 -145
  144. data/docs/shell.rst +0 -130
  145. data/docs/template.rst +0 -51
  146. data/lib/resources/group.rb +0 -137
@@ -0,0 +1,115 @@
1
+ ---
2
+ title: About the grub_conf Resource
3
+ ---
4
+
5
+ # grub_conf
6
+
7
+ Grub is a boot loader on the Linux platform used to load and then transfer control to an operating system kernel, after which that kernel initializes the rest of the operating system. Use the `grub_conf` InSpec audit resource to test boot loader configuration settings that are defined in the `grub.conf` configuration file.
8
+
9
+ # Syntax
10
+
11
+ A `grub_conf` resource block declares a list of settings in a `grub.conf` file:
12
+
13
+ describe grub_conf('path', 'kernel') do
14
+ its('setting') { should eq 'value' }
15
+ end
16
+
17
+ or:
18
+
19
+ describe grub_conf('path') do
20
+ its('default') { should eq '0' } #
21
+ its('setting') { should eq 'value' }
22
+ end
23
+
24
+ where
25
+
26
+ * `'service_name'` is a service listed in the `grub.conf` file
27
+ * `'path'` is the path to the `grub.conf` file
28
+ * `'kernel'` specifies the default kernel (by using `'default'`) or a specific kernel; `'default'` defines the position in the list of kernels at which the default kernel is defined, i.e. `should eq '0'` for the first kernel listed or `'path', 'default'` to use the default kernel as specified in the `grub.conf` file
29
+ * `'value'` is the value that is expected
30
+
31
+
32
+ # Matchers
33
+
34
+ This InSpec audit resource has the following matchers:
35
+
36
+ ## be
37
+
38
+ <%= partial "/shared/matcher_be" %>
39
+
40
+ ## cmp
41
+
42
+ <%= partial "/shared/matcher_cmp" %>
43
+
44
+ ## eq
45
+
46
+ <%= partial "/shared/matcher_eq" %>
47
+
48
+ ## include
49
+
50
+ <%= partial "/shared/matcher_include" %>
51
+
52
+ ## match
53
+
54
+ <%= partial "/shared/matcher_match" %>
55
+
56
+ # Examples
57
+
58
+ The following examples show how to use this InSpec audit resource.
59
+
60
+ ## Test a grub.conf file
61
+
62
+ A Grub configuration file located at `/etc/grub.conf` is similar to the following:
63
+
64
+ # grub.conf generated by anaconda
65
+ #
66
+ # Note that you do not have to rerun grub after making changes to this file
67
+ # NOTICE: You have a /boot partition. This means that
68
+ # all kernel and initrd paths are relative to /boot/, eg.
69
+ # root (hd0,0)
70
+ # kernel /vmlinuz-version ro root=/dev/hda6
71
+ # initrd /initrd-version.img
72
+ #boot=/dev/hda
73
+ default=0
74
+ timeout=10
75
+ splashimage=(hd0,0)/grub/splash.xpm.gz
76
+ title Red Hat Enterprise Linux ES (2.6.32-573.7.1.el6.x86_64)
77
+ root (hd0,0)
78
+ kernel /vmlinuz-2.6.32-573.7.1.el6.x86_64 ro root=/dev/hda6
79
+ initrd /initrd-2.6.32-573.7.1.el6.x86_64.img
80
+ title Red Hat Enterprise Linux ES (2.6.32-358.14.1.el6.x86_64)
81
+ root (hd0,0)
82
+ kernel /vmlinuz-2.6.32-358.14.1.el6.x86_64 ro root=/dev/hda6 ramdisk_size=400000
83
+ initrd /initrd-2.6.32-358.14.1.el6.x86_64.img
84
+
85
+ This file defines two versions of RedHat Enterprise Linux, with version `2.6.32-573.7.1.el6.x86_64` specified as the default.
86
+
87
+ The following test verifies the kernel, ensures that kernel is the default kernel, its initial RAM disk (`initrd`), and the timeout:
88
+
89
+ describe grub_conf('/etc/grub.conf', 'default') do
90
+ its('kernel') { should include '/vmlinuz-2.6.32-573.7.1.el6.x86_64' }
91
+ its('initrd') { should include '/initrd-2.6.32-573.7.1.el6.x86_64.img' }
92
+ its('default') { should_not eq '1' }
93
+ its('timeout') { should eq '10' }
94
+ end
95
+
96
+ The following test verifies the `ramdisk_size` for the non-deault kernel:
97
+
98
+ describe grub_conf('/etc/grub.conf', 'Red Hat Enterprise Linux ES (2.6.32-358.14.1.el6.x86_64)') do
99
+ its('kernel') { should include 'ramdisk_size=400000' }
100
+ end
101
+
102
+ ## Test a configuration file and boot configuration
103
+
104
+ describe grub_conf('/etc/grub.conf', 'default') do
105
+ its('kernel') { should include '/vmlinuz-2.6.32-573.7.1.el6.x86_64' }
106
+ its('initrd') { should include '/initramfs-2.6.32-573.el6.x86_64.img=1' }
107
+ its('default') { should_not eq '1' }
108
+ its('timeout') { should eq '5' }
109
+ end
110
+
111
+ ## Test a specific kernel
112
+
113
+ grub_conf('/etc/grub.conf', 'CentOS (2.6.32-573.12.1.el6.x86_64)') do
114
+ its('kernel') { should include 'audit=1' }
115
+ end
@@ -0,0 +1,85 @@
1
+ ---
2
+ title: About the host Resource
3
+ ---
4
+
5
+ # host
6
+
7
+ Use the `host` InSpec audit resource to test the name used to refer to a specific host and its availability, including the Internet protocols and ports over which that host name should be available.
8
+
9
+ # Syntax
10
+
11
+ A `host` resource block declares a host name, and then (depending on what is to be tested) a port and/or a protocol:
12
+
13
+ .. code-block:: ruby
14
+
15
+ describe host('example.com', port: 80, proto: 'tcp') do
16
+ it { should be_reachable }
17
+ end
18
+
19
+ where
20
+
21
+ * `host()` must specify a host name and may specify a port number and/or a protocol
22
+ * `'example.com'` is the host name
23
+ * `port:` is the port number
24
+ * `proto: 'name'` is the Internet protocol: TCP (`proto: 'tcp'`), UDP (`proto: 'udp'` or ICMP (`proto: 'icmp'`))
25
+ * `be_reachable` is a valid matcher for this resource
26
+
27
+
28
+ # Matchers
29
+
30
+ This InSpec audit resource has the following matchers:
31
+
32
+ ## be
33
+
34
+ <%= partial "/shared/matcher_be" %>
35
+
36
+ ## be_reachable
37
+
38
+ The `be_reachable` matcher tests if the host name is available:
39
+
40
+ it { should be_reachable }
41
+
42
+ ## be_resolvable
43
+
44
+ The `be_resolvable` matcher tests for host name resolution, i.e. "resolvable to an IP address":
45
+
46
+ it { should be_resolvable }
47
+
48
+ ## cmp
49
+
50
+ <%= partial "/shared/matcher_cmp" %>
51
+
52
+ ## eq
53
+
54
+ <%= partial "/shared/matcher_eq" %>
55
+
56
+ ## include
57
+
58
+ <%= partial "/shared/matcher_include" %>
59
+
60
+ ## ipaddress
61
+
62
+ The `ipaddress` matcher tests if a host name is resolvable to a specific IP address:
63
+
64
+ its('ipaddress') { should include '93.184.216.34' }
65
+
66
+ ## match
67
+
68
+ <%= partial "/shared/matcher_match" %>
69
+
70
+ # Examples
71
+
72
+ The following examples show how to use this InSpec audit resource.
73
+
74
+ ## Verify host name is reachable over a specific protocol and port number
75
+
76
+ describe host('example.com', port: 53, proto: 'udp') do
77
+ it { should be_reachable }
78
+ end
79
+
80
+ ## Verify that a specific IP address can be resolved
81
+
82
+ describe host('example.com', port: 80, proto: 'tcp') do
83
+ it { should be_resolvable }
84
+ its('ipaddress') { should include '192.168.1.1' }
85
+ end
@@ -0,0 +1,142 @@
1
+ ---
2
+ title: About the iis_site Resource
3
+ ---
4
+
5
+ # iis_site
6
+
7
+ Use the `iis_site` InSpec audit resource to test the state of IIS on Windows Server 2012 (and later).
8
+
9
+ # Syntax
10
+
11
+ An `iis_site` resource block declares details about the named site:
12
+
13
+ describe iis_site('site_name') do
14
+ it { should exist }
15
+ it { should be_running }
16
+ it { should have_app_pool('app_pool_name') }
17
+ it { should have_binding('binding_details') }
18
+ it { should have_path('path_to_site') }
19
+ end
20
+
21
+ where
22
+
23
+ * `'site_name'` is the name of the site, such as `'Default Web Site'`
24
+ * `('app_pool_name')` is the name of the application pool in which the site's root application is run, such as `'DefaultAppPool'`
25
+ * `('binding_details')` is a binding for the site, such as `'net.pipe *'`. A site may have multiple bindings; therefore, use a `have_binding` matcher for each site binding to be tested
26
+ * `('path_to_site')` is the path to the site, such as `'C:\\inetpub\\wwwroot'`
27
+
28
+ For example:
29
+
30
+ describe iis_site('Default Web Site') do
31
+ it { should exist }
32
+ it { should be_running }
33
+ it { should have_app_pool('DefaultAppPool') }
34
+ it { should have_binding('https :443:www.contoso.com sslFlags=0') }
35
+ it { should have_binding('net.pipe *') }
36
+ it { should have_path('C:\\inetpub\\wwwroot') }
37
+ end
38
+
39
+ # Matchers
40
+
41
+ This InSpec audit resource has the following matchers:
42
+
43
+ ## be
44
+
45
+ <%= partial "/shared/matcher_be" %>
46
+
47
+ ## be_running
48
+
49
+ The `be_running` matcher tests if the site is running:
50
+
51
+ it { should be_running }
52
+
53
+ ## cmp
54
+
55
+ <%= partial "/shared/matcher_cmp" %>
56
+
57
+ ## eq
58
+
59
+ <%= partial "/shared/matcher_eq" %>
60
+
61
+ ## exist
62
+
63
+ The `exist` matcher tests if the site exists:
64
+
65
+ it { should exist }
66
+
67
+ ## have_app_pool
68
+
69
+ The `have_app_pool` matcher tests if the named application pool exists for the site:
70
+
71
+ it { should have_app_pool('DefaultAppPool') }
72
+
73
+ For example, testing if a site's application pool inherits the settings of the parent application pool:
74
+
75
+ it { should have_app_pool('/') }
76
+
77
+ ## have_binding
78
+
79
+ The `have_binding` matcher tests if the specified binding exists for the site:
80
+
81
+ it { should have_binding('http :80:*') }
82
+
83
+ or:
84
+
85
+ it { should have_binding('net.pipe *') }
86
+
87
+ A site may have multiple bindings; use a `have_binding` matcher for each unique site binding to be tested.
88
+
89
+ ### Binding Attributes
90
+
91
+ The `have_binding` matcher can also test attributes that are defined for a site binding. For example, the `sslFlags` attribute defines if SSL is enabled, and (when enabled) what level of SSL is applied to the site.
92
+
93
+ Testing a site with SSL disabled:
94
+
95
+ it { should have_binding('https :443:www.contoso.com sslFlags=0') }
96
+
97
+ Testing a site with SSL enabled:
98
+
99
+ it { should have_binding('https :443:www.contoso.com sslFlags=Ssl') }
100
+
101
+ Testing a site with certificate mapping authentication enabled:
102
+
103
+ it { should have_binding('https :443:www.contoso.com sslFlags=SslMapCert') }
104
+
105
+ Testing a site with 128-bit SSL enabled:
106
+
107
+ it { should have_binding('https :443:www.contoso.com sslFlags=Ssl128') }
108
+
109
+ ## have_path
110
+
111
+ The `have_path` matcher tests if the named path is defined for the site:
112
+
113
+ it { should have_path('C:\\inetpub\\wwwroot') }
114
+
115
+ ## include
116
+
117
+ <%= partial "/shared/matcher_include" %>
118
+
119
+ ## match
120
+
121
+ <%= partial "/shared/matcher_match" %>
122
+
123
+ # Examples
124
+
125
+ The following examples show how to use this InSpec audit resource.
126
+
127
+ ## Test a default IIS site
128
+
129
+ describe iis_site('Default Web Site') do
130
+ it { should exist }
131
+ it { should be_running }
132
+ it { should have_app_pool('DefaultAppPool') }
133
+ it { should have_binding('http *:80:') }
134
+ it { should have_path('%SystemDrive%\\inetpub\\wwwroot\\') }
135
+ end
136
+
137
+ ## Test if IIS service is running
138
+
139
+ describe service('W3SVC') do
140
+ it { should be_installed }
141
+ it { should be_running }
142
+ end
@@ -0,0 +1,99 @@
1
+ ---
2
+ title: About the inetd_conf Resource
3
+ ---
4
+
5
+ # inetd_conf
6
+
7
+ Use the `inetd_conf` InSpec audit resource to test if a service is listed in the `inetd.conf` file on Linux and Unix platforms. inetd---the Internet service daemon---listens on dedicated ports, and then loads the appropriate program based on a request. The `inetd.conf` file is typically located at `/etc/inetd.conf` and contains a list of Internet services associated to the ports on which that service will listen. Only enabled services may handle a request; only services that are required by the system should be enabled.`
8
+
9
+ # Syntax
10
+
11
+ An `inetd_conf` resource block declares the list of services that are enabled in the `inetd.conf` file:
12
+
13
+ describe inetd_conf('path') do
14
+ its('service_name') { should eq 'value' }
15
+ end
16
+
17
+ where
18
+
19
+ * `'service_name'` is a service listed in the `inetd.conf` file
20
+ * `('path')` is the non-default path to the `inetd.conf` file
21
+ * `should eq 'value'` is the value that is expected
22
+
23
+
24
+ # Matchers
25
+
26
+ This resource matches any service that is listed in the `inetd.conf` file. You may want to ensure that specific services do not listen via `inetd.conf`:
27
+
28
+ its('shell') { should eq nil }
29
+
30
+ or:
31
+
32
+ its('netstat') { should eq nil }
33
+
34
+ or:
35
+
36
+ its('systat') { should eq nil }
37
+
38
+ For example:
39
+
40
+ describe inetd_conf do
41
+ its('shell') { should eq nil }
42
+ its('login') { should eq nil }
43
+ its('exec') { should eq nil }
44
+ end
45
+
46
+ ## be
47
+
48
+ <%= partial "/shared/matcher_be" %>
49
+
50
+ ## cmp
51
+
52
+ <%= partial "/shared/matcher_cmp" %>
53
+
54
+ ## eq
55
+
56
+ <%= partial "/shared/matcher_eq" %>
57
+
58
+ ## include
59
+
60
+ <%= partial "/shared/matcher_include" %>
61
+
62
+ ## match
63
+
64
+ <%= partial "/shared/matcher_match" %>
65
+
66
+ # Examples
67
+
68
+ The following examples show how to use this InSpec audit resource.
69
+
70
+ ## Verify that FTP is disabled
71
+
72
+ The contents if the `inetd.conf` file contain the following:
73
+
74
+ #ftp stream tcp nowait root /usr/sbin/tcpd in.ftpd -l -a
75
+ #telnet stream tcp nowait root /usr/sbin/tcpd in.telnetd
76
+
77
+ and the following test is defined:
78
+
79
+ describe inetd_conf do
80
+ its('ftp') { should eq nil }
81
+ its('telnet') { should eq nil }
82
+ end
83
+
84
+ Because both the `ftp` and `telnet` Internet services are commented out (`#`), both services are disabled. Consequently, both tests will return `true`. However, if the `inetd.conf` file is set as follows:
85
+
86
+ ftp stream tcp nowait root /usr/sbin/tcpd in.ftpd -l -a
87
+ #telnet stream tcp nowait root /usr/sbin/tcpd in.telnetd
88
+
89
+ then the same test will return `false` for `ftp` and the entire test will fail.
90
+
91
+ ## Test if telnet is installed
92
+
93
+ describe package('telnetd') do
94
+ it { should_not be_installed }
95
+ end
96
+
97
+ describe inetd_conf do
98
+ its('telnet') { should eq nil }
99
+ end
@@ -0,0 +1,69 @@
1
+ ---
2
+ title: About the ini Resource
3
+ ---
4
+
5
+ # ini
6
+
7
+ Use the `ini` InSpec audit resource to test settings in an INI file.
8
+
9
+ # Syntax
10
+
11
+ An `ini` resource block declares the configuration settings to be tested:
12
+
13
+ describe ini('path') do
14
+ its('setting_name') { should eq 'value' }
15
+ end
16
+
17
+ where
18
+
19
+ * `'setting_name'` is a synchronization setting defined in the INI file
20
+ * `('path')` is the path to the INI file
21
+ * `{ should eq 'value' }` is the value that is expected
22
+
23
+ For example:
24
+
25
+ describe ini('path/to/ini_file.ini') do
26
+ its('port') { should eq '143' }
27
+ its('server') { should eq '192.0.2.62' }
28
+ end
29
+
30
+ # Matchers
31
+
32
+ This InSpec audit resource has the following matchers:
33
+
34
+ ## be
35
+
36
+ <%= partial "/shared/matcher_be" %>
37
+
38
+ ## cmp
39
+
40
+ <%= partial "/shared/matcher_cmp" %>
41
+
42
+ ## eq
43
+
44
+ <%= partial "/shared/matcher_eq" %>
45
+
46
+ ## include
47
+
48
+ <%= partial "/shared/matcher_include" %>
49
+
50
+ ## match
51
+
52
+ <%= partial "/shared/matcher_match" %>
53
+
54
+ # Examples
55
+
56
+ The following examples show how to use this InSpec audit resource.
57
+
58
+ ## Test SMTP settings in a PHP INI file
59
+
60
+ For example, a PHP INI file located at contains the following settings:
61
+
62
+ ; SMTP = smtp.gmail.com
63
+ ; smtp_port = 465
64
+
65
+ and can be tested like this:
66
+
67
+ describe ini(/etc/php5/apache2/php.ini) do
68
+ its('smtp_port') { should eq('465') }
69
+ end
@@ -0,0 +1,66 @@
1
+ ---
2
+ title: About the interface Resource
3
+ ---
4
+
5
+ # interface
6
+
7
+ Use the `interface` InSpec audit resource to test basic network adapter properties, such as name, status, state, address, and link speed (in MB/sec).
8
+
9
+ * On Linux platforms, `/sys/class/net/#{iface}` is used as source
10
+ * On the Windows platform, the `Get-NetAdapter` cmdlet is used as source
11
+
12
+ # Syntax
13
+
14
+ An `interface` resource block declares network interface properties to be tested:
15
+
16
+ describe interface do
17
+ it { should be_up }
18
+ its('speed') { should eq 1000 }
19
+ its('name') { should eq eth0 }
20
+ end
21
+
22
+ # Matchers
23
+
24
+ This InSpec audit resource has the following matchers:
25
+
26
+ ## be
27
+
28
+ <%= partial "/shared/matcher_be" %>
29
+
30
+ ## be_up
31
+
32
+ The `be_up` matcher tests if the network interface is available:
33
+
34
+ it { should be_up }
35
+
36
+ ## cmp
37
+
38
+ <%= partial "/shared/matcher_cmp" %>
39
+
40
+ ## eq
41
+
42
+ <%= partial "/shared/matcher_eq" %>
43
+
44
+ ## include
45
+
46
+ <%= partial "/shared/matcher_include" %>
47
+
48
+ ## match
49
+
50
+ <%= partial "/shared/matcher_match" %>
51
+
52
+ ## name
53
+
54
+ The `name` matcher tests if the named network interface exists:
55
+
56
+ its('name') { should eq eth0 }
57
+
58
+ ## speed
59
+
60
+ The `speed` matcher tests the speed of the network interface, in MB/sec:
61
+
62
+ its('speed') { should eq 1000 }
63
+
64
+ # Examples
65
+
66
+ None.
@@ -0,0 +1,70 @@
1
+ ---
2
+ title: About the iptables Resource
3
+ ---
4
+
5
+ # iptables
6
+
7
+ Use the `iptables` InSpec audit resource to test rules that are defined in `iptables`, which maintains tables of IP packet filtering rules. There may be more than one table. Each table contains one (or more) chains (both built-in and custom). A chain is a list of rules that match packets. When the rule matches, the rule defines what target to assign to the packet.
8
+
9
+ # Syntax
10
+
11
+ A `iptables` resource block declares tests for rules in IP tables:
12
+
13
+ describe iptables(rule:'name', table:'name', chain: 'name') do
14
+ it { should have_rule('RULE') }
15
+ end
16
+
17
+ where
18
+
19
+ * `iptables()` may specify any combination of `rule`, `table`, or `chain`
20
+ * `rule:'name'` is the name of a rule that matches a set of packets
21
+ * `table:'name'` is the packet matching table against which the test is run
22
+ * `chain: 'name'` is the name of a user-defined chain or one of `ACCEPT`, `DROP`, `QUEUE`, or `RETURN`
23
+ * `have_rule('RULE')` tests that rule in the iptables file
24
+
25
+
26
+ # Matchers
27
+
28
+ This InSpec audit resource has the following matchers:
29
+
30
+ ## be
31
+
32
+ <%= partial "/shared/matcher_be" %>
33
+
34
+ ## cmp
35
+
36
+ <%= partial "/shared/matcher_cmp" %>
37
+
38
+ ## eq
39
+
40
+ <%= partial "/shared/matcher_eq" %>
41
+
42
+ ## have_rule
43
+
44
+ The `have_rule` matcher tests the named rule against the information in the `iptables` file:
45
+
46
+ it { should have_rule('RULE') }
47
+
48
+ ## include
49
+
50
+ <%= partial "/shared/matcher_include" %>
51
+
52
+ ## match
53
+
54
+ <%= partial "/shared/matcher_match" %>
55
+
56
+ # Examples
57
+
58
+ The following examples show how to use this InSpec audit resource.
59
+
60
+ ## Test if the IP table allows a packet through
61
+
62
+ describe iptables do
63
+ it { should have_rule('-P INPUT ACCEPT') }
64
+ end
65
+
66
+ ## Test if the IP table allows a packet through, for a specific table and chain
67
+
68
+ describe iptables(table:'mangle', chain: 'input') do
69
+ it { should have_rule('-P INPUT ACCEPT') }
70
+ end