-
-
Save TimothyODonnell/22eb0e615148fb264a12f47c44cfe172 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ##### RUN AV ON FILE ##### | |
log.LogInformation("Download completed. Connecting to AV server {ClamAVServerUrl}:{ClamAVServerPort}... ", ClamAVServerUrl, ClamAVServerPort); | |
var clam = new ClamClient(ClamAVServerUrl, ClamAVServerPort); | |
bool isConnected = await clam.PingAsync(); | |
var version = await clam.GetVersionAsync(); | |
if (!isConnected) throw new Exception("AV server connection could not be established."); | |
log.LogInformation("Connection ok: {IsConnected}. AV server reports version: {ServerVersion}", isConnected, version); | |
var scanResult = await clam.SendAndScanFileAsync(ms.ToArray()); | |
switch (scanResult.Result) | |
{ | |
case ClamScanResults.Clean: | |
log.LogInformation("The file is clean!"); | |
// Continue | |
break; | |
case ClamScanResults.VirusDetected: | |
log.LogCritical("Virus found. Deleting file."); | |
await blobClient.DeleteIfExistsAsync(Azure.Storage.Blobs.Models.DeleteSnapshotsOption.IncludeSnapshots); | |
// Do other steps | |
break; | |
case ClamScanResults.Error: | |
default: | |
log.LogInformation("File scan error occurred. {ScanResult}", scanResult.RawResult); | |
break; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I have linked this discussion in my post to the part where these settings were discussed and improved that bit slightly. Thanks @TimothyODonnell