mihari 3.7.1 → 3.9.0

Sign up to get free protection for your applications and to get access to all the features.
data/lib/mihari.rb CHANGED
@@ -30,32 +30,32 @@ module Mihari
30
30
  extend Dry::Configurable
31
31
  extend Mixins::Configuration
32
32
 
33
- setting :binaryedge_api_key, ENV["BINARYEDGE_API_KEY"]
34
- setting :censys_id, ENV["CENSYS_ID"]
35
- setting :censys_secret, ENV["CENSYS_SECRET"]
36
- setting :circl_passive_password, ENV["CIRCL_PASSIVE_PASSWORD"]
37
- setting :circl_passive_username, ENV["CIRCL_PASSIVE_USERNAME"]
38
- setting :ipinfo_api_key, ENV["IPINFO_API_KEY"]
39
- setting :misp_api_endpoint, ENV["MISP_API_ENDPOINT"]
40
- setting :misp_api_key, ENV["MISP_API_KEY"]
41
- setting :onyphe_api_key, ENV["ONYPHE_API_KEY"]
42
- setting :otx_api_key, ENV["OTX_API_KEY"]
43
- setting :passivetotal_api_key, ENV["PASSIVETOTAL_API_KEY"]
44
- setting :passivetotal_username, ENV["PASSIVETOTAL_USERNAME"]
45
- setting :pulsedive_api_key, ENV["PULSEDIVE_API_KEY"]
46
- setting :securitytrails_api_key, ENV["SECURITYTRAILS_API_KEY"]
47
- setting :shodan_api_key, ENV["SHODAN_API_KEY"]
48
- setting :slack_channel, ENV["SLACK_CHANNEL"]
49
- setting :slack_webhook_url, ENV["SLACK_WEBHOOK_URL"]
50
- setting :spyse_api_key, ENV["SPYSE_API_KEY"]
51
- setting :thehive_api_endpoint, ENV["THEHIVE_API_ENDPOINT"]
52
- setting :thehive_api_key, ENV["THEHIVE_API_KEY"]
53
- setting :urlscan_api_key, ENV["URLSCAN_API_KEY"]
54
- setting :virustotal_api_key, ENV["VIRUSTOTAL_API_KEY"]
55
- setting :zoomeye_api_key, ENV["ZOOMEYE_API_KEY"]
56
- setting :webhook_url, ENV["WEBHOOK_URL"]
57
- setting(:webhook_use_json_body, ENV["WEBHOOK_USE_JSON_BODY"]) { |value| truthy?(value) }
58
- setting :database, ENV["DATABASE"] || "mihari.db"
33
+ setting :binaryedge_api_key, default: ENV["BINARYEDGE_API_KEY"]
34
+ setting :censys_id, default: ENV["CENSYS_ID"]
35
+ setting :censys_secret, default: ENV["CENSYS_SECRET"]
36
+ setting :circl_passive_password, default: ENV["CIRCL_PASSIVE_PASSWORD"]
37
+ setting :circl_passive_username, default: ENV["CIRCL_PASSIVE_USERNAME"]
38
+ setting :ipinfo_api_key, default: ENV["IPINFO_API_KEY"]
39
+ setting :misp_api_endpoint, default: ENV["MISP_API_ENDPOINT"]
40
+ setting :misp_api_key, default: ENV["MISP_API_KEY"]
41
+ setting :onyphe_api_key, default: ENV["ONYPHE_API_KEY"]
42
+ setting :otx_api_key, default: ENV["OTX_API_KEY"]
43
+ setting :passivetotal_api_key, default: ENV["PASSIVETOTAL_API_KEY"]
44
+ setting :passivetotal_username, default: ENV["PASSIVETOTAL_USERNAME"]
45
+ setting :pulsedive_api_key, default: ENV["PULSEDIVE_API_KEY"]
46
+ setting :securitytrails_api_key, default: ENV["SECURITYTRAILS_API_KEY"]
47
+ setting :shodan_api_key, default: ENV["SHODAN_API_KEY"]
48
+ setting :slack_channel, default: ENV["SLACK_CHANNEL"]
49
+ setting :slack_webhook_url, default: ENV["SLACK_WEBHOOK_URL"]
50
+ setting :spyse_api_key, default: ENV["SPYSE_API_KEY"]
51
+ setting :thehive_api_endpoint, default: ENV["THEHIVE_API_ENDPOINT"]
52
+ setting :thehive_api_key, default: ENV["THEHIVE_API_KEY"]
53
+ setting :urlscan_api_key, default: ENV["URLSCAN_API_KEY"]
54
+ setting :virustotal_api_key, default: ENV["VIRUSTOTAL_API_KEY"]
55
+ setting :zoomeye_api_key, default: ENV["ZOOMEYE_API_KEY"]
56
+ setting :webhook_url, default: ENV["WEBHOOK_URL"]
57
+ setting :webhook_use_json_body, constructor: ->(value = ENV["WEBHOOK_USE_JSON_BODY"]) { truthy?(value) }
58
+ setting :database, default: ENV["DATABASE"] || "mihari.db"
59
59
 
