forked from rapid7/metasploit-framework
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4082ef2
commit 7fe97cf
Showing
10 changed files
with
176 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -148,4 +148,4 @@ def post_process_result(result, method, params) | |
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# -*- coding: binary -*- | ||
module Msf | ||
module RPC | ||
class Health | ||
|
||
# Returns whether the framework object is currently healthy and ready to accept | ||
# requests | ||
# | ||
# @return [Hash] | ||
# | ||
def self.check(framework) | ||
# A couple of rudimentary checks to ensure that nothing breaks when interacting | ||
# with framework object | ||
is_healthy = ( | ||
!framework.version.to_s.empty? && | ||
# Ensure that the db method can be invoked and returns a truthy value as | ||
# the rpc clients interact with framework's database object which raises can | ||
# raise an exception | ||
framework.db | ||
) | ||
|
||
unless is_healthy | ||
return { status: 'DOWN' } | ||
end | ||
|
||
{ status: 'UP' } | ||
rescue => e | ||
elog('Health status failing', error: e) | ||
|
||
{ status: 'DOWN' } | ||
end | ||
|
||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# -*- coding: binary -*- | ||
module Msf | ||
module RPC | ||
class RPC_Health < RPC_Base | ||
|
||
# Returns whether the service is currently healthy and ready to accept | ||
# requests. This endpoint is not authenticated. | ||
# | ||
# @return [Hash] | ||
# @example Here's how you would use this from the client: | ||
# rpc.call('health.check') | ||
def rpc_check_noauth | ||
Msf::RPC::Health.check(framework) | ||
end | ||
|
||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
module Msf::WebServices::HealthServlet | ||
|
||
def self.api_path | ||
'/api/v1/health' | ||
end | ||
|
||
def self.registered(app) | ||
app.get self.api_path, &health_check | ||
end | ||
|
||
####### | ||
private | ||
####### | ||
|
||
def self.health_check | ||
lambda { | ||
health_check = Msf::RPC::Health.check(framework) | ||
is_success = health_check[:status] == 'UP' | ||
set_json_data_response(response: health_check, code: is_success ? 200 : 503) | ||
} | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters