inspec 1.0.0 → 1.35.1
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 +933 -101
- data/Gemfile +8 -17
- data/MAINTAINERS.md +2 -1
- data/MAINTAINERS.toml +9 -4
- data/README.md +49 -28
- data/Rakefile +54 -39
- data/bin/inspec +1 -1
- data/docs/dsl_inspec.md +17 -4
- data/docs/dsl_resource.md +1 -1
- data/docs/habitat.md +192 -0
- data/docs/inspec_and_friends.md +4 -2
- data/docs/matchers.md +11 -0
- data/docs/migration.md +293 -0
- data/docs/profiles.md +124 -76
- data/docs/resources/aide_conf.md.erb +81 -0
- data/docs/resources/apache_conf.md.erb +10 -10
- data/docs/resources/apt.md.erb +13 -13
- data/docs/resources/audit_policy.md.erb +10 -10
- data/docs/resources/auditd_conf.md.erb +10 -10
- data/docs/resources/auditd_rules.md.erb +11 -11
- data/docs/resources/bash.md.erb +12 -12
- data/docs/resources/bond.md.erb +15 -15
- data/docs/resources/bridge.md.erb +11 -11
- data/docs/resources/bsd_service.md.erb +11 -11
- data/docs/resources/command.md.erb +23 -23
- data/docs/resources/crontab.md.erb +84 -0
- data/docs/resources/csv.md.erb +10 -10
- data/docs/resources/dh_params.md +191 -0
- data/docs/resources/directory.md.erb +8 -8
- data/docs/resources/docker.md.erb +160 -0
- data/docs/resources/docker_container.md.erb +89 -0
- data/docs/resources/docker_image.md.erb +86 -0
- data/docs/resources/etc_group.md.erb +16 -16
- data/docs/resources/etc_hosts.md.erb +62 -0
- data/docs/resources/file.md.erb +80 -58
- data/docs/resources/gem.md.erb +32 -13
- data/docs/resources/group.md.erb +12 -12
- data/docs/resources/grub_conf.md.erb +11 -11
- data/docs/resources/host.md.erb +27 -18
- data/docs/resources/http.md.erb +104 -0
- data/docs/resources/iis_app.md.erb +126 -0
- data/docs/resources/iis_site.md.erb +17 -17
- data/docs/resources/inetd_conf.md.erb +10 -10
- data/docs/resources/ini.md.erb +9 -9
- data/docs/resources/interface.md.erb +13 -13
- data/docs/resources/iptables.md.erb +21 -14
- data/docs/resources/json.md.erb +11 -11
- data/docs/resources/kernel_module.md.erb +73 -12
- data/docs/resources/kernel_parameter.md.erb +12 -12
- data/docs/resources/key_rsa.md.erb +70 -0
- data/docs/resources/launchd_service.md.erb +11 -11
- data/docs/resources/limits_conf.md.erb +10 -10
- data/docs/resources/login_def.md.erb +12 -12
- data/docs/resources/mount.md.erb +14 -14
- data/docs/resources/mssql_session.md.erb +62 -0
- data/docs/resources/mysql_conf.md.erb +14 -14
- data/docs/resources/mysql_session.md.erb +22 -10
- data/docs/resources/npm.md.erb +13 -13
- data/docs/resources/ntp_conf.md.erb +9 -9
- data/docs/resources/oneget.md.erb +11 -11
- data/docs/resources/oracledb_session.md.erb +53 -0
- data/docs/resources/os.md.erb +17 -17
- data/docs/resources/os_env.md.erb +12 -12
- data/docs/resources/package.md.erb +29 -16
- data/docs/resources/parse_config.md.erb +18 -18
- data/docs/resources/parse_config_file.md.erb +29 -23
- data/docs/resources/{etc_passwd.md.erb → passwd.md.erb} +17 -17
- data/docs/resources/pip.md.erb +15 -15
- data/docs/resources/port.md.erb +23 -23
- data/docs/resources/postgres_conf.md.erb +15 -13
- data/docs/resources/postgres_hba_conf.md.erb +104 -0
- data/docs/resources/postgres_ident_conf.md.erb +87 -0
- data/docs/resources/postgres_session.md.erb +28 -21
- data/docs/resources/powershell.md.erb +14 -14
- data/docs/resources/processes.md.erb +123 -0
- data/docs/resources/rabbitmq_config.md.erb +55 -0
- data/docs/resources/registry_key.md.erb +44 -21
- data/docs/resources/runit_service.md.erb +11 -11
- data/docs/resources/security_policy.md.erb +10 -10
- data/docs/resources/service.md.erb +18 -18
- data/docs/resources/{etc_shadow.md.erb → shadow.md.erb} +19 -19
- data/docs/resources/ssh_config.md.erb +13 -13
- data/docs/resources/sshd_config.md.erb +15 -15
- data/docs/resources/ssl.md.erb +13 -13
- data/docs/resources/sys_info.md.erb +10 -10
- data/docs/resources/systemd_service.md.erb +11 -11
- data/docs/resources/sysv_service.md.erb +11 -11
- data/docs/resources/upstart_service.md.erb +11 -11
- data/docs/resources/user.md.erb +20 -20
- data/docs/resources/users.md.erb +19 -19
- data/docs/resources/vbscript.md.erb +13 -13
- data/docs/resources/virtualization.md.erb +71 -0
- data/docs/resources/windows_feature.md.erb +10 -10
- data/docs/resources/windows_task.md.erb +103 -0
- data/docs/resources/wmi.md.erb +10 -10
- data/docs/resources/x509_certificate.md.erb +146 -0
- data/docs/resources/xinetd_conf.md.erb +17 -17
- data/docs/resources/xml.md.erb +75 -0
- data/docs/resources/yaml.md.erb +25 -11
- data/docs/resources/yum.md.erb +24 -16
- data/docs/resources/zfs_dataset.md.erb +63 -0
- data/docs/resources/zfs_pool.md.erb +57 -0
- data/docs/ruby_usage.md +50 -0
- data/docs/shared/matcher_cmp.md.erb +4 -6
- data/examples/inheritance/README.md +49 -3
- data/examples/inheritance/controls/example.rb +4 -1
- data/examples/inheritance/inspec.yml +3 -1
- data/examples/meta-profile/README.md +29 -3
- data/examples/meta-profile/controls/example.rb +10 -5
- data/examples/meta-profile/inspec.yml +4 -8
- data/examples/profile/README.md +1 -1
- data/examples/profile/controls/example.rb +0 -1
- data/examples/profile/controls/gordon.rb +0 -1
- data/examples/profile/inspec.yml +1 -1
- data/examples/profile-attribute/inspec.yml +1 -1
- data/examples/profile-sensitive/README.md +29 -0
- data/examples/profile-sensitive/controls/sensitive-failures.rb +9 -0
- data/examples/profile-sensitive/controls/sensitive.rb +9 -0
- data/examples/profile-sensitive/inspec.yml +8 -0
- data/inspec.gemspec +10 -2
- data/lib/bundles/inspec-artifact/README.md +1 -0
- data/lib/bundles/inspec-artifact/cli.rb +284 -0
- data/lib/bundles/inspec-artifact.rb +7 -0
- data/lib/bundles/inspec-compliance/README.md +44 -15
- data/lib/bundles/inspec-compliance/api.rb +135 -29
- data/lib/bundles/inspec-compliance/cli.rb +128 -21
- data/lib/bundles/inspec-compliance/configuration.rb +8 -0
- data/lib/bundles/inspec-compliance/http.rb +26 -19
- data/lib/bundles/inspec-compliance/target.rb +50 -25
- data/lib/bundles/inspec-habitat/cli.rb +31 -0
- data/lib/bundles/inspec-habitat/log.rb +10 -0
- data/lib/bundles/inspec-habitat/profile.rb +372 -0
- data/lib/bundles/inspec-habitat.rb +12 -0
- data/lib/bundles/inspec-init/templates/profile/controls/example.rb +0 -1
- data/lib/bundles/inspec-init/templates/profile/inspec.yml +1 -1
- data/lib/bundles/inspec-supermarket/api.rb +7 -5
- data/lib/bundles/inspec-supermarket/cli.rb +2 -2
- data/lib/fetchers/git.rb +4 -2
- data/lib/fetchers/local.rb +4 -1
- data/lib/fetchers/url.rb +64 -10
- data/lib/inspec/archive/tar.rb +1 -1
- data/lib/inspec/backend.rb +26 -3
- data/lib/inspec/base_cli.rb +44 -7
- data/lib/inspec/cached_fetcher.rb +2 -2
- data/lib/inspec/cli.rb +34 -12
- data/lib/inspec/completions/fish.sh.erb +34 -0
- data/lib/inspec/control_eval_context.rb +0 -2
- data/lib/inspec/dependencies/cache.rb +0 -1
- data/lib/inspec/dependencies/dependency_set.rb +2 -2
- data/lib/inspec/dependencies/lockfile.rb +13 -6
- data/lib/inspec/dependencies/requirement.rb +6 -6
- data/lib/inspec/dependencies/resolver.rb +4 -4
- data/lib/inspec/dsl.rb +3 -5
- data/lib/inspec/env_printer.rb +9 -1
- data/lib/inspec/exceptions.rb +8 -0
- data/lib/inspec/fetcher.rb +1 -1
- data/lib/inspec/file_provider.rb +47 -11
- data/lib/inspec/library_eval_context.rb +1 -1
- data/lib/inspec/metadata.rb +62 -18
- data/lib/inspec/method_source.rb +24 -0
- data/lib/inspec/objects/attribute.rb +21 -0
- data/lib/inspec/objects/control.rb +21 -3
- data/lib/inspec/objects/each_loop.rb +2 -1
- data/lib/inspec/objects/list.rb +1 -1
- data/lib/inspec/objects/or_test.rb +17 -2
- data/lib/inspec/objects/tag.rb +27 -0
- data/lib/inspec/objects/test.rb +9 -8
- data/lib/inspec/objects.rb +1 -0
- data/lib/inspec/plugins/fetcher.rb +4 -5
- data/lib/inspec/plugins/resource.rb +1 -2
- data/lib/inspec/plugins/source_reader.rb +3 -3
- data/lib/inspec/plugins.rb +1 -1
- data/lib/inspec/polyfill.rb +0 -1
- data/lib/inspec/profile.rb +92 -23
- data/lib/inspec/profile_context.rb +1 -1
- data/lib/inspec/profile_vendor.rb +66 -0
- data/lib/inspec/resource.rb +29 -3
- data/lib/inspec/rspec_json_formatter.rb +672 -285
- data/lib/inspec/rule.rb +12 -16
- data/lib/inspec/runner.rb +26 -15
- data/lib/inspec/runner_rspec.rb +1 -0
- data/lib/inspec/runtime_profile.rb +26 -0
- data/lib/inspec/schema.rb +185 -0
- data/lib/inspec/secrets/yaml.rb +8 -1
- data/lib/inspec/secrets.rb +1 -1
- data/lib/inspec/shell.rb +92 -22
- data/lib/inspec/source_reader.rb +1 -1
- data/lib/inspec/version.rb +1 -1
- data/lib/inspec.rb +1 -1
- data/lib/matchers/matchers.rb +67 -17
- data/lib/resources/aide_conf.rb +162 -0
- data/lib/resources/apache.rb +0 -1
- data/lib/resources/apache_conf.rb +3 -3
- data/lib/resources/apt.rb +2 -1
- data/lib/resources/audit_policy.rb +0 -1
- data/lib/resources/auditd_conf.rb +1 -2
- data/lib/resources/auditd_rules.rb +5 -5
- data/lib/resources/bond.rb +1 -1
- data/lib/resources/bridge.rb +1 -1
- data/lib/resources/command.rb +5 -3
- data/lib/resources/crontab.rb +102 -0
- data/lib/resources/csv.rb +18 -1
- data/lib/resources/dh_params.rb +84 -0
- data/lib/resources/directory.rb +7 -3
- data/lib/resources/docker.rb +198 -0
- data/lib/resources/docker_container.rb +114 -0
- data/lib/resources/docker_image.rb +96 -0
- data/lib/resources/etc_group.rb +2 -3
- data/lib/resources/etc_hosts.rb +81 -0
- data/lib/resources/file.rb +88 -30
- data/lib/resources/gem.rb +26 -6
- data/lib/resources/groups.rb +4 -5
- data/lib/resources/grub_conf.rb +3 -4
- data/lib/resources/host.rb +175 -35
- data/lib/resources/http.rb +73 -0
- data/lib/resources/iis_app.rb +103 -0
- data/lib/resources/iis_site.rb +23 -0
- data/lib/resources/inetd_conf.rb +9 -4
- data/lib/resources/interface.rb +4 -3
- data/lib/resources/json.rb +37 -14
- data/lib/resources/kernel_module.rb +77 -10
- data/lib/resources/kernel_parameter.rb +0 -1
- data/lib/resources/key_rsa.rb +67 -0
- data/lib/resources/limits_conf.rb +3 -4
- data/lib/resources/login_def.rb +2 -3
- data/lib/resources/mount.rb +34 -4
- data/lib/resources/mssql_session.rb +81 -12
- data/lib/resources/mysql.rb +0 -1
- data/lib/resources/mysql_conf.rb +1 -2
- data/lib/resources/mysql_session.rb +18 -7
- data/lib/resources/nginx_conf.rb +95 -0
- data/lib/resources/ntp_conf.rb +2 -3
- data/lib/resources/oracledb_session.rb +138 -0
- data/lib/resources/os_env.rb +7 -5
- data/lib/resources/package.rb +70 -13
- data/lib/resources/packages.rb +111 -0
- data/lib/resources/parse_config.rb +3 -4
- data/lib/resources/passwd.rb +4 -5
- data/lib/resources/pip.rb +29 -21
- data/lib/resources/port.rb +133 -14
- data/lib/resources/postgres.rb +53 -43
- data/lib/resources/postgres_conf.rb +40 -13
- data/lib/resources/postgres_hba_conf.rb +101 -0
- data/lib/resources/postgres_ident_conf.rb +79 -0
- data/lib/resources/postgres_session.rb +28 -20
- data/lib/resources/powershell.rb +2 -2
- data/lib/resources/processes.rb +61 -26
- data/lib/resources/rabbitmq_conf.rb +53 -0
- data/lib/resources/registry_key.rb +34 -11
- data/lib/resources/security_policy.rb +2 -2
- data/lib/resources/service.rb +17 -7
- data/lib/resources/ssh_conf.rb +17 -6
- data/lib/resources/ssl.rb +3 -4
- data/lib/resources/sys_info.rb +1 -1
- data/lib/resources/toml.rb +26 -0
- data/lib/resources/users.rb +41 -41
- data/lib/resources/virtualization.rb +252 -0
- data/lib/resources/windows_task.rb +106 -0
- data/lib/resources/x509_certificate.rb +143 -0
- data/lib/resources/xinetd.rb +18 -2
- data/lib/resources/xml.rb +27 -0
- data/lib/resources/yaml.rb +10 -2
- data/lib/resources/yum.rb +25 -7
- data/lib/resources/zfs_dataset.rb +60 -0
- data/lib/resources/zfs_pool.rb +49 -0
- data/lib/source_readers/flat.rb +2 -1
- data/lib/source_readers/inspec.rb +30 -11
- data/lib/utils/command_wrapper.rb +3 -3
- data/lib/utils/database_helpers.rb +77 -0
- data/lib/utils/erlang_parser.rb +192 -0
- data/lib/utils/filter.rb +2 -1
- data/lib/utils/filter_array.rb +0 -1
- data/lib/utils/find_files.rb +1 -2
- data/lib/utils/latest_version.rb +21 -0
- data/lib/utils/nginx_parser.rb +76 -0
- data/lib/utils/object_traversal.rb +5 -4
- data/lib/utils/parser.rb +23 -4
- data/lib/utils/plugin_registry.rb +3 -3
- data/lib/utils/simpleconfig.rb +25 -8
- data/lib/utils/spdx.rb +13 -0
- data/lib/utils/spdx.txt +344 -0
- metadata +168 -22
- data/docs/cli.md +0 -342
- data/docs/resources/process.md.erb +0 -73
- /data/docs/{plugin_kitchen_inspec.html.md → plugin_kitchen_inspec.md} +0 -0
data/docs/resources/port.md.erb
CHANGED
|
@@ -6,7 +6,7 @@ title: About the port Resource
|
|
|
6
6
|
|
|
7
7
|
Use the `port` InSpec audit resource to test basic port properties, such as port, process, if it's listening.
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
## Syntax
|
|
10
10
|
|
|
11
11
|
A `port` resource block declares a port, and then depending on what needs to be tested, a process, protocol, process identifier, and its state (is it listening?):
|
|
12
12
|
|
|
@@ -35,55 +35,55 @@ For example, to test if the SSH daemon is available on a Linux machine via the d
|
|
|
35
35
|
its('addresses') { should include '0.0.0.0' }
|
|
36
36
|
end
|
|
37
37
|
|
|
38
|
-
|
|
38
|
+
## Matchers
|
|
39
39
|
|
|
40
40
|
This InSpec audit resource has the following matchers:
|
|
41
41
|
|
|
42
|
-
|
|
42
|
+
### address
|
|
43
43
|
|
|
44
44
|
The `addresses` matcher tests if the specified address is associated with a port:
|
|
45
45
|
|
|
46
46
|
its('addresses') { should include '0.0.0.0' }
|
|
47
47
|
|
|
48
|
-
|
|
48
|
+
### be
|
|
49
49
|
|
|
50
50
|
<%= partial "/shared/matcher_be" %>
|
|
51
51
|
|
|
52
|
-
|
|
52
|
+
### be_listening
|
|
53
53
|
|
|
54
54
|
The `be_listening` matcher tests if the port is listening for traffic:
|
|
55
55
|
|
|
56
56
|
it { should be_listening }
|
|
57
57
|
|
|
58
|
-
|
|
58
|
+
### cmp
|
|
59
59
|
|
|
60
60
|
<%= partial "/shared/matcher_cmp" %>
|
|
61
61
|
|
|
62
|
-
|
|
62
|
+
### eq
|
|
63
63
|
|
|
64
64
|
<%= partial "/shared/matcher_eq" %>
|
|
65
65
|
|
|
66
|
-
|
|
66
|
+
### include
|
|
67
67
|
|
|
68
68
|
<%= partial "/shared/matcher_include" %>
|
|
69
69
|
|
|
70
|
-
|
|
70
|
+
### match
|
|
71
71
|
|
|
72
72
|
<%= partial "/shared/matcher_match" %>
|
|
73
73
|
|
|
74
|
-
|
|
74
|
+
### pids
|
|
75
75
|
|
|
76
76
|
The `pids` matcher tests the process identifiers (PIDs):
|
|
77
77
|
|
|
78
|
-
its('pids') { should
|
|
78
|
+
its('pids') { should cmp 27808 }
|
|
79
79
|
|
|
80
|
-
|
|
80
|
+
### processes
|
|
81
81
|
|
|
82
82
|
The `processes` matcher tests if the named process is running on the system:
|
|
83
83
|
|
|
84
|
-
its('processes') { should
|
|
84
|
+
its('processes') { should cmp 'syslog' }
|
|
85
85
|
|
|
86
|
-
|
|
86
|
+
### protocols
|
|
87
87
|
|
|
88
88
|
The `protocols` matcher tests the Internet protocol: ICMP (`'icmp'`), TCP (`'tcp'` or `'tcp6'`), or UDP (`'udp'` or `'udp6'`):
|
|
89
89
|
|
|
@@ -93,18 +93,18 @@ or for the IPv6 protocol:
|
|
|
93
93
|
|
|
94
94
|
its('protocols') { should include 'tcp6' }
|
|
95
95
|
|
|
96
|
-
|
|
96
|
+
## Examples
|
|
97
97
|
|
|
98
98
|
The following examples show how to use this InSpec audit resource.
|
|
99
99
|
|
|
100
|
-
|
|
100
|
+
### Test port 80, listening with the TCP protocol
|
|
101
101
|
|
|
102
102
|
describe port(80) do
|
|
103
103
|
it { should be_listening }
|
|
104
|
-
its('protocols') {should
|
|
104
|
+
its('protocols') { should cmp 'tcp' }
|
|
105
105
|
end
|
|
106
106
|
|
|
107
|
-
|
|
107
|
+
### Test port 80, on a specific address
|
|
108
108
|
|
|
109
109
|
A specific port address may be checked using either of the following examples:
|
|
110
110
|
|
|
@@ -119,14 +119,14 @@ or:
|
|
|
119
119
|
it { should be_listening }
|
|
120
120
|
end
|
|
121
121
|
|
|
122
|
-
|
|
122
|
+
### Test port 80, listening with TCP version IPv6 protocol
|
|
123
123
|
|
|
124
124
|
describe port(80) do
|
|
125
125
|
it { should be_listening }
|
|
126
|
-
its('protocols') {should
|
|
126
|
+
its('protocols') { should cmp 'tcp6' }
|
|
127
127
|
end
|
|
128
128
|
|
|
129
|
-
|
|
129
|
+
### Test that only secure ports accept requests
|
|
130
130
|
|
|
131
131
|
describe port(80) do
|
|
132
132
|
it { should_not be_listening }
|
|
@@ -134,10 +134,10 @@ or:
|
|
|
134
134
|
|
|
135
135
|
describe port(443) do
|
|
136
136
|
it { should be_listening }
|
|
137
|
-
its('protocols') {should
|
|
137
|
+
its('protocols') { should cmp 'tcp' }
|
|
138
138
|
end
|
|
139
139
|
|
|
140
|
-
|
|
140
|
+
### Verify port 65432 is not listening
|
|
141
141
|
|
|
142
142
|
describe port(22) do
|
|
143
143
|
it { should be_listening }
|
|
@@ -6,7 +6,7 @@ title: About the postgres_conf Resource
|
|
|
6
6
|
|
|
7
7
|
Use the `postgres_conf` InSpec audit resource to test the contents of the configuration file for PostgreSQL, typically located at `/etc/postgresql/<version>/main/postgresql.conf` or `/var/lib/postgres/data/postgresql.conf`, depending on the platform.
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
## Syntax
|
|
10
10
|
|
|
11
11
|
A `postgres_conf` resource block declares one (or more) settings in the `postgresql.conf` file, and then compares the setting in the configuration file to the value stated in the test:
|
|
12
12
|
|
|
@@ -14,37 +14,38 @@ A `postgres_conf` resource block declares one (or more) settings in the `postgre
|
|
|
14
14
|
its('setting') { should eq 'value' }
|
|
15
15
|
end
|
|
16
16
|
|
|
17
|
+
|
|
17
18
|
where
|
|
18
19
|
|
|
19
20
|
* `'setting'` specifies a setting in the `postgresql.conf` file
|
|
20
21
|
* `('path')` is the non-default path to the `postgresql.conf` file (optional)
|
|
21
22
|
* `should eq 'value'` is the value that is expected
|
|
22
23
|
|
|
23
|
-
|
|
24
|
+
## Matchers
|
|
24
25
|
|
|
25
26
|
This InSpec audit resource has the following matchers:
|
|
26
27
|
|
|
27
|
-
|
|
28
|
+
### be
|
|
28
29
|
|
|
29
30
|
<%= partial "/shared/matcher_be" %>
|
|
30
31
|
|
|
31
|
-
|
|
32
|
+
### cmp
|
|
32
33
|
|
|
33
34
|
<%= partial "/shared/matcher_cmp" %>
|
|
34
35
|
|
|
35
|
-
|
|
36
|
+
### eq
|
|
36
37
|
|
|
37
38
|
<%= partial "/shared/matcher_eq" %>
|
|
38
39
|
|
|
39
|
-
|
|
40
|
+
### include
|
|
40
41
|
|
|
41
42
|
<%= partial "/shared/matcher_include" %>
|
|
42
43
|
|
|
43
|
-
|
|
44
|
+
### match
|
|
44
45
|
|
|
45
46
|
<%= partial "/shared/matcher_match" %>
|
|
46
47
|
|
|
47
|
-
|
|
48
|
+
### setting
|
|
48
49
|
|
|
49
50
|
The `setting` matcher tests specific, named settings in the `postgresql.conf` file:
|
|
50
51
|
|
|
@@ -52,17 +53,17 @@ The `setting` matcher tests specific, named settings in the `postgresql.conf` fi
|
|
|
52
53
|
|
|
53
54
|
Use a `setting` matcher for each setting to be tested.
|
|
54
55
|
|
|
55
|
-
|
|
56
|
+
## Examples
|
|
56
57
|
|
|
57
58
|
The following examples show how to use this InSpec audit resource.
|
|
58
59
|
|
|
59
|
-
|
|
60
|
+
### Test the maximum number of allowed client connections
|
|
60
61
|
|
|
61
62
|
describe postgres_conf do
|
|
62
63
|
its('max_connections') { should eq '5' }
|
|
63
64
|
end
|
|
64
65
|
|
|
65
|
-
|
|
66
|
+
### Test system logging
|
|
66
67
|
|
|
67
68
|
describe postgres_conf do
|
|
68
69
|
its('logging_collector') { should eq 'on' }
|
|
@@ -71,15 +72,16 @@ The following examples show how to use this InSpec audit resource.
|
|
|
71
72
|
its('log_duration') { should eq 'on' }
|
|
72
73
|
its('log_hostname') { should eq 'on' }
|
|
73
74
|
its('log_line_prefix') { should eq '%t %u %d %h' }
|
|
75
|
+
its(['pgaudit.log_parameter']) { should cmp 'on' }
|
|
74
76
|
end
|
|
75
77
|
|
|
76
|
-
|
|
78
|
+
### Test the port on which PostgreSQL listens
|
|
77
79
|
|
|
78
80
|
describe postgres_conf do
|
|
79
81
|
its('port') { should eq '5432' }
|
|
80
82
|
end
|
|
81
83
|
|
|
82
|
-
|
|
84
|
+
### Test the Unix socket settings
|
|
83
85
|
|
|
84
86
|
describe postgres_conf do
|
|
85
87
|
its('unix_socket_directories') { should eq '.s.PGSQL.5432' }
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: About the postgres_hba_conf Resource
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# postgres_hba_conf
|
|
6
|
+
|
|
7
|
+
Use the `postgres_hba_conf` InSpec audit resource to test the client authentication data defined in the pg_hba.conf file.
|
|
8
|
+
## Syntax
|
|
9
|
+
|
|
10
|
+
An `postgres_hba_conf` InSpec audit resource block declares client authentication data that should be tested:
|
|
11
|
+
|
|
12
|
+
describe postgres_hba_conf.where { type == 'local' } do
|
|
13
|
+
its('auth_method') { should eq ['peer'] }
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
where
|
|
17
|
+
|
|
18
|
+
* `'attribute'` is a attribute in the pg hba configuration file
|
|
19
|
+
* `'filter_value'` is the value that is to be filtered for
|
|
20
|
+
* `'value'` is the value that is to be matched expected
|
|
21
|
+
|
|
22
|
+
## Matchers
|
|
23
|
+
|
|
24
|
+
This InSpec audit resource matches any service that is listed in the HBA configuration file:
|
|
25
|
+
|
|
26
|
+
its('auth_method') { should_not cmp 'peer' }
|
|
27
|
+
|
|
28
|
+
or:
|
|
29
|
+
|
|
30
|
+
its('auth_method') { should cmp 'peer' }
|
|
31
|
+
|
|
32
|
+
For example:
|
|
33
|
+
|
|
34
|
+
describe postgres_hba_conf.where { type == 'type' } do
|
|
35
|
+
its('auth_method') { should cmp 'value' }
|
|
36
|
+
its('user') { should cmp 'value' }
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
### be
|
|
40
|
+
|
|
41
|
+
<%= partial "/shared/matcher_be" %>
|
|
42
|
+
|
|
43
|
+
### cmp
|
|
44
|
+
|
|
45
|
+
<%= partial "/shared/matcher_cmp" %>
|
|
46
|
+
|
|
47
|
+
### eq
|
|
48
|
+
|
|
49
|
+
<%= partial "/shared/matcher_eq" %>
|
|
50
|
+
|
|
51
|
+
### include
|
|
52
|
+
|
|
53
|
+
<%= partial "/shared/matcher_include" %>
|
|
54
|
+
|
|
55
|
+
### match
|
|
56
|
+
|
|
57
|
+
<%= partial "/shared/matcher_match" %>
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
## Supported Properties
|
|
61
|
+
|
|
62
|
+
'address', 'auth_method', 'auth_params', 'conf_dir' , 'conf_file' , 'database', 'params' ,'type', 'user'
|
|
63
|
+
|
|
64
|
+
## Property Examples and Return Types
|
|
65
|
+
|
|
66
|
+
### address([String])
|
|
67
|
+
|
|
68
|
+
`address` returns a an array of strings that matches the where condition of the filter table
|
|
69
|
+
|
|
70
|
+
describe postgres_hba_conf.where { type == 'local' } do
|
|
71
|
+
its('address') { should cmp 'value' }
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
### auth_method([String])
|
|
75
|
+
|
|
76
|
+
`auth_method` returns a an array of strings that matches the where condition of the filter table
|
|
77
|
+
|
|
78
|
+
describe postgres_hba_conf.where { type == 'local' } do
|
|
79
|
+
its('auth_method') { should cmp 'value' }
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
### database([String])
|
|
83
|
+
|
|
84
|
+
`database` returns a an array of strings that matches the where condition of the filter table
|
|
85
|
+
|
|
86
|
+
describe postgres_hba_conf.where { type == 'local' } do
|
|
87
|
+
its('database') { should cmp 'value' }
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
### type([String])
|
|
91
|
+
|
|
92
|
+
`type` returns a an array of strings that matches the where condition of the filter table
|
|
93
|
+
|
|
94
|
+
describe postgres_hba_conf.where { database == 'acme_test_db' } do
|
|
95
|
+
its('type') { should cmp 'value' }
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
### user([String])
|
|
99
|
+
|
|
100
|
+
`user` returns a an array of strings that matches the where condition of the filter table
|
|
101
|
+
|
|
102
|
+
describe postgres_hba_conf.where { database == 'acme_test_db' } do
|
|
103
|
+
its('user') { should cmp 'value' }
|
|
104
|
+
end
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: About the postgres_ident_conf Resource
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# postgres_ident_conf
|
|
6
|
+
|
|
7
|
+
Use the `postgres_ident_conf` InSpec audit resource to test the client authentication data defined in the pg_hba.conf file.
|
|
8
|
+
## Syntax
|
|
9
|
+
|
|
10
|
+
An `postgres_ident_conf` InSpec audit resource block declares client authentication data that should be tested:
|
|
11
|
+
|
|
12
|
+
describe postgres_ident_conf.where { pg_username == 'filter_value' } do
|
|
13
|
+
its('attribute') { should eq ['value'] }
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
where
|
|
17
|
+
|
|
18
|
+
* `'attribute'` is a attribute in the pg ident configuration file
|
|
19
|
+
* `'filter_value'` is the value that is to be filtered for
|
|
20
|
+
* `'value'` is the value that is to be matched expected
|
|
21
|
+
|
|
22
|
+
## Matchers
|
|
23
|
+
|
|
24
|
+
This InSpec audit resource matches any service that is listed in the pg ident configuration file:
|
|
25
|
+
|
|
26
|
+
its('pg_username') { should_not eq ['peer'] }
|
|
27
|
+
|
|
28
|
+
or:
|
|
29
|
+
|
|
30
|
+
its('map_name') { should eq ['value'] }
|
|
31
|
+
|
|
32
|
+
For example:
|
|
33
|
+
|
|
34
|
+
describe postgres_ident_conf.where { pg_username == 'name' } do
|
|
35
|
+
its('system_username') { should eq ['value'] }
|
|
36
|
+
its('map_name') { should eq ['value'] }
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
### be
|
|
40
|
+
|
|
41
|
+
<%= partial "/shared/matcher_be" %>
|
|
42
|
+
|
|
43
|
+
### cmp
|
|
44
|
+
|
|
45
|
+
<%= partial "/shared/matcher_cmp" %>
|
|
46
|
+
|
|
47
|
+
### eq
|
|
48
|
+
|
|
49
|
+
<%= partial "/shared/matcher_eq" %>
|
|
50
|
+
|
|
51
|
+
### include
|
|
52
|
+
|
|
53
|
+
<%= partial "/shared/matcher_include" %>
|
|
54
|
+
|
|
55
|
+
### match
|
|
56
|
+
|
|
57
|
+
<%= partial "/shared/matcher_match" %>
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
## Supported Properties
|
|
61
|
+
|
|
62
|
+
'conf_file', 'map_name', 'params', 'pg_username', 'system_username'
|
|
63
|
+
|
|
64
|
+
## Property Examples and Return Types
|
|
65
|
+
|
|
66
|
+
### map_name([String])
|
|
67
|
+
|
|
68
|
+
`address` returns a an array of strings that matches the where condition of the filter table
|
|
69
|
+
|
|
70
|
+
describe pg_hba_conf.where { pg_username == 'name' } do
|
|
71
|
+
its('map_name') { should eq ['value'] }
|
|
72
|
+
end
|
|
73
|
+
### pg_username([String])
|
|
74
|
+
|
|
75
|
+
`pg_username` returns a an array of strings that matches the where condition of the filter table
|
|
76
|
+
|
|
77
|
+
describe pg_hba_conf.where { pg_username == 'name' } do
|
|
78
|
+
its('pg_username') { should eq ['value'] }
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
### system_username([String])
|
|
82
|
+
|
|
83
|
+
`system_username` returns a an array of strings that matches the where condition of the filter table
|
|
84
|
+
|
|
85
|
+
describe pg_hba_conf.where { pg_username == 'name' } do
|
|
86
|
+
its('system_username') { should eq ['value'] }
|
|
87
|
+
end
|
|
@@ -6,70 +6,77 @@ title: About the postgres_session Resource
|
|
|
6
6
|
|
|
7
7
|
Use the `postgres_session` InSpec audit resource to test SQL commands run against a PostgreSQL database.
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
## Syntax
|
|
10
10
|
|
|
11
11
|
A `postgres_session` resource block declares the username and password to use for the session, and then the command to be run:
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
# Create a PostgreSQL session:
|
|
14
|
+
sql = postgres_session('username', 'password', 'host')
|
|
14
15
|
|
|
16
|
+
# default values:
|
|
17
|
+
# username: 'postgres'
|
|
18
|
+
# host: 'localhost'
|
|
19
|
+
|
|
20
|
+
# Run an SQL query with an optional database to execute
|
|
21
|
+
sql.query('sql_query', ['database_name'])`
|
|
22
|
+
|
|
23
|
+
A full example is:
|
|
24
|
+
|
|
25
|
+
sql = postgres_session('username', 'password', 'host')
|
|
15
26
|
describe sql.query('SELECT * FROM pg_shadow WHERE passwd IS NULL;') do
|
|
16
|
-
its('output') { should eq
|
|
27
|
+
its('output') { should eq '' }
|
|
17
28
|
end
|
|
18
29
|
|
|
19
|
-
where
|
|
20
|
-
|
|
21
|
-
* `sql = postgres_session` declares a username and password with permission to run the query
|
|
22
|
-
* `sql.query('')` contains the query to be run
|
|
23
|
-
* `its('output') { should eq('') }` compares the results of the query against the expected result in the test
|
|
30
|
+
where `its('output') { should eq '' }` compares the results of the query against the expected result in the test
|
|
24
31
|
|
|
25
|
-
|
|
32
|
+
## Matchers
|
|
26
33
|
|
|
27
34
|
This InSpec audit resource has the following matchers:
|
|
28
35
|
|
|
29
|
-
|
|
36
|
+
### be
|
|
30
37
|
|
|
31
38
|
<%= partial "/shared/matcher_be" %>
|
|
32
39
|
|
|
33
|
-
|
|
40
|
+
### cmp
|
|
34
41
|
|
|
35
42
|
<%= partial "/shared/matcher_cmp" %>
|
|
36
43
|
|
|
37
|
-
|
|
44
|
+
### eq
|
|
38
45
|
|
|
39
46
|
<%= partial "/shared/matcher_eq" %>
|
|
40
47
|
|
|
41
|
-
|
|
48
|
+
### include
|
|
42
49
|
|
|
43
50
|
<%= partial "/shared/matcher_include" %>
|
|
44
51
|
|
|
45
|
-
|
|
52
|
+
### match
|
|
46
53
|
|
|
47
54
|
<%= partial "/shared/matcher_match" %>
|
|
48
55
|
|
|
49
|
-
|
|
56
|
+
### output
|
|
50
57
|
|
|
51
58
|
The `output` matcher tests the results of the query:
|
|
52
59
|
|
|
53
60
|
its('output') { should eq(/^0/) }
|
|
54
61
|
|
|
55
|
-
|
|
62
|
+
## Examples
|
|
56
63
|
|
|
57
64
|
The following examples show how to use this InSpec audit resource.
|
|
58
65
|
|
|
59
|
-
|
|
66
|
+
### Test the PostgreSQL shadow password
|
|
60
67
|
|
|
61
|
-
sql = postgres_session('my_user', 'password')
|
|
68
|
+
sql = postgres_session('my_user', 'password', '192.168.1.2')
|
|
62
69
|
|
|
63
|
-
describe sql.query('SELECT * FROM pg_shadow WHERE passwd IS NULL;') do
|
|
70
|
+
describe sql.query('SELECT * FROM pg_shadow WHERE passwd IS NULL;', ['testdb']) do
|
|
64
71
|
its('output') { should eq('') }
|
|
65
72
|
end
|
|
66
73
|
|
|
67
|
-
|
|
74
|
+
### Test for risky database entries
|
|
68
75
|
|
|
69
76
|
describe postgres_session('my_user', 'password').query('SELECT count (*)
|
|
70
77
|
FROM pg_language
|
|
71
78
|
WHERE lanpltrusted = \'f\'
|
|
72
79
|
AND lanname!=\'internal\'
|
|
73
|
-
AND lanname!=\'c\';') do
|
|
80
|
+
AND lanname!=\'c\';', ['postgres']) do
|
|
74
81
|
its('output') { should eq '0' }
|
|
75
82
|
end
|
|
@@ -6,7 +6,7 @@ title: About the powershell Resource
|
|
|
6
6
|
|
|
7
7
|
Use the `powershell` InSpec audit resource to test a Powershell script on the Windows platform.
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
## Syntax
|
|
10
10
|
|
|
11
11
|
A `powershell` resource block declares a Powershell script to be tested, and then compares the output of that command to the matcher in the test:
|
|
12
12
|
|
|
@@ -14,7 +14,7 @@ A `powershell` resource block declares a Powershell script to be tested, and the
|
|
|
14
14
|
# a PowerShell script
|
|
15
15
|
EOH
|
|
16
16
|
|
|
17
|
-
describe
|
|
17
|
+
describe powershell(script) do
|
|
18
18
|
its('matcher') { should eq 'output' }
|
|
19
19
|
end
|
|
20
20
|
|
|
@@ -25,53 +25,53 @@ where
|
|
|
25
25
|
* `'output'` tests the output of the command run on the system versus the output value stated in the test
|
|
26
26
|
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
## Matchers
|
|
29
29
|
|
|
30
30
|
This InSpec audit resource has the following matchers:
|
|
31
31
|
|
|
32
|
-
|
|
32
|
+
### be
|
|
33
33
|
|
|
34
34
|
<%= partial "/shared/matcher_be" %>
|
|
35
35
|
|
|
36
|
-
|
|
36
|
+
### cmp
|
|
37
37
|
|
|
38
38
|
<%= partial "/shared/matcher_cmp" %>
|
|
39
39
|
|
|
40
|
-
|
|
40
|
+
### eq
|
|
41
41
|
|
|
42
42
|
<%= partial "/shared/matcher_eq" %>
|
|
43
43
|
|
|
44
|
-
|
|
44
|
+
### exit_status
|
|
45
45
|
|
|
46
46
|
The `exit_status` matcher tests the exit status for the command:
|
|
47
47
|
|
|
48
48
|
its('exit_status') { should eq 123 }
|
|
49
49
|
|
|
50
|
-
|
|
50
|
+
### include
|
|
51
51
|
|
|
52
52
|
<%= partial "/shared/matcher_include" %>
|
|
53
53
|
|
|
54
|
-
|
|
54
|
+
### match
|
|
55
55
|
|
|
56
56
|
<%= partial "/shared/matcher_match" %>
|
|
57
57
|
|
|
58
|
-
|
|
58
|
+
### stderr
|
|
59
59
|
|
|
60
60
|
The `stderr` matcher tests results of the command as returned in standard error (stderr):
|
|
61
61
|
|
|
62
62
|
its('stderr') { should eq 'error' }
|
|
63
63
|
|
|
64
|
-
|
|
64
|
+
### stdout
|
|
65
65
|
|
|
66
66
|
The `stdout` matcher tests results of the command as returned in standard output (stdout):
|
|
67
67
|
|
|
68
68
|
its('stdout') { should eq '/^1$/' }
|
|
69
69
|
|
|
70
|
-
|
|
70
|
+
## Examples
|
|
71
71
|
|
|
72
72
|
The following examples show how to use this InSpec audit resource.
|
|
73
73
|
|
|
74
|
-
|
|
74
|
+
### Get all groups of Administrator user
|
|
75
75
|
|
|
76
76
|
script = <<-EOH
|
|
77
77
|
# find user
|
|
@@ -85,7 +85,7 @@ The following examples show how to use this InSpec audit resource.
|
|
|
85
85
|
its('stdout') { should_not eq '' }
|
|
86
86
|
end
|
|
87
87
|
|
|
88
|
-
|
|
88
|
+
### Write-Output 'hello'
|
|
89
89
|
|
|
90
90
|
The following Powershell script:
|
|
91
91
|
|