Class: Ronin::Recon::OutputFormats::GraphvizFormat

Inherits:
Core::OutputFormats::OutputFile
  • Object
show all
Includes:
GraphFormat
Defined in:
lib/ronin/recon/output_formats/graphviz_format.rb

Overview

Represents a GraphViz output format.

Direct Known Subclasses

PDF, PNG, SVG

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(io) ⇒ GraphvizFormat

Initializes the GraphViz output format.

Parameters:

  • io (IO)

    The output stream to write to.



53
54
55
56
57
58
# File 'lib/ronin/recon/output_formats/graphviz_format.rb', line 53

def initialize(io)
  super(io)

  @dot_file   = Tempfile.new(['ronin-recon',"#{format}"])
  @dot_output = Dot.new(@dot_file)
end

Instance Attribute Details

#dot_fileTempfile (readonly)

The .dot output file.

Returns:

  • (Tempfile)


40
41
42
# File 'lib/ronin/recon/output_formats/graphviz_format.rb', line 40

def dot_file
  @dot_file
end

#dot_outputDot (readonly)

The DOT output format.

Returns:



45
46
47
# File 'lib/ronin/recon/output_formats/graphviz_format.rb', line 45

def dot_output
  @dot_output
end

Instance Method Details

#<<(value) ⇒ Object

Writes a value to the GraphViz output stream as a node declaration.

Parameters:

  • value (Value)

    The value object to write.



78
79
80
# File 'lib/ronin/recon/output_formats/graphviz_format.rb', line 78

def <<(value)
  @dot_output << value
end

#[]=(value, parent) ⇒ self

Appends a value and it's parent value to the GraphViz output stream.

Parameters:

  • value (Value)

    The value to append.

  • parent (Value)

    The parent value of the given value.

Returns:

  • (self)


93
94
95
96
# File 'lib/ronin/recon/output_formats/graphviz_format.rb', line 93

def []=(value,parent)
  @dot_output[value] = parent
  return self
end

#closeObject

Closes and generates the GraphViz output file.



101
102
103
104
105
106
107
108
109
110
# File 'lib/ronin/recon/output_formats/graphviz_format.rb', line 101

def close
  @dot_output.close

  IO.popen(['dot',"-T#{format}",@dot_file.path]) do |dot_io|
    # relay the `dot` output to the output stream.
    @io.write(dot_io.readpartial(4096)) until dot_io.eof?
  end

  super
end

#formatSymbol

This method is abstract.

The desired GraphViz output format.

Returns:

  • (Symbol)

    The output format name.

Raises:

  • (NotImplementedError)


68
69
70
# File 'lib/ronin/recon/output_formats/graphviz_format.rb', line 68

def format
  raise(NotImplementedError,"#{self.class}#format was not defined!")
end