inspec 1.0.0.beta2 → 1.0.0.beta3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (95) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +41 -2
  3. data/Gemfile +4 -0
  4. data/Rakefile +2 -1
  5. data/docs/.gitignore +2 -0
  6. data/docs/README.md +21 -1
  7. data/docs/resources/apache_conf.md.erb +75 -0
  8. data/docs/resources/apt.md.erb +84 -0
  9. data/docs/resources/audit_policy.md.erb +61 -0
  10. data/docs/resources/auditd_conf.md.erb +79 -0
  11. data/docs/resources/auditd_rules.md.erb +132 -0
  12. data/docs/resources/bash.md.erb +84 -0
  13. data/docs/resources/bond.md.erb +97 -0
  14. data/docs/resources/bridge.md.erb +67 -0
  15. data/docs/resources/bsd_service.md.erb +76 -0
  16. data/docs/resources/command.md.erb +151 -0
  17. data/docs/resources/csv.md.erb +62 -0
  18. data/docs/resources/directory.md.erb +43 -0
  19. data/docs/resources/etc_group.md.erb +116 -0
  20. data/docs/resources/etc_passwd.md.erb +155 -0
  21. data/docs/resources/etc_shadow.md.erb +149 -0
  22. data/docs/resources/file.md.erb +460 -0
  23. data/docs/resources/gem.md.erb +73 -0
  24. data/docs/resources/group.md.erb +74 -0
  25. data/docs/resources/grub_conf.md.erb +115 -0
  26. data/docs/resources/host.md.erb +85 -0
  27. data/docs/resources/iis_site.md.erb +142 -0
  28. data/docs/resources/inetd_conf.md.erb +99 -0
  29. data/docs/resources/ini.md.erb +69 -0
  30. data/docs/resources/interface.md.erb +66 -0
  31. data/docs/resources/iptables.md.erb +70 -0
  32. data/docs/resources/json.md.erb +76 -0
  33. data/docs/resources/kernel_module.md.erb +60 -0
  34. data/docs/resources/kernel_parameter.md.erb +72 -0
  35. data/docs/resources/launchd_service.md.erb +76 -0
  36. data/docs/resources/limits_conf.md.erb +80 -0
  37. data/docs/resources/login_def.md.erb +77 -0
  38. data/docs/resources/mount.md.erb +83 -0
  39. data/docs/resources/mysql_conf.md.erb +102 -0
  40. data/docs/resources/mysql_session.md.erb +63 -0
  41. data/docs/resources/npm.md.erb +75 -0
  42. data/docs/resources/ntp_conf.md.erb +76 -0
  43. data/docs/resources/oneget.md.erb +67 -0
  44. data/docs/resources/os.md.erb +154 -0
  45. data/docs/resources/os_env.md.erb +98 -0
  46. data/docs/resources/package.md.erb +115 -0
  47. data/docs/resources/parse_config.md.erb +122 -0
  48. data/docs/resources/parse_config_file.md.erb +143 -0
  49. data/docs/resources/pip.md.erb +74 -0
  50. data/docs/resources/port.md.erb +150 -0
  51. data/docs/resources/postgres_conf.md.erb +90 -0
  52. data/docs/resources/postgres_session.md.erb +75 -0
  53. data/docs/resources/powershell.md.erb +116 -0
  54. data/docs/resources/process.md.erb +73 -0
  55. data/docs/resources/registry_key.md.erb +149 -0
  56. data/docs/resources/runit_service.md.erb +76 -0
  57. data/docs/resources/security_policy.md.erb +61 -0
  58. data/docs/resources/service.md.erb +135 -0
  59. data/docs/resources/ssh_config.md.erb +94 -0
  60. data/docs/resources/sshd_config.md.erb +97 -0
  61. data/docs/resources/ssl.md.erb +133 -0
  62. data/docs/resources/sys_info.md.erb +55 -0
  63. data/docs/resources/systemd_service.md.erb +76 -0
  64. data/docs/resources/sysv_service.md.erb +76 -0
  65. data/docs/resources/upstart_service.md.erb +76 -0
  66. data/docs/resources/user.md.erb +154 -0
  67. data/docs/resources/users.md.erb +140 -0
  68. data/docs/resources/vbscript.md.erb +69 -0
  69. data/docs/resources/windows_feature.md.erb +61 -0
  70. data/docs/resources/wmi.md.erb +95 -0
  71. data/docs/resources/xinetd_conf.md.erb +170 -0
  72. data/docs/resources/yaml.md.erb +69 -0
  73. data/docs/resources/yum.md.erb +103 -0
  74. data/docs/ruby_usage.md +154 -0
  75. data/docs/shared/matcher_be.md.erb +1 -0
  76. data/docs/shared/matcher_cmp.md.erb +45 -0
  77. data/docs/shared/matcher_eq.md.erb +3 -0
  78. data/docs/shared/matcher_include.md.erb +1 -0
  79. data/docs/shared/matcher_match.md.erb +1 -0
  80. data/lib/fetchers/url.rb +27 -29
  81. data/lib/inspec/cached_fetcher.rb +67 -0
  82. data/lib/inspec/dependencies/requirement.rb +6 -7
  83. data/lib/inspec/objects/each_loop.rb +5 -2
  84. data/lib/inspec/plugins/fetcher.rb +2 -0
  85. data/lib/inspec/profile.rb +9 -41
  86. data/lib/inspec/resource.rb +1 -1
  87. data/lib/inspec/rspec_json_formatter.rb +11 -5
  88. data/lib/inspec/version.rb +1 -1
  89. data/lib/resources/groups.rb +190 -0
  90. data/lib/resources/users.rb +3 -2
  91. metadata +79 -6
  92. data/docs/cli.rst +0 -448
  93. data/docs/resources.rst +0 -4836
  94. data/docs/ruby_usage.rst +0 -145
  95. data/lib/resources/group.rb +0 -137
