Skip to content

Commit

Permalink
Land #18833, fix for issue #18561
Browse files Browse the repository at this point in the history
This PR catches an exception when updating a non-existing session.
Prior to this PR trying to run sessions -k after running workspace -D
would result in a stacktrace being printed to the console.
  • Loading branch information
jheysel-r7 committed Feb 23, 2024
2 parents 7c000bc + b6b382c commit 03e5b36
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/msf/core/session.rb
Original file line number Diff line number Diff line change
Expand Up @@ -227,10 +227,11 @@ def via_payload
#
def cleanup
if db_record and framework.db.active
::ApplicationRecord.connection_pool.with_connection {
::ApplicationRecord.connection_pool.with_connection do
framework.db.update_session(id: db_record.id, closed_at: Time.now.utc, close_reason: db_record.close_reason)
db_record = nil
}
rescue ActiveRecord::RecordNotFound
nil # this will fail if the workspace was deleted before the session was closed, see #18561
end
end
end

Expand Down

0 comments on commit 03e5b36

Please sign in to comment.