Code Monkey home page Code Monkey logo

php-clamav's Introduction

Appwrite ClamAV PHP Client

Discord Total Downloads Build Status Twitter Account

PHP Client to connect to ClamAV daemon over TCP or using a local socket from command line and scan your storage files for viruses.

Getting Started

Install using composer:

composer require appwrite/php-clamav
<?php

require_once 'vendor/autoload.php';

use Appwrite\ClamAV\Network;

$clam = new Network('localhost', 3310); // Or use new Pipe() for unix socket

$clam->ping(); // Check ClamAV is up and running

$clam->version(); // Check ClamAV version

$clam->fileScan('path/to/file.dmg'); // Returns true if a file is clean or false if a file is infected

$clam->reload(); // Reload ClamAV database

$clam->shutdown(); // Shutdown ClamAV

System Requirements

This package requires PHP 7.1 or later. We recommend using the latest PHP version whenever possible.

Find Us

Authors

Eldad Fux

Copyright and license

The MIT License (MIT) http://www.opensource.org/licenses/mit-license.php

php-clamav's People

Contributors

christyjacob4 avatar drph4nt0m avatar eldadfux avatar peter279k avatar softcreatr avatar tminich avatar torstendittmann avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

php-clamav's Issues

๐Ÿ› Bug Report: ClamAv::fileScanInStream does not detect eicar.com file

๐Ÿ‘Ÿ Reproduction steps

Download the "eicar.com" or the "eicar.com.txt" file from https://www.eicar.org/download-anti-malware-testfile/

$clam = new Network($host, $port);
$is_clean = $clam->fileScanInStream('path/to/eicar/file');

The function is supposed to return false, instead it returns true.
This behavior happen with both "eicar.com" and "eicar.com.txt" files but not with zip files.

The problem seem to happen with text files of less than 8192 bytes.

In Appwrite\ClamAv\ClamAv:107 the fread return an empty string which is sent to the socket. The problem is ClamAv does not detect the eicar file if this empty string is packed and send through the socket.

๐Ÿ‘ Expected behavior

in the example above the $is_clean variable should be false.

๐Ÿ‘Ž Actual Behavior

In the exemple above the $is_clean variable is true.

๐ŸŽฒ PHP ClamAV version

Different version (specify in environment)

๐Ÿ’ป Operating system

Linux

๐Ÿงฑ Your Environment

Version : appwrite/php-clamav:2.0.0
PHP 8.2 (also with 8.1) in a docker container
Clamav in another docker container : https://hub.docker.com/r/clamav/clamav/

๐Ÿ‘€ Have you spent some time to check if this issue has been raised before?

  • I checked and didn't find similar issue

๐Ÿข Have you read the Code of Conduct?

Please remove virus.txt from /tests/data โ€” it is triggering McAffee and causing entire docker containers to be blocked.

๐Ÿ‘Ÿ Reproduction steps

When trying to transfer docker containers to private servers McAffee blocks the entire container because of this one file.

๐Ÿ‘ Expected behavior

There is no reason for such a file to exist in this repo as far as I know?

๐Ÿ‘Ž Actual Behavior

N/A

๐ŸŽฒ PHP ClamAV version

Version 1.1.x

๐Ÿ’ป Operating system

Windows

๐Ÿงฑ Your Environment

No response

๐Ÿ‘€ Have you spent some time to check if this issue has been raised before?

  • I checked and didn't find similar issue

๐Ÿข Have you read the Code of Conduct?

Unable to connect to ClamAV server

I am using windows 10. I followed installation procedure through composer and created a file to execute. But getting this problem.

Fatal error: Uncaught RuntimeException: Unable to connect to ClamAV server in C:\xampp\htdocs\test\scan\appwrite\vendor\appwrite\php-clamav\src\ClamAV\Network.php:48 Stack trace: #0 C:\xampp\htdocs\test\scan\appwrite\vendor\appwrite\php-clamav\src\ClamAV\ClamAV.php(33): Appwrite\ClamAV\Network->getSocket() #1 C:\xampp\htdocs\test\scan\appwrite\vendor\appwrite\php-clamav\src\ClamAV\ClamAV.php(51): Appwrite\ClamAV\ClamAV->sendCommand('PING') #2 C:\xampp\htdocs\test\scan\appwrite\index.php(9): Appwrite\ClamAV\ClamAV->ping() #3 {main} thrown in C:\xampp\htdocs\test\scan\appwrite\vendor\appwrite\php-clamav\src\ClamAV\Network.php on line 48

๐Ÿš€ Feature: DSN support

๐Ÿ”– Feature description

Implement DSN connection strings.

Examples:

unix:///var/run/clamav/clamd.ctl
tcp://localhost:3310

And here's an example of how it could look.

$clam = new Connection('tcp://localhost:3310');  // returns -> new Network('localhost', 3310)
$version = $clam->version();

๐ŸŽค Pitch

I would like to use a single environment variable that would include the type of connection and the connection details. I'd like to give users or administrators the option to use the Network class or Pipe class with a single string.

๐Ÿ‘€ Have you spent some time to check if this issue has been raised before?

  • I checked and didn't find similar issue

๐Ÿข Have you read the Code of Conduct?

๐Ÿš€ Feature: Laravel integration

๐Ÿ”– Feature description

It would be ideal to make a package for laravel

๐ŸŽค Pitch

Laravel being the most popular framework, many developers could benefit from it.

๐Ÿ‘€ Have you spent some time to check if this issue has been raised before?

  • I checked and didn't find similar issue

๐Ÿข Have you read the Code of Conduct?

I trying using the php-clamav but not work.

I trying using the php-clamav but not work.

I'm use the follow code

<?php

require_once 'vendor/autoload.php';

$clam = new Appwrite\ClamAV\Pipe();

echo 'Ping: ';
var_dump($clam->ping());
echo "\n";

echo 'version: ';
var_dump($clam->version());
echo "\n";

echo 'fileScan: ';
var_dump($clam->fileScan('/var/www/html/public/data/tmp/files.txt'));
//var_dump($clam->fileScan('/tmp/files.txt'));
echo "\n";

But the log showed.

Fri Mar  4 15:09:12 2022 -> /var/www/html/public/data/tmp/files.txt: Can't open file or directory ERROR

But, when use the file in /tmp. works

Fri Mar  4 15:01:22 2022 -> /tmp/files.txt: Eicar-Signature(69630e4574ec6798239b091cda43dca0:69) FOUND
root@localhost: ~# namei -lv /var/www/html/public/data/tmp/files.txt
f: /var/www/html//public/data/tmp/files.txt
drwxr-xr-x root     root     /
drwxr-xr-x root     root     var
drwxr-xr-x root     root     www
drwxr-xr-x root     root     html
drwxr-xr-x root     root     public
drwxrwxr-x www-data www-data data
drwxrwxr-x www-data www-data tmp
-rw-r--r-- root     root     files.txt
root@locahost: ~# 

but not work. Let me known what i'm doing wrong.

other detail, that using clamdscan command work with parameter --fppass.

Upgrade our issue templates to use GitHub issue forms โœ๏ธ

Introduction

GitHub has recently rolled out a public beta for their issue forms feature. This would allow you to create interactive issue templates and validate them ๐Ÿคฏ.

Appwrite currently uses the older issue template format. Your task is to create GitHub issue forms for this repository. Please use Appwrite's issue templates as a reference for this PR.

Tasks summary:

  • Fork & clone this repository
  • Prepare bug report issue form in .github/ISSUE_TEMPLATE/bug.yaml
  • Prepare documentation issue form in .github/ISSUE_TEMPLATE/documentation.yaml
  • Prepare feature request issue form in .github/ISSUE_TEMPLATE/feature.yaml
  • Push changes to master and test issue forms on your fork
  • Submit pull request

If you need any help, reach out to us on our Discord server.

Are you ready to work on this issue? ๐Ÿค” Let us know, and we will assign it to you ๐Ÿ˜Š

Happy Appwriting!

๐Ÿ“š Documentation: Specify which filescan() return bool corresponds to infection

๐Ÿ’ญ Description

Thank you for this integration!

Presently the documentation simply states:

// Return true of false for file scan

In my opinion, it would be more intuitive to specify which bool return value indicates infected vs not. So maybe revise this line to say:

// Returns true if a file is clean or false if a file is infected

๐Ÿ‘€ Have you spent some time to check if this issue has been raised before?

  • I checked and didn't find similar issue

๐Ÿข Have you read the Code of Conduct?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.