diff --git a/Gemfile.lock b/Gemfile.lock index 8ce7b00..d7b043c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - tls-map (1.3.0) + tls-map (1.3.1) docopt (~> 0.6) paint (~> 2.2) rexml (~> 3.2) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index cbc1218..996f3d8 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -2,10 +2,16 @@ ## [Unreleased] +## [1.3.1] + Fixes: - `JSON.load_file()` is only available since Ruby 3.0 so `Utils.json_load_file()` was created to bring compatibility with Ruby 2.X +Chore: + +- Convert `Utils` methods as module methods instead of instance methods + ## [1.3.0] Additions: diff --git a/docs/yard/TLSmap.html b/docs/yard/TLSmap.html index c53d5bf..74f3281 100644 --- a/docs/yard/TLSmap.html +++ b/docs/yard/TLSmap.html @@ -119,7 +119,7 @@

VERSION =
-
'1.2.0'
+
'1.3.1'
@@ -135,7 +135,7 @@

diff --git a/docs/yard/TLSmap/App.html b/docs/yard/TLSmap/App.html index 24e5798..5d7e911 100644 --- a/docs/yard/TLSmap/App.html +++ b/docs/yard/TLSmap/App.html @@ -87,11 +87,6 @@ -
-
Includes:
-
Utils
-
- @@ -100,7 +95,7 @@
Defined in:
lib/tls_map.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/extractor.rb,
lib/tls_map/ciphersuiteinfo.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
@@ -195,6 +190,29 @@

  • + #bulk_search(critera, file, output = :all) ⇒ Array<Hash> + + + + + + + + + + + + + +

    Search for corresponding cipher algorithms in other libraries in bulk.

    +
    + +
  • + + +
  • + + #export(filename, format) ⇒ Object @@ -266,17 +284,6 @@

    - - - - - - - - - -

    Methods included from Utils

    -

    #tmpfile

    Constructor Details

    @@ -320,11 +327,11 @@

    # File 'lib/tls_map.rb', line 21
     
     def initialize
    -  @iana_file = tmpfile('iana', IANA_URL)
    -  @openssl_file = tmpfile('openssl', OPENSSL_URL)
    -  @openssl_file2 = tmpfile('openssl', OPENSSL_URL2)
    -  @gnutls_file = tmpfile('gnutls', GNUTLS_URL)
    -  @nss_file = tmpfile('nss', NSS_URL)
    +  @iana_file = Utils.tmpfile('iana', IANA_URL)
    +  @openssl_file = Utils.tmpfile('openssl', OPENSSL_URL)
    +  @openssl_file2 = Utils.tmpfile('openssl', OPENSSL_URL2)
    +  @gnutls_file = Utils.tmpfile('gnutls', GNUTLS_URL)
    +  @nss_file = Utils.tmpfile('nss', NSS_URL)
     
       @tls_map = []
       parse
    @@ -342,7 +349,127 @@ 

    Instance Method Details

    -

    +

    + + #bulk_search(critera, file, output = :all) ⇒ Array<Hash> + + + + + +

    +
    +

    Search for corresponding cipher algorithms in other libraries in bulk

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + critera + + + (Symbol) + + + + — +

      The type of term. +Accepted values: :codepoint, :iana, :openssl, :gnutls, :nss.

      +
      + +
    • + +
    • + + file + + + (String) + + + + — +

      File containing the cipher algorithm names, one per line.

      +
      + +
    • + +
    • + + output + + + (Symbol) + + + (defaults to: :all) + + + — +

      The corresponding type to be included in the return value. +Accepted values: :all (default), :codepoint, :iana, :openssl, +:gnutls, :nss.

      +
      + +
    • + +
    + +

    Returns:

    +
      + +
    • + + + (Array<Hash>) + + + + — +

      The corresponding type, same as #search return value +but one per line stored in an array.

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +67
    +68
    +69
    +70
    +71
    +72
    +73
    +
    +
    # File 'lib/tls_map.rb', line 67
    +
    +def bulk_search(critera, file, output = :all)
    +  res = []
    +  File.foreach(file) do |line|
    +    res.push(search(critera, line.chomp, output))
    +  end
    +  res
    +end
    +
    +
    + +
    +

    #export(filename, format) ⇒ Object @@ -559,7 +686,7 @@

    diff --git a/docs/yard/TLSmap/App/Extended.html b/docs/yard/TLSmap/App/Extended.html index c7e355d..6278fbc 100644 --- a/docs/yard/TLSmap/App/Extended.html +++ b/docs/yard/TLSmap/App/Extended.html @@ -87,11 +87,6 @@ -
    -
    Includes:
    -
    Utils
    -
    - @@ -350,17 +345,6 @@

    - - - - - - - - - -

    Methods included from Utils

    -

    #tmpfile

    Constructor Details

    @@ -389,19 +373,19 @@

     
     
    +49
    +50
    +51
     52
     53
    -54
    -55
    -56
    -57
    +54

    -
    # File 'lib/tls_map/ciphersuiteinfo.rb', line 52
    +      
    # File 'lib/tls_map/ciphersuiteinfo.rb', line 49
     
     def initialize
    -  @tech_file = tmpfile('tech', TECH_DATA)
    -  @vuln_file = tmpfile('vuln', VULN_DATA)
    +  @tech_file = Utils.tmpfile('tech', TECH_DATA)
    +  @vuln_file = Utils.tmpfile('vuln', VULN_DATA)
       @tech = parse_tech
       @vuln = parse_vuln
     end
    @@ -480,6 +464,9 @@

     
     
    +61
    +62
    +63
     64
     65
     66
    @@ -491,13 +478,10 @@ 

    72 73 74 -75 -76 -77 -78

    +75

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

     
     
    +111
    +112
    +113
     114
    -115
    -116
    -117
    -118
    +115

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

     
     
    +102
    +103
    +104
     105
    -106
    -107
    -108
    -109
    +106

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

    diff --git a/docs/yard/TLSmap/App/Extractor.html b/docs/yard/TLSmap/App/Extractor.html index c418e0b..4385281 100644 --- a/docs/yard/TLSmap/App/Extractor.html +++ b/docs/yard/TLSmap/App/Extractor.html @@ -933,7 +933,7 @@

    diff --git a/docs/yard/TLSmap/App/Extractor/SsllabsScan.html b/docs/yard/TLSmap/App/Extractor/SsllabsScan.html index 5b5446f..bded997 100644 --- a/docs/yard/TLSmap/App/Extractor/SsllabsScan.html +++ b/docs/yard/TLSmap/App/Extractor/SsllabsScan.html @@ -455,7 +455,7 @@

    # File 'lib/tls_map/extractor.rb', line 216
     
     def parse(file)
    -  data = JSON.load_file(file)
    +  data = Utils.json_load_file(file)
       extract_cipher(data)
     end
    @@ -468,7 +468,7 @@

    diff --git a/docs/yard/TLSmap/App/Extractor/Sslscan2.html b/docs/yard/TLSmap/App/Extractor/Sslscan2.html index 2368057..3b2ec31 100644 --- a/docs/yard/TLSmap/App/Extractor/Sslscan2.html +++ b/docs/yard/TLSmap/App/Extractor/Sslscan2.html @@ -377,7 +377,7 @@

    diff --git a/docs/yard/TLSmap/App/Extractor/Sslyze.html b/docs/yard/TLSmap/App/Extractor/Sslyze.html index 79f737c..e4bdaf0 100644 --- a/docs/yard/TLSmap/App/Extractor/Sslyze.html +++ b/docs/yard/TLSmap/App/Extractor/Sslyze.html @@ -344,7 +344,7 @@

    # File 'lib/tls_map/extractor.rb', line 99
     
     def parse(file)
    -  data = JSON.load_file(file)
    +  data = Utils.json_load_file(file)
       extract_cipher(data)
     end
    @@ -357,7 +357,7 @@

    diff --git a/docs/yard/TLSmap/App/Extractor/Testssl.html b/docs/yard/TLSmap/App/Extractor/Testssl.html index c1c23b7..5f2c7a3 100644 --- a/docs/yard/TLSmap/App/Extractor/Testssl.html +++ b/docs/yard/TLSmap/App/Extractor/Testssl.html @@ -550,7 +550,7 @@

    # File 'lib/tls_map/extractor.rb', line 166
     
     def parse(file)
    -  data = JSON.load_file(file)
    +  data = Utils.json_load_file(file)
       extract_cipher(data)
     end
    @@ -563,7 +563,7 @@

    diff --git a/docs/yard/TLSmap/CLI.html b/docs/yard/TLSmap/CLI.html index e70544a..db1da81 100644 --- a/docs/yard/TLSmap/CLI.html +++ b/docs/yard/TLSmap/CLI.html @@ -218,18 +218,7 @@

    Methods inherited from App

    -

    #export, #search

    - - - - - - - - - -

    Methods included from Utils

    -

    #tmpfile

    +

    #bulk_search, #export, #search

    Constructor Details

    @@ -350,7 +339,7 @@

    diff --git a/docs/yard/TLSmap/Utils.html b/docs/yard/TLSmap/Utils.html index e8b645e..1f0230b 100644 --- a/docs/yard/TLSmap/Utils.html +++ b/docs/yard/TLSmap/Utils.html @@ -74,11 +74,6 @@ -
    -
    Included in:
    -
    App, App::Extended
    -
    -
    @@ -107,7 +102,7 @@

    Overview

    - Instance Method Summary + Class Method Summary collapse

    @@ -116,7 +111,30 @@

  • - #tmpfile(name, url) ⇒ Object + .json_load_file(filespec, opts = {}) ⇒ Object + + + + + + + + + + + + + + + +
  • + + +
  • + + + .tmpfile(name, url) ⇒ Object @@ -140,14 +158,63 @@

    -
    -

    Instance Method Details

    +
    +

    Class Method Details

    -

    +

    + + .json_load_file(filespec, opts = {}) ⇒ Object + + + + + +

    + +
    +
    + + +
    + + + + +
    +
    +
    +
    +21
    +22
    +23
    +24
    +25
    +26
    +27
    +
    +
    # File 'lib/tls_map/utils.rb', line 21
    +
    +def self.json_load_file(filespec, opts = {})
    +  if RUBY_VERSION < '3.0.0'
    +    JSON.parse(File.read(filespec), opts)
    +  else
    +    JSON.load_file(filespec, opts)
    +  end
    +end
    +
    +
    + +
    +

    - #tmpfile(name, url) ⇒ Object + .tmpfile(name, url) ⇒ Object @@ -159,17 +226,17 @@

     
     
    -11
     12
     13
     14
     15
    -16
    +16 +17 -
    # File 'lib/tls_map/utils.rb', line 11
    +      
    # File 'lib/tls_map/utils.rb', line 12
     
    -def tmpfile(name, url)
    +def self.tmpfile(name, url)
       tmp = Tempfile.new(name)
       tmp.write(Net::HTTP.get(URI(url)))
       tmp.close
    @@ -185,7 +252,7 @@ 

    diff --git a/docs/yard/_index.html b/docs/yard/_index.html index 40a948e..53a3e49 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 325f7e8..6958d9c 100644 --- a/docs/yard/file.LICENSE.html +++ b/docs/yard/file.LICENSE.html @@ -81,7 +81,7 @@

  • diff --git a/docs/yard/file.README.html b/docs/yard/file.README.html index 3669159..a6d6965 100644 --- a/docs/yard/file.README.html +++ b/docs/yard/file.README.html @@ -86,8 +86,14 @@

    Features

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

    Installation

    @@ -107,7 +113,7 @@

    Author

    diff --git a/docs/yard/index.html b/docs/yard/index.html index 7e2516d..784c78f 100644 --- a/docs/yard/index.html +++ b/docs/yard/index.html @@ -86,8 +86,14 @@

    Features

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

    Installation

    @@ -107,7 +113,7 @@

    Author

    diff --git a/docs/yard/method_list.html b/docs/yard/method_list.html index 8cf3b64..d58e04e 100644 --- a/docs/yard/method_list.html +++ b/docs/yard/method_list.html @@ -45,6 +45,14 @@

    Method List

  • +
    + #bulk_search + TLSmap::App +
    +
  • + + +
  • #ciphers TLSmap::App::Extractor @@ -52,7 +60,7 @@

    Method List

  • -
  • +
  • #export TLSmap::App @@ -60,7 +68,7 @@

    Method List

  • -
  • +
  • #extend TLSmap::App::Extended @@ -68,7 +76,7 @@

    Method List

  • -
  • +
  • extract_cipher TLSmap::App::Extractor::Sslyze @@ -76,7 +84,7 @@

    Method List

  • -
  • +
  • extract_cipher TLSmap::App::Extractor::Sslscan2 @@ -84,7 +92,7 @@

    Method List

  • -
  • +
  • extract_cipher TLSmap::App::Extractor::Testssl @@ -92,7 +100,7 @@

    Method List

  • -
  • +
  • extract_cipher TLSmap::App::Extractor::SsllabsScan @@ -100,7 +108,7 @@

    Method List

  • -
  • +
  • #find_vuln TLSmap::App::Extended @@ -108,7 +116,7 @@

    Method List

  • -
  • +
  • finding2cipher TLSmap::App::Extractor::Testssl @@ -116,7 +124,7 @@

    Method List

  • -
  • +
  • id2prot TLSmap::App::Extractor::Testssl @@ -124,7 +132,7 @@

    Method List

  • -
  • +
  • id2prot TLSmap::App::Extractor::SsllabsScan @@ -132,7 +140,7 @@

    Method List

  • -
  • +
  • #initialize TLSmap::App @@ -140,7 +148,7 @@

    Method List

  • -
  • +
  • #initialize TLSmap::CLI @@ -148,7 +156,7 @@

    Method List

  • -
  • +
  • #initialize TLSmap::App::Extractor @@ -156,7 +164,7 @@

    Method List

  • -
  • +
  • #initialize TLSmap::App::Extended @@ -164,6 +172,14 @@

    Method List

  • +
  • +
    + json_load_file + TLSmap::Utils +
    +
  • + +
  • #parse @@ -262,7 +278,7 @@

    Method List

  • - #tmpfile + tmpfile TLSmap::Utils
  • diff --git a/docs/yard/top-level-namespace.html b/docs/yard/top-level-namespace.html index 5ec32ea..6cf583e 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 96fe395..1b981d9 100644 --- a/lib/tls_map.rb +++ b/lib/tls_map.rb @@ -19,11 +19,11 @@ module TLSmap class App # Will automatically fetch source files and parse them. def initialize - @iana_file = tmpfile('iana', IANA_URL) - @openssl_file = tmpfile('openssl', OPENSSL_URL) - @openssl_file2 = tmpfile('openssl', OPENSSL_URL2) - @gnutls_file = tmpfile('gnutls', GNUTLS_URL) - @nss_file = tmpfile('nss', NSS_URL) + @iana_file = Utils.tmpfile('iana', IANA_URL) + @openssl_file = Utils.tmpfile('openssl', OPENSSL_URL) + @openssl_file2 = Utils.tmpfile('openssl', OPENSSL_URL2) + @gnutls_file = Utils.tmpfile('gnutls', GNUTLS_URL) + @nss_file = Utils.tmpfile('nss', NSS_URL) @tls_map = [] parse diff --git a/lib/tls_map/ciphersuiteinfo.rb b/lib/tls_map/ciphersuiteinfo.rb index 3e165c9..6e755bb 100644 --- a/lib/tls_map/ciphersuiteinfo.rb +++ b/lib/tls_map/ciphersuiteinfo.rb @@ -45,13 +45,10 @@ class Extended 2 => { title: 'High', color: :red } }.freeze - include Utils - protected :tmpfile - # Will automatically fetch source files and parse them. def initialize - @tech_file = tmpfile('tech', TECH_DATA) - @vuln_file = tmpfile('vuln', VULN_DATA) + @tech_file = Utils.tmpfile('tech', TECH_DATA) + @vuln_file = Utils.tmpfile('vuln', VULN_DATA) @tech = parse_tech @vuln = parse_vuln end diff --git a/lib/tls_map/utils.rb b/lib/tls_map/utils.rb index 623f178..30fea1e 100644 --- a/lib/tls_map/utils.rb +++ b/lib/tls_map/utils.rb @@ -9,7 +9,7 @@ module TLSmap # Generic utilities module Utils - def tmpfile(name, url) + def self.tmpfile(name, url) tmp = Tempfile.new(name) tmp.write(Net::HTTP.get(URI(url))) tmp.close @@ -26,10 +26,4 @@ def self.json_load_file(filespec, opts = {}) end end end - - # TLS mapping - class App - include Utils - protected :tmpfile - end end diff --git a/lib/tls_map/version.rb b/lib/tls_map/version.rb index f7d48c0..1b3f64c 100644 --- a/lib/tls_map/version.rb +++ b/lib/tls_map/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module TLSmap - VERSION = '1.3.0' + VERSION = '1.3.1' end