在上传到Azure之前需要将文件扫描病毒吗?

时间:2017-07-26 05:58:31

标签: azure asp.net-web-api

作为要求,我们需要对上传到我们的应用程序的任何内容应用病毒扫描。是唯一基于云的服务,提供恶意软件和病毒扫描等功能。我们需要该服务来提供接受文件数据流的api并在扫描后将结果返回给我们。

我们正在使用Asp.Net WebApi C#和Azure。

2 个答案:

答案 0 :(得分:0)

无耻插件,但您可能想要查看https://scanii.com是一种纯粹的SaaS恶意软件检测服务,可以很好地与Azure集成。另外,请务必仔细阅读病毒总计条款,因为它不能用于商业产品(https://www.virustotal.com/en/documentation/public-api/)。

答案 1 :(得分:0)

这种方法非常有效,可以阻止病毒和恶意软件,还可以阻止其他威胁,例如脚本,可执行文件和无效文件:

using System;
using System.Diagnostics;
using Cloudmersive.APIClient.NETCore.VirusScan.Api;
using Cloudmersive.APIClient.NETCore.VirusScan.Client;
using Cloudmersive.APIClient.NETCore.VirusScan.Model;

namespace Example
{
    public class ScanFileAdvancedExample
    {
        public void main()
        {
            // Configure API key authorization: Apikey
            Configuration.Default.AddApiKey("Apikey", "YOUR_API_KEY");
            
            

            var apiInstance = new ScanApi();
            var inputFile = new System.IO.FileStream("C:\\temp\\inputfile", System.IO.FileMode.Open); // System.IO.Stream | Input file to perform the operation on.
            var allowExecutables = false;  // bool? | Set to false to block executable files (program code) from being allowed in the input file.  Default is false (recommended). (optional) 
            var allowInvalidFiles = false;  // bool? | Set to false to block invalid files, such as a PDF file that is not really a valid PDF file, or a Word Document that is not a valid Word Document.  Default is false (recommended). (optional) 
            var allowScripts = false;  // bool? | Set to false to block script files, such as a PHP files, Pythong scripts, and other malicious content or security threats that can be embedded in the file.  Set to true to allow these file types.  Default is false (recommended). (optional) 
            var allowPasswordProtectedFiles = false;  // bool? | Set to false to block password protected and encrypted files, such as encrypted zip and rar files, and other files that seek to circumvent scanning through passwords.  Set to true to allow these file types.  Default is false (recommended). (optional) 
            var restrictFileTypes = "";  // string | Specify a restricted set of file formats to allow as clean as a comma-separated list of file formats, such as .pdf,.docx,.png would allow only PDF, PNG and Word document files.  All files must pass content verification against this list of file formats, if they do not, then the result will be returned as CleanResult=false.  Set restrictFileTypes parameter to null or empty string to disable; default is disabled. (optional) 

            try
            {
                // Advanced Scan a file for viruses
                VirusScanAdvancedResult result = apiInstance.ScanFileAdvanced(inputFile, allowExecutables, allowInvalidFiles, allowScripts, allowPasswordProtectedFiles, restrictFileTypes);
                Debug.WriteLine(result);
            }
            catch (Exception e)
            {
                Debug.Print("Exception when calling ScanApi.ScanFileAdvanced: " + e.Message );
            }
        }
    }
}

您将需要安装此Nuget软件包:

Install-Package Cloudmersive.APIClient.NETCore.VirusScan -Version 2.0.3

Nuget软件包是开源的。 API密钥每月免费提供1,000次扫描。

希望这会有所帮助!