Module: Inspec

Extended by:
InstallContextHelpers
Defined in:
lib/inspec/cli.rb,
lib/inspec/ui.rb,
lib/inspec/log.rb,
lib/inspec/dist.rb,
lib/inspec/rule.rb,
lib/inspec/input.rb,
lib/inspec/input.rb,
lib/inspec/shell.rb,
lib/inspec/config.rb,
lib/inspec/errors.rb,
lib/inspec/expect.rb,
lib/inspec/runner.rb,
lib/inspec/schema.rb,
lib/inspec/backend.rb,
lib/inspec/feature.rb,
lib/inspec/fetcher.rb,
lib/inspec/globals.rb,
lib/inspec/objects.rb,
lib/inspec/profile.rb,
lib/inspec/secrets.rb,
lib/inspec/version.rb,
lib/inspec/iaf_file.rb,
lib/inspec/metadata.rb,
lib/inspec/resource.rb,
lib/inspec/run_data.rb,
lib/inspec/plugin/v2.rb,
lib/inspec/plugin/v2.rb,
lib/inspec/dsl_shared.rb,
lib/inspec/exceptions.rb,
lib/inspec/env_printer.rb,
lib/inspec/objects/tag.rb,
lib/inspec/runner_mock.rb,
lib/inspec/objects/list.rb,
lib/inspec/objects/test.rb,
lib/inspec/runner_rspec.rb,
lib/inspec/utils/parser.rb,
lib/inspec/utils/podman.rb,
lib/inspec/describe_base.rb,
lib/inspec/file_provider.rb,
lib/inspec/method_source.rb,
lib/inspec/objects/input.rb,
lib/inspec/objects/value.rb,
lib/inspec/source_reader.rb,
lib/inspec/cached_fetcher.rb,
lib/inspec/feature/config.rb,
lib/inspec/feature/runner.rb,
lib/inspec/input_registry.rb,
lib/inspec/profile_vendor.rb,
lib/inspec/require_loader.rb,
lib/inspec/shell_detector.rb,
lib/inspec/objects/control.rb,
lib/inspec/objects/or_test.rb,
lib/inspec/profile_context.rb,
lib/inspec/run_data/result.rb,
lib/inspec/runtime_profile.rb,
lib/inspec/ui_table_helper.rb,
lib/inspec/utils/telemetry.rb,
lib/inspec/objects/describe.rb,
lib/inspec/rspec_extensions.rb,
lib/inspec/run_data/control.rb,
lib/inspec/run_data/profile.rb,
lib/inspec/schema/exec_json.rb,
lib/inspec/dependency_loader.rb,
lib/inspec/enhanced_outcomes.rb,
lib/inspec/input_dsl_helpers.rb,
lib/inspec/objects/each_loop.rb,
lib/inspec/plugin/v1/plugins.rb,
lib/inspec/schema/primitives.rb,
lib/inspec/dependencies/cache.rb,
lib/inspec/waiver_file_reader.rb,
lib/inspec/objects/ruby_helper.rb,
lib/inspec/run_data/statistics.rb,
lib/inspec/schema/profile_json.rb,
lib/inspec/control_eval_context.rb,
lib/inspec/dependency_installer.rb,
lib/inspec/library_eval_context.rb,
lib/inspec/schema/exec_json_min.rb,
lib/inspec/schema/output_schema.rb,
lib/inspec/utils/telemetry/base.rb,
lib/inspec/utils/telemetry/http.rb,
lib/inspec/utils/telemetry/null.rb,
lib/inspec/dependencies/lockfile.rb,
lib/inspec/dependencies/resolver.rb,
lib/inspec/utils/install_context.rb,
lib/inspec/utils/run_data_filters.rb,
lib/inspec/dependencies/requirement.rb,
lib/inspec/utils/deprecation/errors.rb,
lib/inspec/utils/profile_ast_helpers.rb,
lib/inspec/plugin/v1/plugin_types/cli.rb,
lib/inspec/utils/json_profile_summary.rb,
lib/inspec/utils/yaml_profile_summary.rb,
lib/inspec/dependencies/dependency_set.rb,
lib/inspec/utils/deprecation/deprecator.rb,
lib/inspec/plugin/v1/plugin_types/secret.rb,
lib/inspec/utils/deprecation/config_file.rb,
lib/inspec/plugin/v1/plugin_types/fetcher.rb,
lib/inspec/utils/deprecation/global_method.rb,
lib/inspec/utils/telemetry/run_context_probe.rb,
lib/inspec/plugin/v1/plugin_types/source_reader.rb,
lib/inspec/base_cli.rb

Overview

These type occur only when running “exec –reporter exec-jsonmin <file>”.

Defined Under Namespace