60
60
  class << self
61
61
  include Mem
@@ -108,10 +108,12 @@ require "mihari/constants"
108
108
  require "mihari/types"
109
109
 
110
110
  # Structs
111
+ require "mihari/structs/alert"
111
112
  require "mihari/structs/censys"
112
113
  require "mihari/structs/ipinfo"
113
114
  require "mihari/structs/onyphe"
114
115
  require "mihari/structs/shodan"
116
+ require "mihari/structs/virustotal_intelligence"
115
117
 
116
118
  # Schemas
117
119
  require "mihari/schemas/analyzer"
@@ -163,9 +165,9 @@ require "mihari/analyzers/securitytrails"
163
165
  require "mihari/analyzers/shodan"
164
166
  require "mihari/analyzers/spyse"
165
167
  require "mihari/analyzers/urlscan"
168
+ require "mihari/analyzers/virustotal_intelligence"
166
169
  require "mihari/analyzers/virustotal"
167
170
  require "mihari/analyzers/zoomeye"
168
-
169
171
  require "mihari/analyzers/rule"
170
172
 
171
173
  # Notifiers
data/mihari.gemspec CHANGED
@@ -26,7 +26,7 @@ Gem::Specification.new do |spec|
26
26
  spec.require_paths = ["lib"]
27
27
 
28
28
  spec.add_development_dependency "bundler", "~> 2.2"
29
- spec.add_development_dependency "coveralls_reborn", "~> 0.22"
29
+ spec.add_development_dependency "coveralls_reborn", "~> 0.23"
30
30
  spec.add_development_dependency "fakefs", "~> 1.3"
31
31
  spec.add_development_dependency "mysql2", "~> 0.5"
32
32
  spec.add_development_dependency "overcommit", "~> 0.58"
@@ -55,11 +55,11 @@ Gem::Specification.new do |spec|
55
55
  spec.add_dependency "dnpedia", "~> 0.1"
56
56
  spec.add_dependency "dnstwister", "~> 0.1"
57
57
  spec.add_dependency "dotenv", "~> 2.7"
58
- spec.add_dependency "dry-configurable", "~> 0.12"
58
+ spec.add_dependency "dry-configurable", "~> 0.13"
59
59
  spec.add_dependency "dry-files", "~> 0.1"
60
60
  spec.add_dependency "dry-initializer", "~> 3.0"
61
61
  spec.add_dependency "dry-struct", "~> 1.4"
62
- spec.add_dependency "dry-validation", "~> 1.6"
62
+ spec.add_dependency "dry-validation", "~> 1.7"
63
63
  spec.add_dependency "email_address", "~> 0.2"
64
64
  spec.add_dependency "hachi", "~> 1.0"
65
65
  spec.add_dependency "http", "~> 5.0"
