I want to share about the step of troubleshooting ZipScanner:isZip() error in aibolit-resident service. The error that i found is like this:

    Fatal error: Uncaught TypeError: Argument 1 passed to ZipScanner::isZip() must be of the type string, null given, called in /opt/ai-bolit/ai-bolit-hoster.php on line 5221 and defined in /opt/ai-bolit/ai-bolit-hoster.php:10681
    Stack trace:
    #0 /opt/ai-bolit/ai-bolit-hoster.php(5221): ZipScanner::isZip(NULL)
    #1 /opt/ai-bolit/ai-bolit-hoster.php(5269): ResidentMode->scanJob('/var/imunify360...', 'upload')
    #2 /opt/ai-bolit/ai-bolit-hoster.php(5337): ResidentMode->scanUploadJob()
    #3 /opt/ai-bolit/ai-bolit-hoster.php(5015): ResidentMode->lifeCycle()
    #4 /opt/ai-bolit/ai-bolit-hoster.php(29862): ResidentMode->__construct(Object(Finder), Object(DebugMode), Object(Closure), Object(LoadSignaturesForScan), Object(Logger), Array, Object(ImLicense))
    #5 /opt/ai-bolit/ai-bolit-hoster.php(1114): Factory->create('ResidentMode', Array)
    #6 {main}
    thrown in /opt/ai-bolit/ai-bolit-hoster.php on line 10681

I got this information after i executed the command from ExecStart of aibolit-resident service. I tried to trace by using ltrace and strace but i didn't find some clue that can help me to solve this problem so i trace it in hard way by doing static analysis the ai-bolit-hoster.php script.

First, I need to look in /opt/ai-bolit/ai-bolit-hoster.php on line 5221 were ZipScanner::isZip() is called, then I found this code:

        if (isset($this->options['scan-archive']) && $type === self::JOB_UPLOAD && ZipScanner::isZip($files_to_scan[0])) {

There is two clue that I found which are self:JOB_UPLOAD and ZipScanner::isZip($files_to_scan[0]). Then I need to trace where $files_to_scan is defined and I found this code:

        $files_to_scan = [];
        $count = 0;

        $job = json_decode(file_get_contents($job_file));
        $file = AibolitHelpers::getBaseName($job_file);

        $this->debugLog("Job {$file} received from queue.");

        array_walk($job->files, static function(&$item) {
            $item = base64_decode($item);
        });

        $files_to_scan = $job->files;

        $count = count($files_to_scan);

I found that $files_to_scan is assigned with the value of $job->$files. Then I also found that $job is asigned by the value of json_decode(file_get_contents($job_file)). Then I need to trace where $job_file is defined. And I found this code:

    protected function scanJob($job_file, $type)
    {
        $start_time = AibolitHelpers::currentTime();

        $vars = new Variables();
        if ($type === self::JOB_NOTIFY) {
            $this->finder->getFilter()->setSkipSystemOwner(isset($this->options['skip-system-owner']));
        } else {
            $this->finder->getFilter()->setSkipSystemOwner(false);
        }
        $vars->signs = $this->signs;
        $vars->users = new UserList();
        $vars->options = $this->options;

        $files_to_scan = [];
        $count = 0;

        $job = json_decode(file_get_contents($job_file));
        $file = AibolitHelpers::getBaseName($job_file);

That is the most top definition of job_file that I can found. Based on that I know that job_file is related to file that contains job of aibolit-resident. So I concluded that the error is caused by the corrupted aibolit job file. At next step, I need to find where this job file is located.

Because this aibolit-resident is from imunify360, so the jobs is located in /var/imunify360/aibolit/resident/in/notify-jobs and /var/imunify360/aibolit/resident/in/upload-jobs. The next step that need to be done is stopping all service related to imunify360 and aibolit-resident. Then I need to delete all the job file inside those directories. After that i can start all imunify360 service and aibolit-resident service again. Then voila the service runs normally again.

ā— aibolit-resident.service - AibolitResident
   Loaded: loaded (/usr/lib/systemd/system/aibolit-resident.service; enabled; vendor preset: dis>
   Active: active (running) since Tue 2023-12-19 16:16:09 WIB; 2h 17min ago
 Main PID: 1672833 (wrapper)
    Tasks: 9 (limit: 408076)
   Memory: 82.0M
   CGroup: /system.slice/aibolit-resident.service

That is all that i can share, I hope this information is useful for you.%
nizarakbarmeilani@Nizars-MacBook-Air aibolit-error-zipscanner-iszip-null % cat item.md | gep png zsh: command not found: gep nizarakbarmeilani@Nizars-MacBook-Air aibolit-error-zipscanner-iszip-null % cat item.md | grep png nizarakbarmeilani@Nizars-MacBook-Air aibolit-error-zipscanner-iszip-null % nizarakbarmeilani@Nizars-MacBook-Air aibolit-error-zipscanner-iszip-null % cat item.md

title: aibolit-resident Error ZipScanner::isZip() Null date: '21:20 12/19/2023' author: 'Nizar Akbar M' taxonomy: category:

  • troubleshooting tag:
  • imunify360

I want to share about the step of troubleshooting ZipScanner:isZip() error in aibolit-resident service. The error that i found is like this:

    Fatal error: Uncaught TypeError: Argument 1 passed to ZipScanner::isZip() must be of the type string, null given, called in /opt/ai-bolit/ai-bolit-hoster.php on line 5221 and defined in /opt/ai-bolit/ai-bolit-hoster.php:10681
    Stack trace:
    #0 /opt/ai-bolit/ai-bolit-hoster.php(5221): ZipScanner::isZip(NULL)
    #1 /opt/ai-bolit/ai-bolit-hoster.php(5269): ResidentMode->scanJob('/var/imunify360...', 'upload')
    #2 /opt/ai-bolit/ai-bolit-hoster.php(5337): ResidentMode->scanUploadJob()
    #3 /opt/ai-bolit/ai-bolit-hoster.php(5015): ResidentMode->lifeCycle()
    #4 /opt/ai-bolit/ai-bolit-hoster.php(29862): ResidentMode->__construct(Object(Finder), Object(DebugMode), Object(Closure), Object(LoadSignaturesForScan), Object(Logger), Array, Object(ImLicense))
    #5 /opt/ai-bolit/ai-bolit-hoster.php(1114): Factory->create('ResidentMode', Array)
    #6 {main}
    thrown in /opt/ai-bolit/ai-bolit-hoster.php on line 10681

I got this information after i executed the command from ExecStart of aibolit-resident service. I tried to trace by using ltrace and strace but i didn't find some clue that can help me to solve this problem so i trace it in hard way by doing static analysis the ai-bolit-hoster.php script.

First, I need to look in /opt/ai-bolit/ai-bolit-hoster.php on line 5221 were ZipScanner::isZip() is called, then I found this code:

        if (isset($this->options['scan-archive']) && $type === self::JOB_UPLOAD && ZipScanner::isZip($files_to_scan[0])) {

There is two clue that I found which are self:JOB_UPLOAD and ZipScanner::isZip($files_to_scan[0]). Then I need to trace where $files_to_scan is defined and I found this code:

        $files_to_scan = [];
        $count = 0;

        $job = json_decode(file_get_contents($job_file));
        $file = AibolitHelpers::getBaseName($job_file);

        $this->debugLog("Job {$file} received from queue.");

        array_walk($job->files, static function(&$item) {
            $item = base64_decode($item);
        });

        $files_to_scan = $job->files;

        $count = count($files_to_scan);

I found that $files_to_scan is assigned with the value of $job->$files. Then I also found that $job is asigned by the value of json_decode(file_get_contents($job_file)). Then I need to trace where $job_file is defined. And I found this code:

    protected function scanJob($job_file, $type)
    {
        $start_time = AibolitHelpers::currentTime();

        $vars = new Variables();
        if ($type === self::JOB_NOTIFY) {
            $this->finder->getFilter()->setSkipSystemOwner(isset($this->options['skip-system-owner']));
        } else {
            $this->finder->getFilter()->setSkipSystemOwner(false);
        }
        $vars->signs = $this->signs;
        $vars->users = new UserList();
        $vars->options = $this->options;

        $files_to_scan = [];
        $count = 0;

        $job = json_decode(file_get_contents($job_file));
        $file = AibolitHelpers::getBaseName($job_file);

That is the most top definition of job_file that I can found. Based on that I know that job_file is related to file that contains job of aibolit-resident. So I concluded that the error is caused by the corrupted aibolit job file. At next step, I need to find where this job file is located.

Because this aibolit-resident is from imunify360, so the jobs is located in /var/imunify360/aibolit/resident/in/notify-jobs and /var/imunify360/aibolit/resident/in/upload-jobs. The next step that need to be done is stopping all service related to imunify360 and aibolit-resident. Then I need to delete all the job file inside those directories. After that i can start all imunify360 service and aibolit-resident service again. Then voila the service runs normally again.

ā— aibolit-resident.service - AibolitResident
   Loaded: loaded (/usr/lib/systemd/system/aibolit-resident.service; enabled; vendor preset: dis>
   Active: active (running) since Tue 2023-12-19 16:16:09 WIB; 2h 17min ago
 Main PID: 1672833 (wrapper)
    Tasks: 9 (limit: 408076)
   Memory: 82.0M
   CGroup: /system.slice/aibolit-resident.service

That is all that i can share, I hope this information is useful for you.