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,46 @@
|
|
|
1
|
+
require 'fluent/config/error'
|
|
2
|
+
require 'fluent/config/v1_parser'
|
|
3
|
+
require 'fluent/auditify/plugin/conf'
|
|
4
|
+
require 'fluent/auditify/parser/v1config'
|
|
5
|
+
|
|
6
|
+
module Fluent::Auditify::Plugin
|
|
7
|
+
class V1DuplicatedId < Conf
|
|
8
|
+
Fluent::Auditify::Plugin.register_conf('v1dupid', self)
|
|
9
|
+
|
|
10
|
+
#
|
|
11
|
+
# The duplicated @id is detected by default, but treated as
|
|
12
|
+
# Fluent::ConfigError and does not show problematic location
|
|
13
|
+
# in configuration file.
|
|
14
|
+
# This plugin demonstrate how to implement simple plugin
|
|
15
|
+
#
|
|
16
|
+
|
|
17
|
+
def supported_platform?
|
|
18
|
+
:any
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def parse(conf, options={})
|
|
22
|
+
begin
|
|
23
|
+
content = file_get_contents(conf)
|
|
24
|
+
root = Fluent::Config::V1Parser.parse(content, conf)
|
|
25
|
+
ids = []
|
|
26
|
+
root.elements.collect do |element|
|
|
27
|
+
ids << element["@id"]
|
|
28
|
+
end
|
|
29
|
+
duplicated_ids = ids.uniq.select do |id|
|
|
30
|
+
ids.count(id) > 1
|
|
31
|
+
end
|
|
32
|
+
duplicated_ids.each do |id|
|
|
33
|
+
file_readlines_each(conf) do |line, index|
|
|
34
|
+
next unless line.split.size == 2
|
|
35
|
+
if line.split == ["@id", id]
|
|
36
|
+
guilty(:error, "#{id} is duplicated",
|
|
37
|
+
{path: conf, line: index + 1, content: line.chomp, category: :syntax, plugin: :v1dupid})
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
rescue => e
|
|
42
|
+
log.error("parse error: #{e.message}")
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
require 'fluent/config/error'
|
|
2
|
+
require 'fluent/auditify/registry'
|
|
3
|
+
require 'logger'
|
|
4
|
+
|
|
5
|
+
module Fluent
|
|
6
|
+
module Auditify
|
|
7
|
+
module Plugin
|
|
8
|
+
|
|
9
|
+
# e.g. PATH_TO_...lib/fluent/auditify/plugin
|
|
10
|
+
DEFAULT_PLUGIN_PATH = File.expand_path('../plugin', __FILE__)
|
|
11
|
+
# e.g. PATH_TO_...lib/fluent/auditify
|
|
12
|
+
FLUENT_AUDITIFY_LIB_PATH = File.dirname(DEFAULT_PLUGIN_PATH)
|
|
13
|
+
|
|
14
|
+
CONF_REGISTRY = Registry.new(:conf, 'fluent/auditify/conf_')
|
|
15
|
+
|
|
16
|
+
REGISTRIES = [CONF_REGISTRY]
|
|
17
|
+
|
|
18
|
+
CHARGES = []
|
|
19
|
+
|
|
20
|
+
ARTIFACT = []
|
|
21
|
+
|
|
22
|
+
def self.charges
|
|
23
|
+
CHARGES
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def self.registries
|
|
27
|
+
REGISTRIES
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def self.discard
|
|
31
|
+
CHARGES.pop(CHARGES.size)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
# This method will be executed when require it
|
|
35
|
+
def self.register_conf(plugin_name, plugin_klass)
|
|
36
|
+
caller_with_location = caller_locations(1, 1).first
|
|
37
|
+
if caller_with_location.path.include?('/lib/fluent/auditify/plugin')
|
|
38
|
+
gem_name = File.basename(File.dirname(caller_with_location.path.sub('/lib/fluent/auditify/plugin', '')))
|
|
39
|
+
plugin_name = "#{plugin_name}@#{gem_name}"
|
|
40
|
+
else
|
|
41
|
+
raise Fluent::ConfigError, "Fluent Auditify plugin must be installed as gem: <#{plugin_name}>."
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
if !plugin_klass.is_a?(Class) and
|
|
45
|
+
!([:supported_platform?, :parse].all? { |v| plugin_klass.respond_to?(v) })
|
|
46
|
+
raise Fluent::ConfigError, "Invalid Fluent Auditify plugin implementation as 'conf' plugin: <#{plugin_name}>."
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
CONF_REGISTRY.register(:conf, plugin_name, plugin_klass)
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def self.guilty(level, message, options={})
|
|
53
|
+
CHARGES.push([level, message, options])
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def self.polish(object)
|
|
57
|
+
ARTIFACT.push(object)
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def self.artifact
|
|
61
|
+
ARTIFACT.pop
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
end
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
require 'fluent/auditify/plugin'
|
|
2
|
+
require 'fluent/auditify/reporter'
|
|
3
|
+
require 'fluent/auditify/reporter'
|
|
4
|
+
require 'tmpdir'
|
|
5
|
+
|
|
6
|
+
module Fluent
|
|
7
|
+
module Auditify
|
|
8
|
+
class PluginManager
|
|
9
|
+
include Plugin
|
|
10
|
+
|
|
11
|
+
def initialize(logger = nil, mask_only: false)
|
|
12
|
+
@logger = logger
|
|
13
|
+
@plugins = []
|
|
14
|
+
@mask_only = mask_only
|
|
15
|
+
load
|
|
16
|
+
Fluent::Auditify::Plugin.registries.each do |registry|
|
|
17
|
+
registry.map.each do |sym, klass|
|
|
18
|
+
@logger.debug("Instantiate #{klass} for <#{sym}> plugin") if @logger
|
|
19
|
+
@plugins << klass.new
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
# search plugin with prefix
|
|
25
|
+
def self.search(plugin_name, logger = nil)
|
|
26
|
+
# Find plugin and require it in advance
|
|
27
|
+
|
|
28
|
+
# Lastly, load built-in plugins
|
|
29
|
+
plugin_path = File.expand_path(File.join(FLUENT_AUDITIFY_LIB_PATH,
|
|
30
|
+
'fluent/auditify/plugin/conf_',
|
|
31
|
+
"#{plugin_name}.rb"))
|
|
32
|
+
if File.exist?(plugin_path)
|
|
33
|
+
logger.debug("Loading <#{plugin_path}>") if logger
|
|
34
|
+
require plugin_path
|
|
35
|
+
return
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def load
|
|
40
|
+
builtin_plugin_paths.each do |plugin_path|
|
|
41
|
+
@logger.debug("Loading <#{plugin_path}>") if @logger
|
|
42
|
+
if @mask_only
|
|
43
|
+
if plugin_path.include?('/lib/fluent/auditify/plugin/conf_mask_secrets.rb')
|
|
44
|
+
require plugin_path
|
|
45
|
+
end
|
|
46
|
+
else
|
|
47
|
+
require plugin_path
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def builtin_plugin_paths
|
|
53
|
+
Dir.glob("#{DEFAULT_PLUGIN_PATH}/*.rb").select do |path|
|
|
54
|
+
File.dirname(path) == DEFAULT_PLUGIN_PATH and
|
|
55
|
+
File.basename(path).start_with?('conf_')
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def windows?
|
|
60
|
+
%w(mswin mingw).any? { |v| RbConfig::CONFIG['host_os'].include?(v) }
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def linux?
|
|
64
|
+
RbConfig::CONFIG['host_os'].include?('linux')
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def supported_plugin?(plugin)
|
|
68
|
+
unless plugin.respond_to?(:supported_platform?)
|
|
69
|
+
@logger.info("Plugin: <#{plugin.class}> must implement supported_platform?")
|
|
70
|
+
return false
|
|
71
|
+
end
|
|
72
|
+
platform = plugin.supported_platform?
|
|
73
|
+
case platform
|
|
74
|
+
when :windows
|
|
75
|
+
unless windows?
|
|
76
|
+
@logger.debug("Plugin: <#{plugin.class}> does not support #{RbConfig::CONFIG['host_os']}")
|
|
77
|
+
return false
|
|
78
|
+
end
|
|
79
|
+
when :linux
|
|
80
|
+
unless linux?
|
|
81
|
+
@logger.debug("Plugin: <#{plugin.class}> does not support #{RbConfig::CONFIG['host_os']}")
|
|
82
|
+
return false
|
|
83
|
+
end
|
|
84
|
+
else
|
|
85
|
+
# :any
|
|
86
|
+
true
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
def skip_plugin?(plugin)
|
|
91
|
+
unless supported_plugin?(plugin)
|
|
92
|
+
return true
|
|
93
|
+
end
|
|
94
|
+
unless plugin.respond_to?(:parse)
|
|
95
|
+
return true
|
|
96
|
+
end
|
|
97
|
+
unless plugin.respond_to?(:supported_file_extension?)
|
|
98
|
+
return true
|
|
99
|
+
end
|
|
100
|
+
unless plugin.respond_to?(:disabled?)
|
|
101
|
+
return true
|
|
102
|
+
end
|
|
103
|
+
false
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
def collect_related_config_files(object)
|
|
107
|
+
files = []
|
|
108
|
+
object.each do |directive|
|
|
109
|
+
if directive[:include]
|
|
110
|
+
files << directive[:include_path].to_s
|
|
111
|
+
elsif directive[:empty_line]
|
|
112
|
+
next
|
|
113
|
+
else
|
|
114
|
+
directive[:body].each do |element|
|
|
115
|
+
if element[:value] and element[:name].to_s == '@include'
|
|
116
|
+
files << element[:value].to_s
|
|
117
|
+
end
|
|
118
|
+
end
|
|
119
|
+
end
|
|
120
|
+
end
|
|
121
|
+
files
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
def evacuate(options={})
|
|
125
|
+
@workspace_dir = Dir.mktmpdir('fluent-auditify')
|
|
126
|
+
@base_dir = File.dirname(options[:config])
|
|
127
|
+
parser = Fluent::Auditify::Parser::V1ConfigParser.new
|
|
128
|
+
object = parser.parse(File.read(options[:config]))
|
|
129
|
+
|
|
130
|
+
# copy configuration files into workspace
|
|
131
|
+
touched = [options[:config]]
|
|
132
|
+
touched << collect_related_config_files(object).collect { |v| File.join(@base_dir, v) }
|
|
133
|
+
touched.flatten!
|
|
134
|
+
FileUtils.cp(touched, @workspace_dir)
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
def dispatch(options={})
|
|
138
|
+
evacuate(options)
|
|
139
|
+
@plugins.each do |plugin|
|
|
140
|
+
next if skip_plugin?(plugin)
|
|
141
|
+
|
|
142
|
+
config_path = File.join(@workspace_dir, File.basename(options[:config]))
|
|
143
|
+
ext = plugin.supported_file_extension?
|
|
144
|
+
ext_symbol = File.extname(config_path).delete('.').to_sym
|
|
145
|
+
unless ext.any?(ext_symbol)
|
|
146
|
+
@logger.debug("#{plugin.class} does not support #{config_path}")
|
|
147
|
+
next
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
plugin.instance_variable_set(:@log, @logger)
|
|
151
|
+
begin
|
|
152
|
+
@logger.debug { "#{plugin.class}\#parse" }
|
|
153
|
+
plugin.parse(config_path, options)
|
|
154
|
+
|
|
155
|
+
if plugin.respond_to?(:transform)
|
|
156
|
+
tree = plugin.transform(config_path, options)
|
|
157
|
+
util = Fluent::Auditify::ParsletUtil.new
|
|
158
|
+
util.export(tree, options)
|
|
159
|
+
@logger.info("Configuration files were saved at: #{@workspace_dir}")
|
|
160
|
+
end
|
|
161
|
+
rescue => e
|
|
162
|
+
@logger.error("#{e.message}")
|
|
163
|
+
end
|
|
164
|
+
end
|
|
165
|
+
end
|
|
166
|
+
|
|
167
|
+
def report(type)
|
|
168
|
+
case type
|
|
169
|
+
when :console
|
|
170
|
+
reporter = Fluent::Auditify::Reporter::ConsoleReporter.new(@logger)
|
|
171
|
+
when :json
|
|
172
|
+
reporter Fluent::Auditify::Reporter::JsonReporter.new(@logger)
|
|
173
|
+
end
|
|
174
|
+
reporter.run(Plugin.charges)
|
|
175
|
+
end
|
|
176
|
+
end
|
|
177
|
+
end
|
|
178
|
+
end
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
require 'fluent/auditify'
|
|
2
|
+
|
|
3
|
+
module Fluent
|
|
4
|
+
module Auditify
|
|
5
|
+
class Registry
|
|
6
|
+
|
|
7
|
+
attr_reader :map
|
|
8
|
+
|
|
9
|
+
def initialize(kind, prefix)
|
|
10
|
+
@kind = kind
|
|
11
|
+
# e.g. lib/fluent/auditify/conf_
|
|
12
|
+
@search_prefix = prefix
|
|
13
|
+
@map = {}
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
# @param [String] name plugin name
|
|
17
|
+
# @return [Class] the object which inherit from Fluent::Auditify::Plugin
|
|
18
|
+
def lookup(name)
|
|
19
|
+
sym = "#{@kind}/#{name}".to_sym
|
|
20
|
+
return @map[sym] if @map[sym]
|
|
21
|
+
raise NotFoundPluginError.new("Unknown #{@kind} plugin", name: name)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
# @param [String] plugin_name plugin name without plugin type prefix
|
|
25
|
+
# @param [Class] plugin_klass inherit from Fluent::Auditify::Plugin
|
|
26
|
+
def register(kind, plugin_name, plugin_klass)
|
|
27
|
+
sym = "#{kind}/#{plugin_name}".to_sym
|
|
28
|
+
if @map.key?(sym)
|
|
29
|
+
raise DuplicatedPluginError.new("#{sym} is already registered")
|
|
30
|
+
end
|
|
31
|
+
@map[sym] = plugin_klass
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
require 'diff/lcs'
|
|
2
|
+
require 'pastel'
|
|
3
|
+
|
|
4
|
+
module Fluent
|
|
5
|
+
module Auditify
|
|
6
|
+
module Reporter
|
|
7
|
+
class ConsoleReporter
|
|
8
|
+
def initialize(logger, options={})
|
|
9
|
+
@options = {
|
|
10
|
+
format: :auto
|
|
11
|
+
}
|
|
12
|
+
@options.merge!(options)
|
|
13
|
+
@logger = logger
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def bomb
|
|
17
|
+
"\u{1f4a3}"
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def file_get_contents(path)
|
|
21
|
+
File.open(path) do |f| f.readlines end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def run(charges, logger=nil)
|
|
25
|
+
charges.each do |entry|
|
|
26
|
+
message = entry.first
|
|
27
|
+
options = entry.last
|
|
28
|
+
if options[:line] and options[:content]
|
|
29
|
+
if @options[:format] == :auto
|
|
30
|
+
lines = file_get_contents(options[:path])
|
|
31
|
+
min = options[:line] - 2 > 0 ? options[:line] - 2 : 0
|
|
32
|
+
max = options[:line] + 2 < lines.size ? options[:line] + 2 : lines.size - 1
|
|
33
|
+
content = ""
|
|
34
|
+
suggested = ""
|
|
35
|
+
min.upto(max).each_with_index do |line, index|
|
|
36
|
+
content << "#{min + index + 1}: #{lines[min + index].chomp}\n"
|
|
37
|
+
if options[:suggest] and options[:line] == min + index + 1
|
|
38
|
+
suggested << "#{min + index + 1}: #{options[:suggest].chomp}\n"
|
|
39
|
+
else
|
|
40
|
+
suggested << "#{min + index + 1}: #{lines[min + index].chomp}\n"
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
if options[:suggest]
|
|
44
|
+
diff_content = ''
|
|
45
|
+
Diff::LCS.sdiff(content.chars, suggested.chars).each do |change|
|
|
46
|
+
case change.action
|
|
47
|
+
when '-'
|
|
48
|
+
diff_content << Pastel.new.red(change.old_element)
|
|
49
|
+
when '+'
|
|
50
|
+
diff_content << Pastel.new.green(change.new_element)
|
|
51
|
+
else
|
|
52
|
+
diff_content << change.old_element
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
@logger.error("#{bomb} [plugin:#{options[:plugin]},category:#{options[:category]}] #{message} at #{options[:path]}:#{options[:line]}\n#{diff_content}")
|
|
56
|
+
else
|
|
57
|
+
@logger.error("#{bomb} [plugin:#{options[:plugin]},category:#{options[:category]}] #{message} at #{options[:path]}:#{options[:line]}\n#{content}")
|
|
58
|
+
end
|
|
59
|
+
else
|
|
60
|
+
@logger.error("#{bomb} [plugin:#{options[:plugin]},category:#{options[:category]}] #{message} at #{options[:path]}:#{options[:line]}: #{options[:content]}")
|
|
61
|
+
end
|
|
62
|
+
else
|
|
63
|
+
@logger.error("#{bomb} [plugin:#{options[:plugin]},category:#{options[:category]}] #{message} at #{options[:path]}")
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
end
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
require 'fluent/auditify/plugin/base'
|
|
2
|
+
require 'fluent/auditify/plugin_manager'
|
|
3
|
+
require 'fluent/auditify/log'
|
|
4
|
+
|
|
5
|
+
module Fluent
|
|
6
|
+
module Auditify
|
|
7
|
+
class SyntaxChecker
|
|
8
|
+
def initialize(options={})
|
|
9
|
+
log_options = {
|
|
10
|
+
log_level: options[:log_level] || Logger::INFO,
|
|
11
|
+
color: options[:color]
|
|
12
|
+
}
|
|
13
|
+
@logger = Fluent::Auditify::Log.new(log_options)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def run(options={})
|
|
17
|
+
if options[:mask_only]
|
|
18
|
+
@manager = Fluent::Auditify::PluginManager.new(@logger, mask_only: true)
|
|
19
|
+
@manager.dispatch(options)
|
|
20
|
+
else
|
|
21
|
+
@manager = Fluent::Auditify::PluginManager.new(@logger)
|
|
22
|
+
@manager.dispatch(options)
|
|
23
|
+
# instance
|
|
24
|
+
@manager.report(:console)
|
|
25
|
+
end
|
|
26
|
+
true
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: fluent-auditify
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Kentaro Hayashi
|
|
8
|
+
bindir: exe
|
|
9
|
+
cert_chain: []
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
|
+
dependencies:
|
|
12
|
+
- !ruby/object:Gem::Dependency
|
|
13
|
+
name: fluentd
|
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
|
15
|
+
requirements:
|
|
16
|
+
- - "<"
|
|
17
|
+
- !ruby/object:Gem::Version
|
|
18
|
+
version: '2.0'
|
|
19
|
+
type: :runtime
|
|
20
|
+
prerelease: false
|
|
21
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
22
|
+
requirements:
|
|
23
|
+
- - "<"
|
|
24
|
+
- !ruby/object:Gem::Version
|
|
25
|
+
version: '2.0'
|
|
26
|
+
- !ruby/object:Gem::Dependency
|
|
27
|
+
name: parslet
|
|
28
|
+
requirement: !ruby/object:Gem::Requirement
|
|
29
|
+
requirements:
|
|
30
|
+
- - "~>"
|
|
31
|
+
- !ruby/object:Gem::Version
|
|
32
|
+
version: 2.0.0
|
|
33
|
+
type: :runtime
|
|
34
|
+
prerelease: false
|
|
35
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
36
|
+
requirements:
|
|
37
|
+
- - "~>"
|
|
38
|
+
- !ruby/object:Gem::Version
|
|
39
|
+
version: 2.0.0
|
|
40
|
+
- !ruby/object:Gem::Dependency
|
|
41
|
+
name: pastel
|
|
42
|
+
requirement: !ruby/object:Gem::Requirement
|
|
43
|
+
requirements:
|
|
44
|
+
- - "~>"
|
|
45
|
+
- !ruby/object:Gem::Version
|
|
46
|
+
version: 0.8.0
|
|
47
|
+
type: :runtime
|
|
48
|
+
prerelease: false
|
|
49
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
50
|
+
requirements:
|
|
51
|
+
- - "~>"
|
|
52
|
+
- !ruby/object:Gem::Version
|
|
53
|
+
version: 0.8.0
|
|
54
|
+
- !ruby/object:Gem::Dependency
|
|
55
|
+
name: diff-lcs
|
|
56
|
+
requirement: !ruby/object:Gem::Requirement
|
|
57
|
+
requirements:
|
|
58
|
+
- - "~>"
|
|
59
|
+
- !ruby/object:Gem::Version
|
|
60
|
+
version: 1.6.2
|
|
61
|
+
type: :runtime
|
|
62
|
+
prerelease: false
|
|
63
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
64
|
+
requirements:
|
|
65
|
+
- - "~>"
|
|
66
|
+
- !ruby/object:Gem::Version
|
|
67
|
+
version: 1.6.2
|
|
68
|
+
- !ruby/object:Gem::Dependency
|
|
69
|
+
name: term-ansicolor
|
|
70
|
+
requirement: !ruby/object:Gem::Requirement
|
|
71
|
+
requirements:
|
|
72
|
+
- - "~>"
|
|
73
|
+
- !ruby/object:Gem::Version
|
|
74
|
+
version: 1.11.2
|
|
75
|
+
type: :runtime
|
|
76
|
+
prerelease: false
|
|
77
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
78
|
+
requirements:
|
|
79
|
+
- - "~>"
|
|
80
|
+
- !ruby/object:Gem::Version
|
|
81
|
+
version: 1.11.2
|
|
82
|
+
description: Audit your Fluentd configuration and raise attention to you
|
|
83
|
+
email:
|
|
84
|
+
- kenhys@gmail.com
|
|
85
|
+
executables:
|
|
86
|
+
- fluent-auditify
|
|
87
|
+
extensions: []
|
|
88
|
+
extra_rdoc_files: []
|
|
89
|
+
files:
|
|
90
|
+
- ".env"
|
|
91
|
+
- CHANGELOG.md
|
|
92
|
+
- LICENSE.txt
|
|
93
|
+
- README.md
|
|
94
|
+
- Rakefile
|
|
95
|
+
- exe/fluent-auditify
|
|
96
|
+
- lib/fluent/auditify.rb
|
|
97
|
+
- lib/fluent/auditify/command/auditify.rb
|
|
98
|
+
- lib/fluent/auditify/helper/test.rb
|
|
99
|
+
- lib/fluent/auditify/log.rb
|
|
100
|
+
- lib/fluent/auditify/parser/v1config.rb
|
|
101
|
+
- lib/fluent/auditify/parsletutil.rb
|
|
102
|
+
- lib/fluent/auditify/plugin.rb
|
|
103
|
+
- lib/fluent/auditify/plugin/base.rb
|
|
104
|
+
- lib/fluent/auditify/plugin/conf.rb
|
|
105
|
+
- lib/fluent/auditify/plugin/conf_buffer_file.rb
|
|
106
|
+
- lib/fluent/auditify/plugin/conf_buffer_file_single.rb
|
|
107
|
+
- lib/fluent/auditify/plugin/conf_buffer_memory.rb
|
|
108
|
+
- lib/fluent/auditify/plugin/conf_filter_grep.rb
|
|
109
|
+
- lib/fluent/auditify/plugin/conf_filter_parser.rb
|
|
110
|
+
- lib/fluent/auditify/plugin/conf_filter_record_transformer.rb
|
|
111
|
+
- lib/fluent/auditify/plugin/conf_filter_stdout.rb
|
|
112
|
+
- lib/fluent/auditify/plugin/conf_in_exec.rb
|
|
113
|
+
- lib/fluent/auditify/plugin/conf_in_forward.rb
|
|
114
|
+
- lib/fluent/auditify/plugin/conf_in_http.rb
|
|
115
|
+
- lib/fluent/auditify/plugin/conf_in_monitor_agent.rb
|
|
116
|
+
- lib/fluent/auditify/plugin/conf_in_sample.rb
|
|
117
|
+
- lib/fluent/auditify/plugin/conf_in_syslog.rb
|
|
118
|
+
- lib/fluent/auditify/plugin/conf_in_tail.rb
|
|
119
|
+
- lib/fluent/auditify/plugin/conf_in_tcp.rb
|
|
120
|
+
- lib/fluent/auditify/plugin/conf_in_udp.rb
|
|
121
|
+
- lib/fluent/auditify/plugin/conf_in_unix.rb
|
|
122
|
+
- lib/fluent/auditify/plugin/conf_mask_secrets.rb
|
|
123
|
+
- lib/fluent/auditify/plugin/conf_out_buffer.rb
|
|
124
|
+
- lib/fluent/auditify/plugin/conf_out_copy.rb
|
|
125
|
+
- lib/fluent/auditify/plugin/conf_out_exec.rb
|
|
126
|
+
- lib/fluent/auditify/plugin/conf_out_exec_filter.rb
|
|
127
|
+
- lib/fluent/auditify/plugin/conf_out_file.rb
|
|
128
|
+
- lib/fluent/auditify/plugin/conf_out_forward.rb
|
|
129
|
+
- lib/fluent/auditify/plugin/conf_out_http.rb
|
|
130
|
+
- lib/fluent/auditify/plugin/conf_out_null.rb
|
|
131
|
+
- lib/fluent/auditify/plugin/conf_out_relabel.rb
|
|
132
|
+
- lib/fluent/auditify/plugin/conf_out_rewrite_tag_filter.rb
|
|
133
|
+
- lib/fluent/auditify/plugin/conf_out_roundrobin.rb
|
|
134
|
+
- lib/fluent/auditify/plugin/conf_out_secondary_file.rb
|
|
135
|
+
- lib/fluent/auditify/plugin/conf_out_stdout.rb
|
|
136
|
+
- lib/fluent/auditify/plugin/conf_plugin_params.rb
|
|
137
|
+
- lib/fluent/auditify/plugin/conf_plugin_type.rb
|
|
138
|
+
- lib/fluent/auditify/plugin/conf_v1dupid.rb
|
|
139
|
+
- lib/fluent/auditify/plugin_manager.rb
|
|
140
|
+
- lib/fluent/auditify/registry.rb
|
|
141
|
+
- lib/fluent/auditify/reporter.rb
|
|
142
|
+
- lib/fluent/auditify/reporter/console.rb
|
|
143
|
+
- lib/fluent/auditify/reporter/json.rb
|
|
144
|
+
- lib/fluent/auditify/syntax_checker.rb
|
|
145
|
+
- lib/fluent/auditify/version.rb
|
|
146
|
+
- sig/fluent/auditify.rbs
|
|
147
|
+
homepage: https://github.com/kenhys/fluent-auditify
|
|
148
|
+
licenses:
|
|
149
|
+
- Apache-2.0
|
|
150
|
+
metadata:
|
|
151
|
+
homepage_uri: https://github.com/kenhys/fluent-auditify
|
|
152
|
+
source_code_uri: https://github.com/kenhys/fluent-auditify
|
|
153
|
+
changelog_uri: https://github.com/kenhys/fluent-auditify/blob/master/CHANGELOG.md
|
|
154
|
+
rubygems_mfa_required: 'true'
|
|
155
|
+
rdoc_options: []
|
|
156
|
+
require_paths:
|
|
157
|
+
- lib
|
|
158
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
159
|
+
requirements:
|
|
160
|
+
- - ">="
|
|
161
|
+
- !ruby/object:Gem::Version
|
|
162
|
+
version: 2.7.0
|
|
163
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
164
|
+
requirements:
|
|
165
|
+
- - ">="
|
|
166
|
+
- !ruby/object:Gem::Version
|
|
167
|
+
version: '0'
|
|
168
|
+
requirements: []
|
|
169
|
+
rubygems_version: 3.6.9
|
|
170
|
+
specification_version: 4
|
|
171
|
+
summary: Audit tool for your Fluentd configuration
|
|
172
|
+
test_files: []
|