Apply chefstyle -a, and manually remove duplicate requires

Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>
This commit is contained in:
Clinton Wolfe 2020-12-18 11:49:35 -05:00
parent e4c46e9dae
commit cdfb325ca3
179 changed files with 225 additions and 256 deletions

View file

@ -4,7 +4,7 @@
# It is traditional in a gemspec to dynamically load the current version # It is traditional in a gemspec to dynamically load the current version
# from a file in the source tree. The next three lines make that happen. # from a file in the source tree. The next three lines make that happen.
lib = File.expand_path("../lib", __FILE__) lib = File.expand_path("lib", __dir__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require "inspec-resource-lister/version" require "inspec-resource-lister/version"

View file

@ -1,5 +1,5 @@
source "https://rubygems.org" source "https://rubygems.org"
main_gemspec = File.expand_path("../inspec-bin.gemspec", __FILE__) main_gemspec = File.expand_path("inspec-bin.gemspec", __dir__)
if File.exist?(main_gemspec) if File.exist?(main_gemspec)
gemspec name: "inspec-bin" gemspec name: "inspec-bin"
else else

View file

@ -3,7 +3,7 @@ Bundler::GemHelper.install_tasks name: "inspec-bin"
desc "force install the inspec-bin gem" desc "force install the inspec-bin gem"
task "install:force" do task "install:force" do
sh "gem build -V inspec-bin.gemspec" sh "gem build -V inspec-bin.gemspec"
built_gem_path = Dir["inspec-bin-*.gem"].sort_by { |f| File.mtime(f) }.last built_gem_path = Dir["inspec-bin-*.gem"].max_by { |f| File.mtime(f) }
FileUtils.mkdir_p("pkg") unless Dir.exist?("pkg") FileUtils.mkdir_p("pkg") unless Dir.exist?("pkg")
FileUtils.mv(built_gem_path, "pkg") FileUtils.mv(built_gem_path, "pkg")
sh "gem install -f pkg/#{built_gem_path}" sh "gem install -f pkg/#{built_gem_path}"

View file

@ -4,7 +4,7 @@
Encoding.default_external = Encoding::UTF_8 Encoding.default_external = Encoding::UTF_8
Encoding.default_internal = Encoding::UTF_8 Encoding.default_internal = Encoding::UTF_8
lib = File.expand_path("../lib", __FILE__) lib = File.expand_path("lib", __dir__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require "inspec/cli" require "inspec/cli"

View file

@ -1,4 +1,4 @@
lib = File.expand_path("../lib", __FILE__) lib = File.expand_path("lib", __dir__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require "inspec-bin/version" require "inspec-bin/version"

View file

@ -1,4 +1,4 @@
lib = File.expand_path("../lib", __FILE__) lib = File.expand_path("lib", __dir__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require "inspec-bin/version" require "inspec-bin/version"

View file

@ -1,5 +1,5 @@
# This file managed by automation - do not edit manually # This file managed by automation - do not edit manually
module InspecBin module InspecBin
INSPECBIN_ROOT = File.expand_path("../..", __FILE__) INSPECBIN_ROOT = File.expand_path("..", __dir__)
VERSION = "4.24.22".freeze VERSION = "4.24.22".freeze
end end

View file

@ -1,4 +1,4 @@
lib = File.expand_path("../lib", __FILE__) lib = File.expand_path("lib", __dir__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require "inspec/version" require "inspec/version"

View file

@ -1,4 +1,4 @@
lib = File.expand_path("../lib", __FILE__) lib = File.expand_path("lib", __dir__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require "inspec/version" require "inspec/version"

View file

@ -1,7 +1,7 @@
# frozen_string_literal: true # frozen_string_literal: true
require "net/http" require "net/http" unless defined?(Net::HTTP)
require "addressable/uri" require "addressable/uri" unless defined?(Addressable::URI)
module Supermarket module Supermarket
class API class API

View file

@ -1,4 +1,4 @@
require "uri" require "uri" unless defined?(URI)
require "inspec/fetcher" require "inspec/fetcher"
require "inspec/fetcher/url" require "inspec/fetcher/url"

View file

@ -1,4 +1,4 @@
require "rubygems/package" require "rubygems/package" unless defined?(Gem::Package)
module Inspec::Archive module Inspec::Archive
class TarArchiveGenerator class TarArchiveGenerator

View file

@ -1,6 +1,6 @@
require "rubygems" require "rubygems" unless defined?(Gem)
require "zip" require "zip" unless defined?(Zip)
require "pathname" require "pathname" unless defined?(Pathname)
module Inspec::Archive module Inspec::Archive
class ZipArchiveGenerator class ZipArchiveGenerator

View file

@ -1,4 +1,4 @@
require "thor" require "thor" unless defined?(Thor)
require "inspec/log" require "inspec/log"
require "inspec/ui" require "inspec/ui"
require "inspec/config" require "inspec/config"

View file

@ -1,5 +1,5 @@
require "inspec/fetcher" require "inspec/fetcher"
require "forwardable" require "forwardable" unless defined?(Forwardable)
module Inspec module Inspec
class CachedFetcher class CachedFetcher

View file

@ -67,7 +67,7 @@ class Inspec::InspecCLI < Inspec::BaseCLI
desc: "A list of controls to include. Ignore all other tests." desc: "A list of controls to include. Ignore all other tests."
profile_options profile_options
def json(target) def json(target)
require "json" require "json" unless defined?(JSON)
o = config o = config
diagnose(o) diagnose(o)

View file

@ -1,11 +1,11 @@
# Represents InSpec configuration. Merges defaults, config file options, # Represents InSpec configuration. Merges defaults, config file options,
# and CLI arguments. # and CLI arguments.
require "pp" require "pp" unless defined?(PP)
require "stringio" require "stringio" unless defined?(StringIO)
require "forwardable" require "forwardable" unless defined?(Forwardable)
require "thor" require "thor" unless defined?(Thor)
require "base64" require "base64" unless defined?(Base64)
require "inspec/plugin/v2/filter" require "inspec/plugin/v2/filter"
module Inspec module Inspec

View file

@ -1,4 +1,4 @@
require "fileutils" require "fileutils" unless defined?(FileUtils)
module Inspec module Inspec
# #

View file

@ -1,6 +1,6 @@
require "inspec/shell_detector" require "inspec/shell_detector"
require "erb" require "erb" unless defined?(Erb)
require "shellwords" require "shellwords" unless defined?(Shellwords)
module Inspec module Inspec
class EnvPrinter class EnvPrinter

View file

@ -1,6 +1,6 @@
require "tmpdir" require "tmpdir" unless defined?(Dir.mktmpdir)
require "fileutils" require "fileutils" unless defined?(FileUtils)
require "mixlib/shellout" require "mixlib/shellout" unless defined?(Mixlib::ShellOut)
require "inspec/log" require "inspec/log"
module Inspec::Fetcher module Inspec::Fetcher

View file

@ -1,4 +1,4 @@
require "openssl" require "openssl" unless defined?(OpenSSL)
module Inspec::Fetcher module Inspec::Fetcher
class Local < Inspec.fetcher(1) class Local < Inspec.fetcher(1)

View file

@ -1,7 +1,7 @@
require "uri" require "uri" unless defined?(URI)
require "openssl" require "openssl" unless defined?(OpenSSL)
require "tempfile" require "tempfile" unless defined?(Tempfile)
require "open-uri" require "open-uri" unless defined?(OpenURI)
module Inspec::Fetcher module Inspec::Fetcher
class Url < Inspec.fetcher(1) class Url < Inspec.fetcher(1)

View file

@ -1,7 +1,7 @@
require "rubygems/package" require "rubygems/package" unless defined?(Gem::Package)
require "pathname" require "pathname" unless defined?(Pathname)
require "zlib" require "zlib" unless defined?(Zlib)
require "zip" require "zip" unless defined?(Zip)
module Inspec module Inspec
class FileProvider class FileProvider

View file

@ -14,14 +14,17 @@ module Inspec
class Input class Input
class Error < Inspec::Error; end class Error < Inspec::Error; end
class ValidationError < Error class ValidationError < Error
attr_accessor :input_name attr_accessor :input_name
attr_accessor :input_value attr_accessor :input_value
attr_accessor :input_type attr_accessor :input_type
end end
class TypeError < Error class TypeError < Error
attr_accessor :input_type attr_accessor :input_type
end end
class RequiredError < Error class RequiredError < Error
attr_accessor :input_name attr_accessor :input_name
end end

View file

@ -1,5 +1,5 @@
require "forwardable" require "forwardable" unless defined?(Forwardable)
require "singleton" require "singleton" unless defined?(Singleton)
require "inspec/input" require "inspec/input"
require "inspec/secrets" require "inspec/secrets"
require "inspec/exceptions" require "inspec/exceptions"
@ -14,9 +14,11 @@ module Inspec
extend Forwardable extend Forwardable
class Error < Inspec::Error; end class Error < Inspec::Error; end
class ProfileLookupError < Error class ProfileLookupError < Error
attr_accessor :profile_name attr_accessor :profile_name
end end
class InputLookupError < Error class InputLookupError < Error
attr_accessor :profile_name attr_accessor :profile_name
attr_accessor :input_name attr_accessor :input_name
@ -199,7 +201,7 @@ module Inspec
value = YAML.load(value) value = YAML.load(value)
rescue Psych::SyntaxError => yaml_error rescue Psych::SyntaxError => yaml_error
# It could be that we just tried to run JSON through the YAML parser. # It could be that we just tried to run JSON through the YAML parser.
require "json" require "json" unless defined?(JSON)
begin begin
value = JSON.parse(value) value = JSON.parse(value)
rescue JSON::ParserError => json_error rescue JSON::ParserError => json_error

View file

@ -216,7 +216,7 @@ module Inspec
end end
def self.from_yaml(ref, content, profile_id, logger = nil) def self.from_yaml(ref, content, profile_id, logger = nil)
require "erb" require "erb" unless defined?(Erb)
res = Metadata.new(ref, logger) res = Metadata.new(ref, logger)
res.params = YAML.load(ERB.new(content).result) res.params = YAML.load(ERB.new(content).result)
res.content = content res.content = content

View file

@ -1,4 +1,4 @@
require "forwardable" require "forwardable" unless defined?(Forwardable)
module Inspec module Inspec
# Resource Plugins # Resource Plugins
@ -36,7 +36,7 @@ module Inspec
.flatten .flatten
# load bundled plugins # load bundled plugins
bundled_dir = File.expand_path(File.dirname(__FILE__)) bundled_dir = __dir__
@paths += Dir[File.join(bundled_dir, "..", "bundles", "inspec-*.rb")].flatten @paths += Dir[File.join(bundled_dir, "..", "bundles", "inspec-*.rb")].flatten
# map paths to names # map paths to names

View file

@ -6,17 +6,22 @@ module Inspec
class Exception < Inspec::Error; end class Exception < Inspec::Error; end
class ConfigError < Inspec::Plugin::V2::Exception; end class ConfigError < Inspec::Plugin::V2::Exception; end
class LoadError < Inspec::Plugin::V2::Exception; end class LoadError < Inspec::Plugin::V2::Exception; end
class GemActionError < Inspec::Plugin::V2::Exception class GemActionError < Inspec::Plugin::V2::Exception
attr_accessor :plugin_name attr_accessor :plugin_name
attr_accessor :version attr_accessor :version
end end
class InstallError < Inspec::Plugin::V2::GemActionError; end class InstallError < Inspec::Plugin::V2::GemActionError; end
class PluginExcludedError < Inspec::Plugin::V2::InstallError class PluginExcludedError < Inspec::Plugin::V2::InstallError
attr_accessor :details attr_accessor :details
end end
class UpdateError < Inspec::Plugin::V2::GemActionError class UpdateError < Inspec::Plugin::V2::GemActionError
attr_accessor :from_version, :to_version attr_accessor :from_version, :to_version
end end
class UnInstallError < Inspec::Plugin::V2::GemActionError; end class UnInstallError < Inspec::Plugin::V2::GemActionError; end
class SearchError < Inspec::Plugin::V2::GemActionError; end class SearchError < Inspec::Plugin::V2::GemActionError; end
end end

View file

@ -1,4 +1,4 @@
require "json" require "json" unless defined?(JSON)
module Inspec::Plugin::V2 module Inspec::Plugin::V2
# Represents the plugin config file on disk. # Represents the plugin config file on disk.

View file

@ -1,5 +1,5 @@
require "singleton" require "singleton" unless defined?(Singleton)
require "json" require "json" unless defined?(JSON)
require "inspec/globals" require "inspec/globals"
module Inspec::Plugin; end module Inspec::Plugin; end

View file

@ -1,12 +1,12 @@
# This file is not required by default. # This file is not required by default.
require "singleton" require "singleton" unless defined?(Singleton)
require "forwardable" require "forwardable" unless defined?(Forwardable)
require "fileutils" require "fileutils" unless defined?(FileUtils)
require "uri" require "uri" unless defined?(URI)
# Gem extensions for doing unusual things - not loaded by Gem default # Gem extensions for doing unusual things - not loaded by Gem default
require "rubygems/package" require "rubygems/package" unless defined?(Gem::Package)
require "rubygems/name_tuple" require "rubygems/name_tuple"
require "rubygems/uninstaller" require "rubygems/uninstaller"
require "rubygems/remote_fetcher" require "rubygems/remote_fetcher"

View file

@ -130,7 +130,7 @@ module Inspec::Plugin::V2
end end
def self.plugin_gem_path def self.plugin_gem_path
require "rbconfig" require "rbconfig" unless defined?(RbConfig)
ruby_abi_version = RbConfig::CONFIG["ruby_version"] ruby_abi_version = RbConfig::CONFIG["ruby_version"]
# TODO: why are we installing under the api directory for plugins? # TODO: why are we installing under the api directory for plugins?
base_dir = Inspec.config_dir base_dir = Inspec.config_dir

View file

@ -1,5 +1,5 @@
require "forwardable" require "forwardable" unless defined?(Forwardable)
require "singleton" require "singleton" unless defined?(Singleton)
require "train" require "train"
require_relative "status" require_relative "status"

View file

@ -1,8 +1,8 @@
# Copyright 2015 Dominik Richter # Copyright 2015 Dominik Richter
require "forwardable" require "forwardable" unless defined?(Forwardable)
require "openssl" require "openssl" unless defined?(OpenSSL)
require "pathname" require "pathname" unless defined?(Pathname)
require "inspec/input_registry" require "inspec/input_registry"
require "inspec/cached_fetcher" # TODO: split or rename require "inspec/cached_fetcher" # TODO: split or rename
require "inspec/source_reader" require "inspec/source_reader"

View file

@ -4,7 +4,7 @@ require "inspec/resource"
require "inspec/library_eval_context" require "inspec/library_eval_context"
require "inspec/control_eval_context" require "inspec/control_eval_context"
require "inspec/require_loader" require "inspec/require_loader"
require "securerandom" require "securerandom" unless defined?(SecureRandom)
require "inspec/input_registry" require "inspec/input_registry"
module Inspec module Inspec

View file

@ -1,5 +1,5 @@
require "json" require "json" unless defined?(JSON)
require "net/http" require "net/http" unless defined?(Net::HTTP)
module Inspec::Reporters module Inspec::Reporters
class Automate < JsonAutomate class Automate < JsonAutomate

View file

@ -1,4 +1,4 @@
require "json" require "json" unless defined?(JSON)
module Inspec::Reporters module Inspec::Reporters
# rubocop:disable Layout/AlignHash, Style/BlockDelimiters # rubocop:disable Layout/AlignHash, Style/BlockDelimiters

View file

@ -1,4 +1,4 @@
require "json" require "json" unless defined?(JSON)
module Inspec::Reporters module Inspec::Reporters
class JsonAutomate < Json class JsonAutomate < Json

View file

@ -16,11 +16,11 @@ inspec_core_only = ENV["NO_AWS"] || !File.exist?(File.join(File.dirname(__FILE__
# Do not attempt to load cloud resources if we are in inspec-core mode # Do not attempt to load cloud resources if we are in inspec-core mode
unless inspec_core_only unless inspec_core_only
require "resource_support/aws" require "resource_support/aws"
require "resources/azure/azure_backend.rb" require "resources/azure/azure_backend"
require "resources/azure/azure_generic_resource.rb" require "resources/azure/azure_generic_resource"
require "resources/azure/azure_resource_group.rb" require "resources/azure/azure_resource_group"
require "resources/azure/azure_virtual_machine.rb" require "resources/azure/azure_virtual_machine"
require "resources/azure/azure_virtual_machine_data_disk.rb" require "resources/azure/azure_virtual_machine_data_disk"
end end
require "inspec/resources/aide_conf" require "inspec/resources/aide_conf"

View file

@ -24,7 +24,7 @@ require "inspec/resources/command"
# apt-get install software-properties-common # apt-get install software-properties-common
# add-apt-repository ppa:ubuntu-wine/ppa # add-apt-repository ppa:ubuntu-wine/ppa
require "uri" require "uri" unless defined?(URI)
module Inspec::Resources module Inspec::Resources
class AptRepository < Inspec.resource(1) class AptRepository < Inspec.resource(1)

View file

@ -1,4 +1,4 @@
require "forwardable" require "forwardable" unless defined?(Forwardable)
require "inspec/utils/filter_array" require "inspec/utils/filter_array"
require "inspec/utils/filter" require "inspec/utils/filter"
require "inspec/utils/parser" require "inspec/utils/parser"

View file

@ -20,7 +20,7 @@ module Inspec::Resources
# { 'name' => 'row2', 'col1' => 'value3', 'col2' => 'value4' } # { 'name' => 'row2', 'col1' => 'value3', 'col2' => 'value4' }
# ] # ]
def parse(content) def parse(content)
require "csv" require "csv" unless defined?(CSV)
# convert empty field to nil # convert empty field to nil
CSV::Converters[:blank_to_nil] = lambda do |field| CSV::Converters[:blank_to_nil] = lambda do |field|

View file

@ -1,4 +1,4 @@
require "openssl" require "openssl" unless defined?(OpenSSL)
require "inspec/utils/file_reader" require "inspec/utils/file_reader"
module Inspec::Resources module Inspec::Resources

View file

@ -1,6 +1,6 @@
# copyright: 2015, Vulcano Security GmbH # copyright: 2015, Vulcano Security GmbH
require "shellwords" require "shellwords" unless defined?(Shellwords)
require "inspec/utils/parser" require "inspec/utils/parser"
module Inspec::Resources module Inspec::Resources

View file

@ -3,7 +3,7 @@
# license: Apache v2 # license: Apache v2
require "inspec/resources/command" require "inspec/resources/command"
require "faraday" require "faraday" unless defined?(Faraday)
require "faraday_middleware" require "faraday_middleware"
require "hashie" require "hashie"

View file

@ -1,2 +1,2 @@
# This is just here to make the dynamic loader happy. # This is just here to make the dynamic loader happy.
require "inspec/resources/iis_website.rb" require "inspec/resources/iis_website"

View file

@ -24,7 +24,7 @@ module Inspec::Resources
.install_filter_methods_on_resource(self, :scan_interfaces) .install_filter_methods_on_resource(self, :scan_interfaces)
def ipv4_address def ipv4_address
require "ipaddr" require "ipaddr" unless defined?(IPAddr)
# Loop over interface names # Loop over interface names
# Select those that are up and have an ipv4 address # Select those that are up and have an ipv4 address

View file

@ -66,7 +66,7 @@ module Inspec::Resources
private private
def parse(content) def parse(content)
require "json" require "json" unless defined?(JSON)
JSON.parse(content) JSON.parse(content)
rescue => e rescue => e
raise Inspec::Exceptions::ResourceFailed, "Unable to parse JSON: #{e.message}" raise Inspec::Exceptions::ResourceFailed, "Unable to parse JSON: #{e.message}"

View file

@ -1,4 +1,4 @@
require "openssl" require "openssl" unless defined?(OpenSSL)
require "hashie/mash" require "hashie/mash"
require "inspec/utils/file_reader" require "inspec/utils/file_reader"
require "inspec/utils/pkey_reader" require "inspec/utils/pkey_reader"

View file

@ -95,7 +95,7 @@ module Inspec::Resources
end end
def parse_csv_result(cmd) def parse_csv_result(cmd)
require "csv" require "csv" unless defined?(CSV)
table = CSV.parse(cmd.stdout, headers: true) table = CSV.parse(cmd.stdout, headers: true)
# remove first row, since it will be a seperator line # remove first row, since it will be a seperator line

View file

@ -1,7 +1,7 @@
# copyright: 2015, Vulcano Security GmbH # copyright: 2015, Vulcano Security GmbH
require "inspec/resources/command" require "inspec/resources/command"
require "shellwords" require "shellwords" unless defined?(Shellwords)
module Inspec::Resources module Inspec::Resources
class Lines class Lines

View file

@ -1,4 +1,4 @@
require "pathname" require "pathname" unless defined?(Pathname)
require "hashie/mash" require "hashie/mash"
require "inspec/resources/command" require "inspec/resources/command"

View file

@ -1,7 +1,7 @@
require "inspec/utils/nginx_parser" require "inspec/utils/nginx_parser"
require "inspec/utils/find_files" require "inspec/utils/find_files"
require "inspec/utils/file_reader" require "inspec/utils/file_reader"
require "forwardable" require "forwardable" unless defined?(Forwardable)
# STABILITY: Experimental # STABILITY: Experimental
# This resouce needs a proper interace to the underlying data, which is currently missing. # This resouce needs a proper interace to the underlying data, which is currently missing.

View file

@ -1,5 +1,5 @@
require "inspec/resources/command" require "inspec/resources/command"
require "shellwords" require "shellwords" unless defined?(Shellwords)
module Inspec::Resources module Inspec::Resources
class NpmPackage < Inspec.resource(1) class NpmPackage < Inspec.resource(1)

View file

@ -1,7 +1,7 @@
require "inspec/resources/command" require "inspec/resources/command"
require "inspec/utils/database_helpers" require "inspec/utils/database_helpers"
require "hashie/mash" require "hashie/mash"
require "csv" require "csv" unless defined?(CSV)
module Inspec::Resources module Inspec::Resources
# STABILITY: Experimental # STABILITY: Experimental

View file

@ -1,6 +1,6 @@
require "inspec/utils/parser" require "inspec/utils/parser"
require "inspec/utils/filter" require "inspec/utils/filter"
require "ipaddr" require "ipaddr" unless defined?(IPAddr)
# TODO: currently we return local ip only # TODO: currently we return local ip only
# TODO: improve handling of same port on multiple interfaces # TODO: improve handling of same port on multiple interfaces

View file

@ -1,6 +1,6 @@
# copyright: 2015, Vulcano Security GmbH # copyright: 2015, Vulcano Security GmbH
require "shellwords" require "shellwords" unless defined?(Shellwords)
module Inspec::Resources module Inspec::Resources
class Lines class Lines

View file

@ -1,2 +1,2 @@
# This is just here to make the dynamic loader happy. # This is just here to make the dynamic loader happy.
require "inspec/resources/apt.rb" require "inspec/resources/apt"

View file

@ -1,7 +1,7 @@
# copyright: 2015, Vulcano Security GmbH # copyright: 2015, Vulcano Security GmbH
require "inspec/utils/filter" require "inspec/utils/filter"
require "ostruct" require "ostruct" unless defined?(OpenStruct)
require "inspec/resources/command" require "inspec/resources/command"
module Inspec::Resources module Inspec::Resources

View file

@ -1,2 +1,2 @@
# This is just here to make the dynamic loader happy. # This is just here to make the dynamic loader happy.
require "inspec/resources/rabbitmq_config.rb" require "inspec/resources/rabbitmq_config"

View file

@ -1,6 +1,6 @@
# copyright: 2015, Vulcano Security GmbH # copyright: 2015, Vulcano Security GmbH
require "json" require "json" unless defined?(JSON)
require "inspec/resources/powershell" require "inspec/resources/powershell"
# Three constructor methods are available: # Three constructor methods are available:

View file

@ -1,2 +1,2 @@
# This is just here to make the dynamic loader happy. # This is just here to make the dynamic loader happy.
require "inspec/resources/ssh_config.rb" require "inspec/resources/ssh_config"

View file

@ -1,8 +1,8 @@
# copyright: 2015, Chef Software Inc. # copyright: 2015, Chef Software Inc.
require "sslshake" require "sslshake" unless defined?(SSLShake)
require "inspec/utils/filter" require "inspec/utils/filter"
require "uri" require "uri" unless defined?(URI)
require "parallel" require "parallel"
# Custom resource based on the InSpec resource DSL # Custom resource based on the InSpec resource DSL

View file

@ -1,4 +1,4 @@
require "tomlrb" require "tomlrb" unless defined?(Tomlrb)
require "inspec/resources/json" require "inspec/resources/json"
module Inspec::Resources module Inspec::Resources

View file

@ -1,5 +1,5 @@
require "inspec/resources/powershell" require "inspec/resources/powershell"
require "securerandom" require "securerandom" unless defined?(SecureRandom)
module Inspec::Resources module Inspec::Resources
# This resource allows users to run vbscript on windows machines. We decided # This resource allows users to run vbscript on windows machines. We decided

View file

@ -1,2 +1,2 @@
# This is just here to make the dynamic loader happy. # This is just here to make the dynamic loader happy.
require "inspec/resources/registry_key.rb" require "inspec/resources/registry_key"

View file

@ -1,4 +1,4 @@
require "openssl" require "openssl" unless defined?(OpenSSL)
require "hashie/mash" require "hashie/mash"
require "inspec/utils/file_reader" require "inspec/utils/file_reader"

View file

@ -13,7 +13,7 @@ module Inspec::Resources
EXAMPLE EXAMPLE
def parse(content) def parse(content)
require "rexml/document" require "rexml/document" unless defined?(REXML::Document)
REXML::Document.new(content) REXML::Document.new(content)
rescue => e rescue => e
raise Inspec::Exceptions::ResourceFailed, "Unable to parse XML: #{e.message}" raise Inspec::Exceptions::ResourceFailed, "Unable to parse XML: #{e.message}"

View file

@ -1,7 +1,7 @@
# copyright: 2015, Dominik Richter # copyright: 2015, Dominik Richter
require "forwardable" require "forwardable" unless defined?(Forwardable)
require "uri" require "uri" unless defined?(URI)
require "inspec/backend" require "inspec/backend"
require "inspec/profile_context" require "inspec/profile_context"
require "inspec/profile" require "inspec/profile"

View file

@ -1,4 +1,4 @@
require "json" require "json" unless defined?(JSON)
module Inspec module Inspec
class Schema class Schema

View file

@ -1,4 +1,4 @@
require "json" require "json" unless defined?(JSON)
require "inspec/schema/primitives" require "inspec/schema/primitives"
require "inspec/schema/exec_json" require "inspec/schema/exec_json"
require "inspec/schema/exec_json_min" require "inspec/schema/exec_json_min"

View file

@ -1,4 +1,4 @@
require "set" require "set" unless defined?(Set)
# These elements are shared between more than one output type # These elements are shared between more than one output type

View file

@ -1,5 +1,5 @@
require "etc" require "etc" unless defined?(Etc)
require "rbconfig" require "rbconfig" unless defined?(RbConfig)
module Inspec module Inspec
# #

View file

@ -1,4 +1,4 @@
require "shellwords" require "shellwords" unless defined?(Shellwords)
class CommandWrapper class CommandWrapper
UNIX_SHELLS = %w{sh bash zsh ksh}.freeze UNIX_SHELLS = %w{sh bash zsh ksh}.freeze

View file

@ -1,5 +1,5 @@
require "stringio" require "stringio" unless defined?(StringIO)
require "json" require "json" unless defined?(JSON)
require "inspec/globals" require "inspec/globals"
require "inspec/config" require "inspec/config"

View file

@ -1,4 +1,4 @@
require "json" require "json" unless defined?(JSON)
# a simple streaming json logger # a simple streaming json logger
class Logger::JSONFormatter < Logger::Formatter class Logger::JSONFormatter < Logger::Formatter

View file

@ -1,6 +1,6 @@
require "inspec/config" require "inspec/config"
require "inspec/utils/telemetry/data_series" require "inspec/utils/telemetry/data_series"
require "singleton" require "singleton" unless defined?(Singleton)
module Inspec::Telemetry module Inspec::Telemetry
# A Singleton collection of data series objects. # A Singleton collection of data series objects.

View file

@ -1,4 +1,4 @@
require "json" require "json" unless defined?(JSON)
module Inspec; end module Inspec; end

View file

@ -1,8 +1,8 @@
require "base64" require "base64" unless defined?(Base64)
require "openssl" require "openssl" unless defined?(OpenSSL)
require "pathname" require "pathname" unless defined?(Pathname)
require "set" require "set" unless defined?(Set)
require "tempfile" require "tempfile" unless defined?(Tempfile)
require "yaml" require "yaml"
require "inspec/dist" require "inspec/dist"
require "inspec/utils/json_profile_summary" require "inspec/utils/json_profile_summary"

View file

@ -1,6 +1,6 @@
require "fileutils" require "fileutils" unless defined?(FileUtils)
require "plugins/shared/core_plugin_test_helper" require "plugins/shared/core_plugin_test_helper"
require "securerandom" require "securerandom" unless defined?(SecureRandom)
class ArtifactCli < Minitest::Test class ArtifactCli < Minitest::Test
include CorePluginFunctionalHelper include CorePluginFunctionalHelper

View file

@ -1,6 +1,6 @@
require "net/http" require "net/http" unless defined?(Net::HTTP)
require "uri" require "uri" unless defined?(URI)
require "json" require "json" unless defined?(JSON)
require "inspec/dist" require "inspec/dist"
require_relative "api/login" require_relative "api/login"

View file

@ -1,6 +1,6 @@
require "net/http" require "net/http" unless defined?(Net::HTTP)
require "net/http/post/multipart" require "net/http/post/multipart"
require "uri" require "uri" unless defined?(URI)
module InspecPlugins module InspecPlugins
module Compliance module Compliance

View file

@ -1,4 +1,4 @@
require "uri" require "uri" unless defined?(URI)
require "inspec/fetcher" require "inspec/fetcher"
require "inspec/errors" require "inspec/errors"
require "inspec/dist" require "inspec/dist"
@ -85,7 +85,7 @@ module InspecPlugins
# If version was specified, it will be the first and only result. # If version was specified, it will be the first and only result.
# Note we are calling the sha256 as a string, not a symbol since # Note we are calling the sha256 as a string, not a symbol since
# it was returned as json from the Compliance API. # it was returned as json from the Compliance API.
profile_info = profile_result.sort_by { |x| Gem::Version.new(x["version"]) }[0] profile_info = profile_result.min_by { |x| Gem::Version.new(x["version"]) }
profile_checksum = profile_info.key?("sha256") ? profile_info["sha256"] : "" profile_checksum = profile_info.key?("sha256") ? profile_info["sha256"] : ""
end end
end end

View file

@ -1,4 +1,4 @@
require_relative "../../../shared/core_plugin_test_helper.rb" require_relative "../../../shared/core_plugin_test_helper"
class ComplianceCli < Minitest::Test class ComplianceCli < Minitest::Test
include CorePluginFunctionalHelper include CorePluginFunctionalHelper

View file

@ -1,7 +1,7 @@
require "minitest/autorun" require "minitest/autorun"
require "mocha/minitest" require "mocha/minitest"
require "webmock/minitest" require "webmock/minitest"
require_relative "../../../lib/inspec-compliance/api.rb" require_relative "../../../lib/inspec-compliance/api"
describe InspecPlugins::Compliance::API do describe InspecPlugins::Compliance::API do
let(:automate_options) do let(:automate_options) do

View file

@ -1,7 +1,7 @@
require "minitest/autorun" require "minitest/autorun"
require "webmock/minitest" require "webmock/minitest"
require "mocha/minitest" require "mocha/minitest"
require_relative "../../lib/inspec-compliance/api.rb" require_relative "../../lib/inspec-compliance/api"
describe InspecPlugins::Compliance::API do describe InspecPlugins::Compliance::API do
let(:profiles_response) do let(:profiles_response) do

View file

@ -1,6 +1,6 @@
require "minitest/autorun" require "minitest/autorun"
require "mocha/minitest" require "mocha/minitest"
require_relative "../../lib/inspec-compliance/api.rb" require_relative "../../lib/inspec-compliance/api"
describe InspecPlugins::Compliance::Fetcher do describe InspecPlugins::Compliance::Fetcher do
let(:config) { { "server" => "myserver" } } let(:config) { { "server" => "myserver" } }

View file

@ -1,7 +1,7 @@
require "inspec/profile_vendor" require "inspec/profile_vendor"
require "mixlib/shellout" require "mixlib/shellout" unless defined?(Mixlib::ShellOut)
require "tomlrb" require "tomlrb" unless defined?(Tomlrb)
require "ostruct" require "ostruct" unless defined?(OpenStruct)
require "inspec/dist" require "inspec/dist"
module InspecPlugins module InspecPlugins

View file

@ -1,5 +1,5 @@
require_relative "../../../shared/core_plugin_test_helper.rb" require_relative "../../../shared/core_plugin_test_helper"
require "fileutils" require "fileutils" unless defined?(FileUtils)
class ProfileCli < Minitest::Test class ProfileCli < Minitest::Test
include CorePluginFunctionalHelper include CorePluginFunctionalHelper

View file

@ -1,8 +1,8 @@
require "mixlib/log" require "mixlib/log"
require "fileutils" require "fileutils" unless defined?(FileUtils)
require "minitest/autorun" require "minitest/autorun"
require "inspec/backend" require "inspec/backend"
require_relative "../../lib/inspec-habitat/profile.rb" require_relative "../../lib/inspec-habitat/profile"
class InspecPlugins::Habitat::ProfileTest < Minitest::Test class InspecPlugins::Habitat::ProfileTest < Minitest::Test
def setup def setup
@ -15,7 +15,7 @@ class InspecPlugins::Habitat::ProfileTest < Minitest::Test
# Path from `__FILE__` needed to support running tests in `inspec/inspec` # Path from `__FILE__` needed to support running tests in `inspec/inspec`
@test_profile_path = File.join( @test_profile_path = File.join(
File.expand_path(File.dirname(__FILE__)), __dir__,
"../", "../",
"support", "support",
"example_profile" "example_profile"

View file

@ -1,4 +1,4 @@
require "pathname" require "pathname" unless defined?(Pathname)
require_relative "renderer" require_relative "renderer"
module InspecPlugins module InspecPlugins

View file

@ -1,4 +1,4 @@
require "pathname" require "pathname" unless defined?(Pathname)
require_relative "renderer" require_relative "renderer"
module InspecPlugins module InspecPlugins

View file

@ -1,5 +1,5 @@
require "fileutils" require "fileutils" unless defined?(FileUtils)
require "erb" require "erb" unless defined?(Erb)
module InspecPlugins module InspecPlugins
module Init module Init

View file

@ -1,4 +1,4 @@
require_relative "../../../shared/core_plugin_test_helper.rb" require_relative "../../../shared/core_plugin_test_helper"
class InitPluginCli < Minitest::Test class InitPluginCli < Minitest::Test
include CorePluginFunctionalHelper include CorePluginFunctionalHelper

View file

@ -1,5 +1,5 @@
require "yaml" require "yaml"
require_relative "../../../shared/core_plugin_test_helper.rb" require_relative "../../../shared/core_plugin_test_helper"
class InitCli < Minitest::Test class InitCli < Minitest::Test
include CorePluginFunctionalHelper include CorePluginFunctionalHelper

View file

@ -1,4 +1,4 @@
require "pathname" require "pathname" unless defined?(Pathname)
require "inspec/plugin/v2" require "inspec/plugin/v2"
require "inspec/plugin/v2/installer" require "inspec/plugin/v2/installer"
require "inspec/dist" require "inspec/dist"
@ -505,8 +505,8 @@ module InspecPlugins
plugin_name = status.name.to_s plugin_name = status.name.to_s
Inspec::Plugin::V2::Loader.list_installed_plugin_gems Inspec::Plugin::V2::Loader.list_installed_plugin_gems
.select { |spec| spec.name == plugin_name } .select { |spec| spec.name == plugin_name }
.sort_by(&:version) .max_by(&:version)
.last.version .version
end end
when :path when :path
"src" "src"

View file

@ -1,4 +1,4 @@
require_relative "../../../shared/core_plugin_test_helper.rb" require_relative "../../../shared/core_plugin_test_helper"
#-----------------------------------------------------------------------# #-----------------------------------------------------------------------#
# Thor option defs # Thor option defs

View file

@ -1,4 +1,4 @@
require_relative "../../../shared/core_plugin_test_helper.rb" require_relative "../../../shared/core_plugin_test_helper"
#-----------------------------------------------------------------------# #-----------------------------------------------------------------------#
# Plugin Definition # Plugin Definition

View file

@ -1,4 +1,4 @@
require "erb" require "erb" unless defined?(Erb)
require "inspec/config" require "inspec/config"
module InspecPlugins::Html2Reporter module InspecPlugins::Html2Reporter

View file

@ -1,5 +1,5 @@
require_relative "../../../shared/core_plugin_test_helper.rb" require_relative "../../../shared/core_plugin_test_helper"
require "tempfile" require "tempfile" unless defined?(Tempfile)
describe "inspec-reporter-html2" do describe "inspec-reporter-html2" do
include CorePluginFunctionalHelper include CorePluginFunctionalHelper

Some files were not shown because too many files have changed in this diff Show more