itamae-plugin-resource-encrypted_remote_file 0.0.1.beta1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: df8e3344bda25a0e3379d31612be0c27f4810603
4
+ data.tar.gz: 96e1d71f210f0fed3e617308f68707f7caf1f830
5
+ SHA512:
6
+ metadata.gz: 03d3a222d0a2fd44dde809dddffc6efa2c0d6e898a3c036e118de14edfe2bfc23a6281362d32580417bd09c1d6c6a5f57d655e2fa09607284a4397f64f35e5c5
7
+ data.tar.gz: a60f41c5141c6ab3fa6f9f7edaf77dedfcfc2f3279d11b9c5b6f03465138f26792381f8cc15914347aed9eaac724c066cedb650b445c14838f38b137828418e8
data/.coveralls.yml ADDED
@@ -0,0 +1 @@
1
+ repo_token: X0BBZfE4kDkJeaSeaYsiGEstlGR9SLRU1
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.hound.yml ADDED
@@ -0,0 +1,127 @@
1
+ # target_version:
2
+ # rubocop v0.30.0
3
+
4
+ # Exclude autogenerated files
5
+ AllCops:
6
+ Exclude:
7
+ - "vendor/**/*" # rubocop config/default.yml
8
+ - "db/schema.rb"
9
+ DisplayCopNames: true
10
+
11
+ ##################### Style ##################################
12
+
13
+ Style/AndOr:
14
+ EnforcedStyle: conditionals
15
+
16
+ Style/AsciiComments:
17
+ Enabled: false
18
+
19
+ Style/BlockDelimiters:
20
+ Enabled: false
21
+
22
+ Style/BracesAroundHashParameters:
23
+ Enabled: false
24
+
25
+ Style/DeprecatedHashMethods:
26
+ Enabled: false
27
+
28
+ Style/Documentation:
29
+ Enabled: false
30
+
31
+ Style/DoubleNegation:
32
+ Enabled: false
33
+
34
+ Style/DotPosition:
35
+ EnforcedStyle: trailing
36
+
37
+ Style/EmptyElse:
38
+ EnforcedStyle: empty
39
+
40
+ Style/FormatString:
41
+ EnforcedStyle: percent
42
+
43
+ Style/GuardClause:
44
+ MinBodyLength: 5
45
+
46
+ Style/HashSyntax:
47
+ EnforcedStyle: ruby19_no_mixed_keys
48
+ Exclude:
49
+ - "**/*.rake"
50
+ - "Rakefile"
51
+
52
+ Style/IfUnlessModifier:
53
+ Enabled: false
54
+
55
+ Style/IndentHash:
56
+ EnforcedStyle: consistent
57
+
58
+ Style/Lambda:
59
+ Enabled: false
60
+
61
+ Style/NumericLiterals:
62
+ MinDigits: 6
63
+
64
+ Style/PredicateName:
65
+ Enabled: false
66
+
67
+ Style/RedundantSelf:
68
+ Enabled: false
69
+
70
+ Style/RedundantReturn:
71
+ AllowMultipleReturnValues: true
72
+
73
+ Style/SignalException:
74
+ EnforcedStyle: only_raise
75
+
76
+ Style/SpaceAroundOperators:
77
+ MultiSpaceAllowedForOperators:
78
+ - "="
79
+ - "=>"
80
+ - "||"
81
+
82
+ Style/StringLiterals:
83
+ EnforcedStyle: double_quotes
84
+
85
+ Style/StringLiteralsInInterpolation:
86
+ Enabled: false
87
+
88
+ Style/SingleLineBlockParams:
89
+ Enabled: false
90
+
91
+ Style/SingleSpaceBeforeFirstArg:
92
+ Enabled: false
93
+
94
+ Style/TrailingComma:
95
+ EnforcedStyleForMultiline: comma
96
+
97
+ ##################### Lint ##################################
98
+
99
+ Lint/UnderscorePrefixedVariableName:
100
+ Enabled: false
101
+
102
+ Lint/UnusedMethodArgument:
103
+ Enabled: false
104
+
105
+ ##################### Metrics ##################################
106
+
107
+ Metrics/AbcSize:
108
+ Max: 30
109
+
110
+ Metrics/CyclomaticComplexity:
111
+ Max: 10
112
+
113
+ Metrics/LineLength:
114
+ Max: 160
115
+ Exclude:
116
+ - "db/migrate/*.rb"
117
+
118
+ Metrics/MethodLength:
119
+ Max: 20
120
+ Exclude:
121
+ - "db/migrate/*.rb"
122
+
123
+ Metrics/PerceivedComplexity:
124
+ Max: 8
125
+
126
+ Metrics/ClassLength:
127
+ Max: 120
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,2 @@
1
+ inherit_from:
2
+ - .hound.yml
data/.travis.yml ADDED
@@ -0,0 +1,21 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.1
4
+ - 2.2
5
+ - ruby-head
6
+ cache: bundler
7
+ before_install: gem install bundler
8
+ before_script:
9
+ - export COVERAGE=true
10
+ script:
11
+ - bundle exec rspec
12
+ branches:
13
+ only:
14
+ - master
15
+ notifications:
16
+ email: false
17
+ slack:
18
+ secure: SusEtW3pV+b+KUQoQjhqTI+7QtaDXlVl0Wx2EPo1VA4k/t9M/FRZXAXxq2j5+K3QE0y4p4QbnMRoZ8W8l4f7NXzOi7CFHQAnKUVDswZdsj2udEWeNWUeN4Rub0de3sInfKkbZKfT0uhamToX/pRH7uhOogeL9Eei+KUekUXJKTE=
19
+ matrix:
20
+ allow_failures:
21
+ - rvm: ruby-head
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in itamae-plugin-resource-encrypted_remote_file.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 sue445
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,62 @@
1
+ # Itamae::Plugin::Resource::EncryptedRemoteFile
2
+
3
+ encrypt secret data (ex. id_rsa), and forward decrypted file to remote.
4
+
5
+ This is like to [knife-solo_data_bag](https://github.com/thbishop/knife-solo_data_bag)
6
+
7
+ [![Build Status](https://travis-ci.org/sue445/itamae-plugin-resource-encrypted_remote_file.svg?branch=master)](https://travis-ci.org/sue445/itamae-plugin-resource-encrypted_remote_file)
8
+ [![Code Climate](https://codeclimate.com/github/sue445/itamae-plugin-resource-encrypted_remote_file/badges/gpa.svg)](https://codeclimate.com/github/sue445/itamae-plugin-resource-encrypted_remote_file)
9
+ [![Coverage Status](https://coveralls.io/repos/sue445/itamae-plugin-resource-encrypted_remote_file/badge.svg)](https://coveralls.io/r/sue445/itamae-plugin-resource-encrypted_remote_file)
10
+ [![Dependency Status](https://gemnasium.com/sue445/itamae-plugin-resource-encrypted_remote_file.svg)](https://gemnasium.com/sue445/itamae-plugin-resource-encrypted_remote_file)
11
+
12
+ ## Installation
13
+
14
+ Add this line to your application's Gemfile:
15
+
16
+ ```ruby
17
+ gem 'itamae-plugin-resource-encrypted_remote_file'
18
+ ```
19
+
20
+ And then execute:
21
+
22
+ $ bundle
23
+
24
+ Or install it yourself as:
25
+
26
+ $ gem install itamae-plugin-resource-encrypted_remote_file
27
+
28
+ ## Usage
29
+
30
+ ### Encrypt data
31
+ install [reversible_cryptography](https://github.com/mitaku/reversible_cryptography)
32
+
33
+ ```sh
34
+ gem install reversible_cryptography
35
+
36
+
37
+ ```
38
+
39
+ ### Recipe
40
+
41
+ ```ruby
42
+ encrypted_remote_file "/home/deployer/.ssh/id_rsa" do
43
+ owner "root"
44
+ group "root"
45
+ source "remote_files/encrypted_file.txt"
46
+ password ENV["PASSWORD"]
47
+ end
48
+ ```
49
+
50
+ ## Development
51
+
52
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
53
+
54
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
55
+
56
+ ## Contributing
57
+
58
+ 1. Fork it ( https://github.com/sue445/itamae-plugin-resource-encrypted_remote_file/fork )
59
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
60
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
61
+ 4. Push to the branch (`git push origin my-new-feature`)
62
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "itamae/plugin/resource/encrypted_remote_file"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,36 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "itamae-plugin-resource-encrypted_remote_file"
7
+ spec.version = "0.0.1.beta1"
8
+ spec.authors = ["sue445"]
9
+ spec.email = ["sue445@sue445.net"]
10
+
11
+ spec.summary = "encrypt secret data, and forward decrypted file to remote."
12
+ spec.description = "encrypt secret data, and forward decrypted file to remote."
13
+ spec.homepage = "https://github.com/sue445/itamae-plugin-resource-encrypted_remote_file"
14
+
15
+ # Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
16
+ # delete this section to allow pushing this gem to any host.
17
+ if spec.respond_to?(:metadata)
18
+ spec.metadata["allowed_push_host"] = "https://rubygems.org"
19
+ else
20
+ raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
21
+ end
22
+
23
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
24
+ spec.bindir = "exe"
25
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
26
+ spec.require_paths = ["lib"]
27
+
28
+ spec.add_dependency "itamae", "~> 1.2.13"
29
+ spec.add_dependency "reversible_cryptography"
30
+
31
+ spec.add_development_dependency "bundler", ">= 1.9.4"
32
+ spec.add_development_dependency "coveralls"
33
+ spec.add_development_dependency "rake", "~> 10.0"
34
+ spec.add_development_dependency "rspec"
35
+ spec.add_development_dependency "rubocop"
36
+ end
@@ -0,0 +1 @@
1
+ require "itamae/plugin/resource/encrypted_remote_file"
@@ -0,0 +1,37 @@
1
+ require "itamae"
2
+
3
+ module Itamae
4
+ module Plugin
5
+ module Resource
6
+ require "tempfile"
7
+ require "reversible_cryptography"
8
+
9
+ class EncryptedRemoteFile < ::Itamae::Resource::RemoteFile
10
+ define_attribute :password, type: String
11
+
12
+ def pre_action
13
+ src_expanded_path = ::File.expand_path(attributes.source, ::File.dirname(@recipe.path))
14
+ encrypted_data = File.read(src_expanded_path).strip
15
+
16
+ decrypted_data = ReversibleCryptography::Message.decrypt(encrypted_data, attributes.password)
17
+ @decrypted_tempfile = Tempfile.open(File.basename(attributes.source)) do |f|
18
+ f.write(decrypted_data)
19
+ f
20
+ end
21
+
22
+ super
23
+ end
24
+
25
+ def content_file
26
+ @decrypted_tempfile.path
27
+ end
28
+
29
+ def action_create(options)
30
+ super
31
+
32
+ @decrypted_tempfile.close! if @decrypted_tempfile
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
metadata ADDED
@@ -0,0 +1,157 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: itamae-plugin-resource-encrypted_remote_file
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1.beta1
5
+ platform: ruby
6
+ authors:
7
+ - sue445
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-04-23 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: itamae
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 1.2.13
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 1.2.13
27
+ - !ruby/object:Gem::Dependency
28
+ name: reversible_cryptography
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: 1.9.4
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: 1.9.4
55
+ - !ruby/object:Gem::Dependency
56
+ name: coveralls
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '10.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '10.0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rspec
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rubocop
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ description: encrypt secret data, and forward decrypted file to remote.
112
+ email:
113
+ - sue445@sue445.net
114
+ executables: []
115
+ extensions: []
116
+ extra_rdoc_files: []
117
+ files:
118
+ - ".coveralls.yml"
119
+ - ".gitignore"
120
+ - ".hound.yml"
121
+ - ".rspec"
122
+ - ".rubocop.yml"
123
+ - ".travis.yml"
124
+ - Gemfile
125
+ - LICENSE.txt
126
+ - README.md
127
+ - Rakefile
128
+ - bin/console
129
+ - bin/setup
130
+ - itamae-plugin-resource-encrypted_remote_file.gemspec
131
+ - lib/itamae-plugin-resource-encrypted_remote_file.rb
132
+ - lib/itamae/plugin/resource/encrypted_remote_file.rb
133
+ homepage: https://github.com/sue445/itamae-plugin-resource-encrypted_remote_file
134
+ licenses: []
135
+ metadata:
136
+ allowed_push_host: https://rubygems.org
137
+ post_install_message:
138
+ rdoc_options: []
139
+ require_paths:
140
+ - lib
141
+ required_ruby_version: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ required_rubygems_version: !ruby/object:Gem::Requirement
147
+ requirements:
148
+ - - ">"
149
+ - !ruby/object:Gem::Version
150
+ version: 1.3.1
151
+ requirements: []
152
+ rubyforge_project:
153
+ rubygems_version: 2.4.5
154
+ signing_key:
155
+ specification_version: 4
156
+ summary: encrypt secret data, and forward decrypted file to remote.
157
+ test_files: []