Class: Msf::OptDatabaseRefOrPath
- Defined in:
- lib/msf/core/opt_database_ref_or_path.rb
Overview
Opt that can be reference a database Id or a file on disk; Valid examples:
-
/tmp/foo.txt
-
id:123
Direct Known Subclasses
Instance Attribute Summary
Attributes inherited from OptBase
#advanced, #aliases, #conditions, #default, #desc, #enums, #evasion, #fallbacks, #max_length, #name, #owner, #regex, #required
Instance Method Summary collapse
- #normalize(value) ⇒ Object
-
#valid?(value, check_empty: true, datastore: nil) ⇒ Boolean
Generally, ‘value’ should be a file that exists, or an integer database id.
- #validate_on_assignment? ⇒ Boolean
Methods inherited from OptBase
#advanced?, #display_value, #empty_required_value?, #evasion?, #initialize, #invalid_value_length?, #required?, #type?
Constructor Details
This class inherits a constructor from Msf::OptBase
Instance Method Details
#normalize(value) ⇒ Object
11 12 13 14 15 |
# File 'lib/msf/core/opt_database_ref_or_path.rb', line 11 def normalize(value) return value if value.nil? || value.to_s.empty? || value.start_with?('id:') File.(value) end |
#valid?(value, check_empty: true, datastore: nil) ⇒ Boolean
Generally, ‘value’ should be a file that exists, or an integer database id.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/msf/core/opt_database_ref_or_path.rb', line 22 def valid?(value, check_empty: true, datastore: nil) return false if check_empty && empty_required_value?(value) if value && !value.empty? if value.start_with?('id:') return value.match?(/^id:\d+$/) end unless File.exist?(File.(value)) return false end end super end |
#validate_on_assignment? ⇒ Boolean
17 18 19 |
# File 'lib/msf/core/opt_database_ref_or_path.rb', line 17 def validate_on_assignment? false end |