clamrb 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +2 -0
- data/Gemfile +6 -0
- data/README.md +31 -0
- data/Rakefile +28 -0
- data/ext/clamrb/Makefile +263 -0
- data/ext/clamrb/clamrb.c +70 -0
- data/ext/clamrb/extconf.rb +3 -0
- data/ext/clamrb/mkmf.log +34 -0
- data/lib/clamrb.rb +2 -0
- data/lib/clamrb/result.rb +9 -0
- metadata +82 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 9d80319ba09033729946002cb5210dc5e307f55b5c150c9e84fbd58714a0c3c3
|
4
|
+
data.tar.gz: e4b415697de5596cc54f6c9d8f9340389909f610579e38032c159eaafd455a34
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 5b17c574a53574170539476ecf00159cbe509104c32f80fe24acb2278d4570ee197ec11ba148632aa0e5cbf62f1708370b2d99d9b1f6fb240c2435e33c0b8588
|
7
|
+
data.tar.gz: 9cb4348b76d66dd679a37ae5277a12932232062848b3cd39177d17fb2438c2a7bc2f0cc27a9343543d6f22d95aff6ac59dfc37d9163cce4afd5fd69df8710245
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# clamrb
|
2
|
+
|
3
|
+
This project is a Ruby gem that interfaces with the Clam AV engine using libclamav.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'clamrb'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install foo
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
```ruby
|
24
|
+
clamrb = Clamrb.new
|
25
|
+
clamrb.scan "file.txt"
|
26
|
+
=> #<Clamrb::Result:0x00000000012d2458 @status=:infected, @identifier="Eicar-Test-Signature">
|
27
|
+
```
|
28
|
+
|
29
|
+
## Contributing
|
30
|
+
|
31
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/abedra/clamrb.
|
data/Rakefile
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'bundler/gem_tasks'
|
2
|
+
require 'rake/testtask'
|
3
|
+
require 'rake/clean'
|
4
|
+
require 'rbconfig'
|
5
|
+
require 'fileutils'
|
6
|
+
|
7
|
+
EXT = RbConfig::CONFIG['DLEXT']
|
8
|
+
|
9
|
+
file "lib/clamrb/clamrb.#{EXT}" => Dir.glob('ext/clamrb/*.c') do
|
10
|
+
Dir.chdir('ext/clamrb') do
|
11
|
+
ruby "extconf.rb"
|
12
|
+
sh "make"
|
13
|
+
end
|
14
|
+
FileUtils.mkdir_p('lib/clamrb')
|
15
|
+
cp "ext/clamrb/clamrb.#{EXT}", "lib/clamrb/clamrb.#{EXT}"
|
16
|
+
end
|
17
|
+
|
18
|
+
task :test => "lib/clamrb/clamrb.#{EXT}"
|
19
|
+
|
20
|
+
CLEAN.include("ext/**/*{.o,.log,.#{EXT}")
|
21
|
+
CLEAN.include('ext/**/Makefile')
|
22
|
+
CLEAN.include("lib/**/*.#{EXT}")
|
23
|
+
|
24
|
+
Rake::TestTask.new do |t|
|
25
|
+
t.libs << 'test'
|
26
|
+
end
|
27
|
+
|
28
|
+
task :default => :test
|
data/ext/clamrb/Makefile
ADDED
@@ -0,0 +1,263 @@
|
|
1
|
+
|
2
|
+
SHELL = /bin/sh
|
3
|
+
|
4
|
+
# V=0 quiet, V=1 verbose. other values don't work.
|
5
|
+
V = 0
|
6
|
+
Q1 = $(V:1=)
|
7
|
+
Q = $(Q1:0=@)
|
8
|
+
ECHO1 = $(V:1=@ :)
|
9
|
+
ECHO = $(ECHO1:0=@ echo)
|
10
|
+
NULLCMD = :
|
11
|
+
|
12
|
+
#### Start of system configuration section. ####
|
13
|
+
|
14
|
+
srcdir = .
|
15
|
+
topdir = /home/abedra/.rvm/rubies/ruby-2.5.1/include/ruby-2.5.0
|
16
|
+
hdrdir = $(topdir)
|
17
|
+
arch_hdrdir = /home/abedra/.rvm/rubies/ruby-2.5.1/include/ruby-2.5.0/x86_64-linux
|
18
|
+
PATH_SEPARATOR = :
|
19
|
+
VPATH = $(srcdir):$(arch_hdrdir)/ruby:$(hdrdir)/ruby
|
20
|
+
prefix = $(DESTDIR)/home/abedra/.rvm/rubies/ruby-2.5.1
|
21
|
+
rubysitearchprefix = $(rubylibprefix)/$(sitearch)
|
22
|
+
rubyarchprefix = $(rubylibprefix)/$(arch)
|
23
|
+
rubylibprefix = $(libdir)/$(RUBY_BASE_NAME)
|
24
|
+
exec_prefix = $(prefix)
|
25
|
+
vendorarchhdrdir = $(vendorhdrdir)/$(sitearch)
|
26
|
+
sitearchhdrdir = $(sitehdrdir)/$(sitearch)
|
27
|
+
rubyarchhdrdir = $(rubyhdrdir)/$(arch)
|
28
|
+
vendorhdrdir = $(rubyhdrdir)/vendor_ruby
|
29
|
+
sitehdrdir = $(rubyhdrdir)/site_ruby
|
30
|
+
rubyhdrdir = $(includedir)/$(RUBY_VERSION_NAME)
|
31
|
+
vendorarchdir = $(vendorlibdir)/$(sitearch)
|
32
|
+
vendorlibdir = $(vendordir)/$(ruby_version)
|
33
|
+
vendordir = $(rubylibprefix)/vendor_ruby
|
34
|
+
sitearchdir = $(sitelibdir)/$(sitearch)
|
35
|
+
sitelibdir = $(sitedir)/$(ruby_version)
|
36
|
+
sitedir = $(rubylibprefix)/site_ruby
|
37
|
+
rubyarchdir = $(rubylibdir)/$(arch)
|
38
|
+
rubylibdir = $(rubylibprefix)/$(ruby_version)
|
39
|
+
sitearchincludedir = $(includedir)/$(sitearch)
|
40
|
+
archincludedir = $(includedir)/$(arch)
|
41
|
+
sitearchlibdir = $(libdir)/$(sitearch)
|
42
|
+
archlibdir = $(libdir)/$(arch)
|
43
|
+
ridir = $(datarootdir)/$(RI_BASE_NAME)
|
44
|
+
mandir = $(datarootdir)/man
|
45
|
+
localedir = $(datarootdir)/locale
|
46
|
+
libdir = $(exec_prefix)/lib
|
47
|
+
psdir = $(docdir)
|
48
|
+
pdfdir = $(docdir)
|
49
|
+
dvidir = $(docdir)
|
50
|
+
htmldir = $(docdir)
|
51
|
+
infodir = $(datarootdir)/info
|
52
|
+
docdir = $(datarootdir)/doc/$(PACKAGE)
|
53
|
+
oldincludedir = $(DESTDIR)/usr/include
|
54
|
+
includedir = $(prefix)/include
|
55
|
+
localstatedir = $(prefix)/var
|
56
|
+
sharedstatedir = $(prefix)/com
|
57
|
+
sysconfdir = $(prefix)/etc
|
58
|
+
datadir = $(datarootdir)
|
59
|
+
datarootdir = $(prefix)/share
|
60
|
+
libexecdir = $(exec_prefix)/libexec
|
61
|
+
sbindir = $(exec_prefix)/sbin
|
62
|
+
bindir = $(exec_prefix)/bin
|
63
|
+
archdir = $(rubyarchdir)
|
64
|
+
|
65
|
+
|
66
|
+
CC = gcc
|
67
|
+
CXX = g++
|
68
|
+
LIBRUBY = $(LIBRUBY_SO)
|
69
|
+
LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
|
70
|
+
LIBRUBYARG_SHARED = -Wl,-rpath,$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)
|
71
|
+
LIBRUBYARG_STATIC = -Wl,-rpath,$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)-static
|
72
|
+
empty =
|
73
|
+
OUTFLAG = -o $(empty)
|
74
|
+
COUTFLAG = -o $(empty)
|
75
|
+
CSRCFLAG = $(empty)
|
76
|
+
|
77
|
+
RUBY_EXTCONF_H =
|
78
|
+
cflags = $(optflags) $(debugflags) $(warnflags)
|
79
|
+
cxxflags = $(optflags) $(debugflags) $(warnflags)
|
80
|
+
optflags = -O3
|
81
|
+
debugflags = -ggdb3
|
82
|
+
warnflags = -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wno-tautological-compare -Wno-parentheses-equality -Wno-constant-logical-operand -Wno-self-assign -Wunused-variable -Wimplicit-int -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wmisleading-indentation -Wno-packed-bitfield-compat -Wsuggest-attribute=noreturn -Wsuggest-attribute=format -Wimplicit-fallthrough=0 -Wduplicated-cond -Wrestrict
|
83
|
+
CCDLFLAGS = -fPIC
|
84
|
+
CFLAGS = $(CCDLFLAGS) $(cflags) -fPIC $(ARCH_FLAG)
|
85
|
+
INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir)/ruby/backward -I$(hdrdir) -I$(srcdir)
|
86
|
+
DEFS =
|
87
|
+
CPPFLAGS = $(DEFS) $(cppflags)
|
88
|
+
CXXFLAGS = $(CCDLFLAGS) $(cxxflags) $(ARCH_FLAG)
|
89
|
+
ldflags = -L. -fstack-protector -rdynamic -Wl,-export-dynamic
|
90
|
+
dldflags = -Wl,--compress-debug-sections=zlib
|
91
|
+
ARCH_FLAG =
|
92
|
+
DLDFLAGS = $(ldflags) $(dldflags) $(ARCH_FLAG)
|
93
|
+
LDSHARED = $(CC) -shared
|
94
|
+
LDSHAREDXX = $(CXX) -shared
|
95
|
+
AR = ar
|
96
|
+
EXEEXT =
|
97
|
+
|
98
|
+
RUBY_INSTALL_NAME = $(RUBY_BASE_NAME)
|
99
|
+
RUBY_SO_NAME = ruby
|
100
|
+
RUBYW_INSTALL_NAME =
|
101
|
+
RUBY_VERSION_NAME = $(RUBY_BASE_NAME)-$(ruby_version)
|
102
|
+
RUBYW_BASE_NAME = rubyw
|
103
|
+
RUBY_BASE_NAME = ruby
|
104
|
+
|
105
|
+
arch = x86_64-linux
|
106
|
+
sitearch = $(arch)
|
107
|
+
ruby_version = 2.5.0
|
108
|
+
ruby = $(bindir)/$(RUBY_BASE_NAME)
|
109
|
+
RUBY = $(ruby)
|
110
|
+
ruby_headers = $(hdrdir)/ruby.h $(hdrdir)/ruby/backward.h $(hdrdir)/ruby/ruby.h $(hdrdir)/ruby/defines.h $(hdrdir)/ruby/missing.h $(hdrdir)/ruby/intern.h $(hdrdir)/ruby/st.h $(hdrdir)/ruby/subst.h $(arch_hdrdir)/ruby/config.h
|
111
|
+
|
112
|
+
RM = rm -f
|
113
|
+
RM_RF = $(RUBY) -run -e rm -- -rf
|
114
|
+
RMDIRS = rmdir --ignore-fail-on-non-empty -p
|
115
|
+
MAKEDIRS = /usr/bin/mkdir -p
|
116
|
+
INSTALL = /usr/bin/install -c
|
117
|
+
INSTALL_PROG = $(INSTALL) -m 0755
|
118
|
+
INSTALL_DATA = $(INSTALL) -m 644
|
119
|
+
COPY = cp
|
120
|
+
TOUCH = exit >
|
121
|
+
|
122
|
+
#### End of system configuration section. ####
|
123
|
+
|
124
|
+
preload =
|
125
|
+
libpath = . $(libdir)
|
126
|
+
LIBPATH = -L. -L$(libdir) -Wl,-rpath,$(libdir)
|
127
|
+
DEFFILE =
|
128
|
+
|
129
|
+
CLEANFILES = mkmf.log
|
130
|
+
DISTCLEANFILES =
|
131
|
+
DISTCLEANDIRS =
|
132
|
+
|
133
|
+
extout =
|
134
|
+
extout_prefix =
|
135
|
+
target_prefix = /clamrb
|
136
|
+
LOCAL_LIBS =
|
137
|
+
LIBS = $(LIBRUBYARG_SHARED) -lclamav -lpthread -ldl -lcrypt -lm -lc
|
138
|
+
ORIG_SRCS = clamrb.c
|
139
|
+
SRCS = $(ORIG_SRCS)
|
140
|
+
OBJS = clamrb.o
|
141
|
+
HDRS =
|
142
|
+
LOCAL_HDRS =
|
143
|
+
TARGET = clamrb
|
144
|
+
TARGET_NAME = clamrb
|
145
|
+
TARGET_ENTRY = Init_$(TARGET_NAME)
|
146
|
+
DLLIB = $(TARGET).so
|
147
|
+
EXTSTATIC =
|
148
|
+
STATIC_LIB =
|
149
|
+
|
150
|
+
TIMESTAMP_DIR = .
|
151
|
+
BINDIR = $(bindir)
|
152
|
+
RUBYCOMMONDIR = $(sitedir)$(target_prefix)
|
153
|
+
RUBYLIBDIR = $(sitelibdir)$(target_prefix)
|
154
|
+
RUBYARCHDIR = $(sitearchdir)$(target_prefix)
|
155
|
+
HDRDIR = $(rubyhdrdir)/ruby$(target_prefix)
|
156
|
+
ARCHHDRDIR = $(rubyhdrdir)/$(arch)/ruby$(target_prefix)
|
157
|
+
TARGET_SO_DIR =
|
158
|
+
TARGET_SO = $(TARGET_SO_DIR)$(DLLIB)
|
159
|
+
CLEANLIBS = $(TARGET_SO)
|
160
|
+
CLEANOBJS = *.o *.bak
|
161
|
+
|
162
|
+
all: $(DLLIB)
|
163
|
+
static: $(STATIC_LIB)
|
164
|
+
.PHONY: all install static install-so install-rb
|
165
|
+
.PHONY: clean clean-so clean-static clean-rb
|
166
|
+
|
167
|
+
clean-static::
|
168
|
+
clean-rb-default::
|
169
|
+
clean-rb::
|
170
|
+
clean-so::
|
171
|
+
clean: clean-so clean-static clean-rb-default clean-rb
|
172
|
+
-$(Q)$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES) .*.time
|
173
|
+
|
174
|
+
distclean-rb-default::
|
175
|
+
distclean-rb::
|
176
|
+
distclean-so::
|
177
|
+
distclean-static::
|
178
|
+
distclean: clean distclean-so distclean-static distclean-rb-default distclean-rb
|
179
|
+
-$(Q)$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
|
180
|
+
-$(Q)$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
|
181
|
+
-$(Q)$(RMDIRS) $(DISTCLEANDIRS) 2> /dev/null || true
|
182
|
+
|
183
|
+
realclean: distclean
|
184
|
+
install: install-so install-rb
|
185
|
+
|
186
|
+
install-so: $(DLLIB) $(TIMESTAMP_DIR)/.sitearchdir.-.clamrb.time
|
187
|
+
$(INSTALL_PROG) $(DLLIB) $(RUBYARCHDIR)
|
188
|
+
clean-static::
|
189
|
+
-$(Q)$(RM) $(STATIC_LIB)
|
190
|
+
install-rb: pre-install-rb do-install-rb install-rb-default
|
191
|
+
install-rb-default: pre-install-rb-default do-install-rb-default
|
192
|
+
pre-install-rb: Makefile
|
193
|
+
pre-install-rb-default: Makefile
|
194
|
+
do-install-rb:
|
195
|
+
do-install-rb-default:
|
196
|
+
pre-install-rb-default:
|
197
|
+
@$(NULLCMD)
|
198
|
+
$(TIMESTAMP_DIR)/.sitearchdir.-.clamrb.time:
|
199
|
+
$(Q) $(MAKEDIRS) $(@D) $(RUBYARCHDIR)
|
200
|
+
$(Q) $(TOUCH) $@
|
201
|
+
|
202
|
+
site-install: site-install-so site-install-rb
|
203
|
+
site-install-so: install-so
|
204
|
+
site-install-rb: install-rb
|
205
|
+
|
206
|
+
.SUFFIXES: .c .m .cc .mm .cxx .cpp .o .S
|
207
|
+
|
208
|
+
.cc.o:
|
209
|
+
$(ECHO) compiling $(<)
|
210
|
+
$(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $(CSRCFLAG)$<
|
211
|
+
|
212
|
+
.cc.S:
|
213
|
+
$(ECHO) translating $(<)
|
214
|
+
$(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $(CSRCFLAG)$<
|
215
|
+
|
216
|
+
.mm.o:
|
217
|
+
$(ECHO) compiling $(<)
|
218
|
+
$(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $(CSRCFLAG)$<
|
219
|
+
|
220
|
+
.mm.S:
|
221
|
+
$(ECHO) translating $(<)
|
222
|
+
$(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $(CSRCFLAG)$<
|
223
|
+
|
224
|
+
.cxx.o:
|
225
|
+
$(ECHO) compiling $(<)
|
226
|
+
$(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $(CSRCFLAG)$<
|
227
|
+
|
228
|
+
.cxx.S:
|
229
|
+
$(ECHO) translating $(<)
|
230
|
+
$(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $(CSRCFLAG)$<
|
231
|
+
|
232
|
+
.cpp.o:
|
233
|
+
$(ECHO) compiling $(<)
|
234
|
+
$(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $(CSRCFLAG)$<
|
235
|
+
|
236
|
+
.cpp.S:
|
237
|
+
$(ECHO) translating $(<)
|
238
|
+
$(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $(CSRCFLAG)$<
|
239
|
+
|
240
|
+
.c.o:
|
241
|
+
$(ECHO) compiling $(<)
|
242
|
+
$(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $(CSRCFLAG)$<
|
243
|
+
|
244
|
+
.c.S:
|
245
|
+
$(ECHO) translating $(<)
|
246
|
+
$(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $(CSRCFLAG)$<
|
247
|
+
|
248
|
+
.m.o:
|
249
|
+
$(ECHO) compiling $(<)
|
250
|
+
$(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $(CSRCFLAG)$<
|
251
|
+
|
252
|
+
.m.S:
|
253
|
+
$(ECHO) translating $(<)
|
254
|
+
$(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $(CSRCFLAG)$<
|
255
|
+
|
256
|
+
$(TARGET_SO): $(OBJS) Makefile
|
257
|
+
$(ECHO) linking shared-object clamrb/$(DLLIB)
|
258
|
+
-$(Q)$(RM) $(@)
|
259
|
+
$(Q) $(LDSHARED) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
|
260
|
+
|
261
|
+
|
262
|
+
|
263
|
+
$(OBJS): $(HDRS) $(ruby_headers)
|
data/ext/clamrb/clamrb.c
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
#include <ruby.h>
|
2
|
+
#include "clamav.h"
|
3
|
+
|
4
|
+
static void clamav_free(void *engine) {
|
5
|
+
cl_engine_free(engine);
|
6
|
+
}
|
7
|
+
|
8
|
+
VALUE constructor(VALUE self, VALUE filename)
|
9
|
+
{
|
10
|
+
VALUE t_data;
|
11
|
+
const char *dbDir;
|
12
|
+
unsigned int signature;
|
13
|
+
|
14
|
+
if (cl_init(CL_INIT_DEFAULT) == CL_SUCCESS) {
|
15
|
+
struct cl_engine *engine = cl_engine_new();
|
16
|
+
t_data = Data_Wrap_Struct(self, 0, clamav_free, engine);
|
17
|
+
dbDir = cl_retdbdir();
|
18
|
+
printf("Initializing clamav engine from database located at %s\n", dbDir);
|
19
|
+
signature = 0;
|
20
|
+
if (cl_load(dbDir, engine, &signature, CL_DB_STDOPT) == CL_SUCCESS
|
21
|
+
&& cl_engine_compile(engine) == CL_SUCCESS) {
|
22
|
+
return t_data;
|
23
|
+
} else {
|
24
|
+
rb_raise(rb_eRuntimeError, "Error loading clamav database\n");
|
25
|
+
return Qnil;
|
26
|
+
}
|
27
|
+
} else {
|
28
|
+
rb_raise(rb_eRuntimeError, "Unable to initialize clamav\n");
|
29
|
+
return Qnil;
|
30
|
+
}
|
31
|
+
}
|
32
|
+
|
33
|
+
VALUE scan(VALUE self, VALUE filename)
|
34
|
+
{
|
35
|
+
struct cl_engine *engine;
|
36
|
+
const char *name;
|
37
|
+
long unsigned int scanned;
|
38
|
+
int ret;
|
39
|
+
VALUE clamrb;
|
40
|
+
VALUE clamrb_result;
|
41
|
+
|
42
|
+
Data_Get_Struct(self, struct cl_engine, engine);
|
43
|
+
name = NULL;
|
44
|
+
scanned = 0;
|
45
|
+
ret = cl_scanfile(StringValueCStr(filename), &name, &scanned, engine, CL_SCAN_STDOPT);
|
46
|
+
|
47
|
+
clamrb = rb_const_get(rb_cObject, rb_intern("Clamrb"));
|
48
|
+
clamrb_result = rb_const_get(clamrb, rb_intern("Result"));
|
49
|
+
|
50
|
+
switch (ret) {
|
51
|
+
case CL_VIRUS:
|
52
|
+
return rb_funcall(clamrb_result, rb_intern("new"), 2,
|
53
|
+
ID2SYM(rb_intern("infected")),
|
54
|
+
rb_str_new_cstr(name));
|
55
|
+
|
56
|
+
case CL_CLEAN:
|
57
|
+
return rb_funcall(clamrb_result, rb_intern("new"), 1,
|
58
|
+
ID2SYM(rb_intern("clean")));
|
59
|
+
default:
|
60
|
+
return rb_funcall(clamrb_result, rb_intern("new"), 1,
|
61
|
+
ID2SYM(rb_intern("unknown")));
|
62
|
+
}
|
63
|
+
}
|
64
|
+
|
65
|
+
void Init_clamrb(void)
|
66
|
+
{
|
67
|
+
VALUE klass = rb_define_class("Clamrb", rb_cObject);
|
68
|
+
rb_define_singleton_method(klass, "new", constructor, 0);
|
69
|
+
rb_define_method(klass, "scan", scan, 1);
|
70
|
+
}
|
data/ext/clamrb/mkmf.log
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
have_library: checking for -lclamav... -------------------- yes
|
2
|
+
|
3
|
+
"gcc -o conftest -I/home/abedra/.rvm/rubies/ruby-2.5.1/include/ruby-2.5.0/x86_64-linux -I/home/abedra/.rvm/rubies/ruby-2.5.1/include/ruby-2.5.0/ruby/backward -I/home/abedra/.rvm/rubies/ruby-2.5.1/include/ruby-2.5.0 -I. -O3 -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wno-tautological-compare -Wno-parentheses-equality -Wno-constant-logical-operand -Wno-self-assign -Wunused-variable -Wimplicit-int -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wmisleading-indentation -Wno-packed-bitfield-compat -Wsuggest-attribute=noreturn -Wsuggest-attribute=format -Wimplicit-fallthrough=0 -Wduplicated-cond -Wrestrict -fPIC conftest.c -L. -L/home/abedra/.rvm/rubies/ruby-2.5.1/lib -Wl,-rpath,/home/abedra/.rvm/rubies/ruby-2.5.1/lib -L. -fstack-protector -rdynamic -Wl,-export-dynamic -Wl,-rpath,/home/abedra/.rvm/rubies/ruby-2.5.1/lib -L/home/abedra/.rvm/rubies/ruby-2.5.1/lib -lruby -lpthread -ldl -lcrypt -lm -lc"
|
4
|
+
checked program was:
|
5
|
+
/* begin */
|
6
|
+
1: #include "ruby.h"
|
7
|
+
2:
|
8
|
+
3: int main(int argc, char **argv)
|
9
|
+
4: {
|
10
|
+
5: return 0;
|
11
|
+
6: }
|
12
|
+
/* end */
|
13
|
+
|
14
|
+
"gcc -o conftest -I/home/abedra/.rvm/rubies/ruby-2.5.1/include/ruby-2.5.0/x86_64-linux -I/home/abedra/.rvm/rubies/ruby-2.5.1/include/ruby-2.5.0/ruby/backward -I/home/abedra/.rvm/rubies/ruby-2.5.1/include/ruby-2.5.0 -I. -O3 -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wno-tautological-compare -Wno-parentheses-equality -Wno-constant-logical-operand -Wno-self-assign -Wunused-variable -Wimplicit-int -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wmisleading-indentation -Wno-packed-bitfield-compat -Wsuggest-attribute=noreturn -Wsuggest-attribute=format -Wimplicit-fallthrough=0 -Wduplicated-cond -Wrestrict -fPIC conftest.c -L. -L/home/abedra/.rvm/rubies/ruby-2.5.1/lib -Wl,-rpath,/home/abedra/.rvm/rubies/ruby-2.5.1/lib -L. -fstack-protector -rdynamic -Wl,-export-dynamic -Wl,-rpath,/home/abedra/.rvm/rubies/ruby-2.5.1/lib -L/home/abedra/.rvm/rubies/ruby-2.5.1/lib -lruby -lclamav -lpthread -ldl -lcrypt -lm -lc"
|
15
|
+
checked program was:
|
16
|
+
/* begin */
|
17
|
+
1: #include "ruby.h"
|
18
|
+
2:
|
19
|
+
3: /*top*/
|
20
|
+
4: extern int t(void);
|
21
|
+
5: int main(int argc, char **argv)
|
22
|
+
6: {
|
23
|
+
7: if (argc > 1000000) {
|
24
|
+
8: printf("%p", &t);
|
25
|
+
9: }
|
26
|
+
10:
|
27
|
+
11: return 0;
|
28
|
+
12: }
|
29
|
+
13:
|
30
|
+
14: int t(void) { ; return 0; }
|
31
|
+
/* end */
|
32
|
+
|
33
|
+
--------------------
|
34
|
+
|
data/lib/clamrb.rb
ADDED
metadata
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: clamrb
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Aaron Bedra
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-11-23 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.16'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.16'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
description: Native Ruby extension for running clamav scans
|
42
|
+
email: aaron@aaronbedra.com
|
43
|
+
executables: []
|
44
|
+
extensions:
|
45
|
+
- ext/clamrb/extconf.rb
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- ".gitignore"
|
49
|
+
- Gemfile
|
50
|
+
- README.md
|
51
|
+
- Rakefile
|
52
|
+
- ext/clamrb/Makefile
|
53
|
+
- ext/clamrb/clamrb.c
|
54
|
+
- ext/clamrb/extconf.rb
|
55
|
+
- ext/clamrb/mkmf.log
|
56
|
+
- lib/clamrb.rb
|
57
|
+
- lib/clamrb/result.rb
|
58
|
+
homepage: https://github.com/abedra/clamrb
|
59
|
+
licenses:
|
60
|
+
- MIT
|
61
|
+
metadata: {}
|
62
|
+
post_install_message:
|
63
|
+
rdoc_options: []
|
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
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
requirements: []
|
77
|
+
rubyforge_project:
|
78
|
+
rubygems_version: 2.7.8
|
79
|
+
signing_key:
|
80
|
+
specification_version: 4
|
81
|
+
summary: Ruby interface to Clam AV
|
82
|
+
test_files: []
|