mihari 5.2.4 → 5.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (126) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +4 -1
  3. data/README.md +0 -10
  4. data/Rakefile +7 -1
  5. data/build_frontend.sh +1 -1
  6. data/frontend/.eslintrc.cjs +22 -0
  7. data/frontend/.gitignore +18 -12
  8. data/frontend/.prettierrc.json +8 -0
  9. data/frontend/env.d.ts +5 -0
  10. data/frontend/package-lock.json +5095 -9661
  11. data/frontend/package.json +34 -24
  12. data/frontend/src/App.vue +5 -5
  13. data/frontend/src/api-helper.ts +38 -40
  14. data/frontend/src/api.ts +40 -40
  15. data/frontend/src/components/ErrorMessage.vue +8 -8
  16. data/frontend/src/components/Loading.vue +3 -3
  17. data/frontend/src/components/Navbar.vue +10 -27
  18. data/frontend/src/components/Pagination.vue +35 -42
  19. data/frontend/src/components/alert/Alert.vue +21 -26
  20. data/frontend/src/components/alert/Alerts.vue +23 -25
  21. data/frontend/src/components/alert/AlertsWithPagination.vue +34 -34
  22. data/frontend/src/components/alert/AlertsWrapper.vue +42 -49
  23. data/frontend/src/components/alert/Form.vue +39 -40
  24. data/frontend/src/components/artifact/AS.vue +7 -7
  25. data/frontend/src/components/artifact/Artifact.vue +66 -83
  26. data/frontend/src/components/artifact/ArtifactTag.vue +21 -27
  27. data/frontend/src/components/artifact/ArtifactTags.vue +8 -8
  28. data/frontend/src/components/artifact/ArtifactWrapper.vue +22 -25
  29. data/frontend/src/components/artifact/CPEs.vue +6 -6
  30. data/frontend/src/components/artifact/DnsRecords.vue +9 -9
  31. data/frontend/src/components/artifact/Ports.vue +6 -6
  32. data/frontend/src/components/artifact/ReverseDnsNames.vue +7 -7
  33. data/frontend/src/components/artifact/Tags.vue +6 -6
  34. data/frontend/src/components/artifact/WhoisRecord.vue +7 -9
  35. data/frontend/src/components/config/Configs.vue +7 -10
  36. data/frontend/src/components/config/ConfigsWrapper.vue +14 -20
  37. data/frontend/src/components/link/Link.vue +7 -7
  38. data/frontend/src/components/link/Links.vue +16 -21
  39. data/frontend/src/components/rule/EditRule.vue +22 -22
  40. data/frontend/src/components/rule/EditRuleWrapper.vue +22 -28
  41. data/frontend/src/components/rule/Form.vue +28 -28
  42. data/frontend/src/components/rule/InputForm.vue +31 -25
  43. data/frontend/src/components/rule/NewRule.vue +18 -18
  44. data/frontend/src/components/rule/Rule.vue +25 -27
  45. data/frontend/src/components/rule/RuleWrapper.vue +24 -31
  46. data/frontend/src/components/rule/Rules.vue +26 -30
  47. data/frontend/src/components/rule/RulesWrapper.vue +39 -42
  48. data/frontend/src/components/rule/YAML.vue +19 -22
  49. data/frontend/src/components/tag/Tag.vue +24 -32
  50. data/frontend/src/components/tag/Tags.vue +11 -11
  51. data/frontend/src/countries.ts +23 -23
  52. data/frontend/src/index.ts +9 -12
  53. data/frontend/src/links/anyrun.ts +10 -10
  54. data/frontend/src/links/base.ts +3 -3
  55. data/frontend/src/links/censys.ts +10 -10
  56. data/frontend/src/links/crtsh.ts +10 -10
  57. data/frontend/src/links/dnslytics.ts +18 -18
  58. data/frontend/src/links/greynoise.ts +10 -10
  59. data/frontend/src/links/index.ts +15 -15
  60. data/frontend/src/links/intezer.ts +10 -10
  61. data/frontend/src/links/otx.ts +14 -14
  62. data/frontend/src/links/securitytrails.ts +15 -15
  63. data/frontend/src/links/shodan.ts +10 -10
  64. data/frontend/src/links/urlscan.ts +19 -19
  65. data/frontend/src/links/virustotal.ts +27 -27
  66. data/frontend/src/main.ts +8 -8
  67. data/frontend/src/router/index.ts +20 -20
  68. data/frontend/src/rule.ts +6 -6
  69. data/frontend/src/shims-vue.d.ts +2 -2
  70. data/frontend/src/types.ts +91 -91
  71. data/frontend/src/utils.ts +23 -29
  72. data/frontend/src/views/Alerts.vue +7 -7
  73. data/frontend/src/views/Artifact.vue +17 -17
  74. data/frontend/src/views/Configs.vue +7 -7
  75. data/frontend/src/views/EditRule.vue +17 -17
  76. data/frontend/src/views/NewRule.vue +10 -10
  77. data/frontend/src/views/Rule.vue +17 -17
  78. data/frontend/src/views/Rules.vue +7 -7
  79. data/frontend/tests/utils.spec.ts +9 -0
  80. data/frontend/tsconfig.app.json +21 -0
  81. data/frontend/tsconfig.json +10 -36
  82. data/frontend/tsconfig.node.json +13 -0
  83. data/frontend/tsconfig.vitest.json +12 -0
  84. data/frontend/vite.config.ts +24 -0
  85. data/frontend/vitest.config.ts +21 -0
  86. data/lefthook.yml +4 -2
  87. data/lib/mihari/analyzers/base.rb +48 -14
  88. data/lib/mihari/analyzers/binaryedge.rb +10 -15
  89. data/lib/mihari/analyzers/censys.rb +12 -15
  90. data/lib/mihari/analyzers/circl.rb +10 -10
  91. data/lib/mihari/analyzers/crtsh.rb +10 -6
  92. data/lib/mihari/analyzers/dnstwister.rb +6 -8
  93. data/lib/mihari/analyzers/feed.rb +21 -10
  94. data/lib/mihari/analyzers/greynoise.rb +10 -20
  95. data/lib/mihari/analyzers/onyphe.rb +9 -14
  96. data/lib/mihari/analyzers/otx.rb +8 -9
  97. data/lib/mihari/analyzers/passivetotal.rb +10 -10
  98. data/lib/mihari/analyzers/pulsedive.rb +21 -31
  99. data/lib/mihari/analyzers/securitytrails.rb +8 -6
  100. data/lib/mihari/analyzers/shodan.rb +8 -13
  101. data/lib/mihari/analyzers/urlscan.rb +15 -20
  102. data/lib/mihari/analyzers/virustotal.rb +16 -26
  103. data/lib/mihari/analyzers/virustotal_intelligence.rb +11 -17
  104. data/lib/mihari/analyzers/zoomeye.rb +12 -17
  105. data/lib/mihari/config.rb +133 -0
  106. data/lib/mihari/constants.rb +3 -0
  107. data/lib/mihari/emitters/slack.rb +13 -3
  108. data/lib/mihari/errors.rb +1 -1
  109. data/lib/mihari/http.rb +2 -3
  110. data/lib/mihari/schemas/analyzer.rb +2 -0
  111. data/lib/mihari/type_checker.rb +6 -6
  112. data/lib/mihari/version.rb +1 -1
  113. data/lib/mihari/web/endpoints/configs.rb +5 -1
  114. data/lib/mihari/web/public/assets/{index-eed1bcd8.css → index-2ba8f0a6.css} +1 -1
  115. data/lib/mihari/web/public/assets/{index-ac4e5ffa.js → index-71285b15.js} +16 -16
  116. data/lib/mihari/web/public/index.html +2 -2
  117. data/lib/mihari/web/public/redoc-static.html +388 -2193
  118. data/lib/mihari.rb +9 -59
  119. data/mihari.gemspec +8 -8
  120. metadata +24 -62
  121. data/frontend/.browserslistrc +0 -3
  122. data/frontend/.eslintrc.js +0 -33
  123. data/frontend/babel.config.js +0 -3
  124. data/frontend/jest.config.js +0 -9
  125. data/frontend/tests/unit/utils.spec.ts +0 -7
  126. data/frontend/vite.config.js +0 -24