@@ -0,0 +1,73 @@
1
+ ---
2
+ title: About the gem Resource
3
+ ---
4
+
5
+ # gem
6
+
7
+ Use the `gem` InSpec audit resource to test if a global Gem package is installed.
8
+
9
+ # Syntax
10
+
11
+ A `gem` resource block declares a package and (optionally) a package version:
12
+
13
+ describe gem('gem_package_name') do
14
+ it { should be_installed }
15
+ end
16
+
17
+ where
18
+
19
+ * `('gem_package_name')` must specify a Gem package, such as `'rubocop'`
20
+ * `be_installed` is a valid matcher for this resource
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_installed
31
+
32
+ The `be_installed` matcher tests if the named Gem package is installed:
33
+
34
+ it { should be_installed }
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
+ ## version
53
+
54
+ The `version` matcher tests if the named package version is on the system:
55
+
56
+ its('version') { should eq '0.33.0' }
57
+
58
+ # Examples
59
+
60
+ The following examples show how to use this InSpec audit resource.
61
+
62
+ ## Verify that a gem package is installed, with a specific version
63
+
64
+ describe gem('rubocop') do
65
+ it { should be_installed }
66
+ its('version') { should eq '0.33.0' }
67
+ end
68
+
69
+ ## Verify that a gem package is not installed
70
+
71
+ describe gem('rubocop') do
72
+ it { should_not be_installed }
73
+ end
@@ -0,0 +1,74 @@
1
+ ---
2
+ title: About the group Resource
3
+ ---
4
+
5
+ # group
6
+
7
+ Use the `group` InSpec audit resource to test groups on the system.
8
+
9
+ # Syntax
10
+
11
+ A `group` resource block declares a group, and then the details to be tested, such as if the group is a local group, the group identifier, or if the group exists:
12
+
13
+ describe group('group_name') do
14
+ it { should exist }
15
+ its('gid') { should eq 0 }
16
+ end
17
+
18
+ where
19
+
20
+ * `'group_name'` must specify the name of a group on the system
21
+ * `exist` and `'gid'` are valid matchers for this resource
22
+
23
+ # Matchers
24
+
25
+ This InSpec audit resource has the following matchers:
26
+
27
+ ## be
28
+
29
+ <%= partial "/shared/matcher_be" %>
30
+
31
+ ## be_local
32
+
33
+ The `be_local` matcher tests if the group is a local group:
34
+
35
+ it { should be_local }
36
+
37
+ ## cmp
38
+
39
+ <%= partial "/shared/matcher_cmp" %>
40
+
41
+ ## eq
42
+
43
+ <%= partial "/shared/matcher_eq" %>
44
+
45
+ ## exist
46
+
47
+ The `exist` matcher tests if the named user exists:
48
+
49
+ it { should exist }
50
+
51
+ ## gid
52
+
53
+ The `gid` matcher tests the named group identifier:
54
+
55
+ its('gid') { should eq 1234 }
56
+
57
+ ## include
58
+
59
+ <%= partial "/shared/matcher_include" %>
60
+
61
+ ## match
62
+
63
+ <%= partial "/shared/matcher_match" %>
64
+
65
+ # Examples
66
+
67
+ The following examples show how to use this InSpec audit resource.
68
+
69
+ ## Test the group identifier for the root group
70
+
71
+ describe group('root') do
72
+ it { should exist }
73
+ its('gid') { should eq 0 }
74
+ end
@@ -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