Skip to content

cleaner fix delete from db#2573

Merged
doomedraven merged 7 commits into
masterfrom
cleaner_proper_delete_from_db
Apr 25, 2025
Merged

cleaner fix delete from db#2573
doomedraven merged 7 commits into
masterfrom
cleaner_proper_delete_from_db

Conversation

@doomedraven
Copy link
Copy Markdown
Collaborator

No description provided.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @doomedraven, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

Summary of Changes

This pull request focuses on cleaning up the database deletion process within the Cuckoo analysis framework. It introduces a dedicated delete_tasks function in lib/cuckoo/core/database.py to handle task deletions based on various criteria, and replaces direct calls to db.list_tasks with db.delete_tasks in lib/cuckoo/common/cleaners_utils.py. This change aims to provide a more streamlined and maintainable approach to removing tasks from the database.

Highlights

  • Database Deletion Function: A new delete_tasks function is added to lib/cuckoo/core/database.py to centralize and simplify task deletion logic.
  • Replacement of list_tasks with delete_tasks: Instances of db.list_tasks with the delete=True parameter in lib/cuckoo/common/cleaners_utils.py are replaced with calls to the new db.delete_tasks function.
  • Parameter Adjustment in delete_bulk_tasks_n_folders: The cuckoo_clean_lower_score function now calls delete_bulk_tasks_n_folders with the delete_db_tasks=True parameter.
  • Test Update: The test test_delete_tasks in tests/test_database.py is updated to use the task_ids parameter.

Changelog

Click here to see the changelog
  • lib/cuckoo/common/cleaners_utils.py
    • Replaced db.list_tasks(delete=True) with db.delete_tasks in cuckoo_clean_failed_tasks, cuckoo_clean_before, cuckoo_clean_pending_tasks, and cuckoo_clean_range_tasks.
    • Added delete_db_tasks=True to the delete_bulk_tasks_n_folders call within cuckoo_clean_lower_score.
    • Removed an extraneous comma in the imports.
  • lib/cuckoo/core/database.py
    • Removed the delete parameter from the list_tasks function.
    • Added a new delete_tasks function to handle task deletions based on various criteria.
    • Added a new delete_task function to delete a single task by ID.
    • Removed the delete_tasks function that took a list of IDs as input.
  • tests/test_database.py
    • Updated the test_delete_tasks test case to use the task_ids parameter when calling db.delete_tasks.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.


A cleaner database,
A task deleted with grace,
Code's clarity shines.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

The pull request aims to improve the task deletion process by introducing a dedicated delete_tasks function in lib/cuckoo/core/database.py and utilizing it across various cleaner utilities. This change streamlines the code and enhances maintainability by centralizing the task deletion logic. The changes look good overall, but I have a few suggestions for improvement.

Summary of Findings

  • Duplication of logic in delete_tasks: The delete_tasks function in lib/cuckoo/core/database.py mirrors much of the filtering logic present in the list_tasks function. This duplication could lead to inconsistencies and increased maintenance overhead. Consider refactoring to reuse the filtering logic.
  • Missing error handling in delete_bulk_tasks_n_folders: The delete_bulk_tasks_n_folders function in lib/cuckoo/common/cleaners_utils.py iterates through task IDs and attempts to delete corresponding folders. However, it lacks specific error handling for database deletion failures, potentially leaving orphaned data in the database.

Merge Readiness

The pull request introduces significant improvements to the task deletion process. However, addressing the duplicated filtering logic in delete_tasks and incorporating more robust error handling in delete_bulk_tasks_n_folders would further enhance the code's quality and reliability. I am unable to directly approve this pull request, and recommend that others review and approve this code before merging. Given the medium severity issues identified, I recommend addressing them before merging.

Comment thread lib/cuckoo/common/cleaners_utils.py
Comment thread lib/cuckoo/core/database.py Outdated
Comment thread lib/cuckoo/core/database.py Outdated
@doomedraven doomedraven merged commit 7523adf into master Apr 25, 2025
5 of 6 checks passed
@doomedraven doomedraven deleted the cleaner_proper_delete_from_db branch April 25, 2025 13:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant