warp-clamav 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +6 -0
- data/ChangeLog +18 -0
- data/README.rdoc +115 -0
- data/VERSION +1 -0
- data/clamav.gemspec +70 -0
- data/ext/clamav/clamav.c +207 -0
- data/ext/clamav/const.h +93 -0
- data/ext/clamav/extconf.rb +9 -0
- data/rakefile +54 -0
- data/spec/clamav-testfiles/clam-p.rar +0 -0
- data/spec/clamav-testfiles/clam-ph.rar +0 -0
- data/spec/clamav-testfiles/clam-v2.rar +0 -0
- data/spec/clamav-testfiles/clam-v3.rar +0 -0
- data/spec/clamav-testfiles/clam.cab +0 -0
- data/spec/clamav-testfiles/clam.exe +0 -0
- data/spec/clamav-testfiles/clam.exe.bz2 +0 -0
- data/spec/clamav-testfiles/clam.zip +0 -0
- data/spec/clamav-testfiles/eicar.com +1 -0
- data/spec/clamav-testfiles/jquery.tooltip.pack.js +15 -0
- data/spec/clamav-testfiles/multi.zip +0 -0
- data/spec/clamav-testfiles/program.doc +0 -0
- data/spec/clamav-testfiles/robots.txt +2 -0
- data/spec/clamav-testfiles/test.rar +0 -0
- data/spec/clamav-testfiles/test.txt +1 -0
- data/spec/clamav-testfiles//320/237/321/200/320/276/320/263/321/200/320/260/320/274/320/274/320/260.doc +0 -0
- data/spec/spec +4 -0
- data/spec/spec_helper.rb +4 -0
- data/spec/unit/clamav_spec.rb +128 -0
- data/tools/rakehelp.rb +117 -0
- metadata +87 -0
data/ChangeLog
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
ChangeLog
|
2
|
+
|
3
|
+
Tue Apr 07 20:57:00 MSK 2009
|
4
|
+
----------------------------
|
5
|
+
V 0.3.0
|
6
|
+
* Update to ClamAV-0.95
|
7
|
+
* Detailed README.rdoc
|
8
|
+
+ ClamAV.new optional parameters options, db_options
|
9
|
+
+ ClamAV#scanfile optional parameter options
|
10
|
+
+ ClamAV#reload - reload virus database
|
11
|
+
+ ClamAV#setlimit, #getlimit, #setstring, #getstring
|
12
|
+
|
13
|
+
Sat Sep 06 15:43:00 MSK 2008
|
14
|
+
----------------------------
|
15
|
+
V 0.2.2
|
16
|
+
* Update to ClamAV-0.94
|
17
|
+
* Add ChangeLog
|
18
|
+
|
data/README.rdoc
ADDED
@@ -0,0 +1,115 @@
|
|
1
|
+
= ClamAV
|
2
|
+
|
3
|
+
ClamAV Ruby binding gem.
|
4
|
+
|
5
|
+
== INSTALL:
|
6
|
+
|
7
|
+
$ sudo gem install clamav
|
8
|
+
|
9
|
+
== REQUIREMENTS:
|
10
|
+
|
11
|
+
clamav >= 0.95, libclamav6, libclamav-dev
|
12
|
+
|
13
|
+
== SYNOPSIS:
|
14
|
+
|
15
|
+
== ClamAV.new([options[, db_options]])
|
16
|
+
|
17
|
+
return:
|
18
|
+
ClamAV instance
|
19
|
+
|
20
|
+
Options:
|
21
|
+
|
22
|
+
* CL_SCAN_STDOPT (default) equal CL_SCAN_ARCHIVE | CL_SCAN_MAIL | CL_SCAN_OLE2 | CL_SCAN_PDF | CL_SCAN_HTML | CL_SCAN_PE | CL_SCAN_ALGORITHMIC | CL_SCAN_ELF
|
23
|
+
* CL_SCAN_RAW
|
24
|
+
* CL_SCAN_BLOCKENCRYPTED
|
25
|
+
* CL_SCAN_BLOCKBROKEN
|
26
|
+
* CL_SCAN_MAILURL
|
27
|
+
* CL_SCAN_PHISHING_BLOCKSSL
|
28
|
+
* CL_SCAN_PHISHING_BLOCKCLOAK
|
29
|
+
* CL_SCAN_STRUCTURED
|
30
|
+
* CL_SCAN_STRUCTURED_SSN_NORMAL
|
31
|
+
* CL_SCAN_STRUCTURED_SSN_STRIPPED
|
32
|
+
* CL_SCAN_PARTIAL_MESSAGE
|
33
|
+
* CL_SCAN_HEURISTIC_PRECEDENCE
|
34
|
+
|
35
|
+
DB options:
|
36
|
+
|
37
|
+
* CL_DB_STDOPT (default) equal CL_DB_PHISHING | CL_DB_PHISHING_URLS
|
38
|
+
* CL_DB_PUA
|
39
|
+
* CL_DB_CVDNOTMP
|
40
|
+
* CL_DB_PUA_MODE
|
41
|
+
* CL_DB_PUA_INCLUDE
|
42
|
+
* CL_DB_PUA_EXCLUDE
|
43
|
+
|
44
|
+
See ClamAV documentation and sources for details.
|
45
|
+
|
46
|
+
|
47
|
+
|
48
|
+
== ClamAV#scanfile(filename[, options])
|
49
|
+
options default CL_SCAN_STDOPT
|
50
|
+
|
51
|
+
return:
|
52
|
+
virusname or ClamAV returncode(Fixnum)
|
53
|
+
|
54
|
+
|
55
|
+
|
56
|
+
== ClamAV#reload()
|
57
|
+
reload virus db if changed
|
58
|
+
|
59
|
+
return:
|
60
|
+
1 - reload successful
|
61
|
+
0 - reload unnecessary
|
62
|
+
|
63
|
+
|
64
|
+
|
65
|
+
== ClamAV#setlimit(param, value)
|
66
|
+
|
67
|
+
== ClamAV#getlimit(param)
|
68
|
+
|
69
|
+
== ClamAV#setstring(param, value)
|
70
|
+
|
71
|
+
== ClamAV#getstring(param)
|
72
|
+
get or set default values internal settings.
|
73
|
+
|
74
|
+
Params:
|
75
|
+
|
76
|
+
* CL_ENGINE_MAX_SCANSIZE, /* integer */
|
77
|
+
* CL_ENGINE_MAX_FILESIZE, /* integer */
|
78
|
+
* CL_ENGINE_MAX_RECURSION, /* integer */
|
79
|
+
* CL_ENGINE_MAX_FILES, /* integer */
|
80
|
+
* CL_ENGINE_MIN_CC_COUNT, /* integer */
|
81
|
+
* CL_ENGINE_MIN_SSN_COUNT, /* integer */
|
82
|
+
* CL_ENGINE_PUA_CATEGORIES, /* string */
|
83
|
+
* CL_ENGINE_DB_OPTIONS, /* integer */
|
84
|
+
* CL_ENGINE_DB_VERSION, /* integer */
|
85
|
+
* CL_ENGINE_DB_TIME, /* integer unixtime (readonly) */
|
86
|
+
* CL_ENGINE_AC_ONLY, /* integer */
|
87
|
+
* CL_ENGINE_AC_MINDEPTH, /* integer */
|
88
|
+
* CL_ENGINE_AC_MAXDEPTH, /* integer */
|
89
|
+
* CL_ENGINE_TMPDIR, /* string */
|
90
|
+
* CL_ENGINE_KEEPTMP /* integer */
|
91
|
+
|
92
|
+
See ClamAV documentation and sources for details.
|
93
|
+
|
94
|
+
|
95
|
+
|
96
|
+
== ClamaAV#signo()
|
97
|
+
get loaded signatures count
|
98
|
+
|
99
|
+
|
100
|
+
|
101
|
+
== LICENSE:
|
102
|
+
|
103
|
+
GNU General Public License
|
104
|
+
|
105
|
+
Copyright(c) 2008-2009 Alexander Oryol <eagle.alex@gmail.com>
|
106
|
+
|
107
|
+
|
108
|
+
|
109
|
+
== THANKS:
|
110
|
+
|
111
|
+
Based on project clamavr-0.2.0
|
112
|
+
|
113
|
+
http://raa.ruby-lang.org/project/clamavr/
|
114
|
+
|
115
|
+
Copyright(c) 2003-2007 MoonWolf <moonwolf@moonwolf.com>
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.3.1
|
data/clamav.gemspec
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run `rake gemspec`
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{clamav}
|
8
|
+
s.version = "0.3.1"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Alexander Oryol"]
|
12
|
+
s.date = %q{2009-10-16}
|
13
|
+
s.email = %q{eagle.alex@gmail.com}
|
14
|
+
s.extensions = ["ext/clamav/extconf.rb"]
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"ChangeLog",
|
17
|
+
"README.rdoc"
|
18
|
+
]
|
19
|
+
s.files = [
|
20
|
+
".gitignore",
|
21
|
+
"ChangeLog",
|
22
|
+
"README.rdoc",
|
23
|
+
"VERSION",
|
24
|
+
"clamav.gemspec",
|
25
|
+
"ext/clamav/clamav.c",
|
26
|
+
"ext/clamav/const.h",
|
27
|
+
"ext/clamav/extconf.rb",
|
28
|
+
"rakefile",
|
29
|
+
"spec/clamav-testfiles/clam-p.rar",
|
30
|
+
"spec/clamav-testfiles/clam-ph.rar",
|
31
|
+
"spec/clamav-testfiles/clam-v2.rar",
|
32
|
+
"spec/clamav-testfiles/clam-v3.rar",
|
33
|
+
"spec/clamav-testfiles/clam.cab",
|
34
|
+
"spec/clamav-testfiles/clam.exe",
|
35
|
+
"spec/clamav-testfiles/clam.exe.bz2",
|
36
|
+
"spec/clamav-testfiles/clam.zip",
|
37
|
+
"spec/clamav-testfiles/eicar.com",
|
38
|
+
"spec/clamav-testfiles/jquery.tooltip.pack.js",
|
39
|
+
"spec/clamav-testfiles/multi.zip",
|
40
|
+
"spec/clamav-testfiles/program.doc",
|
41
|
+
"spec/clamav-testfiles/robots.txt",
|
42
|
+
"spec/clamav-testfiles/test.rar",
|
43
|
+
"spec/clamav-testfiles/test.txt",
|
44
|
+
"spec/clamav-testfiles/\320\237\321\200\320\276\320\263\321\200\320\260\320\274\320\274\320\260.doc",
|
45
|
+
"spec/spec",
|
46
|
+
"spec/spec_helper.rb",
|
47
|
+
"spec/unit/clamav_spec.rb",
|
48
|
+
"tools/rakehelp.rb"
|
49
|
+
]
|
50
|
+
s.homepage = %q{http://github.com/eagleas/clamav}
|
51
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
52
|
+
s.require_paths = ["lib"]
|
53
|
+
s.rubyforge_project = %q{clamav}
|
54
|
+
s.rubygems_version = %q{1.3.5}
|
55
|
+
s.summary = %q{ClamAV Ruby bindings}
|
56
|
+
s.test_files = [
|
57
|
+
"spec/spec_helper.rb",
|
58
|
+
"spec/unit/clamav_spec.rb"
|
59
|
+
]
|
60
|
+
|
61
|
+
if s.respond_to? :specification_version then
|
62
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
63
|
+
s.specification_version = 3
|
64
|
+
|
65
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
66
|
+
else
|
67
|
+
end
|
68
|
+
else
|
69
|
+
end
|
70
|
+
end
|
data/ext/clamav/clamav.c
ADDED
@@ -0,0 +1,207 @@
|
|
1
|
+
#include <clamav.h>
|
2
|
+
#include <ruby.h>
|
3
|
+
|
4
|
+
static VALUE cClamAV;
|
5
|
+
|
6
|
+
struct ClamAV_R {
|
7
|
+
struct cl_engine *root;
|
8
|
+
int options;
|
9
|
+
int db_options;
|
10
|
+
struct cl_stat dbstat;
|
11
|
+
unsigned int signo;
|
12
|
+
};
|
13
|
+
|
14
|
+
static void clamavr_free(struct ClamAV_R *ptr) {
|
15
|
+
int ret;
|
16
|
+
ret = cl_engine_free(ptr->root);
|
17
|
+
if(ret != CL_SUCCESS) {
|
18
|
+
rb_raise(rb_eRuntimeError, "cl_engine_free() error: %s\n", cl_strerror(ret));
|
19
|
+
}
|
20
|
+
xfree(ptr);
|
21
|
+
}
|
22
|
+
|
23
|
+
static VALUE clamavr_new(argc, argv, klass)
|
24
|
+
int argc;
|
25
|
+
VALUE *argv;
|
26
|
+
VALUE klass;
|
27
|
+
{
|
28
|
+
const char *v_fname;
|
29
|
+
VALUE v_options;
|
30
|
+
VALUE v_db_options;
|
31
|
+
rb_scan_args(argc, argv, "02", &v_options, &v_db_options);
|
32
|
+
if(NIL_P(v_options)){
|
33
|
+
v_options = INT2FIX(CL_SCAN_STDOPT); /* default value */
|
34
|
+
}
|
35
|
+
if(NIL_P(v_db_options)){
|
36
|
+
v_db_options = INT2FIX(CL_DB_STDOPT); /* default value */
|
37
|
+
}
|
38
|
+
|
39
|
+
int ret;
|
40
|
+
ret = cl_init(FIX2INT(v_options));
|
41
|
+
if(ret != CL_SUCCESS) {
|
42
|
+
rb_raise(rb_eRuntimeError, "cl_init() error: %s\n", cl_strerror(ret));
|
43
|
+
}
|
44
|
+
struct ClamAV_R *ptr = ALLOC(struct ClamAV_R);
|
45
|
+
ptr->root = cl_engine_new();
|
46
|
+
if(ptr->root == NULL) {
|
47
|
+
rb_raise(rb_eRuntimeError, "cl_engine_new() error: %s\n", cl_strerror(ret));
|
48
|
+
};
|
49
|
+
|
50
|
+
/* save options */
|
51
|
+
ptr->options = v_options;
|
52
|
+
ptr->db_options = v_db_options;
|
53
|
+
|
54
|
+
ptr->signo = 0;
|
55
|
+
|
56
|
+
const char *dbdir;
|
57
|
+
dbdir = cl_retdbdir();
|
58
|
+
|
59
|
+
ret = cl_load(dbdir, ptr->root, &ptr->signo, FIX2INT(v_db_options));
|
60
|
+
if(ret != CL_SUCCESS) {
|
61
|
+
rb_raise(rb_eRuntimeError, "cl_load() error: %s\n", cl_strerror(ret));
|
62
|
+
}
|
63
|
+
|
64
|
+
memset(&ptr->dbstat, 0, sizeof(struct cl_stat));
|
65
|
+
cl_statinidir(dbdir, &ptr->dbstat);
|
66
|
+
|
67
|
+
ret = cl_engine_compile(ptr->root);
|
68
|
+
if(ret != CL_SUCCESS) {
|
69
|
+
rb_raise(rb_eRuntimeError, "cl_engine_compile() error: %s\n", cl_strerror(ret));
|
70
|
+
}
|
71
|
+
return Data_Wrap_Struct(klass, 0, clamavr_free, ptr);
|
72
|
+
}
|
73
|
+
|
74
|
+
static VALUE clamavr_initialize(VALUE self) {
|
75
|
+
return self;
|
76
|
+
}
|
77
|
+
|
78
|
+
static VALUE clamavr_setlimit(VALUE self, VALUE v_limit, VALUE v_value) {
|
79
|
+
Check_Type(v_limit, T_FIXNUM);
|
80
|
+
Check_Type(v_value, T_FIXNUM);
|
81
|
+
|
82
|
+
struct ClamAV_R *ptr;
|
83
|
+
Data_Get_Struct(self, struct ClamAV_R, ptr);
|
84
|
+
|
85
|
+
int ret;
|
86
|
+
ret = cl_engine_set_num(ptr->root, FIX2INT(v_limit), FIX2INT(v_value));
|
87
|
+
if(ret != CL_SUCCESS) {
|
88
|
+
rb_raise(rb_eRuntimeError, "cl_engine_set_num() error: %s\n", cl_strerror(ret));
|
89
|
+
}
|
90
|
+
return INT2FIX(ret);
|
91
|
+
}
|
92
|
+
|
93
|
+
static VALUE clamavr_getlimit(VALUE self, VALUE v_limit) {
|
94
|
+
Check_Type(v_limit, T_FIXNUM);
|
95
|
+
|
96
|
+
struct ClamAV_R *ptr;
|
97
|
+
Data_Get_Struct(self, struct ClamAV_R, ptr);
|
98
|
+
|
99
|
+
int ret;
|
100
|
+
int err;
|
101
|
+
ret = cl_engine_get_num(ptr->root, FIX2INT(v_limit), &err);
|
102
|
+
if(err != CL_SUCCESS) {
|
103
|
+
rb_raise(rb_eRuntimeError, "cl_engine_get_num() error: %s\n", cl_strerror(err));
|
104
|
+
}
|
105
|
+
return INT2NUM(ret);
|
106
|
+
}
|
107
|
+
|
108
|
+
static VALUE clamavr_setstring(VALUE self, VALUE v_param, VALUE v_value) {
|
109
|
+
Check_Type(v_param, T_FIXNUM);
|
110
|
+
Check_Type(v_value, T_STRING);
|
111
|
+
|
112
|
+
struct ClamAV_R *ptr;
|
113
|
+
Data_Get_Struct(self, struct ClamAV_R, ptr);
|
114
|
+
|
115
|
+
int ret;
|
116
|
+
ret = cl_engine_set_str(ptr->root, FIX2INT(v_param), RSTRING(v_value)->ptr);
|
117
|
+
if(ret != CL_SUCCESS) {
|
118
|
+
rb_raise(rb_eRuntimeError, "cl_engine_set_str() error: %s\n", cl_strerror(ret));
|
119
|
+
}
|
120
|
+
return INT2FIX(ret);
|
121
|
+
}
|
122
|
+
|
123
|
+
static VALUE clamavr_getstring(VALUE self, VALUE v_param) {
|
124
|
+
Check_Type(v_param, T_FIXNUM);
|
125
|
+
struct ClamAV_R *ptr;
|
126
|
+
Data_Get_Struct(self, struct ClamAV_R, ptr);
|
127
|
+
const char *result;
|
128
|
+
int err;
|
129
|
+
result = cl_engine_get_str(ptr->root, FIX2INT(v_param), &err);
|
130
|
+
if(err != CL_SUCCESS) {
|
131
|
+
rb_raise(rb_eRuntimeError, "cl_engine_get_str() error: %s\n", cl_strerror(err));
|
132
|
+
}
|
133
|
+
if(result == NULL){
|
134
|
+
return Qnil;
|
135
|
+
}
|
136
|
+
return rb_str_new2(result);
|
137
|
+
}
|
138
|
+
|
139
|
+
static VALUE clamavr_signo(VALUE self) {
|
140
|
+
struct ClamAV_R *ptr;
|
141
|
+
Data_Get_Struct(self, struct ClamAV_R, ptr);
|
142
|
+
return UINT2NUM(ptr->signo);
|
143
|
+
}
|
144
|
+
|
145
|
+
static VALUE clamavr_scanfile(argc, argv, klass)
|
146
|
+
int argc;
|
147
|
+
VALUE *argv;
|
148
|
+
VALUE klass;
|
149
|
+
{
|
150
|
+
struct ClamAV_R *ptr;
|
151
|
+
Data_Get_Struct(klass, struct ClamAV_R, ptr);
|
152
|
+
|
153
|
+
const char *v_fname;
|
154
|
+
VALUE v_options;
|
155
|
+
rb_scan_args(argc, argv, "11", &v_fname, &v_options);
|
156
|
+
if(NIL_P(v_options)){
|
157
|
+
v_options = ptr->options; /* stored value */
|
158
|
+
}
|
159
|
+
|
160
|
+
Check_Type(v_fname, T_STRING);
|
161
|
+
Check_Type(v_options, T_FIXNUM);
|
162
|
+
|
163
|
+
int ret;
|
164
|
+
const char *virname;
|
165
|
+
|
166
|
+
ret = cl_scanfile(RSTRING(v_fname)->ptr, &virname, NULL, ptr->root, FIX2INT(v_options));
|
167
|
+
if (ret == CL_VIRUS) {
|
168
|
+
return rb_str_new2(virname);
|
169
|
+
} else {
|
170
|
+
return INT2FIX(ret);
|
171
|
+
}
|
172
|
+
}
|
173
|
+
|
174
|
+
static VALUE clamavr_dbreload(VALUE self) {
|
175
|
+
struct ClamAV_R *ptr;
|
176
|
+
Data_Get_Struct(self, struct ClamAV_R, ptr);
|
177
|
+
|
178
|
+
int state;
|
179
|
+
state = cl_statchkdir(&ptr->dbstat);
|
180
|
+
if(state == 1) {
|
181
|
+
const char *dbdir;
|
182
|
+
dbdir = cl_retdbdir();
|
183
|
+
int ret;
|
184
|
+
ret = cl_load(dbdir, ptr->root, &ptr->signo, FIX2INT(ptr->db_options));
|
185
|
+
if(ret != CL_SUCCESS) {
|
186
|
+
rb_raise(rb_eRuntimeError, "cl_load() error: %s\n", cl_strerror(ret));
|
187
|
+
}
|
188
|
+
cl_statfree(&ptr->dbstat);
|
189
|
+
cl_statinidir(dbdir, &ptr->dbstat);
|
190
|
+
}
|
191
|
+
return INT2FIX(state);
|
192
|
+
}
|
193
|
+
|
194
|
+
void Init_clamav() {
|
195
|
+
cClamAV = rb_define_class("ClamAV", rb_cObject);
|
196
|
+
rb_define_singleton_method(cClamAV, "new", clamavr_new, -1);
|
197
|
+
rb_define_method(cClamAV, "initialize", clamavr_initialize, 0);
|
198
|
+
rb_define_method(cClamAV, "scanfile", clamavr_scanfile, -1);
|
199
|
+
rb_define_method(cClamAV, "signo", clamavr_signo, 0);
|
200
|
+
rb_define_method(cClamAV, "setlimit", clamavr_setlimit, 2);
|
201
|
+
rb_define_method(cClamAV, "getlimit", clamavr_getlimit, 1);
|
202
|
+
rb_define_method(cClamAV, "setstring", clamavr_setstring, 2);
|
203
|
+
rb_define_method(cClamAV, "getstring", clamavr_getstring, 1);
|
204
|
+
rb_define_method(cClamAV, "reload", clamavr_dbreload, 0);
|
205
|
+
|
206
|
+
#include <const.h>
|
207
|
+
}
|
data/ext/clamav/const.h
ADDED
@@ -0,0 +1,93 @@
|
|
1
|
+
/* return codes */
|
2
|
+
|
3
|
+
/* libclamav specific */
|
4
|
+
rb_define_const(cClamAV, "CL_CLEAN", INT2FIX(CL_CLEAN));
|
5
|
+
rb_define_const(cClamAV, "CL_SUCCESS", INT2FIX(CL_SUCCESS));
|
6
|
+
rb_define_const(cClamAV, "CL_VIRUS", INT2FIX(CL_VIRUS));
|
7
|
+
rb_define_const(cClamAV, "CL_ENULLARG", INT2FIX(CL_ENULLARG));
|
8
|
+
rb_define_const(cClamAV, "CL_EARG", INT2FIX(CL_EARG));
|
9
|
+
rb_define_const(cClamAV, "CL_EMALFDB", INT2FIX(CL_EMALFDB));
|
10
|
+
rb_define_const(cClamAV, "CL_ECVD", INT2FIX(CL_ECVD));
|
11
|
+
rb_define_const(cClamAV, "CL_EVERIFY", INT2FIX(CL_EVERIFY));
|
12
|
+
rb_define_const(cClamAV, "CL_EUNPACK", INT2FIX(CL_EUNPACK));
|
13
|
+
|
14
|
+
/* I/O and memory errors */
|
15
|
+
rb_define_const(cClamAV, "CL_EOPEN", INT2FIX(CL_EOPEN));
|
16
|
+
rb_define_const(cClamAV, "CL_ECREAT", INT2FIX(CL_ECREAT));
|
17
|
+
rb_define_const(cClamAV, "CL_EUNLINK", INT2FIX(CL_EUNLINK));
|
18
|
+
rb_define_const(cClamAV, "CL_ESTAT", INT2FIX(CL_ESTAT));
|
19
|
+
rb_define_const(cClamAV, "CL_EREAD", INT2FIX(CL_EREAD));
|
20
|
+
rb_define_const(cClamAV, "CL_ESEEK", INT2FIX(CL_ESEEK));
|
21
|
+
rb_define_const(cClamAV, "CL_EWRITE", INT2FIX(CL_EWRITE));
|
22
|
+
rb_define_const(cClamAV, "CL_EDUP", INT2FIX(CL_EDUP));
|
23
|
+
rb_define_const(cClamAV, "CL_EACCES", INT2FIX(CL_EACCES));
|
24
|
+
rb_define_const(cClamAV, "CL_ETMPFILE", INT2FIX(CL_ETMPFILE));
|
25
|
+
rb_define_const(cClamAV, "CL_ETMPDIR", INT2FIX(CL_ETMPDIR));
|
26
|
+
rb_define_const(cClamAV, "CL_EMAP", INT2FIX(CL_EMAP));
|
27
|
+
rb_define_const(cClamAV, "CL_EMEM", INT2FIX(CL_EMEM));
|
28
|
+
rb_define_const(cClamAV, "CL_ETIMEOUT", INT2FIX(CL_ETIMEOUT));
|
29
|
+
|
30
|
+
/* internal (not reported outside libclamav) */
|
31
|
+
rb_define_const(cClamAV, "CL_BREAK", INT2FIX(CL_BREAK));
|
32
|
+
rb_define_const(cClamAV, "CL_EMAXREC", INT2FIX(CL_EMAXREC));
|
33
|
+
rb_define_const(cClamAV, "CL_EMAXSIZE", INT2FIX(CL_EMAXSIZE));
|
34
|
+
rb_define_const(cClamAV, "CL_EMAXFILES", INT2FIX(CL_EMAXFILES));
|
35
|
+
rb_define_const(cClamAV, "CL_EFORMAT", INT2FIX(CL_EFORMAT));
|
36
|
+
|
37
|
+
/* db options */
|
38
|
+
rb_define_const(cClamAV, "CL_DB_PHISHING", INT2FIX(CL_DB_PHISHING));
|
39
|
+
rb_define_const(cClamAV, "CL_DB_PHISHING_URLS", INT2FIX(CL_DB_PHISHING_URLS));
|
40
|
+
rb_define_const(cClamAV, "CL_DB_PUA", INT2FIX(CL_DB_PUA));
|
41
|
+
rb_define_const(cClamAV, "CL_DB_CVDNOTMP", INT2FIX(CL_DB_CVDNOTMP));
|
42
|
+
rb_define_const(cClamAV, "CL_DB_OFFICIAL", INT2FIX(CL_DB_OFFICIAL)); /* internal */
|
43
|
+
rb_define_const(cClamAV, "CL_DB_PUA_MODE", INT2FIX(CL_DB_PUA_MODE));
|
44
|
+
rb_define_const(cClamAV, "CL_DB_PUA_INCLUDE", INT2FIX(CL_DB_PUA_INCLUDE));
|
45
|
+
rb_define_const(cClamAV, "CL_DB_PUA_EXCLUDE", INT2FIX(CL_DB_PUA_EXCLUDE));
|
46
|
+
rb_define_const(cClamAV, "CL_DB_COMPILED", INT2FIX(CL_DB_COMPILED)); /* internal */
|
47
|
+
|
48
|
+
/* recommended db settings */
|
49
|
+
rb_define_const(cClamAV, "CL_DB_STDOPT", INT2FIX(CL_DB_STDOPT));
|
50
|
+
|
51
|
+
/* scan options */
|
52
|
+
rb_define_const(cClamAV, "CL_SCAN_RAW", INT2FIX(CL_SCAN_RAW));
|
53
|
+
rb_define_const(cClamAV, "CL_SCAN_ARCHIVE", INT2FIX(CL_SCAN_ARCHIVE));
|
54
|
+
rb_define_const(cClamAV, "CL_SCAN_MAIL", INT2FIX(CL_SCAN_MAIL));
|
55
|
+
rb_define_const(cClamAV, "CL_SCAN_OLE2", INT2FIX(CL_SCAN_OLE2));
|
56
|
+
rb_define_const(cClamAV, "CL_SCAN_BLOCKENCRYPTED", INT2FIX(CL_SCAN_BLOCKENCRYPTED));
|
57
|
+
rb_define_const(cClamAV, "CL_SCAN_HTML", INT2FIX(CL_SCAN_HTML));
|
58
|
+
rb_define_const(cClamAV, "CL_SCAN_PE", INT2FIX(CL_SCAN_PE));
|
59
|
+
rb_define_const(cClamAV, "CL_SCAN_BLOCKBROKEN", INT2FIX(CL_SCAN_BLOCKBROKEN));
|
60
|
+
rb_define_const(cClamAV, "CL_SCAN_MAILURL", INT2FIX(CL_SCAN_MAILURL));
|
61
|
+
rb_define_const(cClamAV, "CL_SCAN_BLOCKMAX", INT2FIX(CL_SCAN_BLOCKMAX)); /* ignored */
|
62
|
+
rb_define_const(cClamAV, "CL_SCAN_ALGORITHMIC", INT2FIX(CL_SCAN_ALGORITHMIC));
|
63
|
+
rb_define_const(cClamAV, "CL_SCAN_PHISHING_BLOCKSSL", INT2FIX(CL_SCAN_PHISHING_BLOCKSSL)); /* ssl mismatches, not ssl by itself */
|
64
|
+
rb_define_const(cClamAV, "CL_SCAN_PHISHING_BLOCKCLOAK", INT2FIX(CL_SCAN_PHISHING_BLOCKCLOAK));
|
65
|
+
rb_define_const(cClamAV, "CL_SCAN_ELF", INT2FIX(CL_SCAN_ELF));
|
66
|
+
rb_define_const(cClamAV, "CL_SCAN_PDF", INT2FIX(CL_SCAN_PDF));
|
67
|
+
rb_define_const(cClamAV, "CL_SCAN_STRUCTURED", INT2FIX(CL_SCAN_STRUCTURED));
|
68
|
+
rb_define_const(cClamAV, "CL_SCAN_STRUCTURED_SSN_NORMAL", INT2FIX(CL_SCAN_STRUCTURED_SSN_NORMAL));
|
69
|
+
rb_define_const(cClamAV, "CL_SCAN_STRUCTURED_SSN_STRIPPED", INT2FIX(CL_SCAN_STRUCTURED_SSN_STRIPPED));
|
70
|
+
rb_define_const(cClamAV, "CL_SCAN_PARTIAL_MESSAGE", INT2FIX(CL_SCAN_PARTIAL_MESSAGE));
|
71
|
+
rb_define_const(cClamAV, "CL_SCAN_HEURISTIC_PRECEDENCE", INT2FIX(CL_SCAN_HEURISTIC_PRECEDENCE));
|
72
|
+
|
73
|
+
/* recommended scan settings */
|
74
|
+
rb_define_const(cClamAV, "CL_SCAN_STDOPT", INT2FIX(CL_SCAN_STDOPT));
|
75
|
+
|
76
|
+
rb_define_const(cClamAV, "CL_INIT_DEFAULT", INT2FIX(CL_INIT_DEFAULT));
|
77
|
+
|
78
|
+
rb_define_const(cClamAV, "CL_ENGINE_MAX_SCANSIZE", INT2FIX(CL_ENGINE_MAX_SCANSIZE));
|
79
|
+
rb_define_const(cClamAV, "CL_ENGINE_MAX_FILESIZE", INT2FIX(CL_ENGINE_MAX_FILESIZE));
|
80
|
+
rb_define_const(cClamAV, "CL_ENGINE_MAX_RECURSION", INT2FIX(CL_ENGINE_MAX_RECURSION));
|
81
|
+
rb_define_const(cClamAV, "CL_ENGINE_MAX_FILES", INT2FIX(CL_ENGINE_MAX_FILES));
|
82
|
+
rb_define_const(cClamAV, "CL_ENGINE_MIN_CC_COUNT", INT2FIX(CL_ENGINE_MIN_CC_COUNT));
|
83
|
+
rb_define_const(cClamAV, "CL_ENGINE_MIN_SSN_COUNT", INT2FIX(CL_ENGINE_MIN_SSN_COUNT));
|
84
|
+
rb_define_const(cClamAV, "CL_ENGINE_PUA_CATEGORIES", INT2FIX(CL_ENGINE_PUA_CATEGORIES));
|
85
|
+
rb_define_const(cClamAV, "CL_ENGINE_DB_OPTIONS", INT2FIX(CL_ENGINE_DB_OPTIONS));
|
86
|
+
rb_define_const(cClamAV, "CL_ENGINE_DB_VERSION", INT2FIX(CL_ENGINE_DB_VERSION));
|
87
|
+
rb_define_const(cClamAV, "CL_ENGINE_DB_TIME", INT2FIX(CL_ENGINE_DB_TIME));
|
88
|
+
rb_define_const(cClamAV, "CL_ENGINE_AC_ONLY", INT2FIX(CL_ENGINE_AC_ONLY));
|
89
|
+
rb_define_const(cClamAV, "CL_ENGINE_AC_MINDEPTH", INT2FIX(CL_ENGINE_AC_MINDEPTH));
|
90
|
+
rb_define_const(cClamAV, "CL_ENGINE_AC_MAXDEPTH", INT2FIX(CL_ENGINE_AC_MAXDEPTH));
|
91
|
+
rb_define_const(cClamAV, "CL_ENGINE_TMPDIR", INT2FIX(CL_ENGINE_TMPDIR));
|
92
|
+
rb_define_const(cClamAV, "CL_ENGINE_KEEPTMP", INT2FIX(CL_ENGINE_KEEPTMP));
|
93
|
+
|
data/rakefile
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
require 'rake/clean'
|
4
|
+
require 'rake/gempackagetask'
|
5
|
+
require 'tools/rakehelp'
|
6
|
+
require 'spec/rake/spectask'
|
7
|
+
|
8
|
+
setup_extension('clamav', 'clamav')
|
9
|
+
|
10
|
+
desc "Compile native extension"
|
11
|
+
task :compile => [:clamav]
|
12
|
+
|
13
|
+
task :default => [:compile, :spec]
|
14
|
+
|
15
|
+
Spec::Rake::SpecTask.new do |task|
|
16
|
+
task.libs << 'spec'
|
17
|
+
task.spec_files = Dir.glob( 'spec/**/*_spec.rb' )
|
18
|
+
task.verbose = true
|
19
|
+
end
|
20
|
+
|
21
|
+
begin
|
22
|
+
require 'jeweler'
|
23
|
+
Jeweler::Tasks.new do |gemspec|
|
24
|
+
gemspec.name = "warp-clamav"
|
25
|
+
gemspec.author = "Alexander Oryol"
|
26
|
+
gemspec.email = "eagle.alex@gmail.com"
|
27
|
+
gemspec.summary = "ClamAV Ruby bindings"
|
28
|
+
gemspec.homepage = "http://github.com/eagleas/clamav"
|
29
|
+
gemspec.rubyforge_project = 'clamav'
|
30
|
+
gemspec.require_path = 'lib'
|
31
|
+
|
32
|
+
if RUBY_PLATFORM.match("win32")
|
33
|
+
gemspec.platform = Gem::Platform::WIN32
|
34
|
+
else
|
35
|
+
gemspec.platform = Gem::Platform::RUBY
|
36
|
+
gemspec.extensions = Dir.glob( 'ext/**/extconf.rb' )
|
37
|
+
end
|
38
|
+
end
|
39
|
+
Jeweler::GemcutterTasks.new
|
40
|
+
rescue LoadError
|
41
|
+
puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
|
42
|
+
end
|
43
|
+
|
44
|
+
task :package => [:clean, :compile, :spec]
|
45
|
+
|
46
|
+
setup_clean ["ext/clamav/*.{so,o}", "ext/clamav/Makefile", "lib/clamav.so", "pkg", "*.gem"]
|
47
|
+
|
48
|
+
task :install => [:default, :package] do
|
49
|
+
sh %{ sudo gem install pkg/clamav-#{GEM_VERSION}.gem }
|
50
|
+
end
|
51
|
+
|
52
|
+
task :uninstall do
|
53
|
+
sh %{ sudo gem uninstall clamav }
|
54
|
+
end
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1 @@
|
|
1
|
+
X5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*
|
@@ -0,0 +1,15 @@
|
|
1
|
+
/*
|
2
|
+
* jQuery Tooltip plugin 1.3
|
3
|
+
*
|
4
|
+
* http://bassistance.de/jquery-plugins/jquery-plugin-tooltip/
|
5
|
+
* http://docs.jquery.com/Plugins/Tooltip
|
6
|
+
*
|
7
|
+
* Copyright (c) 2006 - 2008 Jörn Zaefferer
|
8
|
+
*
|
9
|
+
* $Id: jquery.tooltip.js 5741 2008-06-21 15:22:16Z joern.zaefferer $
|
10
|
+
*
|
11
|
+
* Dual licensed under the MIT and GPL licenses:
|
12
|
+
* http://www.opensource.org/licenses/mit-license.php
|
13
|
+
* http://www.gnu.org/licenses/gpl.html
|
14
|
+
*/
|
15
|
+
eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}(';(8($){j e={},9,m,B,A=$.2u.2g&&/29\\s(5\\.5|6\\.)/.1M(1H.2t),M=12;$.k={w:12,1h:{Z:25,r:12,1d:19,X:"",G:15,E:15,16:"k"},2s:8(){$.k.w=!$.k.w}};$.N.1v({k:8(a){a=$.1v({},$.k.1h,a);1q(a);g 2.F(8(){$.1j(2,"k",a);2.11=e.3.n("1g");2.13=2.m;$(2).24("m");2.22=""}).21(1e).1U(q).1S(q)},H:A?8(){g 2.F(8(){j b=$(2).n(\'Y\');4(b.1J(/^o\\(["\']?(.*\\.1I)["\']?\\)$/i)){b=1F.$1;$(2).n({\'Y\':\'1D\',\'1B\':"2r:2q.2m.2l(2j=19, 2i=2h, 1p=\'"+b+"\')"}).F(8(){j a=$(2).n(\'1o\');4(a!=\'2f\'&&a!=\'1u\')$(2).n(\'1o\',\'1u\')})}})}:8(){g 2},1l:A?8(){g 2.F(8(){$(2).n({\'1B\':\'\',Y:\'\'})})}:8(){g 2},1x:8(){g 2.F(8(){$(2)[$(2).D()?"l":"q"]()})},o:8(){g 2.1k(\'28\')||2.1k(\'1p\')}});8 1q(a){4(e.3)g;e.3=$(\'<t 16="\'+a.16+\'"><10></10><t 1i="f"></t><t 1i="o"></t></t>\').27(K.f).q();4($.N.L)e.3.L();e.m=$(\'10\',e.3);e.f=$(\'t.f\',e.3);e.o=$(\'t.o\',e.3)}8 7(a){g $.1j(a,"k")}8 1f(a){4(7(2).Z)B=26(l,7(2).Z);p l();M=!!7(2).M;$(K.f).23(\'W\',u);u(a)}8 1e(){4($.k.w||2==9||(!2.13&&!7(2).U))g;9=2;m=2.13;4(7(2).U){e.m.q();j a=7(2).U.1Z(2);4(a.1Y||a.1V){e.f.1c().T(a)}p{e.f.D(a)}e.f.l()}p 4(7(2).18){j b=m.1T(7(2).18);e.m.D(b.1R()).l();e.f.1c();1Q(j i=0,R;(R=b[i]);i++){4(i>0)e.f.T("<1P/>");e.f.T(R)}e.f.1x()}p{e.m.D(m).l();e.f.q()}4(7(2).1d&&$(2).o())e.o.D($(2).o().1O(\'1N://\',\'\')).l();p e.o.q();e.3.P(7(2).X);4(7(2).H)e.3.H();1f.1L(2,1K)}8 l(){B=S;4((!A||!$.N.L)&&7(9).r){4(e.3.I(":17"))e.3.Q().l().O(7(9).r,9.11);p e.3.I(\':1a\')?e.3.O(7(9).r,9.11):e.3.1G(7(9).r)}p{e.3.l()}u()}8 u(c){4($.k.w)g;4(c&&c.1W.1X=="1E"){g}4(!M&&e.3.I(":1a")){$(K.f).1b(\'W\',u)}4(9==S){$(K.f).1b(\'W\',u);g}e.3.V("z-14").V("z-1A");j b=e.3[0].1z;j a=e.3[0].1y;4(c){b=c.2o+7(9).E;a=c.2n+7(9).G;j d=\'1w\';4(7(9).2k){d=$(C).1r()-b;b=\'1w\'}e.3.n({E:b,14:d,G:a})}j v=z(),h=e.3[0];4(v.x+v.1s<h.1z+h.1n){b-=h.1n+20+7(9).E;e.3.n({E:b+\'1C\'}).P("z-14")}4(v.y+v.1t<h.1y+h.1m){a-=h.1m+20+7(9).G;e.3.n({G:a+\'1C\'}).P("z-1A")}}8 z(){g{x:$(C).2e(),y:$(C).2d(),1s:$(C).1r(),1t:$(C).2p()}}8 q(a){4($.k.w)g;4(B)2c(B);9=S;j b=7(2);8 J(){e.3.V(b.X).q().n("1g","")}4((!A||!$.N.L)&&b.r){4(e.3.I(\':17\'))e.3.Q().O(b.r,0,J);p e.3.Q().2b(b.r,J)}p J();4(7(2).H)e.3.1l()}})(2a);',62,155,'||this|parent|if|||settings|function|current||||||body|return|||var|tooltip|show|title|css|url|else|hide|fade||div|update||blocked|||viewport|IE|tID|window|html|left|each|top|fixPNG|is|complete|document|bgiframe|track|fn|fadeTo|addClass|stop|part|null|append|bodyHandler|removeClass|mousemove|extraClass|backgroundImage|delay|h3|tOpacity|false|tooltipText|right||id|animated|showBody|true|visible|unbind|empty|showURL|save|handle|opacity|defaults|class|data|attr|unfixPNG|offsetHeight|offsetWidth|position|src|createHelper|width|cx|cy|relative|extend|auto|hideWhenEmpty|offsetTop|offsetLeft|bottom|filter|px|none|OPTION|RegExp|fadeIn|navigator|png|match|arguments|apply|test|http|replace|br|for|shift|click|split|mouseout|jquery|target|tagName|nodeType|call||mouseover|alt|bind|removeAttr|200|setTimeout|appendTo|href|MSIE|jQuery|fadeOut|clearTimeout|scrollTop|scrollLeft|absolute|msie|crop|sizingMethod|enabled|positionLeft|AlphaImageLoader|Microsoft|pageY|pageX|height|DXImageTransform|progid|block|userAgent|browser'.split('|'),0,{}))
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1 @@
|
|
1
|
+
X5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*
|
Binary file
|
data/spec/spec
ADDED
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,128 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
+
|
3
|
+
class ClamAV
|
4
|
+
|
5
|
+
describe "ClamAV" do
|
6
|
+
|
7
|
+
FILES = {
|
8
|
+
'robots.txt' => CL_CLEAN,
|
9
|
+
'eicar.com' => 'Eicar-Test-Signature', # EICAR
|
10
|
+
'test.txt' => 'Eicar-Test-Signature', # EICAR in text/plain
|
11
|
+
'clam.cab' => 'ClamAV-Test-File',
|
12
|
+
'clam.exe' => 'ClamAV-Test-File',
|
13
|
+
'clam.exe.bz2' => 'ClamAV-Test-File',
|
14
|
+
'clam.zip' => 'ClamAV-Test-File',
|
15
|
+
'clam-v2.rar' => 'ClamAV-Test-File',
|
16
|
+
'clam-v3.rar' => 'ClamAV-Test-File',
|
17
|
+
'clam-p.rar' => CL_CLEAN, # encripted RAR
|
18
|
+
'clam-ph.rar' => CL_CLEAN, # encripted RAR with encrypted both file data and headers
|
19
|
+
'program.doc' => 'W97M.Class.EB',
|
20
|
+
'Программа.doc' => 'W97M.Class.EB', # filename in UTF-8
|
21
|
+
}
|
22
|
+
|
23
|
+
FILES_ENCRYPTED = {
|
24
|
+
'clam-p.rar' => 'Encrypted.RAR', # encripted RAR
|
25
|
+
'clam-ph.rar' => 'Encrypted.RAR', # encripted RAR with encrypted both file data and headers
|
26
|
+
}
|
27
|
+
|
28
|
+
describe "with default options" do
|
29
|
+
before(:all) do
|
30
|
+
@clam = ClamAV.new
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should be instance of Clamav" do
|
34
|
+
@clam.should be_instance_of(ClamAV)
|
35
|
+
end
|
36
|
+
|
37
|
+
|
38
|
+
FILES.each do |file, result|
|
39
|
+
it "should scan #{file} with result #{result.to_s}" do
|
40
|
+
@clam.scanfile(File.join(File.dirname(__FILE__), "../clamav-testfiles/", file)).should == result
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
FILES_ENCRYPTED.each do |file, result|
|
45
|
+
it "should scan encrypted #{file} with result #{result.to_s}" do
|
46
|
+
@clam.scanfile(File.join(File.dirname(__FILE__), "../clamav-testfiles/", file),
|
47
|
+
CL_SCAN_STDOPT | CL_SCAN_BLOCKENCRYPTED).should == result
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
it "should return signatures count" do
|
52
|
+
@clam.signo.should >= 538736 # on 7/04/09
|
53
|
+
end
|
54
|
+
|
55
|
+
it "should not reload db when fresh" do
|
56
|
+
@clam.reload.should == 0
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
60
|
+
|
61
|
+
describe "with custom options" do
|
62
|
+
|
63
|
+
before(:all) do
|
64
|
+
@clam = ClamAV.new(CL_SCAN_STDOPT | CL_SCAN_BLOCKENCRYPTED)
|
65
|
+
end
|
66
|
+
|
67
|
+
it "should scan encrypted file with detect" do
|
68
|
+
@clam.scanfile(File.join(File.dirname(__FILE__), "../clamav-testfiles/",
|
69
|
+
'clam-v3.rar')).should == 'ClamAV-Test-File'
|
70
|
+
end
|
71
|
+
|
72
|
+
it "should scan OLE2 file with not detect" do
|
73
|
+
@clam.scanfile(File.join(File.dirname(__FILE__), "../clamav-testfiles/", 'program.doc'),
|
74
|
+
CL_SCAN_RAW).should == CL_CLEAN
|
75
|
+
end
|
76
|
+
|
77
|
+
end
|
78
|
+
|
79
|
+
describe "with custom db options" do
|
80
|
+
|
81
|
+
before(:all) do
|
82
|
+
@clam = ClamAV.new(CL_SCAN_STDOPT, CL_DB_STDOPT | CL_DB_PUA)
|
83
|
+
end
|
84
|
+
|
85
|
+
it "should detect PUA" do
|
86
|
+
@clam.scanfile(File.join(File.dirname(__FILE__), "../clamav-testfiles/",
|
87
|
+
'jquery.tooltip.pack.js')).should == 'PUA.Script.Packed-2'
|
88
|
+
end
|
89
|
+
|
90
|
+
end
|
91
|
+
|
92
|
+
|
93
|
+
describe "limits" do
|
94
|
+
before(:each) do
|
95
|
+
@clam = ClamAV.new
|
96
|
+
end
|
97
|
+
|
98
|
+
it "should set limit" do
|
99
|
+
@clam.setlimit(CL_ENGINE_MAX_FILES, 1).should == CL_SUCCESS
|
100
|
+
end
|
101
|
+
|
102
|
+
it "should do not check archive with two files" do
|
103
|
+
@clam.setlimit(CL_ENGINE_MAX_FILES, 1)
|
104
|
+
@clam.scanfile(File.join(File.dirname(__FILE__), "../clamav-testfiles/", 'multi.zip')).
|
105
|
+
should == CL_CLEAN
|
106
|
+
end
|
107
|
+
|
108
|
+
it "should get limit" do
|
109
|
+
@clam.getlimit(CL_ENGINE_MAX_FILES).should == 10000
|
110
|
+
end
|
111
|
+
|
112
|
+
it "should get db time" do
|
113
|
+
Time.at(@clam.getlimit(CL_ENGINE_DB_TIME)).should >= Time.now - 60*60*24 # 1 day
|
114
|
+
end
|
115
|
+
|
116
|
+
it "should get tmpdir == nil" do
|
117
|
+
@clam.getstring(CL_ENGINE_TMPDIR).should be_nil
|
118
|
+
end
|
119
|
+
|
120
|
+
it "should set tmpdir" do
|
121
|
+
@clam.setstring(CL_ENGINE_TMPDIR, '/tmp').should == CL_SUCCESS
|
122
|
+
@clam.getstring(CL_ENGINE_TMPDIR).should == '/tmp'
|
123
|
+
end
|
124
|
+
|
125
|
+
end
|
126
|
+
|
127
|
+
end
|
128
|
+
end
|
data/tools/rakehelp.rb
ADDED
@@ -0,0 +1,117 @@
|
|
1
|
+
def make(makedir)
|
2
|
+
Dir.chdir(makedir) do
|
3
|
+
sh(PLATFORM =~ /win32/ ? 'nmake' : 'make')
|
4
|
+
end
|
5
|
+
end
|
6
|
+
|
7
|
+
|
8
|
+
def extconf(dir)
|
9
|
+
Dir.chdir(dir) do ruby "extconf.rb" end
|
10
|
+
end
|
11
|
+
|
12
|
+
|
13
|
+
def setup_tests
|
14
|
+
Rake::TestTask.new do |t|
|
15
|
+
t.libs << "test"
|
16
|
+
t.test_files = FileList['test/test*.rb']
|
17
|
+
t.verbose = true
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
|
22
|
+
def setup_clean otherfiles
|
23
|
+
files = ['build/*', '**/*.o', '**/*.so', '**/*.a', 'lib/*-*', '**/*.log'] + otherfiles
|
24
|
+
CLEAN.include(files)
|
25
|
+
end
|
26
|
+
|
27
|
+
|
28
|
+
def setup_rdoc files
|
29
|
+
Rake::RDocTask.new do |rdoc|
|
30
|
+
rdoc.rdoc_dir = 'doc/rdoc'
|
31
|
+
rdoc.options << '--line-numbers'
|
32
|
+
rdoc.rdoc_files.add(files)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
|
37
|
+
def setup_extension(dir, extension)
|
38
|
+
ext = "ext/#{dir}"
|
39
|
+
ext_so = "#{ext}/#{extension}.#{Config::CONFIG['DLEXT']}"
|
40
|
+
ext_files = FileList[
|
41
|
+
"#{ext}/*.cpp",
|
42
|
+
"#{ext}/*.h",
|
43
|
+
"#{ext}/extconf.rb",
|
44
|
+
"#{ext}/Makefile",
|
45
|
+
"lib"
|
46
|
+
]
|
47
|
+
|
48
|
+
task "lib" do
|
49
|
+
directory "lib"
|
50
|
+
end
|
51
|
+
|
52
|
+
desc "Builds just the #{extension} extension"
|
53
|
+
task extension.to_sym => ["#{ext}/Makefile", ext_so ]
|
54
|
+
|
55
|
+
file "#{ext}/Makefile" => ["#{ext}/extconf.rb"] do
|
56
|
+
extconf "#{ext}"
|
57
|
+
end
|
58
|
+
|
59
|
+
file ext_so => ext_files do
|
60
|
+
make "#{ext}"
|
61
|
+
cp ext_so, "lib"
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
|
66
|
+
def base_gem_spec(pkg_name, pkg_version)
|
67
|
+
rm_rf "test/coverage"
|
68
|
+
pkg_version = pkg_version
|
69
|
+
pkg_name = pkg_name
|
70
|
+
pkg_file_name = "#{pkg_name}-#{pkg_version}"
|
71
|
+
Gem::Specification.new do |s|
|
72
|
+
s.name = pkg_name
|
73
|
+
s.version = pkg_version
|
74
|
+
s.platform = Gem::Platform::RUBY
|
75
|
+
s.has_rdoc = true
|
76
|
+
s.extra_rdoc_files = [ "README" ]
|
77
|
+
|
78
|
+
s.files = %w(COPYING LICENSE README Rakefile) +
|
79
|
+
Dir.glob("{bin,doc/rdoc,test}/**/*") +
|
80
|
+
Dir.glob("ext/**/*.{h,cpp,rb,rl}") +
|
81
|
+
Dir.glob("{examples,tools,lib}/**/*.rb")
|
82
|
+
|
83
|
+
s.require_path = "lib"
|
84
|
+
s.extensions = FileList["ext/**/extconf.rb"].to_a
|
85
|
+
s.bindir = "bin"
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
def setup_gem(pkg_name, pkg_version)
|
90
|
+
spec = base_gem_spec(pkg_name, pkg_version)
|
91
|
+
yield spec if block_given?
|
92
|
+
|
93
|
+
Rake::GemPackageTask.new(spec) do |p|
|
94
|
+
p.gem_spec = spec
|
95
|
+
p.need_tar = true if RUBY_PLATFORM !~ /mswin/
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
def sub_project(project, *targets)
|
100
|
+
targets.each do |target|
|
101
|
+
Dir.chdir "projects/#{project}" do
|
102
|
+
sh %{rake --trace #{target.to_s} }
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
# Conditional require rcov/rcovtask if present
|
108
|
+
begin
|
109
|
+
require 'rcov/rcovtask'
|
110
|
+
|
111
|
+
Rcov::RcovTask.new do |t|
|
112
|
+
t.test_files = FileList['test/test*.rb']
|
113
|
+
t.rcov_opts << "-x /usr"
|
114
|
+
t.output_dir = "test/coverage"
|
115
|
+
end
|
116
|
+
rescue Object
|
117
|
+
end
|
metadata
ADDED
@@ -0,0 +1,87 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: warp-clamav
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.3.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Alexander Oryol
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-10-16 00:00:00 +08:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description:
|
17
|
+
email: eagle.alex@gmail.com
|
18
|
+
executables: []
|
19
|
+
|
20
|
+
extensions:
|
21
|
+
- ext/clamav/extconf.rb
|
22
|
+
extra_rdoc_files:
|
23
|
+
- ChangeLog
|
24
|
+
- README.rdoc
|
25
|
+
files:
|
26
|
+
- .gitignore
|
27
|
+
- ChangeLog
|
28
|
+
- README.rdoc
|
29
|
+
- VERSION
|
30
|
+
- clamav.gemspec
|
31
|
+
- ext/clamav/clamav.c
|
32
|
+
- ext/clamav/const.h
|
33
|
+
- ext/clamav/extconf.rb
|
34
|
+
- rakefile
|
35
|
+
- spec/clamav-testfiles/clam-p.rar
|
36
|
+
- spec/clamav-testfiles/clam-ph.rar
|
37
|
+
- spec/clamav-testfiles/clam-v2.rar
|
38
|
+
- spec/clamav-testfiles/clam-v3.rar
|
39
|
+
- spec/clamav-testfiles/clam.cab
|
40
|
+
- spec/clamav-testfiles/clam.exe
|
41
|
+
- spec/clamav-testfiles/clam.exe.bz2
|
42
|
+
- spec/clamav-testfiles/clam.zip
|
43
|
+
- spec/clamav-testfiles/eicar.com
|
44
|
+
- spec/clamav-testfiles/jquery.tooltip.pack.js
|
45
|
+
- spec/clamav-testfiles/multi.zip
|
46
|
+
- spec/clamav-testfiles/program.doc
|
47
|
+
- spec/clamav-testfiles/robots.txt
|
48
|
+
- spec/clamav-testfiles/test.rar
|
49
|
+
- spec/clamav-testfiles/test.txt
|
50
|
+
- !binary |
|
51
|
+
c3BlYy9jbGFtYXYtdGVzdGZpbGVzL9Cf0YDQvtCz0YDQsNC80LzQsC5kb2M=
|
52
|
+
|
53
|
+
- spec/spec
|
54
|
+
- spec/spec_helper.rb
|
55
|
+
- spec/unit/clamav_spec.rb
|
56
|
+
- tools/rakehelp.rb
|
57
|
+
has_rdoc: true
|
58
|
+
homepage: http://github.com/eagleas/clamav
|
59
|
+
licenses: []
|
60
|
+
|
61
|
+
post_install_message:
|
62
|
+
rdoc_options:
|
63
|
+
- --charset=UTF-8
|
64
|
+
require_paths:
|
65
|
+
- lib
|
66
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
67
|
+
requirements:
|
68
|
+
- - ">="
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: "0"
|
71
|
+
version:
|
72
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - ">="
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: "0"
|
77
|
+
version:
|
78
|
+
requirements: []
|
79
|
+
|
80
|
+
rubyforge_project: clamav
|
81
|
+
rubygems_version: 1.3.5
|
82
|
+
signing_key:
|
83
|
+
specification_version: 3
|
84
|
+
summary: ClamAV Ruby bindings
|
85
|
+
test_files:
|
86
|
+
- spec/spec_helper.rb
|
87
|
+
- spec/unit/clamav_spec.rb
|