Files
MichilisandClaude Opus 5.5 44d61df9c9 tests: golden output baseline and default rejection messages
Phase 0 of PLAN.md: pin today's write-policy behavior before the Azzamo
work starts, so every later phase can prove it changed nothing.

- tests/golden.rs runs the binary on test/golden.inputs with a frozen
  copy of the write-side config (test/golden.toml) and compares stdout
  line by line with test/golden.expected. The inputs extend test/inputs
  to cover kinds messages, content shadow rejects (incl. homoglyphs),
  rate limiting and the rate-limit ban.
- Exact-string tests for every default rejection message.
- Rename test_run_filters_shadow_reject to test_protected_events_reject
  (it asserts Reject).
- Add PLAN.md.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-29 06:54:30 +00:00

72 lines
3.3 KiB
TOML
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Frozen copy of the write-side noteguard.toml as of e5a3e47, used by tests/golden.rs.
# Do not edit: it pins today's behavior so later changes can prove they kept it.
pipeline = ["protected_events", "kinds", "content", "whitelist", "ratelimit"]
[filters.ratelimit]
posts_per_minute = 8
whitelist = ["127.0.0.1"]
message = "rate-limited: you note too much"
# IP-ban persistent offenders: after this many *consecutive* rate-limit
# rejections from the same IP (a streak broken by any accepted post), reject
# everything from that IP for `ban_duration_secs`. Omit `ban_after` to disable
# banning entirely (the filter then only ever rate-limits).
ban_after = 10
ban_duration_secs = 3600 # one hour
ban_message = "banned: too many rate-limit violations, try again later"
# Substring blocklist. Matching is homoglyph- and case-insensitive: both the
# note content and each term are folded to their UTS #39 confusables skeleton
# and lowercased before comparison, so Cyrillic/look-alike spoofs like
# "Dаmus Аirdrop" (Cyrillic а/А) are caught by the plain "Damus Airdrop" entry.
[filters.content]
filters = [
"https://cdn.nostr.build/i/some-spammy-or-abusive-image-image.png",
"Damus Airdrop",
]
# IP-ban repeat offenders (same knobs as `filters.ratelimit`). Content
# violations accrue *cumulatively* per IP — unlike ratelimit's consecutive
# streak, a clean note does not reset the count — and once they cross
# `ban_after`, every note from that IP is silently shadow-rejected for
# `ban_duration_secs`. Omit `ban_after` to disable banning (match-only, as
# before). `ban_message` is unused here since the ban is a stealth shadow-reject.
ban_after = 5
ban_duration_secs = 3600 # one hour
# ---------------------------------------------------------------------------
# Cloudflare edge-banning (optional; requires the `cloudflare` build feature)
#
# When present, every BanTracker ban — from `filters.ratelimit` OR
# `filters.content` — is *also* pushed to a Cloudflare WAF IP list for the ban's
# duration, then removed when it expires. A blocked IP is then dropped at
# Cloudflare's edge before it ever reaches the relay.
#
# One-time setup on your side: create an IP list and a WAF custom rule that
# blocks it, e.g. expression `(ip.src in $<your_list>)` with action "block".
# noteguard only manages the list's membership, not the rule.
#
# The API token is read from the CLOUDFLARE_API_TOKEN environment variable (it
# needs Account Filter Lists: Edit), never from this file. Omit this whole
# section to disable edge-banning; bans then stay relay-local as before.
# [cloudflare]
# account_id = "<cloudflare account id>"
# list_id = "<ip list id>"
# comment = "noteguard auto-ban" # optional; stamped on each list item
# timeout_secs = 10 # optional; per-request HTTP timeout
# api_base = "https://api.cloudflare.com/client/v4" # optional override
[filters.whitelist]
pubkeys = ["16c21558762108afc34e4ff19e4ed51d9a48f79e0c34531efc423d21ab435e93"]
ips = ["127.0.0.1"]
[filters.kinds]
kinds = [30065, 1064, 34550, 4550]
[filters.kinds.messages]
30065 = "blocked: files on nostr is dumb"
1064 = "blocked: files on nostr is dumb"
34550 = "blocked: please use a dedicated relay for moderated communities"
4550 = "blocked: please use a dedicated relay for moderated communities"
[filters.protected_events]