crystal_av
Version, currently master branch1 version
- master branchlatestJul 23, 2016
github.com/kofno/crystal_av
ClamAV bindings for Crystal
Installation
# Add this to your shard.yml
dependencies:
crystal_av:
github: kofno/crystal_av
branch: mastermaster is a branch, not a release, so this tracks it rather than pinning a version.
Then run:
shards installshard.yml
- Crystal
- no constraint declared
- License
- GPL 3.0
- Author
- Ryan L. Bell
Dependencies
This version declares no dependencies.
README
crystal_av
ClamAV bindings for Crystal.
Installation
You'll need ClamAV installed.
On OS X:
$> brew update
$> brew install clamav
TODO: Installation instructions for other operation systems.
Add this to your application's shard.yml:
dependencies:
crystal_av:
github: kofno/crystal_av
Usage
Before you can use ClamAV, you'll need to run the freshclam utility. This
installs (or updates) the ClamAV database.
require "crystal_av"
You can scan a file (or many files) using the Engine class.
CrystalAV::Engine.load do |engine|
infected_file = File.expand_path(
"./fixtures/virus.txt",
File.dirname(__FILE__)
)
results = engine.scan(infected_file)
puts results.virus? #=> true
puts results.virus_name #=> Eicar-Test-Signature
end
Or you can use the low level bindings directly.
include CrystalAV
puts LibClamAV.cl_init(0)
engine = LibClamAV.cl_engine_new
puts engine
puts typeof(engine)
dbpath = LibClamAV.cl_retdbdir
puts String.new(dbpath)
signo = 0
signo_ptr = pointerof(signo)
puts LibClamAV.cl_load(dbpath, engine, signo_ptr, LibClamAV::CL_DB_STDOPT)
puts LibClamAV.cl_engine_compile(engine)
puts LibClamAV.cl_scanfile(
"/Users/you/Downloads/clamdoc.pdf",
out not_a_virus,
nil,
engine,
LibClamAV::CL_SCAN_STDOPT
)
puts LibClamAV.cl_scanfile(
"/Users/you/Downloads/example_virus.txt",
out virname,
nil,
engine,
LibClamAV::CL_SCAN_STDOPT
)
puts String.new(virname)
puts LibClamAV.cl_engine_free(engine)
TODO: Document bindings wrapper.
Contributing
- Fork it ( https://github.com/kofno/crystal_av/fork )
- Create your feature branch (git checkout -b my-new-feature)
- Commit your changes (git commit -am 'Add some feature')
- Push to the branch (git push origin my-new-feature)
- Create a new Pull Request
Contributors
- kofno Ryan L. Bell - creator, maintainer
Documentation
Built from the current release. The first visit to a release nobody has asked for starts its build.
Links
This branch
- Branch
master- Seen
- Jul 23, 2016
- Indexed
- yes
Dependents
No indexed shard depends on this one yet.
Repository
github.com/kofno/crystal_av
Metadata
- Created
- Aug 12, 2026
- Updated
- Aug 13, 2026
- Synced
- Aug 13, 2026
- Versions
- 1