diff --git a/bin/tls-map b/bin/tls-map index 5efbb0b..3844991 100755 --- a/bin/tls-map +++ b/bin/tls-map @@ -5,7 +5,7 @@ require 'pp' # Project internal require 'tls_map' -require 'tls_map/cli' +require 'tls_map/cli/cli' # External require 'docopt' require 'paint' diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 456dad9..dd149b9 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -1,6 +1,12 @@ # Changelog -## [Unreleased] +## [2.0.0] + +**BREAKING CHANGES:** + +- More modular file architecture in `lib` + - It shouldn't change anything from user perspective (CLI & lib) + - It will change the `require` path for people who want to develop on tls-map or that use some fragments of the library Additions: diff --git a/docs/yard/TLSmap.html b/docs/yard/TLSmap.html index 0bb3085..212038c 100644 --- a/docs/yard/TLSmap.html +++ b/docs/yard/TLSmap.html @@ -79,7 +79,7 @@
Defined in:
lib/tls_map.rb,
- lib/tls_map/cli.rb,
lib/tls_map/nss.rb,
lib/tls_map/iana.rb,
lib/tls_map/utils.rb,
lib/tls_map/gnutls.rb,
lib/tls_map/output.rb,
lib/tls_map/openssl.rb,
lib/tls_map/version.rb,
lib/tls_map/extractor.rb,
lib/tls_map/ciphersuiteinfo.rb
+ lib/tls_map/cipher.rb,
lib/tls_map/app/nss.rb,
lib/tls_map/cli/cli.rb,
lib/tls_map/version.rb,
lib/tls_map/app/iana.rb,
lib/tls_map/app/gnutls.rb,
lib/tls_map/app/output.rb,
lib/tls_map/app/openssl.rb,
lib/tls_map/utils/utils.rb,
lib/tls_map/app/extractor/extractor.rb,
lib/tls_map/app/extended/ciphersuiteinfo.rb
@@ -135,7 +135,7 @@

diff --git a/docs/yard/TLSmap/App.html b/docs/yard/TLSmap/App.html index d9d3e9a..eb8c774 100644 --- a/docs/yard/TLSmap/App.html +++ b/docs/yard/TLSmap/App.html @@ -95,7 +95,7 @@
Defined in:
lib/tls_map.rb,
- lib/tls_map/nss.rb,
lib/tls_map/iana.rb,
lib/tls_map/gnutls.rb,
lib/tls_map/output.rb,
lib/tls_map/openssl.rb,
lib/tls_map/extractor.rb,
lib/tls_map/ciphersuiteinfo.rb
+ lib/tls_map/cipher.rb,
lib/tls_map/app/nss.rb,
lib/tls_map/app/iana.rb,
lib/tls_map/app/gnutls.rb,
lib/tls_map/app/output.rb,
lib/tls_map/app/openssl.rb,
lib/tls_map/app/extractor/extractor.rb,
lib/tls_map/app/extended/ciphersuiteinfo.rb
@@ -540,7 +540,7 @@

49 -
# File 'lib/tls_map/output.rb', line 41
+      
# File 'lib/tls_map/app/output.rb', line 41
 
 def export(filename, format)
   case format
@@ -686,7 +686,7 @@ 

diff --git a/docs/yard/TLSmap/App/Extended.html b/docs/yard/TLSmap/App/Extended.html index 1f81431..079ce23 100644 --- a/docs/yard/TLSmap/App/Extended.html +++ b/docs/yard/TLSmap/App/Extended.html @@ -94,7 +94,7 @@
Defined in:
-
lib/tls_map/ciphersuiteinfo.rb
+
lib/tls_map/app/extended/ciphersuiteinfo.rb
@@ -231,6 +231,26 @@

2 => { title: 'High', color: :red } }.freeze

+
SECURITY_LEVEL = +
+
+

Hash mapping the security level used by the API and color for the CLI

+ + +
+
+
+ + +
+
+
{
+  'recommended' => { color: :green },
+  'secure' => { color: :green },
+  'weak' => { color: 'orange' },
+  'insecure' => { color: :red }
+}.freeze
+ @@ -373,15 +393,15 @@

 
 
-49
-50
-51
-52
-53
-54
+56 +57 +58 +59 +60 +61

