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!!!