Sha256: a7e4b34f8dca2cd6298a33363fe02fe0b55b6bbbedd8a4612c50bb4de1938c98

Contents?: true

Size: 1.19 KB

Versions: 4

Compression:

Stored size: 1.19 KB

Contents

require 'yaml'

module SSHScan
  # Policy methods that deal with key exchange, macs, encryption methods,
  # compression methods and more.
  class Policy
    attr_reader :name, :kex, :macs, :encryption, :compression,
                :references, :auth_methods, :ssh_version

    def initialize(opts = {})
      @name = opts['name'] || []
      @kex = opts['kex'] || []
      @macs = opts['macs'] || []
      @encryption = opts['encryption'] || []
      @compression = opts['compression'] || []
      @references = opts['references'] || []
      @auth_methods = opts['auth_methods'] || []
      @ssh_version = opts['ssh_version'] || nil
    end

    # Generate a {SSHScan::Policy} object from YAML file.
    # @param file [String] filepath
    # @return [SSHScan::Policy] new instance with parameters loaded
    #   from YAML file
    def self.from_file(file)
      opts = YAML.load_file(file)
      self.new(opts)
    end

    # Generate a {SSHScan::Policy} object from YAML string.
    # @param string [String] YAML string
    # @return [SSHScan::Policy] new instance with parameters loaded
    #   from given string
    def self.from_string(string)
      opts = YAML.load(string)
      self.new(opts)
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ssh_scan-0.0.25 lib/ssh_scan/policy.rb
ssh_scan-0.0.24 lib/ssh_scan/policy.rb
ssh_scan-0.0.23 lib/ssh_scan/policy.rb
ssh_scan-0.0.22 lib/ssh_scan/policy.rb