tls-map 3.3.0 → 3.4.0

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: b443ebf598bbf3d9bdf2b8073a7bf6b0ed3e554c217a20129f5c1cf5e81e134e
4
- data.tar.gz: a46ee605748e824d219103d2dce0a319ea7e6101f373dd5237459f3cfbc20e1c
3
+ metadata.gz: 38d19c493782c2c924f851de6042244682ce65fee3e84ceb96c799691d2dddc8
4
+ data.tar.gz: 845222c2d50a1371ea35a7921c56094d083e9837cb5c7527b235afb3898c2570
5
5
  SHA512:
6
- metadata.gz: da54cb68f0964eb013a7425c870c94664cda381dc6486c9cc356c1b6ffe2a93471c7fb1f2d0bf49d0fe6e61c92d0e72f09e568bff4bce73daecf63bd1d04a46f
7
- data.tar.gz: b5b726048d4173adc23f268a4e77aeaec744fb3261642613de961cc6d7d945593ea8b4945a00d2c7a5f5cbbdc9987d9d72ec8c6037cae126456de849b8a146f2
6
+ metadata.gz: 386e48f96fb817faef6edef0ca05ed1a62f2ea13d64b772f7b77fd56971b08e93488daffaa7a108b8582f444482b033a67e41175153d717673e25bc1d6dbbe42
7
+ data.tar.gz: 701dc705ad5ca0039554a46b846f1af83885afd5f5479d155a6daa550ebc128ec6c07c96946729b36419dfc3ef8c2e7949c8e8342f389718757ecbae2cf4d019
data/bin/tls-map CHANGED
@@ -78,18 +78,20 @@ begin
78
78
  ext.each do |k, v|
79
79
  case k
80
80
  when 'vulns'
81
- puts "#{Paint[dic[k], :magenta]}:"
81
+ puts "#{Paint[dic[k][:display], :magenta]}:"
82
82
  v.each do |vuln|
83
- print " - #{Paint[sev[vuln[:severity]][:title], sev[vuln[:severity]][:color]]} - "
83
+ print " - #{Paint[vuln[:name], :magenta]} "
84
+ print "(#{Paint[sev[vuln[:severity]][:title], sev[vuln[:severity]][:color]]}): "
84
85
  puts Paint[vuln[:description], :white]
85
86
  end
86
87
  when 'tls_version'
87
- puts "#{Paint[dic[k], :magenta]}: #{Paint[v.join(', '), :white]}"
88
+ puts "#{Paint[dic[k][:display], :magenta]}: #{Paint[v.join(', '), :white]}"
88
89
  when 'security'
89
- puts "#{Paint[dic[k], :magenta]}: #{Paint[v, sec_lvl[v][:color]]}"
90
+ puts "#{Paint[dic[k][:display], :magenta]}: #{Paint[v, sec_lvl[v][:color]]}"
90
91
  else
91
- print "#{Paint[dic[k], :magenta]}: #{Paint[v, :white]}"
92
- print " (#{tmext_i.translate_acronym(v)})" if args['--acronym'] && !tmext_i.translate_acronym(v).nil?
92
+ print "#{Paint[dic[k][:display], :magenta]}: #{Paint[v, :white]}"
93
+ term = dic[k][:model] ? dic[k][:model] + v : nil # rubocop:disable Metrics/BlockNesting
94
+ print " (#{tmext_i.translate_acronym(term)})" if args['--acronym'] && !tmext_i.translate_acronym(term).nil?
93
95
  puts
94
96
  end
95
97
  end
Binary file
@@ -17,7 +17,7 @@ module TLSmap
17
17
  # - https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.0.md
18
18
  # - https://ciphersuite.info/api/
19
19
  # - https://github.com/hcrudolph/ciphersuite.info
20
- class Extended
20
+ class Extended # rubocop:disable Metrics/ClassLength
21
21
  # Root URL of Cipher Suite Info
22
22
  ROOT = 'https://ciphersuite.info/'
23
23
  # Root URL of Cipher Suite Info API
@@ -26,17 +26,32 @@ module TLSmap
26
26
  VULN_DATA = 'https://raw.githubusercontent.com/hcrudolph/ciphersuite.info/master/directory/fixtures/00_vulnerabilities.yaml'
27
27
  # URL of the data file containing technologies information
28
28
  TECH_DATA = 'https://raw.githubusercontent.com/hcrudolph/ciphersuite.info/master/directory/fixtures/01_technologies.yaml'
29
- # Hash mapping API key and display name for CLI
29
+ # Hash mapping API key and display name for CLI (`:display`) and model name in `01_technologies.yaml` (`:model`)
30
30
  DICO = {
31
- 'tls_version' => 'TLS Version(s)',
32
- 'protocol_version' => 'Protocol',
33
- 'kex_algorithm' => 'Key Exchange',
34
- 'auth_algorithm' => 'Authentication',
35
- 'enc_algorithm' => 'Encryption',
36
- 'hash_algorithm' => 'Hash',
37
- 'security' => 'Security',
38
- 'url' => 'More info',
39
- 'vulns' => 'Vulnerabilities'
31
+ 'tls_version' => { display: 'TLS Version(s)' },
32
+ 'protocol_version' => {
33
+ display: 'Protocol',
34
+ model: 'ProtocolVersion'
35
+ },
36
+ 'kex_algorithm' => {
37
+ display: 'Key Exchange',
38
+ model: 'KexAlgorithm'
39
+ },
40
+ 'auth_algorithm' => {
41
+ display: 'Authentication',
42
+ model: 'AuthAlgorithm'
43
+ },
44
+ 'enc_algorithm' => {
45
+ display: 'Encryption',
46
+ model: 'EncAlgorithm'
47
+ },
48
+ 'hash_algorithm' => {
49
+ display: 'Hash',
50
+ model: 'HashAlgorithm'
51
+ },
52
+ 'security' => { display: 'Security' },
53
+ 'url' => { display: 'More info' },
54
+ 'vulns' => { display: 'Vulnerabilities' }
40
55
  }.freeze
41
56
  # Hash mapping the severity number used by the API and the severity text and color for the CLI
