log4r_auditor 0.0.1 → 0.0.2

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
  SHA1:
3
- metadata.gz: 88c0a79bb1ba22f167caa468f325846f1978cd3c
4
- data.tar.gz: 9c99481477f8882ac86af39fcb86fb39de537fd2
3
+ metadata.gz: 01b2fe25ed35f22bca22b87f5169c56dc2178108
4
+ data.tar.gz: 02dba7094bc207e69ca895b3596c5c20364fd863
5
5
  SHA512:
6
- metadata.gz: a2f7447537d680b3a9fd58b1ba73c7b15ecde9695a444ccd50c8dff4b674d29064e3e9206a61ed7aa661496d177093036f6f88857013a3db46c552f003019fa6
7
- data.tar.gz: 28fae3bcf2fd1a68b9b43c4b1e01e2ff36dfb4dbdac89d3ebae827ed289ec502c9026a31bee65c6609400b0d4c36e3d1ffcf38ce65c24481f7cd8a859602f148
6
+ metadata.gz: 7ca673e9587602c3fe34c7880cb9d8353ec52ba0b96fbe3e75a9f066823c36d186c4506aeb5e7aa1080cef74977852f63f60a546aa2d34cd912c3f0ee069cb86
7
+ data.tar.gz: 36fe2ef5226178a4395ff5fbc9134d0f75f2479fc84e858dfe5e334075aaabe80a6047459fc070fec640ad7f219da0c26621fbbdab34d5afdd3ffb485cb74a43
data/.gitignore ADDED
@@ -0,0 +1,50 @@
1
+ .byebug_history
2
+ *tgz
3
+ left
4
+ test_tfa.sh
5
+ test_production.sh
6
+ iut-list
7
+ juddi-distro-*
8
+ *.swo
9
+ *.zip
10
+ *.tar.gz
11
+ *.swp
12
+ *.gem
13
+ *.rbc
14
+ Gemfile.lock
15
+ /.config
16
+ /coverage/
17
+ /InstalledFiles
18
+ /pkg/
19
+ /spec/reports/
20
+ /spec/examples.txt
21
+ /test/tmp/
22
+ /test/version_tmp/
23
+ /tmp/
24
+ .DS_Store
25
+ logfile
26
+
27
+ ## Specific to RubyMotion:
28
+ .dat*
29
+ .repl_history
30
+ build/
31
+
32
+ ## Documentation cache and generated files:
33
+ /.yardoc/
34
+ /_yardoc/
35
+ /doc/
36
+ /rdoc/
37
+
38
+ ## Environment normalisation:
39
+ /.bundle/
40
+ /vendor/bundle
41
+ /lib/bundler/man/
42
+
43
+ # for a library or gem, you might want to ignore these files since the code is
44
+ # intended to run in multiple environments; otherwise, check them in:
45
+ # Gemfile.lock
46
+ # .ruby-version
47
+ # .ruby-gemset
48
+
49
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
50
+ .rvmrc
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.ruby-gemset ADDED
@@ -0,0 +1 @@
1
+ log4r_auditor
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ ruby-2.2
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.2
4
+ before_install: gem install bundler -v 1.11.2
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in log4r_auditor.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Barney de Villiers
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,76 @@
1
+ # Log4rAuditor
2
+
3
+ This gem provides the log4r auditor that can be plugged into the SOAR architecture.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'log4r_auditor'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install log4r_auditor
20
+
21
+ ## Testing
22
+
23
+ Behavioural driven testing can be performed by testing so:
24
+
25
+ $ bundle exec rspec -cfd spec/*
26
+
27
+ ## Usage
28
+
29
+ Initialize and configure the auditor so:
30
+
31
+ ```ruby
32
+ @iut = Log4rAuditor::Log4rAuditor.new
33
+ @log4r_configuration = { 'file_name' => 'logfile',
34
+ 'standard_stream' => 'stdout' }
35
+ @iut.configure(@log4r_configuration)
36
+ ```
37
+
38
+ Audit using the API methods inherited from SoarAuditorApi::AuditorAPI, e.g.:
39
+
40
+ ```ruby
41
+ @iut.warn("This is a test event")
42
+ ```
43
+
44
+ ## Detailed example
45
+
46
+ ```ruby
47
+ require 'log4r_auditor'
48
+ require 'soar_auditing_format'
49
+ require 'time'
50
+ require 'securerandom'
51
+
52
+ class Main
53
+ def test_sanity
54
+ @iut = Log4rAuditor::Log4rAuditor.new
55
+ @log4r_configuration =
56
+ { }
57
+ @iut.configure(@log4r_configuration)
58
+ @iut.set_audit_level(:debug)
59
+
60
+ my_optional_operation_field = SoarAuditingFormatter::Formatter.optional_field_format("operation", "Http.Get")
61
+ my_optional_method_name_field = SoarAuditingFormatter::Formatter.optional_field_format("method", "#{self.class}::#{__method__}::#{__LINE__}")
62
+ @iut.debug(SoarAuditingFormatter::Formatter.format(:debug,'my-sanity-service-id',SecureRandom.hex(32),Time.now.iso8601(3),"#{my_optional_method_name_field}#{my_optional_operation_field} test message with optional fields"))
63
+ end
64
+ end
65
+
66
+ main = Main.new
67
+ main.test_sanity
68
+ ```
69
+
70
+ ## Contributing
71
+
72
+ Bug reports and feature requests are welcome by email to barney dot de dot villiers at hetzner dot co dot za. This gem is sponsored by Hetzner (Pty) Ltd (http://hetzner.co.za)
73
+
74
+ ## License
75
+
76
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $LOAD_PATH.unshift File.expand_path('../lib', __FILE__)
4
+
5
+ require "bundler/setup"
6
+ require 'log4r_auditor'
7
+
8
+ # You can add fixtures and/or initialization code here to make experimenting
9
+ # with your gem easier. You can also use a different console, if you like.
10
+
11
+ # (If you use this, don't forget to add pry to your Gemfile!)
12
+ # require "pry"
13
+ # Pry.start
14
+
15
+ require "irb"
16
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,51 @@
1
+ require 'soar_auditor_api'
2
+ require 'log4r'
3
+
4
+ module Log4rAuditor
5
+ class Log4rAuditor < SoarAuditorApi::AuditorAPI
6
+ #Override of AuditorAPI configure method in order to perform post configuration setup
7
+ def configure(configuration)
8
+ super(configuration)
9
+ post_configuration_setup
10
+ end
11
+
12
+ #inversion of control method required by the AuditorAPI to validate the configuration
13
+ def configuration_is_valid?(configuration)
14
+ required_parameters = ['file_name', 'standard_stream']
15
+ required_parameters.each { |parameter| return false unless configuration.include?(parameter) }
16
+ return false if configuration['file_name'].empty?
17
+ return false unless ['stdout', 'stderr'].include?(configuration['standard_stream'])
18
+ return true
19
+ end
20
+
21
+ #inversion of control method required by the AuditorAPI to send the audit event to the auditor
22
+ def audit(audit_data)
23
+ @log4r.debug(audit_data)
24
+ end
25
+
26
+ private
27
+
28
+ def post_configuration_setup
29
+ @log4r = Log4r::Logger.new('soar_sc')
30
+ @log4r.outputters = create_log4r_file_output, create_log4r_standard_stream_output
31
+ @log4r
32
+ end
33
+
34
+ def create_log4r_file_output
35
+ logfile = Log4r::FileOutputter.new('fileOutputter', :filename => @configuration['file_name'],:trunc => false)
36
+ logfile.formatter = create_log4r_pattern
37
+ logfile
38
+ end
39
+
40
+ def create_log4r_standard_stream_output
41
+ logstdout = Log4r::Outputter.stdout if 'stdout' == @configuration['standard_stream']
42
+ logstdout = Log4r::Outputter.stderr if 'stderr' == @configuration['standard_stream']
43
+ logstdout.formatter = create_log4r_pattern
44
+ logstdout
45
+ end
46
+
47
+ def create_log4r_pattern
48
+ Log4r::PatternFormatter.new(:pattern => '%m')
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,3 @@
1
+ module Log4rAuditor
2
+ VERSION = "0.0.2"
3
+ end
@@ -0,0 +1,5 @@
1
+ require 'log4r_auditor/version'
2
+ require 'log4r_auditor/auditor'
3
+
4
+ module Log4rAuditor
5
+ end
@@ -0,0 +1,31 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'log4r_auditor/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "log4r_auditor"
8
+ spec.version = Log4rAuditor::VERSION
9
+ spec.authors = ["Barney de Villiers"]
10
+ spec.email = ["barney.de.villiers@hetzner.co.za"]
11
+
12
+ spec.summary = %q{Log4r implementation of SOAR architecture auditing}
13
+ spec.description = %q{Log4r implementation of SOAR architecture auditing allowing easy publishing of events to a stdout and local logfile}
14
+ spec.homepage = "https://github.com/hetznerZA/log4r_auditor"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ spec.bindir = "exe"
19
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.add_development_dependency "bundler", "~> 1.11"
23
+ spec.add_development_dependency "rake", "~> 10.0"
24
+ spec.add_development_dependency "rspec", "~> 3.0"
25
+ spec.add_development_dependency "byebug", "~> 9"
26
+ spec.add_development_dependency "soar_auditing_format", "~> 0.0.5"
27
+
28
+ spec.add_dependency "log4r", "~> 1.1"
29
+ spec.add_dependency "soar_auditor_api", "~> 0.0.11"
30
+
31
+ end
@@ -0,0 +1 @@
1
+ log4r_auditor_sanity
@@ -0,0 +1 @@
1
+ ruby-2.2
data/sanity/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'log4r_auditor', "~> 0.0.2"
4
+ gem "soar_auditing_format", "~> 0.0.5"
data/sanity/sanity.rb ADDED
@@ -0,0 +1,21 @@
1
+ require 'soar_auditing_format'
2
+ require 'time'
3
+ require 'securerandom'
4
+ require "log4r_auditor"
5
+
6
+ class Main
7
+ def test_sanity
8
+ @iut = Log4rAuditor::Log4rAuditor.new
9
+ @log4r_configuration = { 'file_name' => 'logfile',
10
+ 'standard_stream' => 'stdout' }
11
+ @iut.configure(@log4r_configuration)
12
+ @iut.set_audit_level(:debug)
13
+
14
+ my_optional_operation_field = SoarAuditingFormatter::Formatter.optional_field_format("operation", "Http.Get")
15
+ my_optional_method_name_field = SoarAuditingFormatter::Formatter.optional_field_format("method", "#{self.class}::#{__method__}::#{__LINE__}")
16
+ @iut.debug(SoarAuditingFormatter::Formatter.format(:debug,'my-sanity-service-id',SecureRandom.hex(32),Time.now.iso8601(3),"#{my_optional_method_name_field}#{my_optional_operation_field} test message with optional fields"))
17
+ end
18
+ end
19
+
20
+ main = Main.new
21
+ main.test_sanity
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: log4r_auditor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Barney de Villiers
@@ -115,7 +115,26 @@ email:
115
115
  executables: []
116
116
  extensions: []
117
117
  extra_rdoc_files: []
118
- files: []
118
+ files:
119
+ - ".gitignore"
120
+ - ".rspec"
121
+ - ".ruby-gemset"
122
+ - ".ruby-version"
123
+ - ".travis.yml"
124
+ - Gemfile
125
+ - LICENSE.txt
126
+ - README.md
127
+ - Rakefile
128
+ - bin/console
129
+ - bin/setup
130
+ - lib/log4r_auditor.rb
131
+ - lib/log4r_auditor/auditor.rb
132
+ - lib/log4r_auditor/version.rb
133
+ - log4r_auditor.gemspec
134
+ - sanity/.ruby-gemset
135
+ - sanity/.ruby-version
136
+ - sanity/Gemfile
137
+ - sanity/sanity.rb
119
138
  homepage: https://github.com/hetznerZA/log4r_auditor
120
139
  licenses:
121
140
  - MIT