soar_auditor_api 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +15 -0
- data/lib/soar_auditor_api/auditor_api.rb +4 -3
- data/lib/soar_auditor_api/version.rb +1 -1
- data/sanity/Gemfile +1 -1
- data/sanity/sanity.rb +6 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5b6df8f23b406ea3f044f762a4b89c682ffa1e78
|
4
|
+
data.tar.gz: 457d8bc37bd018832c15a9f03b8c6a563502a898
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f2cbe2db4c2ebb1ff3c4aeb4591acc453032d44a8a62d7eaa3644ba09aa69cf187d95ecbc07af2b82113ae9b3d6f8ac3d47f60349e959aecd618fa68b2f06f47
|
7
|
+
data.tar.gz: c0f88aadbe0f8a7aa92edfeff0494b8dfd6a19945edca55911bd0458e160988bb78614d495bc440603ad4d5d38a637f24f113145fa32d8dffd2858a714d3baf4
|
data/README.md
CHANGED
@@ -99,6 +99,21 @@ some_debug_object = 123
|
|
99
99
|
@iut.debug(some_debug_object)
|
100
100
|
```
|
101
101
|
|
102
|
+
### Serializable classes
|
103
|
+
|
104
|
+
Class instances to be logged in the message field can be serialized by extending from the SoarAuditorApi::Serializable class.
|
105
|
+
Store the data in the @data attribute and implement the to_s method that calls the serialize method in the base class.
|
106
|
+
|
107
|
+
``` ruby
|
108
|
+
class TestSerializable < SoarAuditorApi::Serializable
|
109
|
+
attr_accessor :data
|
110
|
+
|
111
|
+
def to_s
|
112
|
+
serialize
|
113
|
+
end
|
114
|
+
end
|
115
|
+
```
|
116
|
+
|
102
117
|
## Detailed example
|
103
118
|
|
104
119
|
```ruby
|
@@ -1,10 +1,11 @@
|
|
1
1
|
module SoarAuditorApi
|
2
2
|
class AuditorAPI
|
3
3
|
AUDIT_LEVELS = [:debug, :info, :warn, :error, :fatal] unless defined? AUDIT_LEVELS; AUDIT_LEVELS.freeze
|
4
|
+
DEFAULT_AUDIT_LEVEL = :info unless defined? DEFAULT_AUDIT_LEVEL; DEFAULT_AUDIT_LEVEL.freeze
|
4
5
|
|
5
6
|
def initialize
|
6
7
|
@configuration = nil
|
7
|
-
@minimum_audit_level =
|
8
|
+
@minimum_audit_level = DEFAULT_AUDIT_LEVEL
|
8
9
|
end
|
9
10
|
|
10
11
|
def configure(configuration = nil)
|
@@ -43,12 +44,12 @@ module SoarAuditorApi
|
|
43
44
|
|
44
45
|
#Safety to ensure that the Auditor that extends this API implements this IOC method
|
45
46
|
def configuration_is_valid?(configuration)
|
46
|
-
raise NotImplementedError, "
|
47
|
+
raise NotImplementedError, "Class must implement configuration_is_valid? method in Auditor extending the API"
|
47
48
|
end
|
48
49
|
|
49
50
|
#Safety to ensure that the Auditor that extends this API implements this IOC method
|
50
51
|
def audit(data)
|
51
|
-
raise NotImplementedError, "
|
52
|
+
raise NotImplementedError, "Class must implement audit method in Auditor extending the API"
|
52
53
|
end
|
53
54
|
|
54
55
|
private
|
data/sanity/Gemfile
CHANGED
data/sanity/sanity.rb
CHANGED
@@ -11,10 +11,11 @@ class SanityAuditor < SoarAuditorApi::AuditorAPI
|
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
|
-
class
|
14
|
+
class TestSerializable < SoarAuditorApi::Serializable
|
15
15
|
def to_s
|
16
|
-
serialize
|
16
|
+
serialize
|
17
17
|
end
|
18
|
+
end
|
18
19
|
|
19
20
|
class Main
|
20
21
|
def test_sanity
|
@@ -31,6 +32,9 @@ class Main
|
|
31
32
|
@iut.error("Could not resend some dropped packets. They have been lost. All is still OK, I could compensate")
|
32
33
|
@iut.fatal("Unable to perform action, too many dropped packets. Functional degradation.")
|
33
34
|
@iut << 'Rack::CommonLogger requires this'
|
35
|
+
|
36
|
+
serializable_object = TestSerializable.new("some data")
|
37
|
+
serializable_object.to_s
|
34
38
|
end
|
35
39
|
end
|
36
40
|
|