clamav 0.3.2 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/ChangeLog CHANGED
@@ -1,6 +1,15 @@
1
1
  ChangeLog
2
2
 
3
- Thu Feb 25 20:1:00 MSK 2010
3
+ Fri Apr 23 19:31:00 MSK 2010
4
+ ----------------------------
5
+ V 0.4.0
6
+ * Clamav-0.96 compatible now
7
+ * Changes: ClamAV is a singleton (Use ClamAV.instance instead ClamAV.new)
8
+ You should call ClamAV#loaddb([options]) after first call ClamAV.instance
9
+ + ClamAV#version get Clamav engine version string
10
+ + ClamaAV#countsigs get loaded signatures count with options
11
+
12
+ Thu Feb 25 20:01:00 MSK 2010
4
13
  ----------------------------
5
14
  V 0.3.2
6
15
  * Fix to compile on ruby-1.9
@@ -9,32 +9,24 @@ $ sudo gem install clamav
9
9
  == REQUIREMENTS:
10
10
 
11
11
  clamav >= 0.95.3, libclamav6, libclamav-dev
12
+ clamav >= 0.96 is recommended
12
13
 
13
14
  == SYNOPSIS:
14
15
 
15
- == ClamAV.new([options[, db_options]])
16
+ *Changes*: Now ClamAV is a singleton. Use ClamAV.instance instead ClamAV.new.
17
+ You should call ClamAV#loaddb([options]) after first call ClamAV.instance.
18
+ Next run ClamAV#loaddb with another options will recreate/recompile clamav engine/database.
19
+
20
+ == ClamAV.instance
16
21
 
17
22
  return:
18
23
  ClamAV instance
19
24
 
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
25
+ == ClamAV#loaddb([db_options])
34
26
 
35
27
  DB options:
36
28
 
37
- * CL_DB_STDOPT (default) equal CL_DB_PHISHING | CL_DB_PHISHING_URLS
29
+ * CL_DB_STDOPT (default) equal CL_DB_PHISHING | CL_DB_PHISHING_URLS | CL_DB_BYTECODE
38
30
  * CL_DB_PUA
39
31
  * CL_DB_CVDNOTMP
40
32
  * CL_DB_PUA_MODE
@@ -44,24 +36,35 @@ DB options:
44
36
  See ClamAV documentation and sources for details.
45
37
 
46
38
 
47
-
48
39
  == ClamAV#scanfile(filename[, options])
49
40
  options default CL_SCAN_STDOPT
50
-
41
+
42
+ Options:
43
+
44
+ * 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
45
+ * CL_SCAN_RAW
46
+ * CL_SCAN_BLOCKENCRYPTED
47
+ * CL_SCAN_BLOCKBROKEN
48
+ * CL_SCAN_PHISHING_BLOCKSSL
49
+ * CL_SCAN_PHISHING_BLOCKCLOAK
50
+ * CL_SCAN_STRUCTURED
51
+ * CL_SCAN_STRUCTURED_SSN_NORMAL
52
+ * CL_SCAN_STRUCTURED_SSN_STRIPPED
53
+ * CL_SCAN_PARTIAL_MESSAGE
54
+ * CL_SCAN_HEURISTIC_PRECEDENCE
55
+
51
56
  return:
52
57
  virusname or ClamAV returncode(Fixnum)
53
58
 
54
59
 
55
-
56
60
  == ClamAV#reload()
57
- reload virus db if changed
61
+ reload virus database if changed
58
62
 
59
63
  return:
60
64
  1 - reload successful
61
65
  0 - reload unnecessary
62
66
 
63
67
 
64
-
65
68
  == ClamAV#setlimit(param, value)
66
69
 
67
70
  == ClamAV#getlimit(param)
@@ -96,6 +99,17 @@ See ClamAV documentation and sources for details.
96
99
  == ClamaAV#signo()
97
100
  get loaded signatures count
98
101
 
