fluent-auditify 0.1.0 → 0.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 488bfb6e158a298658a1b8487b9f5a366dceae787c7ca8da92fd0b6a20209fe2
4
- data.tar.gz: 5feb6c000fe34dbc4da2929bdef8c103f046aaf65cbc80a74f5d6a30634f4909
3
+ metadata.gz: 6e234cfa52ee9302d33cad2f099be103df74ee3d34d58130be1ab8a540e2baed
4
+ data.tar.gz: 0241bb9816a27f16304248198ba9186e72d504819a63abe1fb2131cf9a0023e2
5
5
  SHA512:
6
- metadata.gz: 37fcbad8013fed868bf58305e3c96509a7ccb209a3729668c44e8f79413ab780d150533da504cf9f8eb6b43de15351f9258b07e4855bfbbc0d62640ab1695273
7
- data.tar.gz: c56ba85d05b47b333d07aa4e0a4ab105eb732326d4dc2764e31f865a265cec2b9ab2ed1ceace30bd699448f480f03ad0a1efbb9c31ef8568df5468a368b04fe3
6
+ metadata.gz: d78ad3f05f6d5c3d9a6cde0c8791ab39ae3b65801a8d918b464486822b857486197cd2bbf6b3061a116473cfb35664ce4de2e5e432753b03f6a58e70fd72f5ba
7
+ data.tar.gz: 1e10a6072de19e430828550bc33c7fe3b426344bc8c838fc544d1e4a71291739bdba5276d8ad602b1e44ed99e197200a965ca301bda39d65b0f7544dfc59b09c
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.2.0] - 2025-11-15
4
+
5
+ * Support to load 3rd party plugin.
6
+
3
7
  ## [0.1.0] - 2025-11-14
4
8
 
5
9
  - Initial release. still in alpha version.
@@ -24,6 +24,10 @@ module Fluent::Auditify::Plugin
24
24
  :any
25
25
  end
26
26
 
27
+ def supported_file_extension?
28
+ [:conf]
29
+ end
30
+
27
31
  def mask_body(body)
28
32
  modified_body = []
29
33
  body.each do |child|
@@ -17,7 +17,7 @@ module Fluent::Auditify::Plugin
17
17
  end
18
18
 
19
19
  def supported_file_extension?
20
- [:conf, :yaml, :yml]
20
+ [:conf]
21
21
  end
22
22
 
23
23
  def initialize
@@ -47,6 +47,15 @@ module Fluent
47
47
  require plugin_path
48
48
  end
49
49
  end
50
+
51
+ Gem::Specification.each { |spec|
52
+ if spec.name.start_with?('fluent-auditify-plugin-')
53
+ Dir.glob("#{spec.full_gem_path}/lib/fluent/auditify/plugin/conf_*.rb") do |path|
54
+ @logger.debug("Loading <#{path}>") if @logger
55
+ require path
56
+ end
57
+ end
58
+ }
50
59
  end
51
60
 
52
61
  def builtin_plugin_paths
@@ -87,6 +96,21 @@ module Fluent
87
96
  end
88
97
  end
89
98
 
99
+ def supported_file_extension?(plugin, config)
100
+ unless plugin.respond_to?(:supported_file_extension?)
101
+ @logger.info("Plugin: <#{plugin.class}> must implement supported_file_extension?")
102
+ return false
103
+ end
104
+ if config.end_with?('.yml', '.yaml') and
105
+ plugin.supported_file_extension?.include?(:yaml)
106
+ return true
107
+ elsif config.end_with?('.conf') and
108
+ plugin.supported_file_extension?.include?(:conf)
109
+ return true
110
+ end
111
+ false
112
+ end
113
+
90
114
  def skip_plugin?(plugin)
91
115
  unless supported_plugin?(plugin)
92
116
  return true
@@ -123,15 +147,23 @@ module Fluent
123
147
 
124
148
  def evacuate(options={})
125
149
  @workspace_dir = Dir.mktmpdir('fluent-auditify')
150
+ @logger.debug("Create workspace under <#{@workspace_dir}>")
126
151
  @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)
152
+
153
+ if options[:config].end_with?('.conf')
154
+ parser = Fluent::Auditify::Parser::V1ConfigParser.new
155
+ object = parser.parse(File.read(options[:config]))
156
+
157
+ # copy configuration files into workspace
158
+ touched = [options[:config]]
159
+ touched << collect_related_config_files(object).collect { |v| File.join(@base_dir, v) }
160
+ touched.flatten!
161
+ @logger.debug("Copy configuration files: <#{touched}>")
162
+ FileUtils.cp(touched, @workspace_dir)
163
+ else
164
+ @logger.debug("Copy configuration files: <#{options[:config]}>")
165
+ FileUtils.cp(options[:config], @workspace_dir)
166
+ end
135
167
  end
136
168
 
137
169
  def dispatch(options={})
@@ -140,10 +172,8 @@ module Fluent
140
172
  next if skip_plugin?(plugin)
141
173
 
142
174
  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}")
175
+ unless supported_file_extension?(plugin, config_path)
176
+ @logger.debug("<#{plugin.class}> is not applicable to <#{config_path}>")
147
177
  next
148
178
  end
149
179
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Fluent
4
4
  module Auditify
5
- VERSION = "0.1.0"
5
+ VERSION = "0.2.0"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-auditify
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kentaro Hayashi