0.0
No release in over a year
Implements most commands for clamdscan using socket communcation so that you don't need ClamAV or clamdscan installed on the same host as your service
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies
 Project Readme

RubyClamdscan

Implementing most clamdscan commands as a Ruby Gem using socket communication.

This is a personal project to learn more about how Ruby gem development works and may not be actively developed.

Installation

Install the gem and add to the application's Gemfile by executing:

$ bundle add ruby_clamdscan

If bundler is not being used to manage dependencies, install the gem by executing:

$ gem install ruby_clamdscan

Usage

Set the configuration for this gem by using:

RubyClamdscan.configure do |conf|
  conf.use_tcp_socket = true
end

Scan files by using:

RubyClamdscan.scan_file_from_path("/path/to/local/file")

or

RubyClamdscan.scan_contents(IO)

Both return instances of RubyClamdscan::Models::ScanResults with information about the scan

Configuration options

RubyClamdscan.configure do |conf|
  conf.use_tcp_socket = true # If using TCP socket, defaults to false to use local unix socket
  conf.tcp_port = 3310 # TCP Port where ClamAV is listening
  conf.tcp_host = "localhost" # Host where ClamAV is listening
  conf.unix_socket = "/tmp/clamd.socket" # If using UNIX socket, what file represents the socket
  conf.chunk_size = 1024 # Size of chunk in bytes to send to ClamAV for scanning
  conf.raise_error_on_empty_response = true # If the socket responds empty, raise `RubyClamdscan::Errors::EmptyResponseError` instead of returning an empty string
  conf.raise_error_on_virus_detected = true # If a virus is detected, raise `RubyClamdscan::Errors::VirusDetectedError` instead of just returning the result
end

Commands

  • RubyClamdscan.ping_server - Ping server, should respond with "PONG"
  • RubyClamdscan.server_version - Query ClamAV for server version info - response format may change
  • RubyClamdscan.server_stats - Query ClamAV for server stats, resources, etc - response format may change
  • RubyClamdscan.reload_server_database - Tell ClamAV server to reload virus db
  • RubyClamdscan.shutdown_server - Tell ClamAV server shutdown and stop listening to requests

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake test to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and the created tag, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/jacobrayschwartz/ruby_clamdscan. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the code of conduct.

Code of Conduct

Everyone interacting in the RubyClamdscan project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.