Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,14 @@ def configure(conf={})
def parse(text)
begin
parsed_line = @audit_parser.parse_audit_line text
time = parsed_line.nil? ? Time.now.to_f : DateTime.parse(parsed_line['time']).to_time.to_f

if parsed_line.nil?
t = Time.now
time = Fluent::EventTime.new(t.to_i, t.nsec)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: This repeatable line can be moved out of if...else..end scope.

else
t = DateTime.parse(parsed_line['time']).to_time
time = Fluent::EventTime.new(t.to_i, t.nsec)
end

yield time, parsed_line
rescue Fluent::ViaqHostAudit::ViaqHostAuditParserException => e
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ def create_driver(conf = '')
assert_equal('296', record['audit.linux']['record_id'])
assert_equal("2019-10-24T09:56:31.145999+00:00", record['time'])
assert_equal(message, record['message'])
assert_true(time.instance_of? Fluent::EventTime)
end
end
test 'AVC denial is detected' do
Expand All @@ -36,6 +37,7 @@ def create_driver(conf = '')
assert_equal('233', record['audit.linux']['record_id'])
assert_equal("2019-10-24T09:56:31.145999+00:00", record['time'])
assert_equal(message, record['message'])
assert_true(time.instance_of? Fluent::EventTime)
end
end
end
Expand Down