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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +323 -6
- data/Gemfile +10 -0
- data/README.md +1 -1
- data/Rakefile +4 -55
- data/docs/.gitignore +2 -0
- data/docs/README.md +40 -0
- data/docs/cli.md +342 -0
- data/docs/dsl_inspec.md +245 -0
- data/docs/dsl_resource.md +93 -0
- data/docs/inspec_and_friends.md +105 -0
- data/docs/matchers.md +136 -0
- data/docs/plugin_kitchen_inspec.html.md +55 -0
- data/docs/profiles.md +285 -0
- data/docs/resources/apache_conf.md.erb +75 -0
- data/docs/resources/apt.md.erb +84 -0
- data/docs/resources/audit_policy.md.erb +61 -0
- data/docs/resources/auditd_conf.md.erb +79 -0
- data/docs/resources/auditd_rules.md.erb +132 -0
- data/docs/resources/bash.md.erb +84 -0
- data/docs/resources/bond.md.erb +97 -0
- data/docs/resources/bridge.md.erb +67 -0
- data/docs/resources/bsd_service.md.erb +76 -0
- data/docs/resources/command.md.erb +151 -0
- data/docs/resources/csv.md.erb +62 -0
- data/docs/resources/directory.md.erb +43 -0
- data/docs/resources/etc_group.md.erb +116 -0
- data/docs/resources/etc_passwd.md.erb +155 -0
- data/docs/resources/etc_shadow.md.erb +149 -0
- data/docs/resources/file.md.erb +460 -0
- data/docs/resources/gem.md.erb +73 -0
- data/docs/resources/group.md.erb +74 -0
- data/docs/resources/grub_conf.md.erb +115 -0
- data/docs/resources/host.md.erb +85 -0
- data/docs/resources/iis_site.md.erb +142 -0
- data/docs/resources/inetd_conf.md.erb +99 -0
- data/docs/resources/ini.md.erb +69 -0
- data/docs/resources/interface.md.erb +66 -0
- data/docs/resources/iptables.md.erb +70 -0
- data/docs/resources/json.md.erb +76 -0
- data/docs/resources/kernel_module.md.erb +60 -0
- data/docs/resources/kernel_parameter.md.erb +72 -0
- data/docs/resources/launchd_service.md.erb +76 -0
- data/docs/resources/limits_conf.md.erb +80 -0
- data/docs/resources/login_def.md.erb +77 -0
- data/docs/resources/mount.md.erb +83 -0
- data/docs/resources/mysql_conf.md.erb +102 -0
- data/docs/resources/mysql_session.md.erb +63 -0
- data/docs/resources/npm.md.erb +75 -0
- data/docs/resources/ntp_conf.md.erb +76 -0
- data/docs/resources/oneget.md.erb +67 -0
- data/docs/resources/os.md.erb +154 -0
- data/docs/resources/os_env.md.erb +98 -0
- data/docs/resources/package.md.erb +115 -0
- data/docs/resources/parse_config.md.erb +122 -0
- data/docs/resources/parse_config_file.md.erb +143 -0
- data/docs/resources/pip.md.erb +74 -0
- data/docs/resources/port.md.erb +150 -0
- data/docs/resources/postgres_conf.md.erb +90 -0
- data/docs/resources/postgres_session.md.erb +75 -0
- data/docs/resources/powershell.md.erb +116 -0
- data/docs/resources/process.md.erb +73 -0
- data/docs/resources/registry_key.md.erb +149 -0
- data/docs/resources/runit_service.md.erb +76 -0
- data/docs/resources/security_policy.md.erb +61 -0
- data/docs/resources/service.md.erb +135 -0
- data/docs/resources/ssh_config.md.erb +94 -0
- data/docs/resources/sshd_config.md.erb +97 -0
- data/docs/resources/ssl.md.erb +133 -0
- data/docs/resources/sys_info.md.erb +55 -0
- data/docs/resources/systemd_service.md.erb +76 -0
- data/docs/resources/sysv_service.md.erb +76 -0
- data/docs/resources/upstart_service.md.erb +76 -0
- data/docs/resources/user.md.erb +154 -0
- data/docs/resources/users.md.erb +140 -0
- data/docs/resources/vbscript.md.erb +69 -0
- data/docs/resources/windows_feature.md.erb +61 -0
- data/docs/resources/wmi.md.erb +95 -0
- data/docs/resources/xinetd_conf.md.erb +170 -0
- data/docs/resources/yaml.md.erb +69 -0
- data/docs/resources/yum.md.erb +103 -0
- data/docs/ruby_usage.md +154 -0
- data/docs/shared/matcher_be.md.erb +1 -0
- data/docs/shared/matcher_cmp.md.erb +45 -0
- data/docs/shared/matcher_eq.md.erb +3 -0
- data/docs/shared/matcher_include.md.erb +1 -0
- data/docs/shared/matcher_match.md.erb +1 -0
- data/docs/shell.md +150 -0
- data/examples/meta-profile/inspec.yml +2 -4
- data/inspec.gemspec +1 -1
- data/lib/bundles/inspec-compliance/api.rb +28 -18
- data/lib/bundles/inspec-compliance/cli.rb +19 -27
- data/lib/bundles/inspec-compliance/target.rb +15 -2
- data/lib/fetchers/git.rb +4 -0
- data/lib/fetchers/local.rb +16 -1
- data/lib/fetchers/mock.rb +4 -0
- data/lib/fetchers/url.rb +46 -20
- data/lib/inspec/base_cli.rb +14 -0
- data/lib/inspec/cached_fetcher.rb +67 -0
- data/lib/inspec/cli.rb +22 -8
- data/lib/inspec/control_eval_context.rb +12 -2
- data/lib/inspec/dependencies/{vendor_index.rb → cache.rb} +5 -4
- data/lib/inspec/dependencies/dependency_set.rb +8 -14
- data/lib/inspec/dependencies/lockfile.rb +5 -13
- data/lib/inspec/dependencies/requirement.rb +31 -41
- data/lib/inspec/dependencies/resolver.rb +3 -3
- data/lib/inspec/dsl.rb +16 -4
- data/lib/inspec/errors.rb +1 -0
- data/lib/inspec/fetcher.rb +25 -1
- data/lib/inspec/objects/each_loop.rb +5 -2
- data/lib/inspec/objects/test.rb +8 -2
- data/lib/inspec/plugins/fetcher.rb +13 -12
- data/lib/inspec/plugins/resource.rb +3 -0
- data/lib/inspec/profile.rb +62 -26
- data/lib/inspec/profile_context.rb +44 -8
- data/lib/inspec/resource.rb +18 -3
- data/lib/inspec/rspec_json_formatter.rb +91 -40
- data/lib/inspec/rule.rb +45 -2
- data/lib/inspec/runner.rb +51 -39
- data/lib/inspec/shell.rb +5 -16
- data/lib/inspec/version.rb +1 -1
- data/lib/resources/apache_conf.rb +1 -1
- data/lib/resources/gem.rb +1 -0
- data/lib/resources/groups.rb +190 -0
- data/lib/resources/oneget.rb +1 -0
- data/lib/resources/os.rb +1 -1
- data/lib/resources/package.rb +3 -1
- data/lib/resources/parse_config.rb +18 -1
- data/lib/resources/pip.rb +1 -1
- data/lib/resources/security_policy.rb +54 -0
- data/lib/resources/ssl.rb +9 -11
- data/lib/resources/sys_info.rb +1 -1
- data/lib/resources/users.rb +81 -64
- metadata +91 -17
- data/docs/cli.rst +0 -442
- data/docs/dsl_inspec.rst +0 -259
- data/docs/dsl_resource.rst +0 -90
- data/docs/inspec_and_friends.rst +0 -85
- data/docs/matchers.rst +0 -137
- data/docs/profiles.rst +0 -169
- data/docs/readme.rst +0 -105
- data/docs/resources.rst +0 -4836
- data/docs/ruby_usage.rst +0 -145
- data/docs/shell.rst +0 -130
- data/docs/template.rst +0 -51
- data/lib/resources/group.rb +0 -137
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: About the apt Resource
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# apt
|
|
6
|
+
|
|
7
|
+
Use the `apt` InSpec audit resource to verify Apt repositories on the Debian and Ubuntu platforms, and also PPA repositories on the Ubuntu platform.
|
|
8
|
+
|
|
9
|
+
# Syntax
|
|
10
|
+
|
|
11
|
+
An `apt` resource block tests the contents of Apt and PPA repositories:
|
|
12
|
+
|
|
13
|
+
describe apt('path') do
|
|
14
|
+
it { should exist }
|
|
15
|
+
it { should be_enabled }
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
where
|
|
19
|
+
|
|
20
|
+
* `apt('path')` must specify an Apt or PPA repository
|
|
21
|
+
* `('path')` may be an `http://` address, a `ppa:` address, or a short `repo-name/ppa` address
|
|
22
|
+
* `exist` and `be_enabled` are a valid matchers for this resource
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
# Matchers
|
|
26
|
+
|
|
27
|
+
This InSpec audit resource has the following matchers:
|
|
28
|
+
|
|
29
|
+
## be
|
|
30
|
+
|
|
31
|
+
<%= partial "/shared/matcher_be" %>
|
|
32
|
+
|
|
33
|
+
## be_enabled
|
|
34
|
+
|
|
35
|
+
The `be_enabled` matcher tests if a package exists in the repository:
|
|
36
|
+
|
|
37
|
+
it { should be_enabled }
|
|
38
|
+
|
|
39
|
+
## cmp
|
|
40
|
+
|
|
41
|
+
<%= partial "/shared/matcher_cmp" %>
|
|
42
|
+
|
|
43
|
+
## eq
|
|
44
|
+
|
|
45
|
+
<%= partial "/shared/matcher_eq" %>
|
|
46
|
+
|
|
47
|
+
## exist
|
|
48
|
+
|
|
49
|
+
The `exist` matcher tests if a package exists on the system:
|
|
50
|
+
|
|
51
|
+
it { should exist }
|
|
52
|
+
|
|
53
|
+
## include
|
|
54
|
+
|
|
55
|
+
<%= partial "/shared/matcher_include" %>
|
|
56
|
+
|
|
57
|
+
## match
|
|
58
|
+
|
|
59
|
+
<%= partial "/shared/matcher_match" %>
|
|
60
|
+
|
|
61
|
+
# Examples
|
|
62
|
+
|
|
63
|
+
The following examples show how to use this InSpec audit resource.
|
|
64
|
+
|
|
65
|
+
## Test if apt repository exists and is enabled
|
|
66
|
+
|
|
67
|
+
describe apt('http://ppa.launchpad.net/juju/stable/ubuntu') do
|
|
68
|
+
it { should exist }
|
|
69
|
+
it { should be_enabled }
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
## Verify that a PPA repository exists and is enabled
|
|
73
|
+
|
|
74
|
+
describe apt('ppa:nginx/stable') do
|
|
75
|
+
it { should exist }
|
|
76
|
+
it { should be_enabled }
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
## Verify that a repository is not present
|
|
80
|
+
|
|
81
|
+
describe apt('ubuntu-wine/ppa') do
|
|
82
|
+
it { should_not exist }
|
|
83
|
+
it { should_not be_enabled }
|
|
84
|
+
end
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: About the audit_policy Resource
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# audit_policy
|
|
6
|
+
|
|
7
|
+
Use the `audit_policy` Inspec audit resource to test auditing policies on the Windows platform. An auditing policy is a category of security-related events to be audited. Auditing is disabled by default and may be enabled for categories like account management, logon events, policy changes, process tracking, privilege use, system events, or object access. For each auditing category property that is enabled, the auditing level may be set to `No Auditing`, `Not Specified`, `Success`, `Success and Failure`, or `Failure`.
|
|
8
|
+
|
|
9
|
+
# Syntax
|
|
10
|
+
|
|
11
|
+
An `audit_policy` resource block declares a parameter that belongs to an audit policy category or subcategory:
|
|
12
|
+
|
|
13
|
+
describe audit_policy do
|
|
14
|
+
its('parameter') { should eq 'value' }
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
where
|
|
18
|
+
|
|
19
|
+
* `'parameter'` must specify a parameter
|
|
20
|
+
* `'value'` must be one of `No Auditing`, `Not Specified`, `Success`, `Success and Failure`, or `Failure`
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
# Matchers
|
|
24
|
+
|
|
25
|
+
This InSpec audit resource has the following matchers:
|
|
26
|
+
|
|
27
|
+
## be
|
|
28
|
+
|
|
29
|
+
<%= partial "/shared/matcher_be" %>
|
|
30
|
+
|
|
31
|
+
## cmp
|
|
32
|
+
|
|
33
|
+
<%= partial "/shared/matcher_cmp" %>
|
|
34
|
+
|
|
35
|
+
## eq
|
|
36
|
+
|
|
37
|
+
<%= partial "/shared/matcher_eq" %>
|
|
38
|
+
|
|
39
|
+
## include
|
|
40
|
+
|
|
41
|
+
<%= partial "/shared/matcher_include" %>
|
|
42
|
+
|
|
43
|
+
## match
|
|
44
|
+
|
|
45
|
+
<%= partial "/shared/matcher_match" %>
|
|
46
|
+
|
|
47
|
+
# Examples
|
|
48
|
+
|
|
49
|
+
The following examples show how to use this InSpec audit resource.
|
|
50
|
+
|
|
51
|
+
## Test that a parameter is not set to "No Auditing"
|
|
52
|
+
|
|
53
|
+
describe audit_policy do
|
|
54
|
+
its('Other Account Logon Events') { should_not eq 'No Auditing' }
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
## Test that a parameter is set to "Success"
|
|
58
|
+
|
|
59
|
+
describe audit_policy do
|
|
60
|
+
its('User Account Management') { should eq 'Success' }
|
|
61
|
+
end
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: About the auditd_conf Resource
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# auditd_conf
|
|
6
|
+
|
|
7
|
+
Use the `auditd_conf` InSpec audit resource to test the configuration settings for the audit daemon. This file is typically located under `/etc/audit/auditd.conf'` on Unix and Linux platforms.
|
|
8
|
+
|
|
9
|
+
# Syntax
|
|
10
|
+
|
|
11
|
+
A `auditd_conf` resource block declares configuration settings that should be tested:
|
|
12
|
+
|
|
13
|
+
describe auditd_conf('path') do
|
|
14
|
+
its('keyword') { should cmp 'value' }
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
where
|
|
18
|
+
|
|
19
|
+
* `'keyword'` is a configuration setting defined in the `auditd.conf` configuration file
|
|
20
|
+
* `('path')` is the non-default path to the `auditd.conf` configuration file
|
|
21
|
+
* `{ should cmp 'value' }` is the value that is expected
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
# Matchers
|
|
25
|
+
|
|
26
|
+
This InSpec audit resource has the following matchers:
|
|
27
|
+
|
|
28
|
+
## be
|
|
29
|
+
|
|
30
|
+
<%= partial "/shared/matcher_be" %>
|
|
31
|
+
|
|
32
|
+
## cmp
|
|
33
|
+
|
|
34
|
+
<%= partial "/shared/matcher_cmp" %>
|
|
35
|
+
|
|
36
|
+
## eq
|
|
37
|
+
|
|
38
|
+
<%= partial "/shared/matcher_eq" %>
|
|
39
|
+
|
|
40
|
+
## include
|
|
41
|
+
|
|
42
|
+
<%= partial "/shared/matcher_include" %>
|
|
43
|
+
|
|
44
|
+
## keyword
|
|
45
|
+
|
|
46
|
+
This matcher will matche any keyword that is listed in the `auditd.conf` configuration file. Option names and values are case-insensitive:
|
|
47
|
+
|
|
48
|
+
its('log_format') { should cmp 'raw' }
|
|
49
|
+
|
|
50
|
+
or:
|
|
51
|
+
|
|
52
|
+
its('max_log_file') { should cmp 6 }
|
|
53
|
+
|
|
54
|
+
## match
|
|
55
|
+
|
|
56
|
+
<%= partial "/shared/matcher_match" %>
|
|
57
|
+
|
|
58
|
+
# Examples
|
|
59
|
+
|
|
60
|
+
The following examples show how to use this InSpec audit resource.
|
|
61
|
+
|
|
62
|
+
## Test the auditd.conf file
|
|
63
|
+
|
|
64
|
+
describe auditd_conf do
|
|
65
|
+
its('log_file') { should cmp '/full/path/to/file' }
|
|
66
|
+
its('log_format') { should cmp 'raw' }
|
|
67
|
+
its('flush') { should cmp 'none' }
|
|
68
|
+
its('freq') { should cmp 1 }
|
|
69
|
+
its('num_logs') { should cmp 0 }
|
|
70
|
+
its('max_log_file') { should cmp 6 }
|
|
71
|
+
its('max_log_file_action') { should cmp 'email' }
|
|
72
|
+
its('space_left') { should cmp 2 }
|
|
73
|
+
its('action_mail_acct') { should cmp 'root' }
|
|
74
|
+
its('space_left_action') { should cmp 'email' }
|
|
75
|
+
its('admin_space_left') { should cmp 1 }
|
|
76
|
+
its('admin_space_left_action') { should cmp 'halt' }
|
|
77
|
+
its('disk_full_action') { should cmp 'halt' }
|
|
78
|
+
its('disk_error_action') { should cmp 'halt' }
|
|
79
|
+
end
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: About the auditd_rules Resource
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# auditd_rules
|
|
6
|
+
|
|
7
|
+
Use the `auditd_rules` InSpec audit resource to test the rules for logging that exist on the system. The `audit.rules` file is typically located under `/etc/audit/` and contains the list of rules that define what is captured in log files. This resource uses `auditctl` to query the run-time `auditd` rules setup, which may be different from `audit.rules`.
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
# Syntax
|
|
11
|
+
|
|
12
|
+
An `auditd_rules` resource block declares one (or more) rules to be tested, and then what that rule should do. The syntax depends on the version of `audit`:
|
|
13
|
+
|
|
14
|
+
For `audit` >= 2.3:
|
|
15
|
+
|
|
16
|
+
describe auditd_rules do
|
|
17
|
+
its('lines') { should contain_match(rule) }
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
For `audit` < 2.3:
|
|
21
|
+
|
|
22
|
+
describe audit_daemon_rules do
|
|
23
|
+
its("LIST_RULES") {
|
|
24
|
+
rule
|
|
25
|
+
}
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
For example:
|
|
29
|
+
|
|
30
|
+
describe auditd_rules do
|
|
31
|
+
its('LIST_RULES') { should eq [
|
|
32
|
+
'exit,always syscall=rmdir,unlink',
|
|
33
|
+
'exit,always auid=1001 (0x3e9) syscall=open',
|
|
34
|
+
'exit,always watch=/etc/group perm=wa',
|
|
35
|
+
'exit,always watch=/etc/passwd perm=wa',
|
|
36
|
+
'exit,always watch=/etc/shadow perm=wa',
|
|
37
|
+
'exit,always watch=/etc/sudoers perm=wa',
|
|
38
|
+
'exit,always watch=/etc/secret_directory perm=r',
|
|
39
|
+
] }
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
or test that individual rules are defined:
|
|
43
|
+
|
|
44
|
+
describe auditd_rules do
|
|
45
|
+
its('LIST_RULES') {
|
|
46
|
+
should contain_match(/^exit,always watch=\/etc\/group perm=wa key=identity/)
|
|
47
|
+
}
|
|
48
|
+
its('LIST_RULES') {
|
|
49
|
+
should contain_match(/^exit,always watch=\/etc\/passwd perm=wa key=identity/)
|
|
50
|
+
}
|
|
51
|
+
its('LIST_RULES') {
|
|
52
|
+
should contain_match(/^exit,always watch=\/etc\/gshadow perm=wa key=identity/)
|
|
53
|
+
}
|
|
54
|
+
its('LIST_RULES') {
|
|
55
|
+
should contain_match(/^exit,always watch=\/etc\/shadow perm=wa key=identity/)
|
|
56
|
+
}
|
|
57
|
+
its('LIST_RULES') {
|
|
58
|
+
should contain_match(/^exit,always watch=\/etc\/security\/opasswd perm=wa key=identity/)
|
|
59
|
+
}
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
where each test must declare one (or more) rules to be tested.
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
# Matchers
|
|
66
|
+
|
|
67
|
+
This InSpec audit resource has the following matchers:
|
|
68
|
+
|
|
69
|
+
## be
|
|
70
|
+
|
|
71
|
+
<%= partial "/shared/matcher_be" %>
|
|
72
|
+
|
|
73
|
+
## cmp
|
|
74
|
+
|
|
75
|
+
<%= partial "/shared/matcher_cmp" %>
|
|
76
|
+
|
|
77
|
+
## eq
|
|
78
|
+
|
|
79
|
+
<%= partial "/shared/matcher_eq" %>
|
|
80
|
+
|
|
81
|
+
## include
|
|
82
|
+
|
|
83
|
+
<%= partial "/shared/matcher_include" %>
|
|
84
|
+
|
|
85
|
+
## match
|
|
86
|
+
|
|
87
|
+
<%= partial "/shared/matcher_match" %>
|
|
88
|
+
|
|
89
|
+
# Examples
|
|
90
|
+
|
|
91
|
+
The following examples show how to use this InSpec audit resource.
|
|
92
|
+
|
|
93
|
+
## Test if a rule contains a matching element that is identified by a regular expression
|
|
94
|
+
|
|
95
|
+
For `audit` >= 2.3:
|
|
96
|
+
|
|
97
|
+
describe auditd_rules do
|
|
98
|
+
its('lines') { should contain_match(%r{-w /etc/ssh/sshd_config/}) }
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
For `audit` < 2.3:
|
|
102
|
+
|
|
103
|
+
describe audit_daemon_rules do
|
|
104
|
+
its("LIST_RULES") {
|
|
105
|
+
should contain_match(/^exit,always arch=.*\
|
|
106
|
+
key=time-change\
|
|
107
|
+
syscall=adjtimex,settimeofday/)
|
|
108
|
+
}
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
## Query the audit daemon status
|
|
113
|
+
|
|
114
|
+
describe auditd_rules.status('backlog') do
|
|
115
|
+
it { should cmp 0 }
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
## Query properties of rules targeting specific syscalls or files
|
|
119
|
+
|
|
120
|
+
describe auditd_rules.syscall('open').action do
|
|
121
|
+
it { should eq(['always']) }
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
describe auditd_rules.key('sshd_config') do
|
|
125
|
+
its('permissions') { should contain_match(/x/) }
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
Filters may be chained. For example:
|
|
129
|
+
|
|
130
|
+
describe auditd_rules.syscall('open').action('always').list do
|
|
131
|
+
it { should eq(['exit']) }
|
|
132
|
+
end
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: About the bash Resource
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# bash
|
|
6
|
+
|
|
7
|
+
Use the `bash` InSpec audit resource to test an arbitrary command that is run on the system using a Bash script.
|
|
8
|
+
|
|
9
|
+
# Syntax
|
|
10
|
+
|
|
11
|
+
A `command` resource block declares a command to be run, one (or more) expected outputs, and the location to which that output is sent:
|
|
12
|
+
|
|
13
|
+
describe bash('command') do
|
|
14
|
+
it { should exist }
|
|
15
|
+
its('matcher') { should eq 'output' }
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
where
|
|
19
|
+
|
|
20
|
+
* `'command'` must specify a command to be run
|
|
21
|
+
* `'matcher'` is one of `exit_status`, `stderr`, or `stdout`
|
|
22
|
+
* `'output'` tests the output of the command run on the system versus the output value stated in the test
|
|
23
|
+
|
|
24
|
+
For example:
|
|
25
|
+
|
|
26
|
+
describe bash('ls -al /') do
|
|
27
|
+
its('stdout') { should match /bin/ }
|
|
28
|
+
its('stderr') { should eq '' }
|
|
29
|
+
its('exit_status') { should eq 0 }
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
# Matchers
|
|
34
|
+
|
|
35
|
+
This InSpec audit resource has the following matchers:
|
|
36
|
+
|
|
37
|
+
## be
|
|
38
|
+
|
|
39
|
+
<%= partial "/shared/matcher_be" %>
|
|
40
|
+
|
|
41
|
+
## cmp
|
|
42
|
+
|
|
43
|
+
<%= partial "/shared/matcher_cmp" %>
|
|
44
|
+
|
|
45
|
+
## eq
|
|
46
|
+
|
|
47
|
+
<%= partial "/shared/matcher_eq" %>
|
|
48
|
+
|
|
49
|
+
## exist
|
|
50
|
+
|
|
51
|
+
The `exist` matcher tests if a command may be run on the system:
|
|
52
|
+
|
|
53
|
+
it { should exist }
|
|
54
|
+
|
|
55
|
+
## exit_status
|
|
56
|
+
|
|
57
|
+
The `exit_status` matcher tests the exit status for the command:
|
|
58
|
+
|
|
59
|
+
its('exit_status') { should eq 0 }
|
|
60
|
+
|
|
61
|
+
## include
|
|
62
|
+
|
|
63
|
+
<%= partial "/shared/matcher_include" %>
|
|
64
|
+
|
|
65
|
+
## match
|
|
66
|
+
|
|
67
|
+
<%= partial "/shared/matcher_match" %>
|
|
68
|
+
|
|
69
|
+
## stderr
|
|
70
|
+
|
|
71
|
+
The `stderr` matcher tests results of the command as returned in standard error (stderr):
|
|
72
|
+
|
|
73
|
+
its('stderr') { should eq '' }
|
|
74
|
+
|
|
75
|
+
## stdout
|
|
76
|
+
|
|
77
|
+
The `stdout` matcher tests results of the command as returned in standard output (stdout).
|
|
78
|
+
|
|
79
|
+
its('stdout') { should match /bin/ }
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
# Examples
|
|
83
|
+
|
|
84
|
+
None.
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: About the bond Resource
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# bond
|
|
6
|
+
|
|
7
|
+
Use the `bond` InSpec audit resource to test a logical, bonded network interface (i.e. "two or more network interfaces aggregated into a single, logical network interface"). On Linux platforms, any value in the `/proc/net/bonding` directory may be tested.
|
|
8
|
+
|
|
9
|
+
# Syntax
|
|
10
|
+
|
|
11
|
+
A `bond` resource block declares a bonded network interface, and then specifies the properties of that bonded network interface to be tested:
|
|
12
|
+
|
|
13
|
+
describe bond('name') do
|
|
14
|
+
it { should exist }
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
where
|
|
18
|
+
|
|
19
|
+
* `'name'` is the name of the bonded network interface
|
|
20
|
+
* `{ should exist }` is a valid matcher for this resource
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
# Matchers
|
|
24
|
+
|
|
25
|
+
This InSpec audit resource has the following matchers:
|
|
26
|
+
|
|
27
|
+
## be
|
|
28
|
+
|
|
29
|
+
<%= partial "/shared/matcher_be" %>
|
|
30
|
+
|
|
31
|
+
## cmp
|
|
32
|
+
|
|
33
|
+
<%= partial "/shared/matcher_cmp" %>
|
|
34
|
+
|
|
35
|
+
## content
|
|
36
|
+
|
|
37
|
+
The `content` matcher tests if contents in the file that defines the bonded network interface match the value specified in the test. The values of the `content` matcher are arbitrary:
|
|
38
|
+
|
|
39
|
+
its('content') { should match('value') }
|
|
40
|
+
|
|
41
|
+
## eq
|
|
42
|
+
|
|
43
|
+
<%= partial "/shared/matcher_eq" %>
|
|
44
|
+
|
|
45
|
+
## exist
|
|
46
|
+
|
|
47
|
+
The `exist` matcher tests if the bonded network interface is available:
|
|
48
|
+
|
|
49
|
+
it { should exist }
|
|
50
|
+
|
|
51
|
+
## have_interface
|
|
52
|
+
|
|
53
|
+
The `have_interface` matcher tests if the bonded network interface has one (or more) secondary interfaces:
|
|
54
|
+
|
|
55
|
+
it { should have_interface }
|
|
56
|
+
|
|
57
|
+
## include
|
|
58
|
+
|
|
59
|
+
<%= partial "/shared/matcher_include" %>
|
|
60
|
+
|
|
61
|
+
## interfaces
|
|
62
|
+
|
|
63
|
+
The `interfaces` matcher tests if the named secondary interfaces are available:
|
|
64
|
+
|
|
65
|
+
its('interfaces') { should eq ['eth0', 'eth1', ...] }
|
|
66
|
+
|
|
67
|
+
## match
|
|
68
|
+
|
|
69
|
+
<%= partial "/shared/matcher_match" %>
|
|
70
|
+
|
|
71
|
+
## params
|
|
72
|
+
|
|
73
|
+
The `params` matcher tests arbitrary parameters for the bonded network interface:
|
|
74
|
+
|
|
75
|
+
its('params') { should eq 'value' }
|
|
76
|
+
|
|
77
|
+
# Examples
|
|
78
|
+
|
|
79
|
+
The following examples show how to use this InSpec audit resource.
|
|
80
|
+
|
|
81
|
+
## Test if eth0 is a secondary interface for bond0
|
|
82
|
+
|
|
83
|
+
describe bond('bond0') do
|
|
84
|
+
it { should exist }
|
|
85
|
+
it { should have_interface 'eth0' }
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
## Test parameters for bond0
|
|
89
|
+
|
|
90
|
+
describe bond('bond0') do
|
|
91
|
+
its('Bonding Mode') { should eq 'IEEE 802.3ad Dynamic link aggregation' }
|
|
92
|
+
its('Transmit Hash Policy') { should eq 'layer3+4 (1)' }
|
|
93
|
+
its('MII Status') { should eq 'up' }
|
|
94
|
+
its('MII Polling Interval (ms)') { should eq '100' }
|
|
95
|
+
its('Up Delay (ms)') { should eq '0' }
|
|
96
|
+
its('Down Delay (ms)') { should eq '0' }
|
|
97
|
+
end
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: About the bridge Resource
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# bridge
|
|
6
|
+
|
|
7
|
+
Use the `bridge` InSpec audit resource to test basic network bridge properties, such as name, if an interface is defined, and the associations for any defined interface.
|
|
8
|
+
|
|
9
|
+
* On Linux platforms, any value in the `/sys/class/net/{interface}/bridge` directory may be tested
|
|
10
|
+
* On the Windows platform, the `Get-NetAdapter` cmdlet is associated with the `Get-NetAdapterBinding` cmdlet and returns the `ComponentID ms_bridge` value as a JSON object
|
|
11
|
+
|
|
12
|
+
# Syntax
|
|
13
|
+
|
|
14
|
+
A `bridge` resource block declares the bridge to be tested and what interface it should be associated with:
|
|
15
|
+
|
|
16
|
+
describe bridge('br0') do
|
|
17
|
+
it { should exist }
|
|
18
|
+
it { should have_interface 'eth0' }
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# Matchers
|
|
22
|
+
|
|
23
|
+
This InSpec audit resource has the following matchers:
|
|
24
|
+
|
|
25
|
+
## be
|
|
26
|
+
|
|
27
|
+
<%= partial "/shared/matcher_be" %>
|
|
28
|
+
|
|
29
|
+
## cmp
|
|
30
|
+
|
|
31
|
+
<%= partial "/shared/matcher_cmp" %>
|
|
32
|
+
|
|
33
|
+
## eq
|
|
34
|
+
|
|
35
|
+
<%= partial "/shared/matcher_eq" %>
|
|
36
|
+
|
|
37
|
+
## exist
|
|
38
|
+
|
|
39
|
+
The `exist` matcher tests if the network bridge is available:
|
|
40
|
+
|
|
41
|
+
it { should exist }
|
|
42
|
+
|
|
43
|
+
## have_interface
|
|
44
|
+
|
|
45
|
+
The `have_interface` matcher tests if the named interface is defined for the network bridge:
|
|
46
|
+
|
|
47
|
+
it { should have_interface 'eth0' }
|
|
48
|
+
|
|
49
|
+
## include
|
|
50
|
+
|
|
51
|
+
<%= partial "/shared/matcher_include" %>
|
|
52
|
+
|
|
53
|
+
## interfaces
|
|
54
|
+
|
|
55
|
+
The `interfaces` matcher tests if the named interface is present:
|
|
56
|
+
|
|
57
|
+
its('interfaces') { should eq 'foo' }
|
|
58
|
+
its('interfaces') { should eq 'bar' }
|
|
59
|
+
its('interfaces') { should include('foo') }
|
|
60
|
+
|
|
61
|
+
## match
|
|
62
|
+
|
|
63
|
+
<%= partial "/shared/matcher_match" %>
|
|
64
|
+
|
|
65
|
+
# Examples
|
|
66
|
+
|
|
67
|
+
None.
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: About the bsd_service Resource
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# bsd_service
|
|
6
|
+
|
|
7
|
+
Use the `bsd_service` InSpec audit resource to test a service using a Berkeley OS-style `init` on the FreeBSD platform.
|
|
8
|
+
|
|
9
|
+
# Syntax
|
|
10
|
+
|
|
11
|
+
A `bsd_service` resource block declares the name of a service and then one (or more) matchers to test the state of the service:
|
|
12
|
+
|
|
13
|
+
describe bsd_service('service_name') do
|
|
14
|
+
it { should be_installed }
|
|
15
|
+
it { should be_enabled }
|
|
16
|
+
it { should be_running }
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
where
|
|
20
|
+
|
|
21
|
+
* `('service_name')` must specify a service name
|
|
22
|
+
* `be_installed`, `be_enabled`, and `be_running` are valid matchers for this resource; all matchers available to the `service` resource may be used
|
|
23
|
+
|
|
24
|
+
The path to the service manager's control may be specified for situations where the path isn't available in the current `PATH`. For example:
|
|
25
|
+
|
|
26
|
+
describe bsd_service('service_name', '/path/to/control') do
|
|
27
|
+
it { should be_enabled }
|
|
28
|
+
it { should be_installed }
|
|
29
|
+
it { should be_running }
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
# Matchers
|
|
33
|
+
|
|
34
|
+
This InSpec audit resource has the following matchers:
|
|
35
|
+
|
|
36
|
+
## be
|
|
37
|
+
|
|
38
|
+
<%= partial "/shared/matcher_be" %>
|
|
39
|
+
|
|
40
|
+
## be_enabled
|
|
41
|
+
|
|
42
|
+
The `be_enabled` matcher tests if the named service is enabled:
|
|
43
|
+
|
|
44
|
+
it { should be_enabled }
|
|
45
|
+
|
|
46
|
+
## be_installed
|
|
47
|
+
|
|
48
|
+
The `be_installed` matcher tests if the named service is installed:
|
|
49
|
+
|
|
50
|
+
it { should be_installed }
|
|
51
|
+
|
|
52
|
+
## be_running
|
|
53
|
+
|
|
54
|
+
The `be_running` matcher tests if the named service is running:
|
|
55
|
+
|
|
56
|
+
it { should be_running }
|
|
57
|
+
|
|
58
|
+
## cmp
|
|
59
|
+
|
|
60
|
+
<%= partial "/shared/matcher_cmp" %>
|
|
61
|
+
|
|
62
|
+
## eq
|
|
63
|
+
|
|
64
|
+
<%= partial "/shared/matcher_eq" %>
|
|
65
|
+
|
|
66
|
+
## include
|
|
67
|
+
|
|
68
|
+
<%= partial "/shared/matcher_include" %>
|
|
69
|
+
|
|
70
|
+
## match
|
|
71
|
+
|
|
72
|
+
<%= partial "/shared/matcher_match" %>
|
|
73
|
+
|
|
74
|
+
# Examples
|
|
75
|
+
|
|
76
|
+
None.
|