Skip to content
This repository was archived by the owner on Jul 30, 2021. It is now read-only.

Commit 34e6bfa

Browse files
committed
v1.3.0
fix #5
1 parent 7290e22 commit 34e6bfa

13 files changed

+152
-13
lines changed

Gemfile.lock

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PATH
22
remote: .
33
specs:
4-
tls-map (1.2.0)
4+
tls-map (1.3.0)
55
docopt (~> 0.6)
66
paint (~> 2.2)
77
rexml (~> 3.2)
@@ -44,6 +44,7 @@ GEM
4444
i18n
4545
ruby-progressbar (1.11.0)
4646
unicode-display_width (2.0.0)
47+
webrick (1.7.0)
4748
yard (0.9.26)
4849

4950
PLATFORMS
@@ -59,6 +60,7 @@ DEPENDENCIES
5960
redcarpet (~> 3.5)
6061
rubocop (~> 1.10)
6162
tls-map!
63+
webrick (~> 1.7)
6264
yard (~> 0.9)
6365

6466
BUNDLED WITH

README.md

+3
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,10 @@
2525

2626
- CLI and library
2727
- Search feature: hexadecimal codepoint and major TLS libraries cipher algorithm name: IANA, OpenSSL, GnuTLS, NSS
28+
- get extra info about a cipher
2829
- Export to files: markdown table, expanded JSON, minified JSON, Ruby marshalized hash
30+
- Extract ciphers from external tools file output (SSLyze, sslscan2, testssl.sh, ssllabs-scan)
31+
- Bulk search (file with one cipher per line)
2932

3033
## Installation
3134

bin/tls-map

+16-1
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,14 @@ require 'tls_map/cli'
1010
require 'docopt'
1111
require 'paint'
1212

13+
# can't specify 2 options with the same name even if used in different commands
14+
# https://github.com/docopt/docopt/issues/296#issuecomment-857477191
1315
doc = <<~DOCOPT
1416
TLS map #{TLSmap::VERSION}
1517
1618
Usage:
1719
tls-map search <critera> <term> [-o <output> --force -e -a] [--no-color --debug]
20+
tls-map bulk <critera> <file> [-q <output> --force] [--no-color --debug]
1821
tls-map export <filename> <format> [--force] [--debug]
1922
tls-map extract <filename> <format> [--no-color --debug]
2023
tls-map update [--debug]
@@ -28,6 +31,11 @@ doc = <<~DOCOPT
2831
-e, --extended (Online) Display additional information about the cipher (requires output = all or iana)
2932
-a, --acronym (Online) Display full acronym name (requires -e / --extended option)
3033
34+
Bulk options: (offline) search and translate cipher names between SSL/TLS libraries in bulk
35+
<critera> The type of term. Accepted values: codepoint, iana, openssl, gnutls, nss.
36+
<file> File containing the cipher algorithm names, one per line.
37+
-q, --output2 <output> Displayed fields. Accepted values: codepoint, iana, openssl, gnutls, nss. [default: iana]
38+
3139
Export options: (offline) export the list of all ciphers (mapping) in various formats
3240
<filename> The output file name to write to.
3341
<format> Supported formats: markdown (a markdown table), json_pretty (expanded JSON), json_compact (minified JSON), marshal (Ruby marshalized hash).
@@ -39,7 +47,7 @@ doc = <<~DOCOPT
3947
Update options: (online) DANGEROUS, will break database integrity, force option will be required
4048
4149
Other options:
42-
--force Force parsing even if intigrity check failed (DANGEROUS, may result in command execution vulnerability)
50+
--force Force parsing even if integrity check failed (DANGEROUS, may result in command execution vulnerability)
4351
--no-color Disable colorized output
4452
--debug Display arguments
4553
-h, --help Show this screen
@@ -80,6 +88,13 @@ begin
8088
end
8189
end
8290
end
91+
elsif args['bulk']
92+
cli = TLSmap::CLI.new(args['--force'])
93+
res = cli.bulk_search(args['<critera>'].to_sym, args['<file>'], args['--output2'].to_sym)
94+
puts Paint['No match found', :red] if res.empty?
95+
res.each do |h|
96+
puts "#{Paint[h[args['--output2'].to_sym], :green]}"
97+
end
8398
elsif args['export']
8499
cli = TLSmap::CLI.new(args['--force'])
85100
cli.export(args['<filename>'], args['<format>'].to_sym)

docs/CHANGELOG.md

+11
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,17 @@
22

33
## [Unreleased]
44

5+
## [1.3.0]
6+
7+
Additions:
8+
9+
- add `bulk_search()` method for bulk search (file with one cipher per line)
10+
- new `bulk` CLI command
11+
12+
Documentation:
13+
14+
- add `webrick` in dev dependencies to be able to use `yard server`
15+
516
## [1.2.0]
617

