Class: SSHScan::Policy

Inherits:
Object
  • Object
show all
Defined in:
lib/ssh_scan/policy.rb

Overview

Policy methods that deal with key exchange, macs, encryption methods, compression methods and more.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ Policy

Returns a new instance of Policy.



11
12
13
14
15
16
17
18
19
20
# File 'lib/ssh_scan/policy.rb', line 11

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

Instance Attribute Details

#auth_methodsObject (readonly)

Returns the value of attribute auth_methods.



8
9
10
# File 'lib/ssh_scan/policy.rb', line 8

def auth_methods
  @auth_methods
end

#compressionObject (readonly)

Returns the value of attribute compression.



8
9
10
# File 'lib/ssh_scan/policy.rb', line 8

def compression
  @compression
end

#encryptionObject (readonly)

Returns the value of attribute encryption.



8
9
10
# File 'lib/ssh_scan/policy.rb', line 8

def encryption
  @encryption
end

#kexObject (readonly)

Returns the value of attribute kex.



8
9
10
# File 'lib/ssh_scan/policy.rb', line 8

def kex
  @kex
end

#macsObject (readonly)

Returns the value of attribute macs.



8
9
10
# File 'lib/ssh_scan/policy.rb', line 8

def macs
  @macs
end

#nameObject (readonly)

Returns the value of attribute name.



8
9
10
# File 'lib/ssh_scan/policy.rb', line 8

def name
  @name
end

#referencesObject (readonly)

Returns the value of attribute references.



8
9
10
# File 'lib/ssh_scan/policy.rb', line 8

def references
  @references
end

#ssh_versionObject (readonly)

Returns the value of attribute ssh_version.



8
9
10
# File 'lib/ssh_scan/policy.rb', line 8

def ssh_version
  @ssh_version
end

Class Method Details

.from_file(file) ⇒ SSHScan::Policy

Generate a SSHScan::Policy object from YAML file.

Parameters:

Returns:



26
27
28
29
# File 'lib/ssh_scan/policy.rb', line 26

def self.from_file(file)
  opts = YAML.load_file(file)
  self.new(opts)
end

.from_string(string) ⇒ SSHScan::Policy

Generate a SSHScan::Policy object from YAML string.

Parameters:

  • string (String)

    YAML string

Returns:

  • (SSHScan::Policy)

    new instance with parameters loaded from given string



51
52
53
54
# File 'lib/ssh_scan/policy.rb', line 51

def self.from_string(string)
  opts = YAML.load(string)
  self.new(opts)
end

Instance Method Details

#compression_attributesObject



43
44
45
# File 'lib/ssh_scan/policy.rb', line 43

def compression_attributes
  SSHScan.make_attributes(@compression)
end

#encryption_attributesObject



39
40
41
# File 'lib/ssh_scan/policy.rb', line 39

def encryption_attributes
  SSHScan.make_attributes(@encryption)
end

#kex_attributesObject



31
32
33
# File 'lib/ssh_scan/policy.rb', line 31

def kex_attributes
  SSHScan.make_attributes(@kex)
end

#mac_attributesObject



35
36
37
# File 'lib/ssh_scan/policy.rb', line 35

def mac_attributes
  SSHScan.make_attributes(@macs)
end