Class: Msf::OptSessionTlvLogging

Inherits:
OptBase
  • Object
show all
Defined in:
lib/msf/core/opt_session_tlv_logging.rb

Overview

Session TLV Logging option.

Valid values: ‘true’, ‘false’, ‘console’, or ‘file:<path>’

Constant Summary collapse

VALID_KEYWORDS =
%w[true false console].freeze

Instance Attribute Summary

Attributes inherited from OptBase

#advanced, #aliases, #conditions, #default, #desc, #enums, #evasion, #fallbacks, #max_length, #name, #owner, #regex, #required

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from OptBase

#advanced?, #display_value, #empty_required_value?, #evasion?, #invalid_value_length?, #normalize, #required?, #type?

Constructor Details

#initialize(in_name, attrs = [], **kwargs) ⇒ OptSessionTlvLogging

Returns a new instance of OptSessionTlvLogging.



14
15
16
# File 'lib/msf/core/opt_session_tlv_logging.rb', line 14

def initialize(in_name, attrs = [], **kwargs)
  super
end

Class Method Details

.valid_tlv_logging?(value) ⇒ Boolean

Returns:

  • (Boolean)


33
34
35
36
37
38
# File 'lib/msf/core/opt_session_tlv_logging.rb', line 33

def self.valid_tlv_logging?(value)
  return true if VALID_KEYWORDS.any? { |kw| value.casecmp?(kw) }
  return true if value.start_with?('file:') && value.split('file:', 2).last.length > 0

  false
end

Instance Method Details

#typeObject



18
19
20
# File 'lib/msf/core/opt_session_tlv_logging.rb', line 18

def type
  'sessiontlvlogging'
end

#valid?(value, check_empty: true, datastore: nil) ⇒ Boolean

Returns:

  • (Boolean)


26
27
28
29
30
31
# File 'lib/msf/core/opt_session_tlv_logging.rb', line 26

def valid?(value, check_empty: true, datastore: nil)
  return false if !super(value, check_empty: check_empty)
  return true if value.nil? || value.to_s.strip.empty?

  self.class.valid_tlv_logging?(value.to_s.strip)
end

#validate_on_assignment?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/msf/core/opt_session_tlv_logging.rb', line 22

def validate_on_assignment?
  true
end