mihari 5.2.4 → 5.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +4 -1
- data/README.md +0 -10
- data/Rakefile +7 -1
- data/build_frontend.sh +1 -1
- data/frontend/.eslintrc.cjs +22 -0
- data/frontend/.gitignore +18 -12
- data/frontend/.prettierrc.json +8 -0
- data/frontend/env.d.ts +5 -0
- data/frontend/package-lock.json +5095 -9661
- data/frontend/package.json +34 -24
- data/frontend/src/App.vue +5 -5
- data/frontend/src/api-helper.ts +38 -40
- data/frontend/src/api.ts +40 -40
- data/frontend/src/components/ErrorMessage.vue +8 -8
- data/frontend/src/components/Loading.vue +3 -3
- data/frontend/src/components/Navbar.vue +10 -27
- data/frontend/src/components/Pagination.vue +35 -42
- data/frontend/src/components/alert/Alert.vue +21 -26
- data/frontend/src/components/alert/Alerts.vue +23 -25
- data/frontend/src/components/alert/AlertsWithPagination.vue +34 -34
- data/frontend/src/components/alert/AlertsWrapper.vue +42 -49
- data/frontend/src/components/alert/Form.vue +39 -40
- data/frontend/src/components/artifact/AS.vue +7 -7
- data/frontend/src/components/artifact/Artifact.vue +66 -83
- data/frontend/src/components/artifact/ArtifactTag.vue +21 -27
- data/frontend/src/components/artifact/ArtifactTags.vue +8 -8
- data/frontend/src/components/artifact/ArtifactWrapper.vue +22 -25
- data/frontend/src/components/artifact/CPEs.vue +6 -6
- data/frontend/src/components/artifact/DnsRecords.vue +9 -9
- data/frontend/src/components/artifact/Ports.vue +6 -6
- data/frontend/src/components/artifact/ReverseDnsNames.vue +7 -7
- data/frontend/src/components/artifact/Tags.vue +6 -6
- data/frontend/src/components/artifact/WhoisRecord.vue +7 -9
- data/frontend/src/components/config/Configs.vue +7 -10
- data/frontend/src/components/config/ConfigsWrapper.vue +14 -20
- data/frontend/src/components/link/Link.vue +7 -7
- data/frontend/src/components/link/Links.vue +16 -21
- data/frontend/src/components/rule/EditRule.vue +22 -22
- data/frontend/src/components/rule/EditRuleWrapper.vue +22 -28
- data/frontend/src/components/rule/Form.vue +28 -28
- data/frontend/src/components/rule/InputForm.vue +31 -25
- data/frontend/src/components/rule/NewRule.vue +18 -18
- data/frontend/src/components/rule/Rule.vue +25 -27
- data/frontend/src/components/rule/RuleWrapper.vue +24 -31
- data/frontend/src/components/rule/Rules.vue +26 -30
- data/frontend/src/components/rule/RulesWrapper.vue +39 -42
- data/frontend/src/components/rule/YAML.vue +19 -22
- data/frontend/src/components/tag/Tag.vue +24 -32
- data/frontend/src/components/tag/Tags.vue +11 -11
- data/frontend/src/countries.ts +23 -23
- data/frontend/src/index.ts +9 -12
- data/frontend/src/links/anyrun.ts +10 -10
- data/frontend/src/links/base.ts +3 -3
- data/frontend/src/links/censys.ts +10 -10
- data/frontend/src/links/crtsh.ts +10 -10
- data/frontend/src/links/dnslytics.ts +18 -18
- data/frontend/src/links/greynoise.ts +10 -10
- data/frontend/src/links/index.ts +15 -15
- data/frontend/src/links/intezer.ts +10 -10
- data/frontend/src/links/otx.ts +14 -14
- data/frontend/src/links/securitytrails.ts +15 -15
- data/frontend/src/links/shodan.ts +10 -10
- data/frontend/src/links/urlscan.ts +19 -19
- data/frontend/src/links/virustotal.ts +27 -27
- data/frontend/src/main.ts +8 -8
- data/frontend/src/router/index.ts +20 -20
- data/frontend/src/rule.ts +6 -6
- data/frontend/src/shims-vue.d.ts +2 -2
- data/frontend/src/types.ts +91 -91
- data/frontend/src/utils.ts +23 -29
- data/frontend/src/views/Alerts.vue +7 -7
- data/frontend/src/views/Artifact.vue +17 -17
- data/frontend/src/views/Configs.vue +7 -7
- data/frontend/src/views/EditRule.vue +17 -17
- data/frontend/src/views/NewRule.vue +10 -10
- data/frontend/src/views/Rule.vue +17 -17
- data/frontend/src/views/Rules.vue +7 -7
- data/frontend/tests/utils.spec.ts +9 -0
- data/frontend/tsconfig.app.json +21 -0
- data/frontend/tsconfig.json +10 -36
- data/frontend/tsconfig.node.json +13 -0
- data/frontend/tsconfig.vitest.json +12 -0
- data/frontend/vite.config.ts +24 -0
- data/frontend/vitest.config.ts +21 -0
- data/lefthook.yml +4 -2
- data/lib/mihari/analyzers/base.rb +48 -14
- data/lib/mihari/analyzers/binaryedge.rb +10 -15
- data/lib/mihari/analyzers/censys.rb +12 -15
- data/lib/mihari/analyzers/circl.rb +10 -10
- data/lib/mihari/analyzers/crtsh.rb +10 -6
- data/lib/mihari/analyzers/dnstwister.rb +6 -8
- data/lib/mihari/analyzers/feed.rb +21 -10
- data/lib/mihari/analyzers/greynoise.rb +10 -20
- data/lib/mihari/analyzers/onyphe.rb +9 -14
- data/lib/mihari/analyzers/otx.rb +8 -9
- data/lib/mihari/analyzers/passivetotal.rb +10 -10
- data/lib/mihari/analyzers/pulsedive.rb +21 -31
- data/lib/mihari/analyzers/securitytrails.rb +8 -6
- data/lib/mihari/analyzers/shodan.rb +8 -13
- data/lib/mihari/analyzers/urlscan.rb +15 -20
- data/lib/mihari/analyzers/virustotal.rb +16 -26
- data/lib/mihari/analyzers/virustotal_intelligence.rb +11 -17
- data/lib/mihari/analyzers/zoomeye.rb +12 -17
- data/lib/mihari/config.rb +133 -0
- data/lib/mihari/constants.rb +3 -0
- data/lib/mihari/emitters/slack.rb +13 -3
- data/lib/mihari/errors.rb +1 -1
- data/lib/mihari/http.rb +2 -3
- data/lib/mihari/schemas/analyzer.rb +2 -0
- data/lib/mihari/type_checker.rb +6 -6
- data/lib/mihari/version.rb +1 -1
- data/lib/mihari/web/endpoints/configs.rb +5 -1
- data/lib/mihari/web/public/assets/{index-eed1bcd8.css → index-2ba8f0a6.css} +1 -1
- data/lib/mihari/web/public/assets/{index-ac4e5ffa.js → index-71285b15.js} +16 -16
- data/lib/mihari/web/public/index.html +2 -2
- data/lib/mihari/web/public/redoc-static.html +388 -2193
- data/lib/mihari.rb +9 -59
- data/mihari.gemspec +8 -8
- metadata +24 -62
- data/frontend/.browserslistrc +0 -3
- data/frontend/.eslintrc.js +0 -33
- data/frontend/babel.config.js +0 -3
- data/frontend/jest.config.js +0 -9
- data/frontend/tests/unit/utils.spec.ts +0 -7
- 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
|
data/lib/mihari/constants.rb
CHANGED
@@ -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
|
-
|
11
|
+
# @return [String]
|
12
|
+
attr_reader :data
|
13
|
+
|
14
|
+
# @return [String]
|
15
|
+
attr_reader :data_type
|
12
16
|
|
13
|
-
|
14
|
-
|
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
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
|
-
|
97
|
-
|
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
|
data/lib/mihari/type_checker.rb
CHANGED
@@ -2,13 +2,13 @@
|
|
2
2
|
|
3
3
|
module Mihari
|
4
4
|
class TypeChecker
|
5
|
-
|
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
|
data/lib/mihari/version.rb
CHANGED
@@ -10,7 +10,11 @@ module Mihari
|
|
10
10
|
summary: "Get configs"
|
11
11
|
}
|
12
12
|
get "/" do
|
13
|
-
|
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
|