soar_auditing_provider 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +11 -0
- data/.rspec +2 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/.travis.yml +4 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +113 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/soar_auditing_provider/auditing_provider_api.rb +73 -0
- data/lib/soar_auditing_provider/version.rb +3 -0
- data/lib/soar_auditing_provider.rb +6 -0
- data/sanity/.gitignore +11 -0
- data/sanity/.ruby-gemset +1 -0
- data/sanity/.ruby-version +1 -0
- data/sanity/Gemfile +5 -0
- data/sanity/sanity.rb +34 -0
- data/soar_auditing_provider.gemspec +25 -0
- metadata +120 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 465bfe3788bfcc23114e22abf0da8a8845fdfc78
|
4
|
+
data.tar.gz: 8b51ec92632cec2b8b540f4b196b749f320560bf
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 0c139ed4399ae4a20f5df0ddf39bc0f716317ed042874197f828d1d5dc8714d0033a1534d257e1670602ccc6718c0813c5a07a3b330875d3a2565d5d81f7406b
|
7
|
+
data.tar.gz: 717ca5b400a3033152c736e1dd858189b2449245f4d86709adf97bb0a4c6c12a7a0798443d963f37a2a52e638fac5b803c60323ea38a230a58a72e17cdac5cdb
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.ruby-gemset
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
soar_auditing_provider
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ruby-2.2
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 Ernst Van Graan
|
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,113 @@
|
|
1
|
+
# SoarAuditingProvider
|
2
|
+
|
3
|
+
This gem provides the auditing API that audit providers for the SOAR architecture should adhere to.
|
4
|
+
|
5
|
+
Providers are initialized with a list of auditors and their configuration, as well as the NFRs they support, and is responsible for selecting an auditor giving a set of NFRs, and configuring the auditor appropriately. The auditing API as set out below then delegates auditing actions to the selected auditor.
|
6
|
+
|
7
|
+
The API provides default delegation behaviour that calls the API methods verbatim on the auditor.
|
8
|
+
|
9
|
+
## Installation
|
10
|
+
|
11
|
+
Add this line to your application's Gemfile:
|
12
|
+
|
13
|
+
```ruby
|
14
|
+
gem 'soar_auditing_provider'
|
15
|
+
```
|
16
|
+
|
17
|
+
And then execute:
|
18
|
+
|
19
|
+
$ bundle
|
20
|
+
|
21
|
+
Or install it yourself as:
|
22
|
+
|
23
|
+
$ gem install soar_auditing_provider
|
24
|
+
|
25
|
+
## Usage
|
26
|
+
|
27
|
+
Extend the SoarAuditingProvider::AuditingProviderAPI to create an auditing provider:
|
28
|
+
|
29
|
+
```
|
30
|
+
class MyAuditingProvider < SoarAuditingProvider::AuditingProviderAPI
|
31
|
+
end
|
32
|
+
```
|
33
|
+
|
34
|
+
Provide the required inversion of control method to configure (an) injected auditor(s):
|
35
|
+
|
36
|
+
```
|
37
|
+
def configure_auditor(configuration = nil)
|
38
|
+
@auditor.configure(configuration)
|
39
|
+
end
|
40
|
+
```
|
41
|
+
|
42
|
+
Initialize the provider so:
|
43
|
+
|
44
|
+
```
|
45
|
+
auditor = MyAuditor.new
|
46
|
+
auditor_configuration = { 'nfrs' => { 'nfr' => 'description' }, 'some' => 'configuration' }
|
47
|
+
@iut = MyAuditingProvider.new(auditor, auditor_configuration)
|
48
|
+
```
|
49
|
+
|
50
|
+
Audit using the API methods, e.g.:
|
51
|
+
|
52
|
+
```
|
53
|
+
@iut.info("This is info")
|
54
|
+
@iut.debug(some_debug_object)
|
55
|
+
@iut.warn("Statistics show that dropped packets have increased to #{dropped}%")
|
56
|
+
@iut.error("Could not resend some dropped packets. They have been lost. All is still OK, I could compensate")
|
57
|
+
@iut.fatal("Unable to perform action, too many dropped packets. Functional degradation.")
|
58
|
+
@iut << 'Rack::CommonLogger requires this'
|
59
|
+
```
|
60
|
+
|
61
|
+
The API also supports appending as below, enabling support, e.g. for Rack::CommonLogger, etc.:
|
62
|
+
|
63
|
+
```
|
64
|
+
<<
|
65
|
+
```
|
66
|
+
|
67
|
+
## Detailed example
|
68
|
+
|
69
|
+
```
|
70
|
+
require 'log4r'
|
71
|
+
require 'soar_auditing_provider'
|
72
|
+
|
73
|
+
class Log4rAuditingProvider < SoarAuditingProvider::AuditingProviderAPI
|
74
|
+
def configure_auditor(configuration = nil)
|
75
|
+
@auditor.outputters = configuration['outputter']
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
class Main
|
80
|
+
include Log4r
|
81
|
+
|
82
|
+
def test_sanity
|
83
|
+
auditor = Logger.new 'sanity'
|
84
|
+
auditor_configuration = { 'nfrs' => { 'accessibility' => 'local' }, 'outputter' => Outputter.stdout }
|
85
|
+
provider = Log4rAuditingProvider.new(auditor, auditor_configuration)
|
86
|
+
@iut = provider.create('')
|
87
|
+
|
88
|
+
some_debug_object = 123
|
89
|
+
@iut.info("This is info")
|
90
|
+
@iut.debug(some_debug_object)
|
91
|
+
dropped = 95
|
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
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
main = Main.new
|
99
|
+
main.test_sanity
|
100
|
+
```
|
101
|
+
|
102
|
+
## Contributing
|
103
|
+
|
104
|
+
Bug reports and feature requests are welcome by email to ernst dot van dot graan at hetzner dot co dot za. This gem is sponsored by Hetzner (Pty) Ltd (http://hetzner.co.za)
|
105
|
+
|
106
|
+
## Notes
|
107
|
+
|
108
|
+
Though out of scope for the provider, auditors should take into account encoding, serialization, and other NFRs.
|
109
|
+
|
110
|
+
## License
|
111
|
+
|
112
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
113
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "soar_auditing_provider"
|
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,73 @@
|
|
1
|
+
require 'soar_auditing_provider/nfr_match_error'
|
2
|
+
|
3
|
+
module SoarAuditingProvider
|
4
|
+
class AuditingProviderAPI
|
5
|
+
attr_accessor :auditors
|
6
|
+
attr_accessor :auditor
|
7
|
+
|
8
|
+
def initialize(auditors)
|
9
|
+
raise ArgumentError.new("Invalid auditors provided") if not auditors.is_a?(Hash)
|
10
|
+
raise ArgumentError.new("No auditors provided") if auditors.nil? or auditors.empty?
|
11
|
+
@auditors = auditors
|
12
|
+
end
|
13
|
+
|
14
|
+
def debug(data)
|
15
|
+
@auditor.debug(data)
|
16
|
+
end
|
17
|
+
|
18
|
+
def <<(data)
|
19
|
+
@auditor.info(data)
|
20
|
+
end
|
21
|
+
|
22
|
+
def info(data)
|
23
|
+
@auditor.info(data)
|
24
|
+
end
|
25
|
+
|
26
|
+
def error(data)
|
27
|
+
@auditor.error(data)
|
28
|
+
end
|
29
|
+
|
30
|
+
def warn(data)
|
31
|
+
@auditor.warn(data)
|
32
|
+
end
|
33
|
+
|
34
|
+
def fatal(data)
|
35
|
+
@auditor.fatal(data)
|
36
|
+
end
|
37
|
+
|
38
|
+
def select(nfrs = nil)
|
39
|
+
if nfrs.nil? or nfrs.empty?
|
40
|
+
auditor_selected = auditors.keys.first
|
41
|
+
else
|
42
|
+
auditor_selected = nil
|
43
|
+
auditors.each do |auditor, configuration|
|
44
|
+
auditor_nfrs = configuration['nfrs']
|
45
|
+
nfrs_matched = true
|
46
|
+
nfrs.each do |nfr, value|
|
47
|
+
nfrs_matched = false if not auditor_nfrs[nfr] or (auditor_nfrs[nfr] != value)
|
48
|
+
end
|
49
|
+
if nfrs_matched
|
50
|
+
auditor_selected = auditor
|
51
|
+
break
|
52
|
+
end
|
53
|
+
end
|
54
|
+
raise NFRMatchError.new("Could not match NFRs to an auditor") if auditor_selected.nil?
|
55
|
+
end
|
56
|
+
configuration = auditors[auditor_selected]
|
57
|
+
clazz = (auditor_selected.class == Class) ? auditor_selected.to_s : auditor_selected
|
58
|
+
@auditor = Object::const_get(clazz).new
|
59
|
+
configure_auditor(@auditor, configuration)
|
60
|
+
@auditor
|
61
|
+
end
|
62
|
+
|
63
|
+
protected
|
64
|
+
|
65
|
+
def configure_auditor(auditor, configuration = nil)
|
66
|
+
raise NotImplementedError.new("You should override this method and configure your auditor")
|
67
|
+
end
|
68
|
+
|
69
|
+
private
|
70
|
+
|
71
|
+
|
72
|
+
end
|
73
|
+
end
|
data/sanity/.gitignore
ADDED
data/sanity/.ruby-gemset
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
sanity
|
@@ -0,0 +1 @@
|
|
1
|
+
ruby-2.2
|
data/sanity/Gemfile
ADDED
data/sanity/sanity.rb
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'log4r'
|
2
|
+
require 'soar_auditing_provider'
|
3
|
+
require 'byebug'
|
4
|
+
|
5
|
+
class Log4rAuditingProvider < SoarAuditingProvider::AuditingProviderAPI
|
6
|
+
def configure_auditor(auditor, configuration = nil)
|
7
|
+
auditor.outputters = configuration['outputter']
|
8
|
+
end
|
9
|
+
|
10
|
+
def select(nfrs)
|
11
|
+
super(nfrs)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
class Main
|
16
|
+
include Log4r
|
17
|
+
|
18
|
+
def test_sanity
|
19
|
+
auditor_configuration = { 'outputter' => Outputter.stdout }
|
20
|
+
@iut = Log4rAuditingProvider.new( { Logger => auditor_configuration } ).select
|
21
|
+
|
22
|
+
some_debug_object = 123
|
23
|
+
@iut.info("This is info")
|
24
|
+
@iut.debug(some_debug_object)
|
25
|
+
dropped = 95
|
26
|
+
@iut.warn("Statistics show that dropped packets have increased to #{dropped}%")
|
27
|
+
@iut.error("Could not resend some dropped packets. They have been lost. All is still OK, I could compensate")
|
28
|
+
@iut.fatal("Unable to perform action, too many dropped packets. Functional degradation.")
|
29
|
+
@iut << 'Rack::CommonLogger requires this'
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
main = Main.new
|
34
|
+
main.test_sanity
|
@@ -0,0 +1,25 @@
|
|
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_provider/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "soar_auditing_provider"
|
8
|
+
spec.version = SoarAuditingProvider::VERSION
|
9
|
+
spec.authors = ["Ernst Van Graan"]
|
10
|
+
spec.email = ["ernst.van.graan@hetzner.co.za"]
|
11
|
+
|
12
|
+
spec.summary = %q{API for SOAR architecture auditing}
|
13
|
+
spec.description = %q{API for SOAR architecture auditing}
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
17
|
+
spec.bindir = "exe"
|
18
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.11"
|
22
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
23
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
24
|
+
spec.add_development_dependency "byebug"
|
25
|
+
end
|
metadata
ADDED
@@ -0,0 +1,120 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: soar_auditing_provider
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.5.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ernst Van Graan
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-05-14 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: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description: API for SOAR architecture auditing
|
70
|
+
email:
|
71
|
+
- ernst.van.graan@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_provider.rb
|
88
|
+
- lib/soar_auditing_provider/auditing_provider_api.rb
|
89
|
+
- lib/soar_auditing_provider/version.rb
|
90
|
+
- sanity/.gitignore
|
91
|
+
- sanity/.ruby-gemset
|
92
|
+
- sanity/.ruby-version
|
93
|
+
- sanity/Gemfile
|
94
|
+
- sanity/sanity.rb
|
95
|
+
- soar_auditing_provider.gemspec
|
96
|
+
homepage:
|
97
|
+
licenses:
|
98
|
+
- MIT
|
99
|
+
metadata: {}
|
100
|
+
post_install_message:
|
101
|
+
rdoc_options: []
|
102
|
+
require_paths:
|
103
|
+
- lib
|
104
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
105
|
+
requirements:
|
106
|
+
- - ">="
|
107
|
+
- !ruby/object:Gem::Version
|
108
|
+
version: '0'
|
109
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
110
|
+
requirements:
|
111
|
+
- - ">="
|
112
|
+
- !ruby/object:Gem::Version
|
113
|
+
version: '0'
|
114
|
+
requirements: []
|
115
|
+
rubyforge_project:
|
116
|
+
rubygems_version: 2.4.8
|
117
|
+
signing_key:
|
118
|
+
specification_version: 4
|
119
|
+
summary: API for SOAR architecture auditing
|
120
|
+
test_files: []
|