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.
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
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
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
RubyClamdscan.ping_server
- Ping server, should respond with "PONG"RubyClamdscan.server_version
- Query ClamAV for server version info - response format may changeRubyClamdscan.server_stats
- Query ClamAV for server stats, resources, etc - response format may changeRubyClamdscan.reload_server_database
- Tell ClamAV server to reload virus dbRubyClamdscan.shutdown_server
- Tell ClamAV server shutdown and stop listening to requests
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.
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.
Everyone interacting in the RubyClamdscan project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.