module Police::DataFlow

Data flow labels “track” data as it is processed in a complex system.

Public Class Methods

label(data, label) click to toggle source

Attaches a label to a piece of data.

@param [BasicObject] data the data that will be labeled @param [Police::DataFlow::Label] label the label to be applied to the

object

@return [BasicObject] either the given piece of data, or a proxy that

should be used instead of it
# File lib/police/dataflow/labeling.rb, line 11
def self.label(data, label)
  label_set = data.__police_labels__
  if nil == label_set
    proxied = data
    label_set = {}
  else
    proxied = data.__police_proxied__
  end

  if Police::DataFlow::Labeling.add_label_to_set label, label_set
    data = Police::DataFlow::Proxying.proxy proxied, label_set
  end
  data
end
labels(data) click to toggle source

All the labels attached to a piece of data.

@param [Object] data the data whose labels are queried @return [Array<Police::DataFlow::Label>] all the labels attached to the

data
# File lib/police/dataflow/labeling.rb, line 31
def self.labels(data)
  return [] unless label_set = data.__police_labels__
  return label_set.first.last.keys if label_set.length == 1

  labels = []
  label_set.each { |label_key, label_hash| labels.concat label_hash.keys }
  labels
end
setup_gates() click to toggle source

Sets up label-propagating gates around all the native methods in the VM.

This method is idempotent, so it is safe to call it multiple times.

# File lib/police/dataflow/gating.rb, line 9
def self.setup_gates

end