Skip to content
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
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Changelog
=========

* 3.0.0
* CakePHP 5.0 compatible release
* CakePHP 5.1 compatible release

* 2.0.0
* CakePHP 4.0 compatible release
Expand Down
2 changes: 1 addition & 1 deletion LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License

Copyright 2013-2023
Copyright 2013-2026
Cake Development Corporation
1785 E. Sahara Avenue, Suite 490-423
Las Vegas, Nevada 89104
Expand Down
8 changes: 3 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
CakeDC\Clamav for CakePHP
===================

[![Build Status](https://secure.travis-ci.org/cakedc/cakephp-clamav.png?branch=master)](http://travis-ci.org/cakedc/cakephp-clamav)
[![Coverage Status](https://img.shields.io/codecov/c/gh/cakedc/cakephp-clamav.svg?style=flat-square)](https://codecov.io/gh/cakedc/cakephp-clamav)
[![Downloads](https://poser.pugx.org/cakedc/cakephp-clamav/d/total.png)](https://packagist.org/packages/cakedc/cakephp-clamav)
[![Latest Version](https://poser.pugx.org/cakedc/cakephp-clamav/v/stable.png)](https://packagist.org/packages/cakedc/cakephp-clamav)
[![License](https://poser.pugx.org/cakedc/cakephp-clamav/license.svg)](https://packagist.org/packages/cakedc/cakephp-clamav)
Expand All @@ -12,8 +10,8 @@ ClamAV integration with CakePHP via Validator
Requirements
------------

* CakePHP 5.0+
* PHP 8.1+
* CakePHP 5.1+
* PHP 8.2+
* Clamd (daemon) up and running, connection via socket

Setup
Expand Down Expand Up @@ -80,7 +78,7 @@ bug fixes to the plugin, please read our [Contribution Guidelines](https://www.c
License
-------

Copyright 2013-2023 Cake Development Corporation (CakeDC). All rights reserved.
Copyright 2013-2026 Cake Development Corporation (CakeDC). All rights reserved.

Licensed under the [MIT](http://www.opensource.org/licenses/mit-license.php) License. Redistributions of the source code included in this repository must retain
the copyright notice found in each file.
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
"type": "cakephp-plugin",
"license": "MIT",
"require": {
"php": ">=8.1",
"cakephp/cakephp": "^5.0"
"php": ">=8.2",
"cakephp/cakephp": "^5.1"
},
"require-dev": {
"phpunit/phpunit": "^10.0",
"cakephp/cakephp-codesniffer": "^4.0"
"phpunit/phpunit": "^10.1.0",
"cakephp/cakephp-codesniffer": "^5.0"
},
"autoload": {
"psr-4": {
Expand Down
4 changes: 2 additions & 2 deletions config/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
declare(strict_types=1);

/**
* Copyright 2013 - 2023, Cake Development Corporation (https://www.cakedc.com)
* Copyright 2013 - 2026, Cake Development Corporation (https://www.cakedc.com)
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright 2013 - 2023, Cake Development Corporation (https://www.cakedc.com)
* @copyright Copyright 2013 - 2026, Cake Development Corporation (https://www.cakedc.com)
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
use Cake\Core\Configure;
Expand Down
2 changes: 0 additions & 2 deletions phpcs.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
<?xml version="1.0"?>
<ruleset name="cakedc/cakephp-clamav plugin for CakePHP">
<config name="installed_paths" value="../../cakephp/cakephp-codesniffer"/>

<rule ref="CakePHP"/>
</ruleset>
93 changes: 0 additions & 93 deletions src/Network/Socket.php

This file was deleted.

22 changes: 11 additions & 11 deletions src/Validation/ClamdValidation.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,22 @@
declare(strict_types=1);

/**
* Copyright 2013 - 2023, Cake Development Corporation (https://www.cakedc.com)
* Copyright 2013 - 2026, Cake Development Corporation (https://www.cakedc.com)
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright 2013 - 2023, Cake Development Corporation (https://www.cakedc.com)
* @copyright Copyright 2013 - 2026, Cake Development Corporation (https://www.cakedc.com)
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
namespace CakeDC\Clamav\Validation;

use Cake\Core\Configure;
use Cake\Log\Log;
use Cake\Network\Socket as BaseSocket;
use Cake\Network\Socket;
use Cake\Validation\Validator;
use CakeDC\Clamav\Network\Socket;
use Exception;
use OutOfBoundsException;
use function Cake\I18n\__d;

/**
Expand All @@ -40,7 +40,7 @@ class ClamdValidation extends Validator
* Use clamd socket to scan the uploaded tmp file
*
* @param mixed $check value to check
* @return bool|string
* @return string|bool
*/
public function fileHasNoVirusesFound(mixed $check): bool|string
{
Expand All @@ -63,7 +63,7 @@ public function fileHasNoVirusesFound(mixed $check): bool|string
'{0} while checking the file {1} for viruses: {2}',
get_class($ex),
$tmpName,
$ex->getMessage()
$ex->getMessage(),
);
Log::warning($message);

Expand Down Expand Up @@ -91,7 +91,7 @@ protected function clamdScan(string $tmpName): ?string
$this->sendInstream($tmpName, $socket);
break;
default:
throw new \OutOfBoundsException(sprintf('Invalid scan mode: %s', $mode));
throw new OutOfBoundsException(sprintf('Invalid scan mode: %s', $mode));
}

return $socket->read();
Expand All @@ -104,12 +104,12 @@ protected function clamdScan(string $tmpName): ?string
* @param \Cake\Network\Socket $socket socket to write
* @return void
*/
protected function sendInstream(string $tmpName, BaseSocket $socket): void
protected function sendInstream(string $tmpName, Socket $socket): void
{
$fhandler = fopen($tmpName, 'r');
$streamMaxLength = Configure::read('CakeDC/Clamav.streamMaxLength', 25 * 1024 * 1024);
if (!$fhandler) {
throw new \OutOfBoundsException(sprintf('Unable to open file: %s', $tmpName));
throw new OutOfBoundsException(sprintf('Unable to open file: %s', $tmpName));
}
$socket->write('nINSTREAM' . PHP_EOL);
while (!feof($fhandler)) {
Expand All @@ -128,7 +128,7 @@ protected function sendInstream(string $tmpName, BaseSocket $socket): void
* Get Socket instance for DI
*
* @param array<string, mixed> $config socket configuration
* @return \CakeDC\Clamav\Network\Socket
* @return \Cake\Network\Socket
*/
protected function getSocketInstance(array $config): Socket
{
Expand All @@ -139,7 +139,7 @@ protected function getSocketInstance(array $config): Socket
* Check scan result and return error msg or true if OK
*
* @param string $result result from clamad
* @return bool|string
* @return string|bool
*/
protected function checkScanResult(string $result): bool|string
{
Expand Down
15 changes: 7 additions & 8 deletions tests/TestCase/Validation/ClamdValidationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
declare(strict_types=1);

/**
* Copyright 2013 - 2023, Cake Development Corporation (https://www.cakedc.com)
* Copyright 2013 - 2026, Cake Development Corporation (https://www.cakedc.com)
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright 2013 - 2023, Cake Development Corporation (https://www.cakedc.com)
* @copyright Copyright 2013 - 2026, Cake Development Corporation (https://www.cakedc.com)
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/

Expand All @@ -17,28 +17,27 @@
use Cake\Cache\Engine\NullEngine;
use Cake\Core\Configure;
use Cake\Network\Exception\SocketException;
use Cake\Network\Socket;
use Cake\TestSuite\TestCase;
use CakeDC\Clamav\Network\Socket;
use CakeDC\Clamav\Validation\ClamdValidation;

/**
* @property ClamdValidation ClamdValidation
*/
class ClamdValidationTest extends TestCase
{
protected ?ClamdValidation $ClamdValidation = null;

public function setUp(): void
{
parent::setUp();
$this->ClamdValidation = new ClamdValidation();
Cache::setConfig('_cake_core_', [
Cache::setConfig('_cake_translations_', [
'className' => NullEngine::class,
]);
}

public function tearDown(): void
{
$this->ClamdValidation = null;
Cache::drop('_cake_core_');
Cache::drop('_cake_translations_');
parent::tearDown();
}

Expand Down
4 changes: 2 additions & 2 deletions tests/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
declare(strict_types=1);

/**
* Copyright 2013 - 2023, Cake Development Corporation (https://www.cakedc.com)
* Copyright 2013 - 2026, Cake Development Corporation (https://www.cakedc.com)
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright 2013 - 2023, Cake Development Corporation (https://www.cakedc.com)
* @copyright Copyright 2013 - 2026, Cake Development Corporation (https://www.cakedc.com)
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/

Expand Down
Loading