@@ -76,7 +76,7 @@ Gem::Specification.new do |spec|
76
76
  spec.add_dependency "passivetotalx", "~> 0.1"
77
77
  spec.add_dependency "public_suffix", "~> 4.0"
78
78
  spec.add_dependency "pulsedive", "~> 0.1"
79
- spec.add_dependency "puma", "~> 5.4"
79
+ spec.add_dependency "puma", "~> 5.5"
80
80
  spec.add_dependency "rack", "~> 2.2"
81
81
  spec.add_dependency "rack-contrib", "~> 2.3"
82
82
  spec.add_dependency "safe_shell", "~> 1.1"
@@ -92,7 +92,7 @@ Gem::Specification.new do |spec|
92
92
  spec.add_dependency "thread_safe", "~> 0.3"
93
93
  spec.add_dependency "urlscan", "~> 0.7"
94
94
  spec.add_dependency "uuidtools", "~> 2.2"
95
- spec.add_dependency "virustotalx", "~> 1.1"
95
+ spec.add_dependency "virustotalx", "~> 1.2"
96
96
  spec.add_dependency "whois", "~> 5.0"
97
97
  spec.add_dependency "whois-parser", "~> 1.2"
98
98
  spec.add_dependency "zoomeye-rb", "~> 0.2"
@@ -1,5 +1,7 @@
1
1
  module Mihari
2
2
  module Analyzers
3
+ ANALYZER_TO_CLASS: Hash[String, singleton(Mihari::Analyzers::Base)]
4
+
3
5
  class Rule < Base
4
6
  include Mihari::Mixins::DisallowedDataValue
5
7
 
@@ -14,14 +16,12 @@ module Mihari
14
16
 
15
17
  def initialize: (**untyped kwargs) -> void
16
18
 
17
- ANALYZER_TO_CLASS: Hash[String, singleton(Mihari::Analyzers::Base)]
18
-
19
19
  #
20
20
  # Returns a list of artifacts matched with queries
21
21
  #
22
22
  # @return [Array<Mihari::Artifact>]
23
23
  #
24
- def artifacts: () -> (Array[String] | Array[Mihari::Artifact])
24
+ def artifacts: () -> (Array[Mihari::Artifact])
25
25
 
26
26
  #
27
27
  # Normalize artifacts
@@ -0,0 +1,32 @@
1
+ module Mihari
2
+ module Analyzers
3
+ class VirusTotalIntelligence < Base
4
+ attr_reader query: String
5
+ attr_reader title: String
6
+ attr_reader description: String
7
+ attr_reader tags: Array[String]
8
+
9
+ def initialize: (*untyped args, **untyped kwargs) -> void
10
+
11
+ def artifacts: () -> (Array[String] | Array[Mihari::Artifact])
12
+
13
+ private
14
+
15
+ def configuration_keys: () -> ::Array["virustotal_api_key"]
16
+
17
+ #
18
+ # VT API
19
+ #
20
+ # @return [::VirusTotal::API]
21
+ #
22
+ def api: () -> untyped
23
+
24
+ #
25
+ # Search with cursor
26
+ #
27
+ # @return [Array<Mihari::Structs::VirusTotalIntelligence::Response>]
28
+ #
29
+ def search_witgh_cursor: () -> Array[Mihari::Structs::VirusTotalIntelligence::Response]
30
+ end
31
+ end
32
+ end
@@ -7,40 +7,12 @@ module Mihari
7
7
  attr_accessor artifacts(): Array[Mihari::Artifact]
8
8
  attr_accessor Tags(): Array[Mihari::Tag]
9
9
 
10
- #
11
- # Search alerts
12
- #
13
- # @param [String, nil] artifact_data
14
- # @param [String, nil] description
15
- # @param [String, nil] source
16
- # @param [String, nil] tag_name
17
- # @param [String, nil] title
18
- # @param [DateTime, nil] from_at
19
- # @param [DateTime, nil] to_at
20
- # @param [Integer, nil] limit
21
- # @param [Integer, nil] page
22
- #
23
- # @return [Array<Hash>]
24
- #
25
- def self.search: (?artifact_data: String? artifact_data, ?description: String? description, ?source: String? source, ?tag_name: String? tag_name, ?title: String? title, ?from_at: DateTime? from_at, ?to_at: DateTime? to_at, ?limit: ::Integer limit, ?page: ::Integer page) -> Array[Hash[(String | Symbol), untyped]]
10
+ def self.search: (Mihari::Structs::Alert::SearchFilterWithPagination filter) -> Array[Hash[(String | Symbol), untyped]]
26
11
 
27
- #
28
- # Count alerts
29
- #
30
- # @param [String, nil] artifact_data
31
- # @param [String, nil] description
32
- # @param [String, nil] source
33
- # @param [String, nil] tag_name
34
- # @param [String, nil] title
35
- # @param [DateTime, nil] from_at
36
- # @param [DateTime, nil] to_at
37
- #
38
- # @return [Integer]
39
- #
40
- def self.count: (?artifact_data: String? artifact_data, ?description: String? description, ?source: String? source, ?tag_name: String? tag_name, ?title: String? title, ?from_at: DateTime? from_at, ?to_at: DateTime? to_at) -> Integer
12
+ def self.count: (Mihari::Structs::Alert::SearchFilter filter) -> Integer
41
13
 
42
14
  private
43
15
 
44
- def self.build_relation: (?artifact_data: String? artifact_data, ?title: String? title, ?description: String? description, ?source: String? source, ?tag_name: String? tag_name, ?from_at: DateTime? from_at, ?to_at: DateTime? to_at) -> Mihari::Alert
16
+ def self.build_relation: (Mihari::Structs::Alert::SearchFilter filter) -> Mihari::Alert
45
17
  end
46
18
  end
@@ -0,0 +1,27 @@
1
+ module Mihari
2
+ module Structs
3
+ module Alert
4
+ class SearchFilter
5
+ attr_reader artifact_data: String?
6
+ attr_reader description: String?
7
+ attr_reader source: String?
8
+ attr_reader tag_name: String?
9
+ attr_reader title: String?
10
+ attr_reader from_at: DateTime?
11
+ attr_reader to_at: DateTime?
12
+ attr_reader asn: Integer?
13
+ attr_reader dns_record: String?
14
+ attr_reader reverse_dns_name: String?
15
+
16
+ def has_valid_artifact_filters: () -> bool
17
+ end
18
+
19
+ class SearchFilterWithPagination
20
+ attr_reader page: Integer
21
+ attr_reader limit: Integer
22
+
23
+ def without_pagination: () -> Mihari::Structs::Alert::SearchFilter
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,33 @@
1
+ module Mihari
2
+ module Structs
3
+ module VirusTotalIntelligence
4
+ class ContextAttributes
5
+ attr_reader url: Array[String]?
6
+
7
+ def self.from_dynamic!: (Hash[(String | Symbol), untyped] d) -> Mihari::Structs::VirusTotalIntelligence::ContextAttributes
8
+ end
9
+
10
+ class Datum
11
+ attr_reader type: String
12
+ attr_reader context_attributes: Mihari::Structs::VirusTotalIntelligence::ContextAttributes?
13
+
14
+ def value: () -> String?
15
+
16
+ def self.from_dynamic!: (Hash[(String | Symbol), untyped] d) -> Mihari::Structs::VirusTotalIntelligence::Datum
17
+ end
18
+
19
+ class Meta
20
+ attr_reader cursor: String?
21
+
22
+ def self.from_dynamic!: (Hash[(String | Symbol), untyped] d) -> Mihari::Structs::VirusTotalIntelligence::Meta
23
+ end
24
+
25
+ class Response
26
+ attr_reader meta: Mihari::Structs::VirusTotalIntelligence::Meta
27
+ attr_reader data: Array[Mihari::Structs::VirusTotalIntelligence::Datum]
28
+
29
+ def self.from_dynamic!: (Hash[(String | Symbol), untyped] d) -> Mihari::Structs::VirusTotalIntelligence::Response
30
+ end
31
+ end
32
+ end
33
+ end
@@ -1,5 +1,5 @@
1
1
  module Mihari
