fluent-auditify 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.env +1 -0
- data/CHANGELOG.md +6 -0
- data/LICENSE.txt +202 -0
- data/README.md +37 -0
- data/Rakefile +13 -0
- data/exe/fluent-auditify +8 -0
- data/lib/fluent/auditify/command/auditify.rb +96 -0
- data/lib/fluent/auditify/helper/test.rb +72 -0
- data/lib/fluent/auditify/log.rb +77 -0
- data/lib/fluent/auditify/parser/v1config.rb +172 -0
- data/lib/fluent/auditify/parsletutil.rb +159 -0
- data/lib/fluent/auditify/plugin/base.rb +17 -0
- data/lib/fluent/auditify/plugin/conf.rb +135 -0
- data/lib/fluent/auditify/plugin/conf_buffer_file.rb +18 -0
- data/lib/fluent/auditify/plugin/conf_buffer_file_single.rb +18 -0
- data/lib/fluent/auditify/plugin/conf_buffer_memory.rb +18 -0
- data/lib/fluent/auditify/plugin/conf_filter_grep.rb +18 -0
- data/lib/fluent/auditify/plugin/conf_filter_parser.rb +18 -0
- data/lib/fluent/auditify/plugin/conf_filter_record_transformer.rb +18 -0
- data/lib/fluent/auditify/plugin/conf_filter_stdout.rb +18 -0
- data/lib/fluent/auditify/plugin/conf_in_exec.rb +18 -0
- data/lib/fluent/auditify/plugin/conf_in_forward.rb +18 -0
- data/lib/fluent/auditify/plugin/conf_in_http.rb +18 -0
- data/lib/fluent/auditify/plugin/conf_in_monitor_agent.rb +18 -0
- data/lib/fluent/auditify/plugin/conf_in_sample.rb +18 -0
- data/lib/fluent/auditify/plugin/conf_in_syslog.rb +18 -0
- data/lib/fluent/auditify/plugin/conf_in_tail.rb +18 -0
- data/lib/fluent/auditify/plugin/conf_in_tcp.rb +18 -0
- data/lib/fluent/auditify/plugin/conf_in_udp.rb +18 -0
- data/lib/fluent/auditify/plugin/conf_in_unix.rb +18 -0
- data/lib/fluent/auditify/plugin/conf_mask_secrets.rb +83 -0
- data/lib/fluent/auditify/plugin/conf_out_buffer.rb +18 -0
- data/lib/fluent/auditify/plugin/conf_out_copy.rb +18 -0
- data/lib/fluent/auditify/plugin/conf_out_exec.rb +18 -0
- data/lib/fluent/auditify/plugin/conf_out_exec_filter.rb +18 -0
- data/lib/fluent/auditify/plugin/conf_out_file.rb +18 -0
- data/lib/fluent/auditify/plugin/conf_out_forward.rb +18 -0
- data/lib/fluent/auditify/plugin/conf_out_http.rb +18 -0
- data/lib/fluent/auditify/plugin/conf_out_null.rb +18 -0
- data/lib/fluent/auditify/plugin/conf_out_relabel.rb +18 -0
- data/lib/fluent/auditify/plugin/conf_out_rewrite_tag_filter.rb +18 -0
- data/lib/fluent/auditify/plugin/conf_out_roundrobin.rb +18 -0
- data/lib/fluent/auditify/plugin/conf_out_secondary_file.rb +18 -0
- data/lib/fluent/auditify/plugin/conf_out_stdout.rb +18 -0
- data/lib/fluent/auditify/plugin/conf_plugin_params.rb +93 -0
- data/lib/fluent/auditify/plugin/conf_plugin_type.rb +113 -0
- data/lib/fluent/auditify/plugin/conf_v1dupid.rb +46 -0
- data/lib/fluent/auditify/plugin.rb +65 -0
- data/lib/fluent/auditify/plugin_manager.rb +178 -0
- data/lib/fluent/auditify/registry.rb +35 -0
- data/lib/fluent/auditify/reporter/console.rb +70 -0
- data/lib/fluent/auditify/reporter/json.rb +14 -0
- data/lib/fluent/auditify/reporter.rb +2 -0
- data/lib/fluent/auditify/syntax_checker.rb +30 -0
- data/lib/fluent/auditify/version.rb +7 -0
- data/lib/fluent/auditify.rb +9 -0
- data/sig/fluent/auditify.rbs +6 -0
- metadata +172 -0
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
require 'parslet'
|
|
2
|
+
|
|
3
|
+
module Fluent
|
|
4
|
+
module Auditify
|
|
5
|
+
module Parser
|
|
6
|
+
class V1ConfigBaseParser < ::Parslet::Parser
|
|
7
|
+
rule(:space) { match('[ \t]').repeat(1) }
|
|
8
|
+
rule(:space?) { space.maybe }
|
|
9
|
+
rule(:newline) { str("\r\n") | str("\n") | str("\r") }
|
|
10
|
+
rule(:newline?) { newline.maybe }
|
|
11
|
+
rule(:integer) { match('[0-9]').repeat(1) }
|
|
12
|
+
rule(:string) { str('"') >> match('[^"]').repeat >> str('"') }
|
|
13
|
+
rule(:identifier) { match('[A-Za-z0-9_-]').repeat(1) }
|
|
14
|
+
rule(:pattern) { match("[A-Za-z0-9_.*{},#'\"\\[\\]]").repeat(1) }
|
|
15
|
+
rule(:pattern?) { pattern.maybe }
|
|
16
|
+
rule(:empty_line) { space? >> newline }
|
|
17
|
+
rule(:comment) { space? >> str('#') >> match('[^\r\n]').repeat >> newline }
|
|
18
|
+
rule(:space_or_newline) { (space | newline).repeat(1) }
|
|
19
|
+
|
|
20
|
+
rule(:eof?) { (newline | any.absent?).maybe }
|
|
21
|
+
rule(:key) { str('@').maybe >> match('[a-zA-Z0-9_]').repeat(1) }
|
|
22
|
+
rule(:path) { match('[.a-z0-9A-Z_/\\*\\-]').repeat(1) }
|
|
23
|
+
rule(:ipv4) {
|
|
24
|
+
match('[0-9]').repeat(1,3) >>
|
|
25
|
+
(str('.') >> match('[0-9]').repeat(1,3)).repeat(3) }
|
|
26
|
+
rule(:nonspace_nonquote_char) { match('[^" \t\r\n]') }
|
|
27
|
+
rule(:unquoted_word) { (str('"').absent? >> nonspace_nonquote_char.repeat(1)) }
|
|
28
|
+
rule(:value) { string | unquoted_word }
|
|
29
|
+
rule(:key_value) { space? >> key.as(:name) >> space >> value.as(:value) >>
|
|
30
|
+
space? >> newline }
|
|
31
|
+
rule(:key_line) { space? >> key.as(:name) >> space_or_newline }
|
|
32
|
+
|
|
33
|
+
rule(:tag_name) { match('[a-zA-Z0-9_]').repeat(1) }
|
|
34
|
+
rule(:open_tag) { str('<') >> tag_name.as(:name) >>
|
|
35
|
+
(space >> tag_name.as(:section_arg)).maybe >> str('>') }
|
|
36
|
+
rule(:close_tag) { str('</') >> tag_name.as(:name) >> str('>') }
|
|
37
|
+
|
|
38
|
+
rule(:conf_path) { (match("[^\s\.]+").repeat(1) >> str('.conf')) }
|
|
39
|
+
rule(:yaml_path) do
|
|
40
|
+
(match("[^\s\.]+").repeat(1) >> str('.yaml')) |
|
|
41
|
+
(match("[^\s\.]+").repeat(1) >> str('.yml'))
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
class V1ConfigParamParser < V1ConfigBaseParser
|
|
46
|
+
# @include key-value-pair conf
|
|
47
|
+
|
|
48
|
+
rule(:conf) { (comment | key_value | key.as(:name) | empty_line).repeat.as(:body) }
|
|
49
|
+
|
|
50
|
+
root :conf
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
class V1ConfigSectionParser < V1ConfigBaseParser
|
|
54
|
+
# @include section conf
|
|
55
|
+
rule(:tag_name) { match('[a-zA-Z0-9_]').repeat(1) }
|
|
56
|
+
rule(:open_tag) { str('<') >> tag_name.as(:name) >>
|
|
57
|
+
(space >> tag_name.as(:section_arg)).maybe >> str('>') }
|
|
58
|
+
rule(:close_tag) { str('</') >> tag_name.as(:name) >> str('>') }
|
|
59
|
+
rule(:section) do
|
|
60
|
+
space? >> open_tag.as(:section) >> space_or_newline >>
|
|
61
|
+
(comment | key_value | section | key.as(:name) | empty_line.as(:empty_line)).repeat.as(:body) >>
|
|
62
|
+
space? >> close_tag >> space? >> eof?
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
rule(:conf) { (comment | key_value | key.as(:name) | empty_line.as(:empty_line) | section).repeat }
|
|
66
|
+
root :conf
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
class V1ConfigParser < V1ConfigBaseParser
|
|
70
|
+
|
|
71
|
+
rule(:system) do
|
|
72
|
+
space? >> str('<system>').as(:system) >> space_or_newline.maybe >>
|
|
73
|
+
(comment | key_value | empty_line.as(:empty_line) | section).repeat.as(:body) >>
|
|
74
|
+
space? >> str('</system>') >> space? >> eof?
|
|
75
|
+
end
|
|
76
|
+
rule(:include_directive) do
|
|
77
|
+
space? >> str('@include').as(:include) >> space >>
|
|
78
|
+
(conf_path | yaml_path).as(:include_path) >> eof?
|
|
79
|
+
end
|
|
80
|
+
rule(:source) do
|
|
81
|
+
space? >> str('<source>').as(:source) >> space_or_newline >>
|
|
82
|
+
(comment | empty_line.as(:empty_line) | key_value | key_line | section).repeat.as(:body) >>
|
|
83
|
+
space? >> str('</source>') >> space_or_newline.maybe >> eof?
|
|
84
|
+
end
|
|
85
|
+
rule(:section) do
|
|
86
|
+
space? >> open_tag.as(:section) >> space_or_newline >>
|
|
87
|
+
(comment | key_value | empty_line | key_line | section).repeat.as(:body) >>
|
|
88
|
+
space? >> close_tag >> eof?
|
|
89
|
+
end
|
|
90
|
+
rule(:filter) do
|
|
91
|
+
space? >> str('<filter').as(:filter) >> space? >> pattern?.as(:pattern) >> str('>') >> space_or_newline >>
|
|
92
|
+
(comment | key_value | empty_line | section).repeat.as(:body) >>
|
|
93
|
+
space? >> str('</filter>') >> eof?
|
|
94
|
+
end
|
|
95
|
+
# match is reserved word
|
|
96
|
+
rule(:match_directive) do
|
|
97
|
+
space? >> str('<match').as(:match) >> space? >> pattern?.as(:pattern) >> str('>') >> space_or_newline >>
|
|
98
|
+
(comment | key_value | empty_line.as(:empty_line) | section).repeat.as(:body) >>
|
|
99
|
+
space? >> str('</match>') >> eof?
|
|
100
|
+
end
|
|
101
|
+
rule(:label) do
|
|
102
|
+
space? >> str('<label').as(:label) >> space? >> key.as(:name) >> str('>') >> space_or_newline >>
|
|
103
|
+
(comment | filter | match_directive).repeat.as(:body) >>
|
|
104
|
+
space? >> str('</label>') >> eof?
|
|
105
|
+
end
|
|
106
|
+
rule(:directive) { system | source | filter | match_directive | include_directive | label} # | filter | match | label | empty_line }
|
|
107
|
+
rule(:conf) { (directive | comment | empty_line.as(:empty_line)).repeat(1) }
|
|
108
|
+
|
|
109
|
+
root :conf
|
|
110
|
+
|
|
111
|
+
# expand @include directive
|
|
112
|
+
def self.eval(object, base_dir: "", path: "", include: true)
|
|
113
|
+
modified = []
|
|
114
|
+
object.each_with_index do |element, index|
|
|
115
|
+
element[:__BASE__] = base_dir
|
|
116
|
+
element[:__PATH__] = path
|
|
117
|
+
unless element[:include]
|
|
118
|
+
if element[:empty_line]
|
|
119
|
+
modified << element
|
|
120
|
+
elsif element[:body].collect { |v| v[:name].to_s }.any?('@include')
|
|
121
|
+
# include section
|
|
122
|
+
modified_body = []
|
|
123
|
+
element[:body].each do |body_element|
|
|
124
|
+
if body_element[:name].to_s == '@include'
|
|
125
|
+
parser = Fluent::Auditify::Parser::V1ConfigSectionParser.new
|
|
126
|
+
parsed = parser.parse(File.read(File.join(base_dir, body_element[:value])))
|
|
127
|
+
parsed.each do |elem|
|
|
128
|
+
elem[:__PATH__] = body_element[:value].to_s
|
|
129
|
+
modified_body << elem
|
|
130
|
+
end
|
|
131
|
+
else
|
|
132
|
+
modified_body << body_element
|
|
133
|
+
end
|
|
134
|
+
end
|
|
135
|
+
element[:body] = modified_body
|
|
136
|
+
modified << element
|
|
137
|
+
else
|
|
138
|
+
modified << element
|
|
139
|
+
end
|
|
140
|
+
next
|
|
141
|
+
end
|
|
142
|
+
parser = Fluent::Auditify::Parser::V1ConfigParser.new
|
|
143
|
+
pattern = File.expand_path(element[:include_path].to_s, base_dir)
|
|
144
|
+
Dir.glob(pattern).sort.each do |path|
|
|
145
|
+
included = parser.parse(File.read(path))
|
|
146
|
+
included.each do |child|
|
|
147
|
+
child[:__PATTERN__] = element[:include_path].to_s
|
|
148
|
+
child[:__PATH__] = Pathname.new(path).relative_path_from(base_dir).to_s
|
|
149
|
+
child[:__BASE__] = base_dir
|
|
150
|
+
modified << child
|
|
151
|
+
end
|
|
152
|
+
end
|
|
153
|
+
end
|
|
154
|
+
modified
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
def find_nth_element(object, nth: 1, elements: [])
|
|
158
|
+
count = 0
|
|
159
|
+
elements.each do |element|
|
|
160
|
+
if element[object.intern]
|
|
161
|
+
count += 1
|
|
162
|
+
if nth == count
|
|
163
|
+
return element
|
|
164
|
+
end
|
|
165
|
+
end
|
|
166
|
+
end
|
|
167
|
+
nil
|
|
168
|
+
end
|
|
169
|
+
end
|
|
170
|
+
end
|
|
171
|
+
end
|
|
172
|
+
end
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
require 'stringio'
|
|
2
|
+
|
|
3
|
+
module Fluent
|
|
4
|
+
module Auditify
|
|
5
|
+
class ParsletUtil
|
|
6
|
+
def initialize(options={})
|
|
7
|
+
reset_style
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def reset_style
|
|
11
|
+
@indent_level = 0
|
|
12
|
+
@align = 2
|
|
13
|
+
@content = StringIO.new
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def collect_file_handlers(object)
|
|
17
|
+
handlers = {}
|
|
18
|
+
object.each do |directive|
|
|
19
|
+
if directive[:empty_line]
|
|
20
|
+
key = directive[:__PATH__]
|
|
21
|
+
unless key and handlers.key?(key)
|
|
22
|
+
if key
|
|
23
|
+
handlers[key] = File.open(key, 'w+')
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
elsif directive[:source] or directive[:match] or
|
|
27
|
+
directive[:system] or directive[:filter]
|
|
28
|
+
key = directive[:__PATH__]
|
|
29
|
+
unless key and handlers.key?(key)
|
|
30
|
+
if key
|
|
31
|
+
handlers[key] = File.open(key, 'w+')
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
directive[:body].each do |body|
|
|
35
|
+
key = body[:__PATH__]
|
|
36
|
+
unless key and handlers.key?(key)
|
|
37
|
+
if key
|
|
38
|
+
handlers[key] = File.open(key, 'w+')
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
handlers
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def export(object, options={})
|
|
48
|
+
# setup rewrite file handles
|
|
49
|
+
@handlers = collect_file_handlers(object)
|
|
50
|
+
object.each do |directive|
|
|
51
|
+
io = @handlers[directive[:__PATH__]]
|
|
52
|
+
if directive[:system]
|
|
53
|
+
io.puts("#{' ' * @align * @indent_level}#{directive[:system].to_s}") if io
|
|
54
|
+
export_body(directive)
|
|
55
|
+
io.puts('</system>') if io
|
|
56
|
+
elsif directive[:source]
|
|
57
|
+
io.puts "#{' ' * @align * @indent_level}#{directive[:source].to_s}" if io
|
|
58
|
+
export_body(directive)
|
|
59
|
+
io.puts('</source>') if io
|
|
60
|
+
elsif directive[:filter]
|
|
61
|
+
io.puts "#{' ' * @align * @indent_level}#{directive[:filter].to_s}" if io
|
|
62
|
+
export_body(directive)
|
|
63
|
+
io.puts('</filter>') if io
|
|
64
|
+
elsif directive[:match]
|
|
65
|
+
io.puts "#{' ' * @align * @indent_level}#{directive[:match].to_s}"
|
|
66
|
+
export_body(directive)
|
|
67
|
+
io.puts('</match>') if io
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
def export_body(directive)
|
|
73
|
+
directive[:body].each do |child|
|
|
74
|
+
if child[:section]
|
|
75
|
+
elsif child[:empty_line]
|
|
76
|
+
if child[:__PATH__]
|
|
77
|
+
io = @handlers[child[:__PATH__]]
|
|
78
|
+
if io
|
|
79
|
+
io.puts
|
|
80
|
+
end
|
|
81
|
+
else
|
|
82
|
+
io = @handlers[directive[:__PATH__]]
|
|
83
|
+
if io
|
|
84
|
+
io.puts
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
elsif child[:value]
|
|
88
|
+
io = @handlers[child[:__PATH__]]
|
|
89
|
+
if io
|
|
90
|
+
io.puts("#{' ' * @align * @indent_level}#{child[:name].to_s} #{child[:value].to_s}")
|
|
91
|
+
end
|
|
92
|
+
elsif child[:name]
|
|
93
|
+
io = @handlers[child[:__PATH__]]
|
|
94
|
+
if io
|
|
95
|
+
io.puts("#{' ' * @align * @indent_level}#{child[:name].to_s}")
|
|
96
|
+
end
|
|
97
|
+
end
|
|
98
|
+
end
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
def to_s(object, options={})
|
|
102
|
+
object.each do |directive|
|
|
103
|
+
if directive[:source]
|
|
104
|
+
@content.puts "#{' ' * @align * @indent_level}#{directive[:source].to_s}"
|
|
105
|
+
stringify_body(directive)
|
|
106
|
+
@content.puts "</source>"
|
|
107
|
+
elsif directive[:match]
|
|
108
|
+
@content.puts "#{' ' * @align * @indent_level}#{directive[:match].to_s}>"
|
|
109
|
+
stringify_body(directive)
|
|
110
|
+
@content.puts "</match>"
|
|
111
|
+
elsif directive[:system]
|
|
112
|
+
@content.puts "#{' ' * @align * @indent_level}#{directive[:system].to_s}"
|
|
113
|
+
stringify_body(directive)
|
|
114
|
+
@content.puts "</system>"
|
|
115
|
+
elsif directive[:empty_line]
|
|
116
|
+
@content.puts
|
|
117
|
+
else
|
|
118
|
+
end
|
|
119
|
+
rescue => e
|
|
120
|
+
p e
|
|
121
|
+
end
|
|
122
|
+
@content.string
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
private
|
|
126
|
+
|
|
127
|
+
def stringify_body(directive)
|
|
128
|
+
@indent_level += 1
|
|
129
|
+
directive[:body].each do |child|
|
|
130
|
+
if child[:section]
|
|
131
|
+
stringify_section(child)
|
|
132
|
+
elsif child[:empty_line]
|
|
133
|
+
@content.puts
|
|
134
|
+
elsif child[:value]
|
|
135
|
+
@content.puts "#{' ' * @align * @indent_level}#{child[:name].to_s} #{child[:value].to_s}"
|
|
136
|
+
elsif child[:name]
|
|
137
|
+
@content.puts "#{' ' * @align * @indent_level}#{child[:name].to_s}"
|
|
138
|
+
else
|
|
139
|
+
end
|
|
140
|
+
end
|
|
141
|
+
@indent_level -= 1
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
def stringify_section(section)
|
|
145
|
+
@content.puts "#{' ' * @align * @indent_level}<#{section[:section][:name].to_s}>"
|
|
146
|
+
@indent_level += 1
|
|
147
|
+
section[:body].each do |child|
|
|
148
|
+
if child[:section]
|
|
149
|
+
stringify_section(child)
|
|
150
|
+
elsif child[:name]
|
|
151
|
+
@content.puts "#{' ' * @align * @indent_level}#{child[:name].to_s} #{child[:value].to_s}"
|
|
152
|
+
end
|
|
153
|
+
end
|
|
154
|
+
@indent_level -= 1
|
|
155
|
+
@content.puts "#{' ' * @align * @indent_level}</#{section[:name].to_s}>"
|
|
156
|
+
end
|
|
157
|
+
end
|
|
158
|
+
end
|
|
159
|
+
end
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
require 'fluent/auditify/log'
|
|
2
|
+
require 'fluent/auditify/plugin/base'
|
|
3
|
+
|
|
4
|
+
module Fluent
|
|
5
|
+
module Auditify
|
|
6
|
+
module Plugin
|
|
7
|
+
class Conf < Base
|
|
8
|
+
|
|
9
|
+
def initialize
|
|
10
|
+
super
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def supported_platform?
|
|
14
|
+
raise NotImplementedError
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def supported_file_extension?
|
|
18
|
+
[:conf]
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def disabled?
|
|
22
|
+
@disabled
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def parse(config_path, options={})
|
|
26
|
+
raise NotImplementedError
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def yaml?(path)
|
|
30
|
+
path.end_with?('.yml', '.yaml')
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def conf?(path)
|
|
34
|
+
path.end_with?('.conf')
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def read_with_include_directive(path)
|
|
38
|
+
contents = []
|
|
39
|
+
File.open(path) do |f|
|
|
40
|
+
f.readlines.each_with_index do |line, index|
|
|
41
|
+
if line.strip.start_with?('@include')
|
|
42
|
+
target = File.expand_path(line.split.last, File.dirname(path))
|
|
43
|
+
contents = (contents << file_get_contents(target, lines: true, include: true)).flattern
|
|
44
|
+
else
|
|
45
|
+
contents << {line: index, content: line, path: path}
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
contents
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def file_get_contents(path, lines: false, include: false)
|
|
53
|
+
contents = []
|
|
54
|
+
if lines
|
|
55
|
+
if include
|
|
56
|
+
contents = read_with_include_directive(path)
|
|
57
|
+
else
|
|
58
|
+
File.open(path) do |f|
|
|
59
|
+
f.readlines.each_with_index do |line, index|
|
|
60
|
+
contents << {line: index, content: line, path: path}
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
else
|
|
65
|
+
if include
|
|
66
|
+
contents = read_with_include_directive(path).collect do |entry|
|
|
67
|
+
entry[:content]
|
|
68
|
+
end.join
|
|
69
|
+
else
|
|
70
|
+
contents = File.open(path) do |f| f.read end
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
contents
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def file_readlines_each(conf)
|
|
77
|
+
File.open(conf) do |f|
|
|
78
|
+
f.readlines.each_with_index do |line, index|
|
|
79
|
+
yield line, index
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
def guilty(level, message, options={})
|
|
85
|
+
Plugin.guilty(level, message, options)
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
def polish(object)
|
|
89
|
+
Plugin.polish(object)
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
def artifact
|
|
93
|
+
Plugin.artifact
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
def plugin_defs(type, plugin_name)
|
|
97
|
+
spec = {}
|
|
98
|
+
begin
|
|
99
|
+
IO.popen(['fluent-plugin-config-format', '--compact', '--format', 'json', type, plugin_name]) do |io|
|
|
100
|
+
json = JSON.parse(io.read)
|
|
101
|
+
json.each do |klass, defs|
|
|
102
|
+
next if klass == 'plugin_helpers'
|
|
103
|
+
next if klass == "Fluent::Plugin::#{type[0].upcase}#{type[1..]}"
|
|
104
|
+
next if klass.split('::').count != 3
|
|
105
|
+
spec = defs
|
|
106
|
+
end
|
|
107
|
+
end
|
|
108
|
+
rescue => e
|
|
109
|
+
log.error("failed to get plugin specification: #{e.message}")
|
|
110
|
+
end
|
|
111
|
+
spec
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
def surround_text(path, line_num, range: 2, replace: nil)
|
|
115
|
+
lines = file_get_contents(path)
|
|
116
|
+
min = line_num - range > 0 ? line - 2 : 0
|
|
117
|
+
max = line_num + range < lines.size ? line_num + range : lines.size - 1
|
|
118
|
+
content = ""
|
|
119
|
+
min.upto(max).each_with_index do |line, index|
|
|
120
|
+
if replace
|
|
121
|
+
if min + index + 1 == line_num
|
|
122
|
+
content << "#{replace}\n"
|
|
123
|
+
else
|
|
124
|
+
content << "#{min + index + 1}: #{lines[min + index].chomp}\n"
|
|
125
|
+
end
|
|
126
|
+
else
|
|
127
|
+
content << "#{min + index + 1}: #{lines[min + index].chomp}\n"
|
|
128
|
+
end
|
|
129
|
+
end
|
|
130
|
+
content
|
|
131
|
+
end
|
|
132
|
+
end
|
|
133
|
+
end
|
|
134
|
+
end
|
|
135
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
require 'fluent/config/error'
|
|
2
|
+
require 'fluent/auditify/plugin/conf'
|
|
3
|
+
|
|
4
|
+
module Fluent::Auditify::Plugin
|
|
5
|
+
class ConfBufferFile < Conf
|
|
6
|
+
Fluent::Auditify::Plugin.register_conf('buffer_file', self)
|
|
7
|
+
|
|
8
|
+
def supported_platform?
|
|
9
|
+
:any
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def initialize
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def parse(conf, options={})
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
require 'fluent/config/error'
|
|
2
|
+
require 'fluent/auditify/plugin/conf'
|
|
3
|
+
|
|
4
|
+
module Fluent::Auditify::Plugin
|
|
5
|
+
class ConfBufferFileSingle < Conf
|
|
6
|
+
Fluent::Auditify::Plugin.register_conf('buffer_file_single', self)
|
|
7
|
+
|
|
8
|
+
def supported_platform?
|
|
9
|
+
:any
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def initialize
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def parse(conf, options={})
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
require 'fluent/config/error'
|
|
2
|
+
require 'fluent/auditify/plugin/conf'
|
|
3
|
+
|
|
4
|
+
module Fluent::Auditify::Plugin
|
|
5
|
+
class ConfBufferMemory < Conf
|
|
6
|
+
Fluent::Auditify::Plugin.register_conf('buffer_memory', self)
|
|
7
|
+
|
|
8
|
+
def supported_platform?
|
|
9
|
+
:any
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def initialize
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def parse(conf, options={})
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
require 'fluent/config/error'
|
|
2
|
+
require 'fluent/auditify/plugin/conf'
|
|
3
|
+
|
|
4
|
+
module Fluent::Auditify::Plugin
|
|
5
|
+
class ConfFilterGrep < Conf
|
|
6
|
+
Fluent::Auditify::Plugin.register_conf('filter_grep', self)
|
|
7
|
+
|
|
8
|
+
def supported_platform?
|
|
9
|
+
:any
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def initialize
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def parse(conf, options={})
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
require 'fluent/config/error'
|
|
2
|
+
require 'fluent/auditify/plugin/conf'
|
|
3
|
+
|
|
4
|
+
module Fluent::Auditify::Plugin
|
|
5
|
+
class ConfFilterParser < Conf
|
|
6
|
+
Fluent::Auditify::Plugin.register_conf('filter_parser', self)
|
|
7
|
+
|
|
8
|
+
def supported_platform?
|
|
9
|
+
:any
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def initialize
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def parse(conf, options={})
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
require 'fluent/config/error'
|
|
2
|
+
require 'fluent/auditify/plugin/conf'
|
|
3
|
+
|
|
4
|
+
module Fluent::Auditify::Plugin
|
|
5
|
+
class ConfFilterRecordTransformer < Conf
|
|
6
|
+
Fluent::Auditify::Plugin.register_conf('filter_record_transformer', self)
|
|
7
|
+
|
|
8
|
+
def supported_platform?
|
|
9
|
+
:any
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def initialize
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def parse(conf, options={})
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
require 'fluent/config/error'
|
|
2
|
+
require 'fluent/auditify/plugin/conf'
|
|
3
|
+
|
|
4
|
+
module Fluent::Auditify::Plugin
|
|
5
|
+
class ConfFilterStdout < Conf
|
|
6
|
+
Fluent::Auditify::Plugin.register_conf('filter_stdout', self)
|
|
7
|
+
|
|
8
|
+
def supported_platform?
|
|
9
|
+
:any
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def initialize
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def parse(conf, options={})
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
require 'fluent/config/error'
|
|
2
|
+
require 'fluent/auditify/plugin/conf'
|
|
3
|
+
|
|
4
|
+
module Fluent::Auditify::Plugin
|
|
5
|
+
class ConfInExec < Conf
|
|
6
|
+
Fluent::Auditify::Plugin.register_conf('in_exec', self)
|
|
7
|
+
|
|
8
|
+
def supported_platform?
|
|
9
|
+
:any
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def initialize
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def parse(conf, options={})
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
require 'fluent/config/error'
|
|
2
|
+
require 'fluent/auditify/plugin/conf'
|
|
3
|
+
|
|
4
|
+
module Fluent::Auditify::Plugin
|
|
5
|
+
class ConfInForward < Conf
|
|
6
|
+
Fluent::Auditify::Plugin.register_conf('in_forward', self)
|
|
7
|
+
|
|
8
|
+
def supported_platform?
|
|
9
|
+
:any
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def initialize
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def parse(conf, options={})
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
require 'fluent/config/error'
|
|
2
|
+
require 'fluent/auditify/plugin/conf'
|
|
3
|
+
|
|
4
|
+
module Fluent::Auditify::Plugin
|
|
5
|
+
class ConfInHttp < Conf
|
|
6
|
+
Fluent::Auditify::Plugin.register_conf('in_http', self)
|
|
7
|
+
|
|
8
|
+
def supported_platform?
|
|
9
|
+
:any
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def initialize
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def parse(conf, options={})
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|