-
# File 'lib/tls_map/ciphersuiteinfo.rb', line 49
+      
# File 'lib/tls_map/app/extended/ciphersuiteinfo.rb', line 56
 
 def initialize
   @tech_file = Utils.tmpfile('tech', TECH_DATA)
@@ -464,13 +484,6 @@ 

 
 
-61
-62
-63
-64
-65
-66
-67
 68
 69
 70
@@ -478,10 +491,17 @@ 

72 73 74 -75

+75 +76 +77 +78 +79 +80 +81 +82

-
# File 'lib/tls_map/ciphersuiteinfo.rb', line 61
+      
# File 'lib/tls_map/app/extended/ciphersuiteinfo.rb', line 68
 
 def extend(iana_name) # rubocop:disable Metrics/MethodLength
   obj = Net::HTTP.get(URI("#{API_ROOT}cs/#{iana_name}/"))
@@ -564,14 +584,14 @@ 

 
 
-111
-112
-113
-114
-115
+118 +119 +120 +121 +122

-
# File 'lib/tls_map/ciphersuiteinfo.rb', line 111
+      
# File 'lib/tls_map/app/extended/ciphersuiteinfo.rb', line 118
 
 def find_vuln(tech)
   return @tech[tech][:vulnerabilities].map { |vuln| @vuln[vuln] } unless @tech[tech][:vulnerabilities].nil?
@@ -644,14 +664,14 @@ 

 
 
-102
-103
-104
-105
-106
+109 +110 +111 +112 +113

-
# File 'lib/tls_map/ciphersuiteinfo.rb', line 102
+      
# File 'lib/tls_map/app/extended/ciphersuiteinfo.rb', line 109
 
 def translate_acronym(term)
   return @tech[term][:long_name] unless @tech[term].nil?
@@ -668,7 +688,7 @@ 

diff --git a/docs/yard/TLSmap/App/Extractor.html b/docs/yard/TLSmap/App/Extractor.html index 20ed47f..1900462 100644 --- a/docs/yard/TLSmap/App/Extractor.html +++ b/docs/yard/TLSmap/App/Extractor.html @@ -94,7 +94,7 @@
Defined in:
-
lib/tls_map/extractor.rb
+
lib/tls_map/app/extractor/extractor.rb
@@ -412,7 +412,7 @@

38

-
# File 'lib/tls_map/extractor.rb', line 36
+      
# File 'lib/tls_map/app/extractor/extractor.rb', line 36
 
 def initialize
   @ciphers = []
@@ -476,7 +476,7 @@ 

35

-
# File 'lib/tls_map/extractor.rb', line 33
+      
# File 'lib/tls_map/app/extractor/extractor.rb', line 33
 
 def ciphers
   @ciphers
@@ -577,7 +577,7 @@ 

85

-
# File 'lib/tls_map/extractor.rb', line 80
+      
# File 'lib/tls_map/app/extractor/extractor.rb', line 80
 
 def parse(tool, file)
   # Convert string to class
@@ -637,7 +637,7 @@ 

44

-
# File 'lib/tls_map/extractor.rb', line 42
+      
# File 'lib/tls_map/app/extractor/extractor.rb', line 42
 
 def ssl20
   @ciphers['SSL2.0']
@@ -694,7 +694,7 @@ 

50

-
# File 'lib/tls_map/extractor.rb', line 48
+      
# File 'lib/tls_map/app/extractor/extractor.rb', line 48
 
 def ssl30
   @ciphers['SSL3.0']
@@ -751,7 +751,7 @@ 

56

-
# File 'lib/tls_map/extractor.rb', line 54
+      
# File 'lib/tls_map/app/extractor/extractor.rb', line 54
 
 def tls10
   @ciphers['TLS1.0']
@@ -808,7 +808,7 @@ 

62

-
# File 'lib/tls_map/extractor.rb', line 60
+      
# File 'lib/tls_map/app/extractor/extractor.rb', line 60
 
 def tls11
   @ciphers['TLS1.1']
@@ -865,7 +865,7 @@ 

68

-
# File 'lib/tls_map/extractor.rb', line 66
+      
# File 'lib/tls_map/app/extractor/extractor.rb', line 66
 
 def tls12
   @ciphers['TLS1.2']
@@ -922,7 +922,7 @@ 

74

-
# File 'lib/tls_map/extractor.rb', line 72
+      
# File 'lib/tls_map/app/extractor/extractor.rb', line 72
 
 def tls13
   @ciphers['TLS1.3']
@@ -937,7 +937,7 @@ 

diff --git a/docs/yard/TLSmap/App/Extractor/SsllabsScan.html b/docs/yard/TLSmap/App/Extractor/SsllabsScan.html index c1becc0..ddc9399 100644 --- a/docs/yard/TLSmap/App/Extractor/SsllabsScan.html +++ b/docs/yard/TLSmap/App/Extractor/SsllabsScan.html @@ -94,7 +94,7 @@
Defined in:
-
lib/tls_map/extractor.rb
+
lib/tls_map/app/extractor/extractor.rb
@@ -279,7 +279,7 @@

258

-
# File 'lib/tls_map/extractor.rb', line 245
+      
# File 'lib/tls_map/app/extractor/extractor.rb', line 245
 
 def extract_cipher(json_data) # rubocop:disable Metrics/MethodLength
   raw = {
@@ -370,7 +370,7 @@ 

269

-
# File 'lib/tls_map/extractor.rb', line 263
+      
# File 'lib/tls_map/app/extractor/extractor.rb', line 263
 
 def id2prot(id)
   prot = {
@@ -452,7 +452,7 @@ 

240

-
# File 'lib/tls_map/extractor.rb', line 237
+      
# File 'lib/tls_map/app/extractor/extractor.rb', line 237
 
 def parse(file)
   data = Utils.json_load_file(file)
@@ -468,7 +468,7 @@ 

diff --git a/docs/yard/TLSmap/App/Extractor/Sslscan2.html b/docs/yard/TLSmap/App/Extractor/Sslscan2.html index ee48a8a..29ce0c4 100644 --- a/docs/yard/TLSmap/App/Extractor/Sslscan2.html +++ b/docs/yard/TLSmap/App/Extractor/Sslscan2.html @@ -94,7 +94,7 @@
Defined in:
-
lib/tls_map/extractor.rb
+
lib/tls_map/app/extractor/extractor.rb
@@ -273,7 +273,7 @@

174

-
# File 'lib/tls_map/extractor.rb', line 162
+      
# File 'lib/tls_map/app/extractor/extractor.rb', line 162
 
 def extract_cipher(xml_doc, online = false) # rubocop:disable Metrics/MethodLength
   raw = {
@@ -361,7 +361,7 @@ 

155

-
# File 'lib/tls_map/extractor.rb', line 152
+      
# File 'lib/tls_map/app/extractor/extractor.rb', line 152
 
 def parse(file, online = false)
   doc = REXML::Document.new(File.new(file))
@@ -377,7 +377,7 @@ 

diff --git a/docs/yard/TLSmap/App/Extractor/Sslyze.html b/docs/yard/TLSmap/App/Extractor/Sslyze.html index f6370c3..6563508 100644 --- a/docs/yard/TLSmap/App/Extractor/Sslyze.html +++ b/docs/yard/TLSmap/App/Extractor/Sslyze.html @@ -94,7 +94,7 @@
Defined in:
-
lib/tls_map/extractor.rb
+
lib/tls_map/app/extractor/extractor.rb
@@ -254,7 +254,7 @@

139

-
# File 'lib/tls_map/extractor.rb', line 128
+      
# File 'lib/tls_map/app/extractor/extractor.rb', line 128
 
 def extract_cipher(json_data)
   ciphers = json_data['server_scan_results'][0]['scan_commands_results']
@@ -341,7 +341,7 @@ 

123

-
# File 'lib/tls_map/extractor.rb', line 120
+      
# File 'lib/tls_map/app/extractor/extractor.rb', line 120
 
 def parse(file)
   data = Utils.json_load_file(file)
@@ -357,7 +357,7 @@ 

diff --git a/docs/yard/TLSmap/App/Extractor/Testssl.html b/docs/yard/TLSmap/App/Extractor/Testssl.html index 12bb476..f5dcdc8 100644 --- a/docs/yard/TLSmap/App/Extractor/Testssl.html +++ b/docs/yard/TLSmap/App/Extractor/Testssl.html @@ -94,7 +94,7 @@
Defined in:
-
lib/tls_map/extractor.rb
+
lib/tls_map/app/extractor/extractor.rb
@@ -299,7 +299,7 @@

205

-
# File 'lib/tls_map/extractor.rb', line 195
+      
# File 'lib/tls_map/app/extractor/extractor.rb', line 195
 
 def extract_cipher(json_data)
   cipher = json_data['scanResult'][0]['cipherTests']
@@ -383,7 +383,7 @@ 

224

-
# File 'lib/tls_map/extractor.rb', line 222
+      
# File 'lib/tls_map/app/extractor/extractor.rb', line 222
 
 def finding2cipher(finding)
   /\s(\w+_\w+)\s/.match(finding).captures[0]
@@ -464,7 +464,7 @@ 

217

-
# File 'lib/tls_map/extractor.rb', line 210
+      
# File 'lib/tls_map/app/extractor/extractor.rb', line 210
 
 def id2prot(id)
   prot = {
@@ -547,7 +547,7 @@ 

190

-
# File 'lib/tls_map/extractor.rb', line 187
+      
# File 'lib/tls_map/app/extractor/extractor.rb', line 187
 
 def parse(file)
   data = Utils.json_load_file(file)
@@ -563,7 +563,7 @@ 

diff --git a/docs/yard/TLSmap/CLI.html b/docs/yard/TLSmap/CLI.html index 2570e4e..7bd83bf 100644 --- a/docs/yard/TLSmap/CLI.html +++ b/docs/yard/TLSmap/CLI.html @@ -96,7 +96,7 @@
Defined in:
-
lib/tls_map/cli.rb
+
lib/tls_map/cli/cli.rb
@@ -280,7 +280,7 @@

23

-
# File 'lib/tls_map/cli.rb', line 16
+      
# File 'lib/tls_map/cli/cli.rb', line 16
 
 def initialize(force = false) # rubocop:disable Lint/MissingSuper
   @storage_location = 'data/'
@@ -323,7 +323,7 @@ 

53

-
# File 'lib/tls_map/cli.rb', line 50
+      
# File 'lib/tls_map/cli/cli.rb', line 50
 
 def update
   tm = TLSmap::App.new
@@ -339,7 +339,7 @@ 

diff --git a/docs/yard/TLSmap/Utils.html b/docs/yard/TLSmap/Utils.html index 5c11104..de444ae 100644 --- a/docs/yard/TLSmap/Utils.html +++ b/docs/yard/TLSmap/Utils.html @@ -78,7 +78,7 @@
Defined in:
-
lib/tls_map/utils.rb
+
lib/tls_map/utils/utils.rb
@@ -197,7 +197,7 @@

27

-
# File 'lib/tls_map/utils.rb', line 21
+      
# File 'lib/tls_map/utils/utils.rb', line 21
 
 def self.json_load_file(filespec, opts = {})
   if RUBY_VERSION < '3.0.0'
@@ -234,7 +234,7 @@ 

17

-
# File 'lib/tls_map/utils.rb', line 12
+      
# File 'lib/tls_map/utils/utils.rb', line 12
 
 def self.tmpfile(name, url)
   tmp = Tempfile.new(name)
@@ -252,7 +252,7 @@ 

diff --git a/docs/yard/_index.html b/docs/yard/_index.html index 33d3ee8..f75de7e 100644 --- a/docs/yard/_index.html +++ b/docs/yard/_index.html @@ -203,7 +203,7 @@

Namespace Listing A-Z

diff --git a/docs/yard/file.LICENSE.html b/docs/yard/file.LICENSE.html index 515bbbd..4b9f021 100644 --- a/docs/yard/file.LICENSE.html +++ b/docs/yard/file.LICENSE.html @@ -82,7 +82,7 @@ diff --git a/docs/yard/file.README.html b/docs/yard/file.README.html index 3e9c0a8..bdabb5e 100644 --- a/docs/yard/file.README.html +++ b/docs/yard/file.README.html @@ -113,7 +113,7 @@

Author

diff --git a/docs/yard/index.html b/docs/yard/index.html index b8a2723..76ab2f4 100644 --- a/docs/yard/index.html +++ b/docs/yard/index.html @@ -113,7 +113,7 @@

Author

diff --git a/docs/yard/top-level-namespace.html b/docs/yard/top-level-namespace.html index 769f161..bb2a1b6 100644 --- a/docs/yard/top-level-namespace.html +++ b/docs/yard/top-level-namespace.html @@ -100,7 +100,7 @@

Defined Under Namespace

diff --git a/lib/tls_map.rb b/lib/tls_map.rb index 1b981d9..472a734 100644 --- a/lib/tls_map.rb +++ b/lib/tls_map.rb @@ -4,14 +4,14 @@ require 'pathname' # Project internal require 'tls_map/version' -require 'tls_map/utils' -require 'tls_map/iana' -require 'tls_map/openssl' -require 'tls_map/gnutls' -require 'tls_map/nss' -require 'tls_map/output' -require 'tls_map/ciphersuiteinfo' -require 'tls_map/extractor' +require 'tls_map/utils/utils' +require 'tls_map/app/iana' +require 'tls_map/app/openssl' +require 'tls_map/app/gnutls' +require 'tls_map/app/nss' +require 'tls_map/app/output' +require 'tls_map/app/extended/ciphersuiteinfo' +require 'tls_map/app/extractor/extractor' # TLS map module module TLSmap diff --git a/lib/tls_map/ciphersuiteinfo.rb b/lib/tls_map/app/extended/ciphersuiteinfo.rb similarity index 100% rename from lib/tls_map/ciphersuiteinfo.rb rename to lib/tls_map/app/extended/ciphersuiteinfo.rb diff --git a/lib/tls_map/extractor.rb b/lib/tls_map/app/extractor/extractor.rb similarity index 99% rename from lib/tls_map/extractor.rb rename to lib/tls_map/app/extractor/extractor.rb index 78f9e8d..f6b8e4c 100644 --- a/lib/tls_map/extractor.rb +++ b/lib/tls_map/app/extractor/extractor.rb @@ -3,7 +3,7 @@ # Ruby internal require 'json' # Project internal -require 'tls_map/cli' +require 'tls_map/cli/cli' # External require 'rexml/document' diff --git a/lib/tls_map/gnutls.rb b/lib/tls_map/app/gnutls.rb similarity index 100% rename from lib/tls_map/gnutls.rb rename to lib/tls_map/app/gnutls.rb diff --git a/lib/tls_map/iana.rb b/lib/tls_map/app/iana.rb similarity index 100% rename from lib/tls_map/iana.rb rename to lib/tls_map/app/iana.rb diff --git a/lib/tls_map/nss.rb b/lib/tls_map/app/nss.rb similarity index 100% rename from lib/tls_map/nss.rb rename to lib/tls_map/app/nss.rb diff --git a/lib/tls_map/openssl.rb b/lib/tls_map/app/openssl.rb similarity index 100% rename from lib/tls_map/openssl.rb rename to lib/tls_map/app/openssl.rb diff --git a/lib/tls_map/output.rb b/lib/tls_map/app/output.rb similarity index 100% rename from lib/tls_map/output.rb rename to lib/tls_map/app/output.rb diff --git a/lib/tls_map/cli.rb b/lib/tls_map/cli/cli.rb similarity index 95% rename from lib/tls_map/cli.rb rename to lib/tls_map/cli/cli.rb index 3c399b0..b823080 100644 --- a/lib/tls_map/cli.rb +++ b/lib/tls_map/cli/cli.rb @@ -26,7 +26,7 @@ def initialize(force = false) # rubocop:disable Lint/MissingSuper # @return [String] absolute filename of the DB def absolute_db_path pn = Pathname.new(__FILE__) - install_dir = pn.dirname.parent.parent.to_s + Pathname::SEPARATOR_LIST + install_dir = pn.dirname.parent.parent.parent.to_s + Pathname::SEPARATOR_LIST install_dir + @storage_location + @database_name end diff --git a/lib/tls_map/utils.rb b/lib/tls_map/utils/utils.rb similarity index 100% rename from lib/tls_map/utils.rb rename to lib/tls_map/utils/utils.rb diff --git a/test/test_cli.rb b/test/test_cli.rb index 35722e9..6b68481 100644 --- a/test/test_cli.rb +++ b/test/test_cli.rb @@ -3,7 +3,7 @@ require 'minitest/autorun' require 'minitest/skip_dsl' require 'tls_map' -require 'tls_map/cli' +require 'tls_map//cli/cli' class TLSmapCLITest < Minitest::Test def test_CLI