CAPEv2 icon indicating copy to clipboard operation
CAPEv2 copied to clipboard

scheduler.py never reaches the cleaner code

Open ClaudioWayne opened this issue 1 year ago • 0 comments

About accounts on capesandbox.com

  • Issues isn't the way to ask for account activation. Ping capesandbox in Twitter with your username

This is open source and you are getting free support so be friendly!

Prerequisites

Please answer the following questions for yourself before submitting an issue.

  • [X] I am running the latest version
  • [X] I did read the README!
  • [X] I checked the documentation and found no answer
  • [X] I checked to make sure that this issue has not already been filed
  • [X] I'm reporting the issue to the correct repository (for multi-repository projects)
  • [X] I have read and checked all configs (with all optional parts)

Expected Behavior

Invoke cleanup if <= of free space detected

Current Behavior

I am trying to make use of the free-space-monitor and the new cleaner function that you can configure in cooko.conf. It doesn't work properly for me, I think scheduler.py never reaches the cleaner code because the parameter return_value=True is passed when the method is called. https://github.com/kevoreilly/CAPEv2/blob/a9d80fd990d6fd7c1b2caced4175e316c1b01a9f/lib/cuckoo/core/scheduler.py#L245 So cleaners_utils.py returns always before execute_cleanup()

    if return_value:
        return need_space, space_available

    if need_space:
        if not printed_error:
            log.error(
                "Not enough free disk space! (Only %d MB!). You can change limits it in cuckoo.conf -> freespace",
                space_available,
            )
            printed_error = True

        # Invoke cleaups here if enabled
        if config.cleaner.enabled:
            # prepare dict on startup
            execute_cleanup(cleanup_dict)

free_space_monitor is also used in process.py but without without return_value. So i tried to set freespace_processing = 50000 and freespace = 0 to skip the check in scheduler.py. https://github.com/kevoreilly/CAPEv2/blob/a9d80fd990d6fd7c1b2caced4175e316c1b01a9f/utils/process.py#L315 But proccess.py checks cfg.cuckoo.freespace. I would expect a check for cfg.cuckoo.freespace_processing?! https://github.com/kevoreilly/CAPEv2/blob/a9d80fd990d6fd7c1b2caced4175e316c1b01a9f/utils/process.py#L311

Failure Information (for bugs)

Please help provide information about the failure if this is a bug. If it is not a bug, please remove the rest of this template.

Steps to Reproduce

configure cleaner and freespace/freespace_processing in cuckoo.conf

[cleaner]
# Invoke cleanup if <= of free space detected. see/set freespace/freespace_processing
enabled = yes
# set any value to 0 to disable it. In days
binaries_days = 30
tmp_days = 1
# Remove analysis folder
analysis_days = 30
# Delete mongo data
mongo = no
# Clean orphan files in mongodb
unused_files_in_mongodb = no

start cuckoo.py

Context

Please provide any relevant information about your setup. This is important in case the issue is not reproducible except for under certain conditions. Operating system version, bitness, installed software versions, test sample details/hash/binary (if applicable).

Question Answer
Git commit ba39c0c7b5da71a83073bd6bc3dc2d0cfc956fe0
OS version Ubuntu 22.04, Windows 10 21H2

Failure Logs

Please include any relevant log snippets or files here.

ClaudioWayne avatar Sep 16 '24 09:09 ClaudioWayne