mihari 4.7.4 → 4.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (35) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +4 -0
  3. data/README.md +0 -1
  4. data/lib/mihari/analyzers/rule.rb +0 -1
  5. data/lib/mihari/commands/search.rb +8 -2
  6. data/lib/mihari/commands/validator.rb +2 -1
  7. data/lib/mihari/schemas/analyzer.rb +0 -7
  8. data/lib/mihari/schemas/rule.rb +4 -4
  9. data/lib/mihari/structs/rule.rb +12 -28
  10. data/lib/mihari/version.rb +1 -1
  11. data/lib/mihari/web/public/index.html +1 -1
  12. data/lib/mihari/web/public/redoc-static.html +282 -246
  13. data/lib/mihari/web/public/static/css/{chunk-vendors.5013d549.css → chunk-vendors.380724be.css} +2 -2
  14. data/lib/mihari/web/public/static/fonts/fa-brands-400.86c7e1fa.woff2 +0 -0
  15. data/lib/mihari/web/public/static/fonts/{fa-brands-400.7fa789ab.ttf → fa-brands-400.f5defc2e.ttf} +0 -0
  16. data/lib/mihari/web/public/static/fonts/{fa-regular-400.da02cb7e.ttf → fa-regular-400.3edb9004.ttf} +0 -0
  17. data/lib/mihari/web/public/static/fonts/fa-regular-400.e0550912.woff2 +0 -0
  18. data/lib/mihari/web/public/static/fonts/fa-solid-900.64d5644d.woff2 +0 -0
  19. data/lib/mihari/web/public/static/fonts/{fa-solid-900.3a463ec3.ttf → fa-solid-900.f418d876.ttf} +0 -0
  20. data/lib/mihari/web/public/static/fonts/{fa-v4compatibility.924588dc.ttf → fa-v4compatibility.7e7e1dad.ttf} +0 -0
  21. data/lib/mihari/web/public/static/js/app.6413bf4f.js +2 -0
  22. data/lib/mihari/web/public/static/js/app.6413bf4f.js.map +1 -0
  23. data/lib/mihari/web/public/static/js/chunk-vendors.723e02cf.js +31 -0
  24. data/lib/mihari/web/public/static/js/chunk-vendors.723e02cf.js.map +1 -0
  25. data/lib/mihari.rb +0 -1
  26. data/mihari.gemspec +13 -13
  27. metadata +41 -41
  28. data/lib/mihari/analyzers/spyse.rb +0 -93
  29. data/lib/mihari/web/public/static/fonts/fa-brands-400.859fc388.woff2 +0 -0
  30. data/lib/mihari/web/public/static/fonts/fa-regular-400.2ffd018f.woff2 +0 -0
  31. data/lib/mihari/web/public/static/fonts/fa-solid-900.40ddefd7.woff2 +0 -0
  32. data/lib/mihari/web/public/static/js/app.524d9ed2.js +0 -2
  33. data/lib/mihari/web/public/static/js/app.524d9ed2.js.map +0 -1
  34. data/lib/mihari/web/public/static/js/chunk-vendors.64580a1f.js +0 -31
  35. 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: 85756e55047ef3bde95c50c1ac3c474adbd29828bf1f95618f3aac85638a1752
4
+ data.tar.gz: babe64cf74a96f659057b06ac3b5864b6faa2c3ec9b7e3f0f9b57bce7dd635a8
5
5
  SHA512:
