Method: ScriptOutputParser#initialize

Defined in:
lib/audit/lib/parser/script_output_parser.rb

#initialize(options) ⇒ ScriptOutputParser

Create a new script output parser and set up the connection object that output is forwarded to this parser.

  • benchmark Benchmark that generates the output to parse.

  • connection Connection to the remote host where the benchmark is executed.

  • attachment_dir A writable directory path as string where file attachments from AttachFileCommand are supposed to be stored.



65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# File 'lib/audit/lib/parser/script_output_parser.rb', line 65

def initialize(options)
	raise "Need parameter :benchmark" unless options[:benchmark]
	raise "Need parameter :connection" unless options[:connection]

	@connection = options[:connection]
	@benchmark = options[:benchmark]
	
	if options[:attachment_dir] then
		@attachment_dir = options[:attachment_dir][-1] == '/' ? options[:attachment_dir][0 ... -1] : options[:attachment_dir]
		if !File.exists?(@attachment_dir) || !File.writable?(@attachment_dir) then
			raise SecurityError, "attachment directory #{@attachment_dir} is not writable"
		end
	else
		@attachment_dir = nil
	end
	
	@@log.level = Logger::DEBUG
	@@log = options[:logger] if options[:logger]
	
	@check_results = {}
	@rule_results = {}

	@total_time_units = 0
	@done_time_units = 0
	@total_time_units = @benchmark.duration()

	@stdout_line_buffer = StdoutLineBuffer.new(connection)
	@stdout_line_buffer.on_line do |msg|
		consume_stdout(msg)
	end
	
	connection.on_stderr do|msg|
		consume_stderr(msg)
	end
end