Skip to content

State, storage and deduplication

7 min readRecon Atlas

Without memory, a pipeline shows you the same finding every night. State is what your pipeline remembers between runs. Keep it in a few plain sorted files, write each run into its own dated folder, and key every finding on a fingerprint that includes what the response actually contained. Plain files and shell tools carry most hunters through their first year.


A stateless script treats every run as the first. That is why the recon monitoring setup needs anew and a master list: without them it would alert on every host every day. State is the small set of files that lets run 50 know what runs 1 to 49 already did.

There are two kinds of files in a pipeline, and keeping them apart is most of the discipline.

Kind Examples Written Rule
Run output runs/2026-11-13T021700Z/httpx.json Once, by one run Never edited after the run ends
State state/hosts.txt, state/ledger.txt, state/suppress.txt Appended or rewritten by each run Sorted, deduplicated, backed up, small

Earlier recon work used one folder per target domain under ~/recon/. A pipeline works per program, because a program can own many roots, so this pipeline guide uses one folder per program under a pipeline root. Keep ~/recon/ for manual work; the pipeline lives beside it.

  • Directory~/pipeline/ the pipeline root, PIPE_ROOT
    • Directorybin/ auto-triage.sh, inscope, guarded wrappers
      • …
    • Directoryetc/ score.conf, shared defaults
      • …
    • Directorytests/ test-fail-closed.sh
      • …
    • Directoryprograms/
      • Directoryexample/ one program, PROGRAM=example
        • Directoryscope/ in-scope.txt, out-of-scope.txt, policy.env
          • …
        • Directorystate/ hosts.txt, ledger.txt, suppress.txt, cve-tech.txt, heartbeat
          • …
        • Directoryruns/ one dated folder per run, written once
          • …
        • current symlink to the newest complete run
        • Directoryevidence/ one folder per finding fingerprint
          • …
        • Directorydigest/ queue.tsv and sent digests
          • …
        • Directoryreports/ findings you confirmed by hand
          • …
        • notes.md
Terminal window
# Create the layout for a new program
mkdir -p ~/pipeline/{bin,etc,tests} ~/pipeline/programs/example/{scope,state,runs,evidence,digest,reports}

Each run writes into a new folder named by a UTC timestamp down to the second, for example runs/2026-11-13T021700Z/. When the run finishes cleanly, a symlink named current is moved to point at it. The recon workflow does the same with runs/latest.

Why both:

  • Dated folders give you history. You can diff Tuesday against Monday, or prove to a program what you sent on a given night.
  • current gives every other script and your own muscle memory one stable path. Your morning review always starts at programs/example/current/queue.tsv.
  • Moving current only at the end means a run that crashed halfway never becomes “current”. The last good run stays the reference.

A folder name with only minutes is not unique enough. The worked pipeline’s own test found that two runs in the same minute shared a folder and re-sent old alerts. Use seconds, and refuse to write into a folder that already exists.

Terminal window
# Hosts in the newest run that were not in the previous run
cd ~/pipeline/programs/example/runs && prev=$(ls -1 | tail -2 | head -1) && comm -13 "$prev/hosts.txt" "$(ls -1 | tail -1)/hosts.txt"
Terminal window
# Hosts that disappeared since the previous run (often more interesting than you think)
comm -23 "$prev/hosts.txt" "$(ls -1 | tail -1)/hosts.txt"
# comm -13 of the previous hosts file against the newest, example output
api-v2.example.com
staging-auth.example.com

Those two names are in the newest hosts.txt and absent from the previous one. That is the set difference of the two files. It does not show that the company just created them, and it does not show a bug on them.

Terminal window
# Status or title changes for the same URL between two httpx runs
diff <(jq -r '[.url,.status_code,.title]|@tsv' "$prev/httpx.json" | sort) <(jq -r '[.url,.status_code,.title]|@tsv' ../current/httpx.json | sort)
Tool Use it for Needs sorted input
anew “Add new lines to a master file, print only the new ones.” The core of every delta No
comm Set operations on two files: only in A, only in B, in both Yes, sort first with the same locale
diff Seeing changed lines in context, by eye No, but sorted is easier to read
sort -u Building and keeping state files deduplicated Not applicable

comm silently gives wrong answers on unsorted input. Pin the locale in scripts with export LC_ALL=C so sort and comm agree on order.

The ledger is a permanent, sorted list of finding fingerprints the pipeline has already delivered for a program, one per line. It answers one question: have I shown this finding to the human before?

# state/ledger.txt: one 16-character fingerprint per line, sorted
0b7e44c1d9a2f310
2d7bbe2f093b189d
e0f8adc731186deb

The ledger rules:

  1. One ledger per program. A finding on program A says nothing about program B.
  2. Append only after delivery. Record the fingerprint after the alert is sent or the digest line is queued, never before. If the alert fails, the next run tries again. This is called at-least-once delivery: you may occasionally see something twice, but you never silently miss it.
  3. Never edit by hand to hide things. Hiding is what the suppression list is for, and it records why. See Part 5.
