Hello community, here is the log from the commit of package rubygem-hiera-eyaml for openSUSE:Factory checked in at 2016-09-21 18:46:44 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/rubygem-hiera-eyaml (Old) and /work/SRC/openSUSE:Factory/.rubygem-hiera-eyaml.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "rubygem-hiera-eyaml" Changes: -------- --- /work/SRC/openSUSE:Factory/rubygem-hiera-eyaml/rubygem-hiera-eyaml.changes 2015-06-01 09:51:07.000000000 +0200 +++ /work/SRC/openSUSE:Factory/.rubygem-hiera-eyaml.new/rubygem-hiera-eyaml.changes 2016-09-21 18:46:46.000000000 +0200 @@ -1,0 +2,9 @@ +Sat Jul 30 08:30:34 UTC 2016 - tampak...@opensuse.org + +- Version bump 2.1.0: + - (#187) - Change the way third party highline library is imported to avoid + memory leak when running under puppet server (@petems) + - (#181) - Improve test suite to run against a variety of puppet versions + (@peculater) + +------------------------------------------------------------------- Old: ---- hiera-eyaml-2.0.8.gem New: ---- hiera-eyaml-2.1.0.gem ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ rubygem-hiera-eyaml.spec ++++++ --- /var/tmp/diff_new_pack.2vJMbe/_old 2016-09-21 18:46:47.000000000 +0200 +++ /var/tmp/diff_new_pack.2vJMbe/_new 2016-09-21 18:46:47.000000000 +0200 @@ -1,7 +1,7 @@ # # spec file for package rubygem-hiera-eyaml # -# Copyright (c) 2015 SUSE LINUX Products GmbH, Nuernberg, Germany. +# Copyright (c) 2016 SUSE LINUX GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -16,7 +16,7 @@ # Name: rubygem-hiera-eyaml -Version: 2.0.8 +Version: 2.1.0 Release: 0 %define mod_name hiera-eyaml %define mod_full_name %{mod_name}-%{version} ++++++ hiera-eyaml-2.0.8.gem -> hiera-eyaml-2.1.0.gem ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/.travis.yml new/.travis.yml --- old/.travis.yml 1970-01-01 01:00:00.000000000 +0100 +++ new/.travis.yml 2016-03-02 22:47:59.000000000 +0100 @@ -1,14 +1,30 @@ language: ruby rvm: - "1.8.7-p374" - - "1.9.2" - "1.9.3" - "2.0.0" - "2.1.5" -before_install: - - sudo apt-get update - - sudo apt-get install expect + - "2.2.3" +env: + - PUPPET_VERSION=3.7.5 + - PUPPET_VERSION=3.8.4 + - PUPPET_VERSION=4.2.2 +sudo: false +addons: + apt: + packages: + - expect script: bundle exec cucumber -f progress notifications: email: false + +matrix: + exclude: + - rvm: 1.8.7-p374 + env: PUPPET_VERSION=4.2.2 + - rvm: 2.2.3 + env: PUPPET_VERSION=3.7.5 + - rvm: 2.2.3 + env: PUPPET_VERSION=3.8.4 + diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Gemfile new/Gemfile --- old/Gemfile 1970-01-01 01:00:00.000000000 +0100 +++ new/Gemfile 2016-03-02 22:47:59.000000000 +0100 @@ -1,14 +1,13 @@ source 'https://rubygems.org/' -gem 'highline', '~> 1.6.19' -gem 'trollop', '~> 2.0' +gemspec group :development do gem "aruba", '~> 0.6.2' gem "cucumber", '~> 1.1' gem "rspec-expectations", '~> 3.1.0' gem "hiera-eyaml-plaintext" - gem "puppet" + gem "puppet", ENV['PUPPET_VERSION'] || '~> 3.8' end group :test do diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/README.md new/README.md --- old/README.md 1970-01-01 01:00:00.000000000 +0100 +++ new/README.md 2016-03-02 22:47:59.000000000 +0100 @@ -281,6 +281,7 @@ - [hiera-eyaml-twofac](https://github.com/gtmtechltd/hiera-eyaml-twofac) - PKCS7 keypair + AES256 symmetric password for two-factor encryption Note that this plugin mandates the user enter a password. It is useful for non-automated scenarios, and is not advised to be used in conjunction with puppet, as it requires entry of a password over a terminal. + - [hiera-eyaml-kms](https://github.com/adenot/hiera-eyaml-kms) - Encryption using AWS Key Management Service (KMS) Notes diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/bin/eyaml new/bin/eyaml --- old/bin/eyaml 1970-01-01 01:00:00.000000000 +0100 +++ new/bin/eyaml 2016-03-02 22:47:59.000000000 +0100 @@ -12,15 +12,15 @@ begin Hiera::Backend::Eyaml::CLI.parse rescue StandardError => e - Hiera::Backend::Eyaml::Utils.warn e.message - Hiera::Backend::Eyaml::Utils.debug e.backtrace.join("\n") + Hiera::Backend::Eyaml::LoggingHelper.warn e.message + Hiera::Backend::Eyaml::LoggingHelper.debug e.backtrace.join("\n") exit 1 end begin Hiera::Backend::Eyaml::CLI.execute rescue StandardError => e - Hiera::Backend::Eyaml::Utils.warn e.message - Hiera::Backend::Eyaml::Utils.debug e.backtrace.join("\n") + Hiera::Backend::Eyaml::LoggingHelper.warn e.message + Hiera::Backend::Eyaml::LoggingHelper.debug e.backtrace.join("\n") exit 1 end Files old/checksums.yaml.gz and new/checksums.yaml.gz differ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/hiera/backend/eyaml/CLI.rb new/lib/hiera/backend/eyaml/CLI.rb --- old/lib/hiera/backend/eyaml/CLI.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/lib/hiera/backend/eyaml/CLI.rb 2016-03-02 22:47:59.000000000 +0100 @@ -1,5 +1,6 @@ require 'trollop' require 'hiera/backend/eyaml' +require 'hiera/backend/eyaml/logginghelper' require 'hiera/backend/eyaml/utils' require 'hiera/backend/eyaml/plugins' require 'hiera/backend/eyaml/options' @@ -45,8 +46,8 @@ result = executor.execute puts result unless result.nil? rescue Exception => e - Utils.warn e.message - Utils.debug e.backtrace.join("\n") + LoggingHelper.warn e.message + LoggingHelper.debug e.backtrace.join("\n") end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/hiera/backend/eyaml/edithelper.rb new/lib/hiera/backend/eyaml/edithelper.rb --- old/lib/hiera/backend/eyaml/edithelper.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/lib/hiera/backend/eyaml/edithelper.rb 2016-03-02 22:47:59.000000000 +0100 @@ -0,0 +1,72 @@ +require 'hiera/backend/eyaml/logginghelper' + +class Hiera + module Backend + module Eyaml + class EditHelper + + def self.find_editor + editor = ENV['EDITOR'] + editor ||= %w{ /usr/bin/sensible-editor /usr/bin/editor /usr/bin/vim /usr/bin/vi }.collect {|e| e if FileTest.executable? e}.compact.first + raise StandardError, "Editor not found. Please set your EDITOR env variable" if editor.nil? + if editor.index(' ') + editor = editor.dup if editor.frozen? # values from ENV are frozen + editor.gsub!(/([^\\]|^)~/, '\1' + ENV['HOME']) # replace ~ with home unless escaped + editor.gsub!(/(^|[^\\])"/, '\1') # remove unescaped quotes during processing + editor.gsub!(/\\ /, ' ') # unescape spaces since we quote paths + pieces = editor.split(' ') + paths = pieces.each_with_index.map {|_,x| pieces[0..x].join(' ')}.reverse # get possible paths, starting with longest + extensions = (ENV['PATHEXT'] || '').split(';') # handle Windows executables + pathdirs = ENV['PATH'].split(File::PATH_SEPARATOR) + paths += pathdirs.collect { |dir| paths.collect { |path| File.expand_path(path, dir) } }.flatten + editorfile = paths.select { |path| + FileTest.file?(path) || ! extensions.select {|ext| FileTest.file?(path + ext) }.empty? + }.first + raise StandardError, "Editor not found. Please set your EDITOR env variable" if editorfile.nil? + raw_command = paths[(paths.index editorfile) % pieces.size] + editor = "\"#{editorfile}\"#{editor[raw_command.size()..-1]}" + end + editor + end + + def self.secure_file_delete args + file = File.open(args[:file], 'r+') + num_bytes = args[:num_bytes] + [0xff, 0x55, 0xaa, 0x00].each do |byte| + file.seek(0, IO::SEEK_SET) + num_bytes.times { file.print(byte.chr) } + file.fsync + end + file.close + File.delete args[:file] + end + + def self.write_tempfile data_to_write + file = Tempfile.open(['eyaml_edit', '.yaml']) + path = file.path + file.close! + + file = File.open(path, "w") + file.chmod(0600) + if ENV['OS'] == 'Windows_NT' + # Windows doesn't support chmod + icacls = 'C:\Windows\system32\icacls.exe' + if File.executable? icacls + current_user = `C:\\Windows\\system32\\whoami.exe`.chomp + # Use ACLs to restrict access to the current user only + command = %Q{#{icacls} "#{file.path}" /grant:r "#{current_user}":f /inheritance:r} + system "#{command} >NUL 2>&1" + end + end + file.puts data_to_write + file.close + + LoggingHelper::debug "Wrote temporary file: #{path}" + + path + end + + end + end + end +end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/hiera/backend/eyaml/encrypthelper.rb new/lib/hiera/backend/eyaml/encrypthelper.rb --- old/lib/hiera/backend/eyaml/encrypthelper.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/lib/hiera/backend/eyaml/encrypthelper.rb 2016-03-02 22:47:59.000000000 +0100 @@ -0,0 +1,40 @@ +require 'tempfile' +require 'fileutils' + +class Hiera + module Backend + module Eyaml + class EncryptHelper + + def self.write_important_file args + require 'hiera/backend/eyaml/highlinehelper' + filename = args[ :filename ] + content = args[ :content ] + mode = args[ :mode ] + if File.file? "#{filename}" + raise StandardError, "User aborted" unless HighlineHelper::confirm? "Are you sure you want to overwrite \"#{filename}\"?" + end + open( "#{filename}", "w" ) do |io| + io.write(content) + end + File.chmod( mode, filename ) unless mode.nil? + end + + def self.ensure_key_dir_exists key_file + key_dir = File.dirname key_file + + unless File.directory? key_dir + begin + FileUtils.mkdir_p key_dir + LoggingHelper::info "Created key directory: #{key_dir}" + rescue + raise StandardError, "Cannot create key directory: #{key_dir}" + end + end + + end + + end + end + end +end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/hiera/backend/eyaml/encryptor.rb new/lib/hiera/backend/eyaml/encryptor.rb --- old/lib/hiera/backend/eyaml/encryptor.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/lib/hiera/backend/eyaml/encryptor.rb 2016-03-02 22:47:59.000000000 +0100 @@ -1,5 +1,5 @@ require 'base64' -require 'hiera/backend/eyaml/utils' +require 'hiera/backend/eyaml/encrypthelper' class Hiera module Backend @@ -60,19 +60,19 @@ end def self.trace msg - Utils::trace :from => plugin_classname, :msg => msg + LoggingHelper::trace :from => plugin_classname, :msg => msg end def self.debug msg - Utils::debug :from => plugin_classname, :msg => msg + LoggingHelper::debug :from => plugin_classname, :msg => msg end def self.info msg - Utils::info :from => plugin_classname, :msg => msg + LoggingHelper::info :from => plugin_classname, :msg => msg end def self.warn msg - Utils::warn :from => plugin_classname, :msg => msg + LoggingHelper::warn :from => plugin_classname, :msg => msg end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/hiera/backend/eyaml/encryptors/pkcs7.rb new/lib/hiera/backend/eyaml/encryptors/pkcs7.rb --- old/lib/hiera/backend/eyaml/encryptors/pkcs7.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/lib/hiera/backend/eyaml/encryptors/pkcs7.rb 2016-03-02 22:47:59.000000000 +0100 @@ -1,6 +1,7 @@ require 'openssl' require 'hiera/backend/eyaml/encryptor' -require 'hiera/backend/eyaml/utils' +require 'hiera/backend/eyaml/encrypthelper' +require 'hiera/backend/eyaml/logginghelper' require 'hiera/backend/eyaml/options' class Hiera @@ -65,8 +66,8 @@ subject = self.option :subject key = OpenSSL::PKey::RSA.new(2048) - Utils.ensure_key_dir_exists private_key - Utils.write_important_file :filename => private_key, :content => key.to_pem, :mode => 0600 + EncryptHelper.ensure_key_dir_exists private_key + EncryptHelper.write_important_file :filename => private_key, :content => key.to_pem, :mode => 0600 cert = OpenSSL::X509::Certificate.new() cert.subject = OpenSSL::X509::Name.parse(subject) @@ -92,9 +93,9 @@ cert.sign key, OpenSSL::Digest::SHA1.new - Utils.ensure_key_dir_exists public_key - Utils.write_important_file :filename => public_key, :content => cert.to_pem - Utils.info "Keys created OK" + EncryptHelper.ensure_key_dir_exists public_key + EncryptHelper.write_important_file :filename => public_key, :content => cert.to_pem + LoggingHelper.info "Keys created OK" end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/hiera/backend/eyaml/highlinehelper.rb new/lib/hiera/backend/eyaml/highlinehelper.rb --- old/lib/hiera/backend/eyaml/highlinehelper.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/lib/hiera/backend/eyaml/highlinehelper.rb 2016-03-02 22:47:59.000000000 +0100 @@ -0,0 +1,24 @@ +require 'highline/import' + +class Hiera + module Backend + module Eyaml + class HighlineHelper + + def self.read_password + ask("Enter password: ") {|q| q.echo = "*" } + end + + def self.confirm? message + result = ask("#{message} (y/N): ") + if result.downcase == "y" or result.downcase == "yes" + true + else + false + end + end + + end + end + end +end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/hiera/backend/eyaml/logginghelper.rb new/lib/hiera/backend/eyaml/logginghelper.rb --- old/lib/hiera/backend/eyaml/logginghelper.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/lib/hiera/backend/eyaml/logginghelper.rb 2016-03-02 22:47:59.000000000 +0100 @@ -0,0 +1,80 @@ +require 'tempfile' +require 'fileutils' + +class Hiera + module Backend + module Eyaml + class LoggingHelper + + def self.structure_message messageinfo + message = {:from => "hiera-eyaml-core"} + case messageinfo.class.to_s + when 'Hash' + message.merge!(messageinfo) + else + message.merge!({:msg => messageinfo.to_s}) + end + message[:prefix] = "[#{message[:from]}]" + message[:spacer] = " #{' ' * message[:from].length} " + formatted_output = message[:msg].split("\n").each_with_index.map do |line, index| + if index == 0 + "#{message[:prefix]} #{line}" + else + "#{message[:spacer]} #{line}" + end + end + formatted_output.join "\n" + end + + def self.warn messageinfo + self.print_message({ :message => self.structure_message( messageinfo ), :hiera_loglevel => :warn, :cli_color => :red }) + end + + def self.info messageinfo + self.print_message({ :message => self.structure_message( messageinfo ), :hiera_loglevel => :debug, :cli_color => :white, :threshold => 0 }) + end + + def self.debug messageinfo + self.print_message({ :message => self.structure_message( messageinfo ), :hiera_loglevel => :debug, :cli_color => :green, :threshold => 1 }) + end + + def self.trace messageinfo + self.print_message({ :message => self.structure_message( messageinfo ), :hiera_loglevel => :debug, :cli_color => :blue, :threshold => 2 }) + end + + def self.print_message( args ) + message = args[:message] ||= "" + hiera_loglevel = args[:hiera_loglevel] ||= :debug + cli_color = args[:cli_color] ||= :blue + threshold = args[:threshold] + + if self.hiera? + Hiera.send(hiera_loglevel, message) if threshold.nil? or Eyaml.verbosity_level > threshold + else + STDERR.puts self.colorize( message, cli_color ) if threshold.nil? or Eyaml.verbosity_level > threshold + end + end + + def self.colorize message, color + suffix = "\e[0m" + prefix = case color + when :red + "\e[31m" + when :green + "\e[32m" + when :blue + "\e[34m" + else #:white + "\e[0m" + end + "#{prefix}#{message}#{suffix}" + end + + def self.hiera? + "hiera".eql? Eyaml::Options[:source] + end + + end + end + end +end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/hiera/backend/eyaml/options.rb new/lib/hiera/backend/eyaml/options.rb --- old/lib/hiera/backend/eyaml/options.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/lib/hiera/backend/eyaml/options.rb 2016-03-02 22:47:59.000000000 +0100 @@ -21,16 +21,16 @@ end def self.trace - Utils::trace "Dump of eyaml tool options dict:" - Utils::trace "--------------------------------" + LoggingHelper::trace "Dump of eyaml tool options dict:" + LoggingHelper::trace "--------------------------------" @@options.each do |k, v| begin - Utils::trace sprintf "%18s %-18s = %18s %-18s", "(#{k.class.name})", k.to_s, "(#{v.class.name})", v.to_s + LoggingHelper::trace sprintf "%18s %-18s = %18s %-18s", "(#{k.class.name})", k.to_s, "(#{v.class.name})", v.to_s rescue - Utils::trace sprintf "%18s %-18s = %18s %-18s", "(#{k.class.name})", k.to_s, "(#{v.class.name})", "<unprintable>" # case where v is binary + LoggingHelper::trace sprintf "%18s %-18s = %18s %-18s", "(#{k.class.name})", k.to_s, "(#{v.class.name})", "<unprintable>" # case where v is binary end end - Utils::trace "--------------------------------" + LoggingHelper::trace "--------------------------------" end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/hiera/backend/eyaml/subcommand.rb new/lib/hiera/backend/eyaml/subcommand.rb --- old/lib/hiera/backend/eyaml/subcommand.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/lib/hiera/backend/eyaml/subcommand.rb 2016-03-02 22:47:59.000000000 +0100 @@ -38,7 +38,7 @@ [ "/etc/eyaml/config.yaml", "#{ENV['HOME']}/.eyaml/config.yaml", "#{ENV['EYAML_CONFIG']}" ].each do |config_file| begin yaml_contents = YAML.load_file(config_file) - Utils::info "Loaded config from #{config_file}" + LoggingHelper::info "Loaded config from #{config_file}" config.merge! yaml_contents rescue raise StandardError, "Could not open config file \"#{config_file}\" for reading" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/hiera/backend/eyaml/subcommands/edit.rb new/lib/hiera/backend/eyaml/subcommands/edit.rb --- old/lib/hiera/backend/eyaml/subcommands/edit.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/lib/hiera/backend/eyaml/subcommands/edit.rb 2016-03-02 22:47:59.000000000 +0100 @@ -1,8 +1,8 @@ -require 'hiera/backend/eyaml/utils' +require 'hiera/backend/eyaml/edithelper' +require 'hiera/backend/eyaml/highlinehelper' require 'hiera/backend/eyaml/options' require 'hiera/backend/eyaml/parser/parser' require 'hiera/backend/eyaml/subcommand' -require 'highline/import' class Hiera module Backend @@ -61,14 +61,14 @@ raise StandardError, "Could not open file for reading: #{options[:eyaml]}" end else - Utils.info "#{options[:eyaml]} doesn't exist, editing new file" + LoggingHelper.info "#{options[:eyaml]} doesn't exist, editing new file" options[:input_data] = "---" end options end def self.execute - editor = Utils.find_editor + editor = EditHelper.find_editor encrypted_parser = Parser::ParserFactory.encrypted_parser tokens = encrypted_parser.parse Eyaml::Options[:input_data] @@ -76,7 +76,7 @@ decrypted_file_content = Eyaml::Options[:no_preamble] ? decrypted_input : (self.preamble + decrypted_input) begin - decrypted_file = Utils.write_tempfile decrypted_file_content unless decrypted_file + decrypted_file = EditHelper.write_tempfile decrypted_file_content unless decrypted_file system "#{editor} \"#{decrypted_file}\"" status = $? @@ -90,7 +90,7 @@ raise StandardError, "Edited file is blank" if edited_file.empty? if edited_file == decrypted_input - Utils.info "No changes detected, exiting" + LoggingHelper.info "No changes detected, exiting" else decrypted_parser = Parser::ParserFactory.decrypted_parser edited_tokens = decrypted_parser.parse(edited_file) @@ -123,14 +123,14 @@ } end rescue RecoverableError => e - Utils.info e + LoggingHelper.info e if agree "Return to the editor to try again?" retry else raise e end ensure - Utils.secure_file_delete :file => decrypted_file, :num_bytes => [edited_file.length, decrypted_input.length].max + EditHelper.secure_file_delete :file => decrypted_file, :num_bytes => [edited_file.length, decrypted_input.length].max end nil diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/hiera/backend/eyaml/subcommands/encrypt.rb new/lib/hiera/backend/eyaml/subcommands/encrypt.rb --- old/lib/hiera/backend/eyaml/subcommands/encrypt.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/lib/hiera/backend/eyaml/subcommands/encrypt.rb 2016-03-02 22:47:59.000000000 +0100 @@ -53,7 +53,8 @@ options[:input_data] = case options[:source] when :password - Utils.read_password + require 'hiera/backend/eyaml/highlinehelper' + HighlineHelper.read_password when :string options[:string] when :file diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/hiera/backend/eyaml/subcommands/version.rb new/lib/hiera/backend/eyaml/subcommands/version.rb --- old/lib/hiera/backend/eyaml/subcommands/version.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/lib/hiera/backend/eyaml/subcommands/version.rb 2016-03-02 22:47:59.000000000 +0100 @@ -19,7 +19,7 @@ def self.execute plugin_versions = {} - Eyaml::Utils.info "hiera-eyaml (core): #{Eyaml::VERSION}" + Eyaml::LoggingHelper.info "hiera-eyaml (core): #{Eyaml::VERSION}" Plugins.plugins.each do |plugin| plugin_shortname = plugin.name.split("hiera-eyaml-").last @@ -28,7 +28,7 @@ rescue "unknown (is plugin compatible with eyaml 2.0+ ?)" end - Eyaml::Utils.info "hiera-eyaml-#{plugin_shortname} (gem): #{plugin_version}" + Eyaml::LoggingHelper.info "hiera-eyaml-#{plugin_shortname} (gem): #{plugin_version}" end nil diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/hiera/backend/eyaml/utils.rb new/lib/hiera/backend/eyaml/utils.rb --- old/lib/hiera/backend/eyaml/utils.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/lib/hiera/backend/eyaml/utils.rb 2016-03-02 22:47:59.000000000 +0100 @@ -1,25 +1,12 @@ -require 'highline/import' require 'tempfile' require 'fileutils' +require 'hiera/backend/eyaml/logginghelper' class Hiera module Backend module Eyaml class Utils - def self.read_password - ask("Enter password: ") {|q| q.echo = "*" } - end - - def self.confirm? message - result = ask("#{message} (y/N): ") - if result.downcase == "y" or result.downcase == "yes" - true - else - false - end - end - def self.camelcase string return string if string !~ /_/ && string =~ /[A-Z]+.*/ string.split('_').map{|e| e.capitalize}.join @@ -30,94 +17,6 @@ string.split(/(?=[A-Z])/).collect {|x| x.downcase}.join("_") end - def self.find_editor - editor = ENV['EDITOR'] - editor ||= %w{ /usr/bin/sensible-editor /usr/bin/editor /usr/bin/vim /usr/bin/vi }.collect {|e| e if FileTest.executable? e}.compact.first - raise StandardError, "Editor not found. Please set your EDITOR env variable" if editor.nil? - if editor.index(' ') - editor = editor.dup if editor.frozen? # values from ENV are frozen - editor.gsub!(/([^\\]|^)~/, '\1' + ENV['HOME']) # replace ~ with home unless escaped - editor.gsub!(/(^|[^\\])"/, '\1') # remove unescaped quotes during processing - editor.gsub!(/\\ /, ' ') # unescape spaces since we quote paths - pieces = editor.split(' ') - paths = pieces.each_with_index.map {|_,x| pieces[0..x].join(' ')}.reverse # get possible paths, starting with longest - extensions = (ENV['PATHEXT'] || '').split(';') # handle Windows executables - pathdirs = ENV['PATH'].split(File::PATH_SEPARATOR) - paths += pathdirs.collect { |dir| paths.collect { |path| File.expand_path(path, dir) } }.flatten - editorfile = paths.select { |path| - FileTest.file?(path) || ! extensions.select {|ext| FileTest.file?(path + ext) }.empty? - }.first - raise StandardError, "Editor not found. Please set your EDITOR env variable" if editorfile.nil? - raw_command = paths[(paths.index editorfile) % pieces.size] - editor = "\"#{editorfile}\"#{editor[raw_command.size()..-1]}" - end - editor - end - - def self.secure_file_delete args - file = File.open(args[:file], 'r+') - num_bytes = args[:num_bytes] - [0xff, 0x55, 0xaa, 0x00].each do |byte| - file.seek(0, IO::SEEK_SET) - num_bytes.times { file.print(byte.chr) } - file.fsync - end - file.close - File.delete args[:file] - end - - def self.write_tempfile data_to_write - file = Tempfile.open(['eyaml_edit', '.yaml']) - path = file.path - file.close! - - file = File.open(path, "w") - file.chmod(0600) - if ENV['OS'] == 'Windows_NT' - # Windows doesn't support chmod - icacls = 'C:\Windows\system32\icacls.exe' - if File.executable? icacls - current_user = `C:\\Windows\\system32\\whoami.exe`.chomp - # Use ACLs to restrict access to the current user only - command = %Q{#{icacls} "#{file.path}" /grant:r "#{current_user}":f /inheritance:r} - system "#{command} >NUL 2>&1" - end - end - file.puts data_to_write - file.close - - Utils::debug "Wrote temporary file: #{path}" - - path - end - - def self.write_important_file args - filename = args[ :filename ] - content = args[ :content ] - mode = args[ :mode ] - if File.file? "#{filename}" - raise StandardError, "User aborted" unless Utils::confirm? "Are you sure you want to overwrite \"#{filename}\"?" - end - open( "#{filename}", "w" ) do |io| - io.write(content) - end - File.chmod( mode, filename ) unless mode.nil? - end - - def self.ensure_key_dir_exists key_file - key_dir = File.dirname key_file - - unless File.directory? key_dir - begin - FileUtils.mkdir_p key_dir - Utils::info "Created key directory: #{key_dir}" - rescue - raise StandardError, "Cannot create key directory: #{key_dir}" - end - end - - end - def self.find_closest_class args parent_class = args[ :parent_class ] class_name = args[ :class_name ] @@ -138,7 +37,7 @@ root_folder = File.dirname(__FILE__) + "/" + Array.new(num_class_hierarchy_levels).fill("..").join("/") class_folder = root_folder + "/" + classdir Dir[File.expand_path("#{class_folder}/*.rb")].uniq.each do |file| - self.trace "Requiring file: #{file}" + LoggingHelper.trace "Requiring file: #{file}" require file end end @@ -157,70 +56,6 @@ "hiera".eql? Eyaml::Options[:source] end - def self.structure_message messageinfo - message = {:from => "hiera-eyaml-core"} - case messageinfo.class.to_s - when 'Hash' - message.merge!(messageinfo) - else - message.merge!({:msg => messageinfo.to_s}) - end - message[:prefix] = "[#{message[:from]}]" - message[:spacer] = " #{' ' * message[:from].length} " - formatted_output = message[:msg].split("\n").each_with_index.map do |line, index| - if index == 0 - "#{message[:prefix]} #{line}" - else - "#{message[:spacer]} #{line}" - end - end - formatted_output.join "\n" - end - - def self.warn messageinfo - self.print_message({ :message => self.structure_message( messageinfo ), :hiera_loglevel => :warn, :cli_color => :red }) - end - - def self.info messageinfo - self.print_message({ :message => self.structure_message( messageinfo ), :hiera_loglevel => :debug, :cli_color => :white, :threshold => 0 }) - end - - def self.debug messageinfo - self.print_message({ :message => self.structure_message( messageinfo ), :hiera_loglevel => :debug, :cli_color => :green, :threshold => 1 }) - end - - def self.trace messageinfo - self.print_message({ :message => self.structure_message( messageinfo ), :hiera_loglevel => :debug, :cli_color => :blue, :threshold => 2 }) - end - - def self.print_message( args ) - message = args[:message] ||= "" - hiera_loglevel = args[:hiera_loglevel] ||= :debug - cli_color = args[:cli_color] ||= :blue - threshold = args[:threshold] - - if self.hiera? - Hiera.send(hiera_loglevel, message) if threshold.nil? or Eyaml.verbosity_level > threshold - else - STDERR.puts self.colorize( message, cli_color ) if threshold.nil? or Eyaml.verbosity_level > threshold - end - end - - def self.colorize message, color - suffix = "\e[0m" - prefix = case color - when :red - "\e[31m" - when :green - "\e[32m" - when :blue - "\e[34m" - else #:white - "\e[0m" - end - "#{prefix}#{message}#{suffix}" - end - end end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/hiera/backend/eyaml.rb new/lib/hiera/backend/eyaml.rb --- old/lib/hiera/backend/eyaml.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/lib/hiera/backend/eyaml.rb 2016-03-02 22:47:59.000000000 +0100 @@ -2,7 +2,7 @@ module Backend module Eyaml - VERSION = "2.0.8" + VERSION = "2.1.0" DESCRIPTION = "Hiera-eyaml is a backend for Hiera which provides OpenSSL encryption/decryption for Hiera properties" class RecoverableError < StandardError diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/metadata new/metadata --- old/metadata 1970-01-01 01:00:00.000000000 +0100 +++ new/metadata 2016-03-02 22:47:59.000000000 +0100 @@ -1,47 +1,52 @@ ---- !ruby/object:Gem::Specification +--- !ruby/object:Gem::Specification name: hiera-eyaml -version: !ruby/object:Gem::Version - version: 2.0.8 +version: !ruby/object:Gem::Version + version: 2.1.0 platform: ruby -authors: +authors: - Tom Poulton autorequire: bindir: bin cert_chain: [] - -date: 2015-04-15 00:00:00 Z -dependencies: -- !ruby/object:Gem::Dependency +date: 2016-03-02 00:00:00.000000000 Z +dependencies: +- !ruby/object:Gem::Dependency name: trollop - prerelease: false - requirement: &id001 !ruby/object:Gem::Requirement - requirements: - - - ~> - - !ruby/object:Gem::Version - version: "2.0" + requirement: !ruby/object:Gem::Requirement + requirements: + - - "~>" + - !ruby/object:Gem::Version + version: '2.0' type: :runtime - version_requirements: *id001 -- !ruby/object:Gem::Dependency - name: highline prerelease: false - requirement: &id002 !ruby/object:Gem::Requirement - requirements: - - - ~> - - !ruby/object:Gem::Version + version_requirements: !ruby/object:Gem::Requirement + requirements: + - - "~>" + - !ruby/object:Gem::Version + version: '2.0' +- !ruby/object:Gem::Dependency + name: highline + requirement: !ruby/object:Gem::Requirement + requirements: + - - "~>" + - !ruby/object:Gem::Version version: 1.6.19 type: :runtime - version_requirements: *id002 + prerelease: false + version_requirements: !ruby/object:Gem::Requirement + requirements: + - - "~>" + - !ruby/object:Gem::Version + version: 1.6.19 description: Hiera backend for decrypting encrypted yaml properties email: -executables: +executables: - eyaml extensions: [] - extra_rdoc_files: [] - -files: -- .gitignore -- .travis.yml +files: +- ".gitignore" +- ".travis.yml" - CHANGES.md - Gemfile - LICENSE.txt @@ -53,8 +58,12 @@ - lib/hiera/backend/eyaml.rb - lib/hiera/backend/eyaml/CLI.rb - lib/hiera/backend/eyaml/commands.rb +- lib/hiera/backend/eyaml/edithelper.rb +- lib/hiera/backend/eyaml/encrypthelper.rb - lib/hiera/backend/eyaml/encryptor.rb - lib/hiera/backend/eyaml/encryptors/pkcs7.rb +- lib/hiera/backend/eyaml/highlinehelper.rb +- lib/hiera/backend/eyaml/logginghelper.rb - lib/hiera/backend/eyaml/options.rb - lib/hiera/backend/eyaml/parser/encrypted_tokens.rb - lib/hiera/backend/eyaml/parser/parser.rb @@ -77,30 +86,27 @@ - tools/git_tag_release.rb - tools/regem.sh homepage: http://github.com/TomPoulton/hiera-eyaml -licenses: +licenses: - MIT metadata: {} - post_install_message: rdoc_options: [] - -require_paths: +require_paths: - lib -required_ruby_version: !ruby/object:Gem::Requirement - requirements: - - &id003 - - ">=" - - !ruby/object:Gem::Version - version: "0" -required_rubygems_version: !ruby/object:Gem::Requirement - requirements: - - *id003 +required_ruby_version: !ruby/object:Gem::Requirement + requirements: + - - ">=" + - !ruby/object:Gem::Version + version: '0' +required_rubygems_version: !ruby/object:Gem::Requirement + requirements: + - - ">=" + - !ruby/object:Gem::Version + version: '0' requirements: [] - rubyforge_project: -rubygems_version: 2.0.14 +rubygems_version: 2.2.2 signing_key: specification_version: 4 summary: OpenSSL Encryption backend for Hiera test_files: [] -