718
Additions:

docs/pages/documentation.md

+12
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ $ npm i docsify-cli -g
1111
$ docsify serve docs
1212
```
1313

14+
Documentation available at: http://localhost:3000/
15+
1416
## Library doc
1517

1618
The output directory of the library documentation will be `docs/yard`.
@@ -24,3 +26,13 @@ For developers who only want to use the library.
2426
```plaintext
2527
$ bundle exec yard doc
2628
```
29+
30+
### Serve locally
31+
32+
Serve with live reload:
33+
34+
```
35+
$ bundle exec yard server --reload
36+
```
37+
38+
Documentation available at: http://localhost:8808/

docs/pages/examples.md

+50-2
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ TLS_AES_256_GCM_SHA384
120120
TLS_CHACHA20_POLY1305_SHA256
121121
TLS_AES_128_GCM_SHA256
122122
123-
$ tls-map extract oldwebsite.json ssllabs-scan
123+
$ tls-map extract oldwebsite.json ssllabs-scan
124124
SSL2.0
125125
SSL_CK_RC4_128_WITH_MD5
126126
SSL_CK_DES_192_EDE3_CBC_WITH_MD5
@@ -152,6 +152,31 @@ word so you have to use the `--force` option every time to bypass the security
152152
check. So it is recommended to not use the update command and wait for official
153153
release.
154154

155+
### Bulk search
156+
157+
Search and translate cipher names between SSL/TLS libraries **in bulk**
158+
159+
`test/file_sample/bulk_IANA.txt`
160+
161+
```
162+
TLS_DH_RSA_WITH_AES_256_CBC_SHA
163+
TLS_RSA_WITH_RC4_128_SHA
164+
TLS_RSA_WITH_AES_128_CBC_SHA
165+
TLS_INVALID
166+
TLS_CHACHA20_POLY1305_SHA256
167+
TLS_AES_256_GCM_SHA384
168+
```
169+
170+
```
171+
$ tls-map bulk iana test/file_sample/bulk_IANA.txt -q openssl
172+
DH-RSA-AES256-SHA
173+
RC4-SHA
174+
AES128-SHA
175+
176+
TLS_CHACHA20_POLY1305_SHA256
177+
TLS_AES_256_GCM_SHA384
178+
```
179+
155180
## Library
156181

157182
Basic usage, searching for cipher name equivalent in other libraries.
@@ -242,7 +267,7 @@ extractor.parse('ssllabs-scan', 'oldwebsite.json')
242267

243268
# Access to all extracted ciphers
244269
extractor.ciphers
245-
=>
270+
=>
246271
# {"SSL2.0"=>["SSL_CK_RC4_128_WITH_MD5", "SSL_CK_DES_192_EDE3_CBC_WITH_MD5"],
247272
# "SSL3.0"=>["TLS_RSA_WITH_3DES_EDE_CBC_SHA", "TLS_RSA_WITH_RC4_128_SHA", "TLS_RSA_WITH_RC4_128_MD5"],
248273
# "TLS1.0"=>
@@ -263,3 +288,26 @@ extractor.ciphers
263288
extractor.ssl20
264289
# => ["SSL_CK_RC4_128_WITH_MD5", "SSL_CK_DES_192_EDE3_CBC_WITH_MD5"]
265290
```
291+
292+
Search and translate cipher names between SSL/TLS libraries **in bulk**:
293+
294+
```ruby
295+
require 'tls_map'
296+
297+
tm = TLSmap::App.new
298+
299+
tm.bulk_search(:iana, 'test/file_sample/bulk_IANA.txt', :openssl)
300+
# => [{:openssl=>"DH-RSA-AES256-SHA"}, {:openssl=>"RC4-SHA"}, {:openssl=>"AES128-SHA"}, {}, {:openssl=>"TLS_CHACHA20_POLY1305_SHA256"}, {:openssl=>"TLS_AES_256_GCM_SHA384"}]
301+
302+
tm.bulk_search(:iana, 'test/file_sample/bulk_IANA.txt', :codepoint)
303+
# => [{:codepoint=>"0037"}, {:codepoint=>"0005"}, {:codepoint=>"002F"}, {}, {:codepoint=>"1303"}, {:codepoint=>"1302"}]
304+
305+
tm.bulk_search(:iana, 'test/file_sample/bulk_IANA.txt')
306+
# =>
307+
# [{:codepoint=>"0037", :iana=>"TLS_DH_RSA_WITH_AES_256_CBC_SHA", :openssl=>"DH-RSA-AES256-SHA", :gnutls=>nil, # :nss=>"TLS_DH_RSA_WITH_AES_256_CBC_SHA"},
308+
# {:codepoint=>"0005", :iana=>"TLS_RSA_WITH_RC4_128_SHA", :openssl=>"RC4-SHA", :gnutls=>"RSA_ARCFOUR_128_SHA1", # :nss=>"TLS_RSA_WITH_RC4_128_SHA"},
309+
# {:codepoint=>"002F", :iana=>"TLS_RSA_WITH_AES_128_CBC_SHA", :openssl=>"AES128-SHA", :gnutls=>"RSA_AES_128_CBC_SHA1", # :nss=>"TLS_RSA_WITH_AES_128_CBC_SHA"},
310+
# {},
311+
# {:codepoint=>"1303", :iana=>"TLS_CHACHA20_POLY1305_SHA256", :openssl=>"TLS_CHACHA20_POLY1305_SHA256", # :gnutls=>"CHACHA20_POLY1305_SHA256", :nss=>"TLS_CHACHA20_POLY1305_SHA256"},
312+
# {:codepoint=>"1302", :iana=>"TLS_AES_256_GCM_SHA384", :openssl=>"TLS_AES_256_GCM_SHA384", :gnutls=>"AES_256_GCM_SHA384", # :nss=>"TLS_AES_256_GCM_SHA384"}]
313+
```

