inspec-core 2.2.55 → 2.2.61
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 +24 -8
- data/docs/resources/aide_conf.md.erb +10 -0
- data/docs/resources/apache.md.erb +10 -0
- data/docs/resources/apache_conf.md.erb +10 -0
- data/docs/resources/apt.md.erb +10 -0
- data/docs/resources/audit_policy.md.erb +10 -0
- data/docs/resources/auditd.md.erb +10 -0
- data/docs/resources/auditd_conf.md.erb +10 -0
- data/docs/resources/bash.md.erb +10 -0
- data/docs/resources/bond.md.erb +10 -0
- data/docs/resources/bridge.md.erb +10 -0
- data/docs/resources/bsd_service.md.erb +10 -0
- data/docs/resources/chocolatey_package.md.erb +10 -0
- data/docs/resources/command.md.erb +10 -0
- data/docs/resources/cpan.md.erb +10 -0
- data/docs/resources/cran.md.erb +10 -0
- data/docs/resources/crontab.md.erb +10 -0
- data/docs/resources/csv.md.erb +10 -0
- data/docs/resources/dh_params.md.erb +10 -0
- data/docs/resources/directory.md.erb +10 -0
- data/docs/resources/docker.md.erb +21 -0
- data/docs/resources/docker_container.md.erb +10 -0
- data/docs/resources/docker_image.md.erb +10 -0
- data/docs/resources/docker_plugin.md.erb +80 -0
- data/docs/resources/docker_service.md.erb +10 -0
- data/docs/resources/elasticsearch.md.erb +10 -0
- data/docs/resources/etc_fstab.md.erb +10 -0
- data/docs/resources/etc_group.md.erb +10 -0
- data/docs/resources/etc_hosts.md.erb +10 -0
- data/docs/resources/etc_hosts_allow.md.erb +10 -0
- data/docs/resources/etc_hosts_deny.md.erb +10 -0
- data/docs/resources/file.md.erb +10 -0
- data/docs/resources/filesystem.md.erb +10 -0
- data/docs/resources/firewalld.md.erb +10 -0
- data/docs/resources/gem.md.erb +10 -0
- data/docs/resources/group.md.erb +10 -0
- data/docs/resources/grub_conf.md.erb +10 -0
- data/docs/resources/host.md.erb +10 -0
- data/docs/resources/http.md.erb +10 -0
- data/docs/resources/iis_app.md.erb +10 -0
- data/docs/resources/iis_site.md.erb +10 -0
- data/docs/resources/inetd_conf.md.erb +10 -0
- data/docs/resources/ini.md.erb +10 -0
- data/docs/resources/interface.md.erb +10 -0
- data/docs/resources/iptables.md.erb +10 -0
- data/docs/resources/json.md.erb +10 -0
- data/docs/resources/kernel_module.md.erb +10 -0
- data/docs/resources/kernel_parameter.md.erb +10 -0
- data/docs/resources/key_rsa.md.erb +10 -0
- data/docs/resources/launchd_service.md.erb +10 -0
- data/docs/resources/limits_conf.md.erb +10 -0
- data/docs/resources/login_defs.md.erb +10 -0
- data/docs/resources/mount.md.erb +10 -0
- data/docs/resources/mssql_session.md.erb +10 -0
- data/docs/resources/mysql_conf.md.erb +10 -0
- data/docs/resources/mysql_session.md.erb +10 -0
- data/docs/resources/nginx.md.erb +10 -0
- data/docs/resources/nginx_conf.md.erb +10 -0
- data/docs/resources/npm.md.erb +10 -0
- data/docs/resources/ntp_conf.md.erb +10 -0
- data/docs/resources/oneget.md.erb +10 -0
- data/docs/resources/oracledb_session.md.erb +10 -0
- data/docs/resources/os.md.erb +10 -0
- data/docs/resources/os_env.md.erb +10 -0
- data/docs/resources/package.md.erb +10 -0
- data/docs/resources/packages.md.erb +10 -0
- data/docs/resources/parse_config.md.erb +10 -0
- data/docs/resources/parse_config_file.md.erb +10 -0
- data/docs/resources/passwd.md.erb +10 -0
- data/docs/resources/pip.md.erb +10 -0
- data/docs/resources/port.md.erb +10 -0
- data/docs/resources/postgres_conf.md.erb +10 -0
- data/docs/resources/postgres_hba_conf.md.erb +10 -0
- data/docs/resources/postgres_ident_conf.md.erb +10 -0
- data/docs/resources/postgres_session.md.erb +10 -0
- data/docs/resources/powershell.md.erb +10 -0
- data/docs/resources/processes.md.erb +10 -0
- data/docs/resources/rabbitmq_config.md.erb +10 -0
- data/docs/resources/registry_key.md.erb +38 -2
- data/docs/resources/runit_service.md.erb +10 -0
- data/docs/resources/security_policy.md.erb +10 -0
- data/docs/resources/service.md.erb +10 -0
- data/docs/resources/shadow.md.erb +10 -0
- data/docs/resources/ssh_config.md.erb +10 -0
- data/docs/resources/sshd_config.md.erb +10 -0
- data/docs/resources/ssl.md.erb +10 -0
- data/docs/resources/sys_info.md.erb +10 -0
- data/docs/resources/systemd_service.md.erb +10 -0
- data/docs/resources/sysv_service.md.erb +10 -0
- data/docs/resources/upstart_service.md.erb +10 -0
- data/docs/resources/user.md.erb +10 -0
- data/docs/resources/users.md.erb +10 -0
- data/docs/resources/vbscript.md.erb +10 -0
- data/docs/resources/virtualization.md.erb +10 -0
- data/docs/resources/windows_feature.md.erb +10 -0
- data/docs/resources/windows_hotfix.md.erb +10 -0
- data/docs/resources/windows_task.md.erb +10 -0
- data/docs/resources/wmi.md.erb +10 -0
- data/docs/resources/x509_certificate.md.erb +10 -0
- data/docs/resources/xinetd_conf.md.erb +10 -0
- data/docs/resources/xml.md.erb +10 -0
- data/docs/resources/yaml.md.erb +10 -0
- data/docs/resources/yum.md.erb +10 -0
- data/docs/resources/zfs_dataset.md.erb +10 -0
- data/docs/resources/zfs_pool.md.erb +10 -0
- data/lib/inspec/base_cli.rb +2 -2
- data/lib/inspec/cli.rb +3 -2
- data/lib/inspec/resource.rb +2 -0
- data/lib/inspec/runner.rb +2 -4
- data/lib/inspec/version.rb +1 -1
- data/lib/resources/docker.rb +34 -0
- data/lib/resources/docker_plugin.rb +63 -0
- data/lib/resources/iis_app_pool.rb +116 -0
- metadata +5 -2
@@ -9,6 +9,16 @@ Use the `vbscript` InSpec audit resource to test a VBScript on the Windows platf
|
|
9
9
|
|
10
10
|
<br>
|
11
11
|
|
12
|
+
## Availability
|
13
|
+
|
14
|
+
### Installation
|
15
|
+
|
16
|
+
This resource is distributed along with InSpec itself. You can use it automatically.
|
17
|
+
|
18
|
+
### Version
|
19
|
+
|
20
|
+
This resource first became available in v1.0.0 of InSpec.
|
21
|
+
|
12
22
|
## Syntax
|
13
23
|
|
14
24
|
A `vbscript` resource block tests the output of a VBScript on the Windows platform:
|
@@ -9,6 +9,16 @@ Use the `virtualization` InSpec audit resource to test the virtualization platfo
|
|
9
9
|
|
10
10
|
<br>
|
11
11
|
|
12
|
+
## Availability
|
13
|
+
|
14
|
+
### Installation
|
15
|
+
|
16
|
+
This resource is distributed along with InSpec itself. You can use it automatically.
|
17
|
+
|
18
|
+
### Version
|
19
|
+
|
20
|
+
This resource first became available in v1.28.0 of InSpec.
|
21
|
+
|
12
22
|
## Syntax
|
13
23
|
|
14
24
|
An `virtualization` resource block declares the virtualization platform that should be tested:
|
@@ -9,6 +9,16 @@ Use the `windows_feature` InSpec audit resource to test features on Windows via
|
|
9
9
|
|
10
10
|
<br>
|
11
11
|
|
12
|
+
## Availability
|
13
|
+
|
14
|
+
### Installation
|
15
|
+
|
16
|
+
This resource is distributed along with InSpec itself. You can use it automatically.
|
17
|
+
|
18
|
+
### Version
|
19
|
+
|
20
|
+
This resource first became available in v1.0.0 of InSpec.
|
21
|
+
|
12
22
|
## Syntax
|
13
23
|
|
14
24
|
A `windows_feature` resource block declares the name of the Windows feature, tests if that feature is installed, and then returns information about that feature:
|
@@ -9,6 +9,16 @@ Use the `windows_hotfix` InSpec audit resource to test if the hotfix has been in
|
|
9
9
|
|
10
10
|
<br>
|
11
11
|
|
12
|
+
## Availability
|
13
|
+
|
14
|
+
### Installation
|
15
|
+
|
16
|
+
This resource is distributed along with InSpec itself. You can use it automatically.
|
17
|
+
|
18
|
+
### Version
|
19
|
+
|
20
|
+
This resource first became available in v1.39.1 of InSpec.
|
21
|
+
|
12
22
|
## Syntax
|
13
23
|
|
14
24
|
A `windows_hotfix` resource block declares a hotfix to validate:
|
@@ -10,6 +10,16 @@ Microsoft and application vendors use scheduled tasks to perform a variety of sy
|
|
10
10
|
|
11
11
|
<br>
|
12
12
|
|
13
|
+
## Availability
|
14
|
+
|
15
|
+
### Installation
|
16
|
+
|
17
|
+
This resource is distributed along with InSpec itself. You can use it automatically.
|
18
|
+
|
19
|
+
### Version
|
20
|
+
|
21
|
+
This resource first became available in v1.10.0 of InSpec.
|
22
|
+
|
13
23
|
## Syntax
|
14
24
|
|
15
25
|
A `windows_task` resource block declares the name of the task (as its full path) and tests its configuration:
|
data/docs/resources/wmi.md.erb
CHANGED
@@ -9,6 +9,16 @@ Use the `wmi` InSpec audit resource to test WMI settings on the Windows platform
|
|
9
9
|
|
10
10
|
<br>
|
11
11
|
|
12
|
+
## Availability
|
13
|
+
|
14
|
+
### Installation
|
15
|
+
|
16
|
+
This resource is distributed along with InSpec itself. You can use it automatically.
|
17
|
+
|
18
|
+
### Version
|
19
|
+
|
20
|
+
This resource first became available in v1.0.0 of InSpec.
|
21
|
+
|
12
22
|
## Syntax
|
13
23
|
|
14
24
|
A `wmi` resource block tests WMI settings on the Windows platform:
|
@@ -15,6 +15,16 @@ certificates.
|
|
15
15
|
|
16
16
|
<br>
|
17
17
|
|
18
|
+
## Availability
|
19
|
+
|
20
|
+
### Installation
|
21
|
+
|
22
|
+
This resource is distributed along with InSpec itself. You can use it automatically.
|
23
|
+
|
24
|
+
### Version
|
25
|
+
|
26
|
+
This resource first became available in v1.18.0 of InSpec.
|
27
|
+
|
18
28
|
## Syntax
|
19
29
|
|
20
30
|
An `x509_certificate` resource block declares a certificate `key file` to be tested.
|
@@ -9,6 +9,16 @@ Use the `xinetd_conf` InSpec audit resource to test services under `/etc/xinet.d
|
|
9
9
|
|
10
10
|
<br>
|
11
11
|
|
12
|
+
## Availability
|
13
|
+
|
14
|
+
### Installation
|
15
|
+
|
16
|
+
This resource is distributed along with InSpec itself. You can use it automatically.
|
17
|
+
|
18
|
+
### Version
|
19
|
+
|
20
|
+
This resource first became available in v1.0.0 of InSpec.
|
21
|
+
|
12
22
|
## Syntax
|
13
23
|
|
14
24
|
An `xinetd_conf` resource block declares settings found in a `xinetd.conf` file for the named service:
|
data/docs/resources/xml.md.erb
CHANGED
@@ -9,6 +9,16 @@ Use the `xml` InSpec audit resource to test data in an XML file.
|
|
9
9
|
|
10
10
|
<br>
|
11
11
|
|
12
|
+
## Availability
|
13
|
+
|
14
|
+
### Installation
|
15
|
+
|
16
|
+
This resource is distributed along with InSpec itself. You can use it automatically.
|
17
|
+
|
18
|
+
### Version
|
19
|
+
|
20
|
+
This resource first became available in v1.37.6 of InSpec.
|
21
|
+
|
12
22
|
## Syntax
|
13
23
|
|
14
24
|
An `xml` resource block declares the data to be tested. Assume the following XML file:
|
data/docs/resources/yaml.md.erb
CHANGED
@@ -9,6 +9,16 @@ Use the `yaml` InSpec audit resource to test configuration data in a Yaml file.
|
|
9
9
|
|
10
10
|
<br>
|
11
11
|
|
12
|
+
## Availability
|
13
|
+
|
14
|
+
### Installation
|
15
|
+
|
16
|
+
This resource is distributed along with InSpec itself. You can use it automatically.
|
17
|
+
|
18
|
+
### Version
|
19
|
+
|
20
|
+
This resource first became available in v1.0.0 of InSpec.
|
21
|
+
|
12
22
|
## Syntax
|
13
23
|
|
14
24
|
A `yaml` resource block declares the configuration data to be tested. Assume the following Yaml file:
|
data/docs/resources/yum.md.erb
CHANGED
@@ -9,6 +9,16 @@ Use the `yum` InSpec audit resource to test packages in the Yum repository.
|
|
9
9
|
|
10
10
|
<br>
|
11
11
|
|
12
|
+
## Availability
|
13
|
+
|
14
|
+
### Installation
|
15
|
+
|
16
|
+
This resource is distributed along with InSpec itself. You can use it automatically.
|
17
|
+
|
18
|
+
### Version
|
19
|
+
|
20
|
+
This resource first became available in v1.0.0 of InSpec.
|
21
|
+
|
12
22
|
## Syntax
|
13
23
|
|
14
24
|
A `yum` resource block declares a package repo, tests if the package repository is present, and if it that package repository is a valid package source (i.e. "is enabled"):
|
@@ -9,6 +9,16 @@ Use the `zfs_dataset` InSpec audit resource to test the ZFS datasets on FreeBSD
|
|
9
9
|
|
10
10
|
<br>
|
11
11
|
|
12
|
+
## Availability
|
13
|
+
|
14
|
+
### Installation
|
15
|
+
|
16
|
+
This resource is distributed along with InSpec itself. You can use it automatically.
|
17
|
+
|
18
|
+
### Version
|
19
|
+
|
20
|
+
This resource first became available in v1.16.0 of InSpec.
|
21
|
+
|
12
22
|
## Syntax
|
13
23
|
|
14
24
|
A `zfs_dataset` resource block declares the ZFS dataset properties that should be tested:
|
@@ -9,6 +9,16 @@ Use the `zfs_pool` InSpec audit resource to test the ZFS pools on FreeBSD system
|
|
9
9
|
|
10
10
|
<br>
|
11
11
|
|
12
|
+
## Availability
|
13
|
+
|
14
|
+
### Installation
|
15
|
+
|
16
|
+
This resource is distributed along with InSpec itself. You can use it automatically.
|
17
|
+
|
18
|
+
### Version
|
19
|
+
|
20
|
+
This resource first became available in v1.16.0 of InSpec.
|
21
|
+
|
12
22
|
## Syntax
|
13
23
|
|
14
24
|
A `zfs_pool` resource block declares the ZFS pool properties that should be tested:
|
data/lib/inspec/base_cli.rb
CHANGED
@@ -67,6 +67,8 @@ module Inspec
|
|
67
67
|
def self.profile_options
|
68
68
|
option :profiles_path, type: :string,
|
69
69
|
desc: 'Folder which contains referenced profiles.'
|
70
|
+
option :vendor_cache, type: :string,
|
71
|
+
desc: 'Use the given path for caching dependencies. (default: ~/.inspec/cache)'
|
70
72
|
end
|
71
73
|
|
72
74
|
def self.exec_options
|
@@ -83,8 +85,6 @@ module Inspec
|
|
83
85
|
desc: 'Use colors in output.'
|
84
86
|
option :attrs, type: :array,
|
85
87
|
desc: 'Load attributes file (experimental)'
|
86
|
-
option :vendor_cache, type: :string,
|
87
|
-
desc: 'Use the given path for caching dependencies. (default: ~/.inspec/cache)'
|
88
88
|
option :create_lockfile, type: :boolean,
|
89
89
|
desc: 'Write out a lockfile based on this execution (unless one already exists)'
|
90
90
|
option :backend_cache, type: :boolean,
|
data/lib/inspec/cli.rb
CHANGED
@@ -34,9 +34,9 @@ class Inspec::InspecCLI < Inspec::BaseCLI
|
|
34
34
|
def json(target)
|
35
35
|
o = opts.dup
|
36
36
|
diagnose(o)
|
37
|
-
o[:ignore_supports] = true
|
38
37
|
o[:backend] = Inspec::Backend.create(target: 'mock://')
|
39
38
|
o[:check_mode] = true
|
39
|
+
o[:vendor_cache] = Inspec::Cache.new(o[:vendor_cache])
|
40
40
|
|
41
41
|
profile = Inspec::Profile.for_target(target, o)
|
42
42
|
info = profile.info
|
@@ -67,9 +67,9 @@ class Inspec::InspecCLI < Inspec::BaseCLI
|
|
67
67
|
def check(path) # rubocop:disable Metrics/AbcSize
|
68
68
|
o = opts.dup
|
69
69
|
diagnose(o)
|
70
|
-
o[:ignore_supports] = true # we check for integrity only
|
71
70
|
o[:backend] = Inspec::Backend.create(target: 'mock://')
|
72
71
|
o[:check_mode] = true
|
72
|
+
o[:vendor_cache] = Inspec::Cache.new(o[:vendor_cache])
|
73
73
|
|
74
74
|
# run check
|
75
75
|
profile = Inspec::Profile.for_target(path, o)
|
@@ -140,6 +140,7 @@ class Inspec::InspecCLI < Inspec::BaseCLI
|
|
140
140
|
o[:logger] = Logger.new(STDOUT)
|
141
141
|
o[:logger].level = get_log_level(o.log_level)
|
142
142
|
o[:backend] = Inspec::Backend.create(target: 'mock://')
|
143
|
+
o[:vendor_cache] = Inspec::Cache.new(o[:vendor_cache])
|
143
144
|
|
144
145
|
profile = Inspec::Profile.for_target(path, o)
|
145
146
|
result = profile.check
|
data/lib/inspec/resource.rb
CHANGED
@@ -128,6 +128,7 @@ require 'resources/directory'
|
|
128
128
|
require 'resources/docker'
|
129
129
|
require 'resources/docker_container'
|
130
130
|
require 'resources/docker_image'
|
131
|
+
require 'resources/docker_plugin'
|
131
132
|
require 'resources/docker_service'
|
132
133
|
require 'resources/elasticsearch'
|
133
134
|
require 'resources/etc_fstab'
|
@@ -143,6 +144,7 @@ require 'resources/grub_conf'
|
|
143
144
|
require 'resources/host'
|
144
145
|
require 'resources/http'
|
145
146
|
require 'resources/iis_app'
|
147
|
+
require 'resources/iis_app_pool'
|
146
148
|
require 'resources/iis_site'
|
147
149
|
require 'resources/inetd_conf'
|
148
150
|
require 'resources/interface'
|
data/lib/inspec/runner.rb
CHANGED
@@ -39,7 +39,6 @@ module Inspec
|
|
39
39
|
@target_profiles = []
|
40
40
|
@controls = @conf[:controls] || []
|
41
41
|
@depends = @conf[:depends] || []
|
42
|
-
@ignore_supports = @conf[:ignore_supports]
|
43
42
|
@create_lockfile = @conf[:create_lockfile]
|
44
43
|
@cache = Inspec::Cache.new(@conf[:vendor_cache])
|
45
44
|
|
@@ -108,7 +107,8 @@ module Inspec
|
|
108
107
|
return if @conf['reporter'].nil?
|
109
108
|
|
110
109
|
@conf['reporter'].each do |reporter|
|
111
|
-
Inspec::Reporters.render(reporter, run_data)
|
110
|
+
result = Inspec::Reporters.render(reporter, run_data)
|
111
|
+
raise Inspec::ReporterError, "Error generating reporter '#{reporter[0]}'" if result == false
|
112
112
|
end
|
113
113
|
end
|
114
114
|
|
@@ -196,8 +196,6 @@ module Inspec
|
|
196
196
|
end
|
197
197
|
|
198
198
|
def supports_profile?(profile)
|
199
|
-
return true if @ignore_supports
|
200
|
-
|
201
199
|
if !profile.supports_runtime?
|
202
200
|
raise 'This profile requires InSpec version '\
|
203
201
|
"#{profile.metadata.inspec_requirement}. You are running "\
|
data/lib/inspec/version.rb
CHANGED
data/lib/resources/docker.rb
CHANGED
@@ -52,6 +52,20 @@ module Inspec::Resources
|
|
52
52
|
end
|
53
53
|
end
|
54
54
|
|
55
|
+
class DockerPluginFilter
|
56
|
+
filter = FilterTable.create
|
57
|
+
filter.add(:ids, field: 'id')
|
58
|
+
.add(:names, field: 'name')
|
59
|
+
.add(:versions, field: 'version')
|
60
|
+
.add(:enabled, field: 'enabled')
|
61
|
+
filter.connect(self, :plugins)
|
62
|
+
|
63
|
+
attr_reader :plugins
|
64
|
+
def initialize(plugins)
|
65
|
+
@plugins = plugins
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
55
69
|
class DockerServiceFilter
|
56
70
|
filter = FilterTable.create
|
57
71
|
filter.register_custom_matcher(:exists?) { |x| !x.entries.empty? }
|
@@ -89,6 +103,10 @@ module Inspec::Resources
|
|
89
103
|
its('repositories') { should_not include 'inssecure_image' }
|
90
104
|
end
|
91
105
|
|
106
|
+
describe docker.plugins.where { name == 'rexray/ebs' } do
|
107
|
+
it { should exist }
|
108
|
+
end
|
109
|
+
|
92
110
|
describe docker.services do
|
93
111
|
its('images') { should_not include 'inssecure_image' }
|
94
112
|
end
|
@@ -119,6 +137,10 @@ module Inspec::Resources
|
|
119
137
|
DockerImageFilter.new(parse_images)
|
120
138
|
end
|
121
139
|
|
140
|
+
def plugins
|
141
|
+
DockerPluginFilter.new(parse_plugins)
|
142
|
+
end
|
143
|
+
|
122
144
|
def services
|
123
145
|
DockerServiceFilter.new(parse_services)
|
124
146
|
end
|
@@ -226,5 +248,17 @@ module Inspec::Resources
|
|
226
248
|
warn 'Could not parse `docker images` output'
|
227
249
|
[]
|
228
250
|
end
|
251
|
+
|
252
|
+
def parse_plugins
|
253
|
+
plugins = inspec.command('docker plugin ls --format \'{"id": {{json .ID}}, "name": "{{ with split .Name ":"}}{{index . 0}}{{end}}", "version": "{{ with split .Name ":"}}{{index . 1}}{{end}}", "enabled": {{json .Enabled}} }\'').stdout
|
254
|
+
c_plugins = []
|
255
|
+
plugins.each_line { |entry|
|
256
|
+
c_plugins.push(JSON.parse(entry))
|
257
|
+
}
|
258
|
+
c_plugins
|
259
|
+
rescue JSON::ParserError => _e
|
260
|
+
warn 'Could not parse `docker plugin ls` output'
|
261
|
+
[]
|
262
|
+
end
|
229
263
|
end
|
230
264
|
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module Inspec::Resources
|
4
|
+
class DockerPlugin < Inspec.resource(1)
|
5
|
+
name 'docker_plugin'
|
6
|
+
supports platform: 'unix'
|
7
|
+
desc 'Retrieves info about docker plugins'
|
8
|
+
example "
|
9
|
+
describe docker_plugin('rexray/ebs') do
|
10
|
+
it { should exist }
|
11
|
+
its('id') { should_not eq '0ac30b93ad40' }
|
12
|
+
its('version') { should eq '0.11.1' }
|
13
|
+
it { should be_enabled }
|
14
|
+
end
|
15
|
+
|
16
|
+
describe docker_plugin('alpine:latest') do
|
17
|
+
it { should exist }
|
18
|
+
end
|
19
|
+
|
20
|
+
describe docker_plugin(id: '4a415e366388') do
|
21
|
+
it { should exist }
|
22
|
+
end
|
23
|
+
"
|
24
|
+
|
25
|
+
def initialize(opts = {})
|
26
|
+
# do sanitizion of input values
|
27
|
+
o = opts.dup
|
28
|
+
o = { name: opts } if opts.is_a?(String)
|
29
|
+
@opts = o
|
30
|
+
end
|
31
|
+
|
32
|
+
def exist?
|
33
|
+
object_info.entries.size == 1
|
34
|
+
end
|
35
|
+
|
36
|
+
def enabled?
|
37
|
+
object_info.enabled[0]
|
38
|
+
end
|
39
|
+
|
40
|
+
def id
|
41
|
+
object_info.ids[0] if object_info.entries.size == 1
|
42
|
+
end
|
43
|
+
|
44
|
+
def version
|
45
|
+
object_info.versions[0] if object_info.entries.size == 1
|
46
|
+
end
|
47
|
+
|
48
|
+
def to_s
|
49
|
+
plugin = @opts[:name] || @opts[:id]
|
50
|
+
"Docker plugin #{plugin}"
|
51
|
+
end
|
52
|
+
|
53
|
+
private
|
54
|
+
|
55
|
+
def object_info
|
56
|
+
return @info if defined?(@info)
|
57
|
+
opts = @opts
|
58
|
+
@info = inspec.docker.plugins.where {
|
59
|
+
(name == opts[:name]) || (!id.nil? && !opts[:id].nil? && (id == opts[:id]))
|
60
|
+
}
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|