102
+ == ClamaAV#countsigs([options])
103
+ get loaded signatures count (since 0.96 engine version)
104
+
105
+ Options:
106
+ * CL_COUNTSIGS_ALL (default)
107
+ * CL_COUNTSIGS_OFFICIAL
108
+ * CL_COUNTSIGS_UNOFFICIAL
109
+
110
+
111
+ == ClamaAV#version()
112
+ get Clamav engine version string
99
113
 
100
114
 
101
115
  == LICENSE:
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.2
1
+ 0.4.0
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{clamav}
8
- s.version = "0.3.2"
8
+ s.version = "0.4.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Alexander Oryol"]
12
- s.date = %q{2010-02-25}
12
+ s.date = %q{2010-04-23}
13
13
  s.description = %q{ClamAV Ruby bindings}
14
14
  s.email = %q{eagle.alex@gmail.com}
15
15
  s.extensions = ["ext/clamav/extconf.rb"]
@@ -52,7 +52,7 @@ Gem::Specification.new do |s|
52
52
  s.rdoc_options = ["--charset=UTF-8"]
53
53
  s.require_paths = ["lib"]
54
54
  s.rubyforge_project = %q{clamav}
55
- s.rubygems_version = %q{1.3.5}
55
+ s.rubygems_version = %q{1.3.6}
56
56
  s.summary = %q{ClamAV Ruby bindings}
57
57
  s.test_files = [
58
58
  "spec/unit/clamav_spec.rb",
@@ -20,21 +20,14 @@ static void clamavr_free(struct ClamAV_R *ptr) {
20
20
  xfree(ptr);
21
21
  }
22
22
 
23
- static VALUE clamavr_new(argc, argv, klass)
24
- int argc;
25
- VALUE *argv;
26
- VALUE klass;
27
- {
28
- const char *v_fname;
23
+ static VALUE clamavr_initialize(VALUE self) {
24
+ return self;
25
+ }
26
+
27
+ static VALUE clamavr_new(VALUE klass) {
28
+
29
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
- }
30
+ v_options = INT2FIX(CL_SCAN_STDOPT); /* default value */
38
31
 
39
32
  int ret;
40
33
  ret = cl_init(FIX2INT(v_options));
@@ -42,21 +35,30 @@ static VALUE clamavr_new(argc, argv, klass)
42
35
  rb_raise(rb_eRuntimeError, "cl_init() error: %s\n", cl_strerror(ret));
43
36
  }
44
37
  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
38
 
50
39
  /* save options */
51
40
  ptr->options = v_options;
52
- ptr->db_options = v_db_options;
41
+
42
+ ptr->root = NULL;
43
+
44
+ return Data_Wrap_Struct(klass, 0, clamavr_free, ptr);
45
+ }
46
+
47
+ static void clamavr_build(VALUE db_options, struct ClamAV_R *ptr) {
48
+
49
+ ptr->root = cl_engine_new();
50
+
51
+ /* save options */
52
+ ptr->db_options = db_options;
53
53
 
54
54
  ptr->signo = 0;
55
55
 
56
56
  const char *dbdir;
57
57
  dbdir = cl_retdbdir();
58
58
 
59
- ret = cl_load(dbdir, ptr->root, &ptr->signo, FIX2INT(v_db_options));
59
+ int ret;
60
+
61
+ ret = cl_load(dbdir, ptr->root, &ptr->signo, FIX2INT(db_options));
60
62
  if(ret != CL_SUCCESS) {
61
63
  rb_raise(rb_eRuntimeError, "cl_load() error: %s\n", cl_strerror(ret));
62
64
  }
@@ -67,12 +69,47 @@ static VALUE clamavr_new(argc, argv, klass)
67
69
  ret = cl_engine_compile(ptr->root);
68
70
  if(ret != CL_SUCCESS) {
69
71
  rb_raise(rb_eRuntimeError, "cl_engine_compile() error: %s\n", cl_strerror(ret));
72
+ cl_engine_free(ptr->root);
70
73
  }
71
- return Data_Wrap_Struct(klass, 0, clamavr_free, ptr);
72
74
  }