docs/pages/quick-start.md

+8-2
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,11 @@ See [Installation](/pages/install)
1212

1313
```plaintext
1414
$ tls-map --help
15-
TLS map 1.2.0
15+
TLS map 1.3.0
1616
1717
Usage:
1818
tls-map search <critera> <term> [-o <output> --force -e -a] [--no-color --debug]
19+
tls-map bulk <critera> <file> [-q <output> --force] [--no-color --debug]
1920
tls-map export <filename> <format> [--force] [--debug]
2021
tls-map extract <filename> <format> [--no-color --debug]
2122
tls-map update [--debug]
@@ -29,6 +30,11 @@ Search options: (offline) search and translate cipher names between SSL/TLS libr
2930
-e, --extended (Online) Display additional information about the cipher (requires output = all or iana)
3031
-a, --acronym (Online) Display full acronym name (requires -e / --extended option)
3132
33+
Bulk options: (offline) search and translate cipher names between SSL/TLS libraries in bulk
34+
<critera> The type of term. Accepted values: codepoint, iana, openssl, gnutls, nss.
35+
<file> File containing the cipher algorithm names, one per line.
36+
-q, --output2 <output> Displayed fields. Accepted values: codepoint, iana, openssl, gnutls, nss. [default: iana]
37+
3238
Export options: (offline) export the list of all ciphers (mapping) in various formats
3339
<filename> The output file name to write to.
3440
<format> Supported formats: markdown (a markdown table), json_pretty (expanded JSON), json_compact (minified JSON), marshal (Ruby marshalized hash).
@@ -40,7 +46,7 @@ Extract options: (offline) extract ciphers from external tools output file
4046
Update options: (online) DANGEROUS, will break database integrity, force option will be required
4147
4248
Other options:
43-
--force Force parsing even if intigrity check failed (DANGEROUS, may result in command execution vulnerability)
49+
--force Force parsing even if integrity check failed (DANGEROUS, may result in command execution vulnerability)
4450
--no-color Disable colorized output
4551
--debug Display arguments
4652
-h, --help Show this screen

docs/pages/usage.md

+8-2
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@
44

55
```plaintext
66
$ tls-map --help
7-
TLS map 1.2.0
7+
TLS map 1.3.0
88
99
Usage:
1010
tls-map search <critera> <term> [-o <output> --force -e -a] [--no-color --debug]
11+
tls-map bulk <critera> <file> [-q <output> --force] [--no-color --debug]
1112
tls-map export <filename> <format> [--force] [--debug]
1213
tls-map extract <filename> <format> [--no-color --debug]
1314
tls-map update [--debug]
@@ -21,6 +22,11 @@ Search options: (offline) search and translate cipher names between SSL/TLS libr
2122
-e, --extended (Online) Display additional information about the cipher (requires output = all or iana)
2223
-a, --acronym (Online) Display full acronym name (requires -e / --extended option)
2324
25+
Bulk options: (offline) search and translate cipher names between SSL/TLS libraries in bulk
26+
<critera> The type of term. Accepted values: codepoint, iana, openssl, gnutls, nss.
27+
<file> File containing the cipher algorithm names, one per line.
28+
-q, --output2 <output> Displayed fields. Accepted values: codepoint, iana, openssl, gnutls, nss. [default: iana]
29+
2430
Export options: (offline) export the list of all ciphers (mapping) in various formats
2531
<filename> The output file name to write to.
2632
<format> Supported formats: markdown (a markdown table), json_pretty (expanded JSON), json_compact (minified JSON), marshal (Ruby marshalized hash).
@@ -32,7 +38,7 @@ Extract options: (offline) extract ciphers from external tools output file
3238
Update options: (online) DANGEROUS, will break database integrity, force option will be required
3339
3440
Other options:
35-
--force Force parsing even if intigrity check failed (DANGEROUS, may result in command execution vulnerability)
41+
--force Force parsing even if integrity check failed (DANGEROUS, may result in command execution vulnerability)
3642
--no-color Disable colorized output
3743
--debug Display arguments
3844
-h, --help Show this screen

