symbiote/silverstripe-steamedclams 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

symbiote/silverstripe-steamedclams

Composer 安装命令:

composer require symbiote/silverstripe-steamedclams

包简介

关键字:

README 文档

README

Using ClamAV, this module scans files as their uploaded and denies uploading if a virus was detected. If the ClamAV daemon is down it will log that the file needs to be scanned, wherein you can either manually scan via the CMS once the daemon is back online, run a nightly cron that scans the files or if you have queuedjobs installed, it will automatically scan missed files at nightly.

Composer Install

composer require symbiote/silverstripe-steamedclams

Screenshots

ModelAdmin

UploadField

Quick Start

  1. Install ClamAV in Unix/Linux.
sudo apt install clamav clamav-daemon

run sudo apt-get install apt-get update when necessary.

  1. Start clamav-daemon
sudo service clamav-freshclam restart
# wait ~2 minutes
sudo service clamav-daemon start

And check the clamav-daemon is running.

 sudo service clamav-daemon status
  1. Setup socket permissions The clamav-daemon creates this /var/run/clamav/clamd.ctl if not.
sudo mkdir /var/run/clamav
sudo chown -R user:group /var/run/clamav

'defaultsite' being the user and group that has ownership.

  1. Configure clamd.conf:
# Path to a local socket file the daemon will listen on.
# Default: disabled (must be specified by a user)
LocalSocket /var/run/clamav/clamd.ctl

(optional) You can use a different socket path, but you will need to change it in the config YML like below to match your clamd.conf:

Symbiote\SteamedClams\ClamAV:
  clamd:
    LocalSocket: '/var/run/clamav/clamd.ctl'
  1. After running dev/build?flush, all files should scan for viruses automatically during uploading / validation. If you are using

  2. To check to see if it's running properly, it should show that it's ONLINE at: http://{mysite.com}/admin/clamav

Configuration

Symbiote\SteamedClams\ClamAV:
  # Make this the same as your clamd.conf settings
  clamd:
    LocalSocket: '/var/run/clamav/clamd.ctl'
  # If true and the ClamAV daemon isn't running or isn't installed the file will be denied as if it has a virus.
  deny_on_failure: false
  # For configuring on existing site builds and ignoring the scanning of pre-module install `File` records. 
  initial_scan_ignore_before_datetime: '1970-12-25 00:00:00'
  # If true will send files to clamd as streams (by default files are referenced using their path). Useful when files are stored remotely and/or encrypted at rest.
  use_streams: false

If you have the QueuedJobs module installed, you can configure when files missed by ClamAV daemon are scanned. This job will only queue if the daemon couldn't be connected to at the time that the file was uploaded.

Symbiote\SteamedClams\ClamAVScanJob:
  # This job will queue itself on dev/build by default if `File` records have been missed in scanning.
  disable_queue_on_devbuild: false
  # Repeat at daily by default (in seconds).
  repeat_time: 86400
  # Repeat at 2am by default
  time: '02:00:00'

Install on existing project

By running the task below, all files uploaded before installation of the module will be scanned.

/dev/tasks/Symbiote-SteamedClams-ClamAVInstallTask

To ignore certain files before a specific date, you can configure the datetime in your YML files, as below:

Symbiote\SteamedClams\ClamAV:
  initial_scan_ignore_before_datetime: '2015-06-06 00:00:00'

Emulate Mode

To emulate ClamAV results, put in your YML

Injector:
  Symbiote\SteamedClams\ClamAV:
    class: Symbiote\SteamedClams\ClamAVEmulator

Then in your _config.php, switch between various testing modes:

<?php

use Symbiote\SteamedClams\ClamAV;
use Symbiote\SteamedClams\ClamAVEmulator;

// Use this instead of YAML for quicker testing
Config::inst()->update('Injector', 'Symbiote\SteamedClams\ClamAV', array('class' => 'Symbiote\SteamedClams\ClamAVEmulator'));

// If no virus found
ClamAVEmulator::config()->mode = ClamAVEmulator::MODE_NO_VIRUS;

// If virus found (Eicar-Test-Signature)
ClamAVEmulator::config()->mode = ClamAVEmulator::MODE_HAS_VIRUS;

// If ClamAV daemon isn't running
ClamAVEmulator::config()->mode = ClamAVEmulator::MODE_OFFLINE;

Supports

  • Silverstripe 5.0 and up
  • Versioned Files
  • CDN Content
  • For Silverstripe 4.x use 3.0
  • For Silverstripe 3.2 and up (3.1 should work, create an issue if you determine otherwise) use 1.0

Credits

Barakat S for clamd PHP interface "How to Forge" users for fixing permission issues

symbiote/silverstripe-steamedclams 适用场景与选型建议

symbiote/silverstripe-steamedclams 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 10.48k 次下载、GitHub Stars 达 13, 最近一次更新时间为 2018 年 09 月 10 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「silverstripe」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 symbiote/silverstripe-steamedclams 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 symbiote/silverstripe-steamedclams 我们能提供哪些服务?
定制开发 / 二次开发

基于 symbiote/silverstripe-steamedclams 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 10.48k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 13
  • 点击次数: 6
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 13
  • Watchers: 4
  • Forks: 18
  • 开发语言: PHP

其他信息

  • 授权协议: BSD-3-Clause
  • 更新时间: 2018-09-10