73
75
 
74
- static VALUE clamavr_initialize(VALUE self) {
75
- return self;
76
+ static VALUE clamavr_loaddb(int argc, VALUE *argv, VALUE self) {
77
+ struct ClamAV_R *ptr;
78
+ Data_Get_Struct(self, struct ClamAV_R, ptr);
79
+
80
+ VALUE v_db_options;
81
+ rb_scan_args(argc, argv, "01", &v_db_options);
82
+
83
+ if(NIL_P(v_db_options)){
84
+ v_db_options = INT2FIX(CL_DB_STDOPT); /* default value */
85
+ }
86
+
87
+ if(ptr->root != NULL) {
88
+ cl_engine_free(ptr->root);
89
+ }
90
+
91
+ clamavr_build(v_db_options, ptr);
92
+ return CL_SUCCESS;
93
+ }
94
+
95
+ static VALUE clamavr_reload(VALUE self) {
96
+ struct ClamAV_R *ptr;
97
+ Data_Get_Struct(self, struct ClamAV_R, ptr);
98
+
99
+ int state;
100
+ state = cl_statchkdir(&ptr->dbstat);
101
+ if(state == 1) {
102
+ const char *dbdir;
103
+ dbdir = cl_retdbdir();
104
+ int ret;
105
+ ret = cl_load(dbdir, ptr->root, &ptr->signo, FIX2INT(ptr->db_options));
106
+ if(ret != CL_SUCCESS) {
107
+ rb_raise(rb_eRuntimeError, "cl_load() error: %s\n", cl_strerror(ret));
108
+ }
109
+ cl_statfree(&ptr->dbstat);
110
+ cl_statinidir(dbdir, &ptr->dbstat);
111
+ }
112
+ return INT2FIX(state);
76
113
  }
77
114
 
78
115
  static VALUE clamavr_setlimit(VALUE self, VALUE v_limit, VALUE v_value) {
@@ -142,19 +179,37 @@ static VALUE clamavr_signo(VALUE self) {
142
179
  return UINT2NUM(ptr->signo);
143
180
  }
144
181
 
145
- static VALUE clamavr_scanfile(argc, argv, klass)
146
- int argc;
147
- VALUE *argv;
148
- VALUE klass;
149
- {
182
+ #ifdef CL_COUNTSIGS_OFFICIAL
183
+ static VALUE clamavr_countsigs(int argc, VALUE *argv, VALUE self) {
184
+ VALUE v_options;
185
+ rb_scan_args(argc, argv, "01", &v_options);
186
+ if(NIL_P(v_options)){
187
+ v_options = CL_COUNTSIGS_ALL; /* all signatures count */
188
+ }
189
+
190
+ const char *dbdir;
191
+ dbdir = cl_retdbdir();
192
+
193
+ int ret;
194
+ int signo = 0;
195
+ ret = cl_countsigs(dbdir, FIX2INT(v_options), &signo);
196
+ if(ret != CL_SUCCESS) {
197
+ rb_raise(rb_eRuntimeError, "cl_countsigs() error: %s\n", cl_strerror(ret));
198
+ }
199
+ return INT2NUM(signo);
200
+ }
201
+ #endif
202
+
203
+ static VALUE clamavr_scanfile(int argc, VALUE *argv, VALUE klass) {
150
204
  struct ClamAV_R *ptr;
151
205
  Data_Get_Struct(klass, struct ClamAV_R, ptr);
152
206
 
153
207
  const char *v_fname;
154
208
  VALUE v_options;
155
209
  rb_scan_args(argc, argv, "11", &v_fname, &v_options);
210
+
156
211
  if(NIL_P(v_options)){
157
- v_options = ptr->options; /* stored value */
212
+ v_options = ptr->options; /* stored value */
158
213
  }
159
214
 
160
215
  Check_Type(v_fname, T_STRING);
@@ -171,37 +226,32 @@ static VALUE clamavr_scanfile(argc, argv, klass)
171
226
  }
172
227
  }
173
228
 
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);
229
+ static VALUE clamavr_retver(VALUE self) {
230
+ const char *res;
231
+ res = cl_retver();
232
+ return rb_str_new2(res);
192
233
  }
193
234
 
194
235
  void Init_clamav() {
195
236
  cClamAV = rb_define_class("ClamAV", rb_cObject);
196
- rb_define_singleton_method(cClamAV, "new", clamavr_new, -1);
237
+
238
+ rb_require("singleton");
239
+ rb_include_module(cClamAV, rb_const_get(rb_cObject, rb_intern("Singleton")));
240
+ rb_funcall(rb_const_get(rb_cObject, rb_intern("Singleton")), rb_intern("included"), 1, cClamAV);
241
+
197
242
  rb_define_method(cClamAV, "initialize", clamavr_initialize, 0);
243
+ rb_define_singleton_method(cClamAV, "new", clamavr_new, 0);
244
+ rb_define_method(cClamAV, "loaddb", clamavr_loaddb, -1);
245
+ rb_define_method(cClamAV, "reload", clamavr_reload, 0);
198
246
  rb_define_method(cClamAV, "scanfile", clamavr_scanfile, -1);
199
247
  rb_define_method(cClamAV, "signo", clamavr_signo, 0);
248
+ #ifdef CL_COUNTSIGS_OFFICIAL
249
+ rb_define_method(cClamAV, "countsigs", clamavr_countsigs, -1);
250
+ #endif
200
251
  rb_define_method(cClamAV, "setlimit", clamavr_setlimit, 2);
201
252
  rb_define_method(cClamAV, "getlimit", clamavr_getlimit, 1);
202
253
  rb_define_method(cClamAV, "setstring", clamavr_setstring, 2);
203
254
  rb_define_method(cClamAV, "getstring", clamavr_getstring, 1);
204
- rb_define_method(cClamAV, "reload", clamavr_dbreload, 0);
205
-
255
+ rb_define_method(cClamAV, "version", clamavr_retver, 0);
206
256
  #include <const.h>
207
257
  }
@@ -33,18 +33,26 @@
33
33
  rb_define_const(cClamAV, "CL_EMAXSIZE", INT2FIX(CL_EMAXSIZE));
34
34
  rb_define_const(cClamAV, "CL_EMAXFILES", INT2FIX(CL_EMAXFILES));
35
35
  rb_define_const(cClamAV, "CL_EFORMAT", INT2FIX(CL_EFORMAT));
36
+ #ifdef CL_EBYTECODE
37
+ rb_define_const(cClamAV, "CL_EBYTECODE", INT2FIX(CL_EBYTECODE));
38
+ #endif
36
39
 
37
40
  /* db options */
38
41
  rb_define_const(cClamAV, "CL_DB_PHISHING", INT2FIX(CL_DB_PHISHING));
39
42
  rb_define_const(cClamAV, "CL_DB_PHISHING_URLS", INT2FIX(CL_DB_PHISHING_URLS));
40
43
  rb_define_const(cClamAV, "CL_DB_PUA", INT2FIX(CL_DB_PUA));
41
- rb_define_const(cClamAV, "CL_DB_CVDNOTMP", INT2FIX(CL_DB_CVDNOTMP));
44
+ rb_define_const(cClamAV, "CL_DB_CVDNOTMP", INT2FIX(CL_DB_CVDNOTMP)); /* obsolete */
42
45
  rb_define_const(cClamAV, "CL_DB_OFFICIAL", INT2FIX(CL_DB_OFFICIAL)); /* internal */
43
46
  rb_define_const(cClamAV, "CL_DB_PUA_MODE", INT2FIX(CL_DB_PUA_MODE));
44
47
  rb_define_const(cClamAV, "CL_DB_PUA_INCLUDE", INT2FIX(CL_DB_PUA_INCLUDE));
45
48
  rb_define_const(cClamAV, "CL_DB_PUA_EXCLUDE", INT2FIX(CL_DB_PUA_EXCLUDE));
46
49
  rb_define_const(cClamAV, "CL_DB_COMPILED", INT2FIX(CL_DB_COMPILED)); /* internal */
47
50
  rb_define_const(cClamAV, "CL_DB_DIRECTORY", INT2FIX(CL_DB_DIRECTORY)); /* internal */
51
+ #ifdef CL_DB_BYTECODE
52
+ rb_define_const(cClamAV, "CL_DB_OFFICIAL_ONLY", INT2FIX(CL_DB_OFFICIAL_ONLY));
53
+ rb_define_const(cClamAV, "CL_DB_BYTECODE", INT2FIX(CL_DB_BYTECODE));
54
+ rb_define_const(cClamAV, "CL_DB_SIGNED", INT2FIX(CL_DB_SIGNED)); /* internal */
55
+ #endif
48
56
 
49
57
  /* recommended db settings */
50
58
  rb_define_const(cClamAV, "CL_DB_STDOPT", INT2FIX(CL_DB_STDOPT));
@@ -58,7 +66,7 @@
58
66
  rb_define_const(cClamAV, "CL_SCAN_HTML", INT2FIX(CL_SCAN_HTML));
59
67
  rb_define_const(cClamAV, "CL_SCAN_PE", INT2FIX(CL_SCAN_PE));
60
68
  rb_define_const(cClamAV, "CL_SCAN_BLOCKBROKEN", INT2FIX(CL_SCAN_BLOCKBROKEN));
61
- rb_define_const(cClamAV, "CL_SCAN_MAILURL", INT2FIX(CL_SCAN_MAILURL));
69
+ rb_define_const(cClamAV, "CL_SCAN_MAILURL", INT2FIX(CL_SCAN_MAILURL)); /* ignored */
62
70
  rb_define_const(cClamAV, "CL_SCAN_BLOCKMAX", INT2FIX(CL_SCAN_BLOCKMAX)); /* ignored */
63
71
  rb_define_const(cClamAV, "CL_SCAN_ALGORITHMIC", INT2FIX(CL_SCAN_ALGORITHMIC));
64
72
  rb_define_const(cClamAV, "CL_SCAN_PHISHING_BLOCKSSL", INT2FIX(CL_SCAN_PHISHING_BLOCKSSL)); /* ssl mismatches, not ssl by itself */
@@ -74,6 +82,13 @@
74
82
  /* recommended scan settings */
75
83
  rb_define_const(cClamAV, "CL_SCAN_STDOPT", INT2FIX(CL_SCAN_STDOPT));
76
84
 
85
+ /* cl_countsigs options */
86
+ #ifdef CL_COUNTSIGS_OFFICIAL
87
+ rb_define_const(cClamAV, "CL_COUNTSIGS_OFFICIAL", INT2FIX(CL_COUNTSIGS_OFFICIAL));
88
+ rb_define_const(cClamAV, "CL_COUNTSIGS_UNOFFICIAL", INT2FIX(CL_COUNTSIGS_UNOFFICIAL));
89
+ rb_define_const(cClamAV, "CL_COUNTSIGS_ALL", INT2FIX(CL_COUNTSIGS_ALL));
90
+ #endif
91
+
77
92
  rb_define_const(cClamAV, "CL_INIT_DEFAULT", INT2FIX(CL_INIT_DEFAULT));
78
93
 
79
94
  rb_define_const(cClamAV, "CL_ENGINE_MAX_SCANSIZE", INT2FIX(CL_ENGINE_MAX_SCANSIZE)); /* uint64_t */
@@ -91,4 +106,11 @@
91
106
  rb_define_const(cClamAV, "CL_ENGINE_AC_MAXDEPTH", INT2FIX(CL_ENGINE_AC_MAXDEPTH)); /* uint32_t */
92
107
  rb_define_const(cClamAV, "CL_ENGINE_TMPDIR", INT2FIX(CL_ENGINE_TMPDIR)); /* (char *) */
93
108
  rb_define_const(cClamAV, "CL_ENGINE_KEEPTMP", INT2FIX(CL_ENGINE_KEEPTMP)); /* uint32_t */
109
+ #ifdef CL_DB_BYTECODE
110
+ rb_define_const(cClamAV, "CL_ENGINE_BYTECODE_SECURITY", INT2FIX(CL_ENGINE_BYTECODE_SECURITY)); /* uint32_t */
111
+ rb_define_const(cClamAV, "CL_ENGINE_BYTECODE_TIMEOUT", INT2FIX(CL_ENGINE_BYTECODE_TIMEOUT)); /* uint32_t */
94
112
 
113
+ rb_define_const(cClamAV, "CL_BYTECODE_TRUST_ALL", INT2FIX(CL_BYTECODE_TRUST_ALL)); /* insecure, debug setting */
114
+ rb_define_const(cClamAV, "CL_BYTECODE_TRUST_SIGNED", INT2FIX(CL_BYTECODE_TRUST_SIGNED)); /* default */
115
+ rb_define_const(cClamAV, "CL_BYTECODE_TRUST_NOTHING", INT2FIX(CL_BYTECODE_TRUST_NOTHING)); /* paranoid setting */
116
+ #endif
@@ -4,6 +4,11 @@ class ClamAV
4
4
 
5
5
  describe "ClamAV" do
6
6
 
7
+ before(:all) do
8
+ @clam = ClamAV.instance
9
+ @clam.loaddb
10
+ end
11
+
7
12
  FILES = {
8
13
  'robots.txt' => CL_CLEAN,
9
14
  'eicar.com' => 'Eicar-Test-Signature', # EICAR
@@ -22,34 +27,37 @@ class ClamAV
22
27
 
23
28
  FILES_ENCRYPTED = {
24
29
  'clam-p.rar' => 'Encrypted.RAR', # encripted RAR
25
- 'clam-ph.rar' => 'Encrypted.RAR', # encripted RAR with encrypted both file data and headers
30
+ 'clam-ph.rar' => 'Encrypted.RAR', # encripted RAR with encrypted both file data and headers
31
+ 'clam-v3.rar' => 'ClamAV-Test-File'
26
32
  }
27
33
 
28
- describe "with default options" do
29
- before(:all) do
30
- @clam = ClamAV.new
31
- end
34
+ context "with default options" do
32
35
 
33
36
  it "should be instance of Clamav" do
34
37
  @clam.should be_instance_of(ClamAV)
35
38
  end
36
39
 
40
+ it "should return engine version" do
41
+ @clam.version.should >= '0.95'
42
+ end
37
43
 
38
44
  FILES.each do |file, result|
39
45
  it "should scan #{file} with result #{result.to_s}" do
40
- @clam.scanfile(File.join(File.dirname(__FILE__), "../clamav-testfiles/", file)).should == result
46
+ @clam.scanfile(File.join(File.dirname(__FILE__), "../clamav-testfiles/", file)).should == result
41
47
  end
42
48
  end
43
49
 
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
50
+ it "should return signatures count" do
51
+ # strange, why not 757156? bug?
52
+ @clam.signo.should >= 756450 # on 17/04/10
49
53
  end
50
54
 
51
- it "should return signatures count" do
52
- @clam.signo.should >= 538736 # on 7/04/09
55
+ if ClamAV.instance.version >= '0.96'
56
+ it "should return all signatures count" do
57
+ (default = @clam.countsigs).should >= 757156 # on 17/04/10
58
+ (all = @clam.countsigs(CL_COUNTSIGS_ALL)).should >= 757156
59
+ default.should == all
60
+ end
53
61
  end
54
62
 
55
63
  it "should not reload db when fresh" do
@@ -58,15 +66,13 @@ class ClamAV
58
66
 
59
67
  end
60
68
 
61
- describe "with custom options" do
69
+ context "scan with custom options" do
62
70
 
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'
71
+ FILES_ENCRYPTED.each do |file, result|
72
+ it "should scan encrypted #{file} with result #{result.to_s}" do
73
+ @clam.scanfile(File.join(File.dirname(__FILE__), "../clamav-testfiles/", file),
74
+ CL_SCAN_STDOPT | CL_SCAN_BLOCKENCRYPTED).should match(/#{result}$/)
75
+ end
70
76
  end
71
77
 
72
78
  it "should scan OLE2 file with not detect" do
@@ -76,10 +82,14 @@ class ClamAV
76
82
 
77
83
  end
78
84
 
79
- describe "with custom db options" do
85
+ context "with custom db options" do
80
86
 
81
87
  before(:all) do
82
- @clam = ClamAV.new(CL_SCAN_STDOPT, CL_DB_STDOPT | CL_DB_PUA)
88
+ @clam.loaddb(CL_DB_STDOPT | CL_DB_PUA)
89
+ end
90
+
91
+ after(:all) do
92
+ @clam.loaddb
83
93
  end
84
94
 
85
95
  it "should detect PUA" do
@@ -89,10 +99,20 @@ class ClamAV
89
99
 
90
100
  end
91
101
 
102
+ context "limit CL_ENGINE_MAX_FILES" do
103
+
104
+ before(:all) do
105
+ # save default
106
+ @mem = @clam.getlimit(CL_ENGINE_MAX_FILES)
107
+ end
108
+
109
+ after(:each) do
110
+ # restore default
111
+ @clam.setlimit(CL_ENGINE_MAX_FILES, @mem)
112
+ end
92
113
 
93
- describe "limits" do
94
- before(:each) do
95
- @clam = ClamAV.new
114
+ it "should get default limit" do
115
+ @clam.getlimit(CL_ENGINE_MAX_FILES).should == 10000
96
116
  end
97
117
 
98
118
  it "should set limit" do
@@ -105,9 +125,9 @@ class ClamAV
105
125
  should == CL_CLEAN
106
126
  end
107
127
 
108
- it "should get limit" do
109
- @clam.getlimit(CL_ENGINE_MAX_FILES).should == 10000
110
- end
128
+ end
129
+
130
+ context "get/set" do
111
131
 
112
132
  it "should get db time" do
113
133
  Time.at(@clam.getlimit(CL_ENGINE_DB_TIME)).should >= Time.now - 60*60*24 # 1 day
metadata CHANGED
@@ -1,7 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: clamav
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 4
8
+ - 0
9
+ version: 0.4.0
5
10
  platform: ruby
6
11
  authors:
7
12
  - Alexander Oryol
@@ -9,7 +14,7 @@ autorequire:
9
14
  bindir: bin
10
15
  cert_chain: []
11
16
 
12
- date: 2010-02-25 00:00:00 +03:00
17
+ date: 2010-04-23 00:00:00 +04:00
13
18
  default_executable:
14
19
  dependencies: []
15
20
 
@@ -67,18 +72,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
67
72
  requirements:
68
73
  - - ">="
69
74
  - !ruby/object:Gem::Version
75
+ segments:
76
+ - 0
70
77
  version: "0"
71
- version:
72
78
  required_rubygems_version: !ruby/object:Gem::Requirement
73
79
  requirements:
74
80
  - - ">="
75
81
  - !ruby/object:Gem::Version
82
+ segments:
83
+ - 0
76
84
  version: "0"
77
- version:
78
85
  requirements: []
79
86
 
80
87
  rubyforge_project: clamav
81
- rubygems_version: 1.3.5
88
+ rubygems_version: 1.3.6
82
89
  signing_key:
83
90
  specification_version: 3
84
91
  summary: ClamAV Ruby bindings