lib/tls_map.rb

+17
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,23 @@ def search(critera, term, output = :all)
5555
{}
5656
end
5757

58+
# Search for corresponding cipher algorithms in other libraries in bulk
59+
# @param critera [Symbol] The type of `term`.
60+
# Accepted values: `:codepoint`, `:iana`, `:openssl`, `:gnutls`, `:nss`.
61+
# @param file [String] File containing the cipher algorithm names, one per line.
62+
# @param output [Symbol] The corresponding type to be included in the return value.
63+
# Accepted values: `:all` (default), `:codepoint`, `:iana`, `:openssl`,
64+
# `:gnutls`, `:nss`.
65+
# @return [Array<Hash>] The corresponding type, same as {search} return value
66+
# but one per line stored in an array.
67+
def bulk_search(critera, file, output = :all)
68+
res = []
69+
File.foreach(file) do |line|
70+
res.push(search(critera, line.chomp, output))
71+
end
72+
res
73+
end
74+
5875
protected :parse
5976
end
6077
end

lib/tls_map/version.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# frozen_string_literal: true
22

33
module TLSmap
4-
VERSION = '1.2.0'
4+
VERSION = '1.3.0'
55
end

test/file_sample/bulk_IANA.txt

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
TLS_DH_RSA_WITH_AES_256_CBC_SHA
2+
TLS_RSA_WITH_RC4_128_SHA
3+
TLS_RSA_WITH_AES_128_CBC_SHA
4+
TLS_INVALID
5+
TLS_CHACHA20_POLY1305_SHA256
6+
TLS_AES_256_GCM_SHA384

test/test_app.rb

+12
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,18 @@ def test_App_search
1717
assert_equal({:codepoint=>"1302", :iana=>"TLS_AES_256_GCM_SHA384", :openssl=>"TLS_AES_256_GCM_SHA384", :gnutls=>"AES_256_GCM_SHA384", :nss=>"TLS_AES_256_GCM_SHA384"}, @tm.search(:nss, 'TLS_AES_256_GCM_SHA384'))
1818
end
1919

20+
def test_App_bulk_search
21+
res = @tm.bulk_search(:iana, 'test/file_sample/bulk_IANA.txt', :openssl)
22+
assert_equal({:openssl=>"DH-RSA-AES256-SHA"}, res[0])
23+
assert_equal({:openssl=>"RC4-SHA"}, res[1])
24+
assert_equal({:openssl=>"AES128-SHA"}, res[2])
25+
assert_equal({}, res[3])
26+
res = @tm.bulk_search(:iana, 'test/file_sample/bulk_IANA.txt', :codepoint)
27+
assert_equal({:codepoint=>"1303"}, res[4])
28+
res = @tm.bulk_search(:iana, 'test/file_sample/bulk_IANA.txt', :iana)
29+
assert_equal({:iana=>"TLS_AES_256_GCM_SHA384"}, res[5])
30+
end
31+
2032
def test_App_export
2133
formats = [:markdown, :json_pretty, :json_compact, :marshal]
2234
formats.each do |format|

tls-map.gemspec

+5-4
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,11 @@ Gem::Specification.new do |s|
3636
s.add_development_dependency('bundler', ['>= 2.1.0', '< 2.3'])
3737
s.add_development_dependency('commonmarker', '~> 0.21') # for GMF support in YARD
3838
s.add_development_dependency('github-markup', '~> 4.0') # for GMF support in YARD
39-
s.add_development_dependency('minitest', '~> 5.12')
40-
s.add_development_dependency('minitest-skip', '~> 0.0')
41-
s.add_development_dependency('rake', '~> 13.0')
39+
s.add_development_dependency('minitest', '~> 5.12') # unit tests
40+
s.add_development_dependency('minitest-skip', '~> 0.0') # skip dummy tests
41+
s.add_development_dependency('rake', '~> 13.0') # used to run tests
4242
s.add_development_dependency('redcarpet', '~> 3.5') # for GMF support in YARD
43-
s.add_development_dependency('rubocop', '~> 1.10')
43+
s.add_development_dependency('rubocop', '~> 1.10') # lint
44+
s.add_development_dependency('webrick', '~> 1.7') # for server support in YARD
4445
s.add_development_dependency('yard', '~> 0.9')
4546
end

0 commit comments

Comments
 (0)