internal FileStreamScanner( AMSIClient client , string filePath , int blockSize , bool acceptEncryptedZipEntries ) { this.client = client; this.filePath = filePath; fileInfo = new FileInfo(filePath); this.blockSize = blockSize; this.acceptEncryptedZipEntries = acceptEncryptedZipEntries; buffer = new byte[blockSize]; cancellationTokenSource = new CancellationTokenSource(); using (var signatureReader = new FileSignatureReader(filePath, Signatures.Get())) fileSignature = signatureReader.GetFileSignature(); md5Hash = client.Configuration.SkipContentHashing ? Task.FromResult((string)null) : Task.Run(() => fileInfo.GetFileMD5Hash(), cancellationTokenSource.Token); }
public ScanResult ScanFile(string filePath) { client.DetermineDetectionEngine(); using (var resultBuilder = new ResultBuilder( new ScanContext(client, null, filePath, ContentType.File, FileType.Unknown, 0, null))) using (var signatureReader = new FileSignatureReader(filePath, Signatures.Get())) if (!signatureReader.FileExists()) { return(resultBuilder.ToResult(DetectionResult.FileNotExists, $"File not found at {filePath}")); } else if (signatureReader.IsFileBlocked()) { return(resultBuilder.ToResultBlocked()); } using (var reader = new FileStreamScannerSession( client , filePath , client.Configuration.FileScannerBlockSize , client.Configuration.FileScannerAcceptZipFileWithEncryptedEntry)) return(reader.Scan()); }