soar_auditing_provider 0.6.0 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0d111d5c387c29b5e0e250738f431f5e4ddd8283
4
- data.tar.gz: 47c07689ce1876570f2ab18ec4adcbdcb8a253b3
3
+ metadata.gz: e21b8597fa31874223d872ab5ce118eacb7a3e01
4
+ data.tar.gz: bf73f8eebe80cd8a37e380f2fecc9ca9b6efaf97
5
5
  SHA512:
6
- metadata.gz: a75314385273556c5a6f10aad6969e77384048da207a2872eb6036de7c434fcaa467317eba2da4d529678516c6ba3276027044445f06aaaa1e3f0705958e347f
7
- data.tar.gz: eb69f3e8a51068240d6ee6b9e1361ca5bdd6eac0cbf7e37122cce75628ef821df12e37a8b6af779bf4eabe452a212d7e113620ef368cc4a870b1907810c866fc
6
+ metadata.gz: 3b0caa7895367d66046e60dbcdf23549313efaf9fa92f2d717217225d02d908b203124c4c2d66d9946c3b6d1a05735e9234642c090d6079544dd9891474baaa9
7
+ data.tar.gz: 90e297cf7d8f4d42f56ecc157068f30bc97a57ab3b7e97d834566e64957d97d8a95b0da403a565c2cb461aaee84103b8eaaa2ff0ced27e4f3875680548ecd347
data/README.md CHANGED
@@ -2,9 +2,13 @@
2
2
 
3
3
  This gem provides the auditing API that audit providers for the SOAR architecture should adhere to.
4
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.
5
+ Providers are initialized with a list of auditors (already configured) and their configurations, which include the NFRs they support (key: 'nfrs'), and is responsible for selecting an auditor given a set of NFRs. Such selection is made by calling the select(nfrs) method. The auditing API as set out below then delegates auditing actions to the selected auditor.
6
6
 
7
- The API provides default delegation behaviour that calls the API methods verbatim on the auditor.
7
+ The API provides default delegation behaviour that calls the API methods verbatim on the auditor. NFRs can be anything you want. You can ask the auditing provider to select an auditor based on a set of NFRs. The default behaviour is that the first auditor which matches all NFRs exactly is returned. You can override this behaviour by overriding the select(nfrs) method.
8
+
9
+ If you'd simply like the auditing provider to use the first (perhaps only?) auditor that it knows about, you can tell it to select DEFAULT so:
10
+
11
+ auditor = auditing_provider.select(SoarAuditingProvider::AuditingProviderAPI::DEFAULT)
8
12
 
9
13
  ## Installation
10
14
 
@@ -24,32 +28,31 @@ Or install it yourself as:
24
28
 
25
29
  ## Usage
26
30
 
27
- Extend the SoarAuditingProvider::AuditingProviderAPI to create an auditing provider:
31
+ Extend the SoarAuditingProvider::AuditingProviderAPI to create a new auditing provider, or instantiate the API directly for an out-of-the-box auditing provider with default behaviour.
28
32
 
29
33
  ```
30
34
  class MyAuditingProvider < SoarAuditingProvider::AuditingProviderAPI
31
35
  end
32
36
  ```
33
37
 
34
- Provide the required inversion of control method to configure (an) injected auditor(s):
38
+ or
35
39
 
36
40
  ```
37
- def configure_auditor(configuration = nil)
38
- @auditor.configure(configuration)
39
- end
41
+ auditor_provider = SoarAuditingProvider::AuditingProviderAPI.new(auditors)
40
42
  ```
41
43
 
42
44
  Initialize the provider so:
43
45
 
44
46
  ```
45
47
  auditor = MyAuditor.new
46
- auditor_configuration = { 'nfrs' => { 'nfr' => 'description' }, 'some' => 'configuration' }
47
- @iut = MyAuditingProvider.new(auditor, auditor_configuration)
48
+ auditor_nfrs = { 'nfrs' => { 'accessibility' => 'local' }, 'privacy' => 'not encrypted' }
49
+ @iut = MyAuditingProvider.new( { auditor => auditor_nfrs } )
48
50
  ```
49
51
 
50
- Audit using the API methods, e.g.:
52
+ Select an auditor and audit using the API methods. The auditing provider remembers your selection, e.g.:
51
53
 
52
54
  ```
55
+ @iut.select( {'accessibility' => 'local' })
53
56
  @iut.info("This is info")
54
57
  @iut.debug(some_debug_object)
55
58
  @iut.warn("Statistics show that dropped packets have increased to #{dropped}%")
@@ -58,6 +61,18 @@ Audit using the API methods, e.g.:
58
61
  @iut << 'Rack::CommonLogger requires this'
59
62
  ```
60
63
 
64
+ Alternatively, to use different auditors for different sets of NFRs in the same code, do as below. The auditing provider remembers the last auditor selected.
65
+
66
+ ```
67
+ auditor_A = @iut.select( {'my nfr 1' => 'criteria 1' })
68
+ auditor_B = @iut.select( {'my nfr 2' => 'criteria 2' })
69
+
70
+ auditor_A.debug('debug')
71
+ auditor_B.warn('warn')
72
+
73
+ @iut.error('error') # Uses auditor_B since it was selected last
74
+ ```
75
+
61
76
  The API also supports appending as below, enabling support, e.g. for Rack::CommonLogger, etc.:
62
77
 
63
78
  ```
@@ -70,21 +85,14 @@ The API also supports appending as below, enabling support, e.g. for Rack::Commo
70
85
  require 'log4r'
71
86
  require 'soar_auditing_provider'
72
87
 
73
- class Log4rAuditingProvider < SoarAuditingProvider::AuditingProviderAPI
74
- def configure_auditor(configuration = nil)
75
- @auditor.outputters = configuration['outputter']
76
- end
77
- end
78
-
79
88
  class Main
80
89
  include Log4r
81
-
90
+
82
91
  def test_sanity
83
92
  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
-
93
+ auditor.outputters = Outputter.stdout
94
+ @iut = SoarAuditingProvider::AuditingProviderAPI.new( { auditor => { 'nfrs' => {'accessibility' => 'local'} } } )
95
+ @iut.select(SoarAuditingProvider::AuditingProviderAPI::DEFAULT)
88
96
  some_debug_object = 123
89
97
  @iut.info("This is info")
90
98
  @iut.debug(some_debug_object)
@@ -92,6 +100,7 @@ class Main
92
100
  @iut.warn("Statistics show that dropped packets have increased to #{dropped}%")
93
101
  @iut.error("Could not resend some dropped packets. They have been lost. All is still OK, I could compensate")
94
102
  @iut.fatal("Unable to perform action, too many dropped packets. Functional degradation.")
103
+ @iut << 'Rack::CommonLogger requires this'
95
104
  end
96
105
  end
97
106
 
@@ -55,18 +55,7 @@ module SoarAuditingProvider
55
55
  end
56
56
  configuration = auditors[auditor_selected]
57
57
  @auditor = auditor_selected
58
- configure_auditor(@auditor, configuration)
59
- @auditor
58
+ return @auditor, configuration
60
59
  end
61
-
62
- protected
63
-
64
- def configure_auditor(auditor, configuration = nil)
65
- raise NotImplementedError.new("You should override this method and configure your auditor")
66
- end
67
-
68
- private
69
-
70
-
71
60
  end
72
61
  end
@@ -1,3 +1,3 @@
1
1
  module SoarAuditingProvider
2
- VERSION = "0.6.0"
2
+ VERSION = "0.7.0"
3
3
  end
data/sanity/sanity.rb CHANGED
@@ -1,23 +1,13 @@
1
1
  require 'log4r'
2
2
  require 'soar_auditing_provider'
3
3
 
4
- class Log4rAuditingProvider < SoarAuditingProvider::AuditingProviderAPI
5
- def configure_auditor(auditor, configuration = nil)
6
- auditor.outputters = configuration['outputter']
7
- end
8
-
9
- def select(nfrs)
10
- super(nfrs)
11
- end
12
- end
13
-
14
4
  class Main
15
5
  include Log4r
16
6
 
17
7
  def test_sanity
18
8
  auditor = Logger.new 'sanity'
19
- auditor_configuration = { 'outputter' => Outputter.stdout }
20
- @iut = Log4rAuditingProvider.new( { auditor => auditor_configuration } )
9
+ auditor.outputters = Outputter.stdout
10
+ @iut = SoarAuditingProvider::AuditingProviderAPI.new( { auditor => { 'nfrs' => {'accessibility' => 'local'} } } )
21
11
  @iut.select(SoarAuditingProvider::AuditingProviderAPI::DEFAULT)
22
12
  some_debug_object = 123
23
13
  @iut.info("This is info")
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: soar_auditing_provider
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ernst Van Graan