Commit 28fd3bc2 authored by Jonas Genannt's avatar Jonas Genannt

Imported Upstream version 2.0.8

parent 26afad1b
......@@ -8,3 +8,4 @@ tmp/
.rvmrc
.ruby-version
.ruby-gemset
Gemfile.lock
......@@ -3,8 +3,12 @@ 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
script:
bundle exec cucumber -f progress
notifications:
email: false
Change log for hiera-eyaml
==========================
2.06
----
2.0.8
-----
- #131 - Fix another EDITOR bug (#130) that could erase command line flags to the specified editor (@elyscape)
- (#149) - Fix to tempfile permissions and invalid editor scenario (@elyscape)
2.05
----
2.0.7
-----
- #128 - Fix a bug (#127) that caused `eyaml edit` to break when `$EDITOR` was a command on PATH rather than a path to a command (@elyscape)
- (#142) - Fixed highline dependency to exclude newer versions that are not compatible with ruby 1.8.7 (@elyscape)
- (#136) - \t and \r characters are now supported in encrypted blocks (@elyscape)
- (#138) - Added missing tags and new tagging tool (@elyscape)
2.04
----
2.0.6
-----
- (#131) - Fix another EDITOR bug (#130) that could erase command line flags to the specified editor (@elyscape)
2.0.5
-----
- (#128) - Fix a bug (#127) that caused `eyaml edit` to break when `$EDITOR` was a command on PATH rather than a path to a command (@elyscape)
2.0.4
-----
- Add change log
- #118 - Some initial support for spaces in filenames (primarily targeted at windows platforms) (@elyscape)
- #114 - Add new config file resolution so that a system wide /etc/eyaml/config.yaml is processed first (@gtmtech)
- #112 - Improve debugging options and colorise output (@gtmtech)
- #102 - Extension of temp files should be yaml to help editors provide syntax highlighting (@ColinHebert)
- #90, #121, #122 - Add preamble in edit mode to make it easier to remember how to edit (@sihil)
- #96, #111, #116 - Various updates to docs
2.03
----
- (#118) - Some initial support for spaces in filenames (primarily targeted at windows platforms) (@elyscape)
- (#114) - Add new config file resolution so that a system wide /etc/eyaml/config.yaml is processed first (@gtmtech)
- (#112) - Improve debugging options and colorise output (@gtmtech)
- (#102) - Extension of temp files should be yaml to help editors provide syntax highlighting (@ColinHebert)
- (#90), #121, #122 - Add preamble in edit mode to make it easier to remember how to edit (@sihil)
- (#96), #111, #116 - Various updates to docs
2.0.3
-----
source 'https://rubygems.org/'
gem 'highline'
gem 'trollop'
gem 'highline', '~> 1.6.19'
gem 'trollop', '~> 2.0'
group :development do
gem "aruba"
gem "aruba", '~> 0.6.2'
gem "cucumber", '~> 1.1'
gem "rspec-expectations", '~> 3.1.0'
gem "hiera-eyaml-plaintext"
gem "puppet"
end
......
GEM
remote: https://rubygems.org/
specs:
aruba (0.5.3)
childprocess (>= 0.3.6)
cucumber (>= 1.1.1)
rspec-expectations (>= 2.7.0)
builder (3.2.2)
childprocess (0.3.9)
ffi (~> 1.0, >= 1.0.11)
cucumber (1.3.10)
builder (>= 2.1.2)
diff-lcs (>= 1.1.3)
gherkin (~> 2.12)
multi_json (>= 1.7.5, < 2.0)
multi_test (>= 0.0.2)
diff-lcs (1.2.5)
facter (1.7.3)
ffi (1.9.3)
gherkin (2.12.2)
multi_json (~> 1.3)
hiera (1.2.1)
json_pure
hiera-eyaml-plaintext (0.5)
highline (1.6.20)
json_pure (1.8.1)
multi_json (1.8.2)
multi_test (0.0.2)
puppet (3.3.2)
facter (~> 1.6)
hiera (~> 1.0)
rgen (~> 0.6.5)
rake (10.1.0)
rgen (0.6.6)
rspec-expectations (2.14.4)
diff-lcs (>= 1.1.3, < 2.0)
trollop (2.0)
PLATFORMS
ruby
DEPENDENCIES
aruba
hiera-eyaml-plaintext
highline
puppet
rake
trollop
......@@ -17,6 +17,6 @@ Gem::Specification.new do |gem|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
gem.require_paths = ["lib"]
gem.add_dependency('trollop', '>= 2.0')
gem.add_dependency('highline', '>= 1.6.19')
gem.add_dependency('trollop', '~> 2.0')
gem.add_dependency('highline', '~> 1.6.19')
end
......@@ -2,7 +2,7 @@ class Hiera
module Backend
module Eyaml
VERSION = "2.0.6"
VERSION = "2.0.8"
DESCRIPTION = "Hiera-eyaml is a backend for Hiera which provides OpenSSL encryption/decryption for Hiera properties"
class RecoverableError < StandardError
......
......@@ -39,13 +39,13 @@ class Hiera
case format
when :block
# strip any white space
@cipher = @cipher.gsub(/ /m, "")
@cipher = @cipher.gsub(/[ \t]/, "")
# normalize indentation
ciphertext = @cipher.gsub(/\n/, "\n" + @indentation)
ciphertext = @cipher.gsub(/[\n\r]/, "\n" + @indentation)
chevron = (args[:use_chevron].nil? || args[:use_chevron]) ? ">\n" : ''
"#{label_string}#{chevron}" + @indentation + "ENC[#{@encryptor.tag},#{ciphertext}]"
when :string
ciphertext = @cipher.gsub(/\n/, "")
ciphertext = @cipher.gsub(/[\n\r]/, "")
"#{label_string}ENC[#{@encryptor.tag},#{ciphertext}]"
else
raise "#{@format} is not a valid format"
......@@ -87,7 +87,7 @@ class Hiera
@string_token_type = EncStringTokenType.new()
end
def create_token(string)
@string_token_type.create_token(string.gsub(/[ \n]/, ''))
@string_token_type.create_token(string.gsub(/\s/, ''))
end
end
......@@ -103,7 +103,7 @@ class Hiera
class EncBlockTokenType < EncTokenType
def initialize
@regex = />\n(\s*)ENC\[(\w+,)?([a-zA-Z0-9\+\/ =\n]+?)\]/
@regex = />\n(\s*)ENC\[(\w+,)?([a-zA-Z0-9\+\/=\s]+?)\]/
end
def create_token(string)
md = @regex.match(string)
......
......@@ -68,15 +68,15 @@ eos
end
def self.execute
editor = Utils.find_editor
encrypted_parser = Parser::ParserFactory.encrypted_parser
tokens = encrypted_parser.parse Eyaml::Options[:input_data]
decrypted_input = tokens.each_with_index.to_a.map{|(t,index)| t.to_decrypted :index => index}.join
decrypted_file_content = Eyaml::Options[:no_preamble] ? decrypted_input : (self.preamble + decrypted_input)
decrypted_file = Utils.write_tempfile decrypted_file_content
editor = Utils.find_editor
begin
decrypted_file = Utils.write_tempfile decrypted_file_content unless decrypted_file
system "#{editor} \"#{decrypted_file}\""
status = $?
......
......@@ -72,9 +72,22 @@ class Hiera
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
......
--- !ruby/object:Gem::Specification
--- !ruby/object:Gem::Specification
name: hiera-eyaml
version: !ruby/object:Gem::Version
version: 2.0.6
prerelease:
version: !ruby/object:Gem::Version
version: 2.0.8
platform: ruby
authors:
authors:
- Tom Poulton
autorequire:
bindir: bin
cert_chain: []
date: 2014-12-13 00:00:00.000000000 Z
dependencies:
- !ruby/object:Gem::Dependency
date: 2015-04-15 00:00:00 Z
dependencies:
- !ruby/object:Gem::Dependency
name: trollop
requirement: !ruby/object:Gem::Requirement
none: false
requirements:
- - ! '>='
- !ruby/object:Gem::Version
version: '2.0'
type: :runtime
prerelease: false
version_requirements: !ruby/object:Gem::Requirement
none: false
requirements:
- - ! '>='
- !ruby/object:Gem::Version
version: '2.0'
- !ruby/object:Gem::Dependency
name: highline
requirement: !ruby/object:Gem::Requirement
none: false
requirements:
- - ! '>='
- !ruby/object:Gem::Version
version: 1.6.19
requirement: &id001 !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
version_requirements: !ruby/object:Gem::Requirement
none: false
requirements:
- - ! '>='
- !ruby/object:Gem::Version
requirement: &id002 !ruby/object:Gem::Requirement
requirements:
- - ~>
- !ruby/object:Gem::Version
version: 1.6.19
type: :runtime
version_requirements: *id002
description: Hiera backend for decrypting encrypted yaml properties
email:
executables:
executables:
- eyaml
extensions: []
extra_rdoc_files: []
files:
files:
- .gitignore
- .travis.yml
- CHANGES.md
- Gemfile
- Gemfile.lock
- LICENSE.txt
- PLUGINS.md
- README.md
......@@ -85,30 +74,33 @@ files:
- sublime_text/README.md
- sublime_text/eyaml.sublime-package
- sublime_text/eyaml.syntax_definition.json
- 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
none: false
requirements:
- - ! '>='
- !ruby/object:Gem::Version
version: '0'
required_rubygems_version: !ruby/object:Gem::Requirement
none: false
requirements:
- - ! '>='
- !ruby/object:Gem::Version
version: '0'
required_ruby_version: !ruby/object:Gem::Requirement
requirements:
- &id003
- ">="
- !ruby/object:Gem::Version
version: "0"
required_rubygems_version: !ruby/object:Gem::Requirement
requirements:
- *id003
requirements: []
rubyforge_project:
rubygems_version: 1.8.23.2
rubygems_version: 2.0.14
signing_key:
specification_version: 3
specification_version: 4
summary: OpenSSL Encryption backend for Hiera
test_files: []
#!/usr/bin/env ruby
require 'rubygems'
if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('1.9')
$stderr.puts "This script requires Ruby >= 1.9"
exit 1
end
require 'open3'
result = Open3.capture3('git rev-parse --show-toplevel')
unless result[2].exitstatus == 0
$stderr.puts "You do not appear to be in a git repository. This script must be run from inside a git repository."
exit 2
end
filename = result[0].lines.first.chomp + '/CHANGES.md'
unless File.exist?(filename)
$stderr.puts "CHANGES.md not found. Please ensure that CHANGES.md exists."
exit 3
end
contents = IO.read(filename)
lines = contents.lines.drop(3).map(&:chomp).reject(&:empty?)
versions = Hash.new
currentversion = nil
versions[nil] = []
lines.each_with_index do |line, index|
if line =~ /\A-+\z/
versions[currentversion].pop
currentversion = lines[index-1]
versions[currentversion] = []
else
versions[currentversion] << line
end
end
versions.delete(nil)
def prompt(*args)
print(*args)
gets.chomp
end
newest = versions.first[0]
version = prompt "Version [#{newest}]: "
version = newest if version.empty?
unless versions[version]
$stderr.puts "Version #{version} is invalid. Valid versions are: #{versions.keys.join(', ')}"
exit 4
end
tagname = "v#{version}"
result = Open3.capture3("git rev-parse #{tagname}")
if result[2].exitstatus == 0
$stderr.puts "Tag #{tagname} already exists."
exit 5
end
commit = prompt "Commit: "
result = Open3.capture3("git --no-pager log -1 #{commit} --format='%ci'")
unless result[2].exitstatus == 0
$stderr.puts "Commit '#{commit}' is not valid."
exit result[2].exitstatus
end
commitdate = result[0].lines.first.chomp
def word_wrap(line, width)
first_prefix = line.match(/([ -]*)/)[1]
prefix = ' ' * first_prefix.size
real_width = width - (prefix.size * 2)
line[prefix.size..-1].gsub(/(^)?(.{1,#{real_width}})(?: +|$)/) { |s| $1 ? "#{first_prefix}#{s}\n" : "#{prefix}#{s}\n" }
end
require 'tempfile'
begin
tf = Tempfile.new('tag-message')
tf.puts "Version #{version} release"
tf.puts ""
tf.puts "Changes:"
versions[version].each do |line|
tf.puts word_wrap(line, 80)
end
tf.flush
result = Open3.capture3({'GIT_COMMITTER_DATE' => commitdate}, "git tag -a #{tagname} #{commit} -F #{tf.path}")
$stderr.puts result[1]
if result[2].exitstatus == 0
system "git --no-pager show #{tagname} --no-patch"
puts ""
puts "Tag created. Please push to GitHub with `git push origin #{tagname}`."
end
exit result[2].exitstatus
ensure
tf.close!
end
#!/bin/bash
# ToDo: Remove as 'rake install' task will build and install the latest gem?
gem uninstall hiera-eyaml --executables
RAKE_OUT=`rake build`
echo ${RAKE_OUT}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment