diff options
| author | DanConwayDev <DanConwayDev@protonmail.com> | 2026-01-12 21:51:57 +0000 |
|---|---|---|
| committer | DanConwayDev <DanConwayDev@protonmail.com> | 2026-01-12 21:51:57 +0000 |
| commit | c8ab2c9c294ae9401ff542d0eecc6606b7908412 (patch) | |
| tree | 2ecf96e0265c855940df149781a0a24640408e1e /docs | |
| parent | 70c577f10bbe150b6b13bec545dc8720ad005a64 (diff) | |
feat(config): add event blacklist to block all events from specific authors
Adds NGIT_EVENT_BLACKLIST option for blocking all events from specific npubs,
taking precedence over all other validation to enable comprehensive moderation
without affecting curation policy.
Key features:
- Simple npub-only format: <npub>,<npub>,...
- Checked FIRST before any other validation (including repository blacklist)
- Blocks ALL event types (announcements, state events, PRs, comments, etc.)
- Events never reach relay storage or purgatory
- Specific rejection reason for operator debugging
Implementation:
- Add EventBlacklistConfig struct with check() method
- Add NGIT_EVENT_BLACKLIST config option and event_blacklist_config() method
- Add config field to PolicyContext for policy access
- Add check_event_blacklist() to Nip34WritePolicy
- Check event blacklist first in admit_event() method (before any other validation)
- 4 new unit tests covering all blacklist behavior
Configuration synced across all four sources:
- src/config.rs: Core implementation with EventBlacklistConfig
- .env.example: Comprehensive documentation with examples
- docs/reference/configuration.md: Complete reference documentation
- nix/module.nix: NixOS module option with environment mapping
README updates:
- Add comprehensive "Curation & Moderation" section
- Document repository whitelists (GRASP-01 and GRASP-05 modes)
- Document repository and event blacklists with precedence order
- Add configuration table for all curation/moderation settings
- Provide real-world examples for different relay configurations
Testing:
- 4 new tests for event blacklist functionality
- All 336 library tests passing
- All 64 integration tests passing
- All 38 filter support tests passing
Verification:
- Repository blacklist confirmed to apply to sync (uses same admit_event flow)
- Sync events validated through process_event_static -> write_policy.admit_event
Use cases:
- Block spam/abusive users completely
- Prevent malicious actors from submitting any events
- Temporary blocks for investigation
- Moderation without affecting whitelist curation policy
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/reference/configuration.md | 92 |
1 files changed, 92 insertions, 0 deletions
diff --git a/docs/reference/configuration.md b/docs/reference/configuration.md index b90686e..66f39f1 100644 --- a/docs/reference/configuration.md +++ b/docs/reference/configuration.md | |||
| @@ -833,6 +833,98 @@ Blacklist does **not** affect NIP-11 metadata: | |||
| 833 | 833 | ||
| 834 | --- | 834 | --- |
| 835 | 835 | ||
| 836 | ### Event Blacklist | ||
| 837 | |||
| 838 | #### `NGIT_EVENT_BLACKLIST` | ||
| 839 | |||
| 840 | **Description:** Blacklist events from specific authors (npubs) | ||
| 841 | **Type:** Comma-separated list of npubs | ||
| 842 | **Default:** Empty (no events are blacklisted by author) | ||
| 843 | **Required:** No | ||
| 844 | |||
| 845 | **Format:** | ||
| 846 | - `npub1...` - Block all events from this author | ||
| 847 | |||
| 848 | **Precedence:** Event blacklist takes precedence over **ALL** other validation: | ||
| 849 | - Blacklisted events are rejected **before** any other policy checks | ||
| 850 | - Applies to all event types (announcements, state events, PRs, etc.) | ||
| 851 | - Events never reach purgatory (rejected immediately) | ||
| 852 | - Overrides repository blacklist, whitelists, and all other policies | ||
| 853 | |||
| 854 | **Examples:** | ||
| 855 | |||
| 856 | ```bash | ||
| 857 | # Block all events from specific author | ||
| 858 | NGIT_EVENT_BLACKLIST=npub1spam... | ||
| 859 | |||
| 860 | # Block events from multiple authors | ||
| 861 | NGIT_EVENT_BLACKLIST=npub1spam...,npub1abuser...,npub1troll... | ||
| 862 | ``` | ||
| 863 | |||
| 864 | **Rejection Reason:** | ||
| 865 | |||
| 866 | The event blacklist provides a specific rejection reason: | ||
| 867 | - **Format:** `"Event author <npub> is blacklisted"` | ||
| 868 | |||
| 869 | This reason helps operators understand why an event was rejected without needing to flag it in metadata. | ||
| 870 | |||
| 871 | **Behavior:** | ||
| 872 | |||
| 873 | Event blacklist is checked **first** before all other validation: | ||
| 874 | 1. Check event blacklist → Reject if author is blacklisted | ||
| 875 | 2. Check repository blacklist (for announcements) → Reject if matched | ||
| 876 | 3. Check event-type specific policies → Accept/Reject based on policy | ||
| 877 | 4. Process event normally | ||
| 878 | |||
| 879 | **Use Cases:** | ||
| 880 | |||
| 881 | ```bash | ||
| 882 | # Block spam/abusive users | ||
| 883 | NGIT_EVENT_BLACKLIST=npub1spammer...,npub1abuser... | ||
| 884 | |||
| 885 | # Block malicious actors | ||
| 886 | NGIT_EVENT_BLACKLIST=npub1malware...,npub1phisher... | ||
| 887 | |||
| 888 | # Temporary block for investigation | ||
| 889 | NGIT_EVENT_BLACKLIST=npub1suspicious... | ||
| 890 | ``` | ||
| 891 | |||
| 892 | **Comparison with Repository Blacklist:** | ||
| 893 | |||
| 894 | | Configuration | Scope | Checked When | Applies To | | ||
| 895 | |---------------|-------|--------------|------------| | ||
| 896 | | Event Blacklist | Author-based | **First** (before all policies) | **All events** from author | | ||
| 897 | | Repository Blacklist | Repo-based | Second (announcements only) | Specific repositories | | ||
| 898 | |||
| 899 | **Event Blacklist vs Repository Blacklist:** | ||
| 900 | |||
| 901 | ```bash | ||
| 902 | # Scenario: npub1alice is event-blacklisted | ||
| 903 | NGIT_EVENT_BLACKLIST=npub1alice... | ||
| 904 | |||
| 905 | # Result: | ||
| 906 | # - ALL events from npub1alice are rejected (announcements, PRs, etc.) | ||
| 907 | # - Events never reach relay or purgatory | ||
| 908 | # - Rejection: "Event author npub1alice... is blacklisted" | ||
| 909 | |||
| 910 | # Scenario: npub1alice/repo is repository-blacklisted | ||
| 911 | NGIT_REPOSITORY_BLACKLIST=npub1alice.../malware | ||
| 912 | |||
| 913 | # Result: | ||
| 914 | # - Only announcements for npub1alice.../malware are rejected | ||
| 915 | # - Other events from npub1alice are still processed normally | ||
| 916 | # - PRs/state events for different repos from npub1alice are accepted | ||
| 917 | ``` | ||
| 918 | |||
| 919 | **NIP-11 Impact:** | ||
| 920 | |||
| 921 | Event blacklist does **not** affect NIP-11 metadata: | ||
| 922 | - No `curation` field changes (blacklist is operational, not policy) | ||
| 923 | - Blacklist is transparent to clients (rejected with specific reason) | ||
| 924 | - Operators can use blacklist without advertising moderation | ||
| 925 | |||
| 926 | --- | ||
| 927 | |||
| 836 | ### Logging Configuration | 928 | ### Logging Configuration |
| 837 | 929 | ||
| 838 | #### `RUST_LOG` | 930 | #### `RUST_LOG` |