fix: handle ActiveRecord::RecordInvalid in ssh_creds when workspace is reset#21536
fix: handle ActiveRecord::RecordInvalid in ssh_creds when workspace is reset#215364ravind-b wants to merge 1 commit into
Conversation
|
Verified on Metasploitable2. Before this fix: Running the module after deleting the workspace with After this fix: The module no longer crashes. Instead, it prints a warning when credential storage fails and continues processing the remaining files. All SSH files are successfully downloaded, post-module execution completes normally, and the session remains active. |
|
@smcintyre-r7 the fix stops the crash and file downloads complete successfully, but credentials aren't saved to the DB in this scenario since the session record is gone. Is rescuing the exception and warning the user acceptable here, or would you prefer we attempt to save credentials to the current workspace as a fallback? |
Fixes #21480
When
workspace -Dis run while a session is active, the session'sdatabase record gets deleted but the session itself stays alive. When
post/multi/gather/ssh_credstries to save credentials, it fails withActiveRecord::RecordInvalid: Session can't be blankand crashes the module.This fix adds a rescue for
ActiveRecord::RecordInvalidso the moduleprints a warning and continues instead of crashing.
Verification
post/multi/gather/ssh_creds— works fineworkspace -Dpost/multi/gather/ssh_credsagain