inspec 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +8 -0
- data/.rubocop.yml +65 -0
- data/.travis.yml +23 -0
- data/CHANGELOG.md +38 -0
- data/Gemfile +33 -0
- data/LICENSE +201 -0
- data/MAINTAINERS.md +28 -0
- data/MAINTAINERS.toml +42 -0
- data/README.md +257 -0
- data/Rakefile +47 -0
- data/bin/inspec +109 -0
- data/docs/ctl_inspec.rst +195 -0
- data/docs/dsl_inspec.rst +182 -0
- data/docs/readme.rst +100 -0
- data/docs/resources.rst +4319 -0
- data/docs/template.rst +51 -0
- data/examples/test-kitchen/.kitchen.yml +20 -0
- data/examples/test-kitchen/Berksfile +3 -0
- data/examples/test-kitchen/Gemfile +21 -0
- data/examples/test-kitchen/README.md +27 -0
- data/examples/test-kitchen/metadata.rb +7 -0
- data/examples/test-kitchen/recipes/default.rb +6 -0
- data/examples/test-kitchen/recipes/nginx.rb +30 -0
- data/examples/test-kitchen/test/integration/default/web_spec.rb +28 -0
- data/inspec.gemspec +30 -0
- data/lib/inspec.rb +20 -0
- data/lib/inspec/backend.rb +42 -0
- data/lib/inspec/dsl.rb +151 -0
- data/lib/inspec/log.rb +34 -0
- data/lib/inspec/metadata.rb +79 -0
- data/lib/inspec/plugins.rb +9 -0
- data/lib/inspec/plugins/resource.rb +62 -0
- data/lib/inspec/profile.rb +138 -0
- data/lib/inspec/profile_context.rb +170 -0
- data/lib/inspec/resource.rb +76 -0
- data/lib/inspec/rspec_json_formatter.rb +27 -0
- data/lib/inspec/rule.rb +170 -0
- data/lib/inspec/runner.rb +154 -0
- data/lib/inspec/shell.rb +66 -0
- data/lib/inspec/targets.rb +9 -0
- data/lib/inspec/targets/core.rb +27 -0
- data/lib/inspec/targets/dir.rb +67 -0
- data/lib/inspec/targets/file.rb +29 -0
- data/lib/inspec/targets/folder.rb +43 -0
- data/lib/inspec/targets/tar.rb +34 -0
- data/lib/inspec/targets/url.rb +39 -0
- data/lib/inspec/targets/zip.rb +47 -0
- data/lib/inspec/version.rb +7 -0
- data/lib/matchers/matchers.rb +221 -0
- data/lib/resources/apache.rb +29 -0
- data/lib/resources/apache_conf.rb +113 -0
- data/lib/resources/apt.rb +140 -0
- data/lib/resources/audit_policy.rb +63 -0
- data/lib/resources/auditd_conf.rb +56 -0
- data/lib/resources/auditd_rules.rb +53 -0
- data/lib/resources/bond.rb +65 -0
- data/lib/resources/bridge.rb +114 -0
- data/lib/resources/command.rb +57 -0
- data/lib/resources/csv.rb +32 -0
- data/lib/resources/directory.rb +15 -0
- data/lib/resources/etc_group.rb +150 -0
- data/lib/resources/file.rb +110 -0
- data/lib/resources/gem.rb +46 -0
- data/lib/resources/group.rb +132 -0
- data/lib/resources/host.rb +143 -0
- data/lib/resources/inetd_conf.rb +56 -0
- data/lib/resources/interface.rb +127 -0
- data/lib/resources/iptables.rb +65 -0
- data/lib/resources/json.rb +64 -0
- data/lib/resources/kernel_module.rb +40 -0
- data/lib/resources/kernel_parameter.rb +55 -0
- data/lib/resources/limits_conf.rb +55 -0
- data/lib/resources/login_def.rb +60 -0
- data/lib/resources/mysql.rb +81 -0
- data/lib/resources/mysql_conf.rb +116 -0
- data/lib/resources/mysql_session.rb +52 -0
- data/lib/resources/npm.rb +44 -0
- data/lib/resources/ntp_conf.rb +58 -0
- data/lib/resources/oneget.rb +63 -0
- data/lib/resources/os.rb +22 -0
- data/lib/resources/os_env.rb +34 -0
- data/lib/resources/package.rb +169 -0
- data/lib/resources/parse_config.rb +75 -0
- data/lib/resources/passwd.rb +93 -0
- data/lib/resources/pip.rb +75 -0
- data/lib/resources/port.rb +296 -0
- data/lib/resources/postgres.rb +37 -0
- data/lib/resources/postgres_conf.rb +87 -0
- data/lib/resources/postgres_session.rb +59 -0
- data/lib/resources/processes.rb +57 -0
- data/lib/resources/registry_key.rb +54 -0
- data/lib/resources/script.rb +34 -0
- data/lib/resources/security_policy.rb +73 -0
- data/lib/resources/service.rb +379 -0
- data/lib/resources/ssh_conf.rb +75 -0
- data/lib/resources/user.rb +374 -0
- data/lib/resources/windows_feature.rb +77 -0
- data/lib/resources/yaml.rb +23 -0
- data/lib/resources/yum.rb +154 -0
- data/lib/utils/convert.rb +12 -0
- data/lib/utils/detect.rb +15 -0
- data/lib/utils/find_files.rb +36 -0
- data/lib/utils/hash.rb +13 -0
- data/lib/utils/modulator.rb +12 -0
- data/lib/utils/parser.rb +61 -0
- data/lib/utils/simpleconfig.rb +115 -0
- data/tasks/maintainers.rb +213 -0
- data/test/docker_run.rb +156 -0
- data/test/docker_test.rb +51 -0
- data/test/helper.rb +200 -0
- data/test/integration/.kitchen.yml +42 -0
- data/test/integration/Berksfile +4 -0
- data/test/integration/cookbooks/os_prepare/metadata.rb +8 -0
- data/test/integration/cookbooks/os_prepare/recipes/apt.rb +20 -0
- data/test/integration/cookbooks/os_prepare/recipes/default.rb +9 -0
- data/test/integration/cookbooks/os_prepare/recipes/file.rb +21 -0
- data/test/integration/cookbooks/os_prepare/recipes/package.rb +26 -0
- data/test/integration/default/_debug_spec.rb +1 -0
- data/test/integration/default/apt_spec.rb +42 -0
- data/test/integration/default/file_spec.rb +109 -0
- data/test/integration/default/group_spec.rb +32 -0
- data/test/integration/default/kernel_module_spec.rb +17 -0
- data/test/integration/default/kernel_parameter_spec.rb +56 -0
- data/test/integration/default/package_spec.rb +11 -0
- data/test/integration/default/service_spec.rb +28 -0
- data/test/integration/default/user_spec.rb +44 -0
- data/test/resource/command_test.rb +33 -0
- data/test/resource/dsl_test.rb +45 -0
- data/test/resource/file_test.rb +130 -0
- data/test/resource/ssh_config.rb +9 -0
- data/test/resource/sshd_config.rb +9 -0
- data/test/test-extra.yaml +11 -0
- data/test/test.yaml +11 -0
- data/test/unit/mock/cmd/Get-NetAdapter +24 -0
- data/test/unit/mock/cmd/GetUserAccount +33 -0
- data/test/unit/mock/cmd/GetWin32Group +23 -0
- data/test/unit/mock/cmd/PATH +1 -0
- data/test/unit/mock/cmd/Resolve-DnsName +26 -0
- data/test/unit/mock/cmd/Test-NetConnection +4 -0
- data/test/unit/mock/cmd/auditctl +7 -0
- data/test/unit/mock/cmd/auditpol +2 -0
- data/test/unit/mock/cmd/brew-info-jq +1 -0
- data/test/unit/mock/cmd/chage-l-root +7 -0
- data/test/unit/mock/cmd/dpkg-s-curl +21 -0
- data/test/unit/mock/cmd/dscl +5 -0
- data/test/unit/mock/cmd/etc-apt +7 -0
- data/test/unit/mock/cmd/find-etc-rc-d-name-S +12 -0
- data/test/unit/mock/cmd/find-net-interface +9 -0
- data/test/unit/mock/cmd/gem-list-local-a-q-rubocop +1 -0
- data/test/unit/mock/cmd/get-net-tcpconnection +24 -0
- data/test/unit/mock/cmd/get-netadapter-binding-bridge +4 -0
- data/test/unit/mock/cmd/get-package-firefox +30 -0
- data/test/unit/mock/cmd/get-package-ruby +18 -0
- data/test/unit/mock/cmd/get-service-dhcp +10 -0
- data/test/unit/mock/cmd/get-windows-feature +7 -0
- data/test/unit/mock/cmd/getent-hosts-example.com +1 -0
- data/test/unit/mock/cmd/getent-passwd-root +1 -0
- data/test/unit/mock/cmd/id-chartmann +1 -0
- data/test/unit/mock/cmd/id-root +1 -0
- data/test/unit/mock/cmd/initctl-show-config-ssh +3 -0
- data/test/unit/mock/cmd/initctl-status-ssh +1 -0
- data/test/unit/mock/cmd/iptables-s +6 -0
- data/test/unit/mock/cmd/launchctl-list +3 -0
- data/test/unit/mock/cmd/ls-1-etc-init.d +2 -0
- data/test/unit/mock/cmd/ls-sys-class-net-br +2 -0
- data/test/unit/mock/cmd/lsmod +2 -0
- data/test/unit/mock/cmd/lsof-np-itcp +4 -0
- data/test/unit/mock/cmd/netstat-tulpen +5 -0
- data/test/unit/mock/cmd/npm-ls-g--json-bower +9 -0
- data/test/unit/mock/cmd/pacman-qi-curl +21 -0
- data/test/unit/mock/cmd/ping-example.com +6 -0
- data/test/unit/mock/cmd/pip-show-jinja2 +11 -0
- data/test/unit/mock/cmd/ps-aux +3 -0
- data/test/unit/mock/cmd/pw-usershow-root-7 +1 -0
- data/test/unit/mock/cmd/reg_schedule +1 -0
- data/test/unit/mock/cmd/rpm-qia-curl +24 -0
- data/test/unit/mock/cmd/sbin_sysctl +1 -0
- data/test/unit/mock/cmd/secedit-export +7 -0
- data/test/unit/mock/cmd/service-e +2 -0
- data/test/unit/mock/cmd/service-sendmail-onestatus +3 -0
- data/test/unit/mock/cmd/service-sshd-status +1 -0
- data/test/unit/mock/cmd/sockstat +5 -0
- data/test/unit/mock/cmd/success +0 -0
- data/test/unit/mock/cmd/systemctl-show-all-sshd +6 -0
- data/test/unit/mock/cmd/win32_product +8 -0
- data/test/unit/mock/cmd/yum-repolist-all +52 -0
- data/test/unit/mock/files/auditd.conf +4 -0
- data/test/unit/mock/files/bond0 +37 -0
- data/test/unit/mock/files/etcgroup +3 -0
- data/test/unit/mock/files/example.csv +6 -0
- data/test/unit/mock/files/inetd.conf +2 -0
- data/test/unit/mock/files/kitchen.yml +7 -0
- data/test/unit/mock/files/limits.conf +5 -0
- data/test/unit/mock/files/login.defs +5 -0
- data/test/unit/mock/files/mysql.conf +8 -0
- data/test/unit/mock/files/mysql2.conf +2 -0
- data/test/unit/mock/files/ntp.conf +5 -0
- data/test/unit/mock/files/passwd +2 -0
- data/test/unit/mock/files/policyfile.lock.json +12 -0
- data/test/unit/mock/files/ssh_config +5 -0
- data/test/unit/mock/files/sshd_config +7 -0
- data/test/unit/mock/profiles/empty/metadata.rb +0 -0
- data/test/unit/mock/profiles/metadata/metadata.rb +1 -0
- data/test/unit/profile_context_test.rb +140 -0
- data/test/unit/profile_test.rb +49 -0
- data/test/unit/resources/apt_test.rb +46 -0
- data/test/unit/resources/audit_policy_test.rb +13 -0
- data/test/unit/resources/auditd_conf_test.rb +15 -0
- data/test/unit/resources/auditd_rules_test.rb +21 -0
- data/test/unit/resources/bond_test.rb +24 -0
- data/test/unit/resources/bridge_test.rb +56 -0
- data/test/unit/resources/csv_test.rb +35 -0
- data/test/unit/resources/etc_group_test.rb +37 -0
- data/test/unit/resources/gem_test.rb +20 -0
- data/test/unit/resources/group_test.rb +96 -0
- data/test/unit/resources/host_test.rb +38 -0
- data/test/unit/resources/inetd_conf_test.rb +15 -0
- data/test/unit/resources/interface_test.rb +54 -0
- data/test/unit/resources/iptables_test.rb +30 -0
- data/test/unit/resources/json_test.rb +36 -0
- data/test/unit/resources/kernel_module_test.rb +23 -0
- data/test/unit/resources/kernel_parameter_test.rb +13 -0
- data/test/unit/resources/limits_conf_test.rb +14 -0
- data/test/unit/resources/login_def_test.rb +16 -0
- data/test/unit/resources/mysql_conf_test.rb +14 -0
- data/test/unit/resources/npm_test.rb +20 -0
- data/test/unit/resources/ntp_conf_test.rb +16 -0
- data/test/unit/resources/oneget_test.rb +45 -0
- data/test/unit/resources/os_env_test.rb +13 -0
- data/test/unit/resources/package_test.rb +51 -0
- data/test/unit/resources/passwd_test.rb +24 -0
- data/test/unit/resources/pip_test.rb +15 -0
- data/test/unit/resources/port_test.rb +46 -0
- data/test/unit/resources/processes_test.rb +32 -0
- data/test/unit/resources/registry_key_test.rb +19 -0
- data/test/unit/resources/script_test.rb +19 -0
- data/test/unit/resources/security_policy_test.rb +16 -0
- data/test/unit/resources/service_test.rb +116 -0
- data/test/unit/resources/ssh_conf_test.rb +33 -0
- data/test/unit/resources/user_test.rb +93 -0
- data/test/unit/resources/windows_feature.rb +17 -0
- data/test/unit/resources/yaml_test.rb +34 -0
- data/test/unit/resources/yum_test.rb +68 -0
- data/test/unit/simpleconfig_test.rb +80 -0
- data/test/unit/utils/content_parser_test.rb +30 -0
- metadata +555 -0
@@ -0,0 +1,37 @@
|
|
1
|
+
Ethernet Channel Bonding Driver: v3.7.1 (April 27, 2011)
|
2
|
+
|
3
|
+
Bonding Mode: IEEE 802.3ad Dynamic link aggregation
|
4
|
+
Transmit Hash Policy: layer3+4 (1)
|
5
|
+
MII Status: up
|
6
|
+
MII Polling Interval (ms): 100
|
7
|
+
Up Delay (ms): 0
|
8
|
+
Down Delay (ms): 0
|
9
|
+
|
10
|
+
802.3ad info
|
11
|
+
LACP rate: fast
|
12
|
+
Min links: 0
|
13
|
+
Aggregator selection policy (ad_select): stable
|
14
|
+
Active Aggregator Info:
|
15
|
+
Aggregator ID: 1
|
16
|
+
Number of ports: 1
|
17
|
+
Actor Key: 9
|
18
|
+
Partner Key: 29
|
19
|
+
Partner Mac Address: 0d:4b:d1:26:32:0e
|
20
|
+
|
21
|
+
Slave Interface: eth0
|
22
|
+
MII Status: up
|
23
|
+
Speed: 100 Mbps
|
24
|
+
Duplex: full
|
25
|
+
Link Failure Count: 0
|
26
|
+
Permanent HW addr: 2e:b7:8d:61:2c:51
|
27
|
+
Aggregator ID: 1
|
28
|
+
Slave queue ID: 0
|
29
|
+
|
30
|
+
Slave Interface: eth2
|
31
|
+
MII Status: down
|
32
|
+
Speed: Unknown
|
33
|
+
Duplex: Unknown
|
34
|
+
Link Failure Count: 0
|
35
|
+
Permanent HW addr: 5a:57:54:66:38:64
|
36
|
+
Aggregator ID: 2
|
37
|
+
Slave queue ID: 0
|
@@ -0,0 +1,6 @@
|
|
1
|
+
addressable,2.3.6,Apache 2.0,URI Implementation,"Addressable is a replacement for the URI implementation that is part of
|
2
|
+
Ruby's standard library. It more closely conforms to the relevant RFCs and
|
3
|
+
adds support for IRIs and URI templates."
|
4
|
+
ast,2.0.0,MIT,A library for working with Abstract Syntax Trees.,A library for working with Abstract Syntax Trees.
|
5
|
+
astrolabe,1.3.0,MIT,An object-oriented AST extension for Parser,An object-oriented AST extension for Parser
|
6
|
+
berkshelf,3.2.3,Apache 2.0,"Manages a Cookbook's, or an Application's, Cookbook dependencies","Manages a Cookbook's, or an Application's, Cookbook dependencies"
|
File without changes
|
@@ -0,0 +1 @@
|
|
1
|
+
name 'metadata profile'
|
@@ -0,0 +1,140 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
# author: Dominik Richter
|
3
|
+
# author: Christoph Hartmann
|
4
|
+
|
5
|
+
require 'helper'
|
6
|
+
require 'inspec/profile_context'
|
7
|
+
|
8
|
+
describe Inspec::ProfileContext do
|
9
|
+
let(:backend) { MockLoader.new.backend }
|
10
|
+
let(:profile) { Inspec::ProfileContext.new(nil, backend) }
|
11
|
+
|
12
|
+
it 'must be able to load empty content' do
|
13
|
+
profile.load('', 'dummy', 1).must_be_nil
|
14
|
+
end
|
15
|
+
|
16
|
+
describe 'its default DSL' do
|
17
|
+
def load(call)
|
18
|
+
proc { profile.load(call) }
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'must provide os resource' do
|
22
|
+
load('print os[:family]').must_output 'ubuntu'
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'must profide file resource' do
|
26
|
+
load('print file("").type').must_output 'unknown'
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'must profide command resource' do
|
30
|
+
load('print command("").stdout').must_output ''
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'provides the describe keyword in the global DSL' do
|
34
|
+
load('describe true do; it { should_eq true }; end')
|
35
|
+
.must_output ''
|
36
|
+
profile.rules.keys.must_equal ['unknown:1']
|
37
|
+
profile.rules.values[0].must_be_kind_of Inspec::Rule
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'does not provide the expect keyword in the global DLS' do
|
41
|
+
load('expect(true).to_eq true').must_raise NoMethodError
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'provides the rule keyword in the global DSL' do
|
45
|
+
profile.load('rule 1')
|
46
|
+
profile.rules.keys.must_equal [1]
|
47
|
+
profile.rules.values[0].must_be_kind_of Inspec::Rule
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
describe 'rule DSL' do
|
52
|
+
let(:rule_id) { rand.to_s }
|
53
|
+
|
54
|
+
it 'doesnt add any checks if none are provided' do
|
55
|
+
profile.load("rule #{rule_id.inspect}")
|
56
|
+
rule = profile.rules[rule_id]
|
57
|
+
rule.instance_variable_get(:@checks).must_equal([])
|
58
|
+
end
|
59
|
+
|
60
|
+
describe 'adds a check via describe' do
|
61
|
+
let(:cmd) {<<-EOF
|
62
|
+
rule #{rule_id.inspect} do
|
63
|
+
describe os[:family] { it { must_equal 'ubuntu' } }
|
64
|
+
end
|
65
|
+
EOF
|
66
|
+
}
|
67
|
+
let(:check) {
|
68
|
+
profile.load(cmd)
|
69
|
+
rule = profile.rules[rule_id]
|
70
|
+
rule.instance_variable_get(:@checks)[0]
|
71
|
+
}
|
72
|
+
|
73
|
+
it 'registers the check with describe' do
|
74
|
+
check[0].must_equal 'describe'
|
75
|
+
end
|
76
|
+
|
77
|
+
it 'registers the check with the describe argument' do
|
78
|
+
check[1].must_equal %w{ubuntu}
|
79
|
+
end
|
80
|
+
|
81
|
+
it 'registers the check with the provided proc' do
|
82
|
+
check[2].must_be_kind_of Proc
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
describe 'adds a check via expect' do
|
87
|
+
let(:cmd) {<<-EOF
|
88
|
+
rule #{rule_id.inspect} do
|
89
|
+
expect(os[:family]).to eq('ubuntu')
|
90
|
+
end
|
91
|
+
EOF
|
92
|
+
}
|
93
|
+
let(:check) {
|
94
|
+
profile.load(cmd)
|
95
|
+
rule = profile.rules[rule_id]
|
96
|
+
rule.instance_variable_get(:@checks)[0]
|
97
|
+
}
|
98
|
+
|
99
|
+
it 'registers the check with describe' do
|
100
|
+
check[0].must_equal 'expect'
|
101
|
+
end
|
102
|
+
|
103
|
+
it 'registers the check with the describe argument' do
|
104
|
+
check[1].must_equal %w{ubuntu}
|
105
|
+
end
|
106
|
+
|
107
|
+
it 'registers the check with the provided proc' do
|
108
|
+
check[2].must_be_kind_of Inspec::ExpectationTarget
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
describe 'adds a check via describe + expect' do
|
113
|
+
let(:cmd) {<<-EOF
|
114
|
+
rule #{rule_id.inspect} do
|
115
|
+
describe 'the actual test' do
|
116
|
+
expect(os[:family]).to eq('ubuntu')
|
117
|
+
end
|
118
|
+
end
|
119
|
+
EOF
|
120
|
+
}
|
121
|
+
let(:check) {
|
122
|
+
profile.load(cmd)
|
123
|
+
rule = profile.rules[rule_id]
|
124
|
+
rule.instance_variable_get(:@checks)[0]
|
125
|
+
}
|
126
|
+
|
127
|
+
it 'registers the check with describe' do
|
128
|
+
check[0].must_equal 'describe'
|
129
|
+
end
|
130
|
+
|
131
|
+
it 'registers the check with the describe argument' do
|
132
|
+
check[1].must_equal ['the actual test']
|
133
|
+
end
|
134
|
+
|
135
|
+
it 'registers the check with the provided proc' do
|
136
|
+
check[2].must_be_kind_of Proc
|
137
|
+
end
|
138
|
+
end
|
139
|
+
end
|
140
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
# author: Christoph Hartmann
|
3
|
+
# author: Dominik Richter
|
4
|
+
|
5
|
+
require 'helper'
|
6
|
+
|
7
|
+
def load_profile(name)
|
8
|
+
pwd = File.dirname(__FILE__)
|
9
|
+
Inspec::Profile.from_path("#{pwd}/mock/profiles/#{name}")
|
10
|
+
end
|
11
|
+
|
12
|
+
describe Inspec::Profile do
|
13
|
+
before {
|
14
|
+
# mock up the profile runner
|
15
|
+
# TODO: try to take the real profile runner here;
|
16
|
+
# currently it's stopped at test runner conflicts
|
17
|
+
class Inspec::Profile::Runner
|
18
|
+
def initialize(opts) end
|
19
|
+
def add_tests(tests) end
|
20
|
+
def rules
|
21
|
+
{}
|
22
|
+
end
|
23
|
+
end
|
24
|
+
}
|
25
|
+
|
26
|
+
describe 'with empty profile' do
|
27
|
+
let(:profile) { load_profile('empty') }
|
28
|
+
|
29
|
+
it 'has no metadata' do
|
30
|
+
profile.params[:name].must_be_nil
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'has no rules' do
|
34
|
+
profile.params[:rules].must_equal({})
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
describe 'with normal metadata in profile' do
|
39
|
+
let(:profile) { load_profile('metadata') }
|
40
|
+
|
41
|
+
it 'has metadata' do
|
42
|
+
profile.params[:name].must_equal 'metadata profile'
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'has no rules' do
|
46
|
+
profile.params[:rules].must_equal({})
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
# author: Christoph Hartmann
|
3
|
+
# author: Dominik Richter
|
4
|
+
|
5
|
+
require 'helper'
|
6
|
+
require 'inspec/resource'
|
7
|
+
|
8
|
+
describe 'Inspec::Resources::AptRepo' do
|
9
|
+
|
10
|
+
it 'check apt on ubuntu' do
|
11
|
+
resource = MockLoader.new(:ubuntu1504).load_resource('apt', 'http://archive.ubuntu.com/ubuntu/')
|
12
|
+
_(resource.exists?).must_equal true
|
13
|
+
_(resource.enabled?).must_equal true
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'check apt on ubuntu with ppa' do
|
17
|
+
resource = MockLoader.new(:ubuntu1504).load_resource('apt', 'ubuntu-wine/ppa')
|
18
|
+
_(resource.exists?).must_equal true
|
19
|
+
_(resource.enabled?).must_equal true
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'check apt on ubuntu with ppa' do
|
23
|
+
resource = MockLoader.new(:ubuntu1504).load_resource('apt', 'ppa:ubuntu-wine/ppa')
|
24
|
+
_(resource.exists?).must_equal true
|
25
|
+
_(resource.enabled?).must_equal true
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'check apt on debian' do
|
29
|
+
resource = MockLoader.new(:ubuntu1504).load_resource('apt', 'http://archive.ubuntu.com/ubuntu/')
|
30
|
+
_(resource.exists?).must_equal true
|
31
|
+
_(resource.enabled?).must_equal true
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'check apt on unknown os' do
|
35
|
+
resource = MockLoader.new(:undefined).load_resource('apt', 'ubuntu-wine/ppa')
|
36
|
+
_(resource.exists?).must_equal false
|
37
|
+
_(resource.enabled?).must_equal false
|
38
|
+
end
|
39
|
+
|
40
|
+
# check ppa resource
|
41
|
+
it 'check apt on ubuntu' do
|
42
|
+
resource = MockLoader.new(:ubuntu1504).load_resource('ppa', 'ubuntu-wine/ppa')
|
43
|
+
_(resource.exists?).must_equal true
|
44
|
+
_(resource.enabled?).must_equal true
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
# author: Christoph Hartmann
|
3
|
+
# author: Dominik Richter
|
4
|
+
|
5
|
+
require 'helper'
|
6
|
+
require 'inspec/resource'
|
7
|
+
|
8
|
+
describe 'Inspec::Resources::AuditPolicy' do
|
9
|
+
it 'check audit policy parsing' do
|
10
|
+
resource = MockLoader.new(:windows).load_resource('audit_policy')
|
11
|
+
_(resource.send('User Account Management')).must_equal 'Success'
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
# author: Christoph Hartmann
|
3
|
+
# author: Dominik Richter
|
4
|
+
|
5
|
+
require 'helper'
|
6
|
+
require 'inspec/resource'
|
7
|
+
|
8
|
+
describe 'Inspec::Resources::AuditDaemonConf' do
|
9
|
+
it 'check audit daemon config parsing' do
|
10
|
+
resource = MockLoader.new(:windows).load_resource('auditd_conf')
|
11
|
+
_(resource.space_left_action).must_equal 'SYSLOG'
|
12
|
+
_(resource.action_mail_acct).must_equal 'root'
|
13
|
+
_(resource.tcp_listen_queue).must_equal '5'
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
# author: Christoph Hartmann
|
3
|
+
# author: Dominik Richter
|
4
|
+
|
5
|
+
require 'helper'
|
6
|
+
require 'inspec/resource'
|
7
|
+
|
8
|
+
describe 'Inspec::Resources::AuditDaemonRules' do
|
9
|
+
it 'check audit policy parsing' do
|
10
|
+
resource = MockLoader.new(:windows).load_resource('auditd_rules')
|
11
|
+
_(resource.send('LIST_RULES')).must_equal [
|
12
|
+
'exit,always syscall=rmdir,unlink',
|
13
|
+
'exit,always auid=1001 (0x3e9) syscall=open',
|
14
|
+
'exit,always watch=/etc/group perm=wa',
|
15
|
+
'exit,always watch=/etc/passwd perm=wa',
|
16
|
+
'exit,always watch=/etc/shadow perm=wa',
|
17
|
+
'exit,always watch=/etc/sudoers perm=wa',
|
18
|
+
'exit,always watch=/etc/secret_directory perm=r',
|
19
|
+
]
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
# author: Christoph Hartmann
|
3
|
+
# author: Dominik Richter
|
4
|
+
|
5
|
+
require 'helper'
|
6
|
+
require 'inspec/resource'
|
7
|
+
|
8
|
+
describe 'Inspec::Resources::Bond' do
|
9
|
+
|
10
|
+
it 'check linux bond on ubuntu' do
|
11
|
+
resource = MockLoader.new(:ubuntu1404).load_resource('bond', 'bond0')
|
12
|
+
# bond must be available
|
13
|
+
resource.exist?.must_equal true
|
14
|
+
# eth0 is part of bond
|
15
|
+
_(resource.has_interface?('eth0')).must_equal true
|
16
|
+
_(resource.has_interface?('eth1')).must_equal false
|
17
|
+
_(resource.has_interface?('eth2')).must_equal true
|
18
|
+
# get all interfaces
|
19
|
+
_(resource.interfaces).must_equal %w{eth0 eth2}
|
20
|
+
# get proc content
|
21
|
+
_(resource.content).wont_equal nil
|
22
|
+
_(resource.content).wont_equal ''
|
23
|
+
end
|
24
|
+
end
|