Class: Nmap::Command::ScanFlags Private
- Inherits:
-
CommandMapper::Types::Str
- Object
- CommandMapper::Types::Str
- Nmap::Command::ScanFlags
- Defined in:
- lib/nmap/command.rb
Overview
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.
Represents one or more TCP scan flags.
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.
Mapping of symbol scan flags to String values.
{ 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.
Regular expression to validate the given scan flags.
/\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.
598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 |
# File 'lib/nmap/command.rb', line 598 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.
546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 |
# File 'lib/nmap/command.rb', line 546 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 |