Class: Nmap::Command::ScanFlags Private
- Inherits:
-
CommandMapper::Types::Str
- Object
- CommandMapper::Types::Str
- Nmap::Command::ScanFlags
- Defined in:
- lib/nmap/command.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Constant Summary collapse
- FLAGS =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
{ urg: 'URG', ack: 'ACK', psh: 'PSH', rst: 'RST', syn: 'SYN', fin: 'FIN' }
- REGEXP =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
/\A(?:\d+|(?:URG|ACK|PSH|RST|SYN|FIN)+)\z/
Instance Method Summary collapse
-
#format(value) ⇒ String
private
Formats a scanflags value.
-
#validate(value) ⇒ true, (false, String)
private
Validates a scanflags value.
Instance Method Details
#format(value) ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Formats a scanflags value.
559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 |
# File 'lib/nmap/command.rb', line 559 def format(value) case value when Hash string = String.new value.each do |key,value| string << FLAGS[key] if value end return string when Array string = String.new value.each do |flag| string << FLAGS[flag] end return string else super(value) end end |
#validate(value) ⇒ true, (false, String)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Validates a scanflags value.
507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 |
# File 'lib/nmap/command.rb', line 507 def validate(value) case value when Hash if value.empty? return [false, "Hash value cannot be empty"] end unless value.keys.all? { |key| FLAGS.has_key?(key) } return [false, "Hash must only contain the keys :urg, :ack, :psh, :rst, :syn, or :fin"] end unless value.values.all? { |value| value == nil || value == false || value == true } return [false, "Hash must only contain the values true, false, or nil"] end return true when Array if value.empty? return [false, "Array value cannot be empty"] end unless value.all? { |flag| FLAGS.has_key?(flag) } return [false, "Array must only contain the values :urg, :ack, :psh, :rst, :syn, or :fin"] end return true else valid, = super(value) unless valid return [valid, ] end value = value.to_s unless value =~ REGEXP return [false, "must only contain URG, ACK, PSH, RST, SYN, or FIN"] end return true end end |