PHPackages                             masilia/clamav-bundle - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Security](/categories/security)
4. /
5. masilia/clamav-bundle

ActiveSymfony-bundle[Security](/categories/security)

masilia/clamav-bundle
=====================

This bundle provides easy scanning virus with clamAv antivirus for Symfony and eZ Platform

v1.0.0-beta(5y ago)20PHP

Since May 2Pushed 2y ago1 watchersCompare

[ Source](https://github.com/masilia/clamav-bundle)[ Packagist](https://packagist.org/packages/masilia/clamav-bundle)[ RSS](/packages/masilia-clamav-bundle/feed)WikiDiscussions master Synced today

READMEChangelog (1)Dependencies (2)Versions (2)Used By (0)

Masilia ClamAv Bundle
=====================

[](#masilia-clamav-bundle)

This bundle provides an antivirus scan with clamAv for Symfony and eZ Platform formBuilder

Requirements
------------

[](#requirements)

- eZ Platform 2.5+

Install instructions
--------------------

[](#install-instructions)

1. Add the project repository:

    In the main `composer.json`, add:

    ```
    "repositories": [
        // ...
        {
            "type": "vcs",
            "url": "https://github.com:masilia/clamav-bundle.git"
        }
    ],

    ```
2. Install the bundle via Composer (initial installation):

    ```
    $ composer require masilia/clamav-bundle
    ```

    2.1 Update the bundle via Composer if needed

    ```
    $ composer update masilia/clamav-bundle
    ```
3. Activate the bundle in your `app/AppKernel.php`:

    ```
    $bundles = [
        ...
        new Masilia\ClamavBundle\MasiliaClamavBundle(),
        ...
    ];
    ```
4. install the clamAv modules in your server

    ```
    clamav
    clamav-daemon
    clamav-freshclam

    ```

    4.1 Under Debian distribution, run the following commands (adapt according to the distribution used):

    ```
     apt-get install clamav &&
     apt-get install clamav-daemon &&
     apt-get install clamav-freshclam
    ```

    4.2 To update the database, we stop the `clamav-freshclam` service and then run the corresponding command as follows:

    ```
    /etc/init.d/clamav-freshclam stop && freshclam
    ```

    4.3 Config the ClamAv service:

    - 4.3.1 run the clamAv with TCP|IP protocol.
        -- Under the file `/etc/clamav/clamd.conf` Add these lines to the config:

    ```
    TCPSocket {{port}} (3310 often we choose this one)
    TCPAddr {{server ip}} (127.0.0.1 if the clamav service is installed locally)

    ```

    \-- Under the file `/etc/systemd/system/clamav-daemon.service.d/extend.conf` Add the line:

    ```
    ListenStream = {{ip: port}} (127.0.0.1:3310 in our example)

    ```

    - 4.3.2 or run the clamAv with UNIX socket protocol.
        -- Under the file /etc/clamav/clamd.conf Add the line :

    ```
     LocalSocket: /var/run/clamav/clamd.sock

    ```

    - 4.3.3 After these configs you can restart your service :

    ```
    $ systemctl daemon-reload && /etc/init.d/clamav-daemon restart
    ```

    - 4.3.4 Add the `clamav` user to the group `www-data`:

    ```
      $ usermod -a -G www-data clamav && /etc/init.d/clamav-daemon restart
    ```

    - To make sure, execute the command :

    ```
     $ groups clamav
    ```

    - Output :

    ```
      clamav : clamav www-data

    ```

- To make sure that our clamav-daemon service is running under the socket ip:port configured or the unix local socket , we execute the command :

```
netstat -lpn | grep clam
```

- Output if the clamAv is lessening to the configured unix local socket :

```
unix  2      [ ACC ]     STREAM     LISTENING     239406   1121/clamd           /var/run/clamav/clamd.sock
```

- Output if the clamAv is lessening to the configured TCP|IP socket :

```
TCP   0         0 127.0.0.1:3310            0.0.0.0.*           LISTEN          97/clamd
```

- Output if we configured both protocols:

```
unix  2      [ ACC ]     STREAM     LISTENING     239406   1121/clamd           /var/run/clamav/clamd.sock
TCP   0         0 127.0.0.1:3310            0.0.0.0.*           LISTEN          97/clamd
```

5. Configuration of app/config/config.yml file

- ```
    masilia_clamav:
        #required config , 'unix:///path/to/clamav/unix_local_socket' if unix socket or 'tcp://ip:port' if tcp|ip socket>>
        socket_path: 'unix:///path/to/clamav/unix_local_socket|tcp://ip:port'
        #optional config, if you have chroot partition in your server you can the path
        root_path: '/opt/www/project-root' ('' as default)
        #optional config, you can add it if your form is handled with ezForm Builder
        ezform_builder_enabled: true|false (false as default)
        #optional config, if we want to scan on streaming the uploaded file
        # if the clamAv is running in the remote server , we must use the the TCP|IP protocol and enable the stream scan
        # when there issue with the scan and you get in logs the message like ('reason' => 'lstat()'), this option may resolve your issue
        enable_stream_scan: true|false (false as default value)
        #To enable validation on BO with ezbinaryfile FieldType
        enable_binary_field_type_validator: true|false (false as default value)

    ```

Usage
-----

[](#usage)

5.1 Antivirus constraint

- In symfony object form To enable Antivirus constraint on your form Type for the input file add the following lines .

    ```