Modules: Archive, DSL, Deprecation, DescribeDslLazyLoader, Dist, EnhancedOutcomes, Exceptions, Fetcher, Formatters, HashLikeStruct, Impact, InputDslHelpers, InstallContextHelpers, MethodSource, Plugin, Plugins, Reporters, Resources, RubyHelper, Schema, TestDslLazyLoader, Utils Classes: Attribute, Backend, BaseCLI, Cache, CachedFetcher, Config, ConfigError, Control, ControlEvalContext, CyclicDependencyError, DependencyInstaller, DependencyLoader, DependencySet, Describe, DescribeBase, DirProvider, DuplicateDep, EachLoop, EnvPrinter, Error, Expect, Feature, FeatureConfigMissingError, FeatureConfigTamperedError, FetcherFailure, FetcherRegistry, FileProvider, GemDependencyInstallError, GemDependencyLoadError, IafFile, IafProvider, ImpactError, Input, InputRegistry, InspecCLI, InvalidProfileSignature, LibraryEvalContext, List, Lockfile, Log, Metadata, MockProvider, OrTest, PluginCtl, Profile, ProfileContext, ProfileNotFound, ProfileSignatureRequired, ProfileVendor, RelativeFileProvider, ReporterError, RequireLoader, Requirement, Resolver, Resource, Rule, RunData, Runner, RunnerMock, RunnerRspec, RuntimeProfile, Shell, ShellDetector, SourceReaderRegistry, Tag, TarProvider, Telemetry, Test, UI, UnsatisfiedVersionSpecification, UserInteractionRequired, Value, WaiverFileReader, ZipProvider

Constant Summary collapse

SecretsBackend =
PluginRegistry.new
VERSION =
"6.8.11".freeze
SourceReader =
SourceReaderRegistry.new

Class Method Summary collapse

Methods included from InstallContextHelpers

guess_install_context

Class Method Details

.config_dirObject



6
7
8
# File 'lib/inspec/globals.rb', line 6

def self.config_dir
  ENV["INSPEC_CONFIG_DIR"] || File.join(home_path, ".inspec")
end

.deprecate(group, msg = "", opts = {}) ⇒ Object



4
5
6
7
8
# File 'lib/inspec/utils/deprecation/global_method.rb', line 4

def self.deprecate(group, msg = "", opts = {})
  config_io = opts.delete(:config_io)
  deprecator = Inspec::Deprecation::Deprecator.new(config_io: config_io)
  deprecator.handle_deprecation(group, msg, opts)
end

.fetcher(version) ⇒ Object



33
34
35
36
37
38
39
# File 'lib/inspec/fetcher.rb', line 33

def self.fetcher(version)
  if version != 1
    raise "Only fetcher version 1 is supported!"
  end

  Inspec::Plugins::Fetcher
end

.home_pathObject



14
15
16
17
18
19
20
# File 'lib/inspec/globals.rb', line 14

def self.home_path
  Dir.home
rescue ArgumentError, NoMethodError
  # If ENV['HOME'] is not set, Dir.home will fail due to expanding the ~. Fallback to Etc.
  require "etc" unless defined?(Etc)
  Etc.getpwuid.dir
end

.locally_windows?Boolean

Returns:

  • (Boolean)


22
23
24
25
# File 'lib/inspec/globals.rb', line 22

def self.locally_windows?
  require "rbconfig" unless defined?(RbConfig)
  RbConfig::CONFIG["host_os"] =~ /mswin|mingw|cygwin/
end

.log_dirObject



27
28
29
30
31
# File 'lib/inspec/globals.rb', line 27

def self.log_dir
  log_dir_path = "#{config_dir}/logs"
  FileUtils.mkdir_p(log_dir_path) unless File.directory?(log_dir_path)
  log_dir_path
end

.plugin(version, plugin_type = nil) ⇒ Object

Provides the base class that plugin implementors should use.



42
43
44
45
46
47
48
49
50
# File 'lib/inspec/plugin/v2.rb', line 42

def self.plugin(version, plugin_type = nil)
  unless version == 2
    raise "Only plugins version 2 is supported!"
  end

  return Inspec::Plugin::V2::PluginBase if plugin_type.nil?

  Inspec::Plugin::V2::PluginBase.base_class_for_type(plugin_type)
end

.resource(version) ⇒ Resource

Retrieve the base class for creating a new resource. Create classes that inherit from this class.

Parameters:

  • version (int)

    the resource version to use

Returns:

  • (Resource)

    base class for creating a new resource



249
250
251
252
# File 'lib/inspec/resource.rb', line 249

def self.resource(version)
  validate_resource_dsl_version!(version)
  Inspec::Resource
end

.secrets(version) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/inspec/secrets.rb', line 6

def self.secrets(version)
  if version != 1
    raise "Only secrets version 1 is supported!"
  end

  Inspec::Plugins::Secret
end

.source_reader(version) ⇒ Object



16
17
18
19
20
21
22
# File 'lib/inspec/source_reader.rb', line 16

def self.source_reader(version)
  if version != 1
    raise "Only source readers version 1 is supported!"
  end

  Inspec::Plugins::SourceReader
end

.src_rootObject



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

def self.src_root
  @src_root ||= File.expand_path(File.join(__FILE__, "../../.."))
end

.validate_resource_dsl_version!(version) ⇒ Object



254
255
256
# File 'lib/inspec/resource.rb', line 254

def self.validate_resource_dsl_version!(version)
  raise "Only resource version 1 is supported!" if version != 1
end

.with_feature(feature_name, opts = {}, &feature_implementation) ⇒ Object



5
6
7
# File 'lib/inspec/feature.rb', line 5

def self.with_feature(feature_name, opts = {}, &feature_implementation)
  Inspec::Feature::Runner.with_feature(feature_name, opts, &feature_implementation)
end