Metadata-Version: 2.4
Name: smoothglue_malware_scan
Version: 1.0.0
Summary: A Python utility wrapper for malware scanning libraries
Author: SmoothGlue
Project-URL: Homepage, https://braingu.com/solutions/smoothglue/
Requires-Python: >= 3.9
Description-Content-Type: text/markdown
License-File: LICENSE
License-File: NOTICE
Requires-Dist: clamd>=1.0.2
Dynamic: license-file
Dynamic: requires-python

# SmoothGlue Malware Scan

A Python package that provides a library for interfacing with malware scanning utilities, currently only ClamAV.

## Overview

`smoothglue_malware_scan` simplifies the process of scanning files for malware. The core problem it solves is providing a stop-check for incoming files to be scanned and either continue through the desired workflow if clean of malware and to follow a rejection workflow if malware is found.

### Key Features

* **Malware Scanning Wrappers:** Easily interact with malware scanning utilities, currently only ClamAV.
* **Custom Exceptions:** A set of custom exceptions to easily use if malware is found or to help debug.

## Installation

### Prerequisites

* Python 3.9+

### Install App From PyPI Package (Official Use)

1. Before installing the package, make sure that there is a virtual environment set up:
    ```python
   python -m venv venv
   source venv/bin/activate
   ```

2. Use pip and the following command:
   ```python
   pip install smoothglue_malware_scan
   ```

## Usage

### ClamAV

```python
from smoothglue_malware_scan.scanners.clamav import ClamAVScanner
from smoothglue_malware_scan.exceptions import MalwareFoundException, ScanningServiceException

scanner = ClamAVScanner(clam_av_host="<clam av host name>", clam_av_port=3310)

with open("/tmp/mymalware.exe", "rb") as f:
    try:
        scanner.scan_stream(f.read())
    except ScanningServiceException as e:
        # Unable to connect to ClamAV server or ClamAV encountered an error scanning the file
        # e.reason may have additional context
        print("Error scan file")
    except MalwareFoundException as e:
        # ClamAV detected malware in the file. e.reason will be the type of malware detected
        print(f"Detected {e.reason} in file")
    else:
        print("No malware detected")
```

## License

This project is licensed under a Proprietary License. See the [LICENSE](./LICENSE) file for more details.
