soar_auditing_format 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 5808f4570485d4eb876c38c01ef85919d245ade0
4
+ data.tar.gz: b5e6d3f4da4a01ce2ccaceedbcd53adb3f24ca6d
5
+ SHA512:
6
+ metadata.gz: cc049109e2d3c27e12b82d23b1469d26a6d2863e06b9a96fd7c075af0e5dbd02c8ac96677f679bfc08bfcf2afddd580bd965e5df7dc1aff8b50267c92846b1fc
7
+ data.tar.gz: d06b0caf51d6cca33223456d82c1a522b960bb7b25b877b56f54b5a5478732ff50e202f0e86288fc928cc66a6fe01ebba6e39fd2f39edb6e82545e3ca40a2b3d
data/.gitignore ADDED
@@ -0,0 +1,49 @@
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
+
26
+ ## Specific to RubyMotion:
27
+ .dat*
28
+ .repl_history
29
+ build/
30
+
31
+ ## Documentation cache and generated files:
32
+ /.yardoc/
33
+ /_yardoc/
34
+ /doc/
35
+ /rdoc/
36
+
37
+ ## Environment normalisation:
38
+ /.bundle/
39
+ /vendor/bundle
40
+ /lib/bundler/man/
41
+
42
+ # for a library or gem, you might want to ignore these files since the code is
43
+ # intended to run in multiple environments; otherwise, check them in:
44
+ # Gemfile.lock
45
+ # .ruby-version
46
+ # .ruby-gemset
47
+
48
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
49
+ .rvmrc
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.ruby-gemset ADDED
@@ -0,0 +1 @@
1
+ soar_auditing_format
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 soar_auditing_format.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,152 @@
1
+ # SoarAuditingFormatter
2
+
3
+ This gem provides the formatting for auditing
4
+
5
+ #TODO complete file
6
+
7
+ ## State of the API
8
+
9
+ This API is still a work in progress but should be sufficient for most auditors
10
+
11
+ Future work:
12
+ * The API should support the reformating of timestamps to a standardized ISO8601 format.
13
+
14
+ ## Installation
15
+
16
+ Add this line to your auditor Gemfile:
17
+
18
+ ```ruby
19
+ gem 'soar_auditing_format'
20
+ ```
21
+
22
+ And then execute:
23
+
24
+ $ bundle
25
+
26
+ Or install it yourself as:
27
+
28
+ $ gem install soar_auditing_format
29
+
30
+ ## Testing
31
+
32
+ Behavioural driven testing can be performed:
33
+
34
+ $ bundle exec rspec -cfd spec/*
35
+
36
+ ## Usage
37
+
38
+ ### Auditors that extend from the AuditorAPI
39
+
40
+ Extend from the AuditorAPI as follow
41
+
42
+ ``` ruby
43
+ class MyAuditor < SoarAuditingFormatter::AuditorAPI
44
+ end
45
+ ```
46
+
47
+ It is required that the auditors that extend from this API implement two methods: "audit" and "configuration_is_valid". The API will call these methods using inversion of control as follow:
48
+
49
+ The configuration_is_valid method provides the API with a way of ensuring that a configuration is valid for the auditor.
50
+ ```ruby
51
+ def configuration_is_valid(configuration)
52
+ return configuration.include?("something_needed")
53
+ end
54
+ ```
55
+
56
+ The audit method will be called when the base API wants to publish an audit event after it has been formatted and filtered.
57
+ ```ruby
58
+ def audit(data)
59
+ puts data
60
+ end
61
+ ```
62
+
63
+ The configuration is made available to the auditor through the @configuration attribute in the API class.
64
+ ```ruby
65
+ def audit(data)
66
+ puts @configuration["preprefix"] + data
67
+ end
68
+ ```
69
+
70
+
71
+ ### Auditing Providers that utilize the AuditorAPI as clients
72
+
73
+ Instantiate an auditor that extends the AuditorAPI:
74
+ ```ruby
75
+ @iut = SanityAuditor.new
76
+ ```
77
+
78
+ Configure the auditor with required parameters:
79
+ ```ruby
80
+ configuration = { "preprefix" => "very important:" }
81
+ @iut.configure(configuration)
82
+ ```
83
+
84
+ Set the desired audit level. Allowed levels (in increasing level of priority) are :debug, :info, :warn, :error and :fatal. As an example only :warn, :error and :fatal audit events will be logged if you set the level to :warn.
85
+ ```ruby
86
+ @iut.set_audit_level(:warn)
87
+ ```
88
+
89
+ Use the auditing interfaces as follow. The API also supports appending as below, enabling support, e.g. for Rack::CommonLogger, etc.:
90
+ ```ruby
91
+ @iut.info("This is info")
92
+ @iut.warn("Statistics show that dropped packets have increased to #{dropped}%")
93
+ @iut.error("Could not resend some dropped packets. They have been lost. All is still OK, I could compensate")
94
+ @iut.fatal("Unable to perform action, too many dropped packets. Functional degradation.")
95
+ @iut << 'Rack::CommonLogger requires this'
96
+ ```
97
+
98
+ Note that the APIs (debug/info/warn/error/fatal) accept any object as a parameter. The object will be serialized using the .to_s method and therefore the object must implement the .to_s method (or already be of a basic object type that has the .to_s method).
99
+ ```ruby
100
+ some_debug_object = 123
101
+ @iut.debug(some_debug_object)
102
+ ```
103
+
104
+ ## Detailed example
105
+
106
+ ```ruby
107
+ require 'soar_auditing_format'
108
+ require 'byebug'
109
+
110
+ class SanityAuditor < SoarAuditingFormatter::AuditorAPI
111
+ def configuration_is_valid(configuration)
112
+ return configuration.include?("preprefix")
113
+ end
114
+
115
+ def audit(data)
116
+ puts @configuration["preprefix"] + data
117
+ end
118
+ end
119
+
120
+ class Main
121
+ def test_sanity
122
+ @iut = SanityAuditor.new
123
+ configuration = { "preprefix" => "very important:" }
124
+ @iut.configure(configuration)
125
+ @iut.set_audit_level(:debug)
126
+
127
+ some_debug_object = 123
128
+ @iut.info("This is info")
129
+ @iut.debug(some_debug_object)
130
+ dropped = 95
131
+ @iut.warn("Statistics show that dropped packets have increased to #{dropped}%")
132
+ @iut.error("Could not resend some dropped packets. They have been lost. All is still OK, I could compensate")
133
+ @iut.fatal("Unable to perform action, too many dropped packets. Functional degradation.")
134
+ @iut << 'Rack::CommonLogger requires this'
135
+ end
136
+ end
137
+
138
+ main = Main.new
139
+ main.test_sanity
140
+ ```
141
+
142
+ ## Contributing
143
+
144
+ 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)
145
+
146
+ ## Notes
147
+
148
+ Though out of scope for the provider, auditors should take into account encoding, serialization, and other NFRs.
149
+
150
+ ## License
151
+
152
+ 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,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "soar_auditing_format"
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
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,18 @@
1
+ require 'time'
2
+
3
+ module SoarAuditingFormatter
4
+ #TODO check if we can do "#{field} here "
5
+ FORMAT="%s,%s,%s,%s" unless defined? FORMAT; FORMAT.freeze
6
+ OPTIONAL_FIELD_FORMAT = "[%s:%s]" unless defined? OPTIONAL_FIELD_FORMAT; OPTIONAL_FIELD_FORMAT.freeze
7
+
8
+ class Formatter
9
+ def self.format(level, flow_id, timestamp, message)
10
+ times = Time.parse(timestamp.to_s).utc.iso8601(3)
11
+ sprintf(FORMAT, level, flow_id, times, message)
12
+ end
13
+
14
+ def self.optional_field_format(key, value)
15
+ sprintf(OPTIONAL_FIELD_FORMAT, key, value)
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,3 @@
1
+ module SoarAuditingFormatter
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,5 @@
1
+ require 'soar_auditing_format/version'
2
+ require 'soar_auditing_format/formatter'
3
+
4
+ module SoarAuditingFormatter
5
+ end
@@ -0,0 +1 @@
1
+ sanity
@@ -0,0 +1 @@
1
+ ruby-2.2
data/sanity/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'byebug'
4
+ gem 'soar_auditing_format', "~> 0.0.1"
data/sanity/sanity.rb ADDED
@@ -0,0 +1,11 @@
1
+ require 'soar_auditing_format'
2
+ require 'byebug'
3
+
4
+ class Main
5
+ def test_sanity
6
+ SoarAuditingFormatter::Formatter.format("level",SecureRandom.hex(32),Time.now,"message")
7
+ end
8
+ end
9
+
10
+ main = Main.new
11
+ main.test_sanity
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'soar_auditing_format/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "soar_auditing_format"
8
+ spec.version = SoarAuditingFormatter::VERSION
9
+ spec.authors = ["Barney de Villiers"]
10
+ spec.email = ["barney.de.villiers@hetzner.co.za"]
11
+
12
+ spec.summary = %q{SOAR auditing format}
13
+ spec.description = %q{SOAR auditing format that will define auditing event entries}
14
+ spec.homepage = "https://github.hetzner.co.za/hetznerZA/soar_auditing_format"
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
+
27
+ end
metadata ADDED
@@ -0,0 +1,119 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: soar_auditing_format
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Barney de Villiers
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-05-27 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.11'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.11'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: byebug
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '9'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '9'
69
+ description: SOAR auditing format that will define auditing event entries
70
+ email:
71
+ - barney.de.villiers@hetzner.co.za
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".gitignore"
77
+ - ".rspec"
78
+ - ".ruby-gemset"
79
+ - ".ruby-version"
80
+ - ".travis.yml"
81
+ - Gemfile
82
+ - LICENSE.txt
83
+ - README.md
84
+ - Rakefile
85
+ - bin/console
86
+ - bin/setup
87
+ - lib/soar_auditing_format.rb
88
+ - lib/soar_auditing_format/formatter.rb
89
+ - lib/soar_auditing_format/version.rb
90
+ - sanity/.ruby-gemset
91
+ - sanity/.ruby-version
92
+ - sanity/Gemfile
93
+ - sanity/sanity.rb
94
+ - soar_auditing_format.gemspec
95
+ homepage: https://github.hetzner.co.za/hetznerZA/soar_auditing_format
96
+ licenses:
97
+ - MIT
98
+ metadata: {}
99
+ post_install_message:
100
+ rdoc_options: []
101
+ require_paths:
102
+ - lib
103
+ required_ruby_version: !ruby/object:Gem::Requirement
104
+ requirements:
105
+ - - ">="
106
+ - !ruby/object:Gem::Version
107
+ version: '0'
108
+ required_rubygems_version: !ruby/object:Gem::Requirement
109
+ requirements:
110
+ - - ">="
111
+ - !ruby/object:Gem::Version
112
+ version: '0'
113
+ requirements: []
114
+ rubyforge_project:
115
+ rubygems_version: 2.4.8
116
+ signing_key:
117
+ specification_version: 4
118
+ summary: SOAR auditing format
119
+ test_files: []