6
- metadata.gz: 0dff43154e317cc31dc13a85f3d7ae14c362ea23ccec2f0d48cff1f12ffb5a0f8f292465888ca9044234963bf5ba5fe5c4ce920111d9b0a8f083c067896e2efa
7
- data.tar.gz: 46e9e1a2fd39d1bb61d8f3db73362074df83d80c5b37c39923a71ed9388059eef249b257116944016c33199c17dd283bbae41325ea29e74dd9759f0acfd6a14c
6
+ metadata.gz: 5c15c65a8952c1fbcf695feba8add8a7fc962eaac9ca426a18dd510663573dc9fe6b27472ca0edcd1ff9fb86b68a49ce8c459e3a7d90eabe9dbbe1e4506181d8
7
+ data.tar.gz: aceb04f0f6e78af7f0df2293d78a4d4d20bcf1827e70d45e3f425e38b128c5f9194dbdac608b29b44852af77b626ccbdd03583e7170d5330a2b584c7cbdca55b
data/.rubocop.yml ADDED
@@ -0,0 +1,4 @@
1
+ Style/HashSyntax:
2
+ EnforcedShorthandSyntax: either
3
+ Style/StringLiterals:
4
+ EnforcedStyle: double_quotes
data/README.md CHANGED
@@ -44,7 +44,6 @@ Mihari supports the following services by default.
44
44
  - [Pulsedive](https://pulsedive.com/)
45
45
  - [SecurityTrails](https://securitytrails.com/)
46
46
  - [Shodan](https://shodan.io)
47
- - [Spyse](https://spyse.com)
48
47
  - [urlscan.io](https://urlscan.io)
49
48
  - [VirusTotal](http://virustotal.com) & [VirusTotal Intelligence](https://www.virustotal.com/gui/intelligence-overview)
50
49
  - [ZoomEye](https://zoomeye.org)
@@ -18,7 +18,6 @@ module Mihari
18
18
  "pulsedive" => Pulsedive,
19
19
  "securitytrails" => SecurityTrails,
20
20
  "shodan" => Shodan,
21
- "spyse" => Spyse,
22
21
  "st" => SecurityTrails,
23
22
  "urlscan" => Urlscan,
24
23
  "virustotal_intelligence" => VirusTotalIntelligence,
@@ -14,7 +14,11 @@ module Mihari
14
14
  rule = Structs::Rule.from_path_or_id path_or_id
15
15
 
16
16
  # validate
17
- rule.validate!
17
+ begin
18
+ rule.validate!
19
+ rescue RuleValidationError
20
+ return
21
+ end
18
22
 
19
23
  # check update
20
24
  id = rule.id
@@ -23,7 +27,9 @@ module Mihari
23
27
  with_db_connection do
24
28
  rule_ = Mihari::Rule.find(id)
25
29
  next if rule.yaml == rule_.yaml
26
- return unless yes?("This operation will overwrite the rule in the database (Rule ID: #{id}). Are you sure you want to update the rule? (yes/no)")
30
+ unless yes?("This operation will overwrite the rule in the database (Rule ID: #{id}). Are you sure you want to update the rule? (yes/no)")
31
+ return
32
+ end
27
33
  rescue ActiveRecord::RecordNotFound
28
34
  next
29
35
  end
@@ -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
@@ -58,13 +58,6 @@ module Mihari
58
58
  optional(:options).hash(AnalyzerOptions)
59
59
  end
60
60
 
61
- Spyse = Dry::Schema.Params do
62
- required(:analyzer).value(Types::String.enum("spyse"))
63
- required(:query).value(:string)
64
- required(:type).value(Types::String.enum("ip", "domain"))
65
- optional(:options).hash(AnalyzerOptions)
66
- end
67
-
68
61
  ZoomEye = Dry::Schema.Params do
69
62
  required(:analyzer).value(Types::String.enum("zoomeye"))
70
63
  required(:query).value(:string)
@@ -22,7 +22,9 @@ module Mihari
22
22
  optional(:created_on).value(:date)
23
23
  optional(:updated_on).value(:date)
24
24
 
25
- required(:queries).value(:array).each { AnalyzerWithoutAPIKey | AnalyzerWithAPIKey | Censys | CIRCL | PassiveTotal | Spyse | ZoomEye | Urlscan | Crtsh | Feed }
25
+ required(:queries).value(:array).each do
26
+ AnalyzerWithoutAPIKey | AnalyzerWithAPIKey | Censys | CIRCL | PassiveTotal | ZoomEye | Urlscan | Crtsh | Feed
27
+ end
26
28
 
27
29
  optional(:emitters).value(:array).each { Emitter | MISP | TheHive | Slack | HTTP }
28
30
 
@@ -57,9 +59,7 @@ module Mihari
57
59
 
58
60
  rule(:disallowed_data_values) do
59
61
  value.each do |v|
60
- unless valid_disallowed_data_value?(v)
61
- key.failure("#{v} is not a valid format.")
62
- end
62
+ key.failure("#{v} is not a valid format.") unless valid_disallowed_data_value?(v)
63
63
  end
64
64
  end
65
65
  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.9.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>