{"id":2185,"date":"2016-07-04T06:13:56","date_gmt":"2016-07-04T06:13:56","guid":{"rendered":"https:\/\/www.botreetechnologies.com\/blog\/?p=2185"},"modified":"2020-12-08T18:02:55","modified_gmt":"2020-12-08T12:32:55","slug":"rails-virus-scanning-for-any-files","status":"publish","type":"post","link":"https:\/\/www.botreetechnologies.com\/blog\/rails-virus-scanning-for-any-files\/","title":{"rendered":"Detecting Malicious Threats Using Ruby on Rails"},"content":{"rendered":"\n<p>Ever wonder how to scan any file for a virus on file upload in a Rails application?<\/p>\n\n\n\n<p>We have been using a ruby wrapper to an open source antivirus engine&nbsp;<a href=\"https:\/\/www.clamav.net\/\" target=\"_blank\" rel=\"noopener noreferrer\">ClamAV\u00ae,<\/a>&nbsp;for detecting trojans, viruses, malware &amp; other malicious threats.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Dependencies<\/h2>\n\n\n\n<p>First, you need to install ClamAV&#8217;s clamscan binary and\/or have clamdscan daemon running on your server. Run following commands to install required binaries:<br><code><i>sudo apt-get install clamav<\/i><\/code><\/p>\n\n\n\n<p><i>sudo apt-get install clamav-daemon<\/i><\/p>\n\n\n\n<p><i>sudo service clamav-daemon restart<\/i><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Optional<\/h3>\n\n\n\n<p>If you face any errors related to &#8220;clamav-daemon&#8221;, run following commands.<br><code><i>sudo freshclam<\/i><\/code><\/p>\n\n\n\n<p><i>sudo service clamav-daemon restart<\/i><br>Now we need to install a ruby wrapper&nbsp;<a href=\"https:\/\/github.com\/jschroeder9000\/clam_scan\" target=\"_blank\" rel=\"noopener noreferrer\">clam_scan<\/a>&nbsp;written for ClamAV\u00ae library.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Gem Installation<\/h3>\n\n\n\n<p><code>gem 'clam_scan' #in Gemfile<\/code><\/p>\n\n\n\n<p>bundle<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">How To Scan a file?<\/h3>\n\n\n\n<p>It is quite easy to scan any file\/input stream using the wrapper.<\/p>\n\n\n\n<p><script src=\"https:\/\/gist.github.com\/AmitPatel-BoTreeConsulting\/499372d21b9142fd1de292f0ca8af374.js\"><\/script><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">How to Delete Infected File?<\/h3>\n\n\n\n<p>Here is a simple configuration to remove infected files:<\/p>\n\n\n\n<p><script src=\"https:\/\/gist.github.com\/AmitPatel-BoTreeConsulting\/10c2b440589239f3447357c9e1dcf0fd.js\"><\/script><\/p>\n\n\n\n<p>Have A Safe Application!&nbsp;\ud83d\ude42<\/p>\n\n\n\n<p>Thank you for reading!<\/p>\n\n\n\n<p><a href=\"https:\/\/www.botreetechnologies.com\/ruby-on-rails-development\"><strong><b>Click here for more<\/b> details&#8230;<\/strong><\/a><\/p>\n\n\n\n<p>At<a href=\"https:\/\/www.botreetechnologies.com\/\"> BoTree Technologies<\/a>, we build enterprise applications with our <a href=\"https:\/\/www.botreetechnologies.com\/hire-ruby-on-rails-developers\" target=\"_blank\" rel=\"noopener noreferrer\">RoR team<\/a> of 25+ engineers.<\/p>\n\n\n\n<p>We also specialize in Python, RPA, AI, Django, JavaScript and ReactJS.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><a href=\"https:\/\/www.botreetechnologies.com\/contact\">Consulting is free<\/a> &#8211; let us help you grow!<\/h3>\n","protected":false},"excerpt":{"rendered":"<p>Ever wonder how to scan any file for a virus&#8230;<\/p>\n","protected":false},"author":11,"featured_media":13980,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[73,10],"tags":[],"class_list":["post-2185","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-ruby-on-rails","category-technology"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.2 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Detecting Malicious Threats Using Ruby on Rails<\/title>\n<meta name=\"description\" content=\"Ever wonder how to scan any file for a virus on file upload in a Rails application? Learn more about how to detecting malicious threats using ruby on rails.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.botreetechnologies.com\/blog\/rails-virus-scanning-for-any-files\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Detecting Malicious Threats Using Ruby on Rails\" \/>\n<meta property=\"og:description\" content=\"Ever wonder how to scan any file for a virus on file upload in a Rails application? Learn more about how to detecting malicious threats using ruby on rails.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.botreetechnologies.com\/blog\/rails-virus-scanning-for-any-files\/\" \/>\n<meta property=\"og:site_name\" content=\"BoTree Technologies\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/BoTreeTechnologies\/\" \/>\n<meta property=\"article:published_time\" content=\"2016-07-04T06:13:56+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2020-12-08T12:32:55+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.botreetechnologies.com\/blog\/wp-content\/uploads\/2016\/07\/detecting-malicious-threats.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1920\" \/>\n\t<meta property=\"og:image:height\" content=\"1280\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Parthiv Patel\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@BoTreeTech\" \/>\n<meta name=\"twitter:site\" content=\"@BoTreeTech\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Parthiv Patel\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.botreetechnologies.com\/blog\/rails-virus-scanning-for-any-files\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.botreetechnologies.com\/blog\/rails-virus-scanning-for-any-files\/\"},\"author\":{\"name\":\"Parthiv Patel\",\"@id\":\"https:\/\/www.botreetechnologies.com\/blog\/#\/schema\/person\/33421652a86a8f62aa02d78c35b1f3c3\"},\"headline\":\"Detecting Malicious Threats Using Ruby on Rails\",\"datePublished\":\"2016-07-04T06:13:56+00:00\",\"dateModified\":\"2020-12-08T12:32:55+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.botreetechnologies.com\/blog\/rails-virus-scanning-for-any-files\/\"},\"wordCount\":197,\"commentCount\":0,\"image\":{\"@id\":\"https:\/\/www.botreetechnologies.com\/blog\/rails-virus-scanning-for-any-files\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.botreetechnologies.com\/blog\/wp-content\/uploads\/2016\/07\/detecting-malicious-threats.jpg\",\"articleSection\":[\"Ruby on Rails\",\"Technology\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.botreetechnologies.com\/blog\/rails-virus-scanning-for-any-files\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.botreetechnologies.com\/blog\/rails-virus-scanning-for-any-files\/\",\"url\":\"https:\/\/www.botreetechnologies.com\/blog\/rails-virus-scanning-for-any-files\/\",\"name\":\"Detecting Malicious Threats Using Ruby on Rails\",\"isPartOf\":{\"@id\":\"https:\/\/www.botreetechnologies.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.botreetechnologies.com\/blog\/rails-virus-scanning-for-any-files\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.botreetechnologies.com\/blog\/rails-virus-scanning-for-any-files\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.botreetechnologies.com\/blog\/wp-content\/uploads\/2016\/07\/detecting-malicious-threats.jpg\",\"datePublished\":\"2016-07-04T06:13:56+00:00\",\"dateModified\":\"2020-12-08T12:32:55+00:00\",\"author\":{\"@id\":\"https:\/\/www.botreetechnologies.com\/blog\/#\/schema\/person\/33421652a86a8f62aa02d78c35b1f3c3\"},\"description\":\"Ever wonder how to scan any file for a virus on file upload in a Rails application? Learn more about how to detecting malicious threats using ruby on rails.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.botreetechnologies.com\/blog\/rails-virus-scanning-for-any-files\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.botreetechnologies.com\/blog\/rails-virus-scanning-for-any-files\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.botreetechnologies.com\/blog\/rails-virus-scanning-for-any-files\/#primaryimage\",\"url\":\"https:\/\/www.botreetechnologies.com\/blog\/wp-content\/uploads\/2016\/07\/detecting-malicious-threats.jpg\",\"contentUrl\":\"https:\/\/www.botreetechnologies.com\/blog\/wp-content\/uploads\/2016\/07\/detecting-malicious-threats.jpg\",\"width\":1920,\"height\":1280,\"caption\":\"detecting malicious threats\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.botreetechnologies.com\/blog\/rails-virus-scanning-for-any-files\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.botreetechnologies.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Detecting Malicious Threats Using Ruby on Rails\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.botreetechnologies.com\/blog\/#website\",\"url\":\"https:\/\/www.botreetechnologies.com\/blog\/\",\"name\":\"BoTree Technologies\",\"description\":\"Committed to inspire generation.\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.botreetechnologies.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.botreetechnologies.com\/blog\/#\/schema\/person\/33421652a86a8f62aa02d78c35b1f3c3\",\"name\":\"Parthiv Patel\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.botreetechnologies.com\/blog\/wp-content\/uploads\/2020\/10\/parthiv-patel-150x150.png\",\"url\":\"https:\/\/www.botreetechnologies.com\/blog\/wp-content\/uploads\/2020\/10\/parthiv-patel-150x150.png\",\"contentUrl\":\"https:\/\/www.botreetechnologies.com\/blog\/wp-content\/uploads\/2020\/10\/parthiv-patel-150x150.png\",\"caption\":\"Parthiv Patel\"},\"description\":\"Parthiv is a Ruby on Rails Engineer. He has strong experience in javascript and DevOps activities like deployment, installation, server, and domain configuration, maintenance, and support of any platform like AWS, digital ocean and Heroku. He develops applications with optimization and clean code with full Rspec coverage.\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Detecting Malicious Threats Using Ruby on Rails","description":"Ever wonder how to scan any file for a virus on file upload in a Rails application? Learn more about how to detecting malicious threats using ruby on rails.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.botreetechnologies.com\/blog\/rails-virus-scanning-for-any-files\/","og_locale":"en_US","og_type":"article","og_title":"Detecting Malicious Threats Using Ruby on Rails","og_description":"Ever wonder how to scan any file for a virus on file upload in a Rails application? Learn more about how to detecting malicious threats using ruby on rails.","og_url":"https:\/\/www.botreetechnologies.com\/blog\/rails-virus-scanning-for-any-files\/","og_site_name":"BoTree Technologies","article_publisher":"https:\/\/www.facebook.com\/BoTreeTechnologies\/","article_published_time":"2016-07-04T06:13:56+00:00","article_modified_time":"2020-12-08T12:32:55+00:00","og_image":[{"width":1920,"height":1280,"url":"https:\/\/www.botreetechnologies.com\/blog\/wp-content\/uploads\/2016\/07\/detecting-malicious-threats.jpg","type":"image\/jpeg"}],"author":"Parthiv Patel","twitter_card":"summary_large_image","twitter_creator":"@BoTreeTech","twitter_site":"@BoTreeTech","twitter_misc":{"Written by":"Parthiv Patel","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.botreetechnologies.com\/blog\/rails-virus-scanning-for-any-files\/#article","isPartOf":{"@id":"https:\/\/www.botreetechnologies.com\/blog\/rails-virus-scanning-for-any-files\/"},"author":{"name":"Parthiv Patel","@id":"https:\/\/www.botreetechnologies.com\/blog\/#\/schema\/person\/33421652a86a8f62aa02d78c35b1f3c3"},"headline":"Detecting Malicious Threats Using Ruby on Rails","datePublished":"2016-07-04T06:13:56+00:00","dateModified":"2020-12-08T12:32:55+00:00","mainEntityOfPage":{"@id":"https:\/\/www.botreetechnologies.com\/blog\/rails-virus-scanning-for-any-files\/"},"wordCount":197,"commentCount":0,"image":{"@id":"https:\/\/www.botreetechnologies.com\/blog\/rails-virus-scanning-for-any-files\/#primaryimage"},"thumbnailUrl":"https:\/\/www.botreetechnologies.com\/blog\/wp-content\/uploads\/2016\/07\/detecting-malicious-threats.jpg","articleSection":["Ruby on Rails","Technology"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.botreetechnologies.com\/blog\/rails-virus-scanning-for-any-files\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.botreetechnologies.com\/blog\/rails-virus-scanning-for-any-files\/","url":"https:\/\/www.botreetechnologies.com\/blog\/rails-virus-scanning-for-any-files\/","name":"Detecting Malicious Threats Using Ruby on Rails","isPartOf":{"@id":"https:\/\/www.botreetechnologies.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.botreetechnologies.com\/blog\/rails-virus-scanning-for-any-files\/#primaryimage"},"image":{"@id":"https:\/\/www.botreetechnologies.com\/blog\/rails-virus-scanning-for-any-files\/#primaryimage"},"thumbnailUrl":"https:\/\/www.botreetechnologies.com\/blog\/wp-content\/uploads\/2016\/07\/detecting-malicious-threats.jpg","datePublished":"2016-07-04T06:13:56+00:00","dateModified":"2020-12-08T12:32:55+00:00","author":{"@id":"https:\/\/www.botreetechnologies.com\/blog\/#\/schema\/person\/33421652a86a8f62aa02d78c35b1f3c3"},"description":"Ever wonder how to scan any file for a virus on file upload in a Rails application? Learn more about how to detecting malicious threats using ruby on rails.","breadcrumb":{"@id":"https:\/\/www.botreetechnologies.com\/blog\/rails-virus-scanning-for-any-files\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.botreetechnologies.com\/blog\/rails-virus-scanning-for-any-files\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.botreetechnologies.com\/blog\/rails-virus-scanning-for-any-files\/#primaryimage","url":"https:\/\/www.botreetechnologies.com\/blog\/wp-content\/uploads\/2016\/07\/detecting-malicious-threats.jpg","contentUrl":"https:\/\/www.botreetechnologies.com\/blog\/wp-content\/uploads\/2016\/07\/detecting-malicious-threats.jpg","width":1920,"height":1280,"caption":"detecting malicious threats"},{"@type":"BreadcrumbList","@id":"https:\/\/www.botreetechnologies.com\/blog\/rails-virus-scanning-for-any-files\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.botreetechnologies.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Detecting Malicious Threats Using Ruby on Rails"}]},{"@type":"WebSite","@id":"https:\/\/www.botreetechnologies.com\/blog\/#website","url":"https:\/\/www.botreetechnologies.com\/blog\/","name":"BoTree Technologies","description":"Committed to inspire generation.","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.botreetechnologies.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.botreetechnologies.com\/blog\/#\/schema\/person\/33421652a86a8f62aa02d78c35b1f3c3","name":"Parthiv Patel","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.botreetechnologies.com\/blog\/wp-content\/uploads\/2020\/10\/parthiv-patel-150x150.png","url":"https:\/\/www.botreetechnologies.com\/blog\/wp-content\/uploads\/2020\/10\/parthiv-patel-150x150.png","contentUrl":"https:\/\/www.botreetechnologies.com\/blog\/wp-content\/uploads\/2020\/10\/parthiv-patel-150x150.png","caption":"Parthiv Patel"},"description":"Parthiv is a Ruby on Rails Engineer. He has strong experience in javascript and DevOps activities like deployment, installation, server, and domain configuration, maintenance, and support of any platform like AWS, digital ocean and Heroku. He develops applications with optimization and clean code with full Rspec coverage."}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/www.botreetechnologies.com\/blog\/wp-json\/wp\/v2\/posts\/2185","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.botreetechnologies.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.botreetechnologies.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.botreetechnologies.com\/blog\/wp-json\/wp\/v2\/users\/11"}],"replies":[{"embeddable":true,"href":"https:\/\/www.botreetechnologies.com\/blog\/wp-json\/wp\/v2\/comments?post=2185"}],"version-history":[{"count":2,"href":"https:\/\/www.botreetechnologies.com\/blog\/wp-json\/wp\/v2\/posts\/2185\/revisions"}],"predecessor-version":[{"id":13982,"href":"https:\/\/www.botreetechnologies.com\/blog\/wp-json\/wp\/v2\/posts\/2185\/revisions\/13982"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.botreetechnologies.com\/blog\/wp-json\/wp\/v2\/media\/13980"}],"wp:attachment":[{"href":"https:\/\/www.botreetechnologies.com\/blog\/wp-json\/wp\/v2\/media?parent=2185"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.botreetechnologies.com\/blog\/wp-json\/wp\/v2\/categories?post=2185"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.botreetechnologies.com\/blog\/wp-json\/wp\/v2\/tags?post=2185"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}