clamav 0.2.2 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/ChangeLog CHANGED
@@ -1,6 +1,16 @@
1
1
  ChangeLog
2
2
 
3
- Sar Sep 06 15:43:00 MSK 2008
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
4
14
  ----------------------------
5
15
  V 0.2.2
6
16
  * Update to ClamAV-0.94
@@ -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>
@@ -5,33 +5,69 @@ static VALUE cClamAV;
5
5
 
6
6
  struct ClamAV_R {
7
7
  struct cl_engine *root;
8
- struct cl_limits limits;
8
+ int options;
9
+ int db_options;
10
+ struct cl_stat dbstat;
9
11
  unsigned int signo;
10
12
  };
11
13
 
12
14
  static void clamavr_free(struct ClamAV_R *ptr) {
13
- cl_free(ptr->root);
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
+ }
14
20
  xfree(ptr);
15
21
  }
16
22
 
17
- static VALUE clamavr_s_allocate(VALUE klass) {
18
- struct ClamAV_R *ptr = ALLOC(struct ClamAV_R);
23
+ static VALUE clamavr_new(argc, argv, klass)
24
+ int argc;
25
+ VALUE *argv;
26
+ VALUE klass;
27
+ {
28
+ const char *v_fname;
29
+ int v_options;
30
+ int 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
+
19
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;
20
53
 
21
- ptr->root = NULL;
22
54
  ptr->signo = 0;
23
- ret = cl_load(cl_retdbdir(), &ptr->root, &ptr->signo, CL_DB_STDOPT);
24
- if(ret) {
25
- rb_raise(rb_eRuntimeError, "cl_loaddbdir() error: %s\n", cl_strerror(ret));
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));
26
62
  }
27
- cl_build(ptr->root);
28
-
29
- ptr->limits.maxscansize = 10 * 1024 * 1024;
30
- ptr->limits.maxfilesize = 10 * 1024 * 1024;
31
- ptr->limits.maxreclevel = 100;
32
- ptr->limits.maxfiles = 1024;
33
- ptr->limits.archivememlim = 1;
34
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
+ }
35
71
  return Data_Wrap_Struct(klass, 0, clamavr_free, ptr);
36
72
  }
37
73
 
@@ -39,23 +75,95 @@ static VALUE clamavr_initialize(VALUE self) {
39
75
  return self;
40
76
  }
41
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
+
42
139
  static VALUE clamavr_signo(VALUE self) {
43
140
  struct ClamAV_R *ptr;
44
141
  Data_Get_Struct(self, struct ClamAV_R, ptr);
45
142
  return UINT2NUM(ptr->signo);
46
143
  }
47
144
 
