hiera-eyaml 3.4.0 → 4.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/release.yml +2 -2
  3. data/.github/workflows/test.yml +18 -28
  4. data/.rubocop.yml +8 -0
  5. data/.rubocop_todo.yml +416 -0
  6. data/CHANGELOG.md +33 -1
  7. data/Gemfile +13 -14
  8. data/README.md +32 -8
  9. data/Rakefile +11 -4
  10. data/hiera-eyaml.gemspec +17 -15
  11. data/lib/hiera/backend/eyaml/CLI.rb +12 -19
  12. data/lib/hiera/backend/eyaml/commands.rb +2 -6
  13. data/lib/hiera/backend/eyaml/edithelper.rb +24 -19
  14. data/lib/hiera/backend/eyaml/encrypthelper.rb +17 -19
  15. data/lib/hiera/backend/eyaml/encryptor.rb +40 -43
  16. data/lib/hiera/backend/eyaml/encryptors/pkcs7.rb +79 -105
  17. data/lib/hiera/backend/eyaml/highlinehelper.rb +3 -5
  18. data/lib/hiera/backend/eyaml/logginghelper.rb +27 -29
  19. data/lib/hiera/backend/eyaml/options.rb +13 -16
  20. data/lib/hiera/backend/eyaml/parser/encrypted_tokens.rb +2 -2
  21. data/lib/hiera/backend/eyaml/parser/parser.rb +35 -36
  22. data/lib/hiera/backend/eyaml/parser/token.rb +15 -6
  23. data/lib/hiera/backend/eyaml/plugins.rb +13 -18
  24. data/lib/hiera/backend/eyaml/subcommand.rb +72 -74
  25. data/lib/hiera/backend/eyaml/subcommands/createkeys.rb +2 -6
  26. data/lib/hiera/backend/eyaml/subcommands/decrypt.rb +52 -52
  27. data/lib/hiera/backend/eyaml/subcommands/edit.rb +57 -58
  28. data/lib/hiera/backend/eyaml/subcommands/encrypt.rb +65 -69
  29. data/lib/hiera/backend/eyaml/subcommands/help.rb +17 -22
  30. data/lib/hiera/backend/eyaml/subcommands/recrypt.rb +13 -20
  31. data/lib/hiera/backend/eyaml/subcommands/unknown_command.rb +10 -14
  32. data/lib/hiera/backend/eyaml/subcommands/version.rb +4 -9
  33. data/lib/hiera/backend/eyaml/utils.rb +27 -28
  34. data/lib/hiera/backend/eyaml.rb +7 -9
  35. data/lib/hiera/backend/eyaml_backend.rb +33 -27
  36. metadata +62 -14
  37. data/tools/git_tag_release.rb +0 -98
  38. data/tools/regem.sh +0 -11
@@ -8,144 +8,118 @@ class Hiera
8
8
  module Backend
9
9
  module Eyaml
10
10
  module Encryptors
11
-
12
11
  class Pkcs7 < Encryptor
13
-
14
12
  self.options = {
15
- :private_key => { :desc => "Path to private key",
16
- :type => :string,
17
- :default => "./keys/private_key.pkcs7.pem" },
18
- :public_key => { :desc => "Path to public key",
19
- :type => :string,
20
- :default => "./keys/public_key.pkcs7.pem" },
21
- :private_key_env_var => { :desc => "Name of environment variable to read private key from",
22
- :type => :string },
23
- :public_key_env_var => { :desc => "Name of environment variable to read public key from",
24
- :type => :string },
25
- :subject => { :desc => "Subject to use for certificate when creating keys",
26
- :type => :string,
27
- :default => "/" },
28
- :keysize => { :desc => "Key size used for encryption",
29
- :type => :integer,
30
- :default => 2048 },
31
- :digest => { :desc => "Hash function used for PKCS7",
32
- :type => :string,
33
- :default => "SHA256"},
13
+ private_key: { desc: 'Path to private key',
14
+ type: :string,
15
+ default: './keys/private_key.pkcs7.pem', },
16
+ public_key: { desc: 'Path to public key',
17
+ type: :string,
18
+ default: './keys/public_key.pkcs7.pem', },
19
+ private_key_env_var: { desc: 'Name of environment variable to read private key from',
20
+ type: :string, },
21
+ public_key_env_var: { desc: 'Name of environment variable to read public key from',
22
+ type: :string, },
23
+ keysize: { desc: 'Key size used for encryption',
24
+ type: :integer,
25
+ default: 2048, },
34
26
  }
