inspec-core 4.37.8 → 4.37.17

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d915bf11e35804382285502f46a3a37b35017a10ab34c4e2f78d7420b0e3f589
4
- data.tar.gz: b85a4f9cda0e1da7461b6d23248e935ceb6fbb2d9028f5bd9eec0683426c1ec3
3
+ metadata.gz: 72cf7b34a66e5b4d2e79329b3530d14e16f5d6eaf75b76322d8e926655573ed4
4
+ data.tar.gz: dd99f49c67c10ca4d97f464331aab65cf286f5ffa355526b8dc39c62ef0620f6
5
5
  SHA512:
6
- metadata.gz: e1925d3c20bcd18a711dfa9d2df7ff98bd522b4afd3fbc8f4c5bc16648e60101fd6984a5a3d4bebf568b2993ec29ecae1ca58380e8d1a5bb55498f335dd144ff
7
- data.tar.gz: da6f422af63ddfa51d96b945cc8d34d0bc67d26557114367406108ff43bada35a2c9dd83e4c0c29081cb3a29fe6c545fcd7cf1e8a8d8a4618da1058b6e562883
6
+ metadata.gz: 2dc77b50b2fa6bc122ac9458030c6a905e56dfbee365dfe21118ec5d26eb87fc0019b035a0e5860c4863289a50a82a8528745db9c1318567d39971cfe90100be
7
+ data.tar.gz: a53f07e9e2b52be166ca2c33afa68db9c424efb6f47e3fd4b741f913e6d667a6f57a5f59ec835ec7ed23caf88c9c60ee10a23f1f000e2c931b5535777934eeb3
@@ -136,10 +136,10 @@ module Inspec::Resources
136
136
  alias sticky? sticky
137
137
 
138
138
  def more_permissive_than?(max_mode = nil)
139
- raise Inspec::Exceptions::ResourceFailed, "The file" + file.path + "doesn't seem to exist" unless exist?
140
- raise ArgumentError, "You must proivde a value for the `maximum allowable permission` for the file." if max_mode.nil?
141
- raise ArgumentError, "You must proivde the `maximum permission target` as a `String`, you provided: " + max_mode.class.to_s unless max_mode.is_a?(String)
142
- raise ArgumentError, "The value of the `maximum permission target` should be a valid file mode in 4-ditgit octal format: for example, `0644` or `0777`" unless /(0)?([0-7])([0-7])([0-7])/.match?(max_mode)
139
+ return nil unless exist?
140
+ raise ArgumentError, "You must provide a value for the `maximum allowable permission` for the file." if max_mode.nil?
141
+ raise ArgumentError, "You must provide the `maximum permission target` as a `String`, you provided: " + max_mode.class.to_s unless max_mode.is_a?(String)
142
+ raise ArgumentError, "The value of the `maximum permission target` should be a valid file mode in 4-digit octal format: for example, `0644` or `0777`" unless /(0)?([0-7])([0-7])([0-7])/.match?(max_mode)
143
143
 
144
144
  # Using the files mode and a few bit-wise calculations we can ensure a
145
145
  # file is no more permisive than desired.
@@ -160,7 +160,6 @@ module Inspec::Resources
160
160
 
161
161
  max_mode = max_mode.to_i(8)
162
162
  inv_mode = 0777 ^ max_mode
163
-
164
163
  inv_mode & file.mode != 0
165
164
  end
166
165
 
@@ -54,7 +54,7 @@ module Inspec::Resources
54
54
  def port_manager_for_os
55
55
  os = inspec.os
56
56
  if os.linux?
57
- LinuxPorts.new(inspec)
57
+ LinuxPorts.new(inspec, @port)
58
58
  elsif os.aix?
59
59
  # AIX: see http://www.ibm.com/developerworks/aix/library/au-lsof.html#resources
60
60
  # and https://www-01.ibm.com/marketing/iwm/iwm/web/reg/pick.do?source=aixbp
@@ -102,8 +102,9 @@ module Inspec::Resources
102
102
  # }]
103
103
  class PortsInfo
104
104
  attr_reader :inspec
105
- def initialize(inspec)
105
+ def initialize(inspec, port = nil)
106
106
  @inspec = inspec
107
+ @port = port
107
108
  end
108
109
  end
109
110
 
@@ -394,7 +395,12 @@ module Inspec::Resources
394
395
  def ports_via_ss
