Raise exception in process_opts_workspace for more meaningful error messages #11059
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The
Msf::Util::DBManager.process_opts_workspace
method is heavily used in variousDBManager
models to get the workspace that is then used for subsequent queries. This modifies the method to raise an exception if the workspace is not found, thus allowing for a more meaningful error to make it back to the user.Ticket: MS-3225
Example: Current
Example: Fixed
Verification
msfdb restart
, and init/reinit if necessary.curl --insecure -H "Accept: application/json" -H "Authorization: Bearer <token>" https://localhost:8080/api/v1/hosts?workspace=DNE | python -m json.tool
whereDNE
is the name of a workspace that doesn't exist in your database.msfconsole
and connect to the data service started above if you didn't select the option to connect automatically during initialization. See Metasploit Web Service for more information.db_status
reportsConnection type: http. Connected to remote_data_service: (https://localhost:8080)
hosts
,services
,vulns
,creds
,loots
,notes
)