mihari 4.7.2 → 4.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/test.yml +1 -0
- data/.rubocop.yml +4 -0
- data/lib/mihari/commands/validator.rb +2 -1
- data/lib/mihari/schemas/rule.rb +5 -0
- data/lib/mihari/structs/rule.rb +12 -28
- data/lib/mihari/version.rb +1 -1
- data/lib/mihari/web/public/index.html +1 -1
- data/lib/mihari/web/public/redoc-static.html +282 -246
- data/lib/mihari/web/public/static/css/{chunk-vendors.5013d549.css → chunk-vendors.380724be.css} +2 -2
- data/lib/mihari/web/public/static/fonts/fa-brands-400.86c7e1fa.woff2 +0 -0
- data/lib/mihari/web/public/static/fonts/{fa-brands-400.7fa789ab.ttf → fa-brands-400.f5defc2e.ttf} +0 -0
- data/lib/mihari/web/public/static/fonts/{fa-regular-400.da02cb7e.ttf → fa-regular-400.3edb9004.ttf} +0 -0
- data/lib/mihari/web/public/static/fonts/fa-regular-400.e0550912.woff2 +0 -0
- data/lib/mihari/web/public/static/fonts/fa-solid-900.64d5644d.woff2 +0 -0
- data/lib/mihari/web/public/static/fonts/{fa-solid-900.3a463ec3.ttf → fa-solid-900.f418d876.ttf} +0 -0
- data/lib/mihari/web/public/static/fonts/{fa-v4compatibility.924588dc.ttf → fa-v4compatibility.7e7e1dad.ttf} +0 -0
- data/lib/mihari/web/public/static/js/app.6413bf4f.js +2 -0
- data/lib/mihari/web/public/static/js/app.6413bf4f.js.map +1 -0
- data/lib/mihari/web/public/static/js/chunk-vendors.723e02cf.js +31 -0
- data/lib/mihari/web/public/static/js/chunk-vendors.723e02cf.js.map +1 -0
- data/mihari.gemspec +18 -18
- metadata +51 -50
- data/lib/mihari/web/public/static/fonts/fa-brands-400.859fc388.woff2 +0 -0
- data/lib/mihari/web/public/static/fonts/fa-regular-400.2ffd018f.woff2 +0 -0
- data/lib/mihari/web/public/static/fonts/fa-solid-900.40ddefd7.woff2 +0 -0
- data/lib/mihari/web/public/static/js/app.3ac3bd7a.js +0 -2
- data/lib/mihari/web/public/static/js/app.3ac3bd7a.js.map +0 -1
- data/lib/mihari/web/public/static/js/chunk-vendors.37b7208e.js +0 -31
- data/lib/mihari/web/public/static/js/chunk-vendors.37b7208e.js.map +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3e827da38142045be9b680636eb69b61d18e465b83f33d3a2a435c251041c7fc
|
4
|
+
data.tar.gz: 91d0c1fa7e50512c9a2bb8aceb914f69bec149c3fd7dc16f136a4b391a086e56
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c6c06c7d217091158d3fc354ccf3e0640494cfcd26b38cf5927d4d2a43f961ce8d2bf7d87bc965037554e745bf54b7dcf06e02b96d93962e6b0948bff11119d7
|
7
|
+
data.tar.gz: 5dd97d8c4a4d9ae9eac0e3823e8da97210de5dae87c448f48f6df565a12c99e7f0620d0477862762465aa77b0727912ccc935cd941e9a291a48a763fbf9ab8f3
|
data/.github/workflows/test.yml
CHANGED
data/.rubocop.yml
ADDED
@@ -18,7 +18,8 @@ module Mihari
|
|
18
18
|
|
19
19
|
begin
|
20
20
|
rule.validate!
|
21
|
-
Mihari.logger.info "Valid format. The input is parsed as the following
|
21
|
+
Mihari.logger.info "Valid format. The input is parsed as the following:"
|
22
|
+
Mihari.logger.info rule.data.to_yaml
|
22
23
|
rescue RuleValidationError
|
23
24
|
nil
|
24
25
|
end
|
data/lib/mihari/schemas/rule.rb
CHANGED
@@ -13,6 +13,11 @@ module Mihari
|
|
13
13
|
optional(:tags).value(array[:string]).default([])
|
14
14
|
optional(:id).value(:string)
|
15
15
|
|
16
|
+
optional(:status).value(:string)
|
17
|
+
|
18
|
+
optional(:related).value(array[:string])
|
19
|
+
optional(:references).value(array[:string])
|
20
|
+
|
16
21
|
optional(:author).value(:string)
|
17
22
|
optional(:created_on).value(:date)
|
18
23
|
optional(:updated_on).value(:date)
|
data/lib/mihari/structs/rule.rb
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
require "date"
|
4
4
|
require "erb"
|
5
|
+
require "json"
|
5
6
|
require "pathname"
|
6
7
|
require "yaml"
|
7
8
|
|
@@ -20,12 +21,17 @@ module Mihari
|
|
20
21
|
# @return [String]
|
21
22
|
attr_writer :id
|
22
23
|
|
24
|
+
#
|
25
|
+
# Initialize
|
26
|
+
#
|
27
|
+
# @param [Hash] data
|
28
|
+
# @param [String] yaml
|
29
|
+
#
|
23
30
|
def initialize(data, yaml)
|
24
31
|
@data = data.deep_symbolize_keys
|
25
32
|
@yaml = yaml
|
26
33
|
|
27
34
|
@errors = nil
|
28
|
-
@no_method_error = nil
|
29
35
|
|
30
36
|
validate
|
31
37
|
end
|
@@ -39,41 +45,19 @@ module Mihari
|
|
39
45
|
!@errors.empty?
|
40
46
|
end
|
41
47
|
|
42
|
-
#
|
43
|
-
# @return [Array<String>]
|
44
|
-
#
|
45
|
-
def error_messages
|
46
|
-
return [] if @errors.nil?
|
47
|
-
|
48
|
-
@errors.messages.filter_map do |message|
|
49
|
-
path = message.path.map(&:to_s).join
|
50
|
-
"#{path} #{message.text}"
|
51
|
-
rescue NoMethodError
|
52
|
-
nil
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
48
|
def validate
|
57
|
-
|
58
|
-
|
59
|
-
result = contract.call(data)
|
60
|
-
rescue NoMethodError => e
|
61
|
-
@no_method_error = e
|
62
|
-
return
|
63
|
-
end
|
49
|
+
contract = Schemas::RuleContract.new
|
50
|
+
result = contract.call(data)
|
64
51
|
|
65
52
|
@data = result.to_h
|
66
53
|
@errors = result.errors
|
67
54
|
end
|
68
55
|
|
69
56
|
def validate!
|
70
|
-
raise RuleValidationError
|
71
|
-
raise RuleValidationError, error_messages.join("\n") if errors?
|
72
|
-
raise RuleValidationError, "Something wrong with queries, emitters or enrichers." unless @no_method_error.nil?
|
57
|
+
raise RuleValidationError if errors?
|
73
58
|
rescue RuleValidationError => e
|
74
|
-
|
75
|
-
|
76
|
-
Mihari.logger.error message
|
59
|
+
Mihari.logger.error "Failed to parse the input as a rule:"
|
60
|
+
Mihari.logger.error JSON.pretty_generate(errors.to_h)
|
77
61
|
|
78
62
|
raise e
|
79
63
|
end
|
data/lib/mihari/version.rb
CHANGED
@@ -1 +1 @@
|
|
1
|
-
<!doctype html><html lang="en"><head><meta charset="utf-8"/><meta http-equiv="X-UA-Compatible" content="IE=edge"/><meta name="viewport" content="width=device-width,initial-scale=1"/><link rel="icon" href="/static/favicon.ico"/><title>Mihari</title><script defer="defer" src="/static/js/chunk-vendors.
|
1
|
+
<!doctype html><html lang="en"><head><meta charset="utf-8"/><meta http-equiv="X-UA-Compatible" content="IE=edge"/><meta name="viewport" content="width=device-width,initial-scale=1"/><link rel="icon" href="/static/favicon.ico"/><title>Mihari</title><script defer="defer" src="/static/js/chunk-vendors.723e02cf.js"></script><script defer="defer" src="/static/js/app.6413bf4f.js"></script><link href="/static/css/chunk-vendors.380724be.css" rel="stylesheet"><link href="/static/css/app.2a5d3d21.css" rel="stylesheet"></head><body><noscript><strong>We're sorry but Mihari doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id="app"></div></body></html>
|