profile
viewpoint
Erling Wegger Linde erlingwl CV Partner AS Oslo, Norway http://erlingwl.wordpress.com

tallakt/geoutm 39

Conversion between latitude/longitude coordinates to UTM

erlingwl/elasticsearch-tutorial 6

Notes for my Elasticsearch tutorial at Boosterconf

erlingwl/Oyster 3

Calculate your oyster expenses - Clojure Edition

erlingwl/geoutm 1

Conversion between latitude/longitude coordinates to UTM

erlingwl/jQuery-Tags-Input 1

Magically convert a simple text input into a cool tag list with this jQuery plugin.

erlingwl/mebla 1

An elasticsearch wrapper for mongoid odm based on slingshot

erlingwl/mongoid-history 1

history tracking, auditing, undo, redo for mongoid

erlingwl/mongoid_fulltext 1

A full-text search implementation for the Mongoid ODM

Pull request review commentfranckverrot/clamav-client

Refactor to use an ENV of max_chunk_size of instream command

 module ClamAV   module Commands     class InstreamCommand < Command+      DEFAULT_MAX_CHUNK_SIZE = 1024 -      def initialize(io, max_chunk_size = 1024)+      def initialize(io)

Let me update my PR

ehdieunguyen

comment created time in 2 days

Pull request review commentfranckverrot/clamav-client

Refactor to use an ENV of max_chunk_size of instream command

 module ClamAV   module Commands     class InstreamCommand < Command+      DEFAULT_MAX_CHUNK_SIZE = 1024 -      def initialize(io, max_chunk_size = 1024)+      def initialize(io)

This constructor being part of the public API, I think that this could break some people's code.

Let's maybe change https://github.com/franckverrot/clamav-client/blob/master/lib/clamav/client.rb#L28 and allow for another parameter to be passed, like configuration (a global configuration object):

class ClamAV::Configuration
  attr_reader :instream_max_chunk_size
  def initialize(instream_max_chunk_size: 1024) # we can for sure use a const here too
    @instream_max_chunk_size = instream_max_chunk_size
  end
end

class ClamAV::Client
  def initialize(connection = default_connection, configuration: Configuration.new)
  ...
  @configuration = configuration
...

    def instream(io)
      execute Commands::InstreamCommand.new(io, @configuration.instream_max_chunk_size)
    end

...

allowing us to do something like

configuration = Configuration.new(instream_max_chunk_size: 2048)
client = Client.new(configuration: configuration)
...

and get to pass down the value this way?

ehdieunguyen

comment created time in 9 days

pull request commentfranckverrot/clamav-client

Refactor to use an ENV of max_chunk_size of instream command

I totally missed this, I'll review shortly, sorry about the delay!

ehdieunguyen

comment created time in 9 days

issue openedfranckverrot/clamav-client

[Bug] wrong response when using safe? method with not existed file via TCP socket

I have a Clamav instance, and I want to scan the file by using a TCP socket. In the latest version, the Clamav Client has a safe? method with one argument. In my case, I passed the argument as a File object from my client like the following:

ClamAV::Client.new.safe?(File.open(File.expand_path('test.png')))

And I expect the above execution will raise an exception like No such file or directory because that file does not exist in the Clamav instance, but it returns true instead.

First thing I tried to investigate it by using the send_request method of connection object directly.

clamav_client = ClamAV::Client.new
connection = clamav_client.instance_variable_get('@connection')
connetion.send_request("SCAN #{File.open(File.expand_path('test.png'))}")
=> "1: #<File:0x000056329b00c9d0>: lstat() failed: No such file or directory. ERROR"

The second thing, I tried with get_status_from_response method:

str = "1: #<File:0x000056329b00c9d0>: lstat() failed: No such file or directory. ERROR"
ClamAV::Commands::Command.new.send(:get_status_from_response, str)
=> #<ClamAV::ErrorResponse:0x000056329b0a3c90 @error_str="1: #<File:0x000056329b00c9d0>: lstat() failed: No such file or directory. ERROR">

As you can see, it returns my expectation. Then, I think the problem comes from the safe? method. Let verify it again, and I see it missed one the condition to make sure the file is safe.

scan(target).all? { |file| file.virus_name.nil? }
=> scan(target).all? { |file| file.virus_name.nil? && file.error_str.nil? }

And the last, I have a PR to fix this issue at https://github.com/franckverrot/clamav-client/pull/13. Please help me to review this PR, and thank you for your effort in building this gem. It helps my work a lot, and I appreciate it very much.

created time in a month

more