From 70c577f10bbe150b6b13bec545dc8720ad005a64 Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Mon, 12 Jan 2026 21:32:38 +0000 Subject: feat(config): add repository blacklist to block specific repos/npubs/identifiers Adds NGIT_REPOSITORY_BLACKLIST option for blocking repositories, taking precedence over all whitelists (archive and repository) to enable moderation without affecting curation policy. Key features: - Three blacklist formats: , /, - Blacklist checked first before any other validation - Overrides archive whitelist and repository whitelist - Specific rejection reasons based on match type (npub/identifier/both) - Not flagged in NIP-11 curation (operational, not policy) Implementation: - Add BlacklistConfig struct with check() method returning detailed reasons - Add NGIT_REPOSITORY_BLACKLIST config option and blacklist_config() method - Update validate_announcement() to check blacklist first with specific reasons - 12 new unit tests covering all blacklist behavior and precedence Configuration synced across all four sources: - src/config.rs: Core implementation with BlacklistConfig - .env.example: Comprehensive documentation with examples - docs/reference/configuration.md: Complete reference documentation - nix/module.nix: NixOS module option with environment mapping Testing: - 12 new tests for blacklist functionality (config + validation) - All 332 library tests passing - All 38 integration tests passing Use cases: - Block spam/malware repos by identifier - Block abusive users by npub - Block specific problematic repos by npub/identifier - Temporary blocks for investigation --- nix/module.nix | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'nix/module.nix') diff --git a/nix/module.nix b/nix/module.nix index d5dfd88..cfac0fc 100644 --- a/nix/module.nix +++ b/nix/module.nix @@ -224,6 +224,19 @@ let ''; }; + repositoryBlacklist = mkOption { + type = types.listOf types.str; + default = [ ]; + example = [ "npub1spam..." "npub1alice.../bad-repo" "malware" ]; + description = '' + Repository blacklist for blocking specific repositories/pubkeys/identifiers. + Blacklist takes precedence over ALL whitelists (archive and repository). + Formats: , /, + Blacklisted repos are rejected with specific reasons (npub/identifier/both). + Does not affect NIP-11 curation field (operational, not curation policy). + ''; + }; + user = mkOption { type = types.str; default = "ngit-grasp-${name}"; @@ -267,6 +280,7 @@ let NGIT_ARCHIVE_ALL = toString cfg.archiveAll; NGIT_ARCHIVE_WHITELIST = concatStringsSep "," cfg.archiveWhitelist; NGIT_REPOSITORY_WHITELIST = concatStringsSep "," cfg.repositoryWhitelist; + NGIT_REPOSITORY_BLACKLIST = concatStringsSep "," cfg.repositoryBlacklist; RUST_LOG = cfg.logLevel; } // optionalAttrs (cfg.relayName != null) { NGIT_RELAY_NAME = cfg.relayName; -- cgit v1.2.3