35
27
 
36
- self.tag = "PKCS7"
37
-
38
- def self.encrypt plaintext
28
+ self.tag = 'PKCS7'
39
29
 
40
- LoggingHelper::trace 'PKCS7 encrypt'
30
+ def self.encrypt(plaintext)
31
+ LoggingHelper.trace 'PKCS7 encrypt'
41
32
 
42
- public_key = self.option :public_key
43
- public_key_env_var = self.option :public_key_env_var
44
- raise StandardError, "pkcs7_public_key is not defined" unless public_key or public_key_env_var
45
-
46
- if public_key and public_key_env_var
47
- warn "both public_key and public_key_env_var specified, using public_key"
48
- end
49
-
50
- if public_key_env_var and ENV[public_key_env_var]
51
- public_key_pem = ENV[public_key_env_var]
33
+ public_key_pem = load_public_key_pem
34
+ if public_key_pem.include? 'BEGIN CERTIFICATE'
35
+ public_key_x509 = OpenSSL::X509::Certificate.new(public_key_pem)
36
+ elsif public_key_pem.include? 'BEGIN PUBLIC KEY'
37
+ public_key_rsa = OpenSSL::PKey::RSA.new(public_key_pem)
38
+ public_key_x509 = OpenSSL::X509::Certificate.new
39
+ public_key_x509.public_key = public_key_rsa.public_key
52
40
  else
53
- public_key_pem = File.read public_key
41
+ raise StandardError, "file #{public_key_pem} cannot be used to encrypt - invalid public key format"
54
42
  end
55
- public_key_x509 = OpenSSL::X509::Certificate.new( public_key_pem )
56
43
 
57
- cipher = OpenSSL::Cipher::AES.new(256, :CBC)
58
- OpenSSL::PKCS7::encrypt([public_key_x509], plaintext, cipher, OpenSSL::PKCS7::BINARY).to_der
44
+ cipher = OpenSSL::Cipher.new('aes-256-cbc')
45
+ OpenSSL::PKCS7.encrypt([public_key_x509], plaintext, cipher, OpenSSL::PKCS7::BINARY).to_der
59
46
  end
60
47
 
61
- def self.decrypt ciphertext
62
-
63
- LoggingHelper::trace 'PKCS7 decrypt'
48
+ def self.decrypt(ciphertext)
49
+ LoggingHelper.trace 'PKCS7 decrypt'
64
50
 
65
- public_key = self.option :public_key
66
- private_key = self.option :private_key
67
- public_key_env_var = self.option :public_key_env_var
68
- private_key_env_var = self.option :private_key_env_var
69
- raise StandardError, "pkcs7_public_key is not defined" unless public_key or public_key_env_var
70
- raise StandardError, "pkcs7_private_key is not defined" unless private_key or private_key_env_var
51
+ private_key_pem = load_private_key_pem
52
+ private_key_rsa = OpenSSL::PKey::RSA.new(private_key_pem)
71
53
 
72
- if public_key and public_key_env_var
73
- warn "both public_key and public_key_env_var specified, using public_key"
74
- end
75
- if private_key and private_key_env_var
76
- warn "both private_key and private_key_env_var specified, using private_key"
77
- end
54
+ public_key_pem = load_public_key_pem
55
+ public_key_x509 = OpenSSL::X509::Certificate.new(public_key_pem)
78
56
 
79
- if private_key_env_var and ENV[private_key_env_var]
80
- private_key_pem = ENV[private_key_env_var]
81
- else
82
- private_key_pem = File.read private_key
83
- end
84
- private_key_rsa = OpenSSL::PKey::RSA.new( private_key_pem )
85
-
86
- if public_key_env_var and ENV[public_key_env_var]
87
- public_key_pem = ENV[public_key_env_var]
88
- else
89
- public_key_pem = File.read public_key
90
- end
91
- public_key_x509 = OpenSSL::X509::Certificate.new( public_key_pem )
92
-
93
- pkcs7 = OpenSSL::PKCS7.new( ciphertext )
57
+ pkcs7 = OpenSSL::PKCS7.new(ciphertext)
94
58
  pkcs7.decrypt(private_key_rsa, public_key_x509)
95
-
96
59
  end
97
60
 
98
61
  def self.create_keys
62
+ # Do equivalent of:
63
+ # openssl req -x509 -nodes -newkey rsa:2048 -keyout privatekey.pem -out publickey.pem -batch
99
64
 
