mihari 4.7.4 → 4.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (28) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +4 -0
  3. data/lib/mihari/commands/validator.rb +2 -1
  4. data/lib/mihari/structs/rule.rb +12 -28
  5. data/lib/mihari/version.rb +1 -1
  6. data/lib/mihari/web/public/index.html +1 -1
  7. data/lib/mihari/web/public/redoc-static.html +282 -246
  8. data/lib/mihari/web/public/static/css/{chunk-vendors.5013d549.css → chunk-vendors.380724be.css} +2 -2
  9. data/lib/mihari/web/public/static/fonts/fa-brands-400.86c7e1fa.woff2 +0 -0
  10. data/lib/mihari/web/public/static/fonts/{fa-brands-400.7fa789ab.ttf → fa-brands-400.f5defc2e.ttf} +0 -0
  11. data/lib/mihari/web/public/static/fonts/{fa-regular-400.da02cb7e.ttf → fa-regular-400.3edb9004.ttf} +0 -0
  12. data/lib/mihari/web/public/static/fonts/fa-regular-400.e0550912.woff2 +0 -0
  13. data/lib/mihari/web/public/static/fonts/fa-solid-900.64d5644d.woff2 +0 -0
  14. data/lib/mihari/web/public/static/fonts/{fa-solid-900.3a463ec3.ttf → fa-solid-900.f418d876.ttf} +0 -0
  15. data/lib/mihari/web/public/static/fonts/{fa-v4compatibility.924588dc.ttf → fa-v4compatibility.7e7e1dad.ttf} +0 -0
  16. data/lib/mihari/web/public/static/js/app.6413bf4f.js +2 -0
  17. data/lib/mihari/web/public/static/js/app.6413bf4f.js.map +1 -0
  18. data/lib/mihari/web/public/static/js/chunk-vendors.723e02cf.js +31 -0
  19. data/lib/mihari/web/public/static/js/chunk-vendors.723e02cf.js.map +1 -0
  20. data/mihari.gemspec +8 -8
  21. metadata +31 -30
  22. data/lib/mihari/web/public/static/fonts/fa-brands-400.859fc388.woff2 +0 -0
  23. data/lib/mihari/web/public/static/fonts/fa-regular-400.2ffd018f.woff2 +0 -0
  24. data/lib/mihari/web/public/static/fonts/fa-solid-900.40ddefd7.woff2 +0 -0
  25. data/lib/mihari/web/public/static/js/app.524d9ed2.js +0 -2
  26. data/lib/mihari/web/public/static/js/app.524d9ed2.js.map +0 -1
  27. data/lib/mihari/web/public/static/js/chunk-vendors.64580a1f.js +0 -31
  28. data/lib/mihari/web/public/static/js/chunk-vendors.64580a1f.js.map +0 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4afac31be7c26f9357097db69a0f5e8e175b9d7bb14f66adc85d38f8d5606dad
4
- data.tar.gz: c6259db1f4f4ed657993e817d3f8fafec5632370f0d21e761ee1dba5fb490321
3
+ metadata.gz: 3e827da38142045be9b680636eb69b61d18e465b83f33d3a2a435c251041c7fc
4
+ data.tar.gz: 91d0c1fa7e50512c9a2bb8aceb914f69bec149c3fd7dc16f136a4b391a086e56
5
5
  SHA512:
6
- metadata.gz: 0dff43154e317cc31dc13a85f3d7ae14c362ea23ccec2f0d48cff1f12ffb5a0f8f292465888ca9044234963bf5ba5fe5c4ce920111d9b0a8f083c067896e2efa
7
- data.tar.gz: 46e9e1a2fd39d1bb61d8f3db73362074df83d80c5b37c39923a71ed9388059eef249b257116944016c33199c17dd283bbae41325ea29e74dd9759f0acfd6a14c
6
+ metadata.gz: c6c06c7d217091158d3fc354ccf3e0640494cfcd26b38cf5927d4d2a43f961ce8d2bf7d87bc965037554e745bf54b7dcf06e02b96d93962e6b0948bff11119d7
7
+ data.tar.gz: 5dd97d8c4a4d9ae9eac0e3823e8da97210de5dae87c448f48f6df565a12c99e7f0620d0477862762465aa77b0727912ccc935cd941e9a291a48a763fbf9ab8f3
data/.rubocop.yml ADDED
@@ -0,0 +1,4 @@
1
+ Style/HashSyntax:
2
+ EnforcedShorthandSyntax: either
3
+ Style/StringLiterals:
4
+ EnforcedStyle: double_quotes
@@ -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:\n#{rule.data.to_yaml}"
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
@@ -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
- begin
58
- contract = Schemas::RuleContract.new
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, "Data should be a hash" unless data.is_a?(Hash)
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
- message = "Failed to parse the input as a rule"
75
- message += ": #{e.message}" unless e.message.empty?
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Mihari
4
- VERSION = "4.7.4"
4
+ VERSION = "4.8.0"
5
5
  end
@@ -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.64580a1f.js"></script><script defer="defer" src="/static/js/app.524d9ed2.js"></script><link href="/static/css/chunk-vendors.5013d549.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>
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>