fluent-plugin-filter-dgi-parse-audit-log 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.github/workflows/ruby.yml +28 -0
- data/.gitignore +14 -0
- data/.rspec +3 -0
- data/.travis.yml +13 -0
- data/Appraisals +7 -0
- data/Gemfile +6 -0
- data/LICENSE.txt +21 -0
- data/README.md +93 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/fluent-plugin-filter-dgi-parse-audit-log.gemspec +33 -0
- data/gemfiles/.bundle/config +2 -0
- data/gemfiles/fluentd_0.12.gemfile +7 -0
- data/gemfiles/fluentd_0.14.gemfile +7 -0
- data/lib/fluent/plugin/filter_parse_audit_log.rb +25 -0
- data/lib/fluent_plugin_filter_parse_audit_log/version.rb +3 -0
- metadata +173 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 64d2b4c7d26a6b3689253f3068572cce936a2d9d5400a316089eabddcf5d0514
|
4
|
+
data.tar.gz: 7fb38a870b79efdfd5f778b72754824514d403f16180066792714aeb8a7a1a13
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: feb1b3f8c2824deddcb2761253900846beebddeb58f60b76f4add4c897a16fe9e4e15592db131b3710a828a84effdd7c67dc97addd017ab414b886927cb58068
|
7
|
+
data.tar.gz: b5de6b433f996f06bab0f7f1d774996c9962c7b60f89bb6e7090fdcef9a0e3d36fbe569fe3145306a5e29e032ae87f3d2bb93dc89e10ceb5524ba6b72d86d85a
|
@@ -0,0 +1,28 @@
|
|
1
|
+
name: Ruby
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches: [ "main" ]
|
6
|
+
pull_request:
|
7
|
+
branches: [ "main" ]
|
8
|
+
|
9
|
+
permissions:
|
10
|
+
contents: read
|
11
|
+
|
12
|
+
jobs:
|
13
|
+
test:
|
14
|
+
|
15
|
+
runs-on: ubuntu-latest
|
16
|
+
strategy:
|
17
|
+
matrix:
|
18
|
+
ruby-version: ['2.6', '2.7', '3.0']
|
19
|
+
|
20
|
+
steps:
|
21
|
+
- uses: actions/checkout@v3
|
22
|
+
- name: Set up Ruby
|
23
|
+
uses: ruby/setup-ruby@v1
|
24
|
+
with:
|
25
|
+
ruby-version: ${{ matrix.ruby-version }}
|
26
|
+
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
|
27
|
+
- name: Run tests
|
28
|
+
run: bundle exec rake
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Appraisals
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2018 winebarrel
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,93 @@
|
|
1
|
+
# fluent-plugin-filter-parse-audit-log
|
2
|
+
|
3
|
+
Fluentd Filter Plugin to parse [linux's audit log](https://github.com/linux-audit/audit-documentation/wiki).
|
4
|
+
|
5
|
+
[![Gem Version](https://badge.fury.io/rb/fluent-plugin-filter-parse-audit-log.svg)](http://badge.fury.io/rb/fluent-plugin-filter-parse-audit-log)
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'fluent-plugin-filter-dgi-audit-log'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install fluent-plugin-filter-dgi-audit-log
|
22
|
+
|
23
|
+
## Configuration
|
24
|
+
|
25
|
+
```
|
26
|
+
@type parse_audit_log
|
27
|
+
#key message
|
28
|
+
#flatten false
|
29
|
+
```
|
30
|
+
|
31
|
+
## Output
|
32
|
+
|
33
|
+
```
|
34
|
+
<source>
|
35
|
+
@type forward
|
36
|
+
</source>
|
37
|
+
|
38
|
+
<filter audit.log>
|
39
|
+
@type parse_audit_log
|
40
|
+
</filter>
|
41
|
+
|
42
|
+
<match audit.log>
|
43
|
+
@type stdout
|
44
|
+
</match>
|
45
|
+
```
|
46
|
+
|
47
|
+
```sh
|
48
|
+
echo '{"message":"type=SYSCALL msg=audit(1364481363.243:24287): arch=c000003e syscall=2 success=no exit=-13 a0=7fffd19c5592 a1=0 a2=7fffd19c4b50 a3=a items=1 ppid=2686 pid=3538 auid=500 uid=500 gid=500 euid=500 suid=500 fsuid=500 egid=500 sgid=500 fsgid=500 tty=pts0 ses=1 comm=\"cat\" exe=\"/bin/cat\" subj=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 key=\"sshd_config\""}' \
|
49
|
+
| fluent-cat -t audit.log
|
50
|
+
```
|
51
|
+
|
52
|
+
```json
|
53
|
+
{
|
54
|
+
"header": {
|
55
|
+
"type": "SYSCALL",
|
56
|
+
"msg": "audit(1364481363.243:24287)"
|
57
|
+
},
|
58
|
+
"body": {
|
59
|
+
"arch": "c000003e",
|
60
|
+
"syscall": "2",
|
61
|
+
"success": "no",
|
62
|
+
"exit": "-13",
|
63
|
+
"a0": "7fffd19c5592",
|
64
|
+
"a1": "0",
|
65
|
+
"a2": "7fffd19c4b50",
|
66
|
+
"a3": "a",
|
67
|
+
"items": "1",
|
68
|
+
"ppid": "2686",
|
69
|
+
"pid": "3538",
|
70
|
+
"auid": "500",
|
71
|
+
"uid": "500",
|
72
|
+
"gid": "500",
|
73
|
+
"euid": "500",
|
74
|
+
"suid": "500",
|
75
|
+
"fsuid": "500",
|
76
|
+
"egid": "500",
|
77
|
+
"sgid": "500",
|
78
|
+
"fsgid": "500",
|
79
|
+
"tty": "pts0",
|
80
|
+
"ses": "1",
|
81
|
+
"comm": "\"cat\"",
|
82
|
+
"exe": "\"/bin/cat\"",
|
83
|
+
"subj": "unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023",
|
84
|
+
"key": "\"sshd_config\""
|
85
|
+
}
|
86
|
+
}
|
87
|
+
```
|
88
|
+
|
89
|
+
## Related Links
|
90
|
+
|
91
|
+
* https://github.com/dg-i/audit_log_parser
|
92
|
+
* [7.6. Understanding Audit Log Files - Red Hat Customer Portal](https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/6/html/security_guide/sec-understanding_audit_log_files)
|
93
|
+
* [SPEC Writing Good Events · linux-audit/audit-documentation Wiki](https://github.com/linux-audit/audit-documentation/wiki/SPEC-Writing-Good-Events)
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "fluent/plugin/filter/audit/log"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
lib = File.expand_path('../lib', __FILE__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require 'fluent_plugin_filter_parse_audit_log/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = 'fluent-plugin-filter-dgi-parse-audit-log'
|
7
|
+
spec.version = FluentPluginFilterParseAuditLog::VERSION
|
8
|
+
spec.authors = ['winebarrel', 'aeber']
|
9
|
+
spec.email = ['']
|
10
|
+
|
11
|
+
spec.summary = %q{Fluentd Filter Plugin to parse linux's audit log.}
|
12
|
+
spec.description = %q{Fluentd Filter Plugin to parse linux's audit log.}
|
13
|
+
spec.homepage = 'https://github.com/dg-i/fluent-plugin-filter-parse-audit-log'
|
14
|
+
spec.license = 'MIT'
|
15
|
+
|
16
|
+
# Specify which files should be added to the gem when it is released.
|
17
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
18
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
19
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
20
|
+
end
|
21
|
+
spec.bindir = 'exe'
|
22
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
23
|
+
spec.require_paths = ['lib']
|
24
|
+
|
25
|
+
spec.add_dependency 'fluentd'
|
26
|
+
spec.add_dependency 'dgi_audit_log_parser', '>= 1.0.0'
|
27
|
+
spec.add_development_dependency 'bundler'
|
28
|
+
spec.add_development_dependency "rake", ">= 12.3.3"
|
29
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
30
|
+
spec.add_development_dependency 'timecop'
|
31
|
+
spec.add_development_dependency 'test-unit', '>= 3.1.0'
|
32
|
+
spec.add_development_dependency 'appraisal', '>= 2.2'
|
33
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'fluent_plugin_filter_parse_audit_log/version'
|
2
|
+
require 'audit_log_parser'
|
3
|
+
|
4
|
+
class FluentParseAuditLogFilter < Fluent::Filter
|
5
|
+
Fluent::Plugin.register_filter('parse_audit_log', self)
|
6
|
+
|
7
|
+
config_param :key, :string, default: 'message'
|
8
|
+
config_param :flatten, :bool, default: false
|
9
|
+
config_param :keep_keys, :array, default: nil
|
10
|
+
|
11
|
+
def filter(tag, time, record)
|
12
|
+
line = record[@key]
|
13
|
+
return record unless line
|
14
|
+
new_record = AuditLogParser.parse_line(line, flatten: @flatten)
|
15
|
+
@keep_keys.each do |k|
|
16
|
+
new_record[k] = record[k] if record.has_key?(k)
|
17
|
+
end if @keep_keys
|
18
|
+
|
19
|
+
new_record
|
20
|
+
rescue => e
|
21
|
+
log.warn "failed to parse a audit log: #{line}", error_class: e.class, error: e.message
|
22
|
+
log.warn_backtrace
|
23
|
+
record
|
24
|
+
end
|
25
|
+
end
|
metadata
ADDED
@@ -0,0 +1,173 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fluent-plugin-filter-dgi-parse-audit-log
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- winebarrel
|
8
|
+
- aeber
|
9
|
+
autorequire:
|
10
|
+
bindir: exe
|
11
|
+
cert_chain: []
|
12
|
+
date: 2023-10-17 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: fluentd
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - ">="
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '0'
|
21
|
+
type: :runtime
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - ">="
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: '0'
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: dgi_audit_log_parser
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - ">="
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: 1.0.0
|
35
|
+
type: :runtime
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - ">="
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: 1.0.0
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: bundler
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - ">="
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '0'
|
49
|
+
type: :development
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '0'
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: rake
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: 12.3.3
|
63
|
+
type: :development
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: 12.3.3
|
70
|
+
- !ruby/object:Gem::Dependency
|
71
|
+
name: rspec
|
72
|
+
requirement: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - "~>"
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '3.0'
|
77
|
+
type: :development
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - "~>"
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '3.0'
|
84
|
+
- !ruby/object:Gem::Dependency
|
85
|
+
name: timecop
|
86
|
+
requirement: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - ">="
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: '0'
|
91
|
+
type: :development
|
92
|
+
prerelease: false
|
93
|
+
version_requirements: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - ">="
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: '0'
|
98
|
+
- !ruby/object:Gem::Dependency
|
99
|
+
name: test-unit
|
100
|
+
requirement: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - ">="
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: 3.1.0
|
105
|
+
type: :development
|
106
|
+
prerelease: false
|
107
|
+
version_requirements: !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
109
|
+
- - ">="
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: 3.1.0
|
112
|
+
- !ruby/object:Gem::Dependency
|
113
|
+
name: appraisal
|
114
|
+
requirement: !ruby/object:Gem::Requirement
|
115
|
+
requirements:
|
116
|
+
- - ">="
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: '2.2'
|
119
|
+
type: :development
|
120
|
+
prerelease: false
|
121
|
+
version_requirements: !ruby/object:Gem::Requirement
|
122
|
+
requirements:
|
123
|
+
- - ">="
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '2.2'
|
126
|
+
description: Fluentd Filter Plugin to parse linux's audit log.
|
127
|
+
email:
|
128
|
+
- ''
|
129
|
+
executables: []
|
130
|
+
extensions: []
|
131
|
+
extra_rdoc_files: []
|
132
|
+
files:
|
133
|
+
- ".github/workflows/ruby.yml"
|
134
|
+
- ".gitignore"
|
135
|
+
- ".rspec"
|
136
|
+
- ".travis.yml"
|
137
|
+
- Appraisals
|
138
|
+
- Gemfile
|
139
|
+
- LICENSE.txt
|
140
|
+
- README.md
|
141
|
+
- Rakefile
|
142
|
+
- bin/console
|
143
|
+
- bin/setup
|
144
|
+
- fluent-plugin-filter-dgi-parse-audit-log.gemspec
|
145
|
+
- gemfiles/.bundle/config
|
146
|
+
- gemfiles/fluentd_0.12.gemfile
|
147
|
+
- gemfiles/fluentd_0.14.gemfile
|
148
|
+
- lib/fluent/plugin/filter_parse_audit_log.rb
|
149
|
+
- lib/fluent_plugin_filter_parse_audit_log/version.rb
|
150
|
+
homepage: https://github.com/dg-i/fluent-plugin-filter-parse-audit-log
|
151
|
+
licenses:
|
152
|
+
- MIT
|
153
|
+
metadata: {}
|
154
|
+
post_install_message:
|
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: '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.3.25
|
170
|
+
signing_key:
|
171
|
+
specification_version: 4
|
172
|
+
summary: Fluentd Filter Plugin to parse linux's audit log.
|
173
|
+
test_files: []
|