# Correlation rules

After a scan, rules run over the whole event graph and raise **findings** — the
"so what" on top of the raw data. `spiderfootplus rules` lists them; each has a risk
(`HIGH`, `MEDIUM`, `LOW`, `INFO`).

A rule is a YAML file. It **collects** events that match some criteria, optionally
**aggregates** them into buckets (one finding per bucket), optionally runs
**analysis** passes (thresholds, outliers), and renders a **headline**.

```yaml
id: weak_security_headers
meta:
  name: Multiple security headers missing
  risk: MEDIUM
collections:
  - collect:
      - method: exact
        field: type
        value: SECURITY_HEADER_MISSING
      - method: regex
        field: data
        value: not ^(No SPF|No DMARC|DMARC policy|SPF allows)
aggregation:
  field: entity.data        # one finding per host
analysis:
  - method: threshold       # only if the host is missing 3+ headers
    field: type
    minimum: 3
headline: "Multiple security headers missing: {entity.data}"
```

Field paths can walk the graph: `type`, `data`, `module`, and `source.*`,
`entity.*` (nearest entity ancestor) or `child.*`. Regex matchers are anchored at
the start; prefix a value with `not ` to negate it.

To write your own, see [Write a correlation rule](https://spiderfootplus.com/docs/guides/writing-a-correlation-rule).
