Skip to content

New. BinaryCheck. Init module.#593

Open
svfcode wants to merge 21 commits into
devfrom
binarycheck-init
Open

New. BinaryCheck. Init module.#593
svfcode wants to merge 21 commits into
devfrom
binarycheck-init

Conversation

@svfcode

@svfcode svfcode commented Jan 20, 2026

Copy link
Copy Markdown
Member

@alexandergull alexandergull marked this pull request as draft February 26, 2026 13:50
@Glomberg Glomberg removed their request for review April 6, 2026 17:50
@Glomberg Glomberg marked this pull request as ready for review June 22, 2026 10:41

@alexandergull alexandergull left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

https://app.doboard.com/1/task/43500 - task is not ready, request a new review since it is.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR introduces a new “Binary analysis” scanning stage to detect and surface potentially suspicious binary/executable files, integrates it into the scanner pipeline/UI, and adds safer handling for viewing binary files in scan results.

Changes:

  • Added a new scanner stage (binary_analysis) with supporting storage/reporting and a binary-check module that inspects file headers.
  • Updated scanner queries and actions to exclude binary-tagged files from cloud send / cure / heuristic/signature flows.
  • Added UI/settings wiring for enabling the stage and rendering binary files as a hex dump when viewing file contents.

Reviewed changes

Copilot reviewed 12 out of 15 changed files in this pull request and generated 11 comments.

Show a summary per file
File Description
lib/CleantalkSP/SpbctWP/State.php Adds default setting for enabling binary analysis.
lib/CleantalkSP/SpbctWP/SpbcEnqueue.php Exposes new stage flags/translations to the frontend.
lib/CleantalkSP/SpbctWP/Scanner/Surface.php Includes extensionless files in scan discovery (binary candidates).
lib/CleantalkSP/SpbctWP/Scanner/Stages/CureStage.php Excludes binary-tagged files from curing selection.
lib/CleantalkSP/SpbctWP/Scanner/Services/SendFileToCloudService.php Prevents sending binary-tagged files to cloud analysis.
lib/CleantalkSP/SpbctWP/Scanner/ScanningStagesModule/Stages/BinaryAnalysis.php New stage data object for logging/progress.
lib/CleantalkSP/SpbctWP/Scanner/ScannerQueue.php Adds the binary_analysis stage and integrates module execution + SQL filtering.
lib/CleantalkSP/SpbctWP/Scanner/ScannerActions/FileSystemActions.php Adds hex-dump rendering when viewing binary files.
lib/CleantalkSP/SpbctWP/Scanner/ScannerActions/CloudAnalysisActions.php Excludes binary-tagged files from bulk cloud-send selection.
lib/CleantalkSP/SpbctWP/Scanner/BinaryCheckModule/BinaryCheckModule.php New module performing header-based binary detection and DB status updates.
js/src/spbc-scanner-plugin.js Adds binary stage handling in the scanner frontend logic.
js/spbc-scanner-plugin.min.js Built/minified output reflecting the new stage.
js/spbc-scanner-plugin.min.js.map Source map updated for the new stage.
inc/spbc-settings.php Adds the settings field and UI stage label; adjusts actions for binary files.
Comments suppressed due to low confidence (1)

lib/CleantalkSP/SpbctWP/Scanner/ScannerQueue.php:1035

  • source is being set to an empty string for non-binary files. This breaks logic that relies on source IS NULL to identify unknown files (e.g., UnknownRepository), and also makes later isset($file_info['source']) checks treat the source as “known”. Store NULL for non-binary files and insert SQL NULL (not an empty string) so existing unknown-file workflows keep working.
                // if extension is not set, set 'source' to 'binary'
                $file['source'] = ! $ext ? 'BINARY' : '';

                if ( ! spbc_check_ascii($file['path']) ) {
                    $sql_query__values_non_ascii[] = '(\'' . implode('\',\'', $file) . '\')';
                } else {
                    $sql_query__values[] = '(\'' . implode('\',\'', $file) . '\')';
                }

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread lib/CleantalkSP/SpbctWP/Scanner/ScannerQueue.php Outdated
Comment thread lib/CleantalkSP/SpbctWP/Scanner/ScannerQueue.php Outdated
Comment thread lib/CleantalkSP/SpbctWP/Scanner/ScannerQueue.php Outdated
Comment thread lib/CleantalkSP/SpbctWP/Scanner/ScannerQueue.php
Comment thread lib/CleantalkSP/SpbctWP/Scanner/Stages/CureStage.php
Comment on lines +634 to +641
if ( is_file($path) && !is_link($path) ) {
$currentFileExtension = pathinfo($path, PATHINFO_EXTENSION);

if ($currentFileExtension === '') {
$this->output_counter_files++;
$this->output_files[]['path'] = $path;
continue;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think that's wrong.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What is this logic for? If you want to count no-extension files, modify the logic before extension check.

if ($currentFileExtension !== "") {
if ( $this->ext_except || $this->ext ) ...
\further extension check
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Note, this is not the same logic as just counting files. If you skip the fie the way it is now, next iterator logic may be broken.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

done

Comment thread inc/spbc-settings.php
Comment on lines +29 to +45
public function run($amount = 4, $offset = 0)
{
$this->batch_count = 0;
$this->scanned_count = 0;
$this->statuses = array();

$binary_files = $this->getBinaryFiles($amount, $offset);
$this->batch_count = count($binary_files);

$this->analyzeBinaryFiles($binary_files);

return array(
'success' => true,
'batch_count' => $this->batch_count,
'scanned_count' => $this->scanned_count,
'statuses' => $this->statuses,
);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Not now.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

So please provide a new task to cover the Binary analysis with unit-test.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Comment thread lib/CleantalkSP/SpbctWP/Scanner/Surface.php
Comment thread lib/CleantalkSP/SpbctWP/Scanner/Surface.php Outdated
Comment thread lib/CleantalkSP/SpbctWP/Scanner/ScannerQueue.php Outdated
Comment thread lib/CleantalkSP/SpbctWP/Scanner/ScannerQueue.php Outdated
Comment thread lib/CleantalkSP/SpbctWP/Scanner/ScannerQueue.php Outdated
Comment on lines +634 to +641
if ( is_file($path) && !is_link($path) ) {
$currentFileExtension = pathinfo($path, PATHINFO_EXTENSION);

if ($currentFileExtension === '') {
$this->output_counter_files++;
$this->output_files[]['path'] = $path;
continue;
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Note, this is not the same logic as just counting files. If you skip the fie the way it is now, next iterator logic may be broken.

Comment on lines +29 to +45
public function run($amount = 4, $offset = 0)
{
$this->batch_count = 0;
$this->scanned_count = 0;
$this->statuses = array();

$binary_files = $this->getBinaryFiles($amount, $offset);
$this->batch_count = count($binary_files);

$this->analyzeBinaryFiles($binary_files);

return array(
'success' => true,
'batch_count' => $this->batch_count,
'scanned_count' => $this->scanned_count,
'statuses' => $this->statuses,
);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

So please provide a new task to cover the Binary analysis with unit-test.

Comment thread inc/spbc-settings.php
alexander-b-clean and others added 7 commits July 9, 2026 09:21
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
…ck-init

# Conflicts:
#	inc/spbc-settings.php
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.

7 participants