• Stars
    star
    3
  • Rank 3,847,877 (Top 78 %)
  • Language
    Crystal
  • License
    Other
  • Created almost 8 years ago
  • Updated almost 8 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

ClamAV bindings for Crystal

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

  1. Fork it ( https://github.com/kofno/crystal_av/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Contributors

  • kofno Ryan L. Bell - creator, maintainer

More Repositories

1

land-of-lisp

Me working through the Land of Lisp book.
Common Lisp
43
star
2

BasicLambda

An example of writing an AWS Lambda function in Purescript
PureScript
37
star
3

jsonous

Type safe JSON decoding for JavaScript
TypeScript
24
star
4

kemal_elm_chat

Simple chat server written in Crystal (Kemal) w/ an Elm front end.
JavaScript
14
star
5

purescript-aws-lambda

Write your AWS Lambda in PureScript!
PureScript
9
star
6

Sparrowhawk

MRI friendly warbler replacement
Ruby
6
star
7

purescript-spacemacs

Purescript configuration layer for spacemacs
Emacs Lisp
6
star
8

pdfcraft

A cute little Rails plugin for rendering PDFs
Ruby
5
star
9

taskarian

A future implementation in TypeScript
TypeScript
4
star
10

festive-possum

FP typescript libraries that I write to use in projects
HTML
4
star
11

resulty

A disjunction implementation in TypeScript.
TypeScript
4
star
12

pouchout-example

Knockout.js & Pouchdb & Couchdb & Todos
CSS
3
star
13

purescript-ical

ICal parser written in Purescript
PureScript
3
star
14

HangmanRails

Hangman... written in Ruby on Rails
CSS
3
star
15

maybeasy

Maybe implemented in TypeScript
TypeScript
3
star
16

pixi-dust

Javascript games experiments (using Pixi.js and other tools)
JavaScript
2
star
17

hangman-purescript

Web based hangman game, written in Purescript. You know, for fun.
JavaScript
2
star
18

haskell-ical

ICal parser
Haskell
1
star
19

purescript-gm

Purescript bindings to the gm node module (GraphicsMagick and ImageMagick)
PureScript
1
star
20

elm-memory-rip-off

Elm memory game stolen from https://alpacaaa.net/blog/post/elm-memory-game-from-scratch/
JavaScript
1
star
21

hullo

Chat rooms... for the web...
Ruby
1
star
22

stack-ts

Implementation of immutable stack data structure
TypeScript
1
star
23

NabuRewrite

An experiment in Elm and Couchdb
JavaScript
1
star
24

gaia

Read environment variables in a type safe way
TypeScript
1
star
25

ajaxian

Ajax requests with better error handling
TypeScript
1
star
26

freshy_filter_chain

Makes filter chains plugin friendly
Ruby
1
star
27

strident-quail

GraphQL Server in Haskell
Haskell
1
star
28

kofno.github.com

Blogging on github
Haskell
1
star
29

cryroutines

Examples of fibers and channels in crystal, based on Go examples.
Crystal
1
star
30

IntroToCrytalPrez

Presentation for Intro to Crystal
Elm
1
star
31

time-pikinator

React time picker
JavaScript
1
star