395
396
  return nil unless inspec.command("ss").exist?
396
397
 
397
- cmd = inspec.command("ss -tulpen")
398
+ if @port.nil?
399
+ cmd = inspec.command("ss -tulpen")
400
+ else
401
+ cmd = inspec.command("ss -tulpen '( dport = #{@port} or sport = #{@port} )'")
402
+ end
403
+
398
404
  return nil unless cmd.exit_status.to_i == 0
399
405
 
400
406
  ports = []
@@ -83,7 +83,7 @@ module Inspec::Resources
83
83
  feature_info = {
84
84
  name: result.match(feature_name_regex).captures[0].chomp,
85
85
  description: result.match(description_regex).captures[0].chomp,
86
- installed: result.match(state_regex).captures[0].chomp == 'Enabled',
86
+ installed: result.match(state_regex).captures[0].chomp == "Enabled",
87
87
  }
88
88
  end
89
89
 
@@ -16,16 +16,20 @@ module Inspec::Resources
16
16
  EXAMPLE
17
17
 
18
18
  def initialize(zfs_dataset)
19
- return skip_resource "The `zfs_dataset` resource is not supported on your OS yet." unless inspec.os.bsd?
19
+ return skip_resource "The `zfs_dataset` resource is not supported on your OS yet." unless inspec.os.bsd? || inspec.os.linux?
20
20
 
21
21
  @zfs_dataset = zfs_dataset
22
+ find_zfs = inspec.command("which zfs")
23
+ @zfs_cmd = find_zfs.stdout.strip
24
+
25
+ return skip_resource "zfs is not installed" if find_zfs.exit_status != 0
22
26
 
23
27
  @params = gather
24
28
  end
25
29
 
26
30
  # method called by 'it { should exist }'
27
31
  def exists?
28
- inspec.command("/sbin/zfs get -Hp all #{@zfs_dataset}").exit_status == 0
32
+ inspec.command("#{@zfs_cmd} get -Hp all #{@zfs_dataset}").exit_status == 0
29
33
  end
30
34
 
31
35
  def mounted?
@@ -39,7 +43,7 @@ module Inspec::Resources
39
43
  end
40
44
 
41
45
  def gather
42
- cmd = inspec.command("/sbin/zfs get -Hp all #{@zfs_dataset}")
46
+ cmd = inspec.command("#{@zfs_cmd} get -Hp all #{@zfs_dataset}")
43
47
  return nil if cmd.exit_status.to_i != 0
44
48
 
45
49
  # parse data
@@ -15,16 +15,20 @@ module Inspec::Resources
15
15
  EXAMPLE
16
16
 
17
17
  def initialize(zfs_pool)
18
- return skip_resource "The `zfs_pool` resource is not supported on your OS yet." unless inspec.os.bsd?
18
+ return skip_resource "The `zfs_pool` resource is not supported on your OS yet." unless inspec.os.bsd? || inspec.os.linux?
19
19
 
20
20
  @zfs_pool = zfs_pool
21
+ find_zpool = inspec.command("which zpool")
22
+ @zpool_cmd = find_zpool.stdout.strip
23
+
24
+ return skip_resource "zfs is not installed" if find_zpool.exit_status != 0
21
25
 
22
26
  @params = gather
23
27
  end
24
28
 
25
29
  # method called by 'it { should exist }'
26
30
  def exists?
27
- inspec.command("/sbin/zpool get -Hp all #{@zfs_pool}").exit_status == 0
31
+ inspec.command("#{@zpool_cmd} get -Hp all #{@zfs_pool}").exit_status == 0
28
32
  end
29
33
 
30
34
  def to_s
@@ -32,7 +36,7 @@ module Inspec::Resources
32
36
  end
33
37
 
34
38
  def gather
35
- cmd = inspec.command("/sbin/zpool get -Hp all #{@zfs_pool}")
39
+ cmd = inspec.command("#{@zpool_cmd} get -Hp all #{@zfs_pool}")
36
40
  return nil if cmd.exit_status.to_i != 0
37
41
 
38
42
  # parse data
@@ -1,3 +1,3 @@
1
1
  module Inspec
2
- VERSION = "4.37.8".freeze
2
+ VERSION = "4.37.17".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: inspec-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.37.8
4
+ version: 4.37.17
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chef InSpec Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-05-10 00:00:00.000000000 Z
11
+ date: 2021-05-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: chef-telemetry