dtk_crd_parser 0.0.67 → 0.0.68

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 44c9c34cc93408e2bd39b9f98cde56fec64eef1f596a47efabbc692b9608a86a
4
- data.tar.gz: 2f4acb8053c767b161833244a4bb057e0d1a7d6922d00cb985af49f33a0531ca
3
+ metadata.gz: 11862b237aaa9dab2d427d6fa6c8573ca54c6b268a7cfd85167ac052f396a1f5
4
+ data.tar.gz: f3778731ef916f039ca0b4d46ed1ed0a4ecb421238f6bad4f8270dec8a6a6fab
5
5
  SHA512:
6
- metadata.gz: bad65cd3743b2b6e66e220a2ad69620368ec7000eb56d7c7587c8d246aaa806c7fed7f76cc82f99e19720798afdf89ffb10e30306cbde8946154508bcd032249
7
- data.tar.gz: 77fe983b615d17f25e748378c7edc4a715803e2a6dc71248b6948bd344215a416040872b7690f12b7f7d99ef9d5915b91053d2180a1dc24f17a869a93f05435a
6
+ metadata.gz: 1818b9dc2435384bfea09fc611af55eeb5538325014f10f8441aade6cc02f6da7f13afb646f9637cf2f82e7ac252fa823503ab22abbede296901bb783560dc9b
7
+ data.tar.gz: 96c614515764afd9a154c6cda23fa4c67a6d7b61a9524214f00133b24f4accf7bc77e2b825fe0c97f58dc6e4b42a383309f87c1064284a48057b20d767860a45
@@ -26,6 +26,19 @@ module DTK::CrdParser
26
26
  end
27
27
  fail "#{the_method} is not defined in the concrete class #{klass}"
28
28
  end
29
+
30
+ def decrypt_if_encrypted(data_to_decrypt, decrypt)
31
+ return nil unless data_to_decrypt
32
+ return data_to_decrypt unless decrypt
33
+ decipher = OpenSSL::Cipher::AES256.new :CBC
34
+ decipher.decrypt
35
+ decipher.iv = Base64.decode64('6aU8K0GsLXQcaDZP+bOMjw==') # previously saved
36
+ decipher.key = 'ThisPasswordIsReallyHardToGuess!'
37
+ plain_text = decipher.update(Base64.decode64(data_to_decrypt)) + decipher.final
38
+ puts "Decrypted: #{plain_text}"
39
+ plaintext
40
+ end
41
+
29
42
  end
30
43
  end
31
44
  end
@@ -4,13 +4,13 @@ module DTK::CrdParser
4
4
 
5
5
  attr_reader :name, :value
6
6
 
7
- def initialize(name, value)
7
+ def initialize(name, value, params = {})
8
8
  @name = fail_if_nil(name, 'Attribute.name')
9
- @value = fail_if_nil(value, 'Attribute.value')
9
+ @value = fail_if_nil(decrypt_if_encrypted(value, params[:encrypted]), 'Attribute.value')
10
10
  end
11
11
 
12
- def self.create_from_kube(attribute_name, attribute_value)
13
- Attribute.new(attribute_name, attribute_value)
12
+ def self.create_from_kube(attribute_name, attribute_value, params)
13
+ Attribute.new(attribute_name, attribute_value, params)
14
14
  end
15
15
 
16
16
  end
@@ -22,7 +22,11 @@ module DTK::CrdParser
22
22
  attributes = []
23
23
  if component_attributes
24
24
  component_attributes.to_hash.each do |attribute_name, attribute_value|
25
- attributes.push Attribute.create_from_kube(attribute_name, attribute_value)
25
+
26
+ encrypted = component_def[:attribute_type_info].select { |attribute|
27
+ attribute[:name] == attribute_name
28
+ }.first[:encrypted] || false
29
+ attributes.push Attribute.create_from_kube(attribute_name, attribute_value, {encrypted: encrypted})
26
30
  end
27
31
  end
28
32
  Component.new(component_name, component_def, attributes)
@@ -7,8 +7,9 @@ module DTK::CrdParser
7
7
  def initialize(params)
8
8
  @name = params[:name]
9
9
  @type = params[:type]
10
- @required = params[:required] || false
11
- @dynamic = params[:dynamic] || false
10
+ @required = params[:required] || false
11
+ @dynamic = params[:dynamic] || false
12
+ @encrypted = params[:encrypted] || false
12
13
  end
13
14
 
14
15
  def self.resolveAttr(attribute)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dtk_crd_parser
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.67
4
+ version: 0.0.68
5
5
  platform: ruby
6
6
  authors:
7
7
  - DTK