100
- # Try to do equivalent of:
101
- # openssl req -x509 -nodes -days 100000 -newkey rsa:2048 -keyout privatekey.pem -out publickey.pem -subj '/'
102
-
103
- public_key = self.option :public_key
104
- private_key = self.option :private_key
105
- subject = self.option :subject
106
- keysize = self.option :keysize
107
- digest = self.option :digest
65
+ public_key = option :public_key
66
+ private_key = option :private_key
67
+ keysize = option :keysize
108
68
 
109
69
  key = OpenSSL::PKey::RSA.new(keysize)
110
70
  EncryptHelper.ensure_key_dir_exists private_key
111
- EncryptHelper.write_important_file :filename => private_key, :content => key.to_pem, :mode => 0600
71
+ EncryptHelper.write_important_file filename: private_key, content: key.to_pem, mode: 0o600
112
72
 
113
- cert = OpenSSL::X509::Certificate.new()
114
- cert.subject = OpenSSL::X509::Name.parse(subject)
115
- cert.serial = 1
116
- cert.version = 2
73
+ cert = OpenSSL::X509::Certificate.new
74
+ # In JRuby implementation of openssl, not_before and not_after
75
+ # are required to sign cert with key and digest. Signing the
76
+ # certificate is only required for Ruby 2.7 to call cert.to_pem.
117
77
  cert.not_before = Time.now
118
- cert.not_after = if 1.size == 8 # 64bit
119
- Time.now + 50 * 365 * 24 * 60 * 60
120
- else # 32bit
121
- Time.at(0x7fffffff)
122
- end
78
+ cert.not_after = if 1.size == 8 # 64bit
79
+ Time.now + (50 * 365 * 24 * 60 * 60)
80
+ else # 32bit
81
+ Time.at(0x7fffffff)
82
+ end
123
83
  cert.public_key = key.public_key
84
+ cert.sign key, OpenSSL::Digest.new('SHA256')
124
85
 
125
- ef = OpenSSL::X509::ExtensionFactory.new
126
- ef.subject_certificate = cert
127
- ef.issuer_certificate = cert
128
- cert.extensions = [
129
- ef.create_extension("basicConstraints","CA:TRUE", true),
130
- ef.create_extension("subjectKeyIdentifier", "hash"),
131
- ]
132
- cert.add_extension ef.create_extension("authorityKeyIdentifier",
133
- "keyid:always,issuer:always")
86
+ EncryptHelper.ensure_key_dir_exists public_key
87
+ EncryptHelper.write_important_file filename: public_key, content: cert.to_pem
88
+ LoggingHelper.info 'Keys created OK'
89
+ end
134
90
 
135
- cert.sign key, OpenSSL::Digest.new(digest)
91
+ def self.load_ANY_key_pem(optname_key, optname_env_var)
92
+ opt_key = option(optname_key.to_sym)
93
+ opt_key_env_var = option(optname_env_var.to_sym)
136
94
 
137
- EncryptHelper.ensure_key_dir_exists public_key
138
- EncryptHelper.write_important_file :filename => public_key, :content => cert.to_pem
139
- LoggingHelper.info "Keys created OK"
95
+ if opt_key and opt_key_env_var
96
+ warn "both #{optname_key} and #{optname_env_var} specified, using #{optname_env_var}"
97
+ end
140
98
 
99
+ if opt_key_env_var
100
+ raise StandardError, "env #{opt_key_env_var} is not set" unless ENV[opt_key_env_var]
101
+
102
+ opt_key_pem = ENV.fetch(opt_key_env_var, nil)
103
+ elsif opt_key
104
+ raise StandardError, "file #{opt_key} does not exist" unless File.exist? opt_key
105
+
106
+ opt_key_pem = File.read opt_key
107
+ else
108
+ raise StandardError, "pkcs7_#{optname_key} is not defined" unless opt_key or opt_key_env_var
109
+ end
110
+
111
+ opt_key_pem
141
112
  end
142
113
 
143
- end
114
+ def self.load_public_key_pem
115
+ load_ANY_key_pem('public_key', 'public_key_env_var')
116
+ end
144
117
 
118
+ def self.load_private_key_pem
119
+ load_ANY_key_pem('private_key', 'private_key_env_var')
120
+ end
121
+ end
145
122
  end
146
-
147
123
  end
148
-
149
124
  end
150
-
151
125
  end
@@ -4,20 +4,18 @@ class Hiera
4
4
  module Backend
5
5
  module Eyaml
6
6
  class HighlineHelper
7
-
8
7
  def self.read_password
