feature: helper method to check if a default command exists

Signed-off-by: Dominik Richter <dominik@vulcanosec.com>
This commit is contained in:
Dominik Richter 2015-06-21 18:19:04 +02:00
parent 5d5b945933
commit cb3e067a1f
2 changed files with 12 additions and 0 deletions

11
lib/resources/command.rb Normal file
View file

@ -0,0 +1,11 @@
# Copyright (c) 2015 Vulcano Security GmbH. All rights reserved.
module Serverspec::Type
class Command < Base
# Check if a given command (executable) exists
# in the default path
def exists?
cmd = @name
Command.new("type \"#{cmd}\" > /dev/null").exit_status == 0
end
end
end

View file

@ -13,6 +13,7 @@ require 'vulcano/rule'
require 'vulcano/rspec_json_formatter'
require 'resources/audit_policy'
require 'resources/command'
require 'resources/file'
require 'resources/group_policy'
require 'resources/mysql_conf'