Class: Fluent::Auditify::Plugin::MaskSecrets
- Inherits:
-
Conf
- Object
- Base
- Conf
- Fluent::Auditify::Plugin::MaskSecrets
show all
- Defined in:
- lib/fluent/auditify/plugin/conf_mask_secrets.rb
Constant Summary
collapse
- MASK_TABLE =
{
'private_key_passphrase' =>'YOUR_PRIVATE_KEY_PASSPHRASE',
'ca_private_key_passphrase' => 'YOUR_CA_PRIVATE_KEY_PASSPHRASE',
'password' => 'YOUR_PASSWORD',
'shared_key' => 'YOUR_SHARED_KEY',
'aws_key_id' => 'YOUR_AWS_KEY_ID',
'aws_sec_key' => 'YOUR_AWS_SEC_KEY',
's3_bucket' => 'YOUR_S3_BUCKET',
}
Instance Attribute Summary
Attributes inherited from Base
#log
Instance Method Summary
collapse
Methods inherited from Conf
#artifact, #conf?, #disabled?, #file_get_contents, #file_readlines_each, #guilty, #initialize, #plugin_defs, #polish, #read_with_include_directive, #surround_text, #yaml?
Methods inherited from Base
#initialize
Instance Method Details
#mask_body(body) ⇒ Object
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
# File 'lib/fluent/auditify/plugin/conf_mask_secrets.rb', line 31
def mask_body(body)
modified_body = []
body.each do |child|
key = child[:name].to_s
if MASK_TABLE.keys.include?(key)
child[:value].instance_variable_set(:@str, MASK_TABLE[key])
modified_body << {name: child[:name],
value: child[:value]}
else
if child[:section]
modified_body << mask_section(child)
else
modified_body << child
end
end
end
modified_body
end
|
#mask_section(section) ⇒ Object
51
52
53
54
55
|
# File 'lib/fluent/auditify/plugin/conf_mask_secrets.rb', line 51
def mask_section(section)
{section: section[:section],
body: mask_body(section[:body]),
name: section[:name]}
end
|
#parse(conf, options = {}) ⇒ Object
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
|
# File 'lib/fluent/auditify/plugin/conf_mask_secrets.rb', line 57
def parse(conf, options={})
begin
content = file_get_contents(conf)
root = Fluent::Config::V1Parser.parse(content, conf)
modified = []
begin
parser = Fluent::Auditify::Parser::V1ConfigParser.new
object = parser.parse(File.read(conf))
object.each_with_index do |directive, index|
if directive[:source] or directive[:match]
directive[:body] = mask_body(directive[:body])
modified << directive
else
modified << directive
end
end
polish(modified)
if options[:mask_only]
util = Fluent::Auditify::ParsletUtil.new
util.export(modified)
end
rescue => e
puts e.parse_failure_cause.ascii_tree
end
rescue => e
log.error("parse error: #{e.message}")
end
end
|
#supported_file_extension? ⇒ Boolean
27
28
29
|
# File 'lib/fluent/auditify/plugin/conf_mask_secrets.rb', line 27
def supported_file_extension?
[:conf]
end
|
23
24
25
|
# File 'lib/fluent/auditify/plugin/conf_mask_secrets.rb', line 23
def supported_platform?
:any
end
|