39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
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
|
# File 'lib/fluent/auditify/plugin/conf_plugin_params.rb', line 39
def process_conf(conf_path, options={})
content = file_get_contents(conf_path)
@parser = Fluent::Auditify::Parser::V1ConfigParser.new
object = @parser.parse(content)
root = Fluent::Config::V1Parser.parse(content, conf_path)
nth_source = 0
root.elements.collect do |element|
case element.name
when 'source'
type = 'input'
plugin_name = element['@type']
plugin_spec = plugin_defs(type, plugin_name)
element.keys.each do |param|
unless plugin_spec.key?(param)
if @options[:config_version] == :v1
next if param == '@type'
source = @parser.find_nth_element('source', nth: nth_source + 1, elements: object)
source[:body].each do |pair|
if pair[:name] == 'type' and pair[:value] == plugin_name
num = pair[:value].line_and_column.first
lines = file_get_contents(conf_path, lines: true)
guilty(:warn, "<#{param}> is deprecated, use @type instead",
{path: conf_path, line: num,
content: lines[num],
suggest: lines[num - 1][:content].sub(/type/, '@type'),
category: :params, plugin: :params})
elsif pair[:name] == param and not pair.key?(:value)
guilty(:error, "unknown <#{param}> parameter", {path: conf_path, category: :params, plugin: :params})
end
end
next
elsif options[:config_version] == :v0
next if param == 'type'
guilty(:error, "unknown <#{param}> parameter", {path: conf_path, category: :params, plugin: :params})
next
end
end
end
if Gem::Version.new(Fluent::VERSION) >= Gem::Version.new('1.7.0')
element.elements.each do |section|
unless plugin_spec.key?(section.name)
guilty(:error, "unknown <#{section.name}> directive", {path: conf_path, category: :params, plugin: :params})
end
end
end
end
end
end
|