Home /Modules/antivirus/SCANNING-CONCEPTS-GLOSSARY.md

SCANNING-CONCEPTS-GLOSSARY.md

antivirus/SCANNING-CONCEPTS-GLOSSARY.md · 476 line(s) · markdown

Scanning Concepts — A Glossary for Novices and Professionals

Author: Max Rupplin — MEARVK LLC — 2026 Companion to: CLAMAV-REFERENCE-ANALYSIS.md Purpose: Define every algorithm, data structure, and structural term used in the ClamAV reference analysis and in the Sleelavirin™ native matcher. Each entry gives (a) a plain-language definition, (b) how it works, (c) why it works, and (d) its structural dependencies and trade-offs. Read top to bottom for a course, or jump to any term.

No ClamAV source is reproduced here. These are general computer-science concepts explained in our own words.


Table of contents


<a name="part-a"></a>

Part A — The core idea: signatures and matching

Novice framing. A virus scanner is mostly a very fast "find this needle in this haystack" machine. The haystack is the file's bytes. The needles are signatures: short fingerprints of known-bad content. "Scanning" means checking whether any needle appears in the haystack. A match means "these bytes contain a known signature → report the threat by name."

Why it is harder than it sounds. There are millions of signatures and files can be large. You cannot search for each needle one at a time — that would be millions of passes over every file. The whole art of an antivirus engine is answering "do ANY of these millions of patterns appear?" in roughly one pass over the data. Every algorithm below is a way to make that one-pass promise true for a different kind of needle (literal bytes, hashes, regexes, fuzzy matches).

Two broad families of signature:

  1. Content signatures — "these specific bytes appear somewhere in the file." Handled by string-matching algorithms (BM, AC) and regex (PCRE).
  2. Hash signatures — "the whole file (or a region) has exactly this fingerprint." Handled by hashing + hash tables.

Sleelavirin's native core currently implements family #2 (hashing) plus a fuzzy variant; ClamAV implements both families. Everything else is machinery to do these fast, safely, and at scale.


<a name="part-b"></a>

Part B — String-matching algorithms

<a name="naive"></a>

Naive / brute-force matching

<a name="boyer-moore"></a>

Boyer–Moore (BM)

<a name="aho-corasick"></a>

Aho–Corasick (AC) — the main engine

<a name="trie"></a>

The trie (prefix tree)

<a name="automaton"></a>


<a name="part-c"></a>

Part C — Hashing

<a name="hashfn"></a>

Hash function

<a name="crypto-hash"></a>

Cryptographic hash (MD5 / SHA-256)

<a name="hashtable"></a>

Hash table / hash map

<a name="open-addressing"></a>

Open addressing & linear probing

<a name="fnv"></a>

FNV-1a (a fast non-cryptographic hash)

<a name="fuzzy"></a>

Fuzzy / similarity hashing & Hamming distance


<a name="part-d"></a>

Part D — Pattern description

<a name="pcre"></a>

Regular expressions & PCRE

<a name="byte-compare"></a>

Byte comparison

<a name="logical-sigs"></a>

Logical signatures & subsignatures

<a name="prefilter"></a>

Prefilter / Bloom-style filter


<a name="part-e"></a>

Part E — Structural concepts

<a name="compile-once"></a>

Compile-once / scan-many

<a name="root"></a>

The matcher "root" (in-memory database)

<a name="context"></a>

Scan context (threaded state)

<a name="fmap"></a>

fmap (byte-source abstraction)

<a name="recursion"></a>

Bounded recursion stack

<a name="mpool"></a>

Memory pool (arena allocation)

<a name="errcodes"></a>

Error-code control flow


<a name="part-f"></a>

Part F — How the pieces fit: a worked mental model

Imagine scanning one file, end to end, using the terms above:

  1. Identify the type (filetypes.c) → choose the matching root (§root) plus the generic root.
  2. Wrap the bytes in an fmap (§fmap) and push a layer on the recursion stack (§recursion).
  3. Run the prefilter (§prefilter) to find where any pattern could even start; skip the dead zones (keep a maxpatlen safety tail).
  4. Over the surviving bytes, run Boyer–Moore (§BM) for quick literal hits, then Aho–Corasick (§AC) to test all literal patterns in one pass, incrementing subsignature counters (§logical-sigs).
  5. Run byte-compare (§byte-compare) and fuzzy hash (§fuzzy) checks; finally run PCRE (§PCRE) for the expensive regex subsigs.
  6. Evaluate each logical signature's boolean expression over the collected counters and metadata (§logical-sigs). Separately, compute the file's SHA-256 and probe the hash table (§hashtable, §open-addressing) for an exact known-bad fingerprint.
  7. Any hit → record the threat name via the engine's "append virus" step, carried on the scan context (§context) and reported through an error code (§errcodes). Pop the recursion layer and continue with any sibling/child objects.

The throughline: compile everything once (§compile-once) into type-specific roots, then make one cheap pass per byte using automata (AC/BM) and O(1) hash probes, guarded by a prefilter, bounded by an explicit recursion stack, with all state on a single thread-safe context. That combination is what lets a scanner check millions of signatures against large files quickly and safely — and it is the design Sleelavirin follows at small scale, deferring full signature coverage to ClamAV as an external provider.