From b58a4b3f436eeabdb55e75cf9a1863fd19482758 Mon Sep 17 00:00:00 2001 From: Dominik Richter Date: Mon, 26 Oct 2015 04:04:18 +0100 Subject: [PATCH] rename vulcanosec -> inspec --- README.md | 26 ++++---- bin/{vulcano => inspec} | 20 +++--- examples/test-kitchen/Gemfile | 2 +- vulcano.gemspec => inspec.gemspec | 12 ++-- lib/{vulcano.rb => inspec.rb} | 14 ++-- lib/{vulcano => inspec}/backend.rb | 4 +- lib/{vulcano => inspec}/dsl.rb | 35 +++++----- lib/{vulcano => inspec}/log.rb | 2 +- lib/{vulcano => inspec}/metadata.rb | 2 +- lib/{vulcano => inspec}/plugins.rb | 4 +- lib/{vulcano => inspec}/plugins/resource.rb | 10 +-- lib/{vulcano => inspec}/profile.rb | 4 +- lib/{vulcano => inspec}/profile_context.rb | 18 ++--- lib/{vulcano => inspec}/resource.rb | 6 +- .../rspec_json_formatter.rb | 0 lib/{vulcano => inspec}/rule.rb | 2 +- lib/{vulcano => inspec}/runner.rb | 16 ++--- lib/{vulcano => inspec}/shell.rb | 6 +- lib/inspec/targets.rb | 9 +++ lib/{vulcano => inspec}/targets/core.rb | 2 +- lib/{vulcano => inspec}/targets/dir.rb | 2 +- lib/{vulcano => inspec}/targets/file.rb | 4 +- lib/{vulcano => inspec}/targets/folder.rb | 10 +-- lib/{vulcano => inspec}/targets/tar.rb | 2 +- lib/{vulcano => inspec}/targets/url.rb | 8 +-- lib/{vulcano => inspec}/targets/zip.rb | 6 +- lib/{vulcano => inspec}/version.rb | 2 +- lib/resources/apache_conf.rb | 6 +- lib/resources/apt.rb | 6 +- lib/resources/audit_policy.rb | 4 +- lib/resources/auditd_conf.rb | 4 +- lib/resources/auditd_rules.rb | 6 +- lib/resources/bond.rb | 4 +- lib/resources/bridge.rb | 23 +++---- lib/resources/command.rb | 6 +- lib/resources/directory.rb | 2 +- lib/resources/etc_group.rb | 6 +- lib/resources/file.rb | 12 ++-- lib/resources/gem.rb | 4 +- lib/resources/group.rb | 19 +++--- lib/resources/group_policy.rb | 4 +- lib/resources/host.rb | 23 +++---- lib/resources/inetd_conf.rb | 4 +- lib/resources/interface.rb | 19 +++--- lib/resources/iptables.rb | 6 +- lib/resources/json.rb | 4 +- lib/resources/kernel_module.rb | 8 +-- lib/resources/kernel_parameter.rb | 6 +- lib/resources/limits_conf.rb | 4 +- lib/resources/login_def.rb | 4 +- lib/resources/mysql.rb | 4 +- lib/resources/mysql_conf.rb | 8 +-- lib/resources/mysql_session.rb | 6 +- lib/resources/npm.rb | 4 +- lib/resources/ntp_conf.rb | 8 +-- lib/resources/oneget.rb | 6 +- lib/resources/os.rb | 6 +- lib/resources/os_env.rb | 4 +- lib/resources/package.rb | 29 ++++---- lib/resources/parse_config.rb | 8 +-- lib/resources/passwd.rb | 4 +- lib/resources/pip.rb | 8 +-- lib/resources/port.rb | 25 +++---- lib/resources/postgres.rb | 6 +- lib/resources/postgres_conf.rb | 8 +-- lib/resources/postgres_session.rb | 2 +- lib/resources/processes.rb | 4 +- lib/resources/registry_key.rb | 4 +- lib/resources/script.rb | 2 +- lib/resources/security_policy.rb | 8 +-- lib/resources/service.rb | 66 ++++++++++--------- lib/resources/ssh_conf.rb | 4 +- lib/resources/user.rb | 29 ++++---- lib/resources/windows_feature.rb | 6 +- lib/resources/yum.rb | 4 +- lib/utils/find_files.rb | 2 +- lib/vulcano/targets.rb | 9 --- test/docker_test.rb | 4 +- test/helper.rb | 10 +-- test/unit/profile_context_test.rb | 12 ++-- test/unit/resources/apt_test.rb | 4 +- test/unit/resources/audit_policy_test.rb | 4 +- test/unit/resources/auditd_conf_test.rb | 4 +- test/unit/resources/auditd_rules_test.rb | 4 +- test/unit/resources/bond_test.rb | 4 +- test/unit/resources/bridge_test.rb | 4 +- test/unit/resources/csv_test.rb | 4 +- test/unit/resources/etc_group_test.rb | 4 +- test/unit/resources/gem_test.rb | 4 +- test/unit/resources/group_test.rb | 4 +- test/unit/resources/host_test.rb | 4 +- test/unit/resources/inetd_conf_test.rb | 4 +- test/unit/resources/interface_test.rb | 4 +- test/unit/resources/iptables_test.rb | 4 +- test/unit/resources/json_test.rb | 4 +- test/unit/resources/kernel_module_test.rb | 4 +- test/unit/resources/kernel_parameter_test.rb | 4 +- test/unit/resources/limits_conf_test.rb | 4 +- test/unit/resources/login_def_test.rb | 4 +- test/unit/resources/mysql_conf_test.rb | 2 +- test/unit/resources/npm_test.rb | 4 +- test/unit/resources/ntp_conf_test.rb | 4 +- test/unit/resources/oneget_test.rb | 4 +- test/unit/resources/os_env_test.rb | 4 +- test/unit/resources/package_test.rb | 4 +- test/unit/resources/passwd_test.rb | 4 +- test/unit/resources/pip_test.rb | 4 +- test/unit/resources/port_test.rb | 4 +- test/unit/resources/processes_test.rb | 4 +- test/unit/resources/registry_key_test.rb | 4 +- test/unit/resources/script_test.rb | 4 +- test/unit/resources/security_policy_test.rb | 4 +- test/unit/resources/service_test.rb | 4 +- test/unit/resources/ssh_conf_test.rb | 4 +- test/unit/resources/user_test.rb | 4 +- test/unit/resources/windows_feature.rb | 4 +- test/unit/resources/yaml_test.rb | 4 +- test/unit/resources/yum_test.rb | 4 +- 118 files changed, 436 insertions(+), 426 deletions(-) rename bin/{vulcano => inspec} (89%) rename vulcano.gemspec => inspec.gemspec (76%) rename lib/{vulcano.rb => inspec.rb} (64%) rename lib/{vulcano => inspec}/backend.rb (93%) rename lib/{vulcano => inspec}/dsl.rb (81%) rename lib/{vulcano => inspec}/log.rb (97%) rename lib/{vulcano => inspec}/metadata.rb (99%) rename lib/{vulcano => inspec}/plugins.rb (60%) rename lib/{vulcano => inspec}/plugins/resource.rb (87%) rename lib/{vulcano => inspec}/profile.rb (98%) rename lib/{vulcano => inspec}/profile_context.rb (91%) rename lib/{vulcano => inspec}/resource.rb (96%) rename lib/{vulcano => inspec}/rspec_json_formatter.rb (100%) rename lib/{vulcano => inspec}/rule.rb (99%) rename lib/{vulcano => inspec}/runner.rb (91%) rename lib/{vulcano => inspec}/shell.rb (91%) create mode 100644 lib/inspec/targets.rb rename lib/{vulcano => inspec}/targets/core.rb (97%) rename lib/{vulcano => inspec}/targets/dir.rb (98%) rename lib/{vulcano => inspec}/targets/file.rb (79%) rename lib/{vulcano => inspec}/targets/folder.rb (77%) rename lib/{vulcano => inspec}/targets/tar.rb (96%) rename lib/{vulcano => inspec}/targets/url.rb (83%) rename lib/{vulcano => inspec}/targets/zip.rb (89%) rename lib/{vulcano => inspec}/version.rb (86%) delete mode 100644 lib/vulcano/targets.rb diff --git a/README.md b/README.md index 226191859..5b9a687f4 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Vulcano CLI +# Inspec CLI Test your Server, VM, or workstation. @@ -17,7 +17,7 @@ end Run this file locally: ```bash -vulcano exec test.rb +inspec exec test.rb ``` ## Installation @@ -28,20 +28,20 @@ To simply run it without installation, you must install [bundler](http://bundler ```bash bundle install -bundle exec bin/vulcano help +bundle exec bin/inspec help ``` To install it as a gem locally, run: ```bash -gem build vulcano.gemspec -gem install vulcano-*.gem +gem build inspec.gemspec +gem install inspec-*.gem ``` You should now be able to run: ```bash -vulcano --help +inspec --help ``` ## Usage @@ -52,16 +52,16 @@ Run tests against different targets: ```bash # run test locally -vulcano exec test.rb +inspec exec test.rb # run test on remote host on SSH -vulcano exec test.rb -t ssh://user@hostname +inspec exec test.rb -t ssh://user@hostname # run test on remote windows host on WinRM -vulcano exec test.rb -t winrm://Administrator@windowshost --password 'your-password' +inspec exec test.rb -t winrm://Administrator@windowshost --password 'your-password' # run test on docker container -vulcano exec test.rb -t docker://container_id +inspec exec test.rb -t docker://container_id ``` ### detect @@ -70,7 +70,7 @@ Verify your configuration and detect ```bash id=$( docker run -dti ubuntu:14.04 /bin/bash ) -vulcano detect -t docker://$id +inspec detect -t docker://$id ``` Which will provide you with: @@ -87,12 +87,12 @@ application called Gordon and save it in `gordon_config.rb`: ```ruby require 'yaml' -class GordonConfig < Vulcano.resource +class GordonConfig < Inspec.resource name 'gordon_config' def initialize @path = '/etc/gordon/config.yaml' - @config = vulcano.file(@path).content + @config = inspec.file(@path).content @params = YAML.load(@config) end diff --git a/bin/vulcano b/bin/inspec similarity index 89% rename from bin/vulcano rename to bin/inspec index 55a3f31ac..6ce82a458 100755 --- a/bin/vulcano +++ b/bin/inspec @@ -6,9 +6,9 @@ require 'thor' require 'json' -require_relative '../lib/vulcano' +require_relative '../lib/inspec' -class VulcanoCLI < Thor +class InspecCLI < Thor def self.target_options option :target, aliases: :t, type: :string, default: nil, desc: 'Simple targeting option using URIs, e.g. ssh://user:pass@host:port' @@ -44,7 +44,7 @@ class VulcanoCLI < Thor option :output, aliases: :o, type: :string, desc: 'Save the created profile to a path' def json(path) - profile = Vulcano::Profile.from_path(path, options) + profile = Inspec::Profile.from_path(path, options) dst = options[:output].to_s if dst.empty? puts JSON.pretty_generate(profile.info) @@ -63,7 +63,7 @@ class VulcanoCLI < Thor def check(path) o = options.dup o[:logger] = Logger.new(STDOUT) - profile = Vulcano::Profile.from_path(path, o) + profile = Inspec::Profile.from_path(path, o) exit 1 unless profile.check end @@ -73,7 +73,7 @@ class VulcanoCLI < Thor target_options option :format, type: :string, default: 'progress' def exec(*tests) - runner = Vulcano::Runner.new(options) + runner = Inspec::Runner.new(options) runner.add_tests(tests) runner.run rescue RuntimeError => e @@ -83,7 +83,7 @@ class VulcanoCLI < Thor desc 'detect', 'detect the target OS' target_options def detect - runner = Vulcano::Runner.new(options) + runner = Inspec::Runner.new(options) rel = File.join(File.dirname(__FILE__), *%w{.. lib utils detect.rb}) detect_util = File.expand_path(rel) runner.add_tests([detect_util]) @@ -95,15 +95,15 @@ class VulcanoCLI < Thor desc 'shell', 'open an interactive debugging shell' target_options def shell_func - runner = Vulcano::Runner.new(options) - Vulcano::Shell.new(runner).start + runner = Inspec::Runner.new(options) + Inspec::Shell.new(runner).start rescue RuntimeError => e puts e.message end desc 'version', 'prints the version of this tool' def version - puts Vulcano::VERSION + puts Inspec::VERSION end end -VulcanoCLI.start(ARGV) +InspecCLI.start(ARGV) diff --git a/examples/test-kitchen/Gemfile b/examples/test-kitchen/Gemfile index 2c08bfb43..7bab89aac 100644 --- a/examples/test-kitchen/Gemfile +++ b/examples/test-kitchen/Gemfile @@ -1,7 +1,7 @@ # encoding: utf-8 source 'https://rubygems.org' -gem 'vulcano', path: '../../.' +gem 'inspec', path: '../../.' gem 'train', git: 'git@github.com:chef/train.git' group :test do diff --git a/vulcano.gemspec b/inspec.gemspec similarity index 76% rename from vulcano.gemspec rename to inspec.gemspec index 485ee38d1..710a01658 100644 --- a/vulcano.gemspec +++ b/inspec.gemspec @@ -1,15 +1,15 @@ # coding: utf-8 lib = File.expand_path('../lib', __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) -require 'vulcano/version' +require 'inspec/version' Gem::Specification.new do |spec| - spec.name = 'vulcano' - spec.version = Vulcano::VERSION + spec.name = 'inspec' + spec.version = Inspec::VERSION spec.authors = ['Dominik Richter'] - spec.email = ['dominik@vulcanosec.com'] - spec.summary = 'Validate Vulcano compliance checks.' - spec.description = 'Validate Vulcano compliance checks.' + spec.email = ['dominik.richter@gmail.com'] + spec.summary = 'Validate Inspec compliance checks.' + spec.description = 'Validate Inspec compliance checks.' spec.homepage = 'https://github.com/...' spec.license = 'Proprietary' diff --git a/lib/vulcano.rb b/lib/inspec.rb similarity index 64% rename from lib/vulcano.rb rename to lib/inspec.rb index 0aa2c5a59..3c0cdde71 100644 --- a/lib/vulcano.rb +++ b/lib/inspec.rb @@ -10,11 +10,11 @@ Encoding.default_internal = Encoding::UTF_8 libdir = File.dirname(__FILE__) $LOAD_PATH.unshift(libdir) unless $LOAD_PATH.include?(libdir) -require 'vulcano/version' -require 'vulcano/profile' -require 'vulcano/resource' -require 'vulcano/rspec_json_formatter' -require 'vulcano/rule' -require 'vulcano/runner' -require 'vulcano/shell' +require 'inspec/version' +require 'inspec/profile' +require 'inspec/resource' +require 'inspec/rspec_json_formatter' +require 'inspec/rule' +require 'inspec/runner' +require 'inspec/shell' require 'matchers/matchers' diff --git a/lib/vulcano/backend.rb b/lib/inspec/backend.rb similarity index 93% rename from lib/vulcano/backend.rb rename to lib/inspec/backend.rb index db06b5b60..d63edd1df 100644 --- a/lib/vulcano/backend.rb +++ b/lib/inspec/backend.rb @@ -6,7 +6,7 @@ require 'train' -module Vulcano +module Inspec module Backend # Create the transport backend with aggregated resources. # @@ -29,7 +29,7 @@ module Vulcano define_method :backend do connection end - Vulcano::Resource.registry.each do |id, r| + Inspec::Resource.registry.each do |id, r| define_method id.to_sym do |*args| r.new(self, id.to_s, *args) end diff --git a/lib/vulcano/dsl.rb b/lib/inspec/dsl.rb similarity index 81% rename from lib/vulcano/dsl.rb rename to lib/inspec/dsl.rb index 26002253c..31a0cda56 100644 --- a/lib/vulcano/dsl.rb +++ b/lib/inspec/dsl.rb @@ -4,13 +4,13 @@ # author: Dominik Richter # author: Christoph Hartmann -module Vulcano::DSL +module Inspec::DSL def require_rules(id, &block) - ::Vulcano::DSL.load_spec_files_for_profile self, id, false, &block + ::Inspec::DSL.load_spec_files_for_profile self, id, false, &block end def include_rules(id, &block) - ::Vulcano::DSL.load_spec_files_for_profile self, id, true, &block + ::Inspec::DSL.load_spec_files_for_profile self, id, true, &block end # Register a given rule with RSpec and @@ -18,18 +18,18 @@ module Vulcano::DSL # else is merged in. def self.execute_rule(r, profile_id) checks = r.instance_variable_get(:@checks) - fid = VulcanoBaseRule.full_id(r, profile_id) + fid = InspecBaseRule.full_id(r, profile_id) checks.each do |m, a, b| # check if the resource is skippable and skipped if a.is_a?(Array) && !a.empty? && a[0].respond_to?(:resource_skipped) && !a[0].resource_skipped.nil? - cres = ::Vulcano::Rule.__send__(m, *a) do + cres = ::Inspec::Rule.__send__(m, *a) do it a[0].resource_skipped end else # execute the method - cres = ::Vulcano::Rule.__send__(m, *a, &b) + cres = ::Inspec::Rule.__send__(m, *a, &b) end if m == 'describe' set_rspec_ids(cres, fid) @@ -42,7 +42,7 @@ module Vulcano::DSL # merge two rules completely; all defined # fields from src will be overwritten in dst def self.merge_rules(dst, src) - VulcanoBaseRule.merge dst, src + InspecBaseRule.merge dst, src end # Attach an ID attribute to the @@ -61,7 +61,7 @@ module Vulcano::DSL raw = File.read(file) # TODO: error-handling - ctx = Vulcano::ProfileContext.new(profile_id, rule_registry, only_ifs) + ctx = Inspec::ProfileContext.new(profile_id, rule_registry, only_ifs) ctx.instance_eval(raw, file, 1) end @@ -79,7 +79,7 @@ module Vulcano::DSL # interpret the block and create a set of rules from it block_registry = {} if block_given? - ctx = Vulcano::ProfileContext.new(profile_id, block_registry, only_ifs) + ctx = Inspec::ProfileContext.new(profile_id, block_registry, only_ifs) ctx.instance_eval(&block) end @@ -110,7 +110,7 @@ module Vulcano::DSL end def self.get_spec_files_for_profile(id) - base_path = '/etc/vulcanosec/tests' + base_path = '/etc/inspec/tests' path = File.join(base_path, id) # find all files to be included files = [] @@ -126,28 +126,25 @@ module Vulcano::DSL end end -module Vulcano::GlobalDSL +module Inspec::GlobalDSL def __register_rule(r) # make sure the profile id is attached to the rule - ::Vulcano::DSL.execute_rule(r, __profile_id) + ::Inspec::DSL.execute_rule(r, __profile_id) end def __unregister_rule(_id) end end -module Vulcano::DSLHelper +module Inspec::DSLHelper def self.bind_dsl(scope) # rubocop:disable Lint/NestedMethodDefinition (class << scope; self; end).class_exec do - include Vulcano::DSL - include Vulcano::GlobalDSL - def __profile_id - ENV['VULCANOSEC_PROFILE_ID'] - end + include Inspec::DSL + include Inspec::GlobalDSL end # rubocop:enable all end end -::Vulcano::DSLHelper.bind_dsl(self) +::Inspec::DSLHelper.bind_dsl(self) diff --git a/lib/vulcano/log.rb b/lib/inspec/log.rb similarity index 97% rename from lib/vulcano/log.rb rename to lib/inspec/log.rb index 53119e99e..93aa1f70d 100644 --- a/lib/vulcano/log.rb +++ b/lib/inspec/log.rb @@ -5,7 +5,7 @@ require 'rainbow/ext/string' -module Vulcano +module Inspec class Log def initialize(opts = {}) @quiet = opts[:quiet] || false diff --git a/lib/vulcano/metadata.rb b/lib/inspec/metadata.rb similarity index 99% rename from lib/vulcano/metadata.rb rename to lib/inspec/metadata.rb index 55e9a3f86..b521cfed7 100644 --- a/lib/vulcano/metadata.rb +++ b/lib/inspec/metadata.rb @@ -5,7 +5,7 @@ require 'logger' -module Vulcano +module Inspec # Extract metadata.rb information class Metadata attr_reader :params diff --git a/lib/vulcano/plugins.rb b/lib/inspec/plugins.rb similarity index 60% rename from lib/vulcano/plugins.rb rename to lib/inspec/plugins.rb index 9e0f0441e..be5c0b89e 100644 --- a/lib/vulcano/plugins.rb +++ b/lib/inspec/plugins.rb @@ -2,8 +2,8 @@ # author: Dominik Richter # author: Christoph Hartmann -module Vulcano +module Inspec module Plugins - autoload :Resource, 'vulcano/plugins/resource' + autoload :Resource, 'inspec/plugins/resource' end end diff --git a/lib/vulcano/plugins/resource.rb b/lib/inspec/plugins/resource.rb similarity index 87% rename from lib/vulcano/plugins/resource.rb rename to lib/inspec/plugins/resource.rb index 493e10b2e..c47a1f0bd 100644 --- a/lib/vulcano/plugins/resource.rb +++ b/lib/inspec/plugins/resource.rb @@ -2,19 +2,19 @@ # author: Dominik Richter # author: Christoph Hartmann -module Vulcano +module Inspec module Plugins class Resource def self.name(name = nil) return if name.nil? - Vulcano::Plugins::Resource.__register(name, self) + Inspec::Plugins::Resource.__register(name, self) end def self.__register(name, obj) # rubocop:disable Lint/NestedMethodDefinition cl = Class.new(obj) do # add some common methods - include Vulcano::Plugins::ResourceCommon + include Inspec::Plugins::ResourceCommon def initialize(backend, name, *args) # attach the backend to this instance @__backend_runner__ = backend @@ -23,14 +23,14 @@ module Vulcano super(*args) end - def vulcano + def inspec @__backend_runner__ end end # rubocop:enable Lint/NestedMethodDefinition # add the resource to the registry by name - Vulcano::Resource.registry[name] = cl + Inspec::Resource.registry[name] = cl end # Define methods which are available to all resources diff --git a/lib/vulcano/profile.rb b/lib/inspec/profile.rb similarity index 98% rename from lib/vulcano/profile.rb rename to lib/inspec/profile.rb index 16f8db344..5ce6ecbaf 100644 --- a/lib/vulcano/profile.rb +++ b/lib/inspec/profile.rb @@ -3,9 +3,9 @@ # author: Dominik Richter # author: Christoph Hartmann -require 'vulcano/metadata' +require 'inspec/metadata' -module Vulcano +module Inspec class Profile def self.from_path(path, options = nil) opt = options.dup || {} diff --git a/lib/vulcano/profile_context.rb b/lib/inspec/profile_context.rb similarity index 91% rename from lib/vulcano/profile_context.rb rename to lib/inspec/profile_context.rb index 89b50a209..a0662bfb9 100644 --- a/lib/vulcano/profile_context.rb +++ b/lib/inspec/profile_context.rb @@ -2,11 +2,11 @@ # author: Dominik Richter # author: Christoph Hartmann -require 'vulcano/rule' -require 'vulcano/dsl' +require 'inspec/rule' +require 'inspec/dsl' require 'rspec/core/dsl' -module Vulcano +module Inspec class ProfileContext attr_reader :rules, :only_ifs def initialize(profile_id, backend, profile_registry = {}, only_ifs = []) @@ -31,13 +31,13 @@ module Vulcano end def unregister_rule(id) - full_id = Vulcano::Rule.full_id(@profile_id, id) + full_id = Inspec::Rule.full_id(@profile_id, id) @rules[full_id] = nil end def register_rule(r) # get the full ID - full_id = Vulcano::Rule.full_id(@profile_id, r) + full_id = Inspec::Rule.full_id(@profile_id, r) if full_id.nil? # TODO: error return @@ -48,7 +48,7 @@ module Vulcano if existing.nil? @rules[full_id] = r else - Vulcano::Rule.merge(existing, r) + Inspec::Rule.merge(existing, r) end end @@ -62,7 +62,7 @@ module Vulcano # @return [InnerDSLModule] def create_inner_dsl(backend) Module.new do - Vulcano::Resource.registry.each do |id, r| + Inspec::Resource.registry.each do |id, r| define_method id.to_sym do |*args| r.new(backend, id.to_s, *args) end @@ -76,7 +76,7 @@ module Vulcano # @param dsl [InnerDSLModule] which contains all resources # @return [OuterDSLClass] def create_outer_dsl(dsl) - rule_class = Class.new(Vulcano::Rule) do + rule_class = Class.new(Inspec::Rule) do include RSpec::Core::DSL include dsl end @@ -127,7 +127,7 @@ module Vulcano # rubocop:disable Lint/NestedMethodDefinition Class.new(outer_dsl) do - include Vulcano::DSL + include Inspec::DSL define_method :__register_rule do |*args| profile_context_owner.register_rule(*args) diff --git a/lib/vulcano/resource.rb b/lib/inspec/resource.rb similarity index 96% rename from lib/vulcano/resource.rb rename to lib/inspec/resource.rb index 82ad08534..5ff66ba72 100644 --- a/lib/vulcano/resource.rb +++ b/lib/inspec/resource.rb @@ -4,9 +4,9 @@ # author: Dominik Richter # author: Christoph Hartmann -require 'vulcano/plugins' +require 'inspec/plugins' -module Vulcano +module Inspec class Resource def self.registry @registry ||= {} @@ -17,7 +17,7 @@ module Vulcano if version != 1 fail 'Only resource version 1 is supported!' end - Vulcano::Plugins::Resource + Inspec::Plugins::Resource end end diff --git a/lib/vulcano/rspec_json_formatter.rb b/lib/inspec/rspec_json_formatter.rb similarity index 100% rename from lib/vulcano/rspec_json_formatter.rb rename to lib/inspec/rspec_json_formatter.rb diff --git a/lib/vulcano/rule.rb b/lib/inspec/rule.rb similarity index 99% rename from lib/vulcano/rule.rb rename to lib/inspec/rule.rb index 56ba3b4b7..4f84e82a0 100644 --- a/lib/vulcano/rule.rb +++ b/lib/inspec/rule.rb @@ -7,7 +7,7 @@ require 'rspec/expectations' require 'method_source' -module Vulcano +module Inspec class ExpectationTarget attr_reader :calls, :value, :block def initialize(value, &block) diff --git a/lib/vulcano/runner.rb b/lib/inspec/runner.rb similarity index 91% rename from lib/vulcano/runner.rb rename to lib/inspec/runner.rb index 4905e8317..95517659b 100644 --- a/lib/vulcano/runner.rb +++ b/lib/inspec/runner.rb @@ -5,15 +5,15 @@ # author: Christoph Hartmann require 'uri' -require 'vulcano/backend' -require 'vulcano/profile_context' -require 'vulcano/targets' +require 'inspec/backend' +require 'inspec/profile_context' +require 'inspec/targets' # spec requirements require 'rspec' require 'rspec/its' -require 'vulcano/rspec_json_formatter' +require 'inspec/rspec_json_formatter' -module Vulcano +module Inspec class Runner attr_reader :tests, :backend, :rules def initialize(conf = {}) @@ -39,13 +39,13 @@ module Vulcano end def configure_transport - @backend = Vulcano::Backend.create(@conf) + @backend = Inspec::Backend.create(@conf) end def add_tests(tests) # retrieve the raw ruby code of all tests items = tests.map do |test| - Vulcano::Targets.resolve(test) + Inspec::Targets.resolve(test) end # add all tests (raw) to the runtime @@ -55,7 +55,7 @@ module Vulcano end def create_context - Vulcano::ProfileContext.new(@profile_id, @backend) + Inspec::ProfileContext.new(@profile_id, @backend) end def add_content(content, source, line = nil) diff --git a/lib/vulcano/shell.rb b/lib/inspec/shell.rb similarity index 91% rename from lib/vulcano/shell.rb rename to lib/inspec/shell.rb index 6c48512cc..88705000d 100644 --- a/lib/vulcano/shell.rb +++ b/lib/inspec/shell.rb @@ -2,7 +2,7 @@ # author: Dominik Richter # author: Christoph Hartmann -module Vulcano +module Inspec class Shell def initialize(runner) @runner = runner @@ -38,7 +38,7 @@ module Vulcano end def intro - puts 'Welcome to the interactive Vulcano Shell' + puts 'Welcome to the interactive Inspec Shell' puts "To find out how to use it, type: #{mark 'usage'}" puts end @@ -47,7 +47,7 @@ module Vulcano ctx = @runner.backend puts < /dev/null") + res = inspec.backend.run_command("type \"#{@command}\" > /dev/null") res.exit_status.to_i == 0 end diff --git a/lib/resources/directory.rb b/lib/resources/directory.rb index 4b400660e..03f79353e 100644 --- a/lib/resources/directory.rb +++ b/lib/resources/directory.rb @@ -4,7 +4,7 @@ require 'resources/file' -module Vulcano::Resources +module Inspec::Resources class Directory < File name 'directory' end diff --git a/lib/resources/etc_group.rb b/lib/resources/etc_group.rb index 1120f4b53..94c19b6d4 100644 --- a/lib/resources/etc_group.rb +++ b/lib/resources/etc_group.rb @@ -24,7 +24,7 @@ require 'utils/convert' require 'utils/parser' -class EtcGroup < Vulcano.resource(1) +class EtcGroup < Inspec.resource(1) include Converter include ContentParser @@ -37,7 +37,7 @@ class EtcGroup < Vulcano.resource(1) # skip resource if it is not supported on current OS return skip_resource 'The `etc_group` resource is not supported on your OS.' \ - unless %w{ubuntu debian redhat fedora arch darwin freebsd}.include?(vulcano.os[:family]) + unless %w{ubuntu debian redhat fedora arch darwin freebsd}.include?(inspec.os[:family]) end def groups(filter = nil) @@ -90,7 +90,7 @@ class EtcGroup < Vulcano.resource(1) private def parse_group(path) - @content = vulcano.file(path).content + @content = inspec.file(path).content # iterate over each line and filter comments @content.split("\n").each_with_object([]) do |line, lines| grp_info = parse_group_line(line) diff --git a/lib/resources/file.rb b/lib/resources/file.rb index dbae4f696..729f99951 100644 --- a/lib/resources/file.rb +++ b/lib/resources/file.rb @@ -4,14 +4,14 @@ # author: Christoph Hartmann # license: All rights reserved -module Vulcano::Resources - class File < Vulcano.resource(1) +module Inspec::Resources + class File < Inspec.resource(1) name 'file' attr_reader :path def initialize(path) @path = path - @file = vulcano.backend.file(@path) + @file = inspec.backend.file(@path) end %w{ @@ -79,16 +79,16 @@ module Vulcano::Resources # check permissions on linux def check_user_access(user, file, flag) - if vulcano.os.linux? == true + if inspec.os.linux? == true # use sh on linux perm_cmd = "su -s /bin/sh -c \"test -#{flag} #{file}\" #{user}" - elsif vulcano.os[:family] == 'freebsd' + elsif inspec.os[:family] == 'freebsd' # use sudo on freebsd perm_cmd = "sudo -u #{user} test -#{flag} #{file}" end if !perm_cmd.nil? - cmd = vulcano.command(perm_cmd) + cmd = inspec.command(perm_cmd) cmd.exit_status == 0 ? true : false else return skip_resource 'The `file` resource does not support `by_user` on your OS.' diff --git a/lib/resources/gem.rb b/lib/resources/gem.rb index 74f63b465..ce039d646 100644 --- a/lib/resources/gem.rb +++ b/lib/resources/gem.rb @@ -6,7 +6,7 @@ # describe gem('rubocop') do # it { should be_installed } # end -class GemPackage < Vulcano.resource(1) +class GemPackage < Inspec.resource(1) name 'gem' def initialize(package_name) @@ -16,7 +16,7 @@ class GemPackage < Vulcano.resource(1) def info return @info if defined?(@info) - cmd = vulcano.command("gem list --local -a -q \^#{@package_name}\$") + cmd = inspec.command("gem list --local -a -q \^#{@package_name}\$") @info = { installed: cmd.exit_status == 0, type: 'gem', diff --git a/lib/resources/group.rb b/lib/resources/group.rb index e437742b0..fc986ced7 100644 --- a/lib/resources/group.rb +++ b/lib/resources/group.rb @@ -13,7 +13,7 @@ # it { should have_gid 0 } # end -class Group < Vulcano.resource(1) +class Group < Inspec.resource(1) name 'group' def initialize(groupname, domain = nil) @@ -25,10 +25,10 @@ class Group < Vulcano.resource(1) # select group manager @group_provider = nil - if vulcano.os.unix? - @group_provider = UnixGroup.new(vulcano) - elsif vulcano.os.windows? - @group_provider = WindowsGroup.new(vulcano) + if inspec.os.unix? + @group_provider = UnixGroup.new(inspec) + elsif inspec.os.windows? + @group_provider = WindowsGroup.new(inspec) else return skip_resource 'The `group` resource is not supported on your OS yet.' end @@ -82,15 +82,16 @@ class Group < Vulcano.resource(1) end class GroupInfo - def initialize(vulcano) - @vulcano = vulcano + attr_reader :inspec + def initialize(inspec) + @inspec = inspec end end # implements generic unix groups via /etc/group class UnixGroup < GroupInfo def group_info(group, _domain = nil) - @vulcano.etc_group.where(name: group).entries.map { |grp| + inspec.etc_group.where(name: group).entries.map { |grp| { name: grp['name'], gid: grp['gid'], @@ -101,7 +102,7 @@ end class WindowsGroup < GroupInfo def group_info(compare_group, compare_domain = nil) - cmd = @vulcano.command('Get-WmiObject Win32_Group | Select-Object -Property Caption, Domain, Name, SID, LocalAccount | ConvertTo-Json') + cmd = inspec.command('Get-WmiObject Win32_Group | Select-Object -Property Caption, Domain, Name, SID, LocalAccount | ConvertTo-Json') # cannot rely on exit code for now, successful command returns exit code 1 # return nil if cmd.exit_status != 0, try to parse json diff --git a/lib/resources/group_policy.rb b/lib/resources/group_policy.rb index e9eb0da2d..502d4a94a 100644 --- a/lib/resources/group_policy.rb +++ b/lib/resources/group_policy.rb @@ -15,13 +15,13 @@ def gpo(policy_path, policy_name) end # Group Policy -class GroupPolicy < Vulcano.resource(1) +class GroupPolicy < Inspec.resource(1) name 'group_policy' def get_registry_value(entry) keys = entry['registry_information'][0] cmd = "(Get-Item 'Registry::#{keys['path']}').GetValue('#{keys['key']}')" - command_result ||= vulcano.command(cmd) + command_result ||= inspec.command(cmd) val = { exit_code: command_result.exit_status.to_i, data: command_result.stdout } val end diff --git a/lib/resources/host.rb b/lib/resources/host.rb index 3e9a3563c..545de0b10 100644 --- a/lib/resources/host.rb +++ b/lib/resources/host.rb @@ -24,7 +24,7 @@ # it { should be_resolvable.by('dns') } # end -class Host < Vulcano.resource(1) +class Host < Inspec.resource(1) name 'host' def initialize(hostname, params = {}) @@ -33,10 +33,10 @@ class Host < Vulcano.resource(1) @proto = params[:proto] || nil @host_provider = nil - if vulcano.os.linux? - @host_provider = LinuxHostProvider.new(vulcano) - elsif vulcano.os.windows? - @host_provider = WindowsHostProvider.new(vulcano) + if inspec.os.linux? + @host_provider = LinuxHostProvider.new(inspec) + elsif inspec.os.windows? + @host_provider = WindowsHostProvider.new(inspec) else return skip_resource 'The `host` resource is not supported on your OS yet.' end @@ -76,8 +76,9 @@ class Host < Vulcano.resource(1) end class HostProvider - def initialize(vulcano) - @vulcano = vulcano + attr_reader :inspec + def initialize(inspec) + @inspec = inspec end end @@ -86,13 +87,13 @@ class LinuxHostProvider < HostProvider def ping(hostname, _port = nil, _proto = nil) # fall back to ping, but we can only test ICMP packages with ping # therefore we have to skip the test, if we do not have everything on the node to run the test - ping = @vulcano.command("ping -w 1 -c 1 #{hostname}") + ping = inspec.command("ping -w 1 -c 1 #{hostname}") ping.exit_status.to_i != 0 ? false : true end def resolve(hostname) # TODO: we rely on getent hosts for now, but it prefers to return IPv6, only then IPv4 - cmd = @vulcano.command("getent hosts #{hostname}") + cmd = inspec.command("getent hosts #{hostname}") return nil if cmd.exit_status.to_i != 0 # extract ip adress @@ -117,7 +118,7 @@ class WindowsHostProvider < HostProvider request += '| Select-Object -Property ComputerName, RemoteAddress, RemotePort, SourceAddress, PingSucceeded | ConvertTo-Json' p request request += '| Select-Object -Property ComputerName, PingSucceeded | ConvertTo-Json' - cmd = @vulcano.command(request) + cmd = inspec.command(request) begin ping = JSON.parse(cmd.stdout) @@ -129,7 +130,7 @@ class WindowsHostProvider < HostProvider end def resolve(hostname) - cmd = @vulcano.command("Resolve-DnsName –Type A #{hostname} | ConvertTo-Json") + cmd = inspec.command("Resolve-DnsName –Type A #{hostname} | ConvertTo-Json") begin resolv = JSON.parse(cmd.stdout) rescue JSON::ParserError => _e diff --git a/lib/resources/inetd_conf.rb b/lib/resources/inetd_conf.rb index 7d573cc9d..756181637 100644 --- a/lib/resources/inetd_conf.rb +++ b/lib/resources/inetd_conf.rb @@ -14,7 +14,7 @@ require 'utils/simpleconfig' # its('exec') { should eq nil } # end -class InetdConf < Vulcano.resource(1) +class InetdConf < Inspec.resource(1) name 'inetd_config' def initialize(path = nil) @@ -29,7 +29,7 @@ class InetdConf < Vulcano.resource(1) return @params if defined?(@params) # read the file - file = vulcano.file(@conf_path) + file = inspec.file(@conf_path) if !file.file? skip_resource "Can't find file \"#{@conf_path}\"" return @params = {} diff --git a/lib/resources/interface.rb b/lib/resources/interface.rb index c2df87a9f..5a0c5eeab 100644 --- a/lib/resources/interface.rb +++ b/lib/resources/interface.rb @@ -11,17 +11,17 @@ require 'utils/convert' -class NetworkInterface < Vulcano.resource(1) +class NetworkInterface < Inspec.resource(1) name 'interface' def initialize(iface) @iface = iface @interface_provider = nil - if vulcano.os.linux? - @interface_provider = LinuxInterface.new(vulcano) - elsif vulcano.os.windows? - @interface_provider = WindowsInterface.new(vulcano) + if inspec.os.linux? + @interface_provider = LinuxInterface.new(inspec) + elsif inspec.os.windows? + @interface_provider = WindowsInterface.new(inspec) else return skip_resource 'The `interface` resource is not supported on your OS yet.' end @@ -54,15 +54,16 @@ end class InterfaceInfo include Converter - def initialize(vulcano) - @vulcano = vulcano + attr_reader :inspec + def initialize(inspec) + @inspec = inspec end end class LinuxInterface < InterfaceInfo def interface_info(iface) # will return "[mtu]\n1500\n[type]\n1" - cmd = @vulcano.command("find /sys/class/net/#{iface}/ -type f -maxdepth 1 -exec sh -c 'echo \"[$(basename {})]\"; cat {} || echo -n' \\;") + cmd = inspec.command("find /sys/class/net/#{iface}/ -type f -maxdepth 1 -exec sh -c 'echo \"[$(basename {})]\"; cat {} || echo -n' \\;") return nil if cmd.exit_status.to_i != 0 # parse values, we only recieve values, therefore we threat them as keys @@ -96,7 +97,7 @@ end class WindowsInterface < InterfaceInfo def interface_info(iface) # gather all network interfaces - cmd = @vulcano.command('Get-NetAdapter | Select-Object -Property Name, InterfaceDescription, Status, State, MacAddress, LinkSpeed, ReceiveLinkSpeed, TransmitLinkSpeed, Virtual | ConvertTo-Json') + cmd = inspec.command('Get-NetAdapter | Select-Object -Property Name, InterfaceDescription, Status, State, MacAddress, LinkSpeed, ReceiveLinkSpeed, TransmitLinkSpeed, Virtual | ConvertTo-Json') # filter network interface begin diff --git a/lib/resources/iptables.rb b/lib/resources/iptables.rb index 8fb0995ea..c51d849e4 100644 --- a/lib/resources/iptables.rb +++ b/lib/resources/iptables.rb @@ -21,7 +21,7 @@ # @see http://ipset.netfilter.org/iptables.man.html # @see http://ipset.netfilter.org/iptables.man.html # @see https://www.frozentux.net/iptables-tutorial/iptables-tutorial.html -class IpTables < Vulcano.resource(1) +class IpTables < Inspec.resource(1) name 'iptables' def initialize(params = {}) @@ -29,7 +29,7 @@ class IpTables < Vulcano.resource(1) @chain = params[:chain] || nil # we're done if we are on linux - return if vulcano.os.linux? + return if inspec.os.linux? # ensures, all calls are aborted for non-supported os @iptables_cache = [] @@ -52,7 +52,7 @@ class IpTables < Vulcano.resource(1) # construct iptables command to read all rules @table.nil? ? table_cmd = '' : table_cmd = " -t #{@table} " @chain.nil? ? chain_cmd = '' : chain_cmd = " #{@chain}" - cmd = vulcano.command(format('iptables %s -S %s', table_cmd, chain_cmd).strip) + cmd = inspec.command(format('iptables %s -S %s', table_cmd, chain_cmd).strip) return [] if cmd.exit_status.to_i != 0 # split rules, returns array or rules diff --git a/lib/resources/json.rb b/lib/resources/json.rb index ac1419223..3c2f071ed 100644 --- a/lib/resources/json.rb +++ b/lib/resources/json.rb @@ -7,7 +7,7 @@ # describe json('policyfile.lock.json') do # its('cookbook_locks.omnibus.version') { should eq('2.2.0') } # end -class JsonConfig < Vulcano.resource(1) +class JsonConfig < Inspec.resource(1) name 'json' # make params readable @@ -15,7 +15,7 @@ class JsonConfig < Vulcano.resource(1) def initialize(path) @path = path - @file_content = vulcano.file(@path).content + @file_content = inspec.file(@path).content @params = parse(@file_content) end diff --git a/lib/resources/kernel_module.rb b/lib/resources/kernel_module.rb index 826829c35..800ea6cb9 100644 --- a/lib/resources/kernel_module.rb +++ b/lib/resources/kernel_module.rb @@ -8,24 +8,24 @@ # describe kernel_module('bridge') do # it { should be_loaded } # end -class KernelModule < Vulcano.resource(1) +class KernelModule < Inspec.resource(1) name 'kernel_module' def initialize(modulename = nil) @module = modulename # this resource is only supported on Linux - return skip_resource 'The `kernel_parameter` resource is not supported on your OS.' if !vulcano.os.linux? + return skip_resource 'The `kernel_parameter` resource is not supported on your OS.' if !inspec.os.linux? end def loaded? # default lsmod command lsmod_cmd = 'lsmod' # special care for CentOS 5 and sudo - lsmod_cmd = '/sbin/lsmod' if vulcano.os[:family] == 'centos' && vulcano.os[:release].to_i == 5 + lsmod_cmd = '/sbin/lsmod' if inspec.os[:family] == 'centos' && inspec.os[:release].to_i == 5 # get list of all modules - cmd = vulcano.command(lsmod_cmd) + cmd = inspec.command(lsmod_cmd) return false if cmd.exit_status != 0 # check if module is loaded diff --git a/lib/resources/kernel_parameter.rb b/lib/resources/kernel_parameter.rb index 5856af00b..97183fb8b 100644 --- a/lib/resources/kernel_parameter.rb +++ b/lib/resources/kernel_parameter.rb @@ -6,18 +6,18 @@ # describe kernel_parameter('net.ipv4.conf.all.forwarding') do # its(:value) { should eq 0 } # end -class KernelParameter < Vulcano.resource(1) +class KernelParameter < Inspec.resource(1) name 'kernel_parameter' def initialize(parameter = nil) @parameter = parameter # this resource is only supported on Linux - return skip_resource 'The `kernel_parameter` resource is not supported on your OS.' if !vulcano.os.linux? + return skip_resource 'The `kernel_parameter` resource is not supported on your OS.' if !inspec.os.linux? end def value - cmd = vulcano.command("/sbin/sysctl -q -n #{@parameter}") + cmd = inspec.command("/sbin/sysctl -q -n #{@parameter}") return nil if cmd.exit_status != 0 # remove whitespace cmd = cmd.stdout.chomp.strip diff --git a/lib/resources/limits_conf.rb b/lib/resources/limits_conf.rb index 79ce0e367..274ca481d 100644 --- a/lib/resources/limits_conf.rb +++ b/lib/resources/limits_conf.rb @@ -12,7 +12,7 @@ require 'utils/simpleconfig' # its('*') { should include ['hard','core','0'] } # end -class LimitsConf < Vulcano.resource(1) +class LimitsConf < Inspec.resource(1) name 'limits_conf' def initialize(path = nil) @@ -27,7 +27,7 @@ class LimitsConf < Vulcano.resource(1) return @params if defined?(@params) # read the file - file = vulcano.file(@conf_path) + file = inspec.file(@conf_path) if !file.file? skip_resource "Can't find file \"#{@conf_path}\"" return @params = {} diff --git a/lib/resources/login_def.rb b/lib/resources/login_def.rb index dc7341ec0..1aa259116 100644 --- a/lib/resources/login_def.rb +++ b/lib/resources/login_def.rb @@ -18,7 +18,7 @@ require 'utils/simpleconfig' # } # end -class LoginDef < Vulcano.resource(1) +class LoginDef < Inspec.resource(1) name 'login_defs' def initialize(path = nil) @@ -33,7 +33,7 @@ class LoginDef < Vulcano.resource(1) return @params if defined?(@params) # read the file - file = vulcano.file(@conf_path) + file = inspec.file(@conf_path) if !file.file? skip_resource "Can't find file \"#{@conf_path}\"" return @params = {} diff --git a/lib/resources/mysql.rb b/lib/resources/mysql.rb index 54ac4b35d..13b8b2946 100644 --- a/lib/resources/mysql.rb +++ b/lib/resources/mysql.rb @@ -4,13 +4,13 @@ # author: Christoph Hartmann # license: All rights reserved -class Mysql < Vulcano.resource(1) +class Mysql < Inspec.resource(1) name 'mysql' attr_reader :package, :service, :conf_dir, :conf_path, :data_dir, :log_dir, :log_path, :log_group, :log_dir_group def initialize # set OS-dependent filenames and paths - case vulcano.os[:family] + case inspec.os[:family] when 'ubuntu', 'debian' init_ubuntu when 'redhat', 'fedora' diff --git a/lib/resources/mysql_conf.rb b/lib/resources/mysql_conf.rb index 8072f3d24..35b4abf25 100644 --- a/lib/resources/mysql_conf.rb +++ b/lib/resources/mysql_conf.rb @@ -26,7 +26,7 @@ class MysqlConfEntry end end -class MysqlConf < Vulcano.resource(1) +class MysqlConf < Inspec.resource(1) name 'mysql_conf' include FindFiles @@ -62,11 +62,11 @@ class MysqlConf < Vulcano.resource(1) @params = {} # skip if the main configuration file doesn't exist - if !vulcano.file(@conf_path).file? + if !inspec.file(@conf_path).file? return skip_resource "Can't find file \"#{@conf_path}\"" end raw_conf = read_file(@conf_path) - if raw_conf.empty? && vulcano.file(@conf_path).size > 0 + if raw_conf.empty? && inspec.file(@conf_path).size > 0 return skip_resource("Can't read file \"#{@conf_path}\"") end @@ -107,7 +107,7 @@ class MysqlConf < Vulcano.resource(1) end def read_file(path) - @files_contents[path] ||= vulcano.file(path).content + @files_contents[path] ||= inspec.file(path).content end def to_s diff --git a/lib/resources/mysql_session.rb b/lib/resources/mysql_session.rb index 75eb9d3ff..d804ecbc3 100644 --- a/lib/resources/mysql_session.rb +++ b/lib/resources/mysql_session.rb @@ -4,7 +4,7 @@ # author: Christoph Hartmann # license: All rights reserved -class MysqlSession < Vulcano.resource(1) +class MysqlSession < Inspec.resource(1) name 'mysql_session' def initialize(user, pass) @@ -20,7 +20,7 @@ class MysqlSession < Vulcano.resource(1) escaped_query = q.gsub(/\\/, '\\\\').gsub(/"/, '\\"').gsub(/\$/, '\\$') # run the query - cmd = vulcano.command("mysql -u#{@user} -p#{@pass} #{db} -s -e \"#{escaped_query}\"") + cmd = inspec.command("mysql -u#{@user} -p#{@pass} #{db} -s -e \"#{escaped_query}\"") out = cmd.stdout + "\n" + cmd.stderr if out =~ /Can't connect to .* MySQL server/ or out.downcase =~ /^error/ @@ -40,7 +40,7 @@ class MysqlSession < Vulcano.resource(1) def init_fallback # support debian mysql administration login - debian = vulcano.command('test -f /etc/mysql/debian.cnf && cat /etc/mysql/debian.cnf').stdout + debian = inspec.command('test -f /etc/mysql/debian.cnf && cat /etc/mysql/debian.cnf').stdout return if debian.empty? user = debian.match(/^\s*user\s*=\s*([^ ]*)\s*$/) diff --git a/lib/resources/npm.rb b/lib/resources/npm.rb index 92184abd0..95d1c665f 100644 --- a/lib/resources/npm.rb +++ b/lib/resources/npm.rb @@ -6,7 +6,7 @@ # describe npm('bower') do # it { should be_installed } # end -class NpmPackage < Vulcano.resource(1) +class NpmPackage < Inspec.resource(1) name 'npm' def initialize(package_name) @@ -17,7 +17,7 @@ class NpmPackage < Vulcano.resource(1) def info return @info if defined?(@info) - cmd = vulcano.command("npm ls -g --json #{@package_name}") + cmd = inspec.command("npm ls -g --json #{@package_name}") @info = { name: @package_name, type: 'npm', diff --git a/lib/resources/ntp_conf.rb b/lib/resources/ntp_conf.rb index f2b7d137c..5752ca6ab 100644 --- a/lib/resources/ntp_conf.rb +++ b/lib/resources/ntp_conf.rb @@ -13,7 +13,7 @@ require 'utils/simpleconfig' # its('restrict') { should include '-4 default kod notrap nomodify nopeer noquery'} # end -class NtpConf < Vulcano.resource(1) +class NtpConf < Inspec.resource(1) name 'ntp_conf' def initialize(path = nil) @@ -36,13 +36,13 @@ class NtpConf < Vulcano.resource(1) def read_params return @params if defined?(@params) - if !vulcano.file(@conf_path).file? + if !inspec.file(@conf_path).file? skip_resource "Can't find file \"#{@conf_path}\"" return @params = {} end - content = vulcano.file(@conf_path).content - if content.empty? && vulcano.file(@conf_path).size > 0 + content = inspec.file(@conf_path).content + if content.empty? && inspec.file(@conf_path).size > 0 skip_resource "Can't read file \"#{@conf_path}\"" return @params = {} end diff --git a/lib/resources/oneget.rb b/lib/resources/oneget.rb index 3624c20a5..c8e56f0ad 100644 --- a/lib/resources/oneget.rb +++ b/lib/resources/oneget.rb @@ -9,14 +9,14 @@ # describe oneget('zoomit') do # it { should be_installed } # end -class OneGetPackage < Vulcano.resource(1) +class OneGetPackage < Inspec.resource(1) name 'oneget' def initialize(package_name) @package_name = package_name # verify that this resource is only supported on Windows - return skip_resource 'The `oneget` resource is not supported on your OS.' if vulcano.os[:family] != 'windows' + return skip_resource 'The `oneget` resource is not supported on your OS.' if inspec.os[:family] != 'windows' end def info @@ -26,7 +26,7 @@ class OneGetPackage < Vulcano.resource(1) @info[:type] = 'oneget' @info[:installed] = false - cmd = vulcano.command("Get-Package -Name '#{@package_name}' | ConvertTo-Json") + cmd = inspec.command("Get-Package -Name '#{@package_name}' | ConvertTo-Json") # cannot rely on exit code for now, successful command returns exit code 1 # return nil if cmd.exit_status != 0 # try to parse json diff --git a/lib/resources/os.rb b/lib/resources/os.rb index 5731db124..8f9a93a76 100644 --- a/lib/resources/os.rb +++ b/lib/resources/os.rb @@ -2,18 +2,18 @@ # author: Dominik Richter # author: Christoph Hartmann -class OS < Vulcano.resource(1) +class OS < Inspec.resource(1) name 'os' # reuse helper methods from backend %w{redhat? debian? suse? bsd? solaris? linux? unix? windows?}.each do |os_family| define_method((os_family).to_sym) do - vulcano.backend.os.send(os_family) + inspec.backend.os.send(os_family) end end def [](name) - vulcano.backend.os[name] + inspec.backend.os[name] end def to_s diff --git a/lib/resources/os_env.rb b/lib/resources/os_env.rb index b5e4814a7..5e3287392 100644 --- a/lib/resources/os_env.rb +++ b/lib/resources/os_env.rb @@ -11,13 +11,13 @@ # its(:split) { should_not include('.') } # end -class OsEnv < Vulcano.resource(1) +class OsEnv < Inspec.resource(1) name 'os_env' attr_reader :content def initialize(env) @osenv = env - @command_result = vulcano.command("su - root -c 'echo $#{env}'") + @command_result = inspec.command("su - root -c 'echo $#{env}'") @content = @command_result.stdout.chomp end diff --git a/lib/resources/package.rb b/lib/resources/package.rb index 4a17c589d..66a144c51 100644 --- a/lib/resources/package.rb +++ b/lib/resources/package.rb @@ -8,7 +8,7 @@ # describe package('nginx') do # it { should be_installed } # end -class Package < Vulcano.resource(1) +class Package < Inspec.resource(1) name 'package' def initialize(package_name = nil) @@ -18,17 +18,17 @@ class Package < Vulcano.resource(1) # select package manager @pkgman = nil - case vulcano.os[:family] + case inspec.os[:family] when 'ubuntu', 'debian' - @pkgman = Deb.new(vulcano) + @pkgman = Deb.new(inspec) when 'redhat', 'fedora', 'centos', 'opensuse' - @pkgman = Rpm.new(vulcano) + @pkgman = Rpm.new(inspec) when 'arch' - @pkgman = Pacman.new(vulcano) + @pkgman = Pacman.new(inspec) when 'darwin' - @pkgman = Brew.new(vulcano) + @pkgman = Brew.new(inspec) when 'windows' - @pkgman = WindowsPkg.new(vulcano) + @pkgman = WindowsPkg.new(inspec) else return skip_resource 'The `package` resource is not supported on your OS yet.' end @@ -60,15 +60,16 @@ class Package < Vulcano.resource(1) end class PkgManagement - def initialize(vulcano) - @vulcano = vulcano + attr_reader :inspec + def initialize(inspec) + @inspec = inspec end end # Debian / Ubuntu class Deb < PkgManagement def info(package_name) - cmd = @vulcano.command("dpkg -s #{package_name}") + cmd = inspec.command("dpkg -s #{package_name}") return nil if cmd.exit_status.to_i != 0 params = SimpleConfig.new( @@ -88,7 +89,7 @@ end # RHEL family class Rpm < PkgManagement def info(package_name) - cmd = @vulcano.command("rpm -qia #{package_name}") + cmd = inspec.command("rpm -qia #{package_name}") # CentOS does not return an error code if the package is not installed, # therefore we need to check for emptyness return nil if cmd.exit_status.to_i != 0 || cmd.stdout.chomp.empty? @@ -109,7 +110,7 @@ end # MacOS / Darwin implementation class Brew < PkgManagement def info(package_name) - cmd = @vulcano.command("brew info --json=v1 #{package_name}") + cmd = inspec.command("brew info --json=v1 #{package_name}") return nil if cmd.exit_status.to_i != 0 # parse data pkg = JSON.parse(cmd.stdout)[0] @@ -125,7 +126,7 @@ end # Arch Linux class Pacman < PkgManagement def info(package_name) - cmd = @vulcano.command("pacman -Qi #{package_name}") + cmd = inspec.command("pacman -Qi #{package_name}") return nil if cmd.exit_status.to_i != 0 params = SimpleConfig.new( @@ -150,7 +151,7 @@ end class WindowsPkg < PkgManagement def info(package_name) # Find the package - cmd = @vulcano.command("Get-WmiObject -Class Win32_Product | Where-Object {$_.Name -eq '#{package_name}'} | Select-Object -Property Name,Version,Vendor,PackageCode,Caption,Description | ConvertTo-Json") + cmd = inspec.command("Get-WmiObject -Class Win32_Product | Where-Object {$_.Name -eq '#{package_name}'} | Select-Object -Property Name,Version,Vendor,PackageCode,Caption,Description | ConvertTo-Json") begin package = JSON.parse(cmd.stdout) diff --git a/lib/resources/parse_config.rb b/lib/resources/parse_config.rb index d7eb00714..0781225cf 100644 --- a/lib/resources/parse_config.rb +++ b/lib/resources/parse_config.rb @@ -13,7 +13,7 @@ # } # describe parse_config(audit, options ) do -class PConfig < Vulcano.resource(1) +class PConfig < Inspec.resource(1) name 'parse_config' def initialize(content = nil, useropts = {}) @@ -35,11 +35,11 @@ class PConfig < Vulcano.resource(1) @conf_path = conf_path # read the file - if !vulcano.file(conf_path).file? + if !inspec.file(conf_path).file? return skip_resource "Can't find file \"#{conf_path}\"" end @content = read_file(conf_path) - if @content.empty? && vulcano.file(conf_path).size > 0 + if @content.empty? && inspec.file(conf_path).size > 0 return skip_resource "Can't read file \"#{conf_path}\"" end @@ -47,7 +47,7 @@ class PConfig < Vulcano.resource(1) end def read_file(path) - @files_contents[path] ||= vulcano.file(path).content + @files_contents[path] ||= inspec.file(path).content end def read_content diff --git a/lib/resources/passwd.rb b/lib/resources/passwd.rb index 3d26e756e..897b581d7 100644 --- a/lib/resources/passwd.rb +++ b/lib/resources/passwd.rb @@ -27,7 +27,7 @@ require 'utils/parser' -class Passwd < Vulcano.resource(1) +class Passwd < Inspec.resource(1) name 'passwd' include ContentParser @@ -37,7 +37,7 @@ class Passwd < Vulcano.resource(1) def initialize(path = nil) @path = path || '/etc/passwd' - @content = vulcano.file(@path).content + @content = inspec.file(@path).content @parsed = parse_passwd(@content) end diff --git a/lib/resources/pip.rb b/lib/resources/pip.rb index 127b000b7..842fde83e 100644 --- a/lib/resources/pip.rb +++ b/lib/resources/pip.rb @@ -7,7 +7,7 @@ # it { should be_installed } # end # -class PipPackage < Vulcano.resource(1) +class PipPackage < Inspec.resource(1) name 'pip' def initialize(package_name) @@ -19,7 +19,7 @@ class PipPackage < Vulcano.resource(1) @info = {} @info[:type] = 'pip' - cmd = vulcano.command("#{pip_cmd} show #{@package_name}") + cmd = inspec.command("#{pip_cmd} show #{@package_name}") return @info if cmd.exit_status != 0 params = SimpleConfig.new( @@ -50,11 +50,11 @@ class PipPackage < Vulcano.resource(1) def pip_cmd # Pip is not on the default path for Windows, therefore we do some logic # to find the binary on Windows - family = vulcano.os[:family] + family = inspec.os[:family] case family when 'windows' # we need to detect the pip command on Windows - cmd = vulcano.command('New-Object -Type PSObject | Add-Member -MemberType NoteProperty -Name Pip -Value (Invoke-Command -ScriptBlock {where.exe pip}) -PassThru | Add-Member -MemberType NoteProperty -Name Python -Value (Invoke-Command -ScriptBlock {where.exe python}) -PassThru | ConvertTo-Json') + cmd = inspec.command('New-Object -Type PSObject | Add-Member -MemberType NoteProperty -Name Pip -Value (Invoke-Command -ScriptBlock {where.exe pip}) -PassThru | Add-Member -MemberType NoteProperty -Name Python -Value (Invoke-Command -ScriptBlock {where.exe python}) -PassThru | ConvertTo-Json') begin paths = JSON.parse(cmd.stdout) # use pip if it on system path diff --git a/lib/resources/port.rb b/lib/resources/port.rb index 371af7fe5..4b7ec944d 100644 --- a/lib/resources/port.rb +++ b/lib/resources/port.rb @@ -15,7 +15,7 @@ # # TODO: currently we return local ip only # TODO: improve handling of same port on multiple interfaces -class Port < Vulcano.resource(1) +class Port < Inspec.resource(1) name 'port' def initialize(port) @@ -23,15 +23,15 @@ class Port < Vulcano.resource(1) @port_manager = nil @cache = nil - case vulcano.os[:family] + case inspec.os[:family] when 'ubuntu', 'debian', 'redhat', 'fedora', 'arch' - @port_manager = LinuxPorts.new(vulcano) + @port_manager = LinuxPorts.new(inspec) when 'darwin' - @port_manager = DarwinPorts.new(vulcano) + @port_manager = DarwinPorts.new(inspec) when 'windows' - @port_manager = WindowsPorts.new(vulcano) + @port_manager = WindowsPorts.new(inspec) when 'freebsd' - @port_manager = FreeBsdPorts.new(vulcano) + @port_manager = FreeBsdPorts.new(inspec) else return skip_resource 'The `port` resource is not supported on your OS yet.' end @@ -82,8 +82,9 @@ end # }], # }] class PortsInfo - def initialize(vulcano) - @vulcano = vulcano + attr_reader :inspec + def initialize(inspec) + @inspec = inspec end end @@ -95,7 +96,7 @@ end class WindowsPorts < PortsInfo def info # get all port information - cmd = @vulcano.command('Get-NetTCPConnection | Select-Object -Property State, Caption, Description, LocalAddress, LocalPort, RemoteAddress, RemotePort, DisplayName, Status | ConvertTo-Json') + cmd = inspec.command('Get-NetTCPConnection | Select-Object -Property State, Caption, Description, LocalAddress, LocalPort, RemoteAddress, RemotePort, DisplayName, Status | ConvertTo-Json') begin ports = JSON.parse(cmd.stdout) @@ -121,7 +122,7 @@ end class DarwinPorts < PortsInfo def info # collects UDP and TCP information - cmd = @vulcano.command('lsof -nP -iTCP -iUDP -sTCP:LISTEN') + cmd = inspec.command('lsof -nP -iTCP -iUDP -sTCP:LISTEN') return nil if cmd.exit_status.to_i != 0 ports = [] @@ -160,7 +161,7 @@ end # extract port information from netstat class LinuxPorts < PortsInfo def info - cmd = @vulcano.command('netstat -tulpen') + cmd = inspec.command('netstat -tulpen') return nil if cmd.exit_status.to_i != 0 ports = [] @@ -224,7 +225,7 @@ end # extracts information from sockstat class FreeBsdPorts < PortsInfo def info - cmd = @vulcano.command('sockstat -46l') + cmd = inspec.command('sockstat -46l') return nil if cmd.exit_status.to_i != 0 ports = [] diff --git a/lib/resources/postgres.rb b/lib/resources/postgres.rb index a66a30e88..c133360d0 100644 --- a/lib/resources/postgres.rb +++ b/lib/resources/postgres.rb @@ -4,16 +4,16 @@ # author: Christoph Hartmann # license: All rights reserved -class Postgres < Vulcano.resource(1) +class Postgres < Inspec.resource(1) name 'postgres' attr_reader :service, :data_dir, :conf_dir, :conf_path def initialize - case vulcano.os[:family] + case inspec.os[:family] when 'ubuntu', 'debian' @service = 'postgresql' @data_dir = '/var/lib/postgresql' - @version = vulcano.command('ls /etc/postgresql/').stdout.chomp + @version = inspec.command('ls /etc/postgresql/').stdout.chomp @conf_dir = "/etc/postgresql/#{@version}/main" @conf_path = File.join @conf_dir, 'postgresql.conf' diff --git a/lib/resources/postgres_conf.rb b/lib/resources/postgres_conf.rb index b08f58e37..ef3d709df 100644 --- a/lib/resources/postgres_conf.rb +++ b/lib/resources/postgres_conf.rb @@ -8,7 +8,7 @@ require 'utils/simpleconfig' require 'utils/find_files' require 'resources/postgres' -class PostgresConf < Vulcano.resource(1) +class PostgresConf < Inspec.resource(1) name 'postgres_conf' include FindFiles @@ -40,11 +40,11 @@ class PostgresConf < Vulcano.resource(1) @params = {} # skip if the main configuration file doesn't exist - if !vulcano.file(@conf_path).file? + if !inspec.file(@conf_path).file? return skip_resource "Can't find file \"#{@conf_path}\"" end raw_conf = read_file(@conf_path) - if raw_conf.empty? && vulcano.file(@conf_path).size > 0 + if raw_conf.empty? && inspec.file(@conf_path).size > 0 return skip_resource("Can't read file \"#{@conf_path}\"") end @@ -78,7 +78,7 @@ class PostgresConf < Vulcano.resource(1) end def read_file(path) - @files_contents[path] ||= vulcano.file(path).content + @files_contents[path] ||= inspec.file(path).content end def to_s diff --git a/lib/resources/postgres_session.rb b/lib/resources/postgres_session.rb index bbf38afd2..d573349d8 100644 --- a/lib/resources/postgres_session.rb +++ b/lib/resources/postgres_session.rb @@ -35,7 +35,7 @@ class PostgresSession # that does this securely escaped_query = query.gsub(/\\/, '\\\\').gsub(/"/, '\\"').gsub(/\$/, '\\$') # run the query - cmd = vulcano.command("PGPASSWORD='#{@pass}' psql -U #{@user} #{dbs} -c \"#{escaped_query}\"") + cmd = inspec.command("PGPASSWORD='#{@pass}' psql -U #{@user} #{dbs} -c \"#{escaped_query}\"") out = cmd.stdout + "\n" + cmd.stderr if out =~ /could not connect to .*/ or out.downcase =~ /^error/ diff --git a/lib/resources/processes.rb b/lib/resources/processes.rb index c88577d4f..0ce59bf9b 100644 --- a/lib/resources/processes.rb +++ b/lib/resources/processes.rb @@ -4,7 +4,7 @@ # author: Christoph Hartmann # license: All rights reserved -class Processes < Vulcano.resource(1) +class Processes < Inspec.resource(1) name 'processes' attr_reader :list @@ -29,7 +29,7 @@ class Processes < Vulcano.resource(1) def ps_aux # get all running processes - cmd = vulcano.command('ps aux') + cmd = inspec.command('ps aux') all = cmd.stdout.split("\n")[1..-1] lines = all.map do |line| diff --git a/lib/resources/registry_key.rb b/lib/resources/registry_key.rb index 91f31a677..a6c6e19ff 100644 --- a/lib/resources/registry_key.rb +++ b/lib/resources/registry_key.rb @@ -10,7 +10,7 @@ require 'json' # its('Start') { should eq 2 } # end -class RegistryKey < Vulcano.resource(1) +class RegistryKey < Inspec.resource(1) name 'registry_key' attr_accessor :reg_key @@ -24,7 +24,7 @@ class RegistryKey < Vulcano.resource(1) def registry_value(path, key) cmd = "(Get-Item 'Registry::#{path}').GetValue('#{key}')" - command_result ||= vulcano.command(cmd) + command_result ||= inspec.command(cmd) val = { exit_code: command_result.exit_status.to_i, data: command_result.stdout } val end diff --git a/lib/resources/script.rb b/lib/resources/script.rb index a452f94ab..cf690b5bd 100644 --- a/lib/resources/script.rb +++ b/lib/resources/script.rb @@ -9,7 +9,7 @@ class Script < Cmd attr_accessor :command def initialize(script) - case vulcano.os[:family] + case inspec.os[:family] when 'windows' # encodes a script as base64 to run as powershell encodedCommand # this comes with performance issues: @see https://gist.github.com/fnichol/7b20596b950e65fb96f9 diff --git a/lib/resources/security_policy.rb b/lib/resources/security_policy.rb index 338572e30..38199fe9e 100644 --- a/lib/resources/security_policy.rb +++ b/lib/resources/security_policy.rb @@ -13,7 +13,7 @@ # All local GPO parameters can be examined via Registry, but not all security # parameters. Therefore we need a combination of Registry and secedit output -class SecurityPolicy < Vulcano.resource(1) +class SecurityPolicy < Inspec.resource(1) name 'security_policy' def initialize @@ -25,11 +25,11 @@ class SecurityPolicy < Vulcano.resource(1) # load security content def load # export the security policy - vulcano.command('secedit /export /cfg win_secpol.cfg') + inspec.command('secedit /export /cfg win_secpol.cfg') # store file content - command_result ||= vulcano.command('type win_secpol.cfg') + command_result ||= inspec.command('type win_secpol.cfg') # delete temp file - vulcano.command('del win_secpol.cfg') + inspec.command('del win_secpol.cfg') @exit_status = command_result.exit_status.to_i @policy = command_result.stdout diff --git a/lib/resources/service.rb b/lib/resources/service.rb index 66aa62957..156fa1e05 100644 --- a/lib/resources/service.rb +++ b/lib/resources/service.rb @@ -19,7 +19,7 @@ # Ubuntu < 15.04 : upstart # # TODO: extend the logic to detect the running init system, independently of OS -class Service < Vulcano.resource(1) +class Service < Inspec.resource(1) name 'service' def initialize(service_name) @@ -30,7 +30,7 @@ class Service < Vulcano.resource(1) end def select_package_manager # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity - family = vulcano.os[:family] + family = inspec.os[:family] case family # Ubuntu @@ -42,34 +42,34 @@ class Service < Vulcano.resource(1) # Upstart runs with PID 1 as /sbin/init. # Systemd runs with PID 1 as /lib/systemd/systemd. when 'ubuntu' - version = vulcano.os[:release].to_f + version = inspec.os[:release].to_f if version < 15.04 - @service_mgmt = Upstart.new(vulcano) + @service_mgmt = Upstart.new(inspec) else - @service_mgmt = Systemd.new(vulcano) + @service_mgmt = Systemd.new(inspec) end when 'debian' - version = vulcano.os[:release].to_i + version = inspec.os[:release].to_i if version > 7 - @service_mgmt = Systemd.new(vulcano) + @service_mgmt = Systemd.new(inspec) else - @service_mgmt = SysV.new(vulcano) + @service_mgmt = SysV.new(inspec) end when 'redhat', 'fedora', 'centos' - version = vulcano.os[:release].to_i + version = inspec.os[:release].to_i if (%w{ redhat centos }.include?(family) && version >= 7) || (family == 'fedora' && version >= 15) - @service_mgmt = Systemd.new(vulcano) + @service_mgmt = Systemd.new(inspec) else - @service_mgmt = SysV.new(vulcano) + @service_mgmt = SysV.new(inspec) end when 'darwin' - @service_mgmt = LaunchCtl.new(vulcano) + @service_mgmt = LaunchCtl.new(inspec) when 'windows' - @service_mgmt = WindowsSrv.new(vulcano) + @service_mgmt = WindowsSrv.new(inspec) when 'freebsd' - @service_mgmt = BSDInit.new(vulcano) + @service_mgmt = BSDInit.new(inspec) when 'arch', 'opensuse' - @service_mgmt = Systemd.new(vulcano) + @service_mgmt = Systemd.new(inspec) end return skip_resource 'The `service` resource is not supported on your OS yet.' if @service_mgmt.nil? @@ -105,8 +105,9 @@ class Service < Vulcano.resource(1) end class ServiceManager - def initialize(vulcano) - @vulcano = vulcano + attr_reader :inspec + def initialize(inspec) + @inspec = inspec end end @@ -114,7 +115,7 @@ end # @see: http://www.freedesktop.org/software/systemd/man/systemd-system.conf.html class Systemd < ServiceManager def info(service_name) - cmd = @vulcano.command("systemctl show --all #{service_name}") + cmd = inspec.command("systemctl show --all #{service_name}") return nil if cmd.exit_status.to_i != 0 # parse data @@ -148,7 +149,7 @@ end class Upstart < ServiceManager def info(service_name) # get the status of upstart service - cmd = @vulcano.command("initctl status #{service_name}") + cmd = inspec.command("initctl status #{service_name}") return nil if cmd.exit_status != 0 # @see: http://upstart.ubuntu.com/cookbook/#job-states @@ -161,12 +162,17 @@ class Upstart < ServiceManager # $ initctl show-config $job | grep -q "^ start on" && echo enabled || echo disabled # Ubuntu 10.04 show-config is not supported # @see http://manpages.ubuntu.com/manpages/maverick/man8/initctl.8.html - config = @vulcano.command("initctl show-config #{service_name}") + config = inspec.command("initctl show-config #{service_name}") match_enabled = /^\s*start on/.match(config.stdout) !match_enabled.nil? ? (enabled = true) : (enabled = false) # implement fallback for Ubuntu 10.04 - enabled = true if @vulcano.os[:family] == 'ubuntu' && @vulcano.os[:release].to_f >= 10.04 && @vulcano.os[:release].to_f < 12.04 && cmd.exit_status == 0 + if inspec.os[:family] == 'ubuntu' && + inspec.os[:release].to_f >= 10.04 && + inspec.os[:release].to_f < 12.04 && + cmd.exit_status == 0 + enabled = true + end { name: service_name, @@ -183,7 +189,7 @@ class SysV < ServiceManager def info(service_name) # check if service is installed # read all available services via ls /etc/init.d/ - srvlist = @vulcano.command('ls -1 /etc/init.d/') + srvlist = inspec.command('ls -1 /etc/init.d/') return nil if srvlist.exit_status != 0 # check if the service is in list @@ -195,7 +201,7 @@ class SysV < ServiceManager # read all enabled services from runlevel # on rhel via: 'chkconfig --list', is not installed by default # bash: for i in `find /etc/rc*.d -name S*`; do basename $i | sed -r 's/^S[0-9]+//'; done | sort | uniq - enabled_services_cmd = @vulcano.command('find /etc/rc*.d -name S*') + enabled_services_cmd = inspec.command('find /etc/rc*.d -name S*') enabled_services = enabled_services_cmd.stdout.split("\n").select { |line| /(^.*#{service_name}.*)/.match(line) } @@ -207,10 +213,10 @@ class SysV < ServiceManager # on debian service is located /usr/sbin/service, on centos it is located here /sbin/service service_cmd = 'service' - service_cmd = '/usr/sbin/service' if @vulcano.os[:family] == 'debian' - service_cmd = '/sbin/service' if @vulcano.os[:family] == 'centos' + service_cmd = '/usr/sbin/service' if inspec.os[:family] == 'debian' + service_cmd = '/sbin/service' if inspec.os[:family] == 'centos' - cmd = @vulcano.command("#{service_cmd} #{service_name} status") + cmd = inspec.command("#{service_cmd} #{service_name} status") cmd.exit_status == 0 ? (running = true) : (running = false) { name: service_name, @@ -233,7 +239,7 @@ class BSDInit < ServiceManager # service SERVICE status returns the following result if not activated: # Cannot 'status' sshd. Set sshd_enable to YES in /etc/rc.conf or use 'onestatus' instead of 'status'. # gather all enabled services - cmd = @vulcano.command('service -e') + cmd = inspec.command('service -e') return nil if cmd.exit_status != 0 # search for the service @@ -243,7 +249,7 @@ class BSDInit < ServiceManager # check if the service is running # if the service is not available or not running, we always get an error code - cmd = @vulcano.command("service #{service_name} onestatus") + cmd = inspec.command("service #{service_name} onestatus") cmd.exit_status == 0 ? (running = true) : (running = false) { @@ -262,7 +268,7 @@ end class LaunchCtl < ServiceManager def info(service_name) # get the status of upstart service - cmd = @vulcano.command('launchctl list') + cmd = inspec.command('launchctl list') return nil if cmd.exit_status != 0 # search for the service @@ -324,7 +330,7 @@ class WindowsSrv < ServiceManager # - 6: Pause Pending # - 7: Paused def info(service_name) - cmd = @vulcano.command("New-Object -Type PSObject | Add-Member -MemberType NoteProperty -Name Service -Value (Get-Service -Name #{service_name}| Select-Object -Property Name, DisplayName, Status) -PassThru | Add-Member -MemberType NoteProperty -Name WMI -Value (Get-WmiObject -Class Win32_Service | Where-Object {$_.Name -eq '#{service_name}' -or $_.DisplayName -eq '#{service_name}'} | Select-Object -Property StartMode) -PassThru | ConvertTo-Json") + cmd = inspec.command("New-Object -Type PSObject | Add-Member -MemberType NoteProperty -Name Service -Value (Get-Service -Name #{service_name}| Select-Object -Property Name, DisplayName, Status) -PassThru | Add-Member -MemberType NoteProperty -Name WMI -Value (Get-WmiObject -Class Win32_Service | Where-Object {$_.Name -eq '#{service_name}' -or $_.DisplayName -eq '#{service_name}'} | Select-Object -Property StartMode) -PassThru | ConvertTo-Json") # cannot rely on exit code for now, successful command returns exit code 1 # return nil if cmd.exit_status != 0 diff --git a/lib/resources/ssh_conf.rb b/lib/resources/ssh_conf.rb index f350a54dc..c3d20c0b2 100644 --- a/lib/resources/ssh_conf.rb +++ b/lib/resources/ssh_conf.rb @@ -6,7 +6,7 @@ require 'utils/simpleconfig' -class SshConf < Vulcano.resource(1) +class SshConf < Inspec.resource(1) name 'ssh_config' def initialize(conf_path = nil, type = nil) @@ -41,7 +41,7 @@ class SshConf < Vulcano.resource(1) def read_content return @content if defined?(@content) - file = vulcano.file(@conf_path) + file = inspec.file(@conf_path) if !file.file? return skip_resource "Can't find file \"#{@conf_path}\"" end diff --git a/lib/resources/user.rb b/lib/resources/user.rb index f3b1a9fbb..4d5aea979 100644 --- a/lib/resources/user.rb +++ b/lib/resources/user.rb @@ -38,7 +38,7 @@ require 'utils/parser' require 'utils/convert' -class User < Vulcano.resource(1) +class User < Inspec.resource(1) name 'user' def initialize(user) @@ -46,15 +46,15 @@ class User < Vulcano.resource(1) # select package manager @user_provider = nil - case vulcano.os[:family] + case inspec.os[:family] when 'ubuntu', 'debian', 'redhat', 'fedora', 'centos', 'arch', 'opensuse' - @user_provider = LinuxUser.new(vulcano) + @user_provider = LinuxUser.new(inspec) when 'windows' - @user_provider = WindowsUser.new(vulcano) + @user_provider = WindowsUser.new(inspec) when 'darwin' - @user_provider = DarwinUser.new(vulcano) + @user_provider = DarwinUser.new(inspec) when 'freebsd' - @user_provider = FreeBSDUser.new(vulcano) + @user_provider = FreeBSDUser.new(inspec) else return skip_resource 'The `user` resource is not supported on your OS yet.' end @@ -166,8 +166,9 @@ end class UserInfo include Converter - def initialize(vulcano) - @vulcano = vulcano + attr_reader :inspec + def initialize(inspec) + @inspec = inspec end def credentials(_username) @@ -189,7 +190,7 @@ class UnixUser < UserInfo # extracts the identity def identity(username) - cmd = @vulcano.command("id #{username}") + cmd = inspec.command("id #{username}") return nil if cmd.exit_status != 0 # parse words @@ -215,7 +216,7 @@ class LinuxUser < UnixUser include ContentParser def meta_info(username) - cmd = @vulcano.command("getent passwd #{username}") + cmd = inspec.command("getent passwd #{username}") return nil if cmd.exit_status != 0 # returns: root:x:0:0:root:/root:/bin/bash passwd = parse_passwd_line(cmd.stdout.chomp) @@ -226,7 +227,7 @@ class LinuxUser < UnixUser end def credentials(username) - cmd = @vulcano.command("chage -l #{username}") + cmd = inspec.command("chage -l #{username}") return nil if cmd.exit_status != 0 params = SimpleConfig.new( @@ -251,7 +252,7 @@ end # @see http://superuser.com/questions/592921/mac-osx-users-vs-dscl-command-to-list-user class DarwinUser < UnixUser def meta_info(username) - cmd = @vulcano.command("dscl -q . -read /Users/#{username} NFSHomeDirectory PrimaryGroupID RecordName UniqueID UserShell") + cmd = inspec.command("dscl -q . -read /Users/#{username} NFSHomeDirectory PrimaryGroupID RecordName UniqueID UserShell") return nil if cmd.exit_status != 0 params = SimpleConfig.new( @@ -280,7 +281,7 @@ class FreeBSDUser < UnixUser include ContentParser def meta_info(username) - cmd = @vulcano.command("pw usershow #{username} -7") + cmd = inspec.command("pw usershow #{username} -7") return nil if cmd.exit_status != 0 # returns: root:*:0:0:Charlie &:/root:/bin/csh passwd = parse_passwd_line(cmd.stdout.chomp) @@ -338,7 +339,7 @@ class WindowsUser < UserInfo ConvertTo-Json EOH - cmd = @vulcano.script(script) + cmd = inspec.script(script) # cannot rely on exit code for now, successful command returns exit code 1 # return nil if cmd.exit_status != 0, try to parse json diff --git a/lib/resources/windows_feature.rb b/lib/resources/windows_feature.rb index 93201ca99..9d0d970b4 100644 --- a/lib/resources/windows_feature.rb +++ b/lib/resources/windows_feature.rb @@ -27,7 +27,7 @@ # "Installed": false, # "InstallState": 0 # } -class WindowsFeature < Vulcano.resource(1) +class WindowsFeature < Inspec.resource(1) name 'windows_feature' def initialize(feature) @@ -35,7 +35,7 @@ class WindowsFeature < Vulcano.resource(1) @cache = nil # verify that this resource is only supported on Windows - return skip_resource 'The `windows_feature` resource is not supported on your OS.' if vulcano.os[:family] != 'windows' + return skip_resource 'The `windows_feature` resource is not supported on your OS.' if inspec.os[:family] != 'windows' end # returns true if the package is installed @@ -47,7 +47,7 @@ class WindowsFeature < Vulcano.resource(1) def info return @cache if !@cache.nil? features_cmd = "Get-WindowsFeature | Where-Object {$_.Name -eq '#{@feature}' -or $_.DisplayName -eq '#{@feature}'} | Select-Object -Property Name,DisplayName,Description,Installed,InstallState | ConvertTo-Json" - cmd = vulcano.command(features_cmd) + cmd = inspec.command(features_cmd) @cache = { name: @feature, diff --git a/lib/resources/yum.rb b/lib/resources/yum.rb index 5544efdba..3bc6d3a56 100644 --- a/lib/resources/yum.rb +++ b/lib/resources/yum.rb @@ -30,7 +30,7 @@ require 'resources/file' # it { should be_enabled } # end -class Yum < Vulcano.resource(1) +class Yum < Inspec.resource(1) name 'yum' # returns all repositories @@ -43,7 +43,7 @@ class Yum < Vulcano.resource(1) return @cache if defined?(@cache) # parse the repository data from yum # we cannot use -C, because this is not reliable and may lead to errors - @command_result = vulcano.command('yum -v repolist all') + @command_result = inspec.command('yum -v repolist all') @content = @command_result.stdout @cache = [] repo = {} diff --git a/lib/utils/find_files.rb b/lib/utils/find_files.rb index b84c141cc..4bbffe8d2 100644 --- a/lib/utils/find_files.rb +++ b/lib/utils/find_files.rb @@ -24,7 +24,7 @@ module FindFiles cmd += " -maxdepth #{depth.to_i}" if depth.to_i > 0 cmd += " -type #{type}" unless type.nil? - result = vulcano.run_command(cmd) + result = inspec.run_command(cmd) exit_status = result.exit_status return [nil, exit_status] unless exit_status == 0 diff --git a/lib/vulcano/targets.rb b/lib/vulcano/targets.rb deleted file mode 100644 index 79d25a786..000000000 --- a/lib/vulcano/targets.rb +++ /dev/null @@ -1,9 +0,0 @@ -# encoding: utf-8 -# author: Dominik Richter -# author: Christoph Hartmann - -require 'vulcano/targets/core' -require 'vulcano/targets/file' -require 'vulcano/targets/folder' -require 'vulcano/targets/url' -require 'vulcano/targets/dir' diff --git a/test/docker_test.rb b/test/docker_test.rb index d1c2acfa6..2be181b68 100644 --- a/test/docker_test.rb +++ b/test/docker_test.rb @@ -2,7 +2,7 @@ # author: Dominik Richter require_relative 'docker_run' -require_relative '../lib/vulcano' +require_relative '../lib/inspec' tests = ARGV if tests.empty? @@ -41,7 +41,7 @@ class DockerTester def test_container(container, report) puts "--> run test on docker #{container.id}" opts = { 'target' => "docker://#{container.id}" } - runner = Vulcano::Runner.new(opts) + runner = Inspec::Runner.new(opts) runner.add_tests(@tests) tests = runner.tests.ordered_example_groups tests.map { |g| g.run(report) } diff --git a/test/helper.rb b/test/helper.rb index ec4b4b5f2..dee9463a5 100644 --- a/test/helper.rb +++ b/test/helper.rb @@ -10,11 +10,11 @@ SimpleCov.start do add_filter '/test/' add_group 'Resources', 'lib/resources' add_group 'Matchers', 'lib/matchers' - add_group 'Backends', 'lib/vulcano/backend' + add_group 'Backends', 'lib/inspec/backend' end -require 'vulcano/resource' -require 'vulcano/backend' +require 'inspec/resource' +require 'inspec/backend' class MockLoader # pass the os identifier to emulate a specific operating system @@ -47,7 +47,7 @@ class MockLoader scriptpath = ::File.realpath(::File.dirname(__FILE__)) # create mock backend - @backend = Vulcano::Backend.create({ backend: :mock }) + @backend = Inspec::Backend.create({ backend: :mock }) mock = @backend.backend # set os emulation @@ -188,7 +188,7 @@ class MockLoader # loads a resource class and instantiates the class with the given arguments def load_resource(resource, *args) # initialize resource with backend and parameters - @resource_class = Vulcano::Resource.registry[resource] + @resource_class = Inspec::Resource.registry[resource] @resource = @resource_class.new(backend, resource, *args) end end diff --git a/test/unit/profile_context_test.rb b/test/unit/profile_context_test.rb index a22c2e8de..c062e87b0 100644 --- a/test/unit/profile_context_test.rb +++ b/test/unit/profile_context_test.rb @@ -3,11 +3,11 @@ # author: Christoph Hartmann require 'helper' -require 'vulcano/profile_context' +require 'inspec/profile_context' -describe Vulcano::ProfileContext do +describe Inspec::ProfileContext do let(:backend) { MockLoader.new.backend } - let(:profile) { Vulcano::ProfileContext.new(nil, backend) } + let(:profile) { Inspec::ProfileContext.new(nil, backend) } it 'must be able to load empty content' do profile.load('', 'dummy', 1).must_be_nil @@ -34,7 +34,7 @@ describe Vulcano::ProfileContext do load('describe true do; it { should_eq true }; end') .must_output '' profile.rules.keys.must_equal ['unknown:1'] - profile.rules.values[0].must_be_kind_of Vulcano::Rule + profile.rules.values[0].must_be_kind_of Inspec::Rule end it 'does not provide the expect keyword in the global DLS' do @@ -44,7 +44,7 @@ describe Vulcano::ProfileContext do it 'provides the rule keyword in the global DSL' do profile.load('rule 1') profile.rules.keys.must_equal [1] - profile.rules.values[0].must_be_kind_of Vulcano::Rule + profile.rules.values[0].must_be_kind_of Inspec::Rule end end @@ -105,7 +105,7 @@ describe Vulcano::ProfileContext do end it 'registers the check with the provided proc' do - check[2].must_be_kind_of Vulcano::ExpectationTarget + check[2].must_be_kind_of Inspec::ExpectationTarget end end diff --git a/test/unit/resources/apt_test.rb b/test/unit/resources/apt_test.rb index 8fa32de40..a741bcc4e 100644 --- a/test/unit/resources/apt_test.rb +++ b/test/unit/resources/apt_test.rb @@ -3,9 +3,9 @@ # author: Dominik Richter require 'helper' -require 'vulcano/resource' +require 'inspec/resource' -describe 'Vulcano::Resources::AptRepo' do +describe 'Inspec::Resources::AptRepo' do it 'check apt on ubuntu' do resource = MockLoader.new(:ubuntu1504).load_resource('apt', 'http://archive.ubuntu.com/ubuntu/') diff --git a/test/unit/resources/audit_policy_test.rb b/test/unit/resources/audit_policy_test.rb index 3c4c73e50..ccacf217b 100644 --- a/test/unit/resources/audit_policy_test.rb +++ b/test/unit/resources/audit_policy_test.rb @@ -3,9 +3,9 @@ # author: Dominik Richter require 'helper' -require 'vulcano/resource' +require 'inspec/resource' -describe 'Vulcano::Resources::AuditPolicy' do +describe 'Inspec::Resources::AuditPolicy' do it 'check audit policy parsing' do resource = MockLoader.new(:windows).load_resource('audit_policy') _(resource.send('User Account Management')).must_equal 'Success' diff --git a/test/unit/resources/auditd_conf_test.rb b/test/unit/resources/auditd_conf_test.rb index bc6440387..1674ed9cd 100644 --- a/test/unit/resources/auditd_conf_test.rb +++ b/test/unit/resources/auditd_conf_test.rb @@ -3,9 +3,9 @@ # author: Dominik Richter require 'helper' -require 'vulcano/resource' +require 'inspec/resource' -describe 'Vulcano::Resources::AuditDaemonConf' do +describe 'Inspec::Resources::AuditDaemonConf' do it 'check audit daemon config parsing' do resource = MockLoader.new(:windows).load_resource('auditd_conf') _(resource.space_left_action).must_equal 'SYSLOG' diff --git a/test/unit/resources/auditd_rules_test.rb b/test/unit/resources/auditd_rules_test.rb index 44e605b23..5c2cb91e8 100644 --- a/test/unit/resources/auditd_rules_test.rb +++ b/test/unit/resources/auditd_rules_test.rb @@ -3,9 +3,9 @@ # author: Dominik Richter require 'helper' -require 'vulcano/resource' +require 'inspec/resource' -describe 'Vulcano::Resources::AuditDaemonRules' do +describe 'Inspec::Resources::AuditDaemonRules' do it 'check audit policy parsing' do resource = MockLoader.new(:windows).load_resource('auditd_rules') _(resource.send('LIST_RULES')).must_equal [ diff --git a/test/unit/resources/bond_test.rb b/test/unit/resources/bond_test.rb index 0bcfa7c21..43aed3b47 100644 --- a/test/unit/resources/bond_test.rb +++ b/test/unit/resources/bond_test.rb @@ -3,9 +3,9 @@ # author: Dominik Richter require 'helper' -require 'vulcano/resource' +require 'inspec/resource' -describe 'Vulcano::Resources::Bond' do +describe 'Inspec::Resources::Bond' do it 'check linux bond on ubuntu' do resource = MockLoader.new(:ubuntu1404).load_resource('bond', 'bond0') diff --git a/test/unit/resources/bridge_test.rb b/test/unit/resources/bridge_test.rb index 201169ef8..b5cfb358f 100644 --- a/test/unit/resources/bridge_test.rb +++ b/test/unit/resources/bridge_test.rb @@ -3,9 +3,9 @@ # author: Dominik Richter require 'helper' -require 'vulcano/resource' +require 'inspec/resource' -describe 'Vulcano::Resources::Bridge' do +describe 'Inspec::Resources::Bridge' do it 'check linux bridge on ubuntu' do resource = MockLoader.new(:ubuntu1404).load_resource('bridge', 'br0') diff --git a/test/unit/resources/csv_test.rb b/test/unit/resources/csv_test.rb index f14a9f9cb..773ed56d0 100644 --- a/test/unit/resources/csv_test.rb +++ b/test/unit/resources/csv_test.rb @@ -3,9 +3,9 @@ # author: Dominik Richter require 'helper' -require 'vulcano/resource' +require 'inspec/resource' -describe 'Vulcano::Resources::CSV' do +describe 'Inspec::Resources::CSV' do it 'verify csv parsing' do resource = load_resource('csv', 'example.csv') _(resource.params).wont_equal nil diff --git a/test/unit/resources/etc_group_test.rb b/test/unit/resources/etc_group_test.rb index 4cee2bad0..7b83ff108 100644 --- a/test/unit/resources/etc_group_test.rb +++ b/test/unit/resources/etc_group_test.rb @@ -3,9 +3,9 @@ # author: Dominik Richter require 'helper' -require 'vulcano/resource' +require 'inspec/resource' -describe 'Vulcano::Resources::EtcGroup' do +describe 'Inspec::Resources::EtcGroup' do let(:resource) { load_resource('etc_group') } it 'verify /etc/group config parsing' do diff --git a/test/unit/resources/gem_test.rb b/test/unit/resources/gem_test.rb index 8276845b2..cfa2df61b 100644 --- a/test/unit/resources/gem_test.rb +++ b/test/unit/resources/gem_test.rb @@ -3,9 +3,9 @@ # author: Dominik Richter require 'helper' -require 'vulcano/resource' +require 'inspec/resource' -describe 'Vulcano::Resources::Gem' do +describe 'Inspec::Resources::Gem' do it 'verify gem package detail parsing' do resource = load_resource('gem', 'rubocop') pkg = { diff --git a/test/unit/resources/group_test.rb b/test/unit/resources/group_test.rb index 80952cf09..a09799eff 100644 --- a/test/unit/resources/group_test.rb +++ b/test/unit/resources/group_test.rb @@ -3,9 +3,9 @@ # author: Dominik Richter require 'helper' -require 'vulcano/resource' +require 'inspec/resource' -describe 'Vulcano::Resources::Group' do +describe 'Inspec::Resources::Group' do # ubuntu 14.04 it 'verify group on ubuntu' do diff --git a/test/unit/resources/host_test.rb b/test/unit/resources/host_test.rb index 3fd806270..b5b303d6c 100644 --- a/test/unit/resources/host_test.rb +++ b/test/unit/resources/host_test.rb @@ -3,9 +3,9 @@ # author: Dominik Richter require 'helper' -require 'vulcano/resource' +require 'inspec/resource' -describe 'Vulcano::Resources::Host' do +describe 'Inspec::Resources::Host' do it 'check host on ubuntu' do resource = MockLoader.new(:ubuntu1404).load_resource('host', 'example.com') diff --git a/test/unit/resources/inetd_conf_test.rb b/test/unit/resources/inetd_conf_test.rb index d4f11179c..b6f04fbb0 100644 --- a/test/unit/resources/inetd_conf_test.rb +++ b/test/unit/resources/inetd_conf_test.rb @@ -3,9 +3,9 @@ # author: Dominik Richter require 'helper' -require 'vulcano/resource' +require 'inspec/resource' -describe 'Vulcano::Resources::InetdConf' do +describe 'Inspec::Resources::InetdConf' do it 'verify limits.conf config parsing' do resource = load_resource('inetd_config') _(resource.send('shell')).must_equal nil diff --git a/test/unit/resources/interface_test.rb b/test/unit/resources/interface_test.rb index 8aad816c5..baa788f73 100644 --- a/test/unit/resources/interface_test.rb +++ b/test/unit/resources/interface_test.rb @@ -3,9 +3,9 @@ # author: Dominik Richter require 'helper' -require 'vulcano/resource' +require 'inspec/resource' -describe 'Vulcano::Resources::Interface' do +describe 'Inspec::Resources::Interface' do # ubuntu 14.04 it 'verify interface on ubuntu' do diff --git a/test/unit/resources/iptables_test.rb b/test/unit/resources/iptables_test.rb index 35ebf1f5c..64bb8bf54 100644 --- a/test/unit/resources/iptables_test.rb +++ b/test/unit/resources/iptables_test.rb @@ -3,9 +3,9 @@ # author: Dominik Richter require 'helper' -require 'vulcano/resource' +require 'inspec/resource' -describe 'Vulcano::Resources::Iptables' do +describe 'Inspec::Resources::Iptables' do # ubuntu 14.04 it 'verify iptables on ubuntu' do diff --git a/test/unit/resources/json_test.rb b/test/unit/resources/json_test.rb index 3b57766f8..e9d8a83d3 100644 --- a/test/unit/resources/json_test.rb +++ b/test/unit/resources/json_test.rb @@ -3,9 +3,9 @@ # author: Dominik Richter require 'helper' -require 'vulcano/resource' +require 'inspec/resource' -describe 'Vulcano::Resources::JSON' do +describe 'Inspec::Resources::JSON' do it 'verify json parsing' do resource = load_resource('json', 'policyfile.lock.json') _(resource.params).wont_equal nil diff --git a/test/unit/resources/kernel_module_test.rb b/test/unit/resources/kernel_module_test.rb index 9f4bd5c9e..c7dc10e29 100644 --- a/test/unit/resources/kernel_module_test.rb +++ b/test/unit/resources/kernel_module_test.rb @@ -3,9 +3,9 @@ # author: Dominik Richter require 'helper' -require 'vulcano/resource' +require 'inspec/resource' -describe 'Vulcano::Resources::KernelModule' do +describe 'Inspec::Resources::KernelModule' do it 'verify kernel_module parsing' do resource = load_resource('kernel_module', 'bridge') _(resource.loaded?).must_equal true diff --git a/test/unit/resources/kernel_parameter_test.rb b/test/unit/resources/kernel_parameter_test.rb index 5defe0f7f..c170b1132 100644 --- a/test/unit/resources/kernel_parameter_test.rb +++ b/test/unit/resources/kernel_parameter_test.rb @@ -3,9 +3,9 @@ # author: Dominik Richter require 'helper' -require 'vulcano/resource' +require 'inspec/resource' -describe 'Vulcano::Resources::KernelParameter' do +describe 'Inspec::Resources::KernelParameter' do it 'verify kernel_parameter parsing' do resource = load_resource('kernel_parameter', 'net.ipv4.conf.all.forwarding') _(resource.value).must_equal 1 diff --git a/test/unit/resources/limits_conf_test.rb b/test/unit/resources/limits_conf_test.rb index 34a217fb8..3c9fa21fb 100644 --- a/test/unit/resources/limits_conf_test.rb +++ b/test/unit/resources/limits_conf_test.rb @@ -3,9 +3,9 @@ # author: Dominik Richter require 'helper' -require 'vulcano/resource' +require 'inspec/resource' -describe 'Vulcano::Resources::LimitsConf' do +describe 'Inspec::Resources::LimitsConf' do it 'verify limits.conf config parsing' do resource = load_resource('limits_conf') _(resource.send('*')).must_equal [['soft', 'core', '0'], ['hard', 'rss', '10000']] diff --git a/test/unit/resources/login_def_test.rb b/test/unit/resources/login_def_test.rb index 19711f24c..a305e619c 100644 --- a/test/unit/resources/login_def_test.rb +++ b/test/unit/resources/login_def_test.rb @@ -3,9 +3,9 @@ # author: Dominik Richter require 'helper' -require 'vulcano/resource' +require 'inspec/resource' -describe 'Vulcano::Resources::LoginDef' do +describe 'Inspec::Resources::LoginDef' do it 'verify login.def config parsing' do resource = load_resource('login_defs') _(resource.UMASK).must_equal '022' diff --git a/test/unit/resources/mysql_conf_test.rb b/test/unit/resources/mysql_conf_test.rb index 8b3db3990..7c767f0ef 100644 --- a/test/unit/resources/mysql_conf_test.rb +++ b/test/unit/resources/mysql_conf_test.rb @@ -4,7 +4,7 @@ require 'helper' -describe 'Vulcano::Resources::MysqlConf' do +describe 'Inspec::Resources::MysqlConf' do it 'verify mysql.conf config parsing' do resource = load_resource('mysql_conf', '/etc/mysql/my.cnf') _(resource.client['port']).must_equal '3306' diff --git a/test/unit/resources/npm_test.rb b/test/unit/resources/npm_test.rb index fce81bffa..ef058ee3c 100644 --- a/test/unit/resources/npm_test.rb +++ b/test/unit/resources/npm_test.rb @@ -3,9 +3,9 @@ # author: Dominik Richter require 'helper' -require 'vulcano/resource' +require 'inspec/resource' -describe 'Vulcano::Resources::Npm' do +describe 'Inspec::Resources::Npm' do it 'verify npm package detail parsing' do resource = load_resource('npm', 'bower') pkg = { diff --git a/test/unit/resources/ntp_conf_test.rb b/test/unit/resources/ntp_conf_test.rb index 811f1a4da..3c6292cb1 100644 --- a/test/unit/resources/ntp_conf_test.rb +++ b/test/unit/resources/ntp_conf_test.rb @@ -3,9 +3,9 @@ # author: Dominik Richter require 'helper' -require 'vulcano/resource' +require 'inspec/resource' -describe 'Vulcano::Resources::NtpConf' do +describe 'Inspec::Resources::NtpConf' do it 'verify ntp config parsing' do resource = load_resource('ntp_conf') _(resource.driftfile).must_equal '/var/lib/ntp/ntp.drift' diff --git a/test/unit/resources/oneget_test.rb b/test/unit/resources/oneget_test.rb index bc30bf93d..c9489fd44 100644 --- a/test/unit/resources/oneget_test.rb +++ b/test/unit/resources/oneget_test.rb @@ -3,9 +3,9 @@ # author: Dominik Richter require 'helper' -require 'vulcano/resource' +require 'inspec/resource' -describe 'Vulcano::Resources::OneGet' do +describe 'Inspec::Resources::OneGet' do it 'verify oneget package detail parsing' do resource = MockLoader.new(:windows).load_resource('oneget', 'Mozilla Firefox') diff --git a/test/unit/resources/os_env_test.rb b/test/unit/resources/os_env_test.rb index 3d4ee254c..9be01ea86 100644 --- a/test/unit/resources/os_env_test.rb +++ b/test/unit/resources/os_env_test.rb @@ -3,9 +3,9 @@ # author: Dominik Richter require 'helper' -require 'vulcano/resource' +require 'inspec/resource' -describe 'Vulcano::Resources::OsEnv' do +describe 'Inspec::Resources::OsEnv' do it 'verify ntp config parsing' do resource = load_resource('os_env', 'PATH') _(resource.split).must_equal %w{/usr/local/sbin /usr/local/bin /usr/sbin /usr/bin /sbin /bin} diff --git a/test/unit/resources/package_test.rb b/test/unit/resources/package_test.rb index dd443245c..a00759be1 100644 --- a/test/unit/resources/package_test.rb +++ b/test/unit/resources/package_test.rb @@ -3,9 +3,9 @@ # author: Dominik Richter require 'helper' -require 'vulcano/resource' +require 'inspec/resource' -describe 'Vulcano::Resources::Package' do +describe 'Inspec::Resources::Package' do # arch linux it 'verify arch linux package parsing' do resource = MockLoader.new(:arch).load_resource('package', 'curl') diff --git a/test/unit/resources/passwd_test.rb b/test/unit/resources/passwd_test.rb index 5a397c211..0823dcf24 100644 --- a/test/unit/resources/passwd_test.rb +++ b/test/unit/resources/passwd_test.rb @@ -3,9 +3,9 @@ # author: Dominik Richter require 'helper' -require 'vulcano/resource' +require 'inspec/resource' -describe 'Vulcano::Resources::Passwd' do +describe 'Inspec::Resources::Passwd' do it 'verify passwd parsing' do resource = load_resource('passwd') _(resource.usernames).must_equal %w{root www-data} diff --git a/test/unit/resources/pip_test.rb b/test/unit/resources/pip_test.rb index 247f9b345..c806035ec 100644 --- a/test/unit/resources/pip_test.rb +++ b/test/unit/resources/pip_test.rb @@ -3,9 +3,9 @@ # author: Dominik Richter require 'helper' -require 'vulcano/resource' +require 'inspec/resource' -describe 'Vulcano::Resources::Pip' do +describe 'Inspec::Resources::Pip' do it 'verify pip package detail parsing' do resource = load_resource('pip', 'jinja2') pkg = {:name=>'Jinja2', :installed=>true, :version=>'2.8', :type=>'pip'} diff --git a/test/unit/resources/port_test.rb b/test/unit/resources/port_test.rb index 538d393d8..3ee743ed4 100644 --- a/test/unit/resources/port_test.rb +++ b/test/unit/resources/port_test.rb @@ -3,9 +3,9 @@ # author: Dominik Richter require 'helper' -require 'vulcano/resource' +require 'inspec/resource' -describe 'Vulcano::Resources::Port' do +describe 'Inspec::Resources::Port' do it 'verify port on Ubuntu 14.04' do resource = MockLoader.new(:ubuntu1404).load_resource('port', 22) _(resource.listening?).must_equal true diff --git a/test/unit/resources/processes_test.rb b/test/unit/resources/processes_test.rb index 0ff71b987..2a3fe2af0 100644 --- a/test/unit/resources/processes_test.rb +++ b/test/unit/resources/processes_test.rb @@ -3,9 +3,9 @@ # author: Dominik Richter require 'helper' -require 'vulcano/resource' +require 'inspec/resource' -describe 'Vulcano::Resources::Processes' do +describe 'Inspec::Resources::Processes' do it 'verify processes resource' do resource = load_resource('processes', '/bin/bash') _(resource.list).must_equal [{ diff --git a/test/unit/resources/registry_key_test.rb b/test/unit/resources/registry_key_test.rb index 03e038d8c..1e441efbe 100644 --- a/test/unit/resources/registry_key_test.rb +++ b/test/unit/resources/registry_key_test.rb @@ -3,9 +3,9 @@ # author: Dominik Richter require 'helper' -require 'vulcano/resource' +require 'inspec/resource' -describe 'Vulcano::Resources::RegistryKey' do +describe 'Inspec::Resources::RegistryKey' do let(:resource) { load_resource('registry_key', 'Task Scheduler', 'HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\Schedule') } let(:resource_without_name) { load_resource('registry_key', 'HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\Schedule') } diff --git a/test/unit/resources/script_test.rb b/test/unit/resources/script_test.rb index f72c8f058..63fed8e94 100644 --- a/test/unit/resources/script_test.rb +++ b/test/unit/resources/script_test.rb @@ -3,9 +3,9 @@ # author: Dominik Richter require 'helper' -require 'vulcano/resource' +require 'inspec/resource' -describe 'Vulcano::Resources::Script' do +describe 'Inspec::Resources::Script' do ps1_script = <<-EOH # call help for get command diff --git a/test/unit/resources/security_policy_test.rb b/test/unit/resources/security_policy_test.rb index 96e8c12d6..6d9806db1 100644 --- a/test/unit/resources/security_policy_test.rb +++ b/test/unit/resources/security_policy_test.rb @@ -3,9 +3,9 @@ # author: Dominik Richter require 'helper' -require 'vulcano/resource' +require 'inspec/resource' -describe 'Vulcano::Resources::SecurityPolicy' do +describe 'Inspec::Resources::SecurityPolicy' do it 'verify processes resource' do resource = load_resource('security_policy') _(resource.MaximumPasswordAge).must_equal 42 diff --git a/test/unit/resources/service_test.rb b/test/unit/resources/service_test.rb index 44e2068c4..aec3b7e59 100644 --- a/test/unit/resources/service_test.rb +++ b/test/unit/resources/service_test.rb @@ -3,9 +3,9 @@ # author: Dominik Richter require 'helper' -require 'vulcano/resource' +require 'inspec/resource' -describe 'Vulcano::Resources::Service' do +describe 'Inspec::Resources::Service' do # windows it 'verify service parsing' do diff --git a/test/unit/resources/ssh_conf_test.rb b/test/unit/resources/ssh_conf_test.rb index ecf89262c..b3dee8034 100644 --- a/test/unit/resources/ssh_conf_test.rb +++ b/test/unit/resources/ssh_conf_test.rb @@ -3,9 +3,9 @@ # author: Dominik Richter require 'helper' -require 'vulcano/resource' +require 'inspec/resource' -describe 'Vulcano::Resources::SshConf' do +describe 'Inspec::Resources::SshConf' do describe 'ssh_config' do it 'check ssh config parsing' do diff --git a/test/unit/resources/user_test.rb b/test/unit/resources/user_test.rb index f37f33907..d78a1b1ae 100644 --- a/test/unit/resources/user_test.rb +++ b/test/unit/resources/user_test.rb @@ -3,9 +3,9 @@ # author: Dominik Richter require 'helper' -require 'vulcano/resource' +require 'inspec/resource' -describe 'Vulcano::Resources::User' do +describe 'Inspec::Resources::User' do # ubuntu 14.04 with upstart it 'read user on ubuntu' do diff --git a/test/unit/resources/windows_feature.rb b/test/unit/resources/windows_feature.rb index d880616d0..eeca0dfc8 100644 --- a/test/unit/resources/windows_feature.rb +++ b/test/unit/resources/windows_feature.rb @@ -3,9 +3,9 @@ # author: Dominik Richter require 'helper' -require 'vulcano/resource' +require 'inspec/resource' -describe 'Vulcano:Resources::Feature' do +describe 'Inspec::Resources::Feature' do describe 'feature' do it 'verify windows feature parsing' do resource = MockLoader.new(:windows).load_resource('windows_feature', 'dhcp') diff --git a/test/unit/resources/yaml_test.rb b/test/unit/resources/yaml_test.rb index 7a6859329..5c7f4bd65 100644 --- a/test/unit/resources/yaml_test.rb +++ b/test/unit/resources/yaml_test.rb @@ -1,9 +1,9 @@ # encoding: utf-8 require 'helper' -require 'vulcano/resource' +require 'inspec/resource' -describe 'Vulcano::Resources::YAML' do +describe 'Inspec::Resources::YAML' do it 'verify yaml parsing' do resource = load_resource('yaml', 'kitchen.yml') _(resource.params).wont_be_nil diff --git a/test/unit/resources/yum_test.rb b/test/unit/resources/yum_test.rb index d36989c88..f4bdf41a1 100644 --- a/test/unit/resources/yum_test.rb +++ b/test/unit/resources/yum_test.rb @@ -3,9 +3,9 @@ # author: Dominik Richter require 'helper' -require 'vulcano/resource' +require 'inspec/resource' -describe 'Vulcano::Resources::YumRepo' do +describe 'Inspec::Resources::YumRepo' do it 'get repository details' do resource = MockLoader.new(:centos7).load_resource('yum') _(resource.repositories).must_equal [{