9
- ask("Enter password: ") {|q| q.echo = "*" }
8
+ ask('Enter password: ') { |q| q.echo = '*' }
10
9
  end
11
10
 
12
- def self.confirm? message
11
+ def self.confirm?(message)
13
12
  result = ask("#{message} (y/N): ")
14
- if result.downcase == "y" or result.downcase == "yes"
13
+ if result.downcase == 'y' or result.downcase == 'yes'
15
14
  true
16
15
  else
17
16
  false
18
17
  end
19
18
  end
20
-
21
19
  end
22
20
  end
23
21
  end
@@ -5,14 +5,13 @@ class Hiera
5
5
  module Backend
6
6
  module Eyaml
7
7
  class LoggingHelper
8
-
9
- def self.structure_message messageinfo
10
- message = {:from => "hiera-eyaml-core"}
8
+ def self.structure_message(messageinfo)
9
+ message = { from: 'hiera-eyaml-core' }
11
10
  case messageinfo.class.to_s
12
11
  when 'Hash'
13
12
  message.merge!(messageinfo)
14
13
  else
15
- message.merge!({:msg => messageinfo.to_s})
14
+ message.merge!({ msg: messageinfo.to_s })
16
15
  end
17
16
  message[:prefix] = "[#{message[:from]}]"
18
17
  message[:spacer] = " #{' ' * message[:from].length} "
@@ -26,54 +25,53 @@ class Hiera
26
25
  formatted_output.join "\n"
27
26
  end
28
27
 
29
- def self.warn messageinfo
30
- self.print_message({ :message => self.structure_message( messageinfo ), :hiera_loglevel => :warn, :cli_color => :red })
28
+ def self.warn(messageinfo)
29
+ print_message({ message: structure_message(messageinfo), hiera_loglevel: :warn, cli_color: :red })
31
30
  end
32
31
 
33
- def self.info messageinfo
34
- self.print_message({ :message => self.structure_message( messageinfo ), :hiera_loglevel => :debug, :cli_color => :white, :threshold => 0 })
32
+ def self.info(messageinfo)
33
+ print_message({ message: structure_message(messageinfo), hiera_loglevel: :debug, cli_color: :white, threshold: 0 })
35
34
  end
36
35
 
37
- def self.debug messageinfo
38
- self.print_message({ :message => self.structure_message( messageinfo ), :hiera_loglevel => :debug, :cli_color => :green, :threshold => 1 })
36
+ def self.debug(messageinfo)
37
+ print_message({ message: structure_message(messageinfo), hiera_loglevel: :debug, cli_color: :green, threshold: 1 })
39
38
  end
40
39
 
41
- def self.trace messageinfo
42
- self.print_message({ :message => self.structure_message( messageinfo ), :hiera_loglevel => :debug, :cli_color => :blue, :threshold => 2 })
40
+ def self.trace(messageinfo)
41
+ print_message({ message: structure_message(messageinfo), hiera_loglevel: :debug, cli_color: :blue, threshold: 2 })
43
42
  end
44
43
 
45
- def self.print_message( args )
46
- message = args[:message] ||= ""
44
+ def self.print_message(args)
45
+ message = args[:message] ||= ''
47
46
  hiera_loglevel = args[:hiera_loglevel] ||= :debug
48
47
  cli_color = args[:cli_color] ||= :blue
49
48
  threshold = args[:threshold]
50
49
 
51
- if self.hiera?
50
+ if hiera?
52
51
  Hiera.send(hiera_loglevel, message) if threshold.nil? or Eyaml.verbosity_level > threshold
53
- else
54
- STDERR.puts self.colorize( message, cli_color ) if threshold.nil? or Eyaml.verbosity_level > threshold
52
+ elsif threshold.nil? or Eyaml.verbosity_level > threshold
53
+ STDERR.puts self.colorize( message, cli_color )
55
54
  end
56
55
  end
57
56
 
58
- def self.colorize message, color
57
+ def self.colorize(message, color)
59
58
  suffix = "\e[0m"
60
59
  prefix = case color
61
- when :red
62
- "\e[31m"
63
- when :green
64
- "\e[32m"
65
- when :blue
66
- "\e[34m"
67
- else #:white
68
- "\e[0m"
69
- end
60
+ when :red
61
+ "\e[31m"
62
+ when :green
63
+ "\e[32m"
64
+ when :blue
65
+ "\e[34m"
66
+ else # :white
67
+ "\e[0m"
68
+ end
70
69
  "#{prefix}#{message}#{suffix}"
71
70
  end
