inspec 0.19.3 → 0.20.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. checksums.yaml +5 -13
  2. data/.rubocop.yml +1 -1
  3. data/CHANGELOG.md +30 -2
  4. data/inspec.gemspec +1 -1
  5. data/lib/bundles/inspec-compliance.rb +1 -0
  6. data/lib/bundles/inspec-compliance/.kitchen.yml +21 -0
  7. data/lib/bundles/inspec-compliance/README.md +24 -0
  8. data/lib/bundles/inspec-compliance/bootstrap.sh +37 -0
  9. data/lib/bundles/inspec-compliance/cli.rb +2 -2
  10. data/lib/bundles/inspec-compliance/support.rb +36 -0
  11. data/lib/bundles/inspec-compliance/target.rb +3 -5
  12. data/lib/bundles/inspec-compliance/test/integration/default/cli.rb +56 -0
  13. data/lib/fetchers/url.rb +7 -2
  14. data/lib/inspec/backend.rb +1 -1
  15. data/lib/inspec/cli.rb +13 -13
  16. data/lib/inspec/plugins/fetcher.rb +1 -0
  17. data/lib/inspec/version.rb +1 -1
  18. data/lib/resources/file.rb +11 -23
  19. data/lib/resources/os.rb +10 -1
  20. data/lib/resources/package.rb +16 -0
  21. data/lib/resources/user.rb +14 -0
  22. data/lib/resources/xinetd.rb +39 -94
  23. data/lib/utils/filter.rb +184 -0
  24. data/lib/utils/hash_map.rb +37 -0
  25. data/test/functional/inspec_test.rb +23 -0
  26. data/test/helper.rb +5 -0
  27. data/test/resource/file_test.rb +3 -1
  28. data/test/unit/{fetchers.rb → fetchers_test.rb} +1 -0
  29. data/test/unit/mock/cmd/logins-x +4 -0
  30. data/test/unit/mock/cmd/swlist-l-product +1 -0
  31. data/test/unit/mock/profiles/resource-tiny/inspec.yml +10 -0
  32. data/test/unit/mock/profiles/resource-tiny/libraries/resource.rb +3 -0
  33. data/test/unit/resources/file_test.rb +21 -0
  34. data/test/unit/resources/package_test.rb +9 -0
  35. data/test/unit/resources/user_test.rb +6 -0
  36. data/test/unit/resources/xinetd_test.rb +3 -3
  37. data/test/unit/utils/filter_table_test.rb +125 -0
  38. metadata +46 -31
  39. data/lib/utils/detect.rb +0 -15
checksums.yaml CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- Y2RmMzdlYzM1NmRkODlmNDNiZDRjMTg4MTkxZDczOGM4ZWEyMjdmNw==
5
- data.tar.gz: !binary |-
6
- NjFmODBkODVkMTI5MzljNjk1NzI4MGNjNDZkMzc0YTczODExYjYwMA==
2
+ SHA1:
3
+ metadata.gz: ffbce1bccc070d857ed236bce62eedcb3bb42a4c
4
+ data.tar.gz: 14004e3dc76705d06589615590dd8bc5f2d4fd12
7
5
  SHA512:
8
- metadata.gz: !binary |-
9
- YzM5Njc4YTc2NTZjNTk0ZTNlYWVlYWU0ZTU3ZGVlNDU2OTA2NWIxZjA5ZDRi
10
- MjVlYWZhNDViZjU4NmIzNDZkNjcwOThkMWZkZGY2NjU4YjI4MzFlMWU1ZjE0
11
- MDY0NDZhOGRiODU4YTFmNWExMGYwYzYwZGYxMTI2Nzg0N2U3Y2M=
12
- data.tar.gz: !binary |-
13
- NGUwMDk1YWFiMmM3ZTNjOGMxY2ZmMjBmYzFmNGIyZWMwYmM4MDNiZWZkYjRm
14
- YTIzMDkyNjg0ODk1YzllNjJmNDMxMzdhMTUyZmQxZTYwMWIwNDVlYTJmNTQ0
15
- ZWUyNzljYjM1NzMzOWFlOWVmOTU4NWE0N2ZhN2FhNTlkODU0N2E=
6
+ metadata.gz: fcd0f4c1ec713bda329e8a2cbfeb9d6897fe511c2f6cfaa9bd6bfb222c68d0a1eefdcf1997bafbce0462172dc7b0153337c58b9c42af0aa6ccaf8c1c16c76495
7
+ data.tar.gz: 4a15062bb74303d4845ff8b0d7128909c3b3bb45aeeae1dd18d5a23fae9fd7841c392adbf757f6a1d3825cfc86a960b3042df8e00505d314f74dde136a7c06cd
data/.rubocop.yml CHANGED
@@ -26,7 +26,7 @@ NumericLiterals:
26
26
  Metrics/CyclomaticComplexity:
