Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed to delete hashlist containing cracked hashes while agent is running on the hashlist #789

Merged
merged 3 commits into from
Jun 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
- Fixed sending two to headers when sending emails (issue #751).
- Fixed access group not being changed on Hashlist detailed screen (issue #765).
- Fixed missing check on permissions for sending notifications (issue #757).
- Fixed not deleting all references (related to zaps) when deleting hashlist (issue #747).

## Enhancements

Expand Down
13 changes: 10 additions & 3 deletions src/inc/utils/HashlistUtils.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
use DBA\Chunk;
use DBA\AgentError;
use DBA\Zap;
use DBA\AgentZap;
use DBA\Factory;
use DBA\Speed;

Expand Down Expand Up @@ -507,14 +508,20 @@ public static function delete($hashlistId, $user) {
$toDelete[] = $superHashlist;
}
}
Factory::getHashlistHashlistFactory()->massDeletion([Factory::FILTER => $qF]);


// when we delete all zaps, we have to make sure that from agentZap, there are no references to zaps of this hashlist
$qF = new QueryFilter(Zap::HASHLIST_ID, $hashlist->getId(), "=");
$zapIds = Util::arrayOfIds(Factory::getZapFactory()->filter([Factory::FILTER => $qF]));
$qF1 = new ContainFilter(AgentZap::LAST_ZAP_ID, $zapIds);
$uS = new UpdateSet(AgentZap::LAST_ZAP_ID, null);
Factory::getAgentZapFactory()->massUpdate([Factory::UPDATE => $uS, Factory::FILTER => $qF1]);
Factory::getZapFactory()->massDeletion([Factory::FILTER => $qF]);

Factory::getHashlistHashlistFactory()->massDeletion([Factory::FILTER => $qF]);

$payload = new DataSet(array(DPayloadKeys::HASHLIST => $hashlist));
NotificationHandler::checkNotifications(DNotificationType::DELETE_HASHLIST, $payload);

$qF = new QueryFilter(NotificationSetting::OBJECT_ID, $hashlist->getId(), "=");
$notifications = Factory::getNotificationSettingFactory()->filter([Factory::FILTER => $qF]);
foreach ($notifications as $notification) {
Expand Down