Class: Contrast::Agent::Assess::Policy::SourceNode
- Inherits:
-
PolicyNode
- Object
- Patching::Policy::PolicyNode
- PolicyNode
- Contrast::Agent::Assess::Policy::SourceNode
- Defined in:
- lib/contrast/agent/assess/policy/source_node.rb
Overview
This class functions to translate our policy.json into an actionable Ruby object, allowing for dynamic patching over hardcoded patching, specifically for those methods which result in the source of untrusted data (indicate points in the application where user controlled input is accessed).
Constant Summary collapse
- JSON_TYPE =
'type'
- SOURCE_TAG =
'UNTRUSTED'
- SOURCE =
'Source'
Constants inherited from PolicyNode
PolicyNode::ALL_TYPE, PolicyNode::JSON_DATAFLOW, PolicyNode::JSON_SOURCE, PolicyNode::JSON_TAGS, PolicyNode::JSON_TARGET, PolicyNode::TO_MARKER
Instance Attribute Summary collapse
-
#type ⇒ Object
Returns the value of attribute type.
Attributes inherited from PolicyNode
#source_string, #sources, #tags, #target_string, #targets
Attributes inherited from Patching::Policy::PolicyNode
#class_name, #instance_method, #method_name, #method_scope, #method_visibility, #properties
Instance Method Summary collapse
-
#initialize(source_hash = {}) ⇒ SourceNode
constructor
A new instance of SourceNode.
- #node_class ⇒ Object
-
#node_type ⇒ Object
This is confusing.
-
#validate ⇒ Object
Standard validation + TS trace version two rules: Must have source and type.
Methods inherited from PolicyNode
#add_property, #build_action, #feature, #generate_sources, #generate_targets, #get_property, #target, #validate_tags
Methods inherited from Patching::Policy::PolicyNode
#feature, #id, #instance_method?
Methods included from Components::Interface
Constructor Details
#initialize(source_hash = {}) ⇒ SourceNode
Returns a new instance of SourceNode.
18 19 20 21 22 |
# File 'lib/contrast/agent/assess/policy/source_node.rb', line 18 def initialize source_hash = {} super(source_hash) @type = source_hash[JSON_TYPE] @tags << SOURCE_TAG end |
Instance Attribute Details
#type ⇒ Object
Returns the value of attribute type.
14 15 16 |
# File 'lib/contrast/agent/assess/policy/source_node.rb', line 14 def type @type end |
Instance Method Details
#node_class ⇒ Object
25 26 27 |
# File 'lib/contrast/agent/assess/policy/source_node.rb', line 25 def node_class SOURCE end |
#node_type ⇒ Object
This is confusing. Sources are Creation action but Propagation type. Oh and also Type refers to input type, like parameter, so we have to call this node_type. :-/
32 33 34 |
# File 'lib/contrast/agent/assess/policy/source_node.rb', line 32 def node_type :TYPE_PROPAGATION end |
#validate ⇒ Object
Standard validation + TS trace version two rules: Must have source and type
38 39 40 41 42 |
# File 'lib/contrast/agent/assess/policy/source_node.rb', line 38 def validate super raise(ArgumentError, "Source #{ id } did not have a proper target. Unable to create.") unless targets&.any? raise(ArgumentError, "Source #{ id } did not have a proper type. Unable to create.") unless type end |