27
27
  Max: 10
28
28
  Metrics/PerceivedComplexity:
29
- Max: 10
29
+ Max: 11
30
30
  Metrics/AbcSize:
31
31
  Max: 33
32
32
  Style/PercentLiteralDelimiters:
data/CHANGELOG.md CHANGED
@@ -1,7 +1,34 @@
1
1
  # Change Log
2
2
 
3
- ## [0.19.3](https://github.com/chef/inspec/tree/0.19.3) (2016-04-22)
4
- [Full Changelog](https://github.com/chef/inspec/compare/v0.19.2...0.19.3)
3
+ ## [0.20.0](https://github.com/chef/inspec/tree/0.20.0) (2016-04-29)
4
+ [Full Changelog](https://github.com/chef/inspec/compare/v0.19.3...0.20.0)
5
+
6
+ **Implemented enhancements:**
7
+
8
+ - `where { field op value }` for filter table [\#684](https://github.com/chef/inspec/pull/684) ([arlimus](https://github.com/arlimus))
9
+ - add `shell -c` for executing calls against the inspec api [\#683](https://github.com/chef/inspec/pull/683) ([arlimus](https://github.com/arlimus))
10
+ - Add table-style filter utility [\#681](https://github.com/chef/inspec/pull/681) ([arlimus](https://github.com/arlimus))
11
+ - added hpux user and package resource support [\#678](https://github.com/chef/inspec/pull/678) ([Anirudh-Gupta](https://github.com/Anirudh-Gupta))
12
+
13
+ **Fixed bugs:**
14
+
15
+ - Specifying an invalid target protocol should give a failure message [\#686](https://github.com/chef/inspec/issues/686)
16
+ - update compliance plugin [\#695](https://github.com/chef/inspec/pull/695) ([chris-rock](https://github.com/chris-rock))
17
+ - bugfix: restore pax\_global\_header fetcher filter [\#669](https://github.com/chef/inspec/pull/669) ([arlimus](https://github.com/arlimus))
18
+
19
+ **Closed issues:**
20
+
21
+ - How do I run an inspec profile in chef audit mode? [\#692](https://github.com/chef/inspec/issues/692)
22
+
23
+ **Merged pull requests:**
24
+
25
+ - update appveyor ruby to 2.2 + fix caching [\#697](https://github.com/chef/inspec/pull/697) ([arlimus](https://github.com/arlimus))
26
+ - update to train's new file interface: symlink + uid + gid [\#694](https://github.com/chef/inspec/pull/694) ([arlimus](https://github.com/arlimus))
27
+ - validate target backend [\#688](https://github.com/chef/inspec/pull/688) ([arlimus](https://github.com/arlimus))
28
+ - Hpux [\#682](https://github.com/chef/inspec/pull/682) ([Anirudh-Gupta](https://github.com/Anirudh-Gupta))
29
+
30
+ ## [v0.19.3](https://github.com/chef/inspec/tree/v0.19.3) (2016-04-22)
31
+ [Full Changelog](https://github.com/chef/inspec/compare/v0.19.2...v0.19.3)
5
32
 
6
33
  **Fixed bugs:**
7
34
 
@@ -9,6 +36,7 @@
9
36
 
10
37
  **Merged pull requests:**
11
38
 
39
+ - Releasing inspec 0.19.3 [\#680](https://github.com/chef/inspec/pull/680) ([alexpop](https://github.com/alexpop))
12
40
  - v0.19.2 [\#675](https://github.com/chef/inspec/pull/675) ([arlimus](https://github.com/arlimus))
13
41
 
14
42
  ## [v0.19.2](https://github.com/chef/inspec/tree/v0.19.2) (2016-04-21)
data/inspec.gemspec CHANGED
@@ -24,7 +24,7 @@ Gem::Specification.new do |spec|
24
24
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
25
25
  spec.require_paths = ['lib']
26
26
 
27
- spec.add_dependency 'r-train', '~> 0.10.5'
27
+ spec.add_dependency 'r-train', '~> 0.11'
28
28
  spec.add_dependency 'thor', '~> 0.19'
29
29
  spec.add_dependency 'json', '~> 1.8'
30
30
  spec.add_dependency 'rainbow', '~> 2'
@@ -8,6 +8,7 @@ $LOAD_PATH.unshift(libdir) unless $LOAD_PATH.include?(libdir)
8
8
  module Compliance
9
9
  autoload :Configuration, 'inspec-compliance/configuration'
10
10
  autoload :HTTP, 'inspec-compliance/http'
11
+ autoload :Support, 'inspec-compliance/support'
11
12
  autoload :API, 'inspec-compliance/api'
12
13
  end
13
14
 
@@ -0,0 +1,21 @@
1
+ ---
2
+ driver:
3
+ name: vagrant
4
+ synced_folders:
5
+ - ['../../../', '/inspec']
6
+ network:
7
+ - ['private_network', {ip: '192.168.251.2'}]
8
+
9
+ provisioner:
10
+ name: shell
11
+
12
+ verifier:
13
+ name: inspec
14
+ sudo: true
15
+
16
+ platforms:
17
+ - name: ubuntu-14.04
18
+ suites:
19
+ - name: default
20
+ run_list:
21
+ attributes:
@@ -19,3 +19,27 @@ Compliance profiles can be executed in two mays:
19
19
 
20
20
  - via compliance exec: `inspec compliance exec profile`
21
21
  - via compliance scheme: `inspec exec compliance://profile`
22
+
23
+ ## Integration Tests
24
+
25
+ At this point of time, InSpec is not able to pick up the token directly, therefore the integration test is semi-automatic at this point of time:
26
+
27
+ * run `kitchen converge`
28
+ * open https://192.168.251.2 and log in with user `admin` and password `admin`
29
+ * click on user->about and obtain the refresh token
30
+ * run `kitchen verify` with the required env variables:
31
+
32
+ ```
33
+ COMPLIANCE_REFRESH_TOKEN=myrefreshtoken COMPLIANCE_ACCESS_TOKEN=mycompliancetoken b kitchen verify
34
+ -----> Starting Kitchen (v1.7.3)
35
+ -----> Verifying <default-ubuntu-1404>...
36
+ Search `/Users/chartmann/Development/compliance/inspec/lib/bundles/inspec-compliance/test/integration/default` for tests
37
+ ..................................
38
+
39
+ Finished in 6.35 seconds (files took 0.40949 seconds to load)
40
+ 34 examples, 0 failures
41
+
42
+ Finished verifying <default-ubuntu-1404> (0m6.62s).
43
+ -----> Kitchen is finished. (0m7.02s)
44
+ zlib(finalizer): the stream was freed prematurely.
45
+ ```
@@ -0,0 +1,37 @@
1
+ #!/bin/bash
2
+
3
+ echo "Installing Chef Compliance $deb"
4
+ # select latest package from cache directory
5
+ # deb=$(find /inspec/.cache -name '*.deb' | tail -1)
6
+ # sudo dpkg -i $deb
7
+
8
+ # use chef compliance package repository
9
+ sudo apt-get install -y apt-transport-https
10
+ sudo apt-get install wget
11
+ wget -qO - https://downloads.chef.io/packages-chef-io-public.key | sudo apt-key add -
12
+ CHANNEL=${CHANNEL:-stable}
13
+ DISTRIBUTION=$(lsb_release --codename | cut -f2)
14
+ echo "found $DISTRIBUTION"
15
+ echo "use $CHANNEL channel"
16
+ echo "deb https://packages.chef.io/$CHANNEL-apt $DISTRIBUTION main" > /etc/apt/sources.list.d/chef-$CHANNEL.list
17
+ sudo apt-get update
18
+ sudo apt-get install chef-compliance
19
+
20
+ sudo chef-compliance-ctl reconfigure --accept-license
21
+ sudo chef-compliance-ctl restart
22
+
23
+ # build master version of inspec
24
+ sudo /opt/chef-compliance/embedded/bin/gem list inspec
25
+
26
+ cd /inspec
27
+ sudo /opt/chef-compliance/embedded/bin/gem build *.gemspec
28
+ sudo /opt/chef-compliance/embedded/bin/gem install inspec*.gem
29
+ sudo /opt/chef-compliance/embedded/bin/inspec version
30
+ sudo /opt/chef-compliance/embedded/bin/gem list inspec
31
+
32
+ # finalize setup
33
+ cd /
34
+ /opt/chef-compliance/embedded/service/core/bin/core setup --endpoint "http://127.0.0.1:10500/setup" --login "admin" --password "admin" --name "John Doe" --accept-eula
35
+
36
+ # wget --no-check-certificate http://127.0.0.1/api/version
37
+ # cat version
@@ -23,9 +23,9 @@ module Compliance
23
23
  desc: 'Chef Compliance access token'
24
24
  option :refresh_token, type: :string, required: false,
25
25
  desc: 'Chef Compliance refresh token'
26
- def login(server) # rubocop:disable Metrics/CyclomaticComplexity, Metrics/AbcSize, PerceivedComplexity
26
+ def login(server) # rubocop:disable Metrics/AbcSize, PerceivedComplexity
27
27
  # show warning if the Compliance Server does not support
28
- if !Compliance::Configuration.new.supported?(:oidc) && (!options['token'].nil? || !options['refresh_token'].nil?)
28
+ if !Compliance::Configuration.new.supported?(:oidc)
29
29
  puts 'Your server supports --user and --password only'
30
30
  end
31
31
 
@@ -0,0 +1,36 @@
1
+ # encoding: utf-8
2
+ # author: Christoph Hartmann
3
+ # author: Dominik Richter
4
+
5
+ module Compliance
6
+ # is a helper that provides information which version of compliance supports
7
+ # which feature
8
+ class Support
9
+ # for a feature, returns either:
10
+ # - a version v0: v supports v0 iff v0 <= v
11
+ # - an array [v0, v1] of two versions: v supports [v0, v1] iff v0 <= v < v1
12
+ def self.version_with_support(feature)
13
+ case feature.to_sym
14
+ when :oidc # open id connect authentication
15
+ Gem::Version.new('0.16.19')
16
+ else
17
+ Gem::Version.new('0.0.0')
18
+ end
19
+ end
20
+
21
+ # determines if the given version support a certain feature
22
+ def self.supported?(feature, version)
23
+ sup = version_with_support(feature)
24
+
25
+ if sup.is_a?(Array)
26
+ Gem::Version.new(version) >= sup[0] &&
27
+ Gem::Version.new(version) < sup[1]
28
+ else
29
+ Gem::Version.new(version) >= sup
30
+ end
31
+ end
32
+
33
+ # we do not know the version, therefore we do not know if its possible to use the feature
34
+ # return if self['version'].nil? || self['version']['version'].nil?
35
+ end
36
+ end
@@ -14,7 +14,7 @@ module Compliance
14
14
  name 'compliance'
15
15
  priority 500
16
16
 
17
- def self.resolve(target, opts = {})
17
+ def self.resolve(target, _opts = {})
18
18
  # check for local scheme compliance://
19
19
  uri = URI(target)
20
20
  return nil unless URI(uri).scheme == 'compliance'
@@ -25,10 +25,8 @@ module Compliance
25
25
 
26
26
  # verifies that the target e.g base/ssh exists
27
27
  profile = uri.host + uri.path
28
- Compliance::API.exist?(profile)
29
-
30
- opts['user'] = config['token']
31
- super(target_url(config, profile), opts)
28
+ Compliance::API.exist?(config, profile)
29
+ super(target_url(config, profile), config)
32
30
  rescue URI::Error => _e
33
31
  nil
34
32
  end
@@ -0,0 +1,56 @@
1
+ # encoding: utf-8
2
+
3
+ # options
4
+ inspec_bin = '/opt/chef-compliance/embedded/bin/inspec'
5
+ api_url = 'https://0.0.0.0'
6
+ profile = '/inspec/examples/profile'
7
+
8
+ # TODO: determine tokens automatically, define in kitchen yml
9
+ access_token = ENV['COMPLIANCE_ACCESS_TOKEN']
10
+ refresh_token = ENV['COMPLIANCE_REFRESH_TOKEN']
11
+
12
+ %w{refresh_token access_token}.each do |type|
13
+ case type
14
+ when 'access_token'
15
+ token_options = "--token '#{access_token}'"
16
+ when 'refresh_token'
17
+ token_options = "--refresh_token '#{refresh_token}'"
18
+ end
19
+
20
+ # verifies that the help command works
21
+ describe command("#{inspec_bin} compliance help") do
22
+ its('stdout') { should include 'inspec compliance help [COMMAND]' }
23
+ its('stderr') { should eq '' }
24
+ its('exit_status') { should eq 0 }
25
+ end
26
+
27
+ # login via access token token
28
+ describe command("#{inspec_bin} compliance login #{api_url} --insecure --user admin #{token_options}") do
29
+ its('stdout') { should include 'Successfully authenticated' }
30
+ its('stderr') { should eq '' }
31
+ its('exit_status') { should eq 0 }
32
+ end
33
+
34
+ # see available resources
35
+ describe command("#{inspec_bin} compliance profiles") do
36
+ its('stdout') { should include 'base/ssh' }
37
+ its('stderr') { should eq '' }
38
+ its('exit_status') { should eq 0 }
39
+ end
40
+
41
+ # upload a compliance profile
42
+ describe command("#{inspec_bin} compliance upload #{profile} --overwrite") do
43
+ its('stdout') { should include 'Profile is valid' }
44
+ its('stdout') { should include 'Successfully uploaded profile' }
45
+ its('stdout') { should_not include 'error(s)' }
46
+ its('stderr') { should eq '' }
47
+ its('exit_status') { should eq 0 }
48
+ end
49
+
50
+ # logout
51
+ describe command("#{inspec_bin} compliance logout") do
52
+ its('stdout') { should include 'Successfully logged out' }
53
+ its('stderr') { should eq '' }
54
+ its('exit_status') { should eq 0 }
55
+ end
56
+ end
data/lib/fetchers/url.rb CHANGED
@@ -65,10 +65,15 @@ module Fetchers
65
65
 
66
66
  # download url into archive using opts,
67
67
  # returns File object and content-type from HTTP headers
68
- def self.download_archive(url, opts)
68
+ def self.download_archive(url, opts = {})
69
+ http_opts = {}
70
+ # http_opts['http_basic_authentication'] = [opts['user'] || '', opts['password'] || ''] if opts['user']
71
+ http_opts['ssl_verify_mode'.to_sym] = OpenSSL::SSL::VERIFY_NONE if opts['insecure']
72
+ http_opts['Authorization'] = "Bearer #{opts['token']}" if opts['token']
73
+
69
74
  remote = open(
70
75
  url,
71
- http_basic_authentication: [opts['user'] || '', opts['password'] || ''],
76
+ http_opts,
72
77
  )
73
78
 
74
79
  content_type = remote.meta['content-type']
@@ -14,7 +14,7 @@ module Inspec
14
14
  # @return [TransportBackend] enriched transport instance
15
15
  def self.create(config)
16
16
  conf = Train.target_config(config)
17
- name = conf[:backend] || :local
17
+ name = Train.validate_backend(conf)
18
18
  transport = Train.create(name, conf)
19
19
  if transport.nil?
20
20
  fail "Can't find transport backend '#{name}'."
data/lib/inspec/cli.rb CHANGED
@@ -116,21 +116,13 @@ class Inspec::InspecCLI < Inspec::BaseCLI # rubocop:disable Metrics/ClassLength
116
116
  desc 'detect', 'detect the target OS'
117
117
  target_options
118
118
  def detect
119
- diagnose
120
-
121
- rel = File.join(File.dirname(__FILE__), *%w{.. utils detect.rb})
122
- detect_util = File.expand_path(rel)
123
- # exits on execution:
124
- runner = Inspec::Runner.new(opts)
125
- profile = Inspec::Profile.for_target(detect_util, opts)
126
- runner.add_profile(profile)
127
- exit runner.run
128
- rescue RuntimeError => e
129
- puts e.message
119
+ options_json[:command] = 'os.params'
120
+ shell_func
130
121
  end
131
122
 
132
123
  desc 'shell', 'open an interactive debugging shell'
133
124
  target_options
125
+ option :command, aliases: :c
134
126
  option :format, type: :string, default: Inspec::NoSummaryFormatter, hide: true
135
127
  def shell_func
136
128
  diagnose
@@ -138,8 +130,16 @@ class Inspec::InspecCLI < Inspec::BaseCLI # rubocop:disable Metrics/ClassLength
138
130
  o[:logger] = Logger.new(STDOUT)
139
131
  o[:logger].level = get_log_level(o.log_level)
140
132
 
141
- runner = Inspec::Runner.new(o)
142
- Inspec::Shell.new(runner).start
133
+ if o[:command].nil?
134
+ runner = Inspec::Runner.new(o)
135
+ return Inspec::Shell.new(runner).start
136
+ else
137
+ opts[:test_collector] = 'mock'
138
+ runner = Inspec::Runner.new(opts)
139
+ res = runner.create_context.load(o[:command])
140
+ jres = res.respond_to?(:to_json) ? res.to_json : JSON.dump(res)
141
+ puts jres
142
+ end
143
143
  rescue RuntimeError => e
144
144
  puts e.message
145
145
  end
@@ -34,6 +34,7 @@ module Inspec
34
34
  end
35
35
 
36
36
  BLACKLIST_FILES = [
37
+ '/pax_global_header',
37
38
  'pax_global_header',
38
39
  ].freeze
39
40
 
@@ -3,5 +3,5 @@
3
3
  # author: Christoph Hartmann
4
4
 
5
5
  module Inspec
6
- VERSION = '0.19.3'.freeze
6
+ VERSION = '0.20.0'.freeze
7
7
  end
@@ -22,17 +22,17 @@ module Inspec::Resources
22
22
  "
23
23
  include MountParser
24
24
 
25
- attr_reader :file, :path, :mount_options
25
+ attr_reader :file, :mount_options
26
26
  def initialize(path)
27
- @path = path
28
- @file = inspec.backend.file(@path)
27
+ @file = inspec.backend.file(path)
29
28
  end
30
29
 
31
30
  %w{
32
31
  type exist? file? block_device? character_device? socket? directory?
33
- symlink? pipe? mode mode? owner owned_by? group grouped_into? link_target
32
+ symlink? pipe? mode mode? owner owned_by? group grouped_into?
34
33
  link_path linked_to? mtime size selinux_label immutable?
35
34
  product_version file_version version? md5sum sha256sum
35
+ path source source_path uid gid
36
36
  }.each do |m|
37
37
  define_method m.to_sym do |*args|
38
38
  file.method(m.to_sym).call(*args)
@@ -74,7 +74,7 @@ module Inspec::Resources
74
74
  return file.mounted? if expected_options.nil?
75
75
 
76
76
  # deprecation warning, this functionality will be removed in future version
77
- warn "[DEPRECATION] `be_mounted.with and be_mounted.only_with` are deprecated. Please use `mount('#{path}')` instead."
77
+ warn "[DEPRECATION] `be_mounted.with and be_mounted.only_with` are deprecated. Please use `mount('#{source_path}')` instead."
78
78
 
79
79
  # we cannot read mount data on non-Linux systems
80
80
  return nil if !inspec.os.linux?
@@ -91,22 +91,8 @@ module Inspec::Resources
91
91
  end
92
92
  end
93
93
 
94
- # TODO: This is temporary and must be moved to train
95
- def uid
96
- res = inspec.command('stat '+Shellwords.escape(@path)+' -c %u')
97
- return nil if res.exit_status != 0 || res.stdout.empty?
98
- res.stdout.to_i
99
- end
100
-
101
- # TODO: This is temporary and must be moved to train
102
- def gid
103
- res = inspec.command('stat '+Shellwords.escape(@path)+' -c %u')
104
- return nil if res.exit_status != 0 || res.stdout.empty?
105
- res.stdout.to_i
106
- end
107
-
108
94
  def to_s
109
- "File #{path}"
95
+ "File #{source_path}"
110
96
  end
111
97
 
112
98
  private
@@ -133,11 +119,13 @@ module Inspec::Resources
133
119
 
134
120
  def check_file_permission_by_user(user, flag)
135
121
  if inspec.os.linux?
136
- perm_cmd = "su -s /bin/sh -c \"test -#{flag} #{path}\" #{user}"
122
+ perm_cmd = "su -s /bin/sh -c \"test -#{flag} #{source_path}\" #{user}"
137
123
  elsif inspec.os.bsd? || inspec.os.solaris?
138
- perm_cmd = "sudo -u #{user} test -#{flag} #{path}"
124
+ perm_cmd = "sudo -u #{user} test -#{flag} #{source_path}"
139
125
  elsif inspec.os.aix?
140
- perm_cmd = "su #{user} -c test -#{flag} #{path}"
126
+ perm_cmd = "su #{user} -c test -#{flag} #{source_path}"
127
+ elsif inspec.os.hpux?
128
+ perm_cmd = "su #{user} -c \"test -#{flag} #{source_path}\""
141
129
  else
142
130
  return skip_resource 'The `file` resource does not support `by_user` on your OS.'
143
131
  end