Skip to content

Add Antivirus Scanner#19329

Open
MikeAlhayek wants to merge 6 commits into
mainfrom
ma/upload-file-scanner
Open

Add Antivirus Scanner#19329
MikeAlhayek wants to merge 6 commits into
mainfrom
ma/upload-file-scanner

Conversation

@MikeAlhayek
Copy link
Copy Markdown
Member

This pull request introduces a new ClamAV-backed antivirus scanning module for Orchard Core, along with Aspire host integration for easier development and deployment. The changes include a new OrchardCore.Antivirus.ClamAV module, Aspire host project setup, and integration of the antivirus scanner into the remote deployment import workflow. This enhances security by ensuring uploaded files are scanned for viruses and streamlines local development with Aspire.

New ClamAV Antivirus Module:

  • Added the OrchardCore.Antivirus.ClamAV module, including implementation of ClamAVAntivirusScanner, configuration options (ClamAvOptions), and module manifest. This module scans files with ClamAV before they are stored or imported. [1] [2] [3] [4] [5]

Aspire Host Integration:

  • Introduced a new OrchardCore.AspireHost project with configuration for Aspire hosting, including a ClamAVResource for running ClamAV in a container, and project setup files (Program.cs, appsettings.json, launchSettings.json, etc.). This enables easy local orchestration of Orchard Core and ClamAV. [1] [2] [3] [4] [5] [6] [7] [8]

Solution and Documentation Updates:

  • Updated the solution file (OrchardCore.slnx) to include the new Aspire host and ClamAV module projects. [1] [2]
  • Added module documentation entry for the ClamAV Antivirus Scanner in mkdocs.yml.

Remote Deployment Security Enhancement:

  • Integrated the new antivirus scanner into the remote deployment import controller, ensuring that uploaded deployment archives are scanned for viruses before extraction. [1] [2] [3] [4]

These changes collectively improve Orchard Core's security posture and developer experience by providing an out-of-the-box, containerized antivirus solution and integrating it into critical file handling workflows.

MikeAlhayek

This comment was marked as off-topic.


try
{
using var client = new TcpClient();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I its lifetime working the same way as httpclient?


public interface IAntivirusScanner
{
Task<AntivirusResult> ScanAsync(AntivirusScanContext context, Stream stream);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IFileStoreEntry

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FileCreatingResult FileCreatingAsync(FileCreatingContext context, Stream stream, CancellationToken ct)

For file system and also blob storage (any file). Use anywhere we upload/get files, not just Media.

FileCreatedAsync (IFileInfo) (whatever is used in orchard to get a stream from a file)
// If we were able to create a file (FileCreating) then we have to be able to get a file info

IFileEventHandler

We return a Stream as we need to read it, even if we don't want to replace/change the content.

FileCreatingResult: Result

  • Stream { get; }

}
}

private async Task<Stream> ScanAsync(string path, Stream stream)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be in the implementation (I might be wrong)

}
}

private static async Task<Stream> CreateTemporarySeekableStreamAsync(Stream stream)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be in the implementation. The implemetnation decides if the stream needs to be opened (caching for isntnce/)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants