soar_auditing_format 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: 5808f4570485d4eb876c38c01ef85919d245ade0
4
- data.tar.gz: b5e6d3f4da4a01ce2ccaceedbcd53adb3f24ca6d
3
+ metadata.gz: 63b94935c99264de5ac0f5a9fb0b88ce2f1718b4
4
+ data.tar.gz: 7397a4fff409fa113cfd28b2e7a3a5288921bf58
5
5
  SHA512:
6
- metadata.gz: cc049109e2d3c27e12b82d23b1469d26a6d2863e06b9a96fd7c075af0e5dbd02c8ac96677f679bfc08bfcf2afddd580bd965e5df7dc1aff8b50267c92846b1fc
7
- data.tar.gz: d06b0caf51d6cca33223456d82c1a522b960bb7b25b877b56f54b5a5478732ff50e202f0e86288fc928cc66a6fe01ebba6e39fd2f39edb6e82545e3ca40a2b3d
6
+ metadata.gz: 20f98f028dc46a3dcc30d774810a06cd4c4c46776b764b1bd940fe79c992e3575b96046578e3639e5f494bc74e669f360ea15b1fa55052898dd2a802519c8223
7
+ data.tar.gz: 7b596173ba504e477b029af241326eab01920e5489b3499e3ae82f1cc67b6547f01751a22c49fdc0689911393ca76ea86d384310b94f69aa33b9a173c40851e8
data/README.md CHANGED
@@ -1,15 +1,6 @@
1
1
  # SoarAuditingFormatter
2
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.
3
+ This gem provides the formatting of audit entries for auditing purposes.
13
4
 
14
5
  ## Installation
15
6
 
@@ -35,70 +26,16 @@ Behavioural driven testing can be performed:
35
26
 
36
27
  ## Usage
37
28
 
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
- ```
29
+ When formatting an auditing entry call the formatter as follow:
83
30
 
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
31
  ```ruby
86
- @iut.set_audit_level(:warn)
32
+ SoarAuditingFormatter::Formatter.format(:error,SecureRandom.hex(32),Time.now,"message")
87
33
  ```
88
34
 
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
- ```
35
+ When formatting an optional field call the formatter as follow:
97
36
 
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
37
  ```ruby
100
- some_debug_object = 123
101
- @iut.debug(some_debug_object)
38
+ SoarAuditingFormatter::Formatter.optional_field_format("somekey", "somevalue")
102
39
  ```
103
40
 
104
41
  ## Detailed example
@@ -106,32 +43,12 @@ some_debug_object = 123
106
43
  ```ruby
107
44
  require 'soar_auditing_format'
108
45
  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
46
+ require 'securerandom'
119
47
 
120
48
  class Main
121
49
  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'
50
+ my_optional_field = SoarAuditingFormatter::Formatter.optional_field_format("somekey", "somevalue")
51
+ puts SoarAuditingFormatter::Formatter.format(:error,SecureRandom.hex(32),Time.now,"#{my_optional_field} message")
135
52
  end
136
53
  end
137
54
 
@@ -1,3 +1,3 @@
1
1
  module SoarAuditingFormatter
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
data/sanity/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
3
  gem 'byebug'
4
- gem 'soar_auditing_format', "~> 0.0.1"
4
+ gem 'soar_auditing_format', "~> 0.0.2"
data/sanity/sanity.rb CHANGED
@@ -1,9 +1,11 @@
1
1
  require 'soar_auditing_format'
2
2
  require 'byebug'
3
+ require 'securerandom'
3
4
 
4
5
  class Main
5
6
  def test_sanity
6
- SoarAuditingFormatter::Formatter.format("level",SecureRandom.hex(32),Time.now,"message")
7
+ my_optional_field = SoarAuditingFormatter::Formatter.optional_field_format("somekey", "somevalue")
8
+ puts SoarAuditingFormatter::Formatter.format(:error,SecureRandom.hex(32),Time.now,"#{my_optional_field} message")
7
9
  end
8
10
  end
9
11
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: soar_auditing_format
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