2
2
  class App # < Sinatra::Base
3
- def self.run!: (?port: ::Integer port, ?host: ::String host) -> void
3
+ def self.run!: (?port: ::Integer port, ?host: ::String host, ?threads: ::String threads, ?verbose: bool verbose) -> void
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mihari
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.7.1
4
+ version: 3.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Manabu Niseki
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-09-04 00:00:00.000000000 Z
11
+ date: 2021-09-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0.22'
33
+ version: '0.23'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '0.22'
40
+ version: '0.23'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: fakefs
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -422,14 +422,14 @@ dependencies:
422
422
  requirements:
423
423
  - - "~>"
424
424
  - !ruby/object:Gem::Version
425
- version: '0.12'
425
+ version: '0.13'
426
426
  type: :runtime
427
427
  prerelease: false
428
428
  version_requirements: !ruby/object:Gem::Requirement
429
429
  requirements:
430
430
  - - "~>"
431
431
  - !ruby/object:Gem::Version
432
- version: '0.12'
432
+ version: '0.13'
433
433
  - !ruby/object:Gem::Dependency
434
434
  name: dry-files
435
435
  requirement: !ruby/object:Gem::Requirement
@@ -478,14 +478,14 @@ dependencies:
478
478
  requirements:
479
479
  - - "~>"
480
480
  - !ruby/object:Gem::Version
481
- version: '1.6'
481
+ version: '1.7'
482
482
  type: :runtime
483
483
  prerelease: false
484
484
  version_requirements: !ruby/object:Gem::Requirement
485
485
  requirements:
486
486
  - - "~>"
487
487
  - !ruby/object:Gem::Version
488
- version: '1.6'
488
+ version: '1.7'
489
489
  - !ruby/object:Gem::Dependency
490
490
  name: email_address
491
491
  requirement: !ruby/object:Gem::Requirement
@@ -716,14 +716,14 @@ dependencies:
716
716
  requirements:
717
717
  - - "~>"
718
718
  - !ruby/object:Gem::Version
719
- version: '5.4'
719
+ version: '5.5'
720
720
  type: :runtime
721
721
  prerelease: false
722
722
  version_requirements: !ruby/object:Gem::Requirement
723
723
  requirements:
724
724
  - - "~>"
725
725
  - !ruby/object:Gem::Version
726
- version: '5.4'
726
+ version: '5.5'
727
727
  - !ruby/object:Gem::Dependency
728
728
  name: rack
729
729
  requirement: !ruby/object:Gem::Requirement
@@ -940,14 +940,14 @@ dependencies:
940
940
  requirements:
941
941
  - - "~>"
942
942
  - !ruby/object:Gem::Version
943
- version: '1.1'
943
+ version: '1.2'
944
944
  type: :runtime
945
945
  prerelease: false
946
946
  version_requirements: !ruby/object:Gem::Requirement
947
947
  requirements:
948
948
  - - "~>"
949
949
  - !ruby/object:Gem::Version
950
- version: '1.1'
950
+ version: '1.2'
951
951
  - !ruby/object:Gem::Dependency
952
952
  name: whois
953
953
  requirement: !ruby/object:Gem::Requirement
@@ -1046,6 +1046,7 @@ files:
1046
1046
  - lib/mihari/analyzers/spyse.rb
1047
1047
  - lib/mihari/analyzers/urlscan.rb
1048
1048
  - lib/mihari/analyzers/virustotal.rb
1049
+ - lib/mihari/analyzers/virustotal_intelligence.rb
1049
1050
  - lib/mihari/analyzers/zoomeye.rb
1050
1051
  - lib/mihari/cli/analyzer.rb
