Module: Ronin::Controls::Behaviors

Public Visibility

Public Instance Method Summary

#behaviors

Lists the behaviors to be controlled.

Returns: Array<Symbol>

#control(*behaviors)

Adds new behaviors to the model which are to be controlled.

#control_helper(name)

Attempts to load and extend the control module defined in.

Returns: Boolean

#control_model

Returns: Model

#load_original!

Load the code from the cached file for the object.

Public Instance Method Details

behaviors

public Array<Symbol> behaviors

Lists the behaviors to be controlled.

Meta Tags

Example:

  behaviors
  # => [:code_exec, :file_read, :file_write, :file_create]

Returns:

[Array<Symbol>]

The behaviors controlled by the model.

[View source]


113
114
115
# File 'lib/ronin/controls/behaviors.rb', line 113

def behaviors
  self.controls.map { |control| control.behavior.name.to_sym }
end

control

public control(*behaviors)

Adds new behaviors to the model which are to be controlled.

Meta Tags

Example:

  control :code_exec,
          :file_read,
          :file_write,
          :file_create

Parameters:

[Array<Symbol>] behaviors

The list of behaviors to be controlled.

Since:

0.3.0

[View source]


93
94
95
96
97
98
99
100
101
# File 'lib/ronin/controls/behaviors.rb', line 93

def control(*behaviors)
  behaviors.each do |behavior|
    self.controls << control_model.new(
      :behavior => Vuln::Behavior[behavior]
    )

    control_helper(behavior)
  end
end

control_helper

public Boolean control_helper(name)

Attempts to load and extend the control module defined in Ronin::Controls::Helpers.

Meta Tags

Example:

  control_helper :file_read

Parameters:

[Symbol, String] name

The snake-case name of the control helper module to load.

Returns:

[Boolean]

Specifies whether the control helper module was successfully loaded.

Since:

0.3.0

[View source]


43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/ronin/controls/behaviors.rb', line 43

def control_helper(name)
  name = name.to_s
  module_name = name.to_const_string

  begin
    require_within File.join('ronin','controls','helpers'), name
  rescue Gem::LoadError => e
    raise(e)
  rescue ::LoadError
    return false
  end

  unless Ronin::Controls::Helpers.const_defined?(module_name)
    return false
  end

  control_module = Ronin::Controls::Helpers.const_get(module_name)

  unless control_module.kind_of?(Module)
    return false
  end

  extend control_module
  return true
end

control_model

public Model control_model

Meta Tags

Returns:

[Model]

The model used by the controls relationship.

Since:

0.3.0

[View source]


75
76
77
# File 'lib/ronin/controls/behaviors.rb', line 75

def control_model
  self.class.relationships[:controls].child_model
end

load_original!

public load_original!

Load the code from the cached file for the object. Will also attempt to load and extend any control modules for the controlled behaviors.

Meta Tags

Since:

0.3.0

[View source]


124
125
126
127
128
129
130
# File 'lib/ronin/controls/behaviors.rb', line 124

def load_original!
  unless original_loaded?
    self.behaviors.each { |name| control_helper name }
  end

  super
end
Generated on Thursday, October 01 2009 at 02:15:01 AM by YARD 0.2.3.5 (ruby-1.8.6).