72
71
 
73
72
  def self.hiera?
74
- "hiera".eql? Eyaml::Options[:source]
73
+ 'hiera'.eql? Eyaml::Options[:source]
75
74
  end
76
-
77
75
  end
78
76
  end
79
77
  end
@@ -2,37 +2,34 @@ class Hiera
2
2
  module Backend
3
3
  module Eyaml
4
4
  class Options
5
-
6
- def self.[]= key, value
5
+ def self.[]=(key, value)
7
6
  @@options ||= {}
8
- @@options[ key.to_sym ] = value
7
+ @@options[key.to_sym] = value
9
8
  end
10
9
 
11
- def self.[] key
10
+ def self.[](key)
12
11
  @@options ||= {}
13
- @@options[ key.to_sym ]
12
+ @@options[key.to_sym]
14
13
  end
15
14
 
16
- def self.set hash
15
+ def self.set(hash)
17
16
  @@options = {}
18
17
  hash.each do |k, v|
19
- @@options[ k.to_sym ] = v
18
+ @@options[k.to_sym] = v
20
19
  end
21
20
  end
22
21
 
23
22
  def self.trace
24
- LoggingHelper::trace "Dump of eyaml tool options dict:"
25
- LoggingHelper::trace "--------------------------------"
23
+ LoggingHelper.trace 'Dump of eyaml tool options dict:'
24
+ LoggingHelper.trace '--------------------------------'
26
25
  @@options.each do |k, v|
27
- begin
28
- LoggingHelper::trace sprintf "%18s %-18s = %18s %-18s", "(#{k.class.name})", k.to_s, "(#{v.class.name})", v.to_s
29
- rescue
30
- LoggingHelper::trace sprintf "%18s %-18s = %18s %-18s", "(#{k.class.name})", k.to_s, "(#{v.class.name})", "<unprintable>" # case where v is binary
31
- end
26
+ LoggingHelper.trace format '%18s %-18s = %18s %-18s', "(#{k.class.name})", k.to_s, "(#{v.class.name})",
27
+ v.to_s
28
+ rescue StandardError
29
+ LoggingHelper.trace format '%18s %-18s = %18s %-18s', "(#{k.class.name})", k.to_s, "(#{v.class.name})", '<unprintable>' # case where v is binary
32
30
  end
33
- LoggingHelper::trace "--------------------------------"
31
+ LoggingHelper.trace '--------------------------------'
34
32
  end
35
-
36
33
  end
37
34
  end
38
35
  end
@@ -66,7 +66,7 @@ class Hiera
66
66
  case format
67
67
  when :block
68
68
  @cipher = @cipher.gsub(/\s/, '')
69
- chevron = args[:use_chevron].nil? || args[:use_chevron] ? ">\n" : ''
69
+ chevron = (args[:use_chevron].nil? || args[:use_chevron]) ? ">\n" : ''
70
70
  "#{label_string}#{chevron}" + @indentation + "ENC[#{@encryptor.tag},#{@cipher}]".scan(/.{1,60}/).join("\n" + @indentation)
71
71
  when :string
72
72
  ciphertext = @cipher.gsub(/[\n\r]/, '')
@@ -85,7 +85,7 @@ class Hiera
85
85
 
86
86
  case format
87
87
  when :block
88
- chevron = args[:use_chevron].nil? || args[:use_chevron] ? ">\n" : ''
88
+ chevron = (args[:use_chevron].nil? || args[:use_chevron]) ? ">\n" : ''
89
89
  "#{label_string}#{chevron}" + indentation + "DEC#{index}::#{@encryptor.tag}[" + @plain_text + ']!'
90
90
  when :string
91
91
  "#{label_string}DEC#{index}::#{@encryptor.tag}[" + @plain_text + ']!'
@@ -8,19 +8,19 @@ class Hiera
8
8
  module Parser
9
9
  class ParserFactory
10
10
  def self.encrypted_parser
11
- enc_string = EncStringTokenType.new()
12
- enc_block = EncBlockTokenType.new()
11
+ enc_string = EncStringTokenType.new
12
+ enc_block = EncBlockTokenType.new
13
13
  Parser.new([enc_string, enc_block])
14
14
  end
15
15
 
16
16
  def self.decrypted_parser
17
- dec_string = DecStringTokenType.new()
18
- dec_block = DecBlockTokenType.new()
17
+ dec_string = DecStringTokenType.new
18
+ dec_block = DecBlockTokenType.new
19
19
  Parser.new([dec_string, dec_block])
