Class: Inspec::ProfileVendor

Inherits:
Object
  • Object
show all
Defined in:
lib/inspec/profile_vendor.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ ProfileVendor

Returns a new instance of ProfileVendor.



10
11
12
# File 'lib/inspec/profile_vendor.rb', line 10

def initialize(path)
  @profile_path = Pathname.new(File.expand_path(path))
end

Instance Attribute Details

#profile_pathObject (readonly)

Returns the value of attribute profile_path.



8
9
10
# File 'lib/inspec/profile_vendor.rb', line 8

def profile_path
  @profile_path
end

Instance Method Details

#cache_pathObject



35
36
37
# File 'lib/inspec/profile_vendor.rb', line 35

def cache_path
  profile_path.join('vendor')
end

#lockfileObject



39
40
41
# File 'lib/inspec/profile_vendor.rb', line 39

def lockfile
  profile_path.join('inspec.lock')
end

#make_readableObject

The URL fetcher uses a Tempfile to retrieve the vendored profile, which creates a file that is only readable by the current user. In most circumstances, this is likely OK. However, in environments like a Habitat package, these files need to be readable by all users or the Habitat Supervisor may not be able to start InSpec correctly.

This method makes sure all vendored files are mode 644 for this use case. This method is not called by default - the caller vendoring the profile must make the decision as to whether this is necessary.



29
30
31
32
33
# File 'lib/inspec/profile_vendor.rb', line 29

def make_readable
  Dir.glob("#{cache_path}/**/*") do |e|
    FileUtils.chmod(0644, e) if File.file?(e)
  end
end

#vendor!Object



14
15
16
# File 'lib/inspec/profile_vendor.rb', line 14

def vendor!
  vendor_dependencies
end