ddr-antivirus 1.3.1 → 1.3.2
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b58d6f83c9173427169af66c7d2ccb1a483a81a9
|
4
|
+
data.tar.gz: bf079fc09190effa086373ffb297666bab0aaf27
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7b90cccfce3fc9c011637c97388541b807f45f6db96f791af66b23aeecdac0acf2fd1f301e34ca7945d494fce2100e3c6de1b71eb56eeebfa280d65be2bb1acb
|
7
|
+
data.tar.gz: 7e170161b67ecb23e110b1917b3f818e42935c13d345949da0e479e2fb7fbf36fa8de32ad437fab8086e9ef0167e98f8f0ee99794289c21955e3ca7558ec279d
|
@@ -1,3 +1,4 @@
|
|
1
|
+
require "fileutils"
|
1
2
|
require_relative "scanner_adapter"
|
2
3
|
require_relative "scan_result"
|
3
4
|
|
@@ -15,6 +16,16 @@ module Ddr
|
|
15
16
|
end
|
16
17
|
|
17
18
|
def clamdscan(path)
|
19
|
+
original_mode = File.stat(path).mode
|
20
|
+
FileUtils.chmod("a+r", path) unless File.world_readable?(path)
|
21
|
+
result = command(path)
|
22
|
+
FileUtils.chmod(original_mode, path) if File.stat(path).mode != original_mode
|
23
|
+
result
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def command(path)
|
18
29
|
`clamdscan --no-summary #{path}`.strip
|
19
30
|
end
|
20
31
|
|
@@ -24,7 +35,7 @@ module Ddr
|
|
24
35
|
# Result of a scan with the ClamdScannerAdapter
|
25
36
|
#
|
26
37
|
class ClamdScanResult < ScanResult
|
27
|
-
|
38
|
+
|
28
39
|
def virus_found
|
29
40
|
if m = /: ([^\s]+) FOUND$/.match(raw)
|
30
41
|
m[1]
|
@@ -7,10 +7,38 @@ module Ddr
|
|
7
7
|
RSpec.describe ClamdScannerAdapter do
|
8
8
|
|
9
9
|
let(:path) { File.expand_path(File.join("..", "..", "fixtures", "blue-devil.png"), __FILE__) }
|
10
|
+
let(:adapter) { described_class.new }
|
11
|
+
|
12
|
+
describe "permissions" do
|
13
|
+
before do
|
14
|
+
@file = Tempfile.new("test")
|
15
|
+
@file.write("Scan me!")
|
16
|
+
@file.close
|
17
|
+
allow(adapter).to receive(:command).with(@file.path) { "#{@file.path}: OK" }
|
18
|
+
end
|
19
|
+
after { @file.unlink }
|
20
|
+
describe "when the file is not world readable" do
|
21
|
+
it "should temporarily change the permissions" do
|
22
|
+
original_mode = File.stat(@file.path).mode
|
23
|
+
expect(FileUtils).to receive(:chmod).with("a+r", @file.path)
|
24
|
+
adapter.scan(@file.path)
|
25
|
+
expect(File.stat(@file.path).mode).to eq(original_mode)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
describe "when the file is world readable" do
|
29
|
+
before { FileUtils.chmod("a+r", @file.path) }
|
30
|
+
it "should not change the permissions" do
|
31
|
+
original_mode = File.stat(@file.path).mode
|
32
|
+
expect(FileUtils).not_to receive(:chmod)
|
33
|
+
adapter.scan(@file.path)
|
34
|
+
expect(File.stat(@file.path).mode).to eq(original_mode)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
10
38
|
|
11
39
|
describe "result" do
|
12
40
|
subject { adapter.scan(path) }
|
13
|
-
|
41
|
+
|
14
42
|
it "should be a scan result" do
|
15
43
|
expect(subject).to be_a(ClamdScanResult)
|
16
44
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ddr-antivirus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Chandek-Stark
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-01-
|
11
|
+
date: 2015-01-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|