Terminal window
# Findings in this run whose fingerprint is not yet in the ledger (both files sorted)
comm -13 state/ledger.txt <(cut -f5 current/triage.tsv | sort -u)
Terminal window
# Add delivered fingerprints and keep the ledger sorted and unique
cut -f5 current/triage.tsv | sort -u -o state/ledger.txt - state/ledger.txt

A fingerprint is a short hash of the fields that make a finding “the same finding” across runs. Choosing those fields decides how much noise you see.

Fingerprint built from Problem Verdict
URL only Two different bugs on one URL collapse into one Too coarse
URL plus template ID Stable, but a page that changed from leaking DB_PASSWORD to leaking AWS_SECRET_ACCESS_KEY looks identical Weak
Template ID plus host and path plus matcher name plus the sorted extracted values A change in what leaked produces a new fingerprint, so you see it Stronger. The worked pipeline uses this
Plus timestamp, response length or full body hash Changes every run, so the ledger never matches and everything alerts forever Too fine

The strong version keys on what the response actually contained (Nuclei’s extracted-results and matcher-name), not only where it was found. Scheme is stripped so http and https variants of the same leak match.

Terminal window
# Build the fingerprint key for each Nuclei finding, then hash it to 16 hex characters
jq -r '[.["template-id"], (.["matched-at"] // "" | sub("^[a-z]+://"; "")), (.["matcher-name"] // ""), ((.["extracted-results"] // []) | sort | join(","))] | join("|")' nuclei.jsonl | while IFS= read -r k; do printf '%s\n' "$k" | sha1sum | cut -c1-16; done

Sixteen hex characters is 64 bits, plenty to avoid collisions at hunter scale. Check one line of your own Nuclei output for these field names first; they have changed between Nuclei versions.

Plain sorted text files plus sort, comm, anew and jq handle more than people expect. sort -u on a million short lines takes seconds on a small VPS. Move when you hit a real limit, not before.

Signal Approximate threshold Move to
Ledger or host list grows past a few million lines and stages slow down noticeably Millions of lines, not thousands SQLite
You keep writing three-file joins in awk to answer one question When the join logic is harder to read than SQL would be SQLite
You need history queries: when did this host first appear, how often did this title change When you ask these weekly SQLite
Two machines write state at the same time When you run a fleet (Part 10) Postgres, or one writer and files everywhere else
You share state with another hunter When you collaborate Postgres or a shared repo with one writer

All thresholds are approximate. They depend on disk speed, how often stages run, and how patient you are. SQLite is a single file with no server, which keeps backups boring.

Terminal window
# Load the ledger into SQLite when you outgrow text (one table, one column)
sqlite3 state/pipeline.db "CREATE TABLE IF NOT EXISTS ledger(fp TEXT PRIMARY KEY, first_seen TEXT DEFAULT CURRENT_TIMESTAMP);" && sed "s/.*/INSERT OR IGNORE INTO ledger(fp) VALUES('&');/" state/ledger.txt | sqlite3 state/pipeline.db

For most hunters in their first year, files win: you can read them, grep them, diff them and back them up with cp.

Your pipeline root is a good Git repository, if you are careful about what goes in it.

Commit Ignore Why
bin/, etc/, tests/ Code and config. You want history and rollback
scope/ for each program A dated record of what you believed was in scope, useful when a policy changes
state/ledger.txt, state/suppress.txt Small, valuable, slow to rebuild
runs/ Large and reproducible. Back up selectively instead
evidence/ Contains target responses, possibly sensitive data. Never push it to a hosted remote
*.env with secrets, ~/.config/* provider files Secrets
state/.lock, state/heartbeat Runtime files
~/pipeline/.gitignore
programs/*/runs/
programs/*/evidence/
programs/*/digest/
programs/*/current
programs/*/state/.lock
programs/*/state/heartbeat
secrets.env
*.db-journal
Terminal window
# Commit state after a review session, with a message that says what changed
cd ~/pipeline && git add -A && git commit -m "example: suppress 3 accepted risks, scope update 2026-11-13"

Why keys never go in the repo, even a private one

Section titled “Why keys never go in the repo, even a private one”

A private repository is still a copy of your keys on someone else’s servers, in every clone, in every backup, and in Git history forever even after you delete the file. A leaked notify webhook lets a stranger post into your channel. A leaked API key for a paid data source runs up your bill. Keep secrets in one file outside the repo, readable only by you.

Terminal window
# Secrets live outside the repo, readable only by your user
install -m 600 /dev/null ~/.config/pipeline/secrets.env

If you ever commit a secret, rotate it. Removing it from history is not enough, because you cannot know who already pulled it.

Next, run the stages on a schedule without overlaps or hangs in Scheduling and process management.

Connections5 backlinks · 5 outgoingFull graph →
Open local graph around this page
Open full graph →
Click a node to open · Drag to reposition · Scroll to zoom

Recon AtlasFor authorized testing only. Your scope is the map edge.