Class: Police::DataFlow::Label
- Inherits:
-
Object
- Object
- Police::DataFlow::Label
- Defined in:
- lib/police/dataflow/label.rb
Overview
Superclass for objects used as data flow labels.
Class Method Summary collapse
-
.return_hook(method_name) ⇒ Symbol, NilClass
Label method changing the return value of a method in a labeled object.
-
.sticky? ⇒ Boolean
True for labels that automatically propagate across operations.
-
.yield_args_hook(method_name) ⇒ Symbol, NilClass
Label method changing the values yielded by a method in a labeled object.
Instance Method Summary collapse
-
#accepts?(data) ⇒ Boolean
An opportunity for a label to reject being attached to a piece of data.
-
#sample_return_hook(value, receiver, *args) ⇒ Object
Hook that can label a decorated method’s return value.
-
#sample_yield_args_hook(receiver, yield_args, *args) ⇒ Object
Hook that can label the values that a decorated method yields to its block.
Class Method Details
.return_hook(method_name) ⇒ Symbol, NilClass
Label method changing the return value of a method in a labeled object.
35 36 37 |
# File 'lib/police/dataflow/label.rb', line 35 def self.return_hook(method_name) :sample_return_hook end |
.sticky? ⇒ Boolean
True for labels that automatically propagate across operations.
This method’s return value is used for methods where the label does not provide a hook. When present, hooks are responsible for label propagation.
Labels that indicate privacy should be sticky. For example, an auto-generated message that contains a user’s phone number is just as sensitive as the phone number.
Labels that indicate sanitization should not be sticky. For example, a substring of an HTML-sanitized string is not necessarily HTML-sanitized.
22 23 24 |
# File 'lib/police/dataflow/label.rb', line 22 def self.sticky? true end |
.yield_args_hook(method_name) ⇒ Symbol, NilClass
Label method changing the values yielded by a method in a labeled object.
48 49 50 |
# File 'lib/police/dataflow/label.rb', line 48 def self.yield_args_hook(method_name) :sample_yield_args_hook end |
Instance Method Details
#accepts?(data) ⇒ Boolean
An opportunity for a label to reject being attached to a piece of data.
84 85 86 |
# File 'lib/police/dataflow/label.rb', line 84 def accepts?(data) true end |
#sample_return_hook(value, receiver, *args) ⇒ Object
Hook that can label a decorated method’s return value.
61 62 63 |
# File 'lib/police/dataflow/label.rb', line 61 def sample_return_hook(value, receiver, *args) Police::DataFlow.label value, self end |
#sample_yield_args_hook(receiver, yield_args, *args) ⇒ Object
Hook that can label the values that a decorated method yields to its block.
74 75 76 |
# File 'lib/police/dataflow/label.rb', line 74 def sample_yield_args_hook(receiver, yield_args, *args) yield_args.map! { |arg| Police::DataFlow.label arg, self } end |