48
- static VALUE clamavr_scanfile(VALUE self, VALUE v_fname, VALUE v_options) {
49
- int ret;
50
- const char *virname;
145
+ static VALUE clamavr_scanfile(argc, argv, klass)
146
+ int argc;
147
+ VALUE *argv;
148
+ VALUE klass;
149
+ {
51
150
  struct ClamAV_R *ptr;
151
+ Data_Get_Struct(klass, struct ClamAV_R, ptr);
152
+
153
+ const char *v_fname;
154
+ int 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
+ }
52
159
 
53
160
  Check_Type(v_fname, T_STRING);
54
161
  Check_Type(v_options, T_FIXNUM);
55
162
 
56
- Data_Get_Struct(self, struct ClamAV_R, ptr);
163
+ int ret;
164
+ const char *virname;
57
165
 
58
- ret = cl_scanfile(RSTRING(v_fname)->ptr, &virname, NULL, ptr->root, &ptr->limits, FIX2INT(v_options));
166
+ ret = cl_scanfile(RSTRING(v_fname)->ptr, &virname, NULL, ptr->root, FIX2INT(v_options));
59
167
  if (ret == CL_VIRUS) {
60
168
  return rb_str_new2(virname);
61
169
  } else {
@@ -63,84 +171,37 @@ static VALUE clamavr_scanfile(VALUE self, VALUE v_fname, VALUE v_options) {
63
171
  }
64
172
  }
65
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
+
66
194
  void Init_clamav() {
67
195
  cClamAV = rb_define_class("ClamAV", rb_cObject);
68
- rb_define_alloc_func(cClamAV, clamavr_s_allocate);
196
+ rb_define_singleton_method(cClamAV, "new", clamavr_new, -1);
69
197
  rb_define_method(cClamAV, "initialize", clamavr_initialize, 0);
70
-
71
- rb_define_method(cClamAV, "scanfile", clamavr_scanfile, 2);
198
+ rb_define_method(cClamAV, "scanfile", clamavr_scanfile, -1);
72
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);
73
205
 
74
- /* return codes */
75
- rb_define_const(cClamAV, "CL_CLEAN", INT2FIX(CL_CLEAN)); /* no virus found */
76
- rb_define_const(cClamAV, "CL_VIRUS", INT2FIX(CL_VIRUS)); /* virus(es) found */
77
- rb_define_const(cClamAV, "CL_SUCCESS", INT2FIX(CL_SUCCESS));
78
- rb_define_const(cClamAV, "CL_BREAK", INT2FIX(CL_BREAK));
79
-
80
- rb_define_const(cClamAV, "CL_EMAXREC", INT2FIX(CL_EMAXREC)); /* (internal) recursion limit exceeded */
81
- rb_define_const(cClamAV, "CL_EMAXSIZE", INT2FIX(CL_EMAXSIZE)); /* (internal) size limit exceeded */
82
- rb_define_const(cClamAV, "CL_EMAXFILES", INT2FIX(CL_EMAXFILES)); /* (internal) files limit exceeded */
83
- rb_define_const(cClamAV, "CL_ERAR", INT2FIX(CL_ERAR)); /* rar handler error */
84
- rb_define_const(cClamAV, "CL_EZIP", INT2FIX(CL_EZIP)); /* zip handler error */
85
- rb_define_const(cClamAV, "CL_EGZIP", INT2FIX(CL_EGZIP)); /* gzip handler error */
86
- rb_define_const(cClamAV, "CL_EBZIP", INT2FIX(CL_EBZIP)); /* bzip2 handler error */
87
- rb_define_const(cClamAV, "CL_EOLE2", INT2FIX(CL_EOLE2)); /* OLE2 handler error */
88
- rb_define_const(cClamAV, "CL_EMSCOMP", INT2FIX(CL_EMSCOMP)); /* MS Expand handler error */
89
- rb_define_const(cClamAV, "CL_EMSCAB", INT2FIX(CL_EMSCAB)); /* MS CAB module error */
90
- rb_define_const(cClamAV, "CL_EACCES", INT2FIX(CL_EACCES)); /* access denied */
91
- rb_define_const(cClamAV, "CL_ENULLARG", INT2FIX(CL_ENULLARG)); /* null argument */
92
- rb_define_const(cClamAV, "CL_ETMPFILE", INT2FIX(CL_ETMPFILE)); /* tmpfile() failed */
93
- rb_define_const(cClamAV, "CL_EMEM", INT2FIX(CL_EMEM)); /* memory allocation error */
94
- rb_define_const(cClamAV, "CL_EOPEN", INT2FIX(CL_EOPEN)); /* file open error */
95
- rb_define_const(cClamAV, "CL_EMALFDB", INT2FIX(CL_EMALFDB)); /* malformed database */
96
- rb_define_const(cClamAV, "CL_EPATSHORT", INT2FIX(CL_EPATSHORT)); /* pattern too short */
97
- rb_define_const(cClamAV, "CL_ETMPDIR", INT2FIX(CL_ETMPDIR)); /* mkdir() failed */
98
- rb_define_const(cClamAV, "CL_ECVD", INT2FIX(CL_ECVD)); /* not a CVD file (or broken) */
99
- rb_define_const(cClamAV, "CL_ECVDEXTR", INT2FIX(CL_ECVDEXTR)); /* CVD extraction failure */
100
- rb_define_const(cClamAV, "CL_EMD5", INT2FIX(CL_EMD5)); /* MD5 verification error */
101
- rb_define_const(cClamAV, "CL_EDSIG", INT2FIX(CL_EDSIG)); /* digital signature verification error */
102
- rb_define_const(cClamAV, "CL_EIO", INT2FIX(CL_EIO)); /* general I/O error */
103
- rb_define_const(cClamAV, "CL_EFORMAT", INT2FIX(CL_EFORMAT)); /* (internal) bad format or broken file */
104
- rb_define_const(cClamAV, "CL_ESUPPORT", INT2FIX(CL_ESUPPORT)); /* not supported data format */
105
- rb_define_const(cClamAV, "CL_EARJ", INT2FIX(CL_EARJ)); /* ARJ handler error */
106
-
107
- /* db options */
108
- rb_define_const(cClamAV, "CL_DB_PHISHING", INT2FIX(CL_DB_PHISHING));
109
- rb_define_const(cClamAV, "CL_DB_ACONLY", INT2FIX(CL_DB_ACONLY)); /* WARNING: only for developers */
110
- rb_define_const(cClamAV, "CL_DB_PHISHING_URLS", INT2FIX(CL_DB_PHISHING_URLS));
111
- rb_define_const(cClamAV, "CL_DB_PUA", INT2FIX(CL_DB_PUA));
112
- rb_define_const(cClamAV, "CL_DB_CVDNOTMP", INT2FIX(CL_DB_CVDNOTMP));
113
- rb_define_const(cClamAV, "CL_DB_OFFICIAL", INT2FIX(CL_DB_OFFICIAL));
114
- rb_define_const(cClamAV, "CL_DB_PUA_MODE", INT2FIX(CL_DB_PUA_MODE));
115
- rb_define_const(cClamAV, "CL_DB_PUA_INCLUDE", INT2FIX(CL_DB_PUA_INCLUDE));
116
- rb_define_const(cClamAV, "CL_DB_PUA_EXCLUDE", INT2FIX(CL_DB_PUA_EXCLUDE));
117
-
118
- /* recommended db settings */
119
- rb_define_const(cClamAV, "CL_DB_STDOPT", INT2FIX(CL_DB_STDOPT));
120
-
121
- /* scan options */
122
- rb_define_const(cClamAV, "CL_SCAN_RAW", INT2FIX(CL_SCAN_RAW));
123
- rb_define_const(cClamAV, "CL_SCAN_ARCHIVE", INT2FIX(CL_SCAN_ARCHIVE));
124
- rb_define_const(cClamAV, "CL_SCAN_MAIL", INT2FIX(CL_SCAN_MAIL));
125
- rb_define_const(cClamAV, "CL_SCAN_OLE2", INT2FIX(CL_SCAN_OLE2));
126
- rb_define_const(cClamAV, "CL_SCAN_BLOCKENCRYPTED", INT2FIX(CL_SCAN_BLOCKENCRYPTED));
127
- rb_define_const(cClamAV, "CL_SCAN_HTML", INT2FIX(CL_SCAN_HTML));
128
- rb_define_const(cClamAV, "CL_SCAN_PE", INT2FIX(CL_SCAN_PE));
129
- rb_define_const(cClamAV, "CL_SCAN_BLOCKBROKEN", INT2FIX(CL_SCAN_BLOCKBROKEN));
130
- rb_define_const(cClamAV, "CL_SCAN_MAILURL", INT2FIX(CL_SCAN_MAILURL));
131
- rb_define_const(cClamAV, "CL_SCAN_BLOCKMAX", INT2FIX(CL_SCAN_BLOCKMAX)); /* ignored */
132
- rb_define_const(cClamAV, "CL_SCAN_ALGORITHMIC", INT2FIX(CL_SCAN_ALGORITHMIC));
133
- rb_define_const(cClamAV, "CL_SCAN_PHISHING_BLOCKSSL", INT2FIX(CL_SCAN_PHISHING_BLOCKSSL)); /* ssl mismatches, not ssl by itself */
134
- rb_define_const(cClamAV, "CL_SCAN_PHISHING_BLOCKCLOAK", INT2FIX(CL_SCAN_PHISHING_BLOCKCLOAK));
135
- rb_define_const(cClamAV, "CL_SCAN_ELF", INT2FIX(CL_SCAN_ELF));
136
- rb_define_const(cClamAV, "CL_SCAN_PDF", INT2FIX(CL_SCAN_PDF));
137
- rb_define_const(cClamAV, "CL_SCAN_STRUCTURED", INT2FIX(CL_SCAN_STRUCTURED));
138
- rb_define_const(cClamAV, "CL_SCAN_STRUCTURED_SSN_NORMAL", INT2FIX(CL_SCAN_STRUCTURED_SSN_NORMAL));
139
- rb_define_const(cClamAV, "CL_SCAN_STRUCTURED_SSN_STRIPPED", INT2FIX(CL_SCAN_STRUCTURED_SSN_STRIPPED));
140
- rb_define_const(cClamAV, "CL_SCAN_PARTIAL_MESSAGE", INT2FIX(CL_SCAN_PARTIAL_MESSAGE));
141
- rb_define_const(cClamAV, "CL_SCAN_HEURISTIC_PRECEDENCE", INT2FIX(CL_SCAN_HEURISTIC_PRECEDENCE));
142
-
143
- /* recommended scan settings */
144
- rb_define_const(cClamAV, "CL_SCAN_STDOPT", INT2FIX(CL_SCAN_STDOPT));
145
-
206
+ #include <const.h>
146
207
  }
