hiera-eyaml-rsa 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 6c034e4142eb2e3068700c28561040a572c4250d8bf79486a20ab1e21ad6892e
4
+ data.tar.gz: a4c647632e2bf247bc7b02b70ffe4845082a8dfceb31b85f01a3e9c3d4b0d632
5
+ SHA512:
6
+ metadata.gz: c8c7351c8b4703d75ce0383652c2f1262ead291eb9db673976ffbfac842168fc882570fc95c9f7ea29992f48bfa09368039e71714ede1f399a3be18d14d8d368
7
+ data.tar.gz: 51d6921b1384f03cef341bb643129abea04f068c0530d2caf336ce58e04be852f60a5d3d15b94d3b6d22854c849398f2a8f04569f2699991b33511781bd2500c
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,19 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.6
3
+
4
+ require:
5
+ - rubocop-rake
6
+
7
+ Style/Documentation:
8
+ Enabled: false
9
+
10
+ Style/StringLiterals:
11
+ Enabled: true
12
+ EnforcedStyle: double_quotes
13
+
14
+ Style/StringLiteralsInInterpolation:
15
+ Enabled: true
16
+ EnforcedStyle: double_quotes
17
+
18
+ Layout/LineLength:
19
+ Max: 120
@@ -0,0 +1,84 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
+
7
+ We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
8
+
9
+ ## Our Standards
10
+
11
+ Examples of behavior that contributes to a positive environment for our community include:
12
+
13
+ * Demonstrating empathy and kindness toward other people
14
+ * Being respectful of differing opinions, viewpoints, and experiences
15
+ * Giving and gracefully accepting constructive feedback
16
+ * Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
17
+ * Focusing on what is best not just for us as individuals, but for the overall community
18
+
19
+ Examples of unacceptable behavior include:
20
+
21
+ * The use of sexualized language or imagery, and sexual attention or
22
+ advances of any kind
23
+ * Trolling, insulting or derogatory comments, and personal or political attacks
24
+ * Public or private harassment
25
+ * Publishing others' private information, such as a physical or email
26
+ address, without their explicit permission
27
+ * Other conduct which could reasonably be considered inappropriate in a
28
+ professional setting
29
+
30
+ ## Enforcement Responsibilities
31
+
32
+ Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
33
+
34
+ Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
35
+
36
+ ## Scope
37
+
38
+ This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
39
+
40
+ ## Enforcement
41
+
42
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at romain@blogreen.org. All complaints will be reviewed and investigated promptly and fairly.
43
+
44
+ All community leaders are obligated to respect the privacy and security of the reporter of any incident.
45
+
46
+ ## Enforcement Guidelines
47
+
48
+ Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
49
+
50
+ ### 1. Correction
51
+
52
+ **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
53
+
54
+ **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
55
+
56
+ ### 2. Warning
57
+
58
+ **Community Impact**: A violation through a single incident or series of actions.
59
+
60
+ **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
61
+
62
+ ### 3. Temporary Ban
63
+
64
+ **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
65
+
66
+ **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
67
+
68
+ ### 4. Permanent Ban
69
+
70
+ **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
71
+
72
+ **Consequence**: A permanent ban from any sort of public interaction within the community.
73
+
74
+ ## Attribution
75
+
76
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
77
+ available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
78
+
79
+ Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
80
+
81
+ [homepage]: https://www.contributor-covenant.org
82
+
83
+ For answers to common questions about this code of conduct, see the FAQ at
84
+ https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in hiera-eyaml-rsa.gemspec
6
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2022 Romain Tartière
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,47 @@
1
+ # hiera-eyaml-rsa
2
+
3
+ Simple RSA encryption backend for use with [hiera-eyaml](https://github.com/voxpupuli/hiera-eyaml).
4
+
5
+ ## Motivation
6
+
7
+ The default PKCS#7 encryption scheme used by hiera-eyaml is… awkward. Just use plain RSA keys, don't wrap them in X.509 certificates that also need a *subject*, an *issuer*, *not before* and *not after* dates.
8
+
9
+ ## Installation
10
+
11
+ Install the gem and add to the application's Gemfile by executing:
12
+
13
+ $ bundle add hiera-eyaml-rsa
14
+
15
+ If bundler is not being used to manage dependencies, install the gem by executing:
16
+
17
+ $ gem install hiera-eyaml-rsa
18
+
19
+ ## Usage
20
+
21
+ Create an RSA key:
22
+
23
+ $ eyaml createkeys -n rsa
24
+
25
+ Alternatively, if you have PKCS#7 material and want to switch to plain RSA without rekeying:
26
+
27
+ $ rm keys/public_key.pkcs7.pem
28
+ $ openssl rsa -pubout -in keys/private_key.pkcs7.pem -out keys/public_key.rsa.pem
29
+ $ mv keys/private_key.pkcs7.pem keys/private_key.rsa.pem
30
+
31
+ ## Development
32
+
33
+ After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
34
+
35
+ 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`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
36
+
37
+ ## Contributing
38
+
39
+ Bug reports and pull requests are welcome on GitHub at https://github.com/smortex/hiera-eyaml-rsa. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/smortex/hiera-eyaml-rsa/blob/main/CODE_OF_CONDUCT.md).
40
+
41
+ ## License
42
+
43
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
44
+
45
+ ## Code of Conduct
46
+
47
+ Everyone interacting in the Hiera::Eyaml::Rsa project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/smortex/hiera-eyaml-rsa/blob/main/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+ require "cucumber/rake/task"
6
+
7
+ RSpec::Core::RakeTask.new(:spec)
8
+ Cucumber::Rake::Task.new(:features)
9
+
10
+ require "rubocop/rake_task"
11
+
12
+ RuboCop::RakeTask.new
13
+
14
+ task default: %i[rubocop features]
15
+
16
+ require "github_changelog_generator/task"
17
+ GitHubChangelogGenerator::RakeTask.new :changelog do |config|
18
+ config.future_release = "v#{Hiera::Backend::Eyaml::Encryptors::RsaVersion::VERSION}"
19
+ config.header = <<~HEADER.chomp
20
+ # Changelog
21
+
22
+ All notable changes to this project will be documented in this file.
23
+
24
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
25
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
26
+ HEADER
27
+ config.exclude_labels = %w[duplicate question invalid wontfix wont-fix skip-changelog ignore]
28
+ config.user = "smortex"
29
+ config.project = "hiera-eyaml-plaintext"
30
+ config.since_tag = "v1.0.0"
31
+ config.issues = false
32
+ end
@@ -0,0 +1,43 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/hiera/backend/eyaml/encryptors/rsa/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "hiera-eyaml-rsa"
7
+ spec.version = Hiera::Backend::Eyaml::Encryptors::RsaVersion::VERSION
8
+ spec.authors = ["Romain Tartière"]
9
+ spec.email = ["romain@blogreen.org"]
10
+
11
+ spec.summary = "Simple RSA encryptor for use with hiera-eyaml"
12
+ spec.description = "Encryption plugin for hiera-eyaml backend for Hiera using simple RSA keys"
13
+ spec.homepage = "https://github.com/smortex/hiera-eyaml-rsa"
14
+ spec.license = "MIT"
15
+ spec.required_ruby_version = ">= 2.6.0"
16
+
17
+ spec.metadata["allowed_push_host"] = "https://rubygems.org/"
18
+
19
+ spec.metadata["homepage_uri"] = spec.homepage
20
+ spec.metadata["source_code_uri"] = spec.homepage
21
+ spec.metadata["changelog_uri"] = spec.homepage
22
+
23
+ # Specify which files should be added to the gem when it is released.
24
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
25
+ spec.files = Dir.chdir(__dir__) do
26
+ `git ls-files -z`.split("\x0").reject do |f|
27
+ (f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
28
+ end
29
+ end
30
+ spec.bindir = "exe"
31
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
32
+ spec.require_paths = ["lib"]
33
+
34
+ spec.add_dependency "hiera-eyaml", "~> 3.0"
35
+
36
+ spec.add_development_dependency "aruba"
37
+ spec.add_development_dependency "cucumber"
38
+ spec.add_development_dependency "github_changelog_generator"
39
+ spec.add_development_dependency "rake"
40
+ spec.add_development_dependency "rspec"
41
+ spec.add_development_dependency "rubocop"
42
+ spec.add_development_dependency "rubocop-rake"
43
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "hiera/backend/eyaml/encryptors/rsa"
4
+
5
+ Hiera::Backend::Eyaml::Encryptors::Rsa.register
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Hiera
4
+ module Backend
5
+ module Eyaml
6
+ module Encryptors
7
+ module RsaVersion
8
+ VERSION = "1.0.0"
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,76 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "openssl"
4
+ require "hiera/backend/eyaml/encryptor"
5
+ require "hiera/backend/eyaml/encrypthelper"
6
+ require "hiera/backend/eyaml/logginghelper"
7
+ require "hiera/backend/eyaml/options"
8
+
9
+ class Hiera
10
+ module Backend
11
+ module Eyaml
12
+ module Encryptors
13
+ class Rsa < Encryptor
14
+ self.tag = "RSA"
15
+
16
+ self.options = {
17
+ private_key: { desc: "Path to private key",
18
+ type: :string,
19
+ default: "./keys/private_key.rsa.pem" },
20
+ public_key: { desc: "Path to public key",
21
+ type: :string,
22
+ default: "./keys/public_key.rsa.pem" },
23
+ private_key_env_var: { desc: "Name of environment variable to read private key from",
24
+ type: :string },
25
+ public_key_env_var: { desc: "Name of environment variable to read public key from",
26
+ type: :string },
27
+ keysize: { desc: "Key size used for encryption",
28
+ type: :integer,
29
+ default: 2048 }
30
+ }
31
+
32
+ def self.encrypt(plaintext)
33
+ LoggingHelper.trace "RSA encrypt"
34
+ public_key = load_key(:public_key, :public_key_env_var)
35
+ public_key.public_encrypt(plaintext)
36
+ end
37
+
38
+ def self.decrypt(ciphertext)
39
+ LoggingHelper.trace "RSA decrypt"
40
+ private_key = load_key(:private_key, :private_key_env_var)
41
+ private_key.private_decrypt(ciphertext)
42
+ end
43
+
44
+ def self.create_keys
45
+ public_key = option(:public_key)
46
+ private_key = option(:private_key)
47
+ keysize = option(:keysize)
48
+
49
+ key = OpenSSL::PKey::RSA.new(keysize)
50
+ EncryptHelper.ensure_key_dir_exists private_key
51
+ EncryptHelper.write_important_file filename: private_key, content: key.to_pem, mode: 0o600
52
+ EncryptHelper.ensure_key_dir_exists public_key
53
+ EncryptHelper.write_important_file filename: public_key, content: key.public_key.to_pem
54
+ LoggingHelper.info "Keys created OK"
55
+ end
56
+
57
+ def self.load_key(key_key, key_env_var_key)
58
+ key = option(key_key)
59
+ key_env_var = option(key_env_var_key)
60
+
61
+ raise StandardError, "rsa_#{key_key} is not defined" unless key || key_env_var
62
+
63
+ warn "both #{key_key} and #{key_env_var} specified, using #{key_key}" if key && key_env_var
64
+
65
+ key_pem = if key_env_var && ENV[key_env_var]
66
+ ENV[key_env_var]
67
+ else
68
+ File.read(key)
69
+ end
70
+ OpenSSL::PKey::RSA.new(key_pem)
71
+ end
72
+ end
73
+ end
74
+ end
75
+ end
76
+ end
metadata ADDED
@@ -0,0 +1,171 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: hiera-eyaml-rsa
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Romain Tartière
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2022-07-25 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: hiera-eyaml
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '3.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '3.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: aruba
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
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: cucumber
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: github_changelog_generator
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: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '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
+ - !ruby/object:Gem::Dependency
112
+ name: rubocop-rake
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ description: Encryption plugin for hiera-eyaml backend for Hiera using simple RSA
126
+ keys
127
+ email:
128
+ - romain@blogreen.org
129
+ executables: []
130
+ extensions: []
131
+ extra_rdoc_files: []
132
+ files:
133
+ - ".rspec"
134
+ - ".rubocop.yml"
135
+ - CODE_OF_CONDUCT.md
136
+ - Gemfile
137
+ - LICENSE.txt
138
+ - README.md
139
+ - Rakefile
140
+ - hiera-eyaml-rsa.gemspec
141
+ - lib/hiera/backend/eyaml/encryptors/rsa.rb
142
+ - lib/hiera/backend/eyaml/encryptors/rsa/eyaml_init.rb
143
+ - lib/hiera/backend/eyaml/encryptors/rsa/version.rb
144
+ homepage: https://github.com/smortex/hiera-eyaml-rsa
145
+ licenses:
146
+ - MIT
147
+ metadata:
148
+ allowed_push_host: https://rubygems.org/
149
+ homepage_uri: https://github.com/smortex/hiera-eyaml-rsa
150
+ source_code_uri: https://github.com/smortex/hiera-eyaml-rsa
151
+ changelog_uri: https://github.com/smortex/hiera-eyaml-rsa
152
+ post_install_message:
153
+ rdoc_options: []
154
+ require_paths:
155
+ - lib
156
+ required_ruby_version: !ruby/object:Gem::Requirement
157
+ requirements:
158
+ - - ">="
159
+ - !ruby/object:Gem::Version
160
+ version: 2.6.0
161
+ required_rubygems_version: !ruby/object:Gem::Requirement
162
+ requirements:
163
+ - - ">="
164
+ - !ruby/object:Gem::Version
165
+ version: '0'
166
+ requirements: []
167
+ rubygems_version: 3.3.17
168
+ signing_key:
169
+ specification_version: 4
170
+ summary: Simple RSA encryptor for use with hiera-eyaml
171
+ test_files: []