20
20
  end
21
21
 
22
22
  def self.hiera_backend_parser
23
- enc_hiera = EncHieraTokenType.new()
23
+ enc_hiera = EncHieraTokenType.new
24
24
  Parser.new([enc_hiera])
25
25
  end
26
26
  end
@@ -32,51 +32,50 @@ class Hiera
32
32
  @token_types = token_types
33
33
  end
34
34
 
35
- def parse text
35
+ def parse(text)
36
36
  parse_scanner(StringScanner.new(text)).reverse
37
37
  end
38
38
 
39
- def parse_scanner s
39
+ def parse_scanner(s)
40
40
  if s.eos?
41
41
  []
42
42
  else
43
43
  # Check if the scanner currently matches a regex
44
- current_match = @token_types.find { |token_type|
44
+ current_match = @token_types.find do |token_type|
45
45
  s.match?(token_type.regex)
46
- }
46
+ end
47
47
 
48
48
  token =
49
- if current_match.nil?
50
- # No regex matches here. Find the earliest match.
51
- next_match_indexes = @token_types.map { |token_type|
52
- next_match = s.check_until(token_type.regex)
53
- if next_match.nil?
54
- nil
55
- else
56
- next_match.length - s.matched.length
57
- end
58
- }.reject { |i| i.nil? }
59
- non_match_size =
60
- if next_match_indexes.length == 0
61
- s.rest_size
62
- else
63
- next_match_indexes.min
64
- end
65
- non_match = s.peek(non_match_size)
66
- # advance scanner
67
- s.pos = s.pos + non_match_size
68
- NonMatchToken.new(non_match)
69
- else
70
- # A regex matches so create a token and do a recursive call with the advanced scanner
71
- current_match.create_token s.scan(current_match.regex)
72
- end
49
+ if current_match.nil?
50
+ # No regex matches here. Find the earliest match.
51
+ next_match_indexes = @token_types.map do |token_type|
52
+ next_match = s.check_until(token_type.regex)
53
+ if next_match.nil?
54
+ nil
55
+ else
56
+ next_match.length - s.matched.length
57
+ end
58
+ end.reject { |i| i.nil? }
59
+ non_match_size =
60
+ if next_match_indexes.length == 0
61
+ s.rest_size
62
+ else
63
+ next_match_indexes.min
64
+ end
65
+ non_match = s.peek(non_match_size)
66
+ # advance scanner
67
+ s.pos = s.pos + non_match_size
68
+ NonMatchToken.new(non_match)
69
+ else
70
+ # A regex matches so create a token and do a recursive call with the advanced scanner
71
+ current_match.create_token s.scan(current_match.regex)
72
+ end
73
73
 
74
- self.parse_scanner(s) << token
74
+ parse_scanner(s) << token
75
75
  end
76
76
  end
77
-
78
77
  end
79
78
  end
80
79
  end
81
80
  end
82
- end
81
+ end
@@ -4,26 +4,32 @@ class Hiera
4
4
  module Parser
5
5
  class TokenType
6
6
  attr_reader :regex
7
+
7
8
  @regex
8
- def create_token string
9
+ def create_token(_string)
9
10
  raise 'Abstract method called'
10
11
  end
11
12
  end
12
13
 
13
14
  class Token
14
15
  attr_reader :match
16
+
15
17
  def initialize(match)
16
18
  @match = match
17
19
  end
18
- def to_encrypted(args={})
20
+
21
+ def to_encrypted(_args = {})
19
22
  raise 'Abstract method called'
20
23
  end
21
- def to_decrypted(args={})
24
+
25
+ def to_decrypted(_args = {})
22
26
  raise 'Abstract method called'
23
27
  end
28
+
24
29
  def to_plain_text
25
30
  raise 'Abstract method called'
26
31
  end
32
+
27
33
  def to_s
28
34
  "#{self.class.name}:#{@match}"
29
35
  end
@@ -33,12 +39,15 @@ class Hiera
33
39
  def initialize(non_match)
34
40
  super(non_match)
35
41
  end
36
- def to_encrypted(args={})
42
+
43
+ def to_encrypted(_args = {})
37
44
  @match
38
45
  end
39
- def to_decrypted(args={})
46
+
47
+ def to_decrypted(_args = {})
40
48
  @match
41
49
  end
50
+
42
51
  def to_plain_text
43
52
  @match
44
53
  end
@@ -46,4 +55,4 @@ class Hiera
46
55
  end
47
56
  end
48
57
  end
49
- end
58
+ end