Class: TLSmap::App::Extractor::Testssl
- Inherits:
-
Object
- Object
- TLSmap::App::Extractor::Testssl
- Defined in:
- lib/tls_map/app/extractor/extractor.rb
Overview
Parsing testssl.sh
Class Method Summary collapse
-
.extract_cipher(json_data) ⇒ Array<String>
Extract the ciphers from the testssl output file.
-
.finding2cipher(finding) ⇒ String
Extract the cipher name from testssl finding.
-
.id2prot(id) ⇒ String
Convert testssl protocol id to protocol name in TLSmap format.
-
.parse(file) ⇒ Array<String>
Extract the ciphers from the testssl output file.
Class Method Details
.extract_cipher(json_data) ⇒ Array<String>
Extract the ciphers from the testssl output file
199 200 201 202 203 204 205 206 207 208 209 |
# File 'lib/tls_map/app/extractor/extractor.rb', line 199 def extract_cipher(json_data) cipher = json_data['scanResult'][0]['cipherTests'] raw = { 'SSL2.0' => [], 'SSL3.0' => [], 'TLS1.0' => [], 'TLS1.1' => [], 'TLS1.2' => [], 'TLS1.3' => [] } cipher.each do |node| raw[id2prot(node['id'])].push(finding2cipher(node['finding'])) end raw end |
.finding2cipher(finding) ⇒ String
Extract the cipher name from testssl finding
226 227 228 |
# File 'lib/tls_map/app/extractor/extractor.rb', line 226 def finding2cipher(finding) /\s(\w+_\w+)\s/.match(finding).captures[0] end |
.id2prot(id) ⇒ String
Convert testssl protocol id to protocol name in TLSmap format
214 215 216 217 218 219 220 221 |
# File 'lib/tls_map/app/extractor/extractor.rb', line 214 def id2prot(id) prot = { 'ssl2' => 'SSL2.0', 'ssl3' => 'SSL3.0', 'tls1' => 'TLS1.0', 'tls1_1' => 'TLS1.1', 'tls1_2' => 'TLS1.2', 'tls1_3' => 'TLS1.3' } protv = id.match(/cipher-(\w+)_x\w+/).captures[0] prot[protv] end |
.parse(file) ⇒ Array<String>
Extract the ciphers from the testssl output file
191 192 193 194 |
# File 'lib/tls_map/app/extractor/extractor.rb', line 191 def parse(file) data = Utils.json_load_file(file) extract_cipher(data) end |