1051
1052
  - lib/mihari/cli/base.rb
@@ -1072,6 +1073,7 @@ files:
1072
1073
  - lib/mihari/commands/urlscan.rb
1073
1074
  - lib/mihari/commands/validator.rb
1074
1075
  - lib/mihari/commands/virustotal.rb
1076
+ - lib/mihari/commands/virustotal_intelligence.rb
1075
1077
  - lib/mihari/commands/web.rb
1076
1078
  - lib/mihari/commands/zoomeye.rb
1077
1079
  - lib/mihari/constants.rb
@@ -1119,10 +1121,12 @@ files:
1119
1121
  - lib/mihari/serializers/tag.rb
1120
1122
  - lib/mihari/serializers/whois.rb
1121
1123
  - lib/mihari/status.rb
1124
+ - lib/mihari/structs/alert.rb
1122
1125
  - lib/mihari/structs/censys.rb
1123
1126
  - lib/mihari/structs/ipinfo.rb
1124
1127
  - lib/mihari/structs/onyphe.rb
1125
1128
  - lib/mihari/structs/shodan.rb
1129
+ - lib/mihari/structs/virustotal_intelligence.rb
1126
1130
  - lib/mihari/templates/rule.yml.erb
1127
1131
  - lib/mihari/type_checker.rb
1128
1132
  - lib/mihari/types.rb
@@ -1175,8 +1179,12 @@ files:
1175
1179
  - lib/mihari/web/public/static/js/app.06d5cf1c.js.map
1176
1180
  - lib/mihari/web/public/static/js/app.365f1907.js
1177
1181
  - lib/mihari/web/public/static/js/app.365f1907.js.map
1182
+ - lib/mihari/web/public/static/js/app.378da3dc.js
1183
+ - lib/mihari/web/public/static/js/app.378da3dc.js.map
1178
1184
  - lib/mihari/web/public/static/js/app.8e3e5150.js
1179
1185
  - lib/mihari/web/public/static/js/app.8e3e5150.js.map
1186
+ - lib/mihari/web/public/static/js/app.a862ebca.js
1187
+ - lib/mihari/web/public/static/js/app.a862ebca.js.map
1180
1188
  - lib/mihari/web/public/static/js/app.ab213f7c.js
1181
1189
  - lib/mihari/web/public/static/js/app.ab213f7c.js.map
1182
1190
  - lib/mihari/web/public/static/js/app.b5914c39.js
@@ -1204,6 +1212,7 @@ files:
1204
1212
  - sig/lib/mihari/analyzers/spyse.rbs
1205
1213
  - sig/lib/mihari/analyzers/urlscan.rbs
1206
1214
  - sig/lib/mihari/analyzers/virustotal.rbs
1215
+ - sig/lib/mihari/analyzers/virustotal_intelligence.rbs
1207
1216
  - sig/lib/mihari/analyzers/zoomeye.rbs
1208
1217
  - sig/lib/mihari/cli/analyzer.rbs
1209
1218
  - sig/lib/mihari/cli/base.rbs
@@ -1265,10 +1274,12 @@ files:
1265
1274
  - sig/lib/mihari/notifiers/exception_notifier.rbs
1266
1275
  - sig/lib/mihari/notifiers/slack.rbs
1267
1276
  - sig/lib/mihari/status.rbs
1277
+ - sig/lib/mihari/structs/alert.rbs
1268
1278
  - sig/lib/mihari/structs/censys.rbs
1269
1279
  - sig/lib/mihari/structs/ipinfo.rbs
1270
1280
  - sig/lib/mihari/structs/onyphe.rbs
1271
1281
  - sig/lib/mihari/structs/shodan.rbs
1282
+ - sig/lib/mihari/structs/virustotal_intelligence.rbs
1272
1283
  - sig/lib/mihari/type_checker.rbs
1273
1284
  - sig/lib/mihari/types.rbs
1274
1285
  - sig/lib/mihari/version.rbs