42
57
  VULN_SEVERITY = {
@@ -91,7 +106,8 @@ module TLSmap
91
106
  # @param caching [Boolean] if true will fetch info for all cipher suites the 1st time and used the cached value
92
107
  # for further requests
93
108
  # @return [Hash] Hash containing advanced information. The keys are the same as {DICO}. All values are string
94
- # except `vulns` which is an array of hashes containing two keys: `:severity` (integer) and `:description`
109
+ # except `vulns` which is an array of hashes containing three keys: `:severity` (integer), `:name` and
110
+ # `:description`.
95
111
  # (string). Each hash in `vulns` correspond to a vulnerability.
96
112
  def extend(iana_name, caching = false) # rubocop:disable Metrics/MethodLength
97
113
  if caching
@@ -107,8 +123,12 @@ module TLSmap
107
123
  %w[openssl_name gnutls_name hex_byte_1 hex_byte_2].each do |key|
108
124
  out.delete(key)
109
125
  end
110
- out.each_value do |v|
111
- out['vulns'].push(find_vuln(v)) if @tech.keys.include?(v)
126
+ out.each do |k, v|
127
+ # '' fallback since out is not containing only algorithms
128
+ # else calling `:model` in DICO will return nil and make the concatenation fail
129
+ # this handling is more explicit that using interpolation that will silently handle nil
130
+ alg_index = DICO[k][:model] ? DICO[k][:model] + v : ''
131
+ out['vulns'].push(find_vuln(alg_index)) if @tech.keys.include?(alg_index)
112
132
  end
113
133
  out['vulns'].flatten!
114
134
  out['vulns'].uniq!
@@ -116,30 +136,35 @@ module TLSmap
116
136
  out
117
137
  end
118
138
 
119
- # Extract data from the YAML file ({TECH_DATA}) to craft a simplified Ruby hash
139
+ # Extract data from the YAML file ({TECH_DATA}) to craft a simplified Ruby hash.
140
+ # Note: The index key changed in 3.4.0.
120
141
  def parse_tech
121
142
  data = Psych.load_file(@tech_file)
122
143
  out = {}
123
144
  data.each do |item|
124
- out.store(item['pk'], { long_name: item['fields']['long_name'],
125
- vulnerabilities: item['fields']['vulnerabilities'] })
145
+ index_key = item['model'].delete_prefix('directory.') + item['pk']
146
+ out.store(index_key, { long_name: item['fields']['long_name'],
147
+ vulnerabilities: item['fields']['vulnerabilities'] })
126
148
  end
127
149
  out
128
150
  end
129
151
 
130
152
  # Extract data from the YAML file ({VULN_DATA}) to craft a simplified Ruby hash
153
+ # Note: also store name even if equal to key because find_vuln() will return only the value hash
131
154
  def parse_vuln
132
155
  data = Psych.load_file(@vuln_file)
133
156
  out = {}
134
157
  data.each do |item|
135
- out.store(item['pk'], { severity: item['fields']['severity'],
158
+ out.store(item['pk'], { name: item['pk'],
159
+ severity: item['fields']['severity'],
136
160
  description: item['fields']['description'] })
137
161
  end
138
162
  out
139
163
  end
140
164
 
141
165
  # Translate cipher related acronyms
142
- # @param term [String] Acronym, eg. DSS
166
+ # @param term [String] Acronym, eg. DSS and algorithm type. Based on `01_technologies.yaml`,
167
+ # this would be the last part of `model` + `pk`. The model value is mapped in {DICO} under the `:model` sub-key.
143
168
  # @return [String] The long name of the acronym, eg. Digital Signature Standard or `nil` if it's not found
144
169
  def translate_acronym(term)
145
170
  return @tech[term][:long_name] unless @tech[term].nil?
@@ -148,7 +173,8 @@ module TLSmap
148
173
  end
149
174
 
150
175
  # Find vulnerabilities related to a technology
151
- # @param tech [String] The technology acronym, eg. CBC
176
+ # @param tech [String] The technology acronym, eg. CBC and algorithm type. Based on `01_technologies.yaml`,
177
+ # this would be the last part of `model` + `pk`. The model value is mapped in {DICO} under the `:model` sub-key.
152
178
  # @return [Array<Hash>] Array of vulnerabilities as described for {extend} return value in the `vulns` key.
153
179
  def find_vuln(tech)
154
180
  return @tech[tech][:vulnerabilities].map { |vuln| @vuln[vuln] } unless @tech[tech][:vulnerabilities].nil?
@@ -123,7 +123,7 @@ module TLSmap
123
123
  # See {TLSmap::App::Extractor}
124
124
  # @return [Array<String>] Cipher array (IANA names)
125
125
  def parse(file)
126
- data = Utils.json_load_file(file)
126
+ data = JSON.load_file(file)
127
127
  extract_cipher(data)
128
128
  end
129
129
 
@@ -155,7 +155,7 @@ module TLSmap
155
155
  # See {TLSmap::App::Extractor}
156
156
  # @return [Array<String>] Cipher array (IANA names)
157
157
  def parse(file)
158
- data = Utils.json_load_file(file)
158
+ data = JSON.load_file(file)
159
159
  extract_cipher(data)
160
160
  end
161
161
 
@@ -222,7 +222,7 @@ module TLSmap
222
222
  # See {TLSmap::App::Extractor}
223
223
  # @return [Array<String>] Cipher array (IANA names)
224
224
  def parse(file)
225
- data = Utils.json_load_file(file)
225
+ data = JSON.load_file(file)
226
226
  extract_cipher(data)
227
227
  end
228
228
 
@@ -276,7 +276,7 @@ module TLSmap
276
276
  # See {TLSmap::App::Extractor}
277
277
  # @return [Array<String>] Cipher array (IANA names)
278
278
  def parse(file)
279
- data = Utils.json_load_file(file)
279
+ data = JSON.load_file(file)
280
280
  extract_cipher(data)
281
281
  end
282
282
 
@@ -321,7 +321,7 @@ module TLSmap
321
321
  # See {TLSmap::App::Extractor}
322
322
  # @return [Array<String>] Cipher array (IANA names)
323
323
  def parse(file)
324
- data = Utils.json_load_file(file)
324
+ data = JSON.load_file(file)
325
325
  extract_cipher(data)
326
326
  end
327
327
 
@@ -56,7 +56,7 @@ module TLSmap
56
56
 
57
57
  # Offline version of {App::Extended}
58
58
  class Extended < App::Extended
59
- INTEGRITY = '5a1beef438f81b819ef3e3bba1baea9bfbccc665bde4308b87a9f155eebedbef' # sha2-256
59
+ INTEGRITY = '257e81b3b0565e1025b0e066ce7412812b062ad63125a7dce64d29f10a6c2e65' # sha2-256
60
60
 
61
61
  # Load and parse data from marshalized hash (`data/extended.marshal`).
62
62
  # It must match the integrity check for security purpose.
@@ -15,15 +15,5 @@ module TLSmap
15
15
  tmp.close
16
16
  tmp
17
17
  end
18
-
19
- # bring JSON.load_file before ruby 3.0.0
20
- # https://ruby-doc.org/stdlib-3.0.0/libdoc/json/rdoc/JSON.html#method-i-load_file
21
- def self.json_load_file(filespec, opts = {})
22
- if RUBY_VERSION < '3.0.0'
23
- JSON.parse(File.read(filespec), opts)
24
- else
25
- JSON.load_file(filespec, opts)
26
- end
27
- end
28
18
  end
29
19
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module TLSmap
4
- VERSION = '3.3.0'
4
+ VERSION = '3.4.0'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tls-map
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.3.0
4
+ version: 3.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexandre ZANNI
@@ -37,6 +37,26 @@ dependencies:
37
37
  - - "~>"
38
38
  - !ruby/object:Gem::Version
39
39
  version: '0.6'
40
+ - !ruby/object:Gem::Dependency
41
+ name: json
42
+ requirement: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: 2.7.1
47
+ - - "<"
48
+ - !ruby/object:Gem::Version
49
+ version: '4.0'
50
+ type: :runtime
51
+ prerelease: false
52
+ version_requirements: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ version: 2.7.1
57
+ - - "<"
58
+ - !ruby/object:Gem::Version
59
+ version: '4.0'
40
60
  - !ruby/object:Gem::Dependency
41
61
  name: paint
42
62
  requirement: !ruby/object:Gem::Requirement