@@ -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
+
@@ -4,6 +4,6 @@ require "mkmf"
4
4
 
5
5
  dir_config("clamav")
6
6
 
7
- if have_header("clamav.h") && have_library('clamav', 'cl_loaddbdir')
7
+ if have_header("clamav.h") && have_library('clamav', 'cl_engine_compile')
8
8
  create_makefile("clamav")
9
9
  end
data/rakefile CHANGED
@@ -5,7 +5,7 @@ require 'rake/gempackagetask'
5
5
  require 'tools/rakehelp'
6
6
  require 'spec/rake/spectask'
7
7
 
8
- GEM_VERSION="0.2.2"
8
+ GEM_VERSION="0.3.0"
9
9
 
10
10
  setup_extension('clamav', 'clamav')
11
11
 
@@ -25,20 +25,21 @@ gemspec = Gem::Specification.new do |gemspec|
25
25
  gemspec.version = GEM_VERSION
26
26
  gemspec.author = "Alexander Oryol"
27
27
  gemspec.email = "eagle.alex@gmail.com"
28
- gemspec.summary = "ClamAV Ruby binding"
28
+ gemspec.summary = "ClamAV Ruby bindings"
29
+ gemspec.homepage = "http://github.com/eagleas/clamav"
30
+ gemspec.rubyforge_project = 'clamav'
29
31
  gemspec.description = <<-EOF
30
- ClamAV Ruby binding. Based on project clamavr-0.2.0
31
- http://raa.ruby-lang.org/project/clamavr/
32
- Thanks to MoonWoolf <moonwolf@moonwolf.com>
32
+ ClamAV Ruby bindings.
33
33
  EOF
34
- gemspec.files = %w( rakefile README ChangeLog ) +
34
+ gemspec.files = %w( rakefile README.rdoc ChangeLog ) +
35
35
  Dir.glob( 'lib/*.rb' ) +
36
36
  Dir.glob( 'spec/*.rb' ) +
37
37
  Dir.glob( 'spec/unit/*.rb' ) +
38
- Dir.glob( 'ext/**/*.{c,rb}' ) +
38
+ Dir.glob( 'spec/clamav-testfiles/*' ) +
39
+ Dir.glob( 'ext/**/*.{c,rb,h}' ) +
39
40
  Dir.glob( 'tools/*.rb' )
40
- gemspec.autorequire = 'clamav'
41
41
  gemspec.require_path = 'lib'
42
+ gemspec.has_rdoc = 'false'
42
43
  # gemspec.add_dependency('builder')
43
44
 
44
45
  if RUBY_PLATFORM.match("win32")
@@ -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,{}))
@@ -0,0 +1,2 @@
1
+ User-agent: *
2
+ Disallow:
@@ -0,0 +1 @@
1
+ X5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*
@@ -2,15 +2,7 @@ require File.dirname(__FILE__) + '/../spec_helper'
2
2
 
3
3
  class ClamAV
4
4
 
5
- describe "class" do
6
-
7
- before(:each) do
8
- @clam = ClamAV.new()
9
- end
10
-
11
- it "should be instance of Clamav" do
12
- @clam.should be_instance_of(ClamAV)
13
- end
5
+ describe "ClamAV" do
14
6
 
15
7
  FILES = {
16
8
  'robots.txt' => CL_CLEAN,
@@ -22,19 +14,114 @@ class ClamAV
22
14
  'clam.zip' => 'ClamAV-Test-File',
23
15
  'clam-v2.rar' => 'ClamAV-Test-File',
24
16
  'clam-v3.rar' => 'ClamAV-Test-File',
25
- 'clam-p.rar' => 'Encrypted.RAR', # encripted RAR
26
- # Bug in ClamAV https://wwws.clamav.net/bugzilla/show_bug.cgi?id=1134
27
- # Fixed in 0.94
28
- 'clam-ph.rar' => 'Encrypted.RAR', # encripted RAR with encrypted both file data and headers
17
+ 'clam-p.rar' => CL_CLEAN, # encripted RAR
18
+ 'clam-ph.rar' => CL_CLEAN, # encripted RAR with encrypted both file data and headers
29
19
  'program.doc' => 'W97M.Class.EB',
30
20
  'Программа.doc' => 'W97M.Class.EB', # filename in UTF-8
31
21
  }
32
22
 
33
- FILES.each do |file, result|
34
- it "should scan #{file} with result #{result.to_s}" do
35
- @clam.scanfile(File.join(File.dirname(__FILE__), "../clamav-testfiles/", file),
36
- CL_SCAN_STDOPT | CL_SCAN_BLOCKENCRYPTED).should == result
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'
37
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
+
38
125
  end
39
126
 
40
127
  end
metadata CHANGED
@@ -1,19 +1,19 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: clamav
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexander Oryol
8
- autorequire: clamav
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-09-08 00:00:00 +04:00
12
+ date: 2009-04-07 00:00:00 +04:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
16
- description: ClamAV Ruby binding. Based on project clamavr-0.2.0 http://raa.ruby-lang.org/project/clamavr/ Thanks to MoonWoolf <moonwolf@moonwolf.com>
16
+ description: ClamAV Ruby bindings.
17
17
  email: eagle.alex@gmail.com
18
18
  executables: []
19
19
 
@@ -23,15 +23,32 @@ extra_rdoc_files: []
23
23
 
24
24
  files:
25
25
  - rakefile
26
- - README
26
+ - README.rdoc
27
27
  - ChangeLog
28
28
  - spec/spec_helper.rb
29
29
  - spec/unit/clamav_spec.rb
30
+ - spec/clamav-testfiles/multi.zip
31
+ - spec/clamav-testfiles/clam.exe.bz2
32
+ - spec/clamav-testfiles/clam.zip
33
+ - spec/clamav-testfiles/eicar.com
34
+ - spec/clamav-testfiles/test.rar
35
+ - "spec/clamav-testfiles/\xD0\x9F\xD1\x80\xD0\xBE\xD0\xB3\xD1\x80\xD0\xB0\xD0\xBC\xD0\xBC\xD0\xB0.doc"
36
+ - spec/clamav-testfiles/jquery.tooltip.pack.js
37
+ - spec/clamav-testfiles/robots.txt
38
+ - spec/clamav-testfiles/clam-v3.rar
39
+ - spec/clamav-testfiles/clam.exe
40
+ - spec/clamav-testfiles/clam-ph.rar
41
+ - spec/clamav-testfiles/test.txt
42
+ - spec/clamav-testfiles/clam.cab
43
+ - spec/clamav-testfiles/clam-v2.rar
44
+ - spec/clamav-testfiles/program.doc
45
+ - spec/clamav-testfiles/clam-p.rar
30
46
  - ext/clamav/clamav.c
31
47
  - ext/clamav/extconf.rb
48
+ - ext/clamav/const.h
32
49
  - tools/rakehelp.rb
33
- has_rdoc: false
34
- homepage:
50
+ has_rdoc: "false"
51
+ homepage: http://github.com/eagleas/clamav
35
52
  post_install_message:
36
53
  rdoc_options: []
37
54
 
@@ -51,10 +68,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
51
68
  version:
52
69
  requirements: []
53
70
 
54
- rubyforge_project:
55
- rubygems_version: 1.2.0
71
+ rubyforge_project: clamav
72
+ rubygems_version: 1.3.1
56
73
  signing_key:
57
74
  specification_version: 2
58
- summary: ClamAV Ruby binding
75
+ summary: ClamAV Ruby bindings
59
76
  test_files: []
60
77
 
data/README DELETED
@@ -1,35 +0,0 @@
1
- ClamAV Ruby binding gem. Based on project clamavr-0.2.0
2
- http://raa.ruby-lang.org/project/clamavr/
3
- Thanks to MoonWoolf <moonwolf@moonwolf.com>
4
-
5
- == INSTALL
6
-
7
- $ sudo gem install clamav
8
- or
9
- $ rake package && cd pkg && sudo gem install *.gem
10
-
11
- == REQUIREMENTS
12
-
13
- clamav >= 0.94
14
- libclamav5, libclamav-dev
15
-
16
- == USAGE
17
- ClamAV.new()
18
- return:
19
- ClamAV instance
20
-
21
- ClamAV#scanfile(filename, options)
22
- filename => filename
23
- options => CL_SCAN_STDOPT
24
-
25
- return:
26
- virusname or ClamAV returncode(Fixnum)
27
-
28
- == LICENSE
29
- GPL
30
-
31
- = Clamav as gem
32
- Copyright(c) 2008 Alexander Oryol <eagle.alex@gmail.com>
33
-
34
- = ClamAV/R
35
- Copyright(c) 2003-2007 MoonWolf <moonwolf@moonwolf.com>