@@ -0,0 +1,133 @@
1
+ module Mihari
2
+ class Config
3
+ # @return [String, nil]
4
+ attr_accessor :binaryedge_api_key
5
+
6
+ # @return [String, nil]
7
+ attr_accessor :censys_id
8
+
9
+ # @return [String, nil]
10
+ attr_accessor :censys_secret
11
+
12
+ # @return [String, nil]
13
+ attr_accessor :circl_passive_password
14
+
15
+ # @return [String, nil]
16
+ attr_accessor :circl_passive_username
17
+
18
+ # @return [URI]
19
+ attr_accessor :database_url
20
+
21
+ # @return [String, nil]
22
+ attr_accessor :greynoise_api_key
23
+
24
+ # @return [String, nil]
25
+ attr_accessor :ipinfo_api_key
26
+
27
+ # @return [String, nil]
28
+ attr_accessor :misp_url
29
+
30
+ # @return [String, nil]
31
+ attr_accessor :misp_api_key
32
+
33
+ # @return [String, nil]
34
+ attr_accessor :onyphe_api_key
35
+
36
+ # @return [String, nil]
37
+ attr_accessor :otx_api_key
38
+
39
+ # @return [String, nil]
40
+ attr_accessor :passivetotal_api_key
41
+
42
+ # @return [String, nil]
43
+ attr_accessor :passivetotal_username
44
+
45
+ # @return [String, nil]
46
+ attr_accessor :pulsedive_api_key
47
+
48
+ # @return [String, nil]
49
+ attr_accessor :securitytrails_api_key
50
+
51
+ # @return [String, nil]
52
+ attr_accessor :shodan_api_key
53
+
54
+ # @return [String, nil]
55
+ attr_accessor :slack_channel
56
+
57
+ # @return [String, nil]
58
+ attr_accessor :slack_webhook_url
59
+
60
+ # @return [String, nil]
61
+ attr_accessor :thehive_url
62
+
63
+ # @return [String, nil]
64
+ attr_accessor :thehive_api_key
65
+
66
+ # @return [String, nil]
67
+ attr_accessor :thehive_api_version
68
+
69
+ # @return [String, nil]
70
+ attr_accessor :urlscan_api_key
71
+
72
+ # @return [String, nil]
73
+ attr_accessor :virustotal_api_key
74
+
75
+ # @return [String, nil]
76
+ attr_accessor :zoomeye_api_key
77
+
78
+ # @return [String, nil]
79
+ attr_accessor :sentry_dsn
80
+
81
+ # @return [String, nil]
82
+ attr_accessor :hide_config_values
83
+
84
+ def initialize
85
+ @binaryedge_api_key = ENV.fetch("BINARYEDGE_API_KEY", nil)
86
+
87
+ @censys_id = ENV.fetch("CENSYS_ID", nil)
88
+ @censys_secret = ENV.fetch("CENSYS_SECRET", nil)
89
+
90
+ @circl_passive_password = ENV.fetch("CIRCL_PASSIVE_PASSWORD", nil)
91
+ @circl_passive_username = ENV.fetch("CIRCL_PASSIVE_USERNAME", nil)
92
+
93
+ @database_url = URI(ENV.fetch("DATABASE_URL", "sqlite3:///mihari.db"))
94
+
95
+ @greynoise_api_key = ENV.fetch("GREYNOISE_API_KEY", nil)
96
+
97
+ @ipinfo_api_key = ENV.fetch("IPINFO_API_KEY", nil)
98
+
99
+ @misp_url = ENV.fetch("MISP_URL", nil)
100
+ @misp_api_key = ENV.fetch("MISP_API_KEY", nil)
101
+
102
+ @onyphe_api_key = ENV.fetch("ONYPHE_API_KEY", nil)
103
+
104
+ @otx_api_key = ENV.fetch("OTX_API_KEY", nil)
105
+
106
+ @passivetotal_api_key = ENV.fetch("PASSIVETOTAL_API_KEY", nil)
107
+ @passivetotal_username = ENV.fetch("PASSIVETOTAL_USERNAME", nil)
108
+
109
+ @pulsedive_api_key = ENV.fetch("PULSEDIVE_API_KEY", nil)
110
+
111
+ @securitytrails_api_key = ENV.fetch("SECURITYTRAILS_API_KEY", nil)
112
+
113
+ @shodan_api_key = ENV.fetch("SHODAN_API_KEY", nil)
114
+
115
+ @slack_channel = ENV.fetch("SLACK_CHANNEL", nil)
116
+ @slack_webhook_url = ENV.fetch("SLACK_WEBHOOK_URL", nil)
117
+
118
+ @thehive_url = ENV.fetch("THEHIVE_URL", nil)
119
+ @thehive_api_key = ENV.fetch("THEHIVE_API_KEY", nil)
120
+ @thehive_api_version = ENV.fetch("THEHIVE_API_VERSION", nil)
121
+
122
+ @urlscan_api_key = ENV.fetch("URLSCAN_API_KEY", nil)
123
+
124
+ @virustotal_api_key = ENV.fetch("VIRUSTOTAL_API_KEY", nil)
125
+
126
+ @zoomeye_api_key = ENV.fetch("ZOOMEYE_API_KEY", nil)
127
+
128
+ @sentry_dsn = ENV.fetch("SENTRY_DSN", nil)
129
+
130
+ @hide_config_values = ENV.fetch("HIDE_CONFIG_VALUES", false)
131
+ end
132
+ end
133
+ end
@@ -6,4 +6,7 @@ module Mihari
6
6
  DEFAULT_EMITTERS = %w[database misp slack the_hive].map { |name| { emitter: name } }.freeze
7
7
 
8
8
  DEFAULT_ENRICHERS = %w[whois ipinfo shodan google_public_dns].map { |name| { enricher: name } }.freeze
9
+
10
+ DEFAULT_RETRY_TIMES = 3
11
+ DEFAULT_RETRY_INTERVAL = 5
9
12
  end
@@ -8,10 +8,20 @@ module Mihari
8
8
  class Attachment
9
9
  include Memist::Memoizable
10
10
 
11
- extend Dry::Initializer
11
+ # @return [String]
12
+ attr_reader :data
13
+
14
+ # @return [String]
15
+ attr_reader :data_type
12
16
 
13
- option :data
14
- option :data_type
17
+ #
18
+ # @param [String] data
19
+ # @param [String] data_type
20
+ #
21
+ def initialize(data:, data_type:)
22
+ @data = data
23
+ @data_type = data_type
24
+ end
15
25
 
16
26
  def actions
17
27
  [vt_link, urlscan_link, censys_link, shodan_link].compact
data/lib/mihari/errors.rb CHANGED
@@ -21,7 +21,7 @@ module Mihari
21
21
 
22
22
  class HTTPError < Error; end
23
23
 
24
- class UnsuccessfulStatusCodeError < HTTPError; end
24
+ class StatusCodeError < HTTPError; end
25
25
 
26
26
  class NetworkError < HTTPError; end
27
27
 
data/lib/mihari/http.rb CHANGED
@@ -93,9 +93,8 @@ module Mihari
93
93
  def request(req)
94
94
  Net::HTTP.start(url.host, url.port, https_options) do |http|
95
95
  res = http.request(req)
96
- unless res.is_a?(Net::HTTPSuccess)
97
- raise UnsuccessfulStatusCodeError, "Unsuccessful response code returned: #{res.code}"
98
- end
96
+
97
+ raise StatusCodeError, "Unsuccessful response code returned: #{res.code}" unless res.is_a?(Net::HTTPSuccess)
99
98
 
100
99
  res
101
100
  end
@@ -4,6 +4,8 @@ module Mihari
4
4
  module Schemas
5
5
  AnalyzerOptions = Dry::Schema.Params do
6
6
  optional(:interval).value(:integer)
7
+ optional(:retry_times).value(:integer).default(DEFAULT_RETRY_TIMES)
8
+ optional(:retry_interval).value(:integer).default(DEFAULT_RETRY_INTERVAL)
7
9
  end
8
10
 
9
11
  AnalyzerWithoutAPIKey = Dry::Schema.Params do
@@ -2,13 +2,13 @@
2
2
 
3
3
  module Mihari
4
4
  class TypeChecker
5
- extend Dry::Initializer
6
-
7
- param :data
8
-
9
- def initialize(*args, **kwargs)
10
- super
5
+ # @return [String]
6
+ attr_reader :data
11
7
 
8
+ #
9
+ # @param [String] data
10
+ #
11
+ def initialize(data)
12
12
  raise ArgumentError if data.is_a?(Hash)
13
13
 
14
14
  @data = data.to_s
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Mihari
4
- VERSION = "5.2.4"
4
+ VERSION = "5.3.0"
5
5
  end
@@ -10,7 +10,11 @@ module Mihari
10
10
  summary: "Get configs"
11
11
  }
12
12
  get "/" do
13
- present(Mihari.configs, with: Entities::Config)
13
+ configs = (Mihari.analyzers + Mihari.emitters + Mihari.enrichers).map do |klass|
14
+ Mihari::Structs::Config.from_class(klass)
15
+ end.compact
16
+
17
+ present(configs, with: Entities::Config)
14
18
  end
15
19
  end
16
20
  end