1

Is there any option to perform an antivirus scan of each of the files uploaded to media library?

Has anyone implemented a solution which allows to scan each file before it's saved to media library, either by running a local antivirus or via external API and can share the information how to proceed?

2 Answers 2

2

I believe you can create a custom processor to do a file scan and patch it before the Checksize processor under the uiUpload pipeline.

<?xml version="1.0"?>
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/" xmlns:set="http://www.sitecore.net/xmlconfig/set/" xmlns:role="http://www.sitecore.net/xmlconfig/role/">
    <sitecore>
      <processors>
        <uiUpload>
          <processor mode="on" patch:before="processor[@type='Sitecore.Pipelines.Upload.CheckSize, Sitecore.Kernel']" type="SitecoreCustomExtensions.ScanForViruses, SitecoreCustomExtensions">
           </processor>
        </uiUpload>
    </sitecore>
</configuration>

There are .Net packages available that scans the file and returns whether file uploaded is clean, such as nClam and AntiVirusScanner. You can find more details for the same here.

https://github.com/tekmaven/nClam

https://www.nuget.org/packages/AntiVirusScanner

Moreover, you can also use Cloudmersive Rest apis to scan file for viruses as below.

https://api.cloudmersive.com/docs/virus.asp

When the scan identifies the file is not clean, we can abort the pipeline.

Hope this helps!!!

2

In the past our team we investigate to use ClamAV (it's an open source antivirus, https://www.clamav.net/) .

And we used their api like here : https://www.c-sharpcorner.com/article/clamav-antivirus-scan-on-file-upload-content-in-net-application/.

But at the end we decided to abandon, the editors should be responsable about the files which are uploaded .

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.