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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 3747ea9b16fe64ca851ea8918f87d952930791e9
4
- data.tar.gz: 9fc0592f74f6fd310255c30ca669a25975cd7e18
2
+ SHA256:
3
+ metadata.gz: e45e9670c42891a1125493b4514306d2a8590020e25a87b96173902c62f602e7
4
+ data.tar.gz: d79657584dd306cbbf610e7f39ca2aa974ec32f0c548df798dc04cf6fbfba54f
5
5
  SHA512:
6
- metadata.gz: 21a01293633e09a2d047c35539357e6c591ac1f5e1ad3db4a22c84e331b7cc0ecab2c985dff2efd032f55ecfb603388ff4fc196b620f5c2d560d788a38a94165
7
- data.tar.gz: 8a8d1813ac8e5eecb57b5e74d0345a2ec77407705fa0b430580ab0428dd919307d8c5538278fdab3fa35c43987561703f343192a040b76b526d1be2cf0364d7b
6
+ metadata.gz: b813f19ddb824b56dac47c9c1345200c46a66cd3019ebebd6c343003b849b7858772134d33f387856eda75e7caa61e3bc67bf507ee3bff655c5742f2a71ff097
7
+ data.tar.gz: d410885ff1717f3780a0a7692e6aaa9e6d6fa9fcf4d8877e3c22e1fd4feff723586fad81bba8159b13eceaedf586a97fb7f9379632f91ad7e7bc82fa430ecf99
@@ -0,0 +1,10 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: bundler
4
+ directory: /
5
+ schedule:
6
+ interval: weekly
7
+ - package-ecosystem: github-actions
8
+ directory: /
9
+ schedule:
10
+ interval: weekly
@@ -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
@@ -21,3 +21,4 @@ Gemfile.lock
21
21
 
22
22
  # Docker is being used in development but we're not ready to push this yet.
23
23
  Dockerfile
24
+ docker-compose.yml
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- # Specify your gem's dependencies in carrierwave-attachmentscan.gemspec
3
+ # Specify your gem's dependencies in carrierwave-attachmentscanner.gemspec
4
4
  gemspec
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Carrierwave::Attachmentscanner
2
2
 
3
- [![Build Status](https://travis-ci.org/attachmentscanner/carrierwave-attachmentscanner.svg?branch=master)](https://travis-ci.org/attachmentscanner/carrierwave-attachmentscanner)
3
+ [![Specs](https://github.com/attachmentscanner/carrierwave-attachmentscanner/actions/workflows/specs.yml/badge.svg?branch=main)](https://github.com/attachmentscanner/carrierwave-attachmentscanner/actions/workflows/specs.yml) [![Ruby](https://img.shields.io/badge/ruby-%3E%3D%203.x-red?logo=ruby)](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 = "http://www.attachmentscanner.com"
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 "faraday_middleware"
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", "~> 10.0"
30
+ spec.add_development_dependency "rake"
31
31
  spec.add_development_dependency "rspec", "~> 3.0"
32
32
  end
@@ -1,5 +1,5 @@
1
1
  module CarrierWave
2
2
  module AttachmentScanner
3
- VERSION = "0.1.0"
3
+ VERSION = "0.2.0"
4
4
  end
5
5
  end
@@ -1,12 +1,12 @@
1
1
  require 'faraday'
2
- require 'faraday_middleware'
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::UploadIO unless we think this is a
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::UploadIO.new(file_or_path, new_file.content_type, new_file.filename)
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 :Bearer, Config.api_token
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.1.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: 2017-04-03 00:00:00.000000000 Z
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: faraday_middleware
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: '10.0'
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: '10.0'
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: http://www.attachmentscanner.com
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
- rubyforge_project:
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