carrierwave-attachmentscanner 0.1.0 → 0.2.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.
- checksums.yaml +5 -5
- data/.github/dependabot.yml +10 -0
- data/.github/workflows/specs.yml +31 -0
- data/.gitignore +1 -0
- data/Gemfile +1 -1
- data/README.md +1 -1
- data/carrierwave-attachmentscanner.gemspec +4 -4
- data/lib/carrierwave/attachmentscanner/version.rb +1 -1
- data/lib/carrierwave/attachmentscanner.rb +8 -6
- data/lib/generators/carrierwave_attachmentscanner/config/templates/config.rb.erb +3 -0
- metadata +15 -14
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: e45e9670c42891a1125493b4514306d2a8590020e25a87b96173902c62f602e7
|
|
4
|
+
data.tar.gz: d79657584dd306cbbf610e7f39ca2aa974ec32f0c548df798dc04cf6fbfba54f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b813f19ddb824b56dac47c9c1345200c46a66cd3019ebebd6c343003b849b7858772134d33f387856eda75e7caa61e3bc67bf507ee3bff655c5742f2a71ff097
|
|
7
|
+
data.tar.gz: d410885ff1717f3780a0a7692e6aaa9e6d6fa9fcf4d8877e3c22e1fd4feff723586fad81bba8159b13eceaedf586a97fb7f9379632f91ad7e7bc82fa430ecf99
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
name: Specs
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [master, main]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [master, main]
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
test:
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
|
|
13
|
+
strategy:
|
|
14
|
+
fail-fast: false
|
|
15
|
+
matrix:
|
|
16
|
+
ruby-version: ['ruby', 'head']
|
|
17
|
+
|
|
18
|
+
steps:
|
|
19
|
+
- uses: actions/checkout@v6
|
|
20
|
+
|
|
21
|
+
- name: Set up Ruby ${{ matrix.ruby-version }}
|
|
22
|
+
uses: ruby/setup-ruby@v1
|
|
23
|
+
with:
|
|
24
|
+
ruby-version: ${{ matrix.ruby-version }}
|
|
25
|
+
bundler-cache: true
|
|
26
|
+
|
|
27
|
+
- name: Run specs
|
|
28
|
+
env:
|
|
29
|
+
ATTACHMENT_SCANNER_URL: ${{ secrets.ATTACHMENT_SCANNER_URL || 'https://us-east-1.attachmentscanner.com' }}
|
|
30
|
+
ATTACHMENT_SCANNER_API_TOKEN: ${{ secrets.ATTACHMENT_SCANNER_API_TOKEN }}
|
|
31
|
+
run: bundle exec rspec
|
data/.gitignore
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Carrierwave::Attachmentscanner
|
|
2
2
|
|
|
3
|
-
[](https://github.com/attachmentscanner/carrierwave-attachmentscanner/actions/workflows/specs.yml) [](https://www.ruby-lang.org/)
|
|
4
4
|
|
|
5
5
|
Carrierwave::Attachmentscanner allows you to scan any file uploaded by
|
|
6
6
|
[CarrierWave](https://github.com/carrierwaveuploader/carrierwave) for viruses or
|
|
@@ -12,7 +12,7 @@ Gem::Specification.new do |spec|
|
|
|
12
12
|
spec.summary = %q{Scan carrierwave attachments using AttachmentScanner}
|
|
13
13
|
spec.description = %q{Automatically sends carrierwave uploads to AttachmentScanner to search for
|
|
14
14
|
viruses, malware and other malicious files. }
|
|
15
|
-
spec.homepage = "
|
|
15
|
+
spec.homepage = "https://www.attachmentscanner.com"
|
|
16
16
|
spec.license = "MIT"
|
|
17
17
|
|
|
18
18
|
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
|
@@ -23,10 +23,10 @@ Gem::Specification.new do |spec|
|
|
|
23
23
|
spec.require_paths = ["lib"]
|
|
24
24
|
|
|
25
25
|
spec.add_dependency "carrierwave"
|
|
26
|
-
spec.add_dependency "faraday"
|
|
27
|
-
spec.add_dependency "
|
|
26
|
+
spec.add_dependency "faraday", "~> 2.0"
|
|
27
|
+
spec.add_dependency "faraday-multipart"
|
|
28
28
|
|
|
29
29
|
spec.add_development_dependency "bundler"
|
|
30
|
-
spec.add_development_dependency "rake"
|
|
30
|
+
spec.add_development_dependency "rake"
|
|
31
31
|
spec.add_development_dependency "rspec", "~> 3.0"
|
|
32
32
|
end
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
require 'faraday'
|
|
2
|
-
require '
|
|
2
|
+
require 'faraday/multipart'
|
|
3
3
|
require 'carrierwave/attachmentscanner/version'
|
|
4
4
|
|
|
5
5
|
module CarrierWave
|
|
6
6
|
module AttachmentScanner
|
|
7
|
-
Config = Struct.new(:url, :api_token, :enabled, :logger)
|
|
7
|
+
Config = Struct.new(:url, :api_token, :enabled, :logger, :timeout)
|
|
8
8
|
.new(ENV['ATTACHMENT_SCANNER_URL'], ENV['ATTACHMENT_SCANNER_API_TOKEN'],
|
|
9
|
-
true, Logger.new(STDOUT))
|
|
9
|
+
true, Logger.new(STDOUT), 60)
|
|
10
10
|
|
|
11
11
|
DISABLED_WARNING = "[CarrierWave::AttachmentScanner] Disabled".freeze
|
|
12
12
|
|
|
@@ -62,7 +62,7 @@ module CarrierWave
|
|
|
62
62
|
|
|
63
63
|
def send_to_scanner(new_file)
|
|
64
64
|
# Needed to support the case that a StringIO is being passed.
|
|
65
|
-
# Passes the root StringIO to Faraday::
|
|
65
|
+
# Passes the root StringIO to Faraday::FilePart unless we think this is a
|
|
66
66
|
# file (i.e. has path) in which case we pass the file.
|
|
67
67
|
# We can't pass the SanitizedFile as it implements read without arguments.
|
|
68
68
|
root_file = new_file
|
|
@@ -70,16 +70,18 @@ module CarrierWave
|
|
|
70
70
|
file_or_path = root_file.respond_to?(:path) ? new_file.path : root_file
|
|
71
71
|
|
|
72
72
|
Config.logger.info("[CarrierWave::AttachmentScanner] scanning #{new_file.filename}")
|
|
73
|
-
upload = Faraday::
|
|
73
|
+
upload = Faraday::FilePart.new(file_or_path, new_file.content_type, new_file.filename)
|
|
74
74
|
response = scan_connection.post('/requests', file: upload)
|
|
75
75
|
response.body
|
|
76
76
|
end
|
|
77
77
|
|
|
78
78
|
def scan_connection
|
|
79
79
|
Faraday.new(Config.url) do |f|
|
|
80
|
+
f.options[:open_timeout] = Config.timeout
|
|
81
|
+
f.options[:timeout] = Config.timeout
|
|
80
82
|
f.request :multipart
|
|
81
83
|
f.request :url_encoded
|
|
82
|
-
f.authorization
|
|
84
|
+
f.request :authorization, 'Bearer', -> { Config.api_token }
|
|
83
85
|
f.response :json
|
|
84
86
|
f.response :raise_error
|
|
85
87
|
f.adapter :net_http
|
|
@@ -11,4 +11,7 @@ CarrierWave::AttachmentScanner.configure do |config|
|
|
|
11
11
|
|
|
12
12
|
# Disable in test and development environments
|
|
13
13
|
# config.enabled = false if Rails.env.development? || Rails.env.test?
|
|
14
|
+
|
|
15
|
+
# Set a custom timeout for connections. Defaults to 60 seconds
|
|
16
|
+
# config.timeout = 60
|
|
14
17
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: carrierwave-attachmentscanner
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Steve Smith
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2026-02-13 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: carrierwave
|
|
@@ -28,18 +28,18 @@ dependencies:
|
|
|
28
28
|
name: faraday
|
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
|
30
30
|
requirements:
|
|
31
|
-
- - "
|
|
31
|
+
- - "~>"
|
|
32
32
|
- !ruby/object:Gem::Version
|
|
33
|
-
version: '0'
|
|
33
|
+
version: '2.0'
|
|
34
34
|
type: :runtime
|
|
35
35
|
prerelease: false
|
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
|
37
37
|
requirements:
|
|
38
|
-
- - "
|
|
38
|
+
- - "~>"
|
|
39
39
|
- !ruby/object:Gem::Version
|
|
40
|
-
version: '0'
|
|
40
|
+
version: '2.0'
|
|
41
41
|
- !ruby/object:Gem::Dependency
|
|
42
|
-
name:
|
|
42
|
+
name: faraday-multipart
|
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
|
44
44
|
requirements:
|
|
45
45
|
- - ">="
|
|
@@ -70,16 +70,16 @@ dependencies:
|
|
|
70
70
|
name: rake
|
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
|
72
72
|
requirements:
|
|
73
|
-
- - "
|
|
73
|
+
- - ">="
|
|
74
74
|
- !ruby/object:Gem::Version
|
|
75
|
-
version: '
|
|
75
|
+
version: '0'
|
|
76
76
|
type: :development
|
|
77
77
|
prerelease: false
|
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
|
79
79
|
requirements:
|
|
80
|
-
- - "
|
|
80
|
+
- - ">="
|
|
81
81
|
- !ruby/object:Gem::Version
|
|
82
|
-
version: '
|
|
82
|
+
version: '0'
|
|
83
83
|
- !ruby/object:Gem::Dependency
|
|
84
84
|
name: rspec
|
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -102,6 +102,8 @@ executables: []
|
|
|
102
102
|
extensions: []
|
|
103
103
|
extra_rdoc_files: []
|
|
104
104
|
files:
|
|
105
|
+
- ".github/dependabot.yml"
|
|
106
|
+
- ".github/workflows/specs.yml"
|
|
105
107
|
- ".gitignore"
|
|
106
108
|
- ".travis.yml"
|
|
107
109
|
- Gemfile
|
|
@@ -114,7 +116,7 @@ files:
|
|
|
114
116
|
- lib/carrierwave/attachmentscanner/version.rb
|
|
115
117
|
- lib/generators/carrierwave_attachmentscanner/config/config_generator.rb
|
|
116
118
|
- lib/generators/carrierwave_attachmentscanner/config/templates/config.rb.erb
|
|
117
|
-
homepage:
|
|
119
|
+
homepage: https://www.attachmentscanner.com
|
|
118
120
|
licenses:
|
|
119
121
|
- MIT
|
|
120
122
|
metadata: {}
|
|
@@ -133,8 +135,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
133
135
|
- !ruby/object:Gem::Version
|
|
134
136
|
version: '0'
|
|
135
137
|
requirements: []
|
|
136
|
-
|
|
137
|
-
rubygems_version: 2.6.8
|
|
138
|
+
rubygems_version: 3.0.3.1
|
|
138
139
|
signing_key:
|
|
139
140
|
specification_version: 4
|
|
140
141
|
summary: Scan carrierwave attachments using AttachmentScanner
|