# MalwareScan task

A MalwareScan task scans the files on the list for malware with the server's own scanners and rules, those of [Malware Scanning](Prefs-Malware-Scanning.md) in the Preferences. Clean files go on to the next task; a refused file is taken off the list.

> Each file is scanned with the server's malware scanners and policy (Preferences, Malware Scanning). Clean files go on; a refused file leaves the list with {scan_verdict} and {scan_threat} on it.

Uploads are scanned on the way in when **Scan uploads** is on. This task is for files that arrive another way: put into a folder by another program, copied in over a network share, or fetched by a job from a partner's server. Each file is read where it is, on the server's disk or on any storage a job can reach.

## Fields

| Field | What it does | On a new task |
|---|---|---|
| **End the task in error when a file is refused (the job's failure path runs)** | after all files are scanned, the task fails when one or more were refused: "Malware scan: 2 files refused (invoice.exe: Rejected: malware found (...))". Off: the task ends normally with the clean files. | on |

The task's **Folder Traversal Filter** says which files: `*` for all. Folders and files the filter leaves out go on unscanned.

Everything else comes from the Preferences: the scanners, what happens when none answers, the size limit, the lists of known files and the content rules.

## What it hands on

The clean files, each with `{scan_verdict}` `clean`, and `{scan_note}` when it was stored without a full scan (such as "only the first 100 MB scanned").

A refused file is not handed on. It gets:

| Variable | What it holds |
|---|---|
| `{scan_verdict}` | `infected`, `not_scannable`, `oversize`, `modified`, `blocked` or `error` (no scanner answered) |
| `{scan_threat}` | the threat's name, when a scanner found one |
| `{scan_detail}` | more about the verdict, such as the content rule that refused it |

## Things to know

- **The task does not move or delete refused files.** They stay where they were. Put the job's next steps on the clean files (move them to where they belong), and use the failure path to move the folder's leftovers away or tell somebody.
- **A typical job**: [Find](Task-Find.md) the new files in a drop folder → MalwareScan → [Move](Task-Move.md) to the folder users read from. Scheduled every few minutes, or started by the [Folder Monitor](Prefs-Folder-Monitor.md).
- **Refused files are in the job's log**, not under the Detections of the Preferences, which list uploads.
- **No scanner settings.** A job engine gets the scanning settings from the server, and again whenever they change. One that has none, such as a job engine of an earlier version, fails the task: "Malware scan: no scanner settings reach this job engine".
- **Scanning what jobs write.** The task scans files that are already there. To have a job's own copies scanned as uploads are, turn on **Also scan what jobs write** in the Policy of [Malware Scanning](Prefs-Malware-Scanning.md#jobs).
