Orchardcore antivirus

From CrestApps/CrestApps.AgentSkills · View interactive version

Orchardcore antivirus is an AI agent skill from the GitHub repository CrestApps/CrestApps.AgentSkills. Skill for scanning uploaded files for malware in Orchard Core 4.0 with the OrchardCore.Antivirus module. Covers the OrchardCore.Antivirus.ClamAV feature (ClamAV Antivirus Scanner), the OrchardCore Antivirus ClamAV configuration section with Host, Port, ConnectTimeoutSeconds and TransferTimeoutSecond

How to use this skill

Skill file

Orchard Core Antivirus - Prompt Templates

Scan Uploads with ClamAV

You are an Orchard Core expert. Generate configuration and deployment guidance for scanning uploaded files with ClamAV before Orchard Core stores them.

Guidelines

Enabling the Feature

Configure the connection before enabling the feature; until clamd is reachable every upload is rejected.

{
  "steps": [
    {
      "name": "feature",
      "enable": [
        "OrchardCore.Antivirus.ClamAV"
      ]
    }
  ]
}

Configuration

The section is OrchardCore:Antivirus:ClamAV (new in 4.0, no legacy OrchardCore_ name). It is read through IShellConfiguration, so it can be set per tenant, and the package ships ConfigurationSchema.json for appsettings IntelliSense.

{
  "OrchardCore": {
    "Antivirus": {
      "ClamAV": {
        "Host": "clamav",
        "Port": 3310,
        "ConnectTimeoutSeconds": 5,
        "TransferTimeoutSeconds": 30
      }
    }
  }
}

| Setting | Default | Description |

|---|---|---|

| Host | none | Host name or IP of the clamd service. Required. |

| Port | 3310 | clamd TCP port, 1 to 65535. |

| ConnectTimeoutSeconds | 5 | Connection timeout, greater than zero. |

| TransferTimeoutSeconds | 30 | Timeout for streaming the file and reading the verdict, greater than zero. Raise it for large uploads. |

OrchardCore__Antivirus__ClamAV__Host=clamav
OrchardCore__Antivirus__ClamAV__Port=3310
OrchardCore__Antivirus__ClamAV__ConnectTimeoutSeconds=5
OrchardCore__Antivirus__ClamAV__TransferTimeoutSeconds=30

The options are bound with IOptions<ClamAvOptions>, so a configuration change applies after the tenant is reloaded.

Running clamd with Docker Compose

services:
  clamav:
    image: clamav/clamav:stable
    ports:
      - "3310:3310"
  cms:
    image: my-orchard-site
    environment:
      OrchardCore__Antivirus__ClamAV__Host: clamav
    depends_on:
      - clamav

clamd limits the size of a scanned stream with its own StreamMaxLength setting. Keep it at least as large as the Media MaxFileSize and the largest deployment package you import; a larger file is rejected with a scanner error. A fresh clamav container can take a while to download and load its signatures before it accepts connections.

How the Scanner Behaves

What Is Scanned

Uploads that run through FileCreationService, which in Orchard Core 4.0 are:

TUS resumable uploads (OrchardCore.Media.Tus) and Data Pipelines Save to the media library write through the plain IMediaFileStore.CreateFileFromStreamAsync() in the current source and are not scanned. Custom upload code is scanned only when it follows orchardcore-file-upload-security.

Troubleshooting

| Symptom | Check |

|---|---|

| Every upload fails after enabling ClamAV | Host is missing, or clamd is unreachable from the app container or still loading signatures. |

| Large uploads fail with a scanner error | Increase TransferTimeoutSeconds and the clamd StreamMaxLength. |

| Uploads are slow under load | Scans with the same configuration are serialized; scale clamd or reduce concurrent large uploads. |

| A custom upload is not scanned | It bypasses FileCreationService; see orchardcore-file-upload-security. |

| Settings change has no effect | Reload the tenant; the options are read once per shell. |

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.