Class: MitmFlowArray

Inherits:
Array
  • Object
show all
Defined in:
lib/mitm_flow_array.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.from_file(filename) ⇒ Object



24
25
26
# File 'lib/mitm_flow_array.rb', line 24

def self.from_file(filename)
	MitmFlowArray.new(MitmdumpReader.new(filename).get_flows_from_file)
end

Instance Method Details

#filter(conditions) ⇒ Object



32
33
34
35
36
37
38
# File 'lib/mitm_flow_array.rb', line 32

def filter(conditions)
	result = self
	conditions.each do |jpath, re|
		result = result.select { |flow| JsonPath.new(jpath).first(flow).encode!('ISO-8859-1', 'UTF-8', :invalid => :replace, :undef => :replace, :replace => "") =~ re }
	end
	MitmFlowArray.new(result)
end

#values_by_jpath(jpath, first = true) ⇒ Object



28
29
30
# File 'lib/mitm_flow_array.rb', line 28

def values_by_jpath(jpath, first=true)
	self.map { |f| first ? JsonPath.new(jpath).first(f) : JsonPath.new(jpath).on(f) }
end