class TLSmap::CLI::Extended
Offline version of {App::Extended}
Constants
- INTEGRITY
Public Class Methods
new(force = false)
click to toggle source
Load and parse data from marshalized hash (`data/extended.marshal`). It must match the integrity check for security purpose. @param force [Boolean] Force parsing even if integrity check failed (DANGEROUS,
may result in command execution vulnerability)
# File lib/tls_map/cli/cli.rb, line 65 def initialize(force = false) # rubocop:disable Lint/MissingSuper @storage_location = 'data/' @extended_path = absolute_db_path('extended.marshal') @enhanced_data = {} extended_exists? parse(force) end
Public Instance Methods
extend(iana_name)
click to toggle source
Same as {App::Extended} but loading data from offline database, so there is no caching option. @see App::Extended
# File lib/tls_map/cli/cli.rb, line 108 def extend(iana_name) @enhanced_data[iana_name] end
update()
click to toggle source
# File lib/tls_map/cli/cli.rb, line 99 def update tmext = TLSmap::App::Extended.new tmext.enhance_all File.write(@extended_path, Marshal.dump(tmext.enhanced_data)) end
Protected Instance Methods
absolute_db_path(filename)
click to toggle source
Find the absolute path of the a data file from its relative location @param filename [String] file name @return [String] absolute filename of the data file
# File lib/tls_map/cli/cli.rb, line 76 def absolute_db_path(filename) pn = Pathname.new(__FILE__) install_dir = pn.dirname.parent.parent.parent.to_s + Pathname::SEPARATOR_LIST install_dir + @storage_location + filename end
extended_exists?()
click to toggle source
Check if the extended DB exists @return [Boolean] `true` if the files exists
# File lib/tls_map/cli/cli.rb, line 84 def extended_exists? exists = File.file?(@extended_path) raise "Database does not exist: #{@extended_path}" unless exists exists end
parse(force = false)
click to toggle source
# File lib/tls_map/cli/cli.rb, line 91 def parse(force = false) if Digest::SHA256.file(@extended_path).hexdigest == INTEGRITY || force # rubocop:disable Style/GuardClause @enhanced_data = Marshal.load(File.read(@extended_path)) # rubocop:disable Security/MarshalLoad else raise 'Integrity